create-threenative 0.2.7 → 0.2.9
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/README.md +3 -1
- 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 +1306 -62
- 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 +1505 -79
- package/dist/index.d.ts +28 -3
- package/dist/index.js +402 -167
- package/dist/threenative.js +989 -237
- 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 +11 -9
- 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 +9 -8
- 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 +11 -9
- 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 +11 -9
- 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 +11 -9
- 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 +21 -1
- package/templates/racing/src/render/worldEnvironment.ts +433 -30
- package/templates/racing/src/scenes/Race.ts +91 -3
- package/templates/racing/src/track/circuit.ts +0 -9
- package/templates/racing/vite.config.ts +10 -2
- package/templates/rain/.codex/config.toml +19 -0
- package/templates/rain/.cursor/mcp.json +32 -0
- package/templates/rain/.gemini/settings.json +32 -0
- package/templates/rain/.mcp.json +32 -0
- package/templates/rain/.vscode/mcp.json +36 -0
- package/templates/rain/.zed/settings.json +36 -0
- package/templates/rain/AGENTS.md +95 -0
- package/templates/rain/CLAUDE.md +97 -0
- package/templates/rain/assets/rain-loop.wav +0 -0
- package/templates/rain/assets/thunder.wav +0 -0
- package/templates/rain/assets/wind-loop.wav +0 -0
- package/templates/rain/index.html +18 -0
- package/templates/rain/kit.json +7 -0
- package/templates/rain/native-playtests/boot.playtest.json +23 -0
- package/templates/rain/native-playtests/lightning.playtest.json +173 -0
- package/templates/rain/opencode.json +41 -0
- package/templates/rain/package.json +59 -0
- package/templates/rain/playtests/auto-lightning-clear.playtest.json +66 -0
- package/templates/rain/playtests/auto-lightning.playtest.json +26 -0
- package/templates/rain/playtests/automation.playtest.json +133 -0
- package/templates/rain/playtests/cinematic.playtest.json +59 -0
- package/templates/rain/playtests/flash.playtest.json +27 -0
- package/templates/rain/playtests/fly.playtest.json +54 -0
- package/templates/rain/playtests/lightning.playtest.json +220 -0
- package/templates/rain/playtests/loading.playtest.json +57 -0
- package/templates/rain/playtests/paused.playtest.json +59 -0
- package/templates/rain/playtests/performance.playtest.json +32 -0
- package/templates/rain/playtests/reduced-motion.playtest.json +87 -0
- package/templates/rain/playtests/simulation.playtest.json +20 -0
- package/templates/rain/playtests/storm.playtest.json +150 -0
- package/templates/rain/playtests/survives.playtest.json +58 -0
- package/templates/rain/playtests/tiers.playtest.json +194 -0
- package/templates/rain/playtests/weather.playtest.json +77 -0
- package/templates/rain/public/favicon.svg +5 -0
- package/templates/rain/src/audio/storm.ts +314 -0
- package/templates/rain/src/game.ts +81 -0
- package/templates/rain/src/main.ts +15 -0
- package/templates/rain/src/render/autoExposure.ts +225 -0
- package/templates/rain/src/render/bloom-shader.ts +65 -0
- package/templates/rain/src/render/camera.ts +160 -0
- package/templates/rain/src/render/clouds-shader.ts +242 -0
- package/templates/rain/src/render/clouds.ts +142 -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/lighting.ts +39 -0
- package/templates/rain/src/render/lightning.ts +360 -0
- package/templates/rain/src/render/loading.ts +327 -0
- package/templates/rain/src/render/materials.ts +19 -0
- package/templates/rain/src/render/noise-volume.ts +159 -0
- package/templates/rain/src/render/palette.ts +18 -0
- package/templates/rain/src/render/post-shader.ts +178 -0
- package/templates/rain/src/render/postprocessing.ts +229 -0
- package/templates/rain/src/render/quality.ts +161 -0
- package/templates/rain/src/render/rain.ts +299 -0
- package/templates/rain/src/render/sky.ts +28 -0
- package/templates/rain/src/render/world-shader.ts +680 -0
- package/templates/rain/src/render/world.ts +146 -0
- package/templates/rain/src/render/worldEnvironment.ts +1212 -0
- package/templates/rain/src/scenes/Boot.ts +348 -0
- package/templates/rain/src/state.ts +261 -0
- package/templates/rain/src/style.css +1160 -0
- package/templates/rain/src/ui/App.tsx +29 -0
- package/templates/rain/src/ui/GameUi.tsx +187 -0
- package/templates/rain/src/ui/Hud.tsx +327 -0
- package/templates/rain/src/ui/LoadingOverlay.tsx +46 -0
- package/templates/rain/src/ui/Menu.tsx +370 -0
- package/templates/rain/src/ui/automation.ts +60 -0
- package/templates/rain/src/ui/main.tsx +7 -0
- package/templates/rain/src/ui/tempest.ts +149 -0
- package/templates/rain/tailwind.config.ts +2 -0
- package/templates/rain/threenative.config.ts +66 -0
- package/templates/rain/tools/generate-shaders.mjs +656 -0
- package/templates/rain/tools/make-storm-audio.mjs +387 -0
- package/templates/rain/tools/storm-dsp.mjs +177 -0
- package/templates/rain/tools/tempest-bloom.frag +10 -0
- package/templates/rain/tools/tempest-clouds.frag +86 -0
- package/templates/rain/tools/tempest-post.frag +47 -0
- package/templates/rain/tools/tempest-world.frag +210 -0
- package/templates/rain/tools/verify-noise-volume.mjs +61 -0
- package/templates/rain/tsconfig.json +17 -0
- package/templates/rain/vite.config.ts +45 -0
- package/templates/rts/AGENTS.md +10 -11
- package/templates/rts/CLAUDE.md +10 -11
- package/templates/rts/package.json +10 -8
- 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 +11 -9
- 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 +11 -9
- 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 +11 -9
- 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/.codex/config.toml +19 -0
- package/templates/snow/.cursor/mcp.json +32 -0
- package/templates/snow/.gemini/settings.json +32 -0
- package/templates/snow/.mcp.json +32 -0
- package/templates/snow/.vscode/mcp.json +36 -0
- package/templates/snow/.zed/settings.json +36 -0
- package/templates/snow/AGENTS.md +90 -0
- package/templates/snow/CLAUDE.md +92 -0
- package/templates/snow/README.md +26 -0
- package/templates/snow/assets/crunch.wav +0 -0
- package/templates/snow/assets/wind.wav +0 -0
- package/templates/snow/index.html +12 -0
- package/templates/snow/kit.json +7 -0
- package/templates/snow/native-playtests/snow-physics.playtest.json +150 -0
- package/templates/snow/native-playtests/survives.playtest.json +47 -0
- package/templates/snow/opencode.json +41 -0
- package/templates/snow/package.json +60 -0
- package/templates/snow/playtests/footsteps.playtest.json +95 -0
- package/templates/snow/playtests/performance.playtest.json +36 -0
- package/templates/snow/playtests/snow-physics.playtest.json +154 -0
- package/templates/snow/playtests/survives.playtest.json +56 -0
- package/templates/snow/playtests/touch-controls.playtest.json +71 -0
- package/templates/snow/playtests/weather.playtest.json +119 -0
- package/templates/snow/public/favicon.svg +5 -0
- package/templates/snow/src/audio.ts +58 -0
- package/templates/snow/src/commands.ts +8 -0
- package/templates/snow/src/entities/Explorer.ts +279 -0
- package/templates/snow/src/game.ts +69 -0
- package/templates/snow/src/main.ts +15 -0
- 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/bootPrint.ts +50 -0
- package/templates/snow/src/render/camera.ts +84 -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/explorer.ts +321 -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 +82 -0
- package/templates/snow/src/render/loading.ts +325 -0
- package/templates/snow/src/render/materialAssignments.ts +160 -0
- package/templates/snow/src/render/materialLighting.ts +155 -0
- package/templates/snow/src/render/materials.ts +36 -0
- package/templates/snow/src/render/palette.ts +17 -0
- package/templates/snow/src/render/postprocessing.ts +58 -0
- package/templates/snow/src/render/props.ts +42 -0
- package/templates/snow/src/render/quality.ts +193 -0
- package/templates/snow/src/render/scenery.ts +244 -0
- package/templates/snow/src/render/sky.ts +76 -0
- package/templates/snow/src/render/snowSurface.ts +259 -0
- package/templates/snow/src/render/touch-controls.ts +143 -0
- package/templates/snow/src/render/weather.ts +279 -0
- package/templates/snow/src/render/worldEnvironment.ts +1212 -0
- package/templates/snow/src/scenes/Boot.ts +12 -0
- package/templates/snow/src/scenes/Snow.ts +663 -0
- package/templates/snow/src/state.ts +46 -0
- package/templates/snow/src/style.css +143 -0
- package/templates/snow/src/terrain.ts +64 -0
- package/templates/snow/src/ui/App.tsx +15 -0
- package/templates/snow/src/ui/Controls.tsx +322 -0
- package/templates/snow/src/ui/GameUi.tsx +354 -0
- package/templates/snow/src/ui/icons.tsx +54 -0
- package/templates/snow/src/ui/main.tsx +7 -0
- package/templates/snow/tailwind.config.ts +2 -0
- package/templates/snow/threenative.config.ts +54 -0
- package/templates/snow/tsconfig.json +17 -0
- package/templates/snow/vite.config.ts +45 -0
- 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 +11 -9
- 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 +1 -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 +84 -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 +11 -9
- 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
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
Scene,
|
|
4
4
|
type SceneFrame,
|
|
5
5
|
afterPhysics,
|
|
6
|
+
getPlatform,
|
|
6
7
|
isMobile,
|
|
7
8
|
isTouchscreenAvailable,
|
|
8
9
|
} from "@threenative/core";
|
|
@@ -13,9 +14,16 @@ import { RacingCar } from "../entities/RacingCar.js";
|
|
|
13
14
|
import { Rival } from "../entities/Rival.js";
|
|
14
15
|
import { emitPlaytestEvent } from "../playtest-events.js";
|
|
15
16
|
import { cameraBank, chaseCamera, setupCamera } from "../render/camera.js";
|
|
17
|
+
import { type IEnvironmentSample, sampleEnvironment } from "../render/environmentSampling.js";
|
|
16
18
|
import { setupLighting } from "../render/lighting.js";
|
|
17
19
|
import { createLoadingScreen } from "../render/loading.js";
|
|
20
|
+
import { createMaterialLighting } from "../render/materialLighting.js";
|
|
18
21
|
import { setupPost } from "../render/postprocessing.js";
|
|
22
|
+
import {
|
|
23
|
+
type QualityTier,
|
|
24
|
+
isWebGLFallbackRenderer,
|
|
25
|
+
materialLightingEnabled,
|
|
26
|
+
} from "../render/quality.js";
|
|
19
27
|
import { SUN_DIRECTION, setupSky } from "../render/sky.js";
|
|
20
28
|
import { TouchControls } from "../render/touch-controls.js";
|
|
21
29
|
import { type GameState, type RaceStatus, resolveRaceStatus } from "../state.js";
|
|
@@ -98,11 +106,42 @@ export class Race extends Scene<GameState, IPhysicsContext> {
|
|
|
98
106
|
* the moment it decodes, which is also what a player sees — a sky that arrives rather than a
|
|
99
107
|
* black screen that waits.
|
|
100
108
|
*/
|
|
109
|
+
#post: ReturnType<typeof setupPost> | undefined;
|
|
110
|
+
#environmentSample: IEnvironmentSample | undefined;
|
|
111
|
+
#materialLighting: ReturnType<typeof createMaterialLighting> | undefined;
|
|
112
|
+
#lightingGeneration = 0;
|
|
113
|
+
|
|
101
114
|
override load(ctx: GameCtx): void {
|
|
102
|
-
|
|
115
|
+
const generation = ++this.#lightingGeneration;
|
|
116
|
+
void ctx.assets.texture("sky.jpg").then(async (texture) => {
|
|
117
|
+
if (generation !== this.#lightingGeneration) return;
|
|
103
118
|
this.#sky = texture;
|
|
104
119
|
const scene = ctx.scene;
|
|
105
|
-
if (scene
|
|
120
|
+
if (scene === undefined) return;
|
|
121
|
+
setupSky(scene, texture);
|
|
122
|
+
const controller = this.#materialLighting;
|
|
123
|
+
const sample = await sampleEnvironment(ctx.renderer.raw, scene, {
|
|
124
|
+
web: getPlatform().runtime === "web",
|
|
125
|
+
rendererKind: ctx.renderer.kind,
|
|
126
|
+
webglFallback: isWebGLFallbackRenderer(ctx.renderer.raw),
|
|
127
|
+
mobile: isMobile(),
|
|
128
|
+
software: ctx.renderer.softwareAdapter !== undefined,
|
|
129
|
+
});
|
|
130
|
+
if (generation !== this.#lightingGeneration || ctx.scene !== scene) return;
|
|
131
|
+
this.#environmentSample = sample;
|
|
132
|
+
// A cached sky may start sampling before enter creates the receiver controller.
|
|
133
|
+
// A controller that already existed when sampling began must still be the same one.
|
|
134
|
+
const currentController = this.#materialLighting;
|
|
135
|
+
if (
|
|
136
|
+
currentController !== undefined &&
|
|
137
|
+
(controller === undefined || controller === currentController)
|
|
138
|
+
)
|
|
139
|
+
currentController.setEnvironmentMeasurement(
|
|
140
|
+
sample.measurement,
|
|
141
|
+
sample.source,
|
|
142
|
+
sample.intensity,
|
|
143
|
+
sample,
|
|
144
|
+
);
|
|
106
145
|
});
|
|
107
146
|
}
|
|
108
147
|
|
|
@@ -115,10 +154,23 @@ export class Race extends Scene<GameState, IPhysicsContext> {
|
|
|
115
154
|
);
|
|
116
155
|
// isMobile() arrives as an argument because src/render/ imports no framework package: the
|
|
117
156
|
// platform decision is made here, in portable game code, exactly like createRandom.
|
|
118
|
-
|
|
157
|
+
const materialEnvironment = {
|
|
158
|
+
web: getPlatform().runtime === "web",
|
|
159
|
+
rendererKind: ctx.renderer.kind,
|
|
160
|
+
webglFallback: isWebGLFallbackRenderer(ctx.renderer.raw),
|
|
161
|
+
mobile: isMobile(),
|
|
162
|
+
software: ctx.renderer.softwareAdapter !== undefined,
|
|
163
|
+
};
|
|
164
|
+
let materialTier: QualityTier = "low";
|
|
165
|
+
this.#post = setupPost(ctx.renderer, ctx.scene, ctx.camera, {
|
|
166
|
+
onTierChanged: (tier) => {
|
|
167
|
+
materialTier = tier;
|
|
168
|
+
this.#materialLighting?.setEnabled(materialLightingEnabled(tier, materialEnvironment));
|
|
169
|
+
},
|
|
119
170
|
godraysLight: lighting.key,
|
|
120
171
|
mobile: isMobile(),
|
|
121
172
|
software: ctx.renderer.softwareAdapter !== undefined,
|
|
173
|
+
gpuClass: ctx.renderer.gpuClass?.class,
|
|
122
174
|
});
|
|
123
175
|
const loading = createLoadingScreen(ctx);
|
|
124
176
|
const camera = ctx.camera as PerspectiveCamera;
|
|
@@ -137,6 +189,14 @@ export class Race extends Scene<GameState, IPhysicsContext> {
|
|
|
137
189
|
const rival = new Rival(ctx, GRID_DISTANCE.rival);
|
|
138
190
|
ctx.entities.add("player", car);
|
|
139
191
|
ctx.entities.add("rival", rival);
|
|
192
|
+
// The sun's aim as three reads it: the target's world matrix, which only a scene traversal refreshes.
|
|
193
|
+
ctx.entities.add("sun", {
|
|
194
|
+
get targetGap(): number {
|
|
195
|
+
return new Vector3()
|
|
196
|
+
.setFromMatrixPosition(lighting.key.target.matrixWorld)
|
|
197
|
+
.distanceTo(car.body.position);
|
|
198
|
+
},
|
|
199
|
+
});
|
|
140
200
|
|
|
141
201
|
// `travelDirection` is the car's **measured** velocity, not the heading it was asked for: a
|
|
142
202
|
// car that is sliding through a corner is travelling somewhere other than where it points, and
|
|
@@ -229,6 +289,24 @@ export class Race extends Scene<GameState, IPhysicsContext> {
|
|
|
229
289
|
camera.rotateZ(cameraBank(car.lateralLoad, FEEL.lateral));
|
|
230
290
|
});
|
|
231
291
|
|
|
292
|
+
// Collect only after the loaded character and scene receivers are attached.
|
|
293
|
+
this.#materialLighting = ctx.entities.add(
|
|
294
|
+
"material-lighting",
|
|
295
|
+
createMaterialLighting(ctx.scene, ctx.camera, lighting.key, {
|
|
296
|
+
...materialEnvironment,
|
|
297
|
+
enabled: materialLightingEnabled(materialTier, materialEnvironment),
|
|
298
|
+
}),
|
|
299
|
+
);
|
|
300
|
+
if (this.#environmentSample !== undefined) {
|
|
301
|
+
const sample = this.#environmentSample;
|
|
302
|
+
this.#materialLighting.setEnvironmentMeasurement(
|
|
303
|
+
sample.measurement,
|
|
304
|
+
sample.source,
|
|
305
|
+
sample.intensity,
|
|
306
|
+
sample,
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
232
310
|
return (frameCtx, dt) => {
|
|
233
311
|
loading.update();
|
|
234
312
|
if (frameCtx.input.justPressed("restart")) {
|
|
@@ -277,4 +355,14 @@ export class Race extends Scene<GameState, IPhysicsContext> {
|
|
|
277
355
|
frameCtx.state.set(statePatch);
|
|
278
356
|
};
|
|
279
357
|
}
|
|
358
|
+
|
|
359
|
+
override exit(ctx: GameCtx): void {
|
|
360
|
+
this.#materialLighting?.dispose();
|
|
361
|
+
this.#materialLighting = undefined;
|
|
362
|
+
this.#post?.dispose();
|
|
363
|
+
this.#post = undefined;
|
|
364
|
+
this.#environmentSample = undefined;
|
|
365
|
+
this.#lightingGeneration += 1;
|
|
366
|
+
super.exit(ctx);
|
|
367
|
+
}
|
|
280
368
|
}
|
|
@@ -466,12 +466,3 @@ export const GRID_DISTANCE = {
|
|
|
466
466
|
export function lineDistance(fraction: number): number {
|
|
467
467
|
return fraction * CIRCUIT.totalLength;
|
|
468
468
|
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* A point on the tarmac: `offset` metres right of the centreline at `distance`, on the banked
|
|
472
|
-
* surface rather than on a flat plane through it, so anything parked on the track sits on it.
|
|
473
|
-
*/
|
|
474
|
-
export function pointOnTrack(distance: number, offset: number, target: Vector3): Vector3 {
|
|
475
|
-
const sample = CIRCUIT.at(distance, CIRCUIT.createSample());
|
|
476
|
-
return target.lerpVectors(sample.left, sample.rightEdge, (offset + HALF) / TRACK_WIDTH);
|
|
477
|
-
}
|
|
@@ -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.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[mcp_servers.threenative-assets]
|
|
2
|
+
command = "node"
|
|
3
|
+
args = ["./node_modules/@threenative/core/mcp/assets.mjs"]
|
|
4
|
+
|
|
5
|
+
[mcp_servers.threenative-assets.env]
|
|
6
|
+
ASSET_DOWNLOAD_DIR = "./public/assets"
|
|
7
|
+
AUDIO_DOWNLOAD_DIR = "./public/audio"
|
|
8
|
+
|
|
9
|
+
[mcp_servers.threenative-sculpt]
|
|
10
|
+
command = "node"
|
|
11
|
+
args = ["./node_modules/@threenative/core/mcp/sculpt.mjs"]
|
|
12
|
+
|
|
13
|
+
[mcp_servers.threenative-engine]
|
|
14
|
+
command = "node"
|
|
15
|
+
args = ["./node_modules/@threenative/core/mcp/engine.mjs"]
|
|
16
|
+
|
|
17
|
+
[mcp_servers.threenative-blender]
|
|
18
|
+
command = "node"
|
|
19
|
+
args = ["./node_modules/@threenative/core/mcp/blender.mjs"]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"threenative-assets": {
|
|
4
|
+
"command": "node",
|
|
5
|
+
"args": [
|
|
6
|
+
"./node_modules/@threenative/core/mcp/assets.mjs"
|
|
7
|
+
],
|
|
8
|
+
"env": {
|
|
9
|
+
"ASSET_DOWNLOAD_DIR": "./public/assets",
|
|
10
|
+
"AUDIO_DOWNLOAD_DIR": "./public/audio"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"threenative-sculpt": {
|
|
14
|
+
"command": "node",
|
|
15
|
+
"args": [
|
|
16
|
+
"./node_modules/@threenative/core/mcp/sculpt.mjs"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"threenative-engine": {
|
|
20
|
+
"command": "node",
|
|
21
|
+
"args": [
|
|
22
|
+
"./node_modules/@threenative/core/mcp/engine.mjs"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"threenative-blender": {
|
|
26
|
+
"command": "node",
|
|
27
|
+
"args": [
|
|
28
|
+
"./node_modules/@threenative/core/mcp/blender.mjs"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"threenative-assets": {
|
|
4
|
+
"command": "node",
|
|
5
|
+
"args": [
|
|
6
|
+
"./node_modules/@threenative/core/mcp/assets.mjs"
|
|
7
|
+
],
|
|
8
|
+
"env": {
|
|
9
|
+
"ASSET_DOWNLOAD_DIR": "./public/assets",
|
|
10
|
+
"AUDIO_DOWNLOAD_DIR": "./public/audio"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"threenative-sculpt": {
|
|
14
|
+
"command": "node",
|
|
15
|
+
"args": [
|
|
16
|
+
"./node_modules/@threenative/core/mcp/sculpt.mjs"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"threenative-engine": {
|
|
20
|
+
"command": "node",
|
|
21
|
+
"args": [
|
|
22
|
+
"./node_modules/@threenative/core/mcp/engine.mjs"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"threenative-blender": {
|
|
26
|
+
"command": "node",
|
|
27
|
+
"args": [
|
|
28
|
+
"./node_modules/@threenative/core/mcp/blender.mjs"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"threenative-assets": {
|
|
4
|
+
"command": "node",
|
|
5
|
+
"args": [
|
|
6
|
+
"./node_modules/@threenative/core/mcp/assets.mjs"
|
|
7
|
+
],
|
|
8
|
+
"env": {
|
|
9
|
+
"ASSET_DOWNLOAD_DIR": "./public/assets",
|
|
10
|
+
"AUDIO_DOWNLOAD_DIR": "./public/audio"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"threenative-sculpt": {
|
|
14
|
+
"command": "node",
|
|
15
|
+
"args": [
|
|
16
|
+
"./node_modules/@threenative/core/mcp/sculpt.mjs"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"threenative-engine": {
|
|
20
|
+
"command": "node",
|
|
21
|
+
"args": [
|
|
22
|
+
"./node_modules/@threenative/core/mcp/engine.mjs"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"threenative-blender": {
|
|
26
|
+
"command": "node",
|
|
27
|
+
"args": [
|
|
28
|
+
"./node_modules/@threenative/core/mcp/blender.mjs"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"servers": {
|
|
3
|
+
"threenative-assets": {
|
|
4
|
+
"type": "stdio",
|
|
5
|
+
"command": "node",
|
|
6
|
+
"args": [
|
|
7
|
+
"./node_modules/@threenative/core/mcp/assets.mjs"
|
|
8
|
+
],
|
|
9
|
+
"env": {
|
|
10
|
+
"ASSET_DOWNLOAD_DIR": "./public/assets",
|
|
11
|
+
"AUDIO_DOWNLOAD_DIR": "./public/audio"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"threenative-sculpt": {
|
|
15
|
+
"type": "stdio",
|
|
16
|
+
"command": "node",
|
|
17
|
+
"args": [
|
|
18
|
+
"./node_modules/@threenative/core/mcp/sculpt.mjs"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"threenative-engine": {
|
|
22
|
+
"type": "stdio",
|
|
23
|
+
"command": "node",
|
|
24
|
+
"args": [
|
|
25
|
+
"./node_modules/@threenative/core/mcp/engine.mjs"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"threenative-blender": {
|
|
29
|
+
"type": "stdio",
|
|
30
|
+
"command": "node",
|
|
31
|
+
"args": [
|
|
32
|
+
"./node_modules/@threenative/core/mcp/blender.mjs"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"context_servers": {
|
|
3
|
+
"threenative-assets": {
|
|
4
|
+
"source": "custom",
|
|
5
|
+
"command": "node",
|
|
6
|
+
"args": [
|
|
7
|
+
"./node_modules/@threenative/core/mcp/assets.mjs"
|
|
8
|
+
],
|
|
9
|
+
"env": {
|
|
10
|
+
"ASSET_DOWNLOAD_DIR": "./public/assets",
|
|
11
|
+
"AUDIO_DOWNLOAD_DIR": "./public/audio"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"threenative-sculpt": {
|
|
15
|
+
"source": "custom",
|
|
16
|
+
"command": "node",
|
|
17
|
+
"args": [
|
|
18
|
+
"./node_modules/@threenative/core/mcp/sculpt.mjs"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"threenative-engine": {
|
|
22
|
+
"source": "custom",
|
|
23
|
+
"command": "node",
|
|
24
|
+
"args": [
|
|
25
|
+
"./node_modules/@threenative/core/mcp/engine.mjs"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"threenative-blender": {
|
|
29
|
+
"source": "custom",
|
|
30
|
+
"command": "node",
|
|
31
|
+
"args": [
|
|
32
|
+
"./node_modules/@threenative/core/mcp/blender.mjs"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# AGENTS.md — __PROJECT_NAME__ rain
|
|
2
|
+
Instructions for the AI agent in this game. `CLAUDE.md` mirrors this file; edit `AGENTS.md`.
|
|
3
|
+
|
|
4
|
+
## Ownership
|
|
5
|
+
ThreeNative owns bootstrap, renderer, fixed-step loop, input, loading, audio lifetimes, and the state bridge. This repository owns the coastal storm: weather presets and easing, the fly camera, the shaders, lightning, sound design and the
|
|
6
|
+
interface; `src/game.ts` is portable and React mounts 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).
|
|
7
|
+
|
|
8
|
+
## Start every change
|
|
9
|
+
1. **Critical planning gate:** invoke `threenative-capabilities` before `prd-creator`. Search
|
|
10
|
+
`engine_search_capabilities` for the full request and each concrete mechanic, inspect relevant
|
|
11
|
+
matches with `engine_capability_detail`, and record a capability or no-match for the plan. Apply the `ponytail` ladder before writing code; never hand-write what the capability search already installs.
|
|
12
|
+
2. Then invoke `prd-creator`. Draft the plan around those capabilities and binding constraints,
|
|
13
|
+
direct the user to review it, and wait for explicit approval plus an instruction to implement it.
|
|
14
|
+
3. Treat returned constraints as binding. This kit needs no navmesh and imports none, so it runs
|
|
15
|
+
on every target; adding `@threenative/physics/navigation` would make it web and desktop only.
|
|
16
|
+
4. If a build, import, device, or blank frame fails, run `npx threenative doctor` and
|
|
17
|
+
`npx @threenative/playtest doctor`; missing observations are not zero.
|
|
18
|
+
|
|
19
|
+
## When the framework blocks you, write plain Three.js
|
|
20
|
+
|
|
21
|
+
When an `@threenative/*` API is broken, missing, or does not do what you need, replace only that
|
|
22
|
+
piece with portable Three.js/plain code. Keep the loop, scenes, input, registry, and playtest
|
|
23
|
+
bridge; avoid DOM globals, dynamic `import()`, and raw physics handles. **Report what blocked you**
|
|
24
|
+
(API, expectation, result, replacement); never stall the game.
|
|
25
|
+
|
|
26
|
+
## Workflow skills
|
|
27
|
+
|
|
28
|
+
- `.agents/skills/prd-creator/SKILL.md` / `.claude/skills/prd-creator/SKILL.md` — game plan and approval gate.
|
|
29
|
+
- `.agents/skills/threenative-capabilities/SKILL.md` / `.claude/skills/threenative-capabilities/SKILL.md` — capability search.
|
|
30
|
+
- `.agents/skills/threenative-playtest/SKILL.md` / `.claude/skills/threenative-playtest/SKILL.md` — diagnosis and proof.
|
|
31
|
+
- `.agents/skills/threenative-assets/SKILL.md` / `.claude/skills/threenative-assets/SKILL.md` — assets and sculpting.
|
|
32
|
+
- `.agents/skills/threenative-visuals/SKILL.md` / `.claude/skills/threenative-visuals/SKILL.md` — captures and look.
|
|
33
|
+
- `.agents/skills/threenative-performance/SKILL.md` / `.claude/skills/threenative-performance/SKILL.md` — measured budgets.
|
|
34
|
+
- `.agents/skills/threenative-ui/SKILL.md` / `.claude/skills/threenative-ui/SKILL.md` — native-safe UI.
|
|
35
|
+
- `.agents/skills/threenative-context/SKILL.md` / `.claude/skills/threenative-context/SKILL.md` — portable ctx APIs.
|
|
36
|
+
- 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 some of its imports yet. The pin keeps upstream Three.js on web and the legacy host on desktop. A native build names each unbound import with `TN_NATIVE_ENGINE_UNBOUND`. Android and iOS use the legacy host.
|
|
37
|
+
|
|
38
|
+
## Commands and map
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
pnpm dev
|
|
42
|
+
pnpm typecheck
|
|
43
|
+
pnpm build:web
|
|
44
|
+
pnpm build:desktop
|
|
45
|
+
pnpm test
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`src/state.ts` owns weather validation, the four presets, easing (τ 0.67 s), the flash envelope and
|
|
49
|
+
the `distance / 343` thunder delay; `src/scenes/Boot.ts` runs the simulation clock, auto-strikes
|
|
50
|
+
(gated on cloud cover above 0.35) and publishes everything the UI reads. The coast, clouds, rain
|
|
51
|
+
and bloom/grade are shaders generated from `tools/tempest-*.frag` by `node tools/generate-shaders.mjs`;
|
|
52
|
+
edit the `.frag`, never a generated `*-shader.ts`. Their named colours and lights live in
|
|
53
|
+
`src/render/palette.ts`, `sky.ts`, `lighting.ts` and `materials.ts`, the bolt in `lightning.ts`. 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.
|
|
54
|
+
The coast is one ray-marched screen quad, so it is marked with `alwaysRender`; so are the rain and
|
|
55
|
+
the bolt, whose quads are projected by their own vertex stage. Sound is three clips baked by
|
|
56
|
+
`tools/make-storm-audio.mjs` and played through `AudioBus` in `src/audio/storm.ts`; audio starts on a
|
|
57
|
+
gesture, and pause, mute and tab visibility each hold it. `safe` gates every strike at one door,
|
|
58
|
+
and `prefers-reduced-motion` turns it on at boot. Keep `playtests/survives.playtest.json` as smoke
|
|
59
|
+
proof, and `storm`, `lightning`, `reduced-motion` and `tiers` honest when you change what they assert.
|
|
60
|
+
To build a game on the storm, keep its rules in a plain module and wire them in `src/scenes/Boot.ts`: `strike()` is the one door every strike passes (its distance and thunder delay are in scope), the frame function runs per-step rules after the camera moves, and the round's state is a `GameState` field the UI reads; `Billboard3D` turns world markers to the camera.
|
|
61
|
+
|
|
62
|
+
## Portable authoring contracts
|
|
63
|
+
|
|
64
|
+
Leave `assets` absent: the cook selects target-decodable passes, with `models.sharedImages: true` deduplicating images. `sharedImages: false` embeds duplicate copies; `models.compact` (default `{ flatten: true, join: true, instance: true }`) flattens the scene graph, merges primitives by material and batches a mesh shared by several nodes as `EXT_mesh_gpu_instancing` — all lossless, keeping any node matching `protectedPattern` (or named in `protectedNames`), an animation target, or a skin joint individually addressable; `compact: false` ships the scene graph as authored. `models: "none"` / `textures: "none"` / `audio: "none"` skip those passes and report uncooked bytes. Android/iOS currently skip compression and model dedupe. `assets.exclude` defaults to `[]`; source-relative globs (for example `["unused/**"]`) omit matching files and report saved bytes. `assets.budget` accepts `{ uncooked?: number | "none", total?: number | "none" }`, default `{ uncooked: 64_000_000, total: "none" }`: only bytes left uncooked where cooking was possible count toward `uncooked`. A number sets that ceiling; `"none"` disables both gates. Either disabled gate still reports bytes. Automatic texture cooking retains unaligned source images unchanged and reports `block-size`; those bytes still count toward the uncooked budget. An explicit compression codec override must satisfy four-pixel block alignment; `codec: "none"` opts out. Cooking never silently resizes an image to fix alignment.
|
|
65
|
+
|
|
66
|
+
Relative look capture: a binding with `pointerRelative: true` captures the canvas on click by default; set `captureOnClick: false` and call `ctx.input.captureMouse()` from your own gesture to opt out. Desktop mode precedence is CLI (`--windowed`, `--maximized`, `--fullscreen`) over `display.fullscreen` over `window.maximized`; with both false, `window.width`/`height` size the normal window.
|
|
67
|
+
Scenes use `load`, `enter`, `update`, `exit`, `render`. One world unit is one metre; the camera starts at `(1.8, 2.85, 18)` and `src/render/camera.ts` owns its clamps and speeds; manual input cancels the cinematic orbit. There is no walking actor, weapon or agent here to ground, bind or navigate.
|
|
68
|
+
`input.vector("move").y` is +up and means forward; use one explicit `-move.y` conversion.
|
|
69
|
+
Rigged assets: put a `.glb` in `assets/`, await `ctx.assets.model("hero.glb")` in `Scene.load()`, then drive `AnimationPlayer` beside its entity. `ctx.goto(name)` rebuilds without resetting game
|
|
70
|
+
state; from a frame function `goto` and then `return`; `ctx.state.set({ /* copy this game's initial-state shape */ })`
|
|
71
|
+
is a partial patch. `game.goto("<scene-name>")` also rebuilds the scene, but it resets the game's
|
|
72
|
+
state. Seeded randomness is deterministic only when `defineGame({ seed })` is configured.
|
|
73
|
+
|
|
74
|
+
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. `src/render/quality.ts` owns `low`, `medium`, `high` (the engine chain: no built-in stage at any tier); the GPU family from `ctx.renderer.gpuClass` sets the start (`discrete` `high`, `integrated` and `mobile-high` `medium`, other phones `low`); `isMobile()` chooses `low`, otherwise `high` when the family is `unknown`; override with `setupPost(..., { tier: "low" })`. Unknown tiers throw and `TN_QUALITY_TIER` reports
|
|
75
|
+
the source. The player's four tiers are `STUDY_TIERS` in the same file. The bridge flushes about 100 ms; a control flushes it at once.
|
|
76
|
+
|
|
77
|
+
When an animation looks wrong, measure it before rewriting it. `clipPoseError` scores a
|
|
78
|
+
retargeted clip against its source per bone in degrees — whole quaternions relative to each rig's
|
|
79
|
+
own bind pose, so the two rigs' bind conventions cancel and a limb rolled about its own axis is
|
|
80
|
+
caught where a bone-direction check reads zero. `clipTrackBindings` names tracks that bind nothing
|
|
81
|
+
(the `<bone>.undefined` failure that plays the bind pose instead of the animation),
|
|
82
|
+
`clipBoneCoverage` names bones the clip does not drive and which therefore keep the previous
|
|
83
|
+
clip's pose, and `boneContact` reports in metres whether a named bone reaches the prop it is
|
|
84
|
+
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.
|
|
85
|
+
## Budget real time for the look
|
|
86
|
+
|
|
87
|
+
Reference-driven authoring starts at `node_modules/create-threenative/agent-docs/references/dream-loop.md`.
|
|
88
|
+
|
|
89
|
+
Open a capture after visual changes. A scenario with no assertions or missing observations fails. 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 beside the frame rate; `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.
|
|
90
|
+
|
|
91
|
+
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`.
|
|
92
|
+
## Optional multiplayer transport
|
|
93
|
+
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`.
|
|
94
|
+
Backlight exception: this storm raymarches custom shader lighting in `src/render/lighting.ts`; standard-material `rimGain`/`fillGain` conversion is unqualified. Preserve its authored flash rim and sky fill. The cloud render-target radiance is unknown until sampled; do not claim an environment contribution from `scene.environment`.
|
|
95
|
+
`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`.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<!-- Generated mirror of AGENTS.md. Do not edit; edit AGENTS.md. -->
|
|
2
|
+
|
|
3
|
+
# AGENTS.md — __PROJECT_NAME__ rain
|
|
4
|
+
Instructions for the AI agent in this game. `CLAUDE.md` mirrors this file; edit `AGENTS.md`.
|
|
5
|
+
|
|
6
|
+
## Ownership
|
|
7
|
+
ThreeNative owns bootstrap, renderer, fixed-step loop, input, loading, audio lifetimes, and the state bridge. This repository owns the coastal storm: weather presets and easing, the fly camera, the shaders, lightning, sound design and the
|
|
8
|
+
interface; `src/game.ts` is portable and React mounts 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
|
+
|
|
10
|
+
## Start every change
|
|
11
|
+
1. **Critical planning gate:** invoke `threenative-capabilities` before `prd-creator`. Search
|
|
12
|
+
`engine_search_capabilities` for the full request and each concrete mechanic, inspect relevant
|
|
13
|
+
matches with `engine_capability_detail`, and record a capability or no-match for the plan. Apply the `ponytail` ladder before writing code; never hand-write what the capability search already installs.
|
|
14
|
+
2. Then invoke `prd-creator`. Draft the plan around those capabilities and binding constraints,
|
|
15
|
+
direct the user to review it, and wait for explicit approval plus an instruction to implement it.
|
|
16
|
+
3. Treat returned constraints as binding. This kit needs no navmesh and imports none, so it runs
|
|
17
|
+
on every target; adding `@threenative/physics/navigation` would make it web and desktop only.
|
|
18
|
+
4. If a build, import, device, or blank frame fails, run `npx threenative doctor` and
|
|
19
|
+
`npx @threenative/playtest doctor`; missing observations are not zero.
|
|
20
|
+
|
|
21
|
+
## When the framework blocks you, write plain Three.js
|
|
22
|
+
|
|
23
|
+
When an `@threenative/*` API is broken, missing, or does not do what you need, replace only that
|
|
24
|
+
piece with portable Three.js/plain code. Keep the loop, scenes, input, registry, and playtest
|
|
25
|
+
bridge; avoid DOM globals, dynamic `import()`, and raw physics handles. **Report what blocked you**
|
|
26
|
+
(API, expectation, result, replacement); never stall the game.
|
|
27
|
+
|
|
28
|
+
## Workflow skills
|
|
29
|
+
|
|
30
|
+
- `.agents/skills/prd-creator/SKILL.md` / `.claude/skills/prd-creator/SKILL.md` — game plan and approval gate.
|
|
31
|
+
- `.agents/skills/threenative-capabilities/SKILL.md` / `.claude/skills/threenative-capabilities/SKILL.md` — capability search.
|
|
32
|
+
- `.agents/skills/threenative-playtest/SKILL.md` / `.claude/skills/threenative-playtest/SKILL.md` — diagnosis and proof.
|
|
33
|
+
- `.agents/skills/threenative-assets/SKILL.md` / `.claude/skills/threenative-assets/SKILL.md` — assets and sculpting.
|
|
34
|
+
- `.agents/skills/threenative-visuals/SKILL.md` / `.claude/skills/threenative-visuals/SKILL.md` — captures and look.
|
|
35
|
+
- `.agents/skills/threenative-performance/SKILL.md` / `.claude/skills/threenative-performance/SKILL.md` — measured budgets.
|
|
36
|
+
- `.agents/skills/threenative-ui/SKILL.md` / `.claude/skills/threenative-ui/SKILL.md` — native-safe UI.
|
|
37
|
+
- `.agents/skills/threenative-context/SKILL.md` / `.claude/skills/threenative-context/SKILL.md` — portable ctx APIs.
|
|
38
|
+
- 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 some of its imports yet. The pin keeps upstream Three.js on web and the legacy host on desktop. A native build names each unbound import with `TN_NATIVE_ENGINE_UNBOUND`. Android and iOS use the legacy host.
|
|
39
|
+
|
|
40
|
+
## Commands and map
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
pnpm dev
|
|
44
|
+
pnpm typecheck
|
|
45
|
+
pnpm build:web
|
|
46
|
+
pnpm build:desktop
|
|
47
|
+
pnpm test
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`src/state.ts` owns weather validation, the four presets, easing (τ 0.67 s), the flash envelope and
|
|
51
|
+
the `distance / 343` thunder delay; `src/scenes/Boot.ts` runs the simulation clock, auto-strikes
|
|
52
|
+
(gated on cloud cover above 0.35) and publishes everything the UI reads. The coast, clouds, rain
|
|
53
|
+
and bloom/grade are shaders generated from `tools/tempest-*.frag` by `node tools/generate-shaders.mjs`;
|
|
54
|
+
edit the `.frag`, never a generated `*-shader.ts`. Their named colours and lights live in
|
|
55
|
+
`src/render/palette.ts`, `sky.ts`, `lighting.ts` and `materials.ts`, the bolt in `lightning.ts`. 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.
|
|
56
|
+
The coast is one ray-marched screen quad, so it is marked with `alwaysRender`; so are the rain and
|
|
57
|
+
the bolt, whose quads are projected by their own vertex stage. Sound is three clips baked by
|
|
58
|
+
`tools/make-storm-audio.mjs` and played through `AudioBus` in `src/audio/storm.ts`; audio starts on a
|
|
59
|
+
gesture, and pause, mute and tab visibility each hold it. `safe` gates every strike at one door,
|
|
60
|
+
and `prefers-reduced-motion` turns it on at boot. Keep `playtests/survives.playtest.json` as smoke
|
|
61
|
+
proof, and `storm`, `lightning`, `reduced-motion` and `tiers` honest when you change what they assert.
|
|
62
|
+
To build a game on the storm, keep its rules in a plain module and wire them in `src/scenes/Boot.ts`: `strike()` is the one door every strike passes (its distance and thunder delay are in scope), the frame function runs per-step rules after the camera moves, and the round's state is a `GameState` field the UI reads; `Billboard3D` turns world markers to the camera.
|
|
63
|
+
|
|
64
|
+
## Portable authoring contracts
|
|
65
|
+
|
|
66
|
+
Leave `assets` absent: the cook selects target-decodable passes, with `models.sharedImages: true` deduplicating images. `sharedImages: false` embeds duplicate copies; `models.compact` (default `{ flatten: true, join: true, instance: true }`) flattens the scene graph, merges primitives by material and batches a mesh shared by several nodes as `EXT_mesh_gpu_instancing` — all lossless, keeping any node matching `protectedPattern` (or named in `protectedNames`), an animation target, or a skin joint individually addressable; `compact: false` ships the scene graph as authored. `models: "none"` / `textures: "none"` / `audio: "none"` skip those passes and report uncooked bytes. Android/iOS currently skip compression and model dedupe. `assets.exclude` defaults to `[]`; source-relative globs (for example `["unused/**"]`) omit matching files and report saved bytes. `assets.budget` accepts `{ uncooked?: number | "none", total?: number | "none" }`, default `{ uncooked: 64_000_000, total: "none" }`: only bytes left uncooked where cooking was possible count toward `uncooked`. A number sets that ceiling; `"none"` disables both gates. Either disabled gate still reports bytes. Automatic texture cooking retains unaligned source images unchanged and reports `block-size`; those bytes still count toward the uncooked budget. An explicit compression codec override must satisfy four-pixel block alignment; `codec: "none"` opts out. Cooking never silently resizes an image to fix alignment.
|
|
67
|
+
|
|
68
|
+
Relative look capture: a binding with `pointerRelative: true` captures the canvas on click by default; set `captureOnClick: false` and call `ctx.input.captureMouse()` from your own gesture to opt out. Desktop mode precedence is CLI (`--windowed`, `--maximized`, `--fullscreen`) over `display.fullscreen` over `window.maximized`; with both false, `window.width`/`height` size the normal window.
|
|
69
|
+
Scenes use `load`, `enter`, `update`, `exit`, `render`. One world unit is one metre; the camera starts at `(1.8, 2.85, 18)` and `src/render/camera.ts` owns its clamps and speeds; manual input cancels the cinematic orbit. There is no walking actor, weapon or agent here to ground, bind or navigate.
|
|
70
|
+
`input.vector("move").y` is +up and means forward; use one explicit `-move.y` conversion.
|
|
71
|
+
Rigged assets: put a `.glb` in `assets/`, await `ctx.assets.model("hero.glb")` in `Scene.load()`, then drive `AnimationPlayer` beside its entity. `ctx.goto(name)` rebuilds without resetting game
|
|
72
|
+
state; from a frame function `goto` and then `return`; `ctx.state.set({ /* copy this game's initial-state shape */ })`
|
|
73
|
+
is a partial patch. `game.goto("<scene-name>")` also rebuilds the scene, but it resets the game's
|
|
74
|
+
state. Seeded randomness is deterministic only when `defineGame({ seed })` is configured.
|
|
75
|
+
|
|
76
|
+
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. `src/render/quality.ts` owns `low`, `medium`, `high` (the engine chain: no built-in stage at any tier); the GPU family from `ctx.renderer.gpuClass` sets the start (`discrete` `high`, `integrated` and `mobile-high` `medium`, other phones `low`); `isMobile()` chooses `low`, otherwise `high` when the family is `unknown`; override with `setupPost(..., { tier: "low" })`. Unknown tiers throw and `TN_QUALITY_TIER` reports
|
|
77
|
+
the source. The player's four tiers are `STUDY_TIERS` in the same file. The bridge flushes about 100 ms; a control flushes it at once.
|
|
78
|
+
|
|
79
|
+
When an animation looks wrong, measure it before rewriting it. `clipPoseError` scores a
|
|
80
|
+
retargeted clip against its source per bone in degrees — whole quaternions relative to each rig's
|
|
81
|
+
own bind pose, so the two rigs' bind conventions cancel and a limb rolled about its own axis is
|
|
82
|
+
caught where a bone-direction check reads zero. `clipTrackBindings` names tracks that bind nothing
|
|
83
|
+
(the `<bone>.undefined` failure that plays the bind pose instead of the animation),
|
|
84
|
+
`clipBoneCoverage` names bones the clip does not drive and which therefore keep the previous
|
|
85
|
+
clip's pose, and `boneContact` reports in metres whether a named bone reaches the prop it is
|
|
86
|
+
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.
|
|
87
|
+
## Budget real time for the look
|
|
88
|
+
|
|
89
|
+
Reference-driven authoring starts at `node_modules/create-threenative/agent-docs/references/dream-loop.md`.
|
|
90
|
+
|
|
91
|
+
Open a capture after visual changes. A scenario with no assertions or missing observations fails. 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 beside the frame rate; `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
|
+
|
|
93
|
+
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
|
+
## Optional multiplayer transport
|
|
95
|
+
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`.
|
|
96
|
+
Backlight exception: this storm raymarches custom shader lighting in `src/render/lighting.ts`; standard-material `rimGain`/`fillGain` conversion is unqualified. Preserve its authored flash rim and sky fill. The cloud render-target radiance is unknown until sampled; do not claim an environment contribution from `scene.environment`.
|
|
97
|
+
`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`.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
|
|
6
|
+
<meta name="theme-color" content="#101c24" />
|
|
7
|
+
<meta
|
|
8
|
+
name="description"
|
|
9
|
+
content="A real-time coastal weather study. Shape rain, cloud, wind, fog and wetness, and watch a coastline answer."
|
|
10
|
+
/>
|
|
11
|
+
<link rel="icon" href="/favicon.svg" />
|
|
12
|
+
<title>__PROJECT_NAME__</title>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div id="root"></div>
|
|
16
|
+
<script type="module" src="/src/main.ts"></script>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|