Improved harness - with card selection

This commit is contained in:
2026-09-15 06:08:43 -07:00
parent 97ed7f05c8
commit 786f63a042
29 changed files with 1398 additions and 494 deletions

View File

@@ -541,3 +541,59 @@ test('pack frames report motion and touch settling but settled and hidden scenes
pack.setActive(false)
assert.equal(pack.tick(performance.now()), false)
})
test('streamed packs acquire current and next fronts and release outgoing leases', async (t) => {
installDOM()
let now = 1000
t.mock.method(performance, 'now', () => now)
const canvas = new TestCanvas()
const acquired = []
const released = []
const placeholder = { artwork: new THREE.Texture(), mask: new THREE.Texture() }
const contents = [
{ fixture: 'one', finish: 'Holographic', substrate: 'Linen' },
{ fixture: 'two', finish: 'Foil', substrate: 'Metal' },
{ fixture: 'three', finish: 'Printed ink', substrate: 'Paper' },
]
const pack = new PackOpening({
canvas, contents, placeholderTextures: placeholder,
async acquireTextures(spec) {
acquired.push(spec.fixture)
return { textures: { artwork: new THREE.Texture(), mask: new THREE.Texture() },
release: () => released.push(spec.fixture) }
},
resolveSurfaceDefaults(finish, substrate) {
return { finishStrength: finish === 'Holographic' ? 0.33 : 1,
roughness: 0.23, normalStrength: substrate === 'Linen' ? 0.05 : 1,
metalBrushHorizontal: false }
},
backMaterial: new THREE.MeshPhysicalMaterial(), normalMap: new THREE.Texture(),
environment: new THREE.CubeTexture(), lightPosition: new THREE.Vector3(), onChange() {},
})
pack.setActive(true)
pack.skip()
now += 3200
pack.tick(now)
await Promise.resolve()
await Promise.resolve()
assert.deepEqual(acquired, ['one'])
assert.ok(pack.cards.every(card => !card.front.visible))
assert.equal(pack.cards[0].material.uniforms.finishStrength.value, 0.33)
assert.equal(pack.cards[0].material.uniforms.normalStrength.value, 0.05)
pack.skip()
assert.equal(pack.state, 'lifted')
pack.skip()
assert.equal(pack.state, 'inspecting')
await Promise.resolve()
await Promise.resolve()
assert.deepEqual(acquired, ['one', 'two'])
assert.equal(pack.cards[0].front.visible, true)
pack.skip()
assert.equal(pack.state, 'stackReady')
assert.deepEqual(released, ['one'])
pack.dispose()
assert.deepEqual(released, ['one', 'two'])
})