Fix scale keyframes defaulting to 0

This commit is contained in:
JannisX11 2020-10-12 14:40:42 +02:00
parent 5d11899da4
commit 9ee8deb082
2 changed files with 13 additions and 9 deletions

View File

@ -21,9 +21,9 @@ class KeyframeDataPoint {
return copy;
}
}
new Property(KeyframeDataPoint, 'molang', 'x', {label: 'X', condition: point => point.keyframe.transform});
new Property(KeyframeDataPoint, 'molang', 'y', {label: 'Y', condition: point => point.keyframe.transform});
new Property(KeyframeDataPoint, 'molang', 'z', {label: 'Z', condition: point => point.keyframe.transform});
new Property(KeyframeDataPoint, 'molang', 'x', { label: 'X', condition: point => point.keyframe.transform, default: point => (point && point.keyframe.channel == 'scale' ? '1' : '0') });
new Property(KeyframeDataPoint, 'molang', 'y', { label: 'Y', condition: point => point.keyframe.transform, default: point => (point && point.keyframe.channel == 'scale' ? '1' : '0') });
new Property(KeyframeDataPoint, 'molang', 'z', { label: 'Z', condition: point => point.keyframe.transform, default: point => (point && point.keyframe.channel == 'scale' ? '1' : '0') });
new Property(KeyframeDataPoint, 'string', 'effect', {label: tl('data.effect'), condition: point => ['particle', 'sound'].includes(point.keyframe.channel)});
new Property(KeyframeDataPoint, 'string', 'locator',{label: tl('data.locator'), condition: point => 'particle' == point.keyframe.channel});
new Property(KeyframeDataPoint, 'molang', 'script', {label: tl('timeline.pre_effect_script'), condition: point => ['particle', 'timeline'].includes(point.keyframe.channel), default: ''});

View File

@ -37,7 +37,7 @@ class Property {
if (this.isMolang) {
Object.defineProperty(target_class.prototype, `${name}_string`, {
get() {
return typeof this[name] == 'number' ? trimFloatNumber(this[name]) || scope.default : this[name];
return typeof this[name] == 'number' ? trimFloatNumber(this[name]) || scope.getDefault(this) : this[name];
},
set(val) {
this[name] = val;
@ -53,6 +53,13 @@ class Property {
if (options.label) this.label = options.label;
if (options.options) this.options = options.options;
}
getDefault(instance) {
if (typeof this.default == 'function') {
return this.default(instance);
} else {
return this.default;
}
}
merge(instance, data) {
if (data[this.name] == undefined || !Condition(this.condition, instance)) return;
@ -90,11 +97,8 @@ class Property {
}
reset(instance) {
if (instance[this.name] == undefined && !Condition(this.condition, instance)) return;
if (typeof this.default == 'function') {
var dft = this.default(instance);
} else {
var dft = this.default;
}
var dft = this.getDefault(instance)
if (this.isArray || this.isVector || this.isVector2) {
if (instance[this.name] instanceof Array == false) {
instance[this.name] = [];