Finished up most documentation
This commit is contained in:
@@ -720,6 +720,8 @@ async function preparePack() {
|
||||
packLoading = true
|
||||
packError = undefined
|
||||
updatePackUI()
|
||||
let preparedPack: PackOpening | undefined
|
||||
let textures: THREE.Texture[] = []
|
||||
try {
|
||||
// Separate texture ownership keeps local artwork, experiments and fixture disposal independent.
|
||||
const paths = [fixtureAssets.David.artwork, fixtureAssets.David.mask,
|
||||
@@ -732,12 +734,12 @@ async function preparePack() {
|
||||
}
|
||||
throw failure.reason
|
||||
}
|
||||
const textures = results.map((result, index) => {
|
||||
textures = results.map((result, index) => {
|
||||
if (result.status !== 'fulfilled') throw new Error(`Missing pack asset: ${paths[index]}`)
|
||||
configureFrontTexture(result.value, index % 2 ? THREE.NoColorSpace : THREE.SRGBColorSpace)
|
||||
return result.value
|
||||
})
|
||||
pack = new PackOpening({
|
||||
preparedPack = new PackOpening({
|
||||
canvas,
|
||||
textures: {
|
||||
David: { artwork: textures[0], mask: textures[1] },
|
||||
@@ -749,12 +751,24 @@ async function preparePack() {
|
||||
lightPosition,
|
||||
onChange: () => { packUIDirty = true },
|
||||
})
|
||||
scene.add(pack.root)
|
||||
pack.syncLighting(frontMaterial)
|
||||
pack.setActive(mode === 'Pack')
|
||||
pack.resize(canvas.clientWidth, canvas.clientHeight)
|
||||
preparedPack.resize(canvas.clientWidth, canvas.clientHeight)
|
||||
let preparedEnvironment: THREE.Texture | null
|
||||
let preparedLightType: LightType
|
||||
do {
|
||||
preparedEnvironment = scene.environment
|
||||
preparedLightType = controls.lightType
|
||||
preparedPack.syncLighting(frontMaterial)
|
||||
await preparedPack.prepareGPU(renderer, scene)
|
||||
} while (scene.environment !== preparedEnvironment || controls.lightType !== preparedLightType)
|
||||
preparedPack.syncLighting(frontMaterial)
|
||||
preparedPack.resize(canvas.clientWidth, canvas.clientHeight)
|
||||
preparedPack.setActive(mode === 'Pack')
|
||||
scene.add(preparedPack.root)
|
||||
pack = preparedPack
|
||||
} catch (error) {
|
||||
packError = `Pack assets unavailable: ${error instanceof Error ? error.message : String(error)}`
|
||||
preparedPack?.dispose()
|
||||
for (const texture of textures) texture.dispose()
|
||||
packError = `Pack unavailable: ${error instanceof Error ? error.message : String(error)}`
|
||||
console.error('Could not prepare pack prototype', error)
|
||||
} finally {
|
||||
packLoading = false
|
||||
|
||||
Reference in New Issue
Block a user