Auto-load particle and sound files when loading from bbmodel

Closes #1309
This commit is contained in:
JannisX11 2023-11-03 00:05:31 +01:00
parent 8abf744639
commit d1d73231f6
3 changed files with 18 additions and 1 deletions

View File

@ -1383,6 +1383,9 @@
stroke-width: 0;
pointer-events: initial;
}
.keyframe .keyframe_waveform > polygon:hover {
fill: var(--color-accent);
}
#timeline_graph_editor {
position: absolute;

View File

@ -9,9 +9,23 @@ class KeyframeDataPoint {
if (data.values) {
Object.assign(data, data.values)
}
let file_value_before = this.file;
for (var key in KeyframeDataPoint.properties) {
KeyframeDataPoint.properties[key].merge(this, data)
}
if (isApp && data.file && !file_value_before) {
if (this.keyframe.channel == 'sound' && !Timeline.waveforms[this.file]) {
Timeline.visualizeAudioFile(this.file);
} else if (this.keyframe.channel == 'particle') {
try {
Blockbench.read([this.file], {}, (files) => {
Animator.loadParticleEmitter(this.file, files[0].content);
})
} catch (err) {
console.log('Could not load particle effect for', this.file)
}
}
}
}
getUndoCopy() {
var copy = {}

View File

@ -71,7 +71,7 @@ class Property {
if (typeof this.default == 'function') {
return this.default(instance);
} else if (this.isArray) {
return this.default.slice();
return this.default ? this.default.slice() : [];
} else if (this.isObject) {
return Object.keys(this.default).length ? JSON.parse(JSON.stringify(this.default)) : {};
} else {