sound library

This commit is contained in:
2026-09-29 01:07:15 +02:00
parent 6d4094e7c4
commit 55d5593804
5 changed files with 378 additions and 20 deletions
+26 -2
View File
@@ -8,7 +8,7 @@ const vm = require('node:vm');
function harness() {
const source = fs.readFileSync(path.join(__dirname, '..', 'AnimationDirector.js'), 'utf8').replace(
' Plugin.register(PLUGIN_ID, {',
' globalThis.uvTest = { normalizeActorUvs, expandProjectUvs, scaleCubeUvs, getActorUvBasis, tryLoadImportedActorTexture, applyActorTexturePreview, importGeometryIntoCurrentProject };\n Plugin.register(PLUGIN_ID, {'
' globalThis.uvTest = { normalizeActorUvs, expandProjectUvs, scaleCubeUvs, getActorUvBasis, tryLoadImportedActorTexture, applyActorTexturePreview, importGeometryIntoCurrentProject, applyAllActorTexturePreviews, setProjectActorTextures, setProjectBoneTextureOverrides };\n Plugin.register(PLUGIN_ID, {'
);
class Group {
static all = [];
@@ -46,7 +46,7 @@ function harness() {
setTimeout(callback) { callback(); },
Undo: { initEdit() {}, finishEdit() {}, cancelEdit() {} },
Project: { texture_width: 64, texture_height: 64, box_uv: true },
Canvas: { updateAllUVs() {} }, Plugin: { register() {} },
Canvas: { updateAllUVs() {}, updateAll() {} }, Plugin: { register() {} },
localStorage: { getItem() { return null; } },
};
vm.runInNewContext(source, context);
@@ -82,6 +82,30 @@ test('assigning a manually imported texture to an actor normalizes only that act
assert.deepEqual(Array.from(selected.faces.north.uv), [0, 0, 32, 16]);
});
test('bone texture dimensions override the base without repeated UV scaling', () => {
const h = harness();
const group = new h.context.Group({ name: 'actor1_wind', uuid: 'wind' });
group.init();
const baseCube = new h.Cube('actor1_base'), windCube = new h.Cube('actor1_wind_cube');
windCube.addTo(group);
h.context.Project.texture_width = h.context.Project.texture_height = 128;
h.normalizeActorUvs(1, 128, 128);
for (const [name, size] of [['vanilla', 32], ['wind', 128]]) {
new h.Texture({ name, uv_width: size, uv_height: size }).add();
}
h.setProjectActorTextures({ 1: 'vanilla' });
h.setProjectBoneTextureOverrides({ wind: { uuid: 'wind', name: group.name, texture: 'wind' } });
h.applyAllActorTexturePreviews();
assert.deepEqual(Array.from(baseCube.faces.north.uv), [0, 0, 64, 64]);
assert.deepEqual(Array.from(windCube.faces.north.uv), [0, 0, 16, 16]);
assert.equal(windCube.faces.north.texture, 'wind');
h.applyAllActorTexturePreviews();
assert.deepEqual(Array.from(windCube.faces.north.uv), [0, 0, 16, 16]);
h.setProjectBoneTextureOverrides({});
h.applyAllActorTexturePreviews();
assert.deepEqual(Array.from(windCube.faces.north.uv), [0, 0, 64, 64]);
});
test('importing a larger actor preserves UV mapping of the earlier model', () => {
const h = harness();
const geometry = (width) => ({ description: { texture_width: width, texture_height: width }, bones: [{ name: 'body', cubes: [