mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Remove conditional chaining to increase compatiblity
This commit is contained in:
parent
506f40ec8c
commit
a17035c812
@ -54,8 +54,8 @@ class Animation {
|
||||
let uuid = isUUID(key) && key;
|
||||
if (!uuid) {
|
||||
let lowercase_bone_name = key.toLowerCase();
|
||||
uuid = Group.all.find(group => group.name.toLowerCase() == lowercase_bone_name)?.uuid;
|
||||
if (!uuid) uuid = guid();
|
||||
let group_match = Group.all.find(group => group.name.toLowerCase() == lowercase_bone_name)
|
||||
uuid = group_match ? group_match.uuid : guid();
|
||||
}
|
||||
animator = this.animators[uuid] = new BoneAnimator(uuid, this, animator_blueprint.name)
|
||||
}
|
||||
@ -978,8 +978,8 @@ class EffectAnimator extends GeneralAnimator {
|
||||
this.sound.forEach(kf => {
|
||||
var diff = kf.time - Timeline.time;
|
||||
if (diff >= 0 && diff < (1/60) * (Timeline.playback_speed/100)) {
|
||||
if (kf.data_points[0]?.file && !kf.cooldown) {
|
||||
var media = new Audio(kf.data_points[0]?.file);
|
||||
if (kf.data_points[0].file && !kf.cooldown) {
|
||||
var media = new Audio(kf.data_points[0].file);
|
||||
media.playbackRate = Math.clamp(Timeline.playback_speed/100, 0.1, 4.0);
|
||||
media.volume = Math.clamp(settings.volume.value/100, 0, 1);
|
||||
media.play().catch(() => {});
|
||||
@ -1015,9 +1015,9 @@ class EffectAnimator extends GeneralAnimator {
|
||||
if (locator && locator.parent instanceof Group) {
|
||||
locator.parent.mesh.add(emitter.local_space);
|
||||
emitter.local_space.position.set(
|
||||
locator.from[0] - (locator.parent.origin?.[0] || 0),
|
||||
locator.from[1] - (locator.parent.origin?.[1] || 0),
|
||||
locator.from[2] - (locator.parent.origin?.[2] || 0)
|
||||
locator.from[0] - ((locator.parent.origin && locator.parent.origin[0]) || 0),
|
||||
locator.from[1] - ((locator.parent.origin && locator.parent.origin[1]) || 0),
|
||||
locator.from[2] - ((locator.parent.origin && locator.parent.origin[2]) || 0)
|
||||
)
|
||||
emitter.parent_mode = 'locator';
|
||||
} else {
|
||||
@ -1035,10 +1035,10 @@ class EffectAnimator extends GeneralAnimator {
|
||||
startPreviousSounds() {
|
||||
if (!this.muted.sound) {
|
||||
this.sound.forEach(kf => {
|
||||
if (kf.data_points[0]?.file && !kf.cooldown) {
|
||||
if (kf.data_points[0].file && !kf.cooldown) {
|
||||
var diff = kf.time - Timeline.time;
|
||||
if (diff < 0 && Timeline.waveforms[kf.data_points[0]?.file] && Timeline.waveforms[kf.data_points[0]?.file].duration > -diff) {
|
||||
var media = new Audio(kf.data_points[0]?.file);
|
||||
if (diff < 0 && Timeline.waveforms[kf.data_points[0].file] && Timeline.waveforms[kf.data_points[0].file].duration > -diff) {
|
||||
var media = new Audio(kf.data_points[0].file);
|
||||
media.playbackRate = Math.clamp(Timeline.playback_speed/100, 0.1, 4.0);
|
||||
media.volume = Math.clamp(settings.volume.value/100, 0, 1);
|
||||
media.currentTime = -diff;
|
||||
@ -1311,9 +1311,10 @@ const Animator = {
|
||||
Animator.updateMotionTrailScale();
|
||||
},
|
||||
updateMotionTrailScale() {
|
||||
if (!Preview.selected) return;
|
||||
Animator.motion_trail.children.forEach((object) => {
|
||||
if (object.isLine) return;
|
||||
let scale = Preview.selected?.calculateControlScale(object.position) * 0.6;
|
||||
let scale = Preview.selected.calculateControlScale(object.position) * 0.6;
|
||||
object.scale.set(scale, scale, scale)
|
||||
})
|
||||
},
|
||||
|
@ -671,7 +671,7 @@ BARS.defineActions(function() {
|
||||
resource_id: 'animation_particle',
|
||||
extensions: ['json'],
|
||||
type: 'Bedrock Particle',
|
||||
startpath: Timeline.selected[0].data_points[0]?.file
|
||||
startpath: Timeline.selected[0].data_points[0].file
|
||||
}, function(files) {
|
||||
|
||||
let {path} = files[0];
|
||||
@ -691,7 +691,7 @@ BARS.defineActions(function() {
|
||||
resource_id: 'animation_audio',
|
||||
extensions: ['ogg'],
|
||||
type: 'Audio File',
|
||||
startpath: Timeline.selected[0].data_points[0]?.file
|
||||
startpath: Timeline.selected[0].data_points[0].file
|
||||
}, function(files) {
|
||||
|
||||
// Todo: move to panel
|
||||
|
@ -397,7 +397,7 @@ const Timeline = {
|
||||
drag: function(event, ui) {
|
||||
var difference = Math.clamp((ui.position.left - ui.originalPosition.left - 8) / Timeline.vue._data.size, -256, 256);
|
||||
let [min, max] = Timeline.dragging_range;
|
||||
let id = event.target?.id;
|
||||
let id = event.target && event.target.id;
|
||||
let target = Timeline.selected.find(kf => kf.uuid == id);
|
||||
if (event.ctrlKey) {
|
||||
var time_factor = (target && target.time_before < (min + max) / 2)
|
||||
@ -529,7 +529,7 @@ const Timeline = {
|
||||
if (Animation.selected && Timeline.time < (Animation.selected.length||1e3)) {
|
||||
|
||||
var new_time;
|
||||
if (Animation.selected?.anim_time_update) {
|
||||
if (Animation.selected && Animation.selected.anim_time_update) {
|
||||
var new_time = Animator.MolangParser.parse(Animation.selected.anim_time_update);
|
||||
}
|
||||
if (new_time == undefined || new_time <= Timeline.time) {
|
||||
|
@ -148,10 +148,10 @@ const Blockbench = {
|
||||
Blockbench.showQuickMessage(message)
|
||||
}
|
||||
},
|
||||
showMessageBox(options, cb) {
|
||||
showMessageBox(options = 0, cb) {
|
||||
|
||||
if (options.confirm === undefined) options.confirm = 0
|
||||
if (options.cancel === undefined) options.cancel = options?.buttons?.length ? options.buttons.length-1 : 0;
|
||||
if (options.cancel === undefined) options.cancel = (options.buttons && options.buttons.length) ? options.buttons.length-1 : 0;
|
||||
if (!options.buttons) options.buttons = [tl('dialog.ok')]
|
||||
|
||||
if (options.translateKey) {
|
||||
|
@ -84,7 +84,7 @@ class BarItem {
|
||||
if (!tooltip.length) return;
|
||||
|
||||
tooltip.css('margin-left', '0')
|
||||
var offset = tooltip?.offset()
|
||||
var offset = tooltip && tooltip.offset()
|
||||
offset.right = offset.left + parseInt(tooltip.css('width').replace(/px/, '')) - $(window).width()
|
||||
|
||||
if (offset.right > 4) {
|
||||
@ -95,7 +95,7 @@ class BarItem {
|
||||
if (!description.length) return;
|
||||
|
||||
description.css('margin-left', '-5px')
|
||||
var offset = description?.offset()
|
||||
var offset = description.offset()
|
||||
offset.right = offset.left + parseInt(description.css('width').replace(/px/, '')) - $(window).width()
|
||||
|
||||
if (offset.right > 4) {
|
||||
|
@ -136,7 +136,7 @@ window.BedrockEntityManager = {
|
||||
},
|
||||
initAnimations() {
|
||||
|
||||
var anim_list = BedrockEntityManager?.client_entity?.description?.animations
|
||||
var anim_list = BedrockEntityManager.client_entity && BedrockEntityManager.client_entity.description && BedrockEntityManager.client_entity.description.animations;
|
||||
if (anim_list instanceof Object) {
|
||||
let animation_names = [];
|
||||
for (var key in anim_list) {
|
||||
|
@ -156,7 +156,7 @@ const Templates = {
|
||||
}
|
||||
|
||||
function getIdentifier() {
|
||||
return Project.geometry_name?.replace(/[\s-]+/g, '_') || 'custom_model';
|
||||
return (Project.geometry_name && Project.geometry_name.replace(/[\s-]+/g, '_')) || 'custom_model';
|
||||
}
|
||||
|
||||
var codec = new Codec('modded_entity', {
|
||||
|
@ -8,7 +8,7 @@ var codec = new Codec('optifine_entity', {
|
||||
type: 'json',
|
||||
extensions: ['jem'],
|
||||
condition(file) {
|
||||
return file?.models != undefined;
|
||||
return file && file.models != undefined;
|
||||
}
|
||||
},
|
||||
compile(options) {
|
||||
|
@ -322,7 +322,7 @@ class Codec {
|
||||
Codec.getAllExtensions = function() {
|
||||
let extensions = [];
|
||||
for (var id in Codecs) {
|
||||
if (Codecs[id].load_filter?.extensions) {
|
||||
if (Codecs[id].load_filter && Codecs[id].load_filter.extensions) {
|
||||
extensions.safePush(...Codecs[id].load_filter.extensions);
|
||||
}
|
||||
}
|
||||
|
@ -824,8 +824,9 @@
|
||||
this.isIKMovement = function() {
|
||||
return Modes.animate
|
||||
&& Toolbox.selected.id === 'move_tool'
|
||||
&& Group.selected?.ik_enabled
|
||||
&& Group.selected?.ik_chain_length
|
||||
&& Group.selected
|
||||
&& Group.selected.ik_enabled
|
||||
&& Group.selected.ik_chain_length
|
||||
&& Group.selected.parent instanceof Group;
|
||||
}
|
||||
this.center = function() {
|
||||
|
@ -383,8 +383,9 @@ const Vertexsnap = {
|
||||
Vertexsnap.step1 = true
|
||||
},
|
||||
updateVertexSize: function() {
|
||||
if (!Preview.selected) return;
|
||||
Vertexsnap.vertexes.children.forEach(function(v,i) {
|
||||
let scale = Preview.selected?.calculateControlScale(v.position) * 0.6;
|
||||
let scale = Preview.selected.calculateControlScale(v.position) * 0.6;
|
||||
v.scale.set(scale, scale, scale);
|
||||
})
|
||||
}
|
||||
|
@ -1807,7 +1807,7 @@ GLTFExporter.prototype = {
|
||||
function processNode( object ) {
|
||||
|
||||
if (object.no_export) return null;
|
||||
if (OutlinerElement.uuids[object.name]?.export == false) return null;
|
||||
if (OutlinerElement.uuids[object.name] && OutlinerElement.uuids[object.name].export == false) return null;
|
||||
|
||||
if ( ! outputJSON.nodes ) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user