improvements
This commit is contained in:
@@ -27,6 +27,7 @@ function harness(capture = false) {
|
||||
static all = [];
|
||||
constructor(data) { Object.assign(this, data); }
|
||||
fromPath(file) { this.path = file; this.name = path.basename(file); return this; }
|
||||
fromDataURL(url) { this.source = url; return this; }
|
||||
add(undo) { assert.equal(undo, false); Texture.all.push(this); }
|
||||
}
|
||||
const context = {
|
||||
@@ -272,6 +273,39 @@ test('complete import prepares all stages, actor models, local textures and defi
|
||||
assert.ok(h.storage.get('animationdirector_pack_folders').includes(source.root.replace(/\\/g, '\\\\')));
|
||||
});
|
||||
|
||||
test('complete import finds model texture in cached assets and uses its PNG dimensions', async (t) => {
|
||||
const f = fixtures(t), h = harness(true), source = f.makePack('source');
|
||||
const defFile = f.write(path.join(source.root, 'data/test/afw_animdefs/example.json'), {
|
||||
actors: [{ label: 'wolf', entity_types: ['minecraft:wolf'] }], stages: [{ stage: 1 }],
|
||||
});
|
||||
f.write(path.join(source.root, 'assets/test/animations/afw/example.animation.json'), {
|
||||
animations: { p1_wolf: { animation_length: 1, bones: { body: { rotation: [0, 0, 0] } } } },
|
||||
});
|
||||
f.model(source, 'test:source/entity/wolf.m');
|
||||
const cache = path.join(f.root, 'cached-assets');
|
||||
const image = path.join(cache, 'assets/test/textures/entity/wolf.png');
|
||||
fs.mkdirSync(path.dirname(image), { recursive: true });
|
||||
const png = Buffer.alloc(24);
|
||||
Buffer.from('89504e470d0a1a0a', 'hex').copy(png);
|
||||
png.writeUInt32BE(32, 16); png.writeUInt32BE(64, 20);
|
||||
fs.writeFileSync(image, png);
|
||||
h.storage.set('animationdirector_prop_source', cache);
|
||||
h.context.selectedFile = { path: defFile };
|
||||
await h.automaticallyImportAnimation();
|
||||
assert.deepEqual(h.errors, []);
|
||||
const row = h.context.importedPlan.rows[0];
|
||||
assert.equal(row.defaultTexture, 'test:textures/entity/wolf.png');
|
||||
assert.equal(row.textures.get(row.defaultTexture).dimensions.width, 32);
|
||||
assert.equal(row.textures.get(row.defaultTexture).dimensions.height, 64);
|
||||
|
||||
const importing = harness();
|
||||
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.multiactor_actor_textures)['1'], row.defaultTexture);
|
||||
});
|
||||
|
||||
test('definition actors exclude extra clips, their effects and stages containing only unused actors', async (t) => {
|
||||
const f = fixtures(t), h = harness(true), source = f.makePack('source');
|
||||
const file = f.write(path.join(source.root, 'data/test/afw_animdefs/example.json'), {
|
||||
|
||||
Reference in New Issue
Block a user