create-threenative 0.2.8 → 0.2.10
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/references/assertion-reference.md +87 -35
- package/agent-docs/references/auto-exposure.md +57 -0
- package/agent-docs/references/capability-reference.md +1097 -23
- package/agent-docs/references/debug-surface.md +6 -0
- package/agent-docs/references/finding-assets.md +46 -10
- package/agent-docs/references/performance-basics.md +5 -4
- package/agent-docs/references/terrain-authoring.md +140 -0
- package/agent-files/.agents/skills/threenative-assets/SKILL.md +2 -1
- package/capabilities.json +1210 -27
- package/dist/index.d.ts +28 -3
- package/dist/index.js +396 -166
- package/dist/threenative.js +986 -235
- package/dist/web-engine-buffer-geometry-utils.js +281 -0
- package/dist/web-engine-decal-geometry.js +184 -0
- package/dist/web-engine-gltf-loader.js +196 -0
- package/dist/web-engine-hdr-loader.js +190 -0
- package/dist/web-engine-lut-cube-loader.js +122 -0
- package/dist/web-engine-mesh-bvh-webgpu.js +29 -0
- package/dist/web-engine-mesh-bvh.js +32 -0
- package/dist/web-engine-post-effects.js +168 -0
- package/dist/web-engine-runtime.js +42506 -0
- package/package.json +11 -8
- package/template-assets/autoExposure.ts +225 -0
- package/template-assets/exposure.ts +111 -0
- package/template-assets/exposureGraph.ts +178 -0
- package/template-assets/exposureReadback.ts +79 -0
- package/template-assets/patches/@tailwindcss__node@4.3.3.patch +22 -0
- package/template-assets/patches/three@0.185.1.patch +6594 -700
- package/template-assets/patches/vite@8.2.0.patch +422 -0
- package/template-assets/worldEnvironment.ts +433 -30
- package/templates/action-rpg/AGENTS.md +11 -10
- package/templates/action-rpg/CLAUDE.md +11 -10
- package/templates/action-rpg/package.json +13 -10
- package/templates/action-rpg/playtests/performance.playtest.json +7 -1
- package/templates/action-rpg/src/progress.ts +0 -4
- package/templates/action-rpg/src/render/autoExposure.ts +225 -0
- package/templates/action-rpg/src/render/backlightControls.ts +66 -0
- package/templates/action-rpg/src/render/backlightMaterial.ts +147 -0
- package/templates/action-rpg/src/render/environmentContribution.ts +188 -0
- package/templates/action-rpg/src/render/environmentRadiance.ts +36 -0
- package/templates/action-rpg/src/render/environmentSampleCache.ts +43 -0
- package/templates/action-rpg/src/render/environmentSampling.ts +193 -0
- package/templates/action-rpg/src/render/environmentSnapshot.ts +53 -0
- package/templates/action-rpg/src/render/exposure.ts +111 -0
- package/templates/action-rpg/src/render/exposureGraph.ts +178 -0
- package/templates/action-rpg/src/render/exposureReadback.ts +79 -0
- package/templates/action-rpg/src/render/heightFog.ts +118 -0
- package/templates/action-rpg/src/render/lighting.ts +26 -1
- package/templates/action-rpg/src/render/materialAssignments.ts +160 -0
- package/templates/action-rpg/src/render/materialLighting.ts +155 -0
- package/templates/action-rpg/src/render/postprocessing.ts +17 -2
- package/templates/action-rpg/src/render/quality.ts +61 -2
- package/templates/action-rpg/src/render/sky.ts +21 -1
- package/templates/action-rpg/src/render/vfx.ts +133 -58
- package/templates/action-rpg/src/render/worldEnvironment.ts +433 -30
- package/templates/action-rpg/src/scenes/Play.ts +81 -16
- package/templates/action-rpg/threenative.config.ts +3 -0
- package/templates/action-rpg/vite.config.ts +10 -2
- package/templates/minimal/AGENTS.md +9 -10
- package/templates/minimal/CLAUDE.md +9 -10
- package/templates/minimal/package.json +11 -9
- package/templates/minimal/playtests/play.playtest.json +7 -1
- package/templates/minimal/playtests/sky.playtest.json +10 -1
- package/templates/minimal/src/render/autoExposure.ts +225 -0
- package/templates/minimal/src/render/backlightControls.ts +66 -0
- package/templates/minimal/src/render/backlightMaterial.ts +147 -0
- package/templates/minimal/src/render/environmentContribution.ts +188 -0
- package/templates/minimal/src/render/environmentRadiance.ts +36 -0
- package/templates/minimal/src/render/environmentSampleCache.ts +43 -0
- package/templates/minimal/src/render/environmentSampling.ts +193 -0
- package/templates/minimal/src/render/environmentSnapshot.ts +53 -0
- package/templates/minimal/src/render/exposure.ts +111 -0
- package/templates/minimal/src/render/exposureGraph.ts +178 -0
- package/templates/minimal/src/render/exposureReadback.ts +79 -0
- package/templates/minimal/src/render/heightFog.ts +118 -0
- package/templates/minimal/src/render/lighting.ts +25 -1
- package/templates/minimal/src/render/materialAssignments.ts +102 -0
- package/templates/minimal/src/render/materialLighting.ts +146 -0
- package/templates/minimal/src/render/postprocessing.ts +16 -2
- package/templates/minimal/src/render/quality.ts +60 -2
- package/templates/minimal/src/render/sky.ts +21 -1
- package/templates/minimal/src/render/worldEnvironment.ts +433 -30
- package/templates/minimal/src/scenes/Play.ts +50 -1
- package/templates/minimal/vite.config.ts +10 -2
- package/templates/platformer/AGENTS.md +7 -5
- package/templates/platformer/CLAUDE.md +7 -5
- package/templates/platformer/package.json +13 -10
- package/templates/platformer/playtests/performance.playtest.json +7 -1
- package/templates/platformer/src/render/autoExposure.ts +225 -0
- package/templates/platformer/src/render/backlightControls.ts +66 -0
- package/templates/platformer/src/render/backlightMaterial.ts +147 -0
- package/templates/platformer/src/render/environmentContribution.ts +188 -0
- package/templates/platformer/src/render/environmentRadiance.ts +36 -0
- package/templates/platformer/src/render/environmentSampleCache.ts +43 -0
- package/templates/platformer/src/render/environmentSampling.ts +193 -0
- package/templates/platformer/src/render/environmentSnapshot.ts +53 -0
- package/templates/platformer/src/render/exposure.ts +111 -0
- package/templates/platformer/src/render/exposureGraph.ts +178 -0
- package/templates/platformer/src/render/exposureReadback.ts +79 -0
- package/templates/platformer/src/render/heightFog.ts +118 -0
- package/templates/platformer/src/render/lighting.ts +26 -1
- package/templates/platformer/src/render/materialAssignments.ts +160 -0
- package/templates/platformer/src/render/materialLighting.ts +155 -0
- package/templates/platformer/src/render/materials.ts +7 -2
- package/templates/platformer/src/render/palette.ts +3 -3
- package/templates/platformer/src/render/postprocessing.ts +17 -2
- package/templates/platformer/src/render/quality.ts +61 -2
- package/templates/platformer/src/render/sky.ts +72 -23
- package/templates/platformer/src/render/skyEnvironment.ts +50 -0
- package/templates/platformer/src/render/worldEnvironment.ts +433 -30
- package/templates/platformer/src/scenes/Play.ts +70 -6
- package/templates/platformer/vite.config.ts +10 -2
- package/templates/puzzle/AGENTS.md +10 -9
- package/templates/puzzle/CLAUDE.md +10 -9
- package/templates/puzzle/package.json +13 -10
- package/templates/puzzle/playtests/boot-failure.playtest.json +2 -2
- package/templates/puzzle/playtests/lit.playtest.json +7 -1
- package/templates/puzzle/playtests/performance.playtest.json +7 -1
- package/templates/puzzle/src/render/autoExposure.ts +225 -0
- package/templates/puzzle/src/render/backlightControls.ts +66 -0
- package/templates/puzzle/src/render/backlightMaterial.ts +147 -0
- package/templates/puzzle/src/render/environmentContribution.ts +188 -0
- package/templates/puzzle/src/render/environmentRadiance.ts +36 -0
- package/templates/puzzle/src/render/environmentSampleCache.ts +43 -0
- package/templates/puzzle/src/render/environmentSampling.ts +193 -0
- package/templates/puzzle/src/render/environmentSnapshot.ts +53 -0
- package/templates/puzzle/src/render/exposure.ts +111 -0
- package/templates/puzzle/src/render/exposureGraph.ts +178 -0
- package/templates/puzzle/src/render/exposureReadback.ts +79 -0
- package/templates/puzzle/src/render/heightFog.ts +118 -0
- package/templates/puzzle/src/render/lighting.ts +33 -1
- package/templates/puzzle/src/render/materialAssignments.ts +160 -0
- package/templates/puzzle/src/render/materialLighting.ts +155 -0
- package/templates/puzzle/src/render/materials.ts +1 -1
- package/templates/puzzle/src/render/postprocessing.ts +8 -2
- package/templates/puzzle/src/render/quality.ts +62 -1
- package/templates/puzzle/src/render/sky.ts +20 -1
- package/templates/puzzle/src/render/worldEnvironment.ts +433 -30
- package/templates/puzzle/src/scenes/Play.ts +51 -2
- package/templates/puzzle/vite.config.ts +10 -2
- package/templates/racing/AGENTS.md +8 -7
- package/templates/racing/CLAUDE.md +8 -7
- package/templates/racing/package.json +13 -10
- package/templates/racing/playtests/performance.playtest.json +7 -1
- package/templates/racing/playtests/survives.playtest.json +6 -0
- package/templates/racing/src/render/autoExposure.ts +225 -0
- package/templates/racing/src/render/backlightControls.ts +66 -0
- package/templates/racing/src/render/backlightMaterial.ts +147 -0
- package/templates/racing/src/render/environmentContribution.ts +188 -0
- package/templates/racing/src/render/environmentRadiance.ts +36 -0
- package/templates/racing/src/render/environmentSampleCache.ts +43 -0
- package/templates/racing/src/render/environmentSampling.ts +193 -0
- package/templates/racing/src/render/environmentSnapshot.ts +53 -0
- package/templates/racing/src/render/exposure.ts +111 -0
- package/templates/racing/src/render/exposureGraph.ts +178 -0
- package/templates/racing/src/render/exposureReadback.ts +79 -0
- package/templates/racing/src/render/heightFog.ts +118 -0
- package/templates/racing/src/render/lighting.ts +29 -1
- package/templates/racing/src/render/materialAssignments.ts +160 -0
- package/templates/racing/src/render/materialLighting.ts +155 -0
- package/templates/racing/src/render/palette.ts +1 -10
- package/templates/racing/src/render/postprocessing.ts +17 -2
- package/templates/racing/src/render/quality.ts +61 -2
- package/templates/racing/src/render/shapes.ts +0 -25
- package/templates/racing/src/render/sky.ts +25 -5
- package/templates/racing/src/render/worldEnvironment.ts +433 -30
- package/templates/racing/src/scenes/Race.ts +110 -13
- package/templates/racing/src/track/circuit.ts +0 -9
- package/templates/racing/vite.config.ts +10 -2
- package/templates/rain/AGENTS.md +8 -9
- package/templates/rain/CLAUDE.md +8 -9
- package/templates/rain/native-playtests/boot.playtest.json +11 -1
- package/templates/rain/package.json +14 -10
- package/templates/rain/playtests/automation.playtest.json +1 -1
- package/templates/rain/playtests/performance.playtest.json +11 -1
- package/templates/rain/playtests/tiers.playtest.json +15 -0
- package/templates/rain/playtests/weather.playtest.json +1 -1
- package/templates/rain/src/game.ts +1 -34
- package/templates/rain/src/render/autoExposure.ts +225 -0
- package/templates/rain/src/render/exposure.ts +111 -0
- package/templates/rain/src/render/exposureGraph.ts +178 -0
- package/templates/rain/src/render/exposureReadback.ts +79 -0
- package/templates/rain/src/render/postprocessing.ts +3 -0
- package/templates/rain/src/render/quality.ts +27 -1
- package/templates/rain/src/render/worldEnvironment.ts +433 -30
- package/templates/rain/src/scenes/Boot.ts +14 -0
- package/templates/rain/src/state.ts +5 -1
- package/templates/rain/src/ui/GameUi.tsx +6 -6
- package/templates/rain/tools/generate-shaders.mjs +1 -1
- package/templates/rain/vite.config.ts +10 -2
- package/templates/rts/AGENTS.md +10 -11
- package/templates/rts/CLAUDE.md +10 -11
- package/templates/rts/package.json +12 -9
- package/templates/rts/playtests/performance.playtest.json +7 -1
- package/templates/rts/playtests/rts-ai-attack.playtest.json +10 -1
- package/templates/rts/playtests/rts-attack.playtest.json +10 -1
- package/templates/rts/playtests/rts-build.playtest.json +10 -1
- package/templates/rts/playtests/rts-orders.playtest.json +7 -1
- package/templates/rts/playtests/rts-train.playtest.json +10 -1
- package/templates/rts/src/render/army.ts +10 -2
- package/templates/rts/src/render/autoExposure.ts +225 -0
- package/templates/rts/src/render/backlightControls.ts +66 -0
- package/templates/rts/src/render/backlightMaterial.ts +147 -0
- package/templates/rts/src/render/environmentContribution.ts +188 -0
- package/templates/rts/src/render/environmentRadiance.ts +36 -0
- package/templates/rts/src/render/environmentSampleCache.ts +43 -0
- package/templates/rts/src/render/environmentSampling.ts +193 -0
- package/templates/rts/src/render/environmentSnapshot.ts +53 -0
- package/templates/rts/src/render/exposure.ts +111 -0
- package/templates/rts/src/render/exposureGraph.ts +178 -0
- package/templates/rts/src/render/exposureReadback.ts +79 -0
- package/templates/rts/src/render/heightFog.ts +118 -0
- package/templates/rts/src/render/lighting.ts +26 -1
- package/templates/rts/src/render/materialAssignments.ts +160 -0
- package/templates/rts/src/render/materialLighting.ts +155 -0
- package/templates/rts/src/render/postprocessing.ts +8 -2
- package/templates/rts/src/render/quality.ts +61 -2
- package/templates/rts/src/render/sky.ts +21 -1
- package/templates/rts/src/render/worldEnvironment.ts +433 -30
- package/templates/rts/src/scenes/Play.ts +54 -3
- package/templates/rts/src/sim/ai.ts +0 -1
- package/templates/rts/src/sim/terrain.ts +0 -4
- package/templates/rts/vite.config.ts +10 -2
- package/templates/runner/AGENTS.md +10 -8
- package/templates/runner/CLAUDE.md +10 -8
- package/templates/runner/package.json +13 -10
- package/templates/runner/playtests/performance.playtest.json +10 -1
- package/templates/runner/src/physics.ts +0 -1
- package/templates/runner/src/render/autoExposure.ts +225 -0
- package/templates/runner/src/render/backlightControls.ts +66 -0
- package/templates/runner/src/render/backlightMaterial.ts +147 -0
- package/templates/runner/src/render/environmentContribution.ts +188 -0
- package/templates/runner/src/render/environmentRadiance.ts +36 -0
- package/templates/runner/src/render/environmentSampleCache.ts +43 -0
- package/templates/runner/src/render/environmentSampling.ts +193 -0
- package/templates/runner/src/render/environmentSnapshot.ts +53 -0
- package/templates/runner/src/render/exposure.ts +111 -0
- package/templates/runner/src/render/exposureGraph.ts +178 -0
- package/templates/runner/src/render/exposureReadback.ts +79 -0
- package/templates/runner/src/render/heightFog.ts +118 -0
- package/templates/runner/src/render/lighting.ts +26 -1
- package/templates/runner/src/render/materialAssignments.ts +160 -0
- package/templates/runner/src/render/materialLighting.ts +155 -0
- package/templates/runner/src/render/postprocessing.ts +17 -2
- package/templates/runner/src/render/quality.ts +61 -2
- package/templates/runner/src/render/sky.ts +21 -1
- package/templates/runner/src/render/worldEnvironment.ts +433 -30
- package/templates/runner/src/scenes/Run.ts +67 -2
- package/templates/runner/threenative.config.ts +3 -0
- package/templates/runner/vite.config.ts +10 -2
- package/templates/sailing/AGENTS.md +14 -13
- package/templates/sailing/CLAUDE.md +14 -13
- package/templates/sailing/native-playtests/survives.playtest.json +7 -0
- package/templates/sailing/package.json +13 -10
- package/templates/sailing/playtests/live/render-motion.playtest.json +30 -0
- package/templates/sailing/src/entities/Ship.ts +38 -18
- package/templates/sailing/src/render/autoExposure.ts +225 -0
- package/templates/sailing/src/render/backlightControls.ts +66 -0
- package/templates/sailing/src/render/backlightMaterial.ts +147 -0
- package/templates/sailing/src/render/camera.ts +12 -4
- package/templates/sailing/src/render/environmentContribution.ts +188 -0
- package/templates/sailing/src/render/environmentRadiance.ts +36 -0
- package/templates/sailing/src/render/environmentSampleCache.ts +43 -0
- package/templates/sailing/src/render/environmentSampling.ts +193 -0
- package/templates/sailing/src/render/environmentSetup.ts +24 -0
- package/templates/sailing/src/render/environmentSnapshot.ts +53 -0
- package/templates/sailing/src/render/exposure.ts +111 -0
- package/templates/sailing/src/render/exposureGraph.ts +178 -0
- package/templates/sailing/src/render/exposureReadback.ts +79 -0
- package/templates/sailing/src/render/heightFog.ts +118 -0
- package/templates/sailing/src/render/lighting.ts +26 -1
- package/templates/sailing/src/render/materialAssignments.ts +160 -0
- package/templates/sailing/src/render/materialLighting.ts +155 -0
- package/templates/sailing/src/render/ocean.ts +71 -53
- package/templates/sailing/src/render/postprocessing.ts +16 -2
- package/templates/sailing/src/render/props.ts +0 -45
- package/templates/sailing/src/render/quality.ts +61 -1
- package/templates/sailing/src/render/sky.ts +21 -1
- package/templates/sailing/src/render/worldEnvironment.ts +433 -30
- package/templates/sailing/src/scenes/Boot.ts +12 -1
- package/templates/sailing/src/scenes/Sailing.ts +87 -2
- package/templates/sailing/src/scenes/ocean-readiness.ts +68 -0
- package/templates/sailing/threenative.config.ts +3 -0
- package/templates/sailing/vite.config.ts +10 -2
- package/templates/shooter/AGENTS.md +8 -6
- package/templates/shooter/CLAUDE.md +8 -6
- package/templates/shooter/package.json +13 -10
- package/templates/shooter/playtests/performance.playtest.json +7 -1
- package/templates/shooter/src/entities/Enemy.ts +0 -15
- package/templates/shooter/src/entities/Rifle.ts +38 -1
- package/templates/shooter/src/render/autoExposure.ts +225 -0
- package/templates/shooter/src/render/backlightControls.ts +66 -0
- package/templates/shooter/src/render/backlightMaterial.ts +147 -0
- package/templates/shooter/src/render/camera.ts +1 -12
- package/templates/shooter/src/render/decals.ts +299 -5
- package/templates/shooter/src/render/environmentContribution.ts +188 -0
- package/templates/shooter/src/render/environmentRadiance.ts +36 -0
- package/templates/shooter/src/render/environmentSampleCache.ts +43 -0
- package/templates/shooter/src/render/environmentSampling.ts +193 -0
- package/templates/shooter/src/render/environmentSnapshot.ts +53 -0
- package/templates/shooter/src/render/exposure.ts +111 -0
- package/templates/shooter/src/render/exposureGraph.ts +178 -0
- package/templates/shooter/src/render/exposureReadback.ts +79 -0
- package/templates/shooter/src/render/gunfx.ts +0 -1
- package/templates/shooter/src/render/heightFog.ts +118 -0
- package/templates/shooter/src/render/lighting.ts +26 -1
- package/templates/shooter/src/render/materialAssignments.ts +160 -0
- package/templates/shooter/src/render/materialLighting.ts +155 -0
- package/templates/shooter/src/render/postprocessing.ts +17 -2
- package/templates/shooter/src/render/quality.ts +61 -2
- package/templates/shooter/src/render/scale.ts +2 -93
- package/templates/shooter/src/render/sky.ts +21 -1
- package/templates/shooter/src/render/vehicles.ts +0 -17
- package/templates/shooter/src/render/worldEnvironment.ts +433 -30
- package/templates/shooter/src/scenes/Play.ts +64 -2
- package/templates/shooter/vite.config.ts +10 -2
- package/templates/snow/AGENTS.md +8 -6
- package/templates/snow/CLAUDE.md +8 -6
- package/templates/snow/package.json +13 -10
- package/templates/snow/src/render/autoExposure.ts +225 -0
- package/templates/snow/src/render/backlightControls.ts +66 -0
- package/templates/snow/src/render/backlightMaterial.ts +147 -0
- package/templates/snow/src/render/environmentContribution.ts +188 -0
- package/templates/snow/src/render/environmentRadiance.ts +36 -0
- package/templates/snow/src/render/environmentSampleCache.ts +43 -0
- package/templates/snow/src/render/environmentSampling.ts +193 -0
- package/templates/snow/src/render/environmentSnapshot.ts +53 -0
- package/templates/snow/src/render/exposure.ts +111 -0
- package/templates/snow/src/render/exposureGraph.ts +178 -0
- package/templates/snow/src/render/exposureReadback.ts +79 -0
- package/templates/snow/src/render/heightFog.ts +118 -0
- package/templates/snow/src/render/lighting.ts +33 -1
- package/templates/snow/src/render/materialAssignments.ts +160 -0
- package/templates/snow/src/render/materialLighting.ts +155 -0
- package/templates/snow/src/render/postprocessing.ts +16 -2
- package/templates/snow/src/render/quality.ts +59 -1
- package/templates/snow/src/render/sky.ts +21 -2
- package/templates/snow/src/render/worldEnvironment.ts +433 -30
- package/templates/snow/src/scenes/Snow.ts +29 -1
- package/templates/snow/threenative.config.ts +3 -0
- package/templates/snow/vite.config.ts +10 -2
- package/templates/starter/AGENTS.md +11 -16
- package/templates/starter/CLAUDE.md +11 -16
- package/templates/starter/native-playtests/react-hud.playtest.json +1 -1
- package/templates/starter/native-playtests/render-chain.playtest.json +51 -8
- package/templates/starter/native-playtests/smooth-motion.playtest.json +64 -0
- package/templates/starter/package.json +13 -10
- package/templates/starter/playtests/live/smooth-motion.playtest.json +63 -0
- package/templates/starter/playtests/movement.playtest.json +192 -0
- package/templates/starter/playtests/play.playtest.json +18 -2
- package/templates/starter/playtests/production-readiness.playtest.json +43 -1
- package/templates/starter/public/grade.cube +735 -0
- package/templates/starter/src/entities/Crate.ts +4 -0
- package/templates/starter/src/entities/Player.ts +79 -18
- package/templates/starter/src/game.ts +1 -0
- package/templates/starter/src/render/adaptiveQuality.ts +28 -41
- package/templates/starter/src/render/autoExposure.ts +225 -0
- package/templates/starter/src/render/backlightControls.ts +66 -0
- package/templates/starter/src/render/backlightMaterial.ts +147 -0
- package/templates/starter/src/render/environmentContribution.ts +188 -0
- package/templates/starter/src/render/environmentRadiance.ts +36 -0
- package/templates/starter/src/render/environmentSampleCache.ts +43 -0
- package/templates/starter/src/render/environmentSampling.ts +193 -0
- package/templates/starter/src/render/environmentSnapshot.ts +53 -0
- package/templates/starter/src/render/exposure.ts +111 -0
- package/templates/starter/src/render/exposureGraph.ts +178 -0
- package/templates/starter/src/render/exposureReadback.ts +79 -0
- package/templates/starter/src/render/grade.ts +157 -0
- package/templates/starter/src/render/heightFog.ts +118 -0
- package/templates/starter/src/render/lighting.ts +26 -1
- package/templates/starter/src/render/materialAssignments.ts +160 -0
- package/templates/starter/src/render/materialLighting.ts +155 -0
- package/templates/starter/src/render/postprocessing.ts +90 -4
- package/templates/starter/src/render/quality.ts +80 -8
- package/templates/starter/src/render/qualityPolicy.ts +54 -0
- package/templates/starter/src/render/rendererGate.ts +36 -0
- package/templates/starter/src/render/sky.ts +23 -1
- package/templates/starter/src/render/temporalAA.ts +197 -0
- package/templates/starter/src/render/temporalAAFrame.ts +179 -0
- package/templates/starter/src/render/temporalAAHooks.ts +101 -0
- package/templates/starter/src/render/temporalAAInput.ts +56 -0
- package/templates/starter/src/render/temporalAAResolve.ts +65 -0
- package/templates/starter/src/render/temporalAAStage.ts +76 -0
- package/templates/starter/src/render/temporalCurrentArea.ts +31 -0
- package/templates/starter/src/render/temporalCurrentFootprint.ts +198 -0
- package/templates/starter/src/render/temporalCurrentFootprintMath.ts +41 -0
- package/templates/starter/src/render/temporalCurrentProducer.ts +161 -0
- package/templates/starter/src/render/temporalCurrentReplay.ts +160 -0
- package/templates/starter/src/render/temporalCurrentSelection.ts +89 -0
- package/templates/starter/src/render/temporalCurrentVisibility.ts +170 -0
- package/templates/starter/src/render/temporalDepthSamples.ts +34 -0
- package/templates/starter/src/render/temporalRejectionCounter.ts +179 -0
- package/templates/starter/src/render/temporalResolve.ts +139 -0
- package/templates/starter/src/render/temporalResolveDepth.ts +193 -0
- package/templates/starter/src/render/temporalResolveMath.ts +196 -0
- package/templates/starter/src/render/volumetricFog.ts +124 -0
- package/templates/starter/src/render/volumetricFogOptions.ts +96 -0
- package/templates/starter/src/render/volumetricFogTransport.ts +176 -0
- package/templates/starter/src/render/volumetricFogVolume.ts +139 -0
- package/templates/starter/src/render/worldEnvironment.ts +433 -30
- package/templates/starter/src/scenes/Play.ts +110 -1
- package/templates/starter/src/state.ts +1 -0
- package/templates/starter/src/ui/Hud.tsx +1 -1
- package/templates/starter/src/ui/Menu.tsx +1 -1
- package/templates/starter/tools/make-grade-lut.mjs +101 -0
- package/templates/starter/vite.config.ts +10 -2
- package/templates/tower-defense/AGENTS.md +10 -9
- package/templates/tower-defense/CLAUDE.md +10 -9
- package/templates/tower-defense/package.json +13 -10
- package/templates/tower-defense/playtests/performance.playtest.json +7 -1
- package/templates/tower-defense/src/render/autoExposure.ts +225 -0
- package/templates/tower-defense/src/render/backlightControls.ts +66 -0
- package/templates/tower-defense/src/render/backlightMaterial.ts +147 -0
- package/templates/tower-defense/src/render/environmentContribution.ts +188 -0
- package/templates/tower-defense/src/render/environmentRadiance.ts +36 -0
- package/templates/tower-defense/src/render/environmentSampleCache.ts +43 -0
- package/templates/tower-defense/src/render/environmentSampling.ts +193 -0
- package/templates/tower-defense/src/render/environmentSnapshot.ts +53 -0
- package/templates/tower-defense/src/render/exposure.ts +111 -0
- package/templates/tower-defense/src/render/exposureGraph.ts +178 -0
- package/templates/tower-defense/src/render/exposureReadback.ts +79 -0
- package/templates/tower-defense/src/render/lighting.ts +33 -1
- package/templates/tower-defense/src/render/materialAssignments.ts +160 -0
- package/templates/tower-defense/src/render/materialLighting.ts +155 -0
- package/templates/tower-defense/src/render/postprocessing.ts +8 -2
- package/templates/tower-defense/src/render/quality.ts +61 -2
- package/templates/tower-defense/src/render/shapes.ts +0 -3
- package/templates/tower-defense/src/render/worldEnvironment.ts +433 -30
- package/templates/tower-defense/src/scenes/Battle.ts +65 -2
- package/templates/tower-defense/vite.config.ts +10 -2
- package/templates/minimal/src/scenes/Boot.ts +0 -5
|
@@ -25,13 +25,17 @@ import { type IPlayerModel, PLAYER_STAND_Y, Player } from "../entities/Player.js
|
|
|
25
25
|
import { createArena, platform } from "../render/arena.js";
|
|
26
26
|
import { createSpringArm } from "../render/camera.js";
|
|
27
27
|
import { pickupRiseEase } from "../render/easing.js";
|
|
28
|
+
import { type IEnvironmentSample, sampleEnvironment } from "../render/environmentSampling.js";
|
|
28
29
|
import { setupLighting } from "../render/lighting.js";
|
|
29
30
|
import { createLoadingScreen } from "../render/loading.js";
|
|
31
|
+
import { createMaterialLighting } from "../render/materialLighting.js";
|
|
30
32
|
import { createPennantMaterial, propMaterial } from "../render/materials.js";
|
|
31
33
|
import { setupPost } from "../render/postprocessing.js";
|
|
34
|
+
import { isWebGLFallbackRenderer, materialLightingEnabled } from "../render/quality.js";
|
|
32
35
|
import { ball, block, spike, tube } from "../render/shapes.js";
|
|
33
36
|
import { setupSky } from "../render/sky.js";
|
|
34
37
|
import { TouchControls } from "../render/touch-controls.js";
|
|
38
|
+
import { STARTER_MIST, createVolumetricFog } from "../render/volumetricFog.js";
|
|
35
39
|
import type { GameState } from "../state.js";
|
|
36
40
|
|
|
37
41
|
export type GameCtx = ICtx<GameState, IPhysicsContext>;
|
|
@@ -44,9 +48,11 @@ const FLOOR_BOUNDS = { maxX: 5, minX: -5, maxZ: 2, minZ: -2 } as const;
|
|
|
44
48
|
const FLOOR_SIZE = { depth: 4.2, width: 10 } as const;
|
|
45
49
|
|
|
46
50
|
export class Play extends Scene<GameState, IPhysicsContext> {
|
|
51
|
+
#observeMotion: (() => void) | undefined;
|
|
47
52
|
#assetProof: Mesh | undefined;
|
|
48
53
|
#playerModel: IPlayerModel | undefined;
|
|
49
54
|
#sky: Texture | undefined;
|
|
55
|
+
#environmentSample: IEnvironmentSample | undefined;
|
|
50
56
|
|
|
51
57
|
static override readonly initialState: GameState = {
|
|
52
58
|
coyoteJumps: 0,
|
|
@@ -62,6 +68,7 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
62
68
|
paused: false,
|
|
63
69
|
peakRise: 0,
|
|
64
70
|
playerX: -2,
|
|
71
|
+
progress: 0,
|
|
65
72
|
respawns: 0,
|
|
66
73
|
score: 0,
|
|
67
74
|
status: "playing",
|
|
@@ -77,6 +84,14 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
77
84
|
]);
|
|
78
85
|
this.#playerModel = playerModel;
|
|
79
86
|
this.#sky = sky;
|
|
87
|
+
setupSky(ctx.scene, sky, ctx.renderer.softwareAdapter !== undefined);
|
|
88
|
+
this.#environmentSample = await sampleEnvironment(ctx.renderer.raw, ctx.scene, {
|
|
89
|
+
web: getPlatform().runtime === "web",
|
|
90
|
+
rendererKind: ctx.renderer.kind,
|
|
91
|
+
webglFallback: isWebGLFallbackRenderer(ctx.renderer.raw),
|
|
92
|
+
mobile: isMobile(),
|
|
93
|
+
software: ctx.renderer.softwareAdapter !== undefined,
|
|
94
|
+
});
|
|
80
95
|
// A 16-pixel check filtered smoothly is a grey smear at flag size; nearest keeps the
|
|
81
96
|
// squares square, which is the whole reason the finish flag is legible from the ledge.
|
|
82
97
|
texture.magFilter = NearestFilter;
|
|
@@ -135,6 +150,45 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
135
150
|
z: 0,
|
|
136
151
|
}),
|
|
137
152
|
);
|
|
153
|
+
// Observation is armed by playtest's first sample; ordinary games retain no frame series.
|
|
154
|
+
let observeMotion = false;
|
|
155
|
+
let wasMovingRight = false;
|
|
156
|
+
const presented: Array<[number, number, number]> = [];
|
|
157
|
+
this.#observeMotion = () => {
|
|
158
|
+
if (!observeMotion) return;
|
|
159
|
+
const movingRight = ctx.input.vector("move").x > 0;
|
|
160
|
+
if (movingRight && !wasMovingRight) presented.length = 0;
|
|
161
|
+
wasMovingRight = movingRight;
|
|
162
|
+
if (!movingRight) return;
|
|
163
|
+
presented.push([ctx.frameTime, player.body.object.position.x, ctx.camera.position.x]);
|
|
164
|
+
if (presented.length > 31) presented.shift();
|
|
165
|
+
};
|
|
166
|
+
ctx.entities.add("smooth-motion", {
|
|
167
|
+
debug: () => {
|
|
168
|
+
observeMotion = true;
|
|
169
|
+
const speeds = (axis: 1 | 2): number[] =>
|
|
170
|
+
presented.slice(1).map((frame, index) => {
|
|
171
|
+
const previous = presented[index];
|
|
172
|
+
if (previous === undefined) throw new Error("Missing presented motion sample.");
|
|
173
|
+
return (frame[axis] - previous[axis]) / ((frame[0] - previous[0]) / 1000);
|
|
174
|
+
});
|
|
175
|
+
const cv = (values: number[]): number | null => {
|
|
176
|
+
if (values.length < 20) return null;
|
|
177
|
+
const mean = values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
178
|
+
if (mean <= 0) return null;
|
|
179
|
+
return (
|
|
180
|
+
Math.sqrt(values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / values.length) /
|
|
181
|
+
mean
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
samples: presented.length,
|
|
186
|
+
playerCv: cv(speeds(1)),
|
|
187
|
+
cameraCv: cv(speeds(2)),
|
|
188
|
+
presented,
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
});
|
|
138
192
|
const audio = ctx.entities.add("audio", new AudioBus({ camera: ctx.camera }));
|
|
139
193
|
const pickupAudio = ctx.assets.audio("pickup.wav");
|
|
140
194
|
void pickupAudio.catch(() => undefined);
|
|
@@ -146,16 +200,34 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
146
200
|
ctx.renderer.raw as Parameters<typeof setupLighting>[1],
|
|
147
201
|
isMobile(),
|
|
148
202
|
);
|
|
203
|
+
const materialEnvironment = {
|
|
204
|
+
web: getPlatform().runtime === "web",
|
|
205
|
+
rendererKind: ctx.renderer.kind,
|
|
206
|
+
webglFallback: isWebGLFallbackRenderer(ctx.renderer.raw),
|
|
207
|
+
mobile: isMobile(),
|
|
208
|
+
software: ctx.renderer.softwareAdapter !== undefined,
|
|
209
|
+
};
|
|
149
210
|
this.#post = ctx.entities.add(
|
|
150
211
|
"quality",
|
|
151
212
|
setupPost(ctx.renderer, ctx.scene, ctx.camera, {
|
|
152
213
|
godraysLight: key,
|
|
214
|
+
onTierChanged: (tier) =>
|
|
215
|
+
this.#materialLighting?.setEnabled(materialLightingEnabled(tier, materialEnvironment)),
|
|
153
216
|
mobile: isMobile(),
|
|
154
217
|
software: ctx.renderer.softwareAdapter !== undefined,
|
|
218
|
+
gpuClass: ctx.renderer.gpuClass?.class,
|
|
155
219
|
// One rule for the frame budget, from the engine: the display refresh capped at 120,
|
|
156
220
|
// 60 on mobile. A game that names `display.maxFps` overrides it here too.
|
|
157
221
|
targetFps: resolveTargetFps(config, getPlatform()).targetFps,
|
|
158
222
|
ready: () => ctx.startup.phase === "ready",
|
|
223
|
+
// Rebuilt per graph, so a tier change that replaces the chain cannot compose one medium
|
|
224
|
+
// twice. The look and the flag are `STARTER_MIST`'s, in `volumetricFog.ts`; only the
|
|
225
|
+
// backend is wired here, and with `enabled` false nothing is allocated at all.
|
|
226
|
+
fog: () =>
|
|
227
|
+
createVolumetricFog(ctx.scene, ctx.camera as PerspectiveCamera, {
|
|
228
|
+
...STARTER_MIST,
|
|
229
|
+
renderer: ctx.renderer.kind,
|
|
230
|
+
}),
|
|
159
231
|
}),
|
|
160
232
|
);
|
|
161
233
|
const loading = createLoadingScreen(ctx);
|
|
@@ -199,7 +271,7 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
199
271
|
);
|
|
200
272
|
ctx.add(fixed(floorMesh));
|
|
201
273
|
ctx.add(fixed(floorBase));
|
|
202
|
-
new Crate(ctx, levelX, 4, -1.5, propMaterial);
|
|
274
|
+
ctx.entities.add("crate", new Crate(ctx, levelX, 4, -1.5, propMaterial));
|
|
203
275
|
const pickupBase = block(0.42, 0.14, 0.42, propMaterial);
|
|
204
276
|
const pickupStem = tube(0.08, 0.08, 0.3, propMaterial);
|
|
205
277
|
const pickupOrb = ball(0.16, propMaterial);
|
|
@@ -220,6 +292,23 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
220
292
|
// not a debug object parked over the level. The texture and the glTF still load in
|
|
221
293
|
// `load()` above, which is what the native asset gate greps for.
|
|
222
294
|
const goal = ctx.entities.add("goal", new Goal(ctx, this.#assetProof));
|
|
295
|
+
// All borrowed materials, including the cloned skinned mannequin and arena, now exist.
|
|
296
|
+
this.#materialLighting = ctx.entities.add(
|
|
297
|
+
"material-lighting",
|
|
298
|
+
createMaterialLighting(ctx.scene, ctx.camera, key, {
|
|
299
|
+
...materialEnvironment,
|
|
300
|
+
enabled: materialLightingEnabled(this.#post.tier, materialEnvironment),
|
|
301
|
+
}),
|
|
302
|
+
);
|
|
303
|
+
if (this.#environmentSample !== undefined) {
|
|
304
|
+
const { measurement, source, intensity } = this.#environmentSample;
|
|
305
|
+
this.#materialLighting.setEnvironmentMeasurement(
|
|
306
|
+
measurement,
|
|
307
|
+
source,
|
|
308
|
+
intensity,
|
|
309
|
+
this.#environmentSample,
|
|
310
|
+
);
|
|
311
|
+
}
|
|
223
312
|
const supportSurfaceY = (position: { readonly x: number; readonly z: number }):
|
|
224
313
|
| number
|
|
225
314
|
| undefined => {
|
|
@@ -309,6 +398,7 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
309
398
|
lives -= 1;
|
|
310
399
|
player.respawn();
|
|
311
400
|
springArm.snap(player.mesh.position);
|
|
401
|
+
frameCtx.resetInterpolation(frameCtx.camera);
|
|
312
402
|
respawned = true;
|
|
313
403
|
}
|
|
314
404
|
springArm.dolly(frameCtx.input.axis("zoom"), dt);
|
|
@@ -331,6 +421,15 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
331
421
|
// 1.8 m figure would report its own height as a jump.
|
|
332
422
|
frameState.peakRise = Math.max(previous.peakRise, player.mesh.position.y - PLAYER_STAND_Y);
|
|
333
423
|
frameState.playerX = player.mesh.position.x;
|
|
424
|
+
frameState.progress = Math.max(
|
|
425
|
+
0,
|
|
426
|
+
Math.min(
|
|
427
|
+
100,
|
|
428
|
+
((frameState.playerX - Play.initialState.playerX) /
|
|
429
|
+
(ISLAND.x - ISLAND.width / 2 - Play.initialState.playerX)) *
|
|
430
|
+
100,
|
|
431
|
+
),
|
|
432
|
+
);
|
|
334
433
|
frameState.respawns = previous.respawns + (respawned ? 1 : 0);
|
|
335
434
|
const current = frameCtx.state.getState();
|
|
336
435
|
const changed =
|
|
@@ -343,6 +442,7 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
343
442
|
frameState.odometer !== current.odometer ||
|
|
344
443
|
frameState.peakRise !== current.peakRise ||
|
|
345
444
|
frameState.playerX !== current.playerX ||
|
|
445
|
+
frameState.progress !== current.progress ||
|
|
346
446
|
frameState.respawns !== current.respawns;
|
|
347
447
|
if (changed) frameCtx.state.set(frameState);
|
|
348
448
|
if (respawned) frameCtx.state.flush();
|
|
@@ -350,8 +450,17 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
350
450
|
}
|
|
351
451
|
|
|
352
452
|
#post: ReturnType<typeof setupPost> | undefined;
|
|
453
|
+
#materialLighting: ReturnType<typeof createMaterialLighting> | undefined;
|
|
454
|
+
|
|
455
|
+
override render(): void {
|
|
456
|
+
this.#observeMotion?.();
|
|
457
|
+
}
|
|
353
458
|
|
|
354
459
|
override exit(ctx: GameCtx): void {
|
|
460
|
+
this.#observeMotion = undefined;
|
|
461
|
+
this.#materialLighting?.dispose();
|
|
462
|
+
this.#materialLighting = undefined;
|
|
463
|
+
// Also releases the medium `setupPost` built, with the graph it composed into.
|
|
355
464
|
this.#post?.dispose();
|
|
356
465
|
this.#post = undefined;
|
|
357
466
|
super.exit(ctx);
|
|
@@ -16,7 +16,7 @@ export function Hud() {
|
|
|
16
16
|
// Nothing to draw until the game publishes its first snapshot, a few milliseconds in. Rendering
|
|
17
17
|
// zeroes instead would put a wrong score on screen and then correct it.
|
|
18
18
|
if (state === undefined) return null;
|
|
19
|
-
const position =
|
|
19
|
+
const position = state.progress;
|
|
20
20
|
const won = state.status === "won";
|
|
21
21
|
|
|
22
22
|
return (
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Writes this game's colour table to `public/grade.cube`.
|
|
3
|
+
//
|
|
4
|
+
// `src/render/grade.ts` loads whatever is in that file and looks it up; nothing else in the game
|
|
5
|
+
// knows what the grade is. Swap that file for a `.cube` exported from any grading tool and the
|
|
6
|
+
// stage reads that instead — this script exists so the shipped table is reproducible and its few
|
|
7
|
+
// numbers sit in one readable place, not because a `.cube` needs generating.
|
|
8
|
+
//
|
|
9
|
+
// node tools/make-grade-lut.mjs the shipped grade
|
|
10
|
+
// node tools/make-grade-lut.mjs --identity a table that changes nothing, for checking the
|
|
11
|
+
// round trip through grade.ts
|
|
12
|
+
// node tools/make-grade-lut.mjs --out other.cube
|
|
13
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Table edge length. 9 keeps the shipped table a readable 729 lines, and the cost of a coarse grid
|
|
19
|
+
* is measured rather than assumed: the hardware's trilinear interpolation of this grade departs
|
|
20
|
+
* from the curve it was written from by at most 7.5 of 255 steps, all of it in the top interval of
|
|
21
|
+
* a channel whose gain above one has to clip (`__tests__/grade.spec.ts` measures both numbers, and
|
|
22
|
+
* re-reads the constants below from this file, so raising SIZE cannot pass unnoticed). A grade that
|
|
23
|
+
* needs its top of the range followed exactly wants 17 or 33; a gentler curve wants neither.
|
|
24
|
+
*/
|
|
25
|
+
const SIZE = 9;
|
|
26
|
+
|
|
27
|
+
/** The grade itself, in display-referred [0, 1] — which is what a `.cube` is written against. */
|
|
28
|
+
const CONTRAST = 1.06;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The pivot is mid-grey, and that is most of what makes this a default rather than a look. A pivot
|
|
32
|
+
* at 0.18 — where this table started — leaves everything above it brighter, because a contrast
|
|
33
|
+
* curve anchored low down lifts the whole middle of the range: measured on the frame, it moved
|
|
34
|
+
* mid-grey up 8 of 255 steps and the sky up 12, which is what "washed toward cream" and "muddy"
|
|
35
|
+
* read like on screen. Anchored at 0.5 it darkens below the middle, brightens above it, and keeps
|
|
36
|
+
* the blacks where they were.
|
|
37
|
+
*/
|
|
38
|
+
const PIVOT = 0.5;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The channel mixer, and deliberately the smallest one that is still a grade.
|
|
42
|
+
*
|
|
43
|
+
* This started at `{ b: 0.94, g: 1, r: 1.07 }` — a 13% warm spread. A blind judge compared the
|
|
44
|
+
* starter with that table against the starter without one and preferred **no table**: grey
|
|
45
|
+
* concrete read as sandstone, the sky as cream, and the whole frame as mud. A default that makes
|
|
46
|
+
* the picture worse is not a default, so the spread is now about 1/26 of that — one 8-bit step or
|
|
47
|
+
* less on concrete and on sky alike, which is what `__tests__/grade.spec.ts` pins. A game that
|
|
48
|
+
* wants the warm look names its own gain here.
|
|
49
|
+
*/
|
|
50
|
+
const GAIN = { b: 0.9975, g: 1, r: 1.0025 };
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Contrast about a pivot: a power function that leaves the pivot alone and darkens below it. This
|
|
54
|
+
* is the one operation a grading tool would call a curve; the gain above is its channel mixer, and
|
|
55
|
+
* it is why the top of the warm channel clips — a gain above one cannot brighten a pixel that is
|
|
56
|
+
* already white, which is what the table above says about highlights.
|
|
57
|
+
*/
|
|
58
|
+
const grade = (value, channel) =>
|
|
59
|
+
Math.min(1, PIVOT ** (1 - CONTRAST) * value ** CONTRAST * GAIN[channel]);
|
|
60
|
+
|
|
61
|
+
function flag(name) {
|
|
62
|
+
return process.argv.includes(`--${name}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function option(name, fallback) {
|
|
66
|
+
const at = process.argv.indexOf(`--${name}`);
|
|
67
|
+
return at === -1 ? fallback : process.argv[at + 1];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const identity = flag("identity");
|
|
71
|
+
const target = option(
|
|
72
|
+
"out",
|
|
73
|
+
path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "public", "grade.cube"),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const lines = [
|
|
77
|
+
"# Written by tools/make-grade-lut.mjs — edit that, not this file.",
|
|
78
|
+
`# ${identity ? "Identity table: this game ungraded, to check the round trip." : "This game's grade."}`,
|
|
79
|
+
"# Red varies fastest, which is the Cube LUT order and the x axis of the uploaded 3D texture.",
|
|
80
|
+
`TITLE "starter ${identity ? "identity" : "neutral-warm"}"`,
|
|
81
|
+
`LUT_3D_SIZE ${SIZE}`,
|
|
82
|
+
"",
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
// `LUTCubeLoader` copies each line's three numbers into x, y then z, so the loop below walks x
|
|
86
|
+
// fastest and an identity table is a straight ramp along every axis.
|
|
87
|
+
for (let texel = 0; texel < SIZE ** 3; texel += 1) {
|
|
88
|
+
const r = (texel % SIZE) / (SIZE - 1);
|
|
89
|
+
const g = (Math.floor(texel / SIZE) % SIZE) / (SIZE - 1);
|
|
90
|
+
const b = (Math.floor(texel / SIZE ** 2) % SIZE) / (SIZE - 1);
|
|
91
|
+
const graded = [
|
|
92
|
+
identity ? r : grade(r, "r"),
|
|
93
|
+
identity ? g : grade(g, "g"),
|
|
94
|
+
identity ? b : grade(b, "b"),
|
|
95
|
+
];
|
|
96
|
+
lines.push(graded.map((value) => value.toFixed(6)).join(" "));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
mkdirSync(path.dirname(target), { recursive: true });
|
|
100
|
+
writeFileSync(target, `${lines.join("\n")}\n`, "utf8");
|
|
101
|
+
process.stdout.write(`wrote ${target} (${SIZE}^3, red varies fastest)\n`);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import tailwindcss from "@tailwindcss/vite";
|
|
2
2
|
import { watchAssets } from "@threenative/assets";
|
|
3
3
|
import react from "@vitejs/plugin-react";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
createEngineFreshnessPlugin,
|
|
6
|
+
createWebBrandPlugin,
|
|
7
|
+
webRuntimeDecoders,
|
|
8
|
+
} from "create-threenative";
|
|
5
9
|
import { defineConfig } from "vite";
|
|
6
10
|
import type { Plugin } from "vite";
|
|
7
11
|
import config from "./threenative.config.js";
|
|
@@ -15,7 +19,11 @@ function assetsWatchPlugin(): Plugin {
|
|
|
15
19
|
name: "threenative-assets-watch",
|
|
16
20
|
apply: "serve",
|
|
17
21
|
async configureServer(server) {
|
|
18
|
-
const handle = watchAssets({
|
|
22
|
+
const handle = watchAssets({
|
|
23
|
+
config: config.assets,
|
|
24
|
+
cwd: server.config.root,
|
|
25
|
+
runtimeDecoders: webRuntimeDecoders(config),
|
|
26
|
+
});
|
|
19
27
|
server.httpServer?.once("close", () => handle.close());
|
|
20
28
|
// Nothing is served before the first cook settles: until it does, `public/` has no
|
|
21
29
|
// `assets.manifest.json` and every asset answers from its source fallback.
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Instructions for the AI agent in this game. `CLAUDE.md` mirrors this file; edit `AGENTS.md`.
|
|
4
4
|
|
|
5
5
|
## Ownership
|
|
6
|
-
|
|
7
6
|
ThreeNative owns bootstrap, renderer, fixed-step loop, input, loading, physics bindings, and the state bridge. This repository owns the road, pads, enemies, towers, economy, waves, HUD, and look;
|
|
8
|
-
`src/game.ts` is portable and React mounts only from `src/main.ts`. The render camera also skips an object that projects under **0.5 px** in it; `renderer.minimumProjectedPixels` raises that threshold (`false` disables the cut, not the count) and `alwaysRender(object)` exempts an object, while camera-attached objects and shadow casters are kept. The engine also owns the per-frame world-matrix walk, and by default it does not descend into a hidden subtree — so a game that reads a hidden object's `matrixWorld` directly must use `getWorldPosition` (or call `object.updateWorldMatrix(true, false)`) first; `renderer.matrixWorld: "all"` restores three's every-node walk, and `TN_PROJECTION` reports the visited-node count either way.
|
|
7
|
+
`src/game.ts` is portable and React mounts only from `src/main.ts`. The render camera also skips an object that projects under **0.5 px** in it; `renderer.minimumProjectedPixels` raises that threshold (`false` disables the cut, not the count) and `alwaysRender(object)` exempts an object, while camera-attached objects and shadow casters are kept. The engine also owns the per-frame world-matrix walk, and by default it does not descend into a hidden subtree — so a game that reads a hidden object's `matrixWorld` directly must use `getWorldPosition` (or call `object.updateWorldMatrix(true, false)`) first; `renderer.matrixWorld: "all"` restores three's every-node walk, and `TN_PROJECTION` reports the visited-node count either way. Physics bodies and `ctx.camera` interpolate between fixed ticks by default; `physicsInterpolation: false` disables it globally, `body.interpolate = false` disables one body, `ctx.interpolate(object)` opts in another transform, and `ctx.resetInterpolation(object)` resets game-driven teleports (`TN_PHYSICS_INTERPOLATION` reports the setting and tracked count).
|
|
9
8
|
|
|
10
9
|
## Start every change
|
|
11
10
|
|
|
@@ -37,7 +36,7 @@ bridge; avoid DOM globals, dynamic `import()`, and raw physics handles. **Report
|
|
|
37
36
|
- `.agents/skills/threenative-performance/SKILL.md` / `.claude/skills/threenative-performance/SKILL.md` — measured budgets.
|
|
38
37
|
- `.agents/skills/threenative-ui/SKILL.md` / `.claude/skills/threenative-ui/SKILL.md` — native-safe UI.
|
|
39
38
|
- `.agents/skills/threenative-context/SKILL.md` / `.claude/skills/threenative-context/SKILL.md` — portable ctx APIs.
|
|
40
|
-
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro. A game-side `patches/` fix is temporary: once it is settled, it moves into the engine in one PR. Lazy-first: `.agents/skills/ponytail/SKILL.md` / `.claude/skills/ponytail/SKILL.md` — smallest correct change, and its reuse rung is the capability search above.
|
|
39
|
+
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro. A game-side `patches/` fix is temporary: once it is settled, it moves into the engine in one PR. Lazy-first: `.agents/skills/ponytail/SKILL.md` / `.claude/skills/ponytail/SKILL.md` — smallest correct change, and its reuse rung is the capability search above. Engine: The owned C++ engine is the default for a new game: the Wasm engine on web and the engine player on desktop. This template pins `engine: "threejs"` in `threenative.config.ts` because the native engine does not bind MeshStandardMaterial.flatShading yet. The pin keeps upstream Three.js on web and the legacy host on desktop. Android and iOS use the legacy host.
|
|
41
40
|
|
|
42
41
|
## Commands and map
|
|
43
42
|
|
|
@@ -65,7 +64,7 @@ Relative look capture: a binding with `pointerRelative: true` captures the canva
|
|
|
65
64
|
Scenes use `load`, `enter`, `update`, `exit`, `render`; physics nodes are Godot-named and disposable.
|
|
66
65
|
Generated conventions call `GroundSnap` for floor contact and `normaliseToMetres` for authored model scale.
|
|
67
66
|
`input.vector("move").y` is +up, so forward uses one explicit `-move.y` conversion. Rigged assets: put a `.glb` in `assets/`, await `ctx.assets.model("hero.glb")` in `Scene.load()`, then drive
|
|
68
|
-
`AnimationPlayer` beside its entity. `ctx.goto(name)` rebuilds without resetting game state; from
|
|
67
|
+
`AnimationPlayer` beside its entity. Imported foliage (Fab/Megascans cutouts) draws with its own albedo, normal map and alpha cutoff under the scene's environment light — never tint it, fake its emission or flatten its normals to make up for missing light; `TN_UNLIT_FOLIAGE` names cutout materials drawn with no environment. `ctx.goto(name)` rebuilds without resetting game state; from
|
|
69
68
|
a frame function `goto` and then `return`; `ctx.state.set({ /* copy this game's initial-state shape */ })`
|
|
70
69
|
is a partial patch. `game.goto("<scene-name>")` also rebuilds the scene, but it resets the game's
|
|
71
70
|
state. Seeded randomness is deterministic only when `defineGame({ seed })` is configured.
|
|
@@ -77,7 +76,7 @@ caught where a bone-direction check reads zero. `clipTrackBindings` names tracks
|
|
|
77
76
|
(the `<bone>.undefined` failure that plays the bind pose instead of the animation),
|
|
78
77
|
`clipBoneCoverage` names bones the clip does not drive and which therefore keep the previous
|
|
79
78
|
clip's pose, and `boneContact` reports in metres whether a named bone reaches the prop it is
|
|
80
|
-
supposed to be touching. Two loading conventions come from `@threenative/core`, not from your own loops: `loadAll(items, load)` fetches six at a time and returns results **in the input's order** (a pool that pushes returns completion order, so a positional pick lands a different asset every load), and `addInSlices(objects, (object) => ctx.add(object))` attaches
|
|
79
|
+
supposed to be touching. Two loading conventions come from `@threenative/core`, not from your own loops: `loadAll(items, load)` fetches six at a time and returns results **in the input's order** (a pool that pushes returns completion order, so a positional pick lands a different asset every load), and `addInSlices(objects, (object) => ctx.add(object))` attaches in 8 ms slices so hundreds of objects never land in one long frame; override `concurrency`/`sliceSize`, pass `while: () => alive` to stop a torn-down scene without throwing, and `marker: false` silences `TN_LOAD_ALL`/`TN_ADD_SLICES` but never the measurement. Gate the loading curtain on a measured readiness with `ctx.startup.hold(label, () => ready)`: core polls it every rendered frame, so it settles without a physics step.
|
|
81
80
|
|
|
82
81
|
## Look and evidence
|
|
83
82
|
|
|
@@ -85,11 +84,13 @@ supposed to be touching. Two loading conventions come from `@threenative/core`,
|
|
|
85
84
|
|
|
86
85
|
Reference-driven authoring starts at `node_modules/create-threenative/agent-docs/references/dream-loop.md`.
|
|
87
86
|
|
|
88
|
-
Edit `src/render/` directly; `postprocessing.ts` reports stages but decides no game colour. Quality
|
|
89
|
-
tiers live in `src/render/quality.ts`: `low`, `medium`, `high`; `isMobile()` chooses `low`, otherwise
|
|
90
|
-
`high`; override with `setupPost(..., { tier: "low" })`. Unknown tiers throw and `TN_QUALITY_TIER`
|
|
87
|
+
WebGPU reports `TN_GPU_CLASS` once per launch. Automatic `render.resolutionScale` starts at 0.85 for `mobile-low`, otherwise 1; a numeric value pins it. `TN_FRAME_BUDGET` reports the actual scale under both policies. Edit `src/render/` directly; `postprocessing.ts` reports stages but decides no game colour. Quality
|
|
88
|
+
tiers live in `src/render/quality.ts`: `low`, `medium`, `high`; the GPU family from `ctx.renderer.gpuClass` sets the start (`discrete` `high`, `integrated` and `mobile-high` `medium`, other phones `low`); `isMobile()` chooses `low`, otherwise
|
|
89
|
+
`high` when the family is `unknown`; override with `setupPost(..., { tier: "low" })`. Unknown tiers throw and `TN_QUALITY_TIER`
|
|
91
90
|
reports the source. A scenario with no assertions or missing observations fails; open a real capture. The engine warns you before a human does: `TN_SCENE_WARNING` fires when the GPU used under a third of the frame while the JS render phase ran longer than the display's own period, and names the census behind it — objects considered, draws per pass, triangles per draw, shadow-exempt casters. It is a scene-shape verdict, so answer it by moving the draw and object counts, not the engine: read the bucket census before promising a merge. `npx threenative doctor` repeats the last verdict and the `DEV_MODE=true` chip shows it on screen (it draws the verdict alone — no frame rate, which reads throttled under a compositor or a virtual display; see `agent-docs/references/performance-basics.md`); `TN_FRAME_SPANS=1` adds the render phase's own span tree when you need to know which part costs the milliseconds. The cheapest static object is one whose transform you never write: measured on 1,561 objects, leaving them alone costs 10.10 ms of render phase against 17.45 ms when the game rewrites every transform each frame, because three skips the per-object binding update when nothing changed. So do not touch a transform you do not need to — that is worth ~7 ms where `markStatic(root)`, which additionally composes a never-moving subtree once, measured 0.009 ms. Use it for scenery you are sure of, and `invalidateStatic(object)` to announce a write inside one; it deletes matrix arithmetic, not the walk. `TN_RENDERLIST_VALIDATE=1` recomputes every world matrix the long way each frame and throws on the first that disagrees, which is how you prove a freeze did not leave something stale on screen.
|
|
92
91
|
|
|
93
|
-
Recipes in the installed create-threenative: `node_modules/create-threenative/agent-docs/references/assertion-reference.md`, `node_modules/create-threenative/agent-docs/references/build-profiles.md`, `node_modules/create-threenative/agent-docs/references/capability-reference.md`, `node_modules/create-threenative/agent-docs/references/capture-the-frame.md`, `node_modules/create-threenative/agent-docs/references/creating-creatures.md`, `node_modules/create-threenative/agent-docs/references/ctx-cookbook.md`, `node_modules/create-threenative/agent-docs/references/debug-surface.md`, `node_modules/create-threenative/agent-docs/references/finding-assets.md`, `node_modules/create-threenative/agent-docs/references/gameplay-recipes.md`, `node_modules/create-threenative/agent-docs/references/menu-screens.md`, `node_modules/create-threenative/agent-docs/references/mobile-memory-budget.md`, `node_modules/create-threenative/agent-docs/references/performance-basics.md`, `node_modules/create-threenative/agent-docs/references/rigging-characters.md`, `node_modules/create-threenative/agent-docs/references/sculpt-from-a-reference.md`, `node_modules/create-threenative/agent-docs/references/trace-a-slow-frame.md`, `node_modules/create-threenative/agent-docs/references/visual-baseline.md`, and `node_modules/create-threenative/agent-docs/references/webview-ui.md`.
|
|
92
|
+
For terrain generation or editing, read `node_modules/create-threenative/agent-docs/references/terrain-authoring.md`; install optional `@threenative/terrain`, bake before play, and own its appearance in `src/render/`; test water proximity with its `createSegmentIndex` and steep ground with `slopeQuantile`, never a per-point scan or fixed degrees. Recipes in the installed create-threenative: `node_modules/create-threenative/agent-docs/references/assertion-reference.md`, `node_modules/create-threenative/agent-docs/references/build-profiles.md`, `node_modules/create-threenative/agent-docs/references/capability-reference.md`, `node_modules/create-threenative/agent-docs/references/capture-the-frame.md`, `node_modules/create-threenative/agent-docs/references/creating-creatures.md`, `node_modules/create-threenative/agent-docs/references/ctx-cookbook.md`, `node_modules/create-threenative/agent-docs/references/debug-surface.md`, `node_modules/create-threenative/agent-docs/references/finding-assets.md`, `node_modules/create-threenative/agent-docs/references/gameplay-recipes.md`, `node_modules/create-threenative/agent-docs/references/menu-screens.md`, `node_modules/create-threenative/agent-docs/references/mobile-memory-budget.md`, `node_modules/create-threenative/agent-docs/references/performance-basics.md`, `node_modules/create-threenative/agent-docs/references/rigging-characters.md`, `node_modules/create-threenative/agent-docs/references/sculpt-from-a-reference.md`, `node_modules/create-threenative/agent-docs/references/trace-a-slow-frame.md`, `node_modules/create-threenative/agent-docs/references/visual-baseline.md`, and `node_modules/create-threenative/agent-docs/references/webview-ui.md`.
|
|
94
93
|
## Optional multiplayer transport
|
|
95
94
|
For online play only, import `connect` from `@threenative/core/net` with an HTTPS URL and nonempty identity credential; configure `connectTimeoutMs`, `maxReliableMessageBytes`, `maxQueuedReliableBytes`, and `maxQueuedDatagrams` (10s/65,536/1 MiB/256), use `reliable-ordered` for ordered reliable messages and bounded `unreliable` datagrams that may drop, and keep serialization, replication, prediction, interpolation, snapshots and rejoin in this game's `src/` and server. There is no fallback: unsupported WebTransport/native rejects with `TN_NET_UNAVAILABLE`; reference Go server: `packages/runtime-native/examples/webtransport/server`.
|
|
95
|
+
Material backlighting lives in `src/render/lighting.ts`: named `rimGain` and `fillGain` controls preserve the authored palette; `materialLighting.ts` reports `TN_ENVIRONMENT_CONTRIBUTION`. Admission is limited to high hardware desktop WebGPU; mobile/software/WebGL/native retain original materials. Existing authored fill stays authoritative.
|
|
96
|
+
`src/render/exposure.ts` owns optional adaptation (`enabled: false`); `autoExposure.ts` meters even when disabled. Recipe: `node_modules/create-threenative/agent-docs/references/auto-exposure.md`.
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
Instructions for the AI agent in this game. `CLAUDE.md` mirrors this file; edit `AGENTS.md`.
|
|
6
6
|
|
|
7
7
|
## Ownership
|
|
8
|
-
|
|
9
8
|
ThreeNative owns bootstrap, renderer, fixed-step loop, input, loading, physics bindings, and the state bridge. This repository owns the road, pads, enemies, towers, economy, waves, HUD, and look;
|
|
10
|
-
`src/game.ts` is portable and React mounts only from `src/main.ts`. The render camera also skips an object that projects under **0.5 px** in it; `renderer.minimumProjectedPixels` raises that threshold (`false` disables the cut, not the count) and `alwaysRender(object)` exempts an object, while camera-attached objects and shadow casters are kept. The engine also owns the per-frame world-matrix walk, and by default it does not descend into a hidden subtree — so a game that reads a hidden object's `matrixWorld` directly must use `getWorldPosition` (or call `object.updateWorldMatrix(true, false)`) first; `renderer.matrixWorld: "all"` restores three's every-node walk, and `TN_PROJECTION` reports the visited-node count either way.
|
|
9
|
+
`src/game.ts` is portable and React mounts only from `src/main.ts`. The render camera also skips an object that projects under **0.5 px** in it; `renderer.minimumProjectedPixels` raises that threshold (`false` disables the cut, not the count) and `alwaysRender(object)` exempts an object, while camera-attached objects and shadow casters are kept. The engine also owns the per-frame world-matrix walk, and by default it does not descend into a hidden subtree — so a game that reads a hidden object's `matrixWorld` directly must use `getWorldPosition` (or call `object.updateWorldMatrix(true, false)`) first; `renderer.matrixWorld: "all"` restores three's every-node walk, and `TN_PROJECTION` reports the visited-node count either way. Physics bodies and `ctx.camera` interpolate between fixed ticks by default; `physicsInterpolation: false` disables it globally, `body.interpolate = false` disables one body, `ctx.interpolate(object)` opts in another transform, and `ctx.resetInterpolation(object)` resets game-driven teleports (`TN_PHYSICS_INTERPOLATION` reports the setting and tracked count).
|
|
11
10
|
|
|
12
11
|
## Start every change
|
|
13
12
|
|
|
@@ -39,7 +38,7 @@ bridge; avoid DOM globals, dynamic `import()`, and raw physics handles. **Report
|
|
|
39
38
|
- `.agents/skills/threenative-performance/SKILL.md` / `.claude/skills/threenative-performance/SKILL.md` — measured budgets.
|
|
40
39
|
- `.agents/skills/threenative-ui/SKILL.md` / `.claude/skills/threenative-ui/SKILL.md` — native-safe UI.
|
|
41
40
|
- `.agents/skills/threenative-context/SKILL.md` / `.claude/skills/threenative-context/SKILL.md` — portable ctx APIs.
|
|
42
|
-
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro. A game-side `patches/` fix is temporary: once it is settled, it moves into the engine in one PR. Lazy-first: `.agents/skills/ponytail/SKILL.md` / `.claude/skills/ponytail/SKILL.md` — smallest correct change, and its reuse rung is the capability search above.
|
|
41
|
+
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro. A game-side `patches/` fix is temporary: once it is settled, it moves into the engine in one PR. Lazy-first: `.agents/skills/ponytail/SKILL.md` / `.claude/skills/ponytail/SKILL.md` — smallest correct change, and its reuse rung is the capability search above. Engine: The owned C++ engine is the default for a new game: the Wasm engine on web and the engine player on desktop. This template pins `engine: "threejs"` in `threenative.config.ts` because the native engine does not bind MeshStandardMaterial.flatShading yet. The pin keeps upstream Three.js on web and the legacy host on desktop. Android and iOS use the legacy host.
|
|
43
42
|
|
|
44
43
|
## Commands and map
|
|
45
44
|
|
|
@@ -67,7 +66,7 @@ Relative look capture: a binding with `pointerRelative: true` captures the canva
|
|
|
67
66
|
Scenes use `load`, `enter`, `update`, `exit`, `render`; physics nodes are Godot-named and disposable.
|
|
68
67
|
Generated conventions call `GroundSnap` for floor contact and `normaliseToMetres` for authored model scale.
|
|
69
68
|
`input.vector("move").y` is +up, so forward uses one explicit `-move.y` conversion. Rigged assets: put a `.glb` in `assets/`, await `ctx.assets.model("hero.glb")` in `Scene.load()`, then drive
|
|
70
|
-
`AnimationPlayer` beside its entity. `ctx.goto(name)` rebuilds without resetting game state; from
|
|
69
|
+
`AnimationPlayer` beside its entity. Imported foliage (Fab/Megascans cutouts) draws with its own albedo, normal map and alpha cutoff under the scene's environment light — never tint it, fake its emission or flatten its normals to make up for missing light; `TN_UNLIT_FOLIAGE` names cutout materials drawn with no environment. `ctx.goto(name)` rebuilds without resetting game state; from
|
|
71
70
|
a frame function `goto` and then `return`; `ctx.state.set({ /* copy this game's initial-state shape */ })`
|
|
72
71
|
is a partial patch. `game.goto("<scene-name>")` also rebuilds the scene, but it resets the game's
|
|
73
72
|
state. Seeded randomness is deterministic only when `defineGame({ seed })` is configured.
|
|
@@ -79,7 +78,7 @@ caught where a bone-direction check reads zero. `clipTrackBindings` names tracks
|
|
|
79
78
|
(the `<bone>.undefined` failure that plays the bind pose instead of the animation),
|
|
80
79
|
`clipBoneCoverage` names bones the clip does not drive and which therefore keep the previous
|
|
81
80
|
clip's pose, and `boneContact` reports in metres whether a named bone reaches the prop it is
|
|
82
|
-
supposed to be touching. Two loading conventions come from `@threenative/core`, not from your own loops: `loadAll(items, load)` fetches six at a time and returns results **in the input's order** (a pool that pushes returns completion order, so a positional pick lands a different asset every load), and `addInSlices(objects, (object) => ctx.add(object))` attaches
|
|
81
|
+
supposed to be touching. Two loading conventions come from `@threenative/core`, not from your own loops: `loadAll(items, load)` fetches six at a time and returns results **in the input's order** (a pool that pushes returns completion order, so a positional pick lands a different asset every load), and `addInSlices(objects, (object) => ctx.add(object))` attaches in 8 ms slices so hundreds of objects never land in one long frame; override `concurrency`/`sliceSize`, pass `while: () => alive` to stop a torn-down scene without throwing, and `marker: false` silences `TN_LOAD_ALL`/`TN_ADD_SLICES` but never the measurement. Gate the loading curtain on a measured readiness with `ctx.startup.hold(label, () => ready)`: core polls it every rendered frame, so it settles without a physics step.
|
|
83
82
|
|
|
84
83
|
## Look and evidence
|
|
85
84
|
|
|
@@ -87,11 +86,13 @@ supposed to be touching. Two loading conventions come from `@threenative/core`,
|
|
|
87
86
|
|
|
88
87
|
Reference-driven authoring starts at `node_modules/create-threenative/agent-docs/references/dream-loop.md`.
|
|
89
88
|
|
|
90
|
-
Edit `src/render/` directly; `postprocessing.ts` reports stages but decides no game colour. Quality
|
|
91
|
-
tiers live in `src/render/quality.ts`: `low`, `medium`, `high`; `isMobile()` chooses `low`, otherwise
|
|
92
|
-
`high`; override with `setupPost(..., { tier: "low" })`. Unknown tiers throw and `TN_QUALITY_TIER`
|
|
89
|
+
WebGPU reports `TN_GPU_CLASS` once per launch. Automatic `render.resolutionScale` starts at 0.85 for `mobile-low`, otherwise 1; a numeric value pins it. `TN_FRAME_BUDGET` reports the actual scale under both policies. Edit `src/render/` directly; `postprocessing.ts` reports stages but decides no game colour. Quality
|
|
90
|
+
tiers live in `src/render/quality.ts`: `low`, `medium`, `high`; the GPU family from `ctx.renderer.gpuClass` sets the start (`discrete` `high`, `integrated` and `mobile-high` `medium`, other phones `low`); `isMobile()` chooses `low`, otherwise
|
|
91
|
+
`high` when the family is `unknown`; override with `setupPost(..., { tier: "low" })`. Unknown tiers throw and `TN_QUALITY_TIER`
|
|
93
92
|
reports the source. A scenario with no assertions or missing observations fails; open a real capture. The engine warns you before a human does: `TN_SCENE_WARNING` fires when the GPU used under a third of the frame while the JS render phase ran longer than the display's own period, and names the census behind it — objects considered, draws per pass, triangles per draw, shadow-exempt casters. It is a scene-shape verdict, so answer it by moving the draw and object counts, not the engine: read the bucket census before promising a merge. `npx threenative doctor` repeats the last verdict and the `DEV_MODE=true` chip shows it on screen (it draws the verdict alone — no frame rate, which reads throttled under a compositor or a virtual display; see `agent-docs/references/performance-basics.md`); `TN_FRAME_SPANS=1` adds the render phase's own span tree when you need to know which part costs the milliseconds. The cheapest static object is one whose transform you never write: measured on 1,561 objects, leaving them alone costs 10.10 ms of render phase against 17.45 ms when the game rewrites every transform each frame, because three skips the per-object binding update when nothing changed. So do not touch a transform you do not need to — that is worth ~7 ms where `markStatic(root)`, which additionally composes a never-moving subtree once, measured 0.009 ms. Use it for scenery you are sure of, and `invalidateStatic(object)` to announce a write inside one; it deletes matrix arithmetic, not the walk. `TN_RENDERLIST_VALIDATE=1` recomputes every world matrix the long way each frame and throws on the first that disagrees, which is how you prove a freeze did not leave something stale on screen.
|
|
94
93
|
|
|
95
|
-
Recipes in the installed create-threenative: `node_modules/create-threenative/agent-docs/references/assertion-reference.md`, `node_modules/create-threenative/agent-docs/references/build-profiles.md`, `node_modules/create-threenative/agent-docs/references/capability-reference.md`, `node_modules/create-threenative/agent-docs/references/capture-the-frame.md`, `node_modules/create-threenative/agent-docs/references/creating-creatures.md`, `node_modules/create-threenative/agent-docs/references/ctx-cookbook.md`, `node_modules/create-threenative/agent-docs/references/debug-surface.md`, `node_modules/create-threenative/agent-docs/references/finding-assets.md`, `node_modules/create-threenative/agent-docs/references/gameplay-recipes.md`, `node_modules/create-threenative/agent-docs/references/menu-screens.md`, `node_modules/create-threenative/agent-docs/references/mobile-memory-budget.md`, `node_modules/create-threenative/agent-docs/references/performance-basics.md`, `node_modules/create-threenative/agent-docs/references/rigging-characters.md`, `node_modules/create-threenative/agent-docs/references/sculpt-from-a-reference.md`, `node_modules/create-threenative/agent-docs/references/trace-a-slow-frame.md`, `node_modules/create-threenative/agent-docs/references/visual-baseline.md`, and `node_modules/create-threenative/agent-docs/references/webview-ui.md`.
|
|
94
|
+
For terrain generation or editing, read `node_modules/create-threenative/agent-docs/references/terrain-authoring.md`; install optional `@threenative/terrain`, bake before play, and own its appearance in `src/render/`; test water proximity with its `createSegmentIndex` and steep ground with `slopeQuantile`, never a per-point scan or fixed degrees. Recipes in the installed create-threenative: `node_modules/create-threenative/agent-docs/references/assertion-reference.md`, `node_modules/create-threenative/agent-docs/references/build-profiles.md`, `node_modules/create-threenative/agent-docs/references/capability-reference.md`, `node_modules/create-threenative/agent-docs/references/capture-the-frame.md`, `node_modules/create-threenative/agent-docs/references/creating-creatures.md`, `node_modules/create-threenative/agent-docs/references/ctx-cookbook.md`, `node_modules/create-threenative/agent-docs/references/debug-surface.md`, `node_modules/create-threenative/agent-docs/references/finding-assets.md`, `node_modules/create-threenative/agent-docs/references/gameplay-recipes.md`, `node_modules/create-threenative/agent-docs/references/menu-screens.md`, `node_modules/create-threenative/agent-docs/references/mobile-memory-budget.md`, `node_modules/create-threenative/agent-docs/references/performance-basics.md`, `node_modules/create-threenative/agent-docs/references/rigging-characters.md`, `node_modules/create-threenative/agent-docs/references/sculpt-from-a-reference.md`, `node_modules/create-threenative/agent-docs/references/trace-a-slow-frame.md`, `node_modules/create-threenative/agent-docs/references/visual-baseline.md`, and `node_modules/create-threenative/agent-docs/references/webview-ui.md`.
|
|
96
95
|
## Optional multiplayer transport
|
|
97
96
|
For online play only, import `connect` from `@threenative/core/net` with an HTTPS URL and nonempty identity credential; configure `connectTimeoutMs`, `maxReliableMessageBytes`, `maxQueuedReliableBytes`, and `maxQueuedDatagrams` (10s/65,536/1 MiB/256), use `reliable-ordered` for ordered reliable messages and bounded `unreliable` datagrams that may drop, and keep serialization, replication, prediction, interpolation, snapshots and rejoin in this game's `src/` and server. There is no fallback: unsupported WebTransport/native rejects with `TN_NET_UNAVAILABLE`; reference Go server: `packages/runtime-native/examples/webtransport/server`.
|
|
97
|
+
Material backlighting lives in `src/render/lighting.ts`: named `rimGain` and `fillGain` controls preserve the authored palette; `materialLighting.ts` reports `TN_ENVIRONMENT_CONTRIBUTION`. Admission is limited to high hardware desktop WebGPU; mobile/software/WebGL/native retain original materials. Existing authored fill stays authoritative.
|
|
98
|
+
`src/render/exposure.ts` owns optional adaptation (`enabled: false`); `autoExposure.ts` meters even when disabled. Recipe: `node_modules/create-threenative/agent-docs/references/auto-exposure.md`.
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@threenative/core": "0.3.
|
|
19
|
-
"@threenative/physics": "0.3.
|
|
20
|
-
"@threenative/ui": "0.3.
|
|
18
|
+
"@threenative/core": "0.3.6",
|
|
19
|
+
"@threenative/physics": "0.3.6",
|
|
20
|
+
"@threenative/ui": "0.3.6",
|
|
21
21
|
"react": "19.2.0",
|
|
22
22
|
"react-dom": "19.2.0",
|
|
23
23
|
"three": "0.185.1"
|
|
@@ -25,24 +25,25 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@gltf-transform/cli": "4.4.2",
|
|
27
27
|
"@tailwindcss/vite": "4.3.3",
|
|
28
|
-
"@threenative/assets": "0.3.
|
|
29
|
-
"@threenative/playtest": "0.3.
|
|
28
|
+
"@threenative/assets": "0.3.7",
|
|
29
|
+
"@threenative/playtest": "0.3.6",
|
|
30
30
|
"@types/react": "19.2.0",
|
|
31
31
|
"@types/react-dom": "19.2.0",
|
|
32
32
|
"@types/three": "0.185.3",
|
|
33
33
|
"@vitejs/plugin-react": "6.0.5",
|
|
34
|
-
"create-threenative": "0.2.
|
|
34
|
+
"create-threenative": "0.2.10",
|
|
35
35
|
"esbuild": "0.27.0",
|
|
36
36
|
"playwright": "1.62.1",
|
|
37
37
|
"tailwindcss": "4.3.3",
|
|
38
|
-
"typescript": "
|
|
38
|
+
"typescript": "7.0.2",
|
|
39
39
|
"vite": "8.2.0"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
|
-
"@threenative/runtime-native": "0.3.
|
|
42
|
+
"@threenative/runtime-native": "0.3.6"
|
|
43
43
|
},
|
|
44
44
|
"overrides": {
|
|
45
|
-
"sharp": ">=0.35.4"
|
|
45
|
+
"sharp": ">=0.35.4",
|
|
46
|
+
"@vitejs/devtools": "0.4.1"
|
|
46
47
|
},
|
|
47
48
|
"pnpm": {
|
|
48
49
|
"overrides": {
|
|
@@ -50,7 +51,9 @@
|
|
|
50
51
|
},
|
|
51
52
|
"onlyBuiltDependencies": ["@threenative/core", "@threenative/runtime-native"],
|
|
52
53
|
"patchedDependencies": {
|
|
53
|
-
"three@0.185.1": "patches/three@0.185.1.patch"
|
|
54
|
+
"three@0.185.1": "patches/three@0.185.1.patch",
|
|
55
|
+
"vite@8.2.0": "patches/vite@8.2.0.patch",
|
|
56
|
+
"@tailwindcss/node@4.3.3": "patches/@tailwindcss__node@4.3.3.patch"
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -68,7 +68,13 @@
|
|
|
68
68
|
},
|
|
69
69
|
"renderChain": {
|
|
70
70
|
"tier": "high",
|
|
71
|
-
"perAdapter": {
|
|
71
|
+
"perAdapter": {
|
|
72
|
+
"integrated": { "tier": "medium" },
|
|
73
|
+
"mobile-high": { "tier": "medium" },
|
|
74
|
+
"mobile-low": { "tier": "low" },
|
|
75
|
+
"mobile-mid": { "tier": "low" },
|
|
76
|
+
"software": { "tier": "low" }
|
|
77
|
+
}
|
|
72
78
|
}
|
|
73
79
|
},
|
|
74
80
|
"artifacts": {
|