sound library
This commit is contained in:
@@ -31,7 +31,7 @@ function harness(capture = false) {
|
||||
add(undo) { assert.equal(undo, false); Texture.all.push(this); }
|
||||
}
|
||||
const context = {
|
||||
Buffer, Timeline: { animation: null },
|
||||
Buffer, Blob, URL: { createObjectURL() { return 'blob:import-preview'; }, revokeObjectURL() {} }, Timeline: { animation: null },
|
||||
Project: { uuid: 'original' }, Group, Cube: { all: [] }, Texture, Outliner: { elements: [] },
|
||||
Plugin: { register() {} }, requireNativeModule: require,
|
||||
localStorage: { getItem: (key) => storage.get(key), setItem: (key, value) => storage.set(key, value) },
|
||||
@@ -49,7 +49,10 @@ function harness(capture = false) {
|
||||
Animator: {
|
||||
loadFile(file, names) {
|
||||
context.loadedAnimation = JSON.parse(file.content);
|
||||
context.Animation.all = names.map((name) => ({ name, select() {} }));
|
||||
context.Animation.all = names.map((name) => ({ name, select() {}, animators: { effects: { sound:
|
||||
Object.entries(context.loadedAnimation.animations[name]?.sound_effects || {}).map(([time, cues]) => ({
|
||||
time: Number(time), data_points: Array.isArray(cues) ? cues : [cues],
|
||||
})) } } }));
|
||||
},
|
||||
},
|
||||
Animation: { all: [] }, Canvas: { updateAll() {}, updateView() {} },
|
||||
@@ -313,7 +316,8 @@ test('complete import finds model texture in cached assets and uses its PNG dime
|
||||
importing.commitAutomaticImport(h.context.importedPlan);
|
||||
assert.equal(importing.context.Texture.all[0].uv_width, 32);
|
||||
assert.equal(importing.context.Texture.all[0].uv_height, 64);
|
||||
assert.equal(JSON.parse(importing.context.Project.animationdirector_actor_uv_basis)['1'].width, 32);
|
||||
assert.equal(JSON.parse(importing.context.Project.animationdirector_actor_uv_basis)['1'].width, 64,
|
||||
'The actor retains its geometry basis; each textured cube tracks its own normalization');
|
||||
assert.equal(JSON.parse(importing.context.Project.multiactor_actor_textures)['1'], row.defaultTexture);
|
||||
});
|
||||
|
||||
@@ -494,10 +498,13 @@ test('missing models can be supplied manually, and their locally supplied textur
|
||||
|
||||
test('batch import uses a new project, one undo entry, actor prefixes and texture override bindings', () => {
|
||||
const h = harness();
|
||||
h.storage.set('animationdirector_sound_source', path.resolve(__dirname, '../../NON/src/main/resources'));
|
||||
const plan = { parsed: { animationId: 'example' }, blockEntry: null,
|
||||
propEntries: { '["example","wolf","right",0]': { animation: 'example', item: 'minecraft:carrot', mode: 'item' } },
|
||||
definition: { actors: [{ label: 'wolf', entity_types: ['minecraft:wolf'] }], animators: ['Creator'], stages: [{ stage: 1 }] },
|
||||
imported: { stageNames: ['example.p1'], fileObj: { animations: { 'example.p1': { bones: { actor1_body: { rotation: [1, 2, 3] } } } } } },
|
||||
imported: { stageNames: ['example.p1'], fileObj: { animations: { 'example.p1': {
|
||||
bones: { actor1_body: { rotation: [1, 2, 3] } }, sound_effects: { '0.5': { effect: 'reactiveimpact' } },
|
||||
} } } },
|
||||
rows: [{ label: 'wolf', json: { afw_bone_textures: { body: 'test:textures/wolf.png' } },
|
||||
geo: { bones: [{ name: 'body' }] }, defaultTexture: 'test:textures/wolf.png',
|
||||
textures: new Map([['test:textures/wolf.png', { file: 'wolf.png' }]]) }] };
|
||||
@@ -511,6 +518,9 @@ test('batch import uses a new project, one undo entry, actor prefixes and textur
|
||||
assert.equal(override[h.context.Group.all[0].uuid].texture, 'test:textures/wolf.png');
|
||||
assert.ok(JSON.parse(h.context.Project.animationdirector_animdef_definitions).example);
|
||||
assert.equal(JSON.parse(h.context.Project.animationdirector_prop_previews)['["example","wolf","right",0]'].item,'minecraft:carrot');
|
||||
const cue = h.context.Animation.all[0].animators.effects.sound[0].data_points[0];
|
||||
assert.equal(cue.effect, 'reactiveimpact');
|
||||
assert.equal(cue.file, 'blob:import-preview');
|
||||
});
|
||||
|
||||
test('unexpected animation-load failures cancel the batch rather than keeping a partial import', () => {
|
||||
|
||||
Reference in New Issue
Block a user