create-threenative 0.2.17 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-docs/kit-mcp.md +1 -1
- package/agent-docs/kit-router.md +1 -1
- package/agent-docs/references/assertion-reference.md +54 -110
- package/agent-docs/references/capability-reference.md +790 -24
- package/agent-docs/references/conventions.md +28 -0
- package/agent-docs/references/kit-racing.md +4 -2
- package/agent-docs/references/performance-basics.md +10 -5
- package/agent-docs/references/terrain-authoring.md +21 -7
- package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
- package/agent-files/.agents/skills/prd-creator/SKILL.md +24 -0
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +7 -4
- package/agent-files/.claude/hooks/discovery-gate.mjs +2 -2
- package/dist/index.d.ts +97 -6
- package/dist/index.js +1040 -529
- package/dist/quality.d.ts +5 -1
- package/dist/quality.js +75 -6
- package/dist/terrain-kit.js +1 -1
- package/dist/threenative.js +98 -17
- package/dist/web-engine-ccd-ik-solver.js +127 -0
- package/dist/web-engine-gltf-loader.js +52 -14
- package/dist/web-engine-post-effects.js +11 -10
- package/dist/web-engine-runtime.js +3638 -361
- package/package.json +8 -7
- package/template-assets/assets/floor-fern-0.glb +0 -0
- package/template-assets/assets/floor-litter-0.glb +0 -0
- package/template-assets/assets/floor-log-0.glb +0 -0
- package/template-assets/assets/floor-log-1.glb +0 -0
- package/template-assets/assets/floor-stump-0.glb +0 -0
- package/template-assets/assets/floor-twig-0.glb +0 -0
- package/template-assets/clearwater/README.md +1 -1
- package/template-assets/patches/manifest.json +18 -0
- package/template-assets/quality/eslint.config.js +1 -1
- package/templates/action-rpg/AGENTS.md +8 -4
- package/templates/action-rpg/CLAUDE.md +8 -4
- package/templates/action-rpg/package.json +7 -7
- package/templates/action-rpg/src/game.ts +1 -1
- package/templates/action-rpg/src/loot/drops.ts +3 -7
- package/templates/action-rpg/src/render/atmosphere.ts +6 -0
- package/templates/action-rpg/src/render/backlightControls.ts +10 -0
- package/templates/action-rpg/src/render/backlightMaterial.ts +4 -4
- package/templates/action-rpg/src/render/camera.ts +2 -2
- package/templates/action-rpg/src/render/clouds.ts +16 -1
- package/templates/action-rpg/src/render/materialLighting.ts +5 -5
- package/templates/action-rpg/src/render/materials.ts +3 -2
- package/templates/action-rpg/src/render/quality.ts +7 -32
- package/templates/action-rpg/src/render/touch-controls.ts +7 -6
- package/templates/action-rpg/src/scenes/Play.ts +5 -16
- package/templates/action-rpg/src/style.css +4 -0
- package/templates/action-rpg/vite.config.ts +2 -0
- package/templates/adventure/AGENTS.md +10 -5
- package/templates/adventure/CLAUDE.md +10 -5
- package/templates/adventure/kit.json +5 -1
- package/templates/adventure/native-playtests/survives.playtest.json +12 -0
- package/templates/adventure/native-playtests/woodland-floor.playtest.json +61 -0
- package/templates/adventure/package.json +7 -7
- package/templates/adventure/playtests/grass.playtest.json +61 -0
- package/templates/adventure/playtests/performance.playtest.json +1 -1
- package/templates/adventure/playtests/survives.playtest.json +2 -2
- package/templates/adventure/playtests/woodland-floor.playtest.json +61 -0
- package/templates/adventure/src/entities/LockOn.ts +42 -4
- package/templates/adventure/src/entities/Warden.ts +4 -1
- package/templates/adventure/src/game.ts +1 -1
- package/templates/adventure/src/level/Vale.ts +241 -16
- package/templates/adventure/src/render/camera.ts +2 -2
- package/templates/adventure/src/render/foliage.ts +64 -20
- package/templates/adventure/src/render/grass.ts +325 -0
- package/templates/adventure/src/render/materials.ts +3 -2
- package/templates/adventure/src/render/palette.ts +3 -0
- package/templates/adventure/src/render/touch-controls.ts +4 -1
- package/templates/adventure/src/scenes/Play.ts +96 -1
- package/templates/adventure/src/style.css +4 -0
- package/templates/adventure/tsconfig.json +1 -1
- package/templates/adventure/vite.config.ts +2 -0
- package/templates/collectathon/AGENTS.md +7 -2
- package/templates/collectathon/CLAUDE.md +7 -2
- package/templates/collectathon/package.json +7 -7
- package/templates/collectathon/src/game.ts +1 -1
- package/templates/collectathon/src/level/Course.ts +55 -14
- package/templates/collectathon/src/level/terrain.ts +29 -7
- package/templates/collectathon/src/main.ts +1 -0
- package/templates/collectathon/src/render/camera.ts +2 -2
- package/templates/collectathon/src/render/foliage.ts +359 -98
- package/templates/collectathon/src/render/ground.ts +4 -4
- package/templates/collectathon/src/render/hero.ts +1 -1
- package/templates/collectathon/src/render/materials.ts +0 -1
- package/templates/collectathon/src/render/sky.ts +80 -15
- package/templates/collectathon/src/render/water.ts +32 -10
- package/templates/collectathon/src/scenes/Play.ts +18 -5
- package/templates/collectathon/src/style.css +4 -0
- package/templates/collectathon/tsconfig.json +1 -1
- package/templates/collectathon/vite.config.ts +2 -0
- package/templates/kart/AGENTS.md +7 -2
- package/templates/kart/CLAUDE.md +7 -2
- package/templates/kart/package.json +6 -6
- package/templates/kart/src/entities/Kart.ts +2 -1
- package/templates/kart/src/game.ts +1 -1
- package/templates/kart/src/main.ts +1 -0
- package/templates/kart/src/render/course.ts +2 -1
- package/templates/kart/src/style.css +4 -0
- package/templates/kart/src/track/Course.ts +3 -1
- package/templates/kart/tsconfig.json +1 -1
- package/templates/kart/vite.config.ts +2 -0
- package/templates/minimal/AGENTS.md +8 -3
- package/templates/minimal/CLAUDE.md +8 -3
- package/templates/minimal/package.json +6 -6
- package/templates/minimal/playtests/stands-still.playtest.json +30 -0
- package/templates/minimal/src/game.ts +1 -1
- package/templates/minimal/src/render/atmosphere.ts +6 -0
- package/templates/minimal/src/render/backlightControls.ts +10 -0
- package/templates/minimal/src/render/backlightMaterial.ts +4 -4
- package/templates/minimal/src/render/camera.ts +14 -3
- package/templates/minimal/src/render/clouds.ts +16 -1
- package/templates/minimal/src/render/lighting.ts +4 -2
- package/templates/minimal/src/render/materialLighting.ts +5 -5
- package/templates/minimal/src/render/materials.ts +13 -2
- package/templates/minimal/src/render/quality.ts +7 -32
- package/templates/minimal/src/render/touch-controls.ts +7 -6
- package/templates/minimal/src/scenes/Play.ts +4 -1
- package/templates/minimal/vite.config.ts +7 -1
- package/templates/platformer/AGENTS.md +9 -4
- package/templates/platformer/CLAUDE.md +9 -4
- package/templates/platformer/index.html +1 -1
- package/templates/platformer/main.html +12 -0
- package/templates/platformer/package.json +7 -7
- package/templates/platformer/playtests/collect.playtest.json +4 -1
- package/templates/platformer/playtests/gamepad-idle.playtest.json +21 -0
- package/templates/platformer/playtests/gamepad.playtest.json +30 -0
- package/templates/platformer/src/entities/Fox.ts +21 -6
- package/templates/platformer/src/game.ts +1 -1
- package/templates/platformer/src/level/Stage.ts +2 -6
- package/templates/platformer/src/main.ts +1 -0
- package/templates/platformer/src/render/backlightControls.ts +10 -0
- package/templates/platformer/src/render/backlightMaterial.ts +4 -4
- package/templates/platformer/src/render/materialLighting.ts +5 -5
- package/templates/platformer/src/render/quality.ts +7 -32
- package/templates/platformer/src/scenes/Play.ts +4 -2
- package/templates/platformer/src/style.css +4 -0
- package/templates/platformer/src/worker-page.ts +29 -0
- package/templates/platformer/src/worker.ts +5 -0
- package/templates/platformer/tsconfig.json +1 -1
- package/templates/platformer/vite.config.ts +4 -0
- package/templates/puzzle/AGENTS.md +7 -2
- package/templates/puzzle/CLAUDE.md +7 -2
- package/templates/puzzle/package.json +7 -7
- package/templates/puzzle/src/entities/Warden.ts +3 -3
- package/templates/puzzle/src/game.ts +1 -1
- package/templates/puzzle/src/render/backlightControls.ts +10 -0
- package/templates/puzzle/src/render/backlightMaterial.ts +4 -4
- package/templates/puzzle/src/render/camera.ts +2 -2
- package/templates/puzzle/src/render/materialLighting.ts +5 -5
- package/templates/puzzle/src/render/quality.ts +7 -32
- package/templates/puzzle/src/render/touch-controls.ts +7 -6
- package/templates/puzzle/src/scenes/Play.ts +1 -1
- package/templates/puzzle/src/style.css +4 -0
- package/templates/puzzle/tsconfig.json +1 -1
- package/templates/puzzle/vite.config.ts +2 -0
- package/templates/racing/AGENTS.md +9 -4
- package/templates/racing/CLAUDE.md +9 -4
- package/templates/racing/CREDITS.md +29 -0
- package/templates/racing/assets/engine-loop.wav +0 -0
- package/templates/racing/assets/grass/Grass004_color.jpg +0 -0
- package/templates/racing/assets/grass/Grass004_normal.jpg +0 -0
- package/templates/racing/assets/grass/Grass004_roughness.jpg +0 -0
- package/templates/racing/assets/nitro-burst.wav +0 -0
- package/templates/racing/assets/tyre-squeal.wav +0 -0
- package/templates/racing/package.json +7 -7
- package/templates/racing/playtests/drift-natural.playtest.json +68 -0
- package/templates/racing/playtests/drift.playtest.json +100 -0
- package/templates/racing/playtests/hud.playtest.json +117 -0
- package/templates/racing/playtests/launch-pose.playtest.json +34 -0
- package/templates/racing/playtests/nitro.playtest.json +158 -0
- package/templates/racing/playtests/outcome.playtest.json +4 -4
- package/templates/racing/playtests/performance.playtest.json +1 -1
- package/templates/racing/playtests/steady-camera.playtest.json +88 -0
- package/templates/racing/src/audio/engine.ts +138 -0
- package/templates/racing/src/entities/CarBody.ts +83 -10
- package/templates/racing/src/entities/Drift.ts +243 -0
- package/templates/racing/src/entities/LineDriver.ts +2 -2
- package/templates/racing/src/entities/Nitro.ts +72 -0
- package/templates/racing/src/entities/RacingCar.ts +86 -21
- package/templates/racing/src/entities/Rival.ts +35 -21
- package/templates/racing/src/game.ts +7 -1
- package/templates/racing/src/gauges.ts +74 -0
- package/templates/racing/src/render/atmosphere.ts +6 -0
- package/templates/racing/src/render/backlightControls.ts +10 -0
- package/templates/racing/src/render/backlightMaterial.ts +4 -4
- package/templates/racing/src/render/camera.ts +29 -4
- package/templates/racing/src/render/clouds.ts +16 -1
- package/templates/racing/src/render/effects.ts +244 -0
- package/templates/racing/src/render/materialLighting.ts +5 -5
- package/templates/racing/src/render/materials.ts +43 -8
- package/templates/racing/src/render/quality.ts +7 -32
- package/templates/racing/src/render/shapes.ts +37 -0
- package/templates/racing/src/render/skids.ts +84 -0
- package/templates/racing/src/render/touch-controls.ts +10 -10
- package/templates/racing/src/scenes/Race.ts +281 -26
- package/templates/racing/src/state.ts +35 -0
- package/templates/racing/src/style.css +7 -0
- package/templates/racing/src/track/Track.ts +132 -58
- package/templates/racing/src/track/TrackSector.ts +19 -1
- package/templates/racing/src/track/circuit.ts +21 -15
- package/templates/racing/src/ui/GameUi.tsx +0 -2
- package/templates/racing/src/ui/Hud.tsx +417 -50
- package/templates/racing/threenative.config.ts +15 -0
- package/templates/racing/tools/make-racing-audio.mjs +388 -0
- package/templates/racing/tsconfig.json +1 -1
- package/templates/racing/vite.config.ts +2 -0
- package/templates/rain/AGENTS.md +6 -2
- package/templates/rain/CLAUDE.md +6 -2
- package/templates/rain/package.json +6 -6
- package/templates/rain/src/game.ts +1 -1
- package/templates/rain/src/render/noise-volume.ts +2 -1
- package/templates/rain/src/state.ts +3 -1
- package/templates/rain/src/ui/GameUi.tsx +1 -1
- package/templates/rain/src/ui/automation.ts +10 -8
- package/templates/rain/src/ui/tempest.ts +3 -4
- package/templates/rain/vite.config.ts +6 -0
- package/templates/rts/AGENTS.md +6 -2
- package/templates/rts/CLAUDE.md +6 -2
- package/templates/rts/package.json +6 -6
- package/templates/rts/src/game.ts +1 -1
- package/templates/rts/src/render/backlightControls.ts +10 -0
- package/templates/rts/src/render/backlightMaterial.ts +4 -4
- package/templates/rts/src/render/materialLighting.ts +5 -5
- package/templates/rts/src/render/quality.ts +7 -31
- package/templates/rts/src/scenes/Play.ts +1 -1
- package/templates/rts/src/sim/terrain.ts +1 -0
- package/templates/rts/src/sim/types.ts +1 -0
- package/templates/rts/src/style.css +4 -0
- package/templates/rts/vite.config.ts +2 -0
- package/templates/runner/AGENTS.md +7 -2
- package/templates/runner/CLAUDE.md +7 -2
- package/templates/runner/package.json +7 -7
- package/templates/runner/src/game.ts +1 -1
- package/templates/runner/src/render/atmosphere.ts +6 -0
- package/templates/runner/src/render/backlightControls.ts +10 -0
- package/templates/runner/src/render/backlightMaterial.ts +4 -4
- package/templates/runner/src/render/clouds.ts +16 -1
- package/templates/runner/src/render/materialLighting.ts +5 -5
- package/templates/runner/src/render/materials.ts +3 -2
- package/templates/runner/src/render/quality.ts +7 -32
- package/templates/runner/src/render/touch-controls.ts +7 -6
- package/templates/runner/src/scenes/Run.ts +8 -10
- package/templates/runner/src/style.css +4 -0
- package/templates/runner/tsconfig.json +1 -1
- package/templates/runner/vite.config.ts +2 -0
- package/templates/sailing/AGENTS.md +7 -2
- package/templates/sailing/CLAUDE.md +7 -2
- package/templates/sailing/package.json +7 -7
- package/templates/sailing/src/game.ts +1 -1
- package/templates/sailing/src/render/backlightControls.ts +10 -0
- package/templates/sailing/src/render/backlightMaterial.ts +4 -4
- package/templates/sailing/src/render/environmentSetup.ts +1 -1
- package/templates/sailing/src/render/materialLighting.ts +5 -5
- package/templates/sailing/src/render/quality.ts +7 -32
- package/templates/sailing/src/render/touch-controls.ts +7 -6
- package/templates/sailing/src/style.css +5 -0
- package/templates/sailing/vite.config.ts +6 -0
- package/templates/shooter/AGENTS.md +6 -2
- package/templates/shooter/CLAUDE.md +6 -2
- package/templates/shooter/package.json +7 -7
- package/templates/shooter/src/game.ts +3 -2
- package/templates/shooter/src/render/atmosphere.ts +6 -0
- package/templates/shooter/src/render/backlightControls.ts +10 -0
- package/templates/shooter/src/render/backlightMaterial.ts +4 -4
- package/templates/shooter/src/render/clouds.ts +16 -1
- package/templates/shooter/src/render/materialLighting.ts +5 -5
- package/templates/shooter/src/render/quality.ts +7 -32
- package/templates/shooter/src/scenes/Play.ts +4 -1
- package/templates/shooter/src/style.css +4 -0
- package/templates/shooter/vite.config.ts +2 -0
- package/templates/snow/AGENTS.md +7 -2
- package/templates/snow/CLAUDE.md +7 -2
- package/templates/snow/package.json +7 -7
- package/templates/snow/src/entities/Explorer.ts +6 -12
- package/templates/snow/src/game.ts +1 -1
- package/templates/snow/src/render/backlightControls.ts +10 -0
- package/templates/snow/src/render/backlightMaterial.ts +4 -4
- package/templates/snow/src/render/bootPrint.ts +3 -1
- package/templates/snow/src/render/camera.ts +3 -2
- package/templates/snow/src/render/materialLighting.ts +5 -5
- package/templates/snow/src/render/quality.ts +7 -32
- package/templates/snow/src/render/scenery.ts +3 -3
- package/templates/snow/src/render/touch-controls.ts +7 -6
- package/templates/snow/src/render/weather.ts +3 -5
- package/templates/snow/src/style.css +5 -0
- package/templates/snow/src/terrain.ts +2 -1
- package/templates/snow/vite.config.ts +6 -0
- package/templates/starter/AGENTS.md +8 -3
- package/templates/starter/CLAUDE.md +8 -3
- package/templates/starter/native-playtests/render-chain.playtest.json +9 -9
- package/templates/starter/package.json +7 -7
- package/templates/starter/src/entities/Crate.ts +5 -2
- package/templates/starter/src/entities/Player.ts +10 -2
- package/templates/starter/src/game.ts +4 -3
- package/templates/starter/src/render/adaptiveQuality.ts +17 -0
- package/templates/starter/src/render/atmosphere.ts +6 -0
- package/templates/starter/src/render/backlightControls.ts +10 -0
- package/templates/starter/src/render/backlightMaterial.ts +4 -4
- package/templates/starter/src/render/camera.ts +2 -2
- package/templates/starter/src/render/clouds.ts +16 -1
- package/templates/starter/src/render/contactShadow.ts +1 -1
- package/templates/starter/src/render/materialLighting.ts +5 -5
- package/templates/starter/src/render/materials.ts +3 -2
- package/templates/starter/src/render/postprocessing.ts +11 -10
- package/templates/starter/src/render/quality.ts +14 -1
- package/templates/starter/src/render/touch-controls.ts +7 -6
- package/templates/starter/src/scenes/Play.ts +13 -17
- package/templates/starter/src/state.ts +2 -0
- package/templates/starter/src/style.css +4 -0
- package/templates/starter/src/ui/Menu.tsx +5 -1
- package/templates/starter/vite.config.ts +2 -0
- package/templates/tower-defense/AGENTS.md +7 -2
- package/templates/tower-defense/CLAUDE.md +7 -2
- package/templates/tower-defense/package.json +7 -7
- package/templates/tower-defense/src/game.ts +1 -1
- package/templates/tower-defense/src/render/backlightControls.ts +10 -0
- package/templates/tower-defense/src/render/backlightMaterial.ts +4 -4
- package/templates/tower-defense/src/render/materialLighting.ts +5 -5
- package/templates/tower-defense/src/render/quality.ts +7 -32
- package/templates/tower-defense/src/render/shapes.ts +1 -2
- package/templates/tower-defense/src/scenes/Battle.ts +4 -9
- package/templates/tower-defense/src/style.css +4 -0
- package/templates/tower-defense/tsconfig.json +1 -1
- package/templates/tower-defense/vite.config.ts +2 -0
- package/templates/action-rpg/src/render/environmentContribution.ts +0 -188
- package/templates/action-rpg/src/render/environmentRadiance.ts +0 -36
- package/templates/action-rpg/src/render/environmentSampleCache.ts +0 -43
- package/templates/action-rpg/src/render/environmentSampling.ts +0 -193
- package/templates/action-rpg/src/render/environmentSnapshot.ts +0 -53
- package/templates/minimal/src/render/environmentContribution.ts +0 -188
- package/templates/minimal/src/render/environmentRadiance.ts +0 -36
- package/templates/minimal/src/render/environmentSampleCache.ts +0 -43
- package/templates/minimal/src/render/environmentSampling.ts +0 -193
- package/templates/minimal/src/render/environmentSnapshot.ts +0 -53
- package/templates/platformer/src/render/environmentContribution.ts +0 -188
- package/templates/platformer/src/render/environmentRadiance.ts +0 -36
- package/templates/platformer/src/render/environmentSampleCache.ts +0 -43
- package/templates/platformer/src/render/environmentSampling.ts +0 -193
- package/templates/platformer/src/render/environmentSnapshot.ts +0 -53
- package/templates/puzzle/src/render/environmentContribution.ts +0 -188
- package/templates/puzzle/src/render/environmentRadiance.ts +0 -36
- package/templates/puzzle/src/render/environmentSampleCache.ts +0 -43
- package/templates/puzzle/src/render/environmentSampling.ts +0 -193
- package/templates/puzzle/src/render/environmentSnapshot.ts +0 -53
- package/templates/racing/src/render/environmentContribution.ts +0 -188
- package/templates/racing/src/render/environmentRadiance.ts +0 -36
- package/templates/racing/src/render/environmentSampleCache.ts +0 -43
- package/templates/racing/src/render/environmentSampling.ts +0 -193
- package/templates/racing/src/render/environmentSnapshot.ts +0 -53
- package/templates/racing/src/ui/Menu.tsx +0 -7
- package/templates/rts/src/render/environmentContribution.ts +0 -188
- package/templates/rts/src/render/environmentRadiance.ts +0 -36
- package/templates/rts/src/render/environmentSampleCache.ts +0 -43
- package/templates/rts/src/render/environmentSampling.ts +0 -193
- package/templates/rts/src/render/environmentSnapshot.ts +0 -53
- package/templates/runner/src/render/environmentContribution.ts +0 -188
- package/templates/runner/src/render/environmentRadiance.ts +0 -36
- package/templates/runner/src/render/environmentSampleCache.ts +0 -43
- package/templates/runner/src/render/environmentSampling.ts +0 -193
- package/templates/runner/src/render/environmentSnapshot.ts +0 -53
- package/templates/sailing/src/render/environmentContribution.ts +0 -188
- package/templates/sailing/src/render/environmentRadiance.ts +0 -36
- package/templates/sailing/src/render/environmentSampleCache.ts +0 -43
- package/templates/sailing/src/render/environmentSampling.ts +0 -193
- package/templates/sailing/src/render/environmentSnapshot.ts +0 -53
- package/templates/shooter/src/render/environmentContribution.ts +0 -188
- package/templates/shooter/src/render/environmentRadiance.ts +0 -36
- package/templates/shooter/src/render/environmentSampleCache.ts +0 -43
- package/templates/shooter/src/render/environmentSampling.ts +0 -193
- package/templates/shooter/src/render/environmentSnapshot.ts +0 -53
- package/templates/snow/src/render/environmentContribution.ts +0 -188
- package/templates/snow/src/render/environmentRadiance.ts +0 -36
- package/templates/snow/src/render/environmentSampleCache.ts +0 -43
- package/templates/snow/src/render/environmentSampling.ts +0 -193
- package/templates/snow/src/render/environmentSnapshot.ts +0 -53
- package/templates/starter/src/render/environmentContribution.ts +0 -188
- package/templates/starter/src/render/environmentRadiance.ts +0 -36
- package/templates/starter/src/render/environmentSampleCache.ts +0 -43
- package/templates/starter/src/render/environmentSampling.ts +0 -193
- package/templates/starter/src/render/environmentSnapshot.ts +0 -53
- package/templates/starter/src/render/rendererGate.ts +0 -36
- package/templates/tower-defense/src/render/environmentContribution.ts +0 -188
- package/templates/tower-defense/src/render/environmentRadiance.ts +0 -36
- package/templates/tower-defense/src/render/environmentSampleCache.ts +0 -43
- package/templates/tower-defense/src/render/environmentSampling.ts +0 -193
- package/templates/tower-defense/src/render/environmentSnapshot.ts +0 -53
|
@@ -33,7 +33,27 @@ function refuse(what) {
|
|
|
33
33
|
}
|
|
34
34
|
var HOSTED_PLUGIN = "TN_discrete_lod";
|
|
35
35
|
var ELEMENTS = { 5121: Uint8Array, 5123: Uint16Array, 5125: Uint32Array };
|
|
36
|
-
function
|
|
36
|
+
async function viewBytes(view, bin, decoder, index) {
|
|
37
|
+
const meshopt = view.extensions?.EXT_meshopt_compression ?? view.extensions?.KHR_meshopt_compression;
|
|
38
|
+
if (meshopt === void 0) return bin.subarray(view.byteOffset ?? 0);
|
|
39
|
+
const { byteLength = 0, byteOffset = 0, byteStride = 0, count = 0, mode = "" } = meshopt;
|
|
40
|
+
if (decoder === void 0 || (meshopt.buffer ?? 0) !== 0 || byteOffset + byteLength > bin.byteLength)
|
|
41
|
+
throw new Error(
|
|
42
|
+
`TN_WASM_GLTF_LOD_ACCESSOR: accessor ${String(index)} is meshopt-compressed ${decoder === void 0 ? "and no meshopt decoder was set" : "outside the binary chunk"}`
|
|
43
|
+
);
|
|
44
|
+
await decoder.ready;
|
|
45
|
+
const decoded = new Uint8Array(count * byteStride);
|
|
46
|
+
decoder.decodeGltfBuffer(
|
|
47
|
+
decoded,
|
|
48
|
+
count,
|
|
49
|
+
byteStride,
|
|
50
|
+
bin.subarray(byteOffset, byteOffset + byteLength),
|
|
51
|
+
mode,
|
|
52
|
+
meshopt.filter
|
|
53
|
+
);
|
|
54
|
+
return decoded;
|
|
55
|
+
}
|
|
56
|
+
async function readIndices(json, bin, index, decoder) {
|
|
37
57
|
const accessor = json.accessors?.[index];
|
|
38
58
|
const view = json.bufferViews?.[accessor?.bufferView ?? -1];
|
|
39
59
|
const Element = ELEMENTS[accessor?.componentType];
|
|
@@ -43,13 +63,14 @@ function readIndices(json, bin, index) {
|
|
|
43
63
|
);
|
|
44
64
|
if (bin === void 0)
|
|
45
65
|
throw new Error("TN_WASM_GLTF_LOD_ACCESSOR: only a GLB's binary chunk is read for a LOD chain");
|
|
46
|
-
const
|
|
66
|
+
const bytes = await viewBytes(view, bin, decoder, index);
|
|
67
|
+
const start = accessor.byteOffset ?? 0;
|
|
47
68
|
const end = start + accessor.count * Element.BYTES_PER_ELEMENT;
|
|
48
|
-
if (!Number.isInteger(start) || end >
|
|
69
|
+
if (!Number.isInteger(start) || end > bytes.byteLength)
|
|
49
70
|
throw new Error(
|
|
50
71
|
`TN_WASM_GLTF_LOD_ACCESSOR: accessor ${String(index)} reads past the binary chunk`
|
|
51
72
|
);
|
|
52
|
-
return { array: new Element(
|
|
73
|
+
return { array: new Element(bytes.slice(start, end).buffer) };
|
|
53
74
|
}
|
|
54
75
|
function associate(json, scene, into) {
|
|
55
76
|
const expected = [];
|
|
@@ -75,13 +96,13 @@ function associate(json, scene, into) {
|
|
|
75
96
|
);
|
|
76
97
|
for (const [i, mesh] of meshes.entries()) into.set(mesh, expected[i]);
|
|
77
98
|
}
|
|
78
|
-
function hostPlugins(factories, data) {
|
|
99
|
+
function hostPlugins(factories, data, decoder) {
|
|
79
100
|
if (factories.length === 0) return void 0;
|
|
80
101
|
const { bin, json } = readGltf(data);
|
|
81
102
|
const parser = {
|
|
82
103
|
associations: /* @__PURE__ */ new Map(),
|
|
83
104
|
getDependency: async (type, index) => {
|
|
84
|
-
if (type === "accessor") return readIndices(json, bin, index);
|
|
105
|
+
if (type === "accessor") return readIndices(json, bin, index, decoder);
|
|
85
106
|
throw new Error(
|
|
86
107
|
`TN_WASM_GLTF_DEPENDENCY_UNSUPPORTED: the engine glTF loader returns no '${type}'`
|
|
87
108
|
);
|
|
@@ -112,9 +133,15 @@ function imageBytes(url) {
|
|
|
112
133
|
}
|
|
113
134
|
var GLTFLoader = class {
|
|
114
135
|
path = "";
|
|
136
|
+
/**
|
|
137
|
+
* Serves one image file's bytes in place of a plain fetch: core hands the resident levels of a
|
|
138
|
+
* KTX2 here (PRD-860). `undefined` from it means "fetch it as usual".
|
|
139
|
+
*/
|
|
140
|
+
imageSource = void 0;
|
|
115
141
|
/** A plugin defect (a chain the file declares and cannot deliver) rejects the load; core's plugin logs it on stock three. */
|
|
116
142
|
failClosed = true;
|
|
117
143
|
#factories = [];
|
|
144
|
+
#meshopt;
|
|
118
145
|
setPath(path) {
|
|
119
146
|
this.path = path;
|
|
120
147
|
return this;
|
|
@@ -128,11 +155,17 @@ var GLTFLoader = class {
|
|
|
128
155
|
setRequestHeader() {
|
|
129
156
|
return this;
|
|
130
157
|
}
|
|
131
|
-
|
|
132
|
-
|
|
158
|
+
/** The engine's loader transcodes KHR_texture_basisu itself (PRD-861), so the JS loader goes unused. */
|
|
159
|
+
setKTX2Loader(_loader) {
|
|
160
|
+
return this;
|
|
133
161
|
}
|
|
134
|
-
|
|
135
|
-
|
|
162
|
+
/**
|
|
163
|
+
* The engine's loader decodes EXT/KHR_meshopt_compression itself (PRD-861); the JS decoder reads
|
|
164
|
+
* only a hosted LOD chain's compressed index views.
|
|
165
|
+
*/
|
|
166
|
+
setMeshoptDecoder(decoder) {
|
|
167
|
+
this.#meshopt = decoder;
|
|
168
|
+
return this;
|
|
136
169
|
}
|
|
137
170
|
setDRACOLoader() {
|
|
138
171
|
return refuse("DRACO");
|
|
@@ -150,11 +183,11 @@ var GLTFLoader = class {
|
|
|
150
183
|
if (load === void 0)
|
|
151
184
|
throw new Error("TN_WASM_GLTF_UNAVAILABLE: this web engine has no glTF loader");
|
|
152
185
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : new Uint8Array(data);
|
|
153
|
-
const hosted = hostPlugins(this.#factories, data);
|
|
154
|
-
const model = load(bytes, files);
|
|
186
|
+
const hosted = hostPlugins(this.#factories, data, this.#meshopt);
|
|
187
|
+
const model = await load(bytes, files);
|
|
155
188
|
result = {
|
|
156
189
|
scene: model.scene,
|
|
157
|
-
scenes: [model.
|
|
190
|
+
scenes: [...model.scenes],
|
|
158
191
|
animations: [...model.animations],
|
|
159
192
|
cameras: [],
|
|
160
193
|
asset: { version: "2.0" },
|
|
@@ -179,7 +212,12 @@ var GLTFLoader = class {
|
|
|
179
212
|
}
|
|
180
213
|
Promise.all(
|
|
181
214
|
// The engine loader asks for the uri with its percent escapes decoded.
|
|
182
|
-
uris.map(
|
|
215
|
+
uris.map(
|
|
216
|
+
async (uri) => [
|
|
217
|
+
decodeURIComponent(uri),
|
|
218
|
+
await this.imageSource?.(path + uri) ?? await imageBytes(path + uri)
|
|
219
|
+
]
|
|
220
|
+
)
|
|
183
221
|
).then(
|
|
184
222
|
(files) => settle(new Map(files)),
|
|
185
223
|
(error) => {
|
|
@@ -535,6 +535,7 @@ function defineScreenSpaceGi(tsl) {
|
|
|
535
535
|
const probeJitter = uniform(1);
|
|
536
536
|
const probeDebug = uniform(0);
|
|
537
537
|
const occlusion = (gather) => {
|
|
538
|
+
if (options.fallback !== void 0) return vec4(1, 1, 1, 1);
|
|
538
539
|
const ao2 = pow(clamp(float(1).sub(gather.a), float(0), float(1)), aoIntensity);
|
|
539
540
|
return vec4(ao2, ao2, ao2, 1);
|
|
540
541
|
};
|
|
@@ -586,7 +587,6 @@ function defineScreenSpaceGi(tsl) {
|
|
|
586
587
|
If(centreDepth.lessThan(1).and(centreNormal.dot(centreNormal).greaterThan(0.25)), () => {
|
|
587
588
|
const position = viewPosition(coordinate, centreDepth);
|
|
588
589
|
const normal = normalize(centreNormal);
|
|
589
|
-
const fallback = options.fallback?.(position, normal) ?? vec3(0, 0, 0);
|
|
590
590
|
const helper = normal.y.abs().lessThan(0.99).select(vec3(0, 1, 0), vec3(1, 0, 0));
|
|
591
591
|
const tangent = normalize(helper.cross(normal));
|
|
592
592
|
const bitangent = normal.cross(tangent);
|
|
@@ -613,8 +613,12 @@ function defineScreenSpaceGi(tsl) {
|
|
|
613
613
|
const trace = march(origin, direction, position.z);
|
|
614
614
|
If(trace.hitDistance.greaterThanEqual(0), () => {
|
|
615
615
|
const hit = shade(trace.hitCoordinate, trace.hitDistance, direction);
|
|
616
|
+
const fallback = options.fallback?.(position, direction, normal) ?? vec3(0, 0, 0);
|
|
616
617
|
gathered.assign(gathered.add(hit.radiance.sub(fallback).mul(hit.weight)));
|
|
617
618
|
hits.assign(hits.add(hit.weight));
|
|
619
|
+
}).Else(() => {
|
|
620
|
+
const past = options.miss?.(position, direction, normal);
|
|
621
|
+
if (past !== void 0) gathered.assign(gathered.add(past));
|
|
618
622
|
});
|
|
619
623
|
}
|
|
620
624
|
);
|
|
@@ -712,7 +716,11 @@ function defineScreenProbes(tsl, input) {
|
|
|
712
716
|
const trace = march(origin, direction, position.z);
|
|
713
717
|
If(trace.hitDistance.greaterThanEqual(0), () => {
|
|
714
718
|
const hit = shade(trace.hitCoordinate, trace.hitDistance, direction);
|
|
715
|
-
|
|
719
|
+
const believed = options.fallback?.(position, direction, normal) ?? vec3(0, 0, 0);
|
|
720
|
+
result.assign(vec4(hit.radiance.sub(believed).mul(hit.weight), hit.weight));
|
|
721
|
+
}).Else(() => {
|
|
722
|
+
const past = options.miss?.(position, direction, normal);
|
|
723
|
+
if (past !== void 0) result.assign(vec4(past, 0));
|
|
716
724
|
});
|
|
717
725
|
});
|
|
718
726
|
return result;
|
|
@@ -739,15 +747,8 @@ function defineScreenProbes(tsl, input) {
|
|
|
739
747
|
sum.assign(sum.add(found.mul(weight)));
|
|
740
748
|
weights.assign(weights.add(weight));
|
|
741
749
|
});
|
|
742
|
-
const probeUv = tile.add(0.5).div(tiles).min(vec2(1, 1));
|
|
743
|
-
const depth = depthNode.sample(probeUv).r;
|
|
744
|
-
const rawNormal = normalNode.sample(probeUv).xyz;
|
|
745
|
-
const believed = valid(depth, rawNormal).select(
|
|
746
|
-
options.fallback?.(viewPosition(probeUv, depth), normal) ?? vec3(0, 0, 0),
|
|
747
|
-
vec3(0, 0, 0)
|
|
748
|
-
);
|
|
749
750
|
const total = max(weights, float(1e-4));
|
|
750
|
-
return vec4(sum.rgb.
|
|
751
|
+
return vec4(sum.rgb.div(total), sum.a.div(total));
|
|
751
752
|
})();
|
|
752
753
|
const filtered = rtt(filterGraph, tilesX * IRRADIANCE_SIDE, tilesY * IRRADIANCE_SIDE, {
|
|
753
754
|
type: HALF_FLOAT_TYPE,
|