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
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import type { GameState, WeatherKey } from "../state.js";
|
|
4
|
+
|
|
5
|
+
export interface IMenuProps {
|
|
6
|
+
readonly state: GameState;
|
|
7
|
+
readonly send: (intent: string, payload?: unknown) => void;
|
|
8
|
+
readonly say: (text: string) => void;
|
|
9
|
+
/** Photosensitivity mode: safe on also takes automatic lightning down with it, as the study does. */
|
|
10
|
+
readonly setSafeMode: (on: boolean) => void;
|
|
11
|
+
readonly toggleAutoLightning: () => void;
|
|
12
|
+
readonly panelOpen: boolean;
|
|
13
|
+
readonly setPanelOpen: (open: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ISwitchProps {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly label: string;
|
|
19
|
+
readonly checked: boolean;
|
|
20
|
+
readonly onToggle: () => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface ISliderControlProps {
|
|
24
|
+
readonly channel: WeatherKey;
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly label: string;
|
|
27
|
+
/** The slider's own upper bound in hundredths. Exposure reaches 1.8, the rest stop at 1. */
|
|
28
|
+
readonly max?: number;
|
|
29
|
+
readonly readout: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const QUALITY_LABELS: readonly { readonly value: GameState["quality"]; readonly label: string }[] =
|
|
33
|
+
[
|
|
34
|
+
{ value: "performance", label: "Performance" },
|
|
35
|
+
{ value: "balanced", label: "Balanced" },
|
|
36
|
+
{ value: "high", label: "High" },
|
|
37
|
+
{ value: "ultra", label: "Ultra" },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
function Switch({ checked, id, label, onToggle }: ISwitchProps) {
|
|
41
|
+
return (
|
|
42
|
+
<div className="switch-row">
|
|
43
|
+
<span>{label}</span>
|
|
44
|
+
<button
|
|
45
|
+
aria-checked={checked}
|
|
46
|
+
aria-label={label}
|
|
47
|
+
className="switch"
|
|
48
|
+
data-tn-interactive
|
|
49
|
+
id={id}
|
|
50
|
+
onClick={onToggle}
|
|
51
|
+
role="switch"
|
|
52
|
+
type="button"
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The frosted weather panel and the help dialog — every control that writes the atmosphere, plus
|
|
60
|
+
* the accessibility switches the study asks a reader to check before the first storm.
|
|
61
|
+
*/
|
|
62
|
+
export function Menu({
|
|
63
|
+
panelOpen,
|
|
64
|
+
say,
|
|
65
|
+
send,
|
|
66
|
+
setPanelOpen,
|
|
67
|
+
setSafeMode,
|
|
68
|
+
state,
|
|
69
|
+
toggleAutoLightning,
|
|
70
|
+
}: IMenuProps) {
|
|
71
|
+
const dialogRef = useRef<HTMLDialogElement>(null);
|
|
72
|
+
const helpRef = useRef<HTMLButtonElement>(null);
|
|
73
|
+
// The study drops the lit preset as soon as a slider is dragged, because the target is then no
|
|
74
|
+
// longer the preset's. The game keeps naming the last preset, so the UI owns the distinction.
|
|
75
|
+
const customTarget = useRef(false);
|
|
76
|
+
const target = state.target;
|
|
77
|
+
|
|
78
|
+
// A real `<dialog>` in the top layer: focus is trapped, Escape is the platform's own, and the
|
|
79
|
+
// backdrop click lands on the dialog element itself. State still decides whether it is open.
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
const dialog = dialogRef.current;
|
|
82
|
+
if (dialog === null) return;
|
|
83
|
+
if (state.helpOpen && !dialog.open) {
|
|
84
|
+
dialog.showModal();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!state.helpOpen && dialog.open) {
|
|
88
|
+
dialog.close();
|
|
89
|
+
helpRef.current?.focus();
|
|
90
|
+
}
|
|
91
|
+
}, [state.helpOpen]);
|
|
92
|
+
|
|
93
|
+
const weather = (channel: WeatherKey, value: number) => {
|
|
94
|
+
customTarget.current = true;
|
|
95
|
+
send("setWeather", { [channel]: value });
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const choosePreset = (name: "drizzle" | "storm" | "supercell") => {
|
|
99
|
+
customTarget.current = false;
|
|
100
|
+
send("setPreset", name);
|
|
101
|
+
say(`${name.toUpperCase()} · transitioning the atmosphere`);
|
|
102
|
+
setPanelOpen(false);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const control = ({ channel, id, label, max = 100, readout }: ISliderControlProps) => (
|
|
106
|
+
<div className="control">
|
|
107
|
+
<div className="control-line">
|
|
108
|
+
<label htmlFor={id}>{label}</label>
|
|
109
|
+
{readout}
|
|
110
|
+
</div>
|
|
111
|
+
{/* Mirrored: the value is the target the simulation is easing towards, so the control can
|
|
112
|
+
never show a number the game is not actually heading for. `--fill` paints the mint part
|
|
113
|
+
of the track. */}
|
|
114
|
+
<input
|
|
115
|
+
aria-label={label}
|
|
116
|
+
data-tn-interactive
|
|
117
|
+
id={id}
|
|
118
|
+
max={max}
|
|
119
|
+
min={0}
|
|
120
|
+
onChange={(event) => weather(channel, Number(event.target.value) / 100)}
|
|
121
|
+
style={
|
|
122
|
+
{ "--fill": `${Math.min(100, (target[channel] * 100) / max) * 100}%` } as CSSProperties
|
|
123
|
+
}
|
|
124
|
+
type="range"
|
|
125
|
+
value={Math.round(target[channel] * 100)}
|
|
126
|
+
/>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<>
|
|
132
|
+
<aside
|
|
133
|
+
aria-hidden={state.uiHidden}
|
|
134
|
+
aria-label="Weather controls"
|
|
135
|
+
className={`panel${panelOpen ? " mobile-open" : ""}${state.uiHidden ? " hidden" : ""}`}
|
|
136
|
+
>
|
|
137
|
+
<div className="panel-header">
|
|
138
|
+
<div className="weather-glyph">
|
|
139
|
+
<svg aria-hidden="true" viewBox="0 0 36 36">
|
|
140
|
+
<path d="M9 21a7 7 0 1 1 1-14 10 10 0 0 1 18 5 5 5 0 0 1 0 10M12 25l-2 4m9-4-2 4m9-4-2 4" />
|
|
141
|
+
</svg>
|
|
142
|
+
</div>
|
|
143
|
+
<div className="eyebrow">WEATHER SYSTEM</div>
|
|
144
|
+
<h2 className="panel-title">Inside the storm.</h2>
|
|
145
|
+
<div className="panel-sub">Shape the atmosphere. Feel it change.</div>
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div aria-label="Weather presets" className="presets">
|
|
149
|
+
{(["drizzle", "storm", "supercell"] as const).map((name) => (
|
|
150
|
+
<button
|
|
151
|
+
aria-pressed={state.preset === name && !customTarget.current}
|
|
152
|
+
className={state.preset === name && !customTarget.current ? "active" : undefined}
|
|
153
|
+
data-tn-interactive
|
|
154
|
+
id={`preset-${name}`}
|
|
155
|
+
key={name}
|
|
156
|
+
onClick={() => choosePreset(name)}
|
|
157
|
+
type="button"
|
|
158
|
+
>
|
|
159
|
+
{name.toUpperCase()}
|
|
160
|
+
</button>
|
|
161
|
+
))}
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div className="sliders">
|
|
165
|
+
{control({
|
|
166
|
+
channel: "rain",
|
|
167
|
+
id: "rain",
|
|
168
|
+
label: "Precipitation",
|
|
169
|
+
readout: (
|
|
170
|
+
<output className="readout" id="rainValue">
|
|
171
|
+
{Math.round(target.rain * 48)} <span>mm/h</span>
|
|
172
|
+
</output>
|
|
173
|
+
),
|
|
174
|
+
})}
|
|
175
|
+
{control({
|
|
176
|
+
channel: "cloud",
|
|
177
|
+
id: "cloud",
|
|
178
|
+
label: "Cloud cover",
|
|
179
|
+
readout: (
|
|
180
|
+
<output className="readout" id="cloudValue">
|
|
181
|
+
{Math.round(target.cloud * 100)} <span>%</span>
|
|
182
|
+
</output>
|
|
183
|
+
),
|
|
184
|
+
})}
|
|
185
|
+
{control({
|
|
186
|
+
channel: "wind",
|
|
187
|
+
id: "wind",
|
|
188
|
+
label: "Wind speed",
|
|
189
|
+
readout: (
|
|
190
|
+
<output className="readout" id="windValue">
|
|
191
|
+
{Math.round(target.wind * 72)} <span>km/h</span>
|
|
192
|
+
</output>
|
|
193
|
+
),
|
|
194
|
+
})}
|
|
195
|
+
{control({
|
|
196
|
+
channel: "fog",
|
|
197
|
+
id: "fog",
|
|
198
|
+
label: "Atmospheric haze",
|
|
199
|
+
readout: (
|
|
200
|
+
<output className="readout" id="fogValue">
|
|
201
|
+
{Math.round(target.fog * 100)} <span>%</span>
|
|
202
|
+
</output>
|
|
203
|
+
),
|
|
204
|
+
})}
|
|
205
|
+
</div>
|
|
206
|
+
<div className="divider" />
|
|
207
|
+
|
|
208
|
+
<Switch
|
|
209
|
+
checked={state.autoLightning}
|
|
210
|
+
id="autoLightning"
|
|
211
|
+
label="Automatic lightning"
|
|
212
|
+
onToggle={toggleAutoLightning}
|
|
213
|
+
/>
|
|
214
|
+
<Switch
|
|
215
|
+
checked={state.cinematic}
|
|
216
|
+
id="cinematic"
|
|
217
|
+
label="Cinematic camera"
|
|
218
|
+
onToggle={() => send("setCinematic", !state.cinematic)}
|
|
219
|
+
/>
|
|
220
|
+
|
|
221
|
+
<button
|
|
222
|
+
className="strike-button"
|
|
223
|
+
data-tn-interactive
|
|
224
|
+
id="strike"
|
|
225
|
+
disabled={state.safe}
|
|
226
|
+
onClick={() => send("strike")}
|
|
227
|
+
type="button"
|
|
228
|
+
>
|
|
229
|
+
<svg aria-hidden="true" viewBox="0 0 12 18">
|
|
230
|
+
<path d="M7 1 1 10h5l-1 7 6-10H6z" />
|
|
231
|
+
</svg>
|
|
232
|
+
<span className="button-label">Trigger lightning</span>
|
|
233
|
+
<kbd>L</kbd>
|
|
234
|
+
</button>
|
|
235
|
+
|
|
236
|
+
<details className="advanced">
|
|
237
|
+
<summary>RENDERING & ACCESSIBILITY</summary>
|
|
238
|
+
<Switch
|
|
239
|
+
checked={state.safe}
|
|
240
|
+
id="safe"
|
|
241
|
+
label="Disable lightning flashes"
|
|
242
|
+
onToggle={() => setSafeMode(!state.safe)}
|
|
243
|
+
/>
|
|
244
|
+
<Switch
|
|
245
|
+
checked={state.droplets}
|
|
246
|
+
id="lens"
|
|
247
|
+
label="Rain on the lens"
|
|
248
|
+
onToggle={() => send("setDroplets", !state.droplets)}
|
|
249
|
+
/>
|
|
250
|
+
{control({
|
|
251
|
+
channel: "exposure",
|
|
252
|
+
id: "exposure",
|
|
253
|
+
label: "Exposure",
|
|
254
|
+
max: 180,
|
|
255
|
+
readout: <output id="exposureValue">{target.exposure.toFixed(2)}</output>,
|
|
256
|
+
})}
|
|
257
|
+
{control({
|
|
258
|
+
channel: "wet",
|
|
259
|
+
id: "wet",
|
|
260
|
+
label: "Surface wetness",
|
|
261
|
+
readout: <output id="wetValue">{Math.round(target.wet * 100)}%</output>,
|
|
262
|
+
})}
|
|
263
|
+
{/* The scene publishes the rain geometry's own `instanceCount`, so this is the draw the
|
|
264
|
+
renderer was handed this frame rather than the budget it would come from. */}
|
|
265
|
+
<div className="engine" id="engine">
|
|
266
|
+
{state.dropCount} rain drops in the air
|
|
267
|
+
</div>
|
|
268
|
+
</details>
|
|
269
|
+
|
|
270
|
+
<div className="render-footer">
|
|
271
|
+
<span className="quality-label">RENDER QUALITY</span>
|
|
272
|
+
<select
|
|
273
|
+
aria-label="Render quality"
|
|
274
|
+
data-tn-interactive
|
|
275
|
+
id="quality"
|
|
276
|
+
onChange={(event) => send("setQuality", event.target.value)}
|
|
277
|
+
value={state.quality}
|
|
278
|
+
>
|
|
279
|
+
{QUALITY_LABELS.map((option) => (
|
|
280
|
+
<option key={option.value} value={option.value}>
|
|
281
|
+
{option.label}
|
|
282
|
+
</option>
|
|
283
|
+
))}
|
|
284
|
+
</select>
|
|
285
|
+
</div>
|
|
286
|
+
</aside>
|
|
287
|
+
|
|
288
|
+
{/*
|
|
289
|
+
* The backdrop click is a mouse convenience. The keyboard way out is Escape, which the
|
|
290
|
+
* native dialog reports through `onCancel` above, so this needs no key handler of its own.
|
|
291
|
+
*/}
|
|
292
|
+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: Escape is the keyboard way out. */}
|
|
293
|
+
<dialog
|
|
294
|
+
aria-labelledby="helpTitle"
|
|
295
|
+
className="modal"
|
|
296
|
+
onCancel={(event) => {
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
send("closeHelp");
|
|
299
|
+
}}
|
|
300
|
+
onClick={(event) => {
|
|
301
|
+
if (event.target === event.currentTarget) send("closeHelp");
|
|
302
|
+
}}
|
|
303
|
+
ref={dialogRef}
|
|
304
|
+
>
|
|
305
|
+
<div className="modal-content">
|
|
306
|
+
<button
|
|
307
|
+
aria-label="Close help"
|
|
308
|
+
className="icon-btn close"
|
|
309
|
+
data-tn-interactive
|
|
310
|
+
onClick={() => send("closeHelp")}
|
|
311
|
+
type="button"
|
|
312
|
+
>
|
|
313
|
+
×
|
|
314
|
+
</button>
|
|
315
|
+
<div className="eyebrow" style={{ marginBottom: "14px" }}>
|
|
316
|
+
EXPLORE THE ATMOSPHERE
|
|
317
|
+
</div>
|
|
318
|
+
<h2 id="helpTitle">A moment in the storm.</h2>
|
|
319
|
+
<p>
|
|
320
|
+
Drag the scene to look around. Move along the road or rise above the coast. Every
|
|
321
|
+
surface, cloud and sound is generated in real time.
|
|
322
|
+
</p>
|
|
323
|
+
<div className="help-grid">
|
|
324
|
+
<span>
|
|
325
|
+
<kbd>W A S D</kbd> Move
|
|
326
|
+
</span>
|
|
327
|
+
<span>
|
|
328
|
+
<kbd>Q E</kbd> Altitude
|
|
329
|
+
</span>
|
|
330
|
+
<span>
|
|
331
|
+
<kbd>SHIFT</kbd> Move faster
|
|
332
|
+
</span>
|
|
333
|
+
<span>
|
|
334
|
+
<kbd>R</kbd> Reset view
|
|
335
|
+
</span>
|
|
336
|
+
<span>
|
|
337
|
+
<kbd>L</kbd> Lightning
|
|
338
|
+
</span>
|
|
339
|
+
<span>
|
|
340
|
+
<kbd>SPACE</kbd> Pause
|
|
341
|
+
</span>
|
|
342
|
+
<span>
|
|
343
|
+
<kbd>H</kbd> Hide interface
|
|
344
|
+
</span>
|
|
345
|
+
<span>
|
|
346
|
+
<kbd>P</kbd> Save image
|
|
347
|
+
</span>
|
|
348
|
+
<span>
|
|
349
|
+
<kbd>F</kbd> Fullscreen
|
|
350
|
+
</span>
|
|
351
|
+
<span>
|
|
352
|
+
<kbd>X</kbd> Disable flashes
|
|
353
|
+
</span>
|
|
354
|
+
<span>
|
|
355
|
+
<kbd>M</kbd> Sound on / mute
|
|
356
|
+
</span>
|
|
357
|
+
</div>
|
|
358
|
+
<p className="warning">
|
|
359
|
+
Photosensitivity: lightning creates bright, repeated flashes. Press X to disable all
|
|
360
|
+
flashes. Reduced-motion preferences disable automatic lightning by default.
|
|
361
|
+
</p>
|
|
362
|
+
<p>
|
|
363
|
+
Weather readings are simulation controls, not a live forecast. The landscape is
|
|
364
|
+
procedural, with no scanned assets.
|
|
365
|
+
</p>
|
|
366
|
+
</div>
|
|
367
|
+
</dialog>
|
|
368
|
+
</>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The automation vocabulary, with no browser in it.
|
|
3
|
+
*
|
|
4
|
+
* The source study called its render tiers `low`, `balanced`, `high` and `cinematic`; this
|
|
5
|
+
* framework calls them `performance`, `balanced`, `high` and `ultra`. Both names are accepted —
|
|
6
|
+
* a captured URL or a script written against the source keeps working — and one table is the
|
|
7
|
+
* whole mapping. A name in neither list throws: a typo must not silently pick a tier and report
|
|
8
|
+
* success.
|
|
9
|
+
*
|
|
10
|
+
* Query reading takes a search string rather than reaching for `location`, so the rules are the
|
|
11
|
+
* same on every target and a test can hold one.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { QualityName } from "../state.js";
|
|
15
|
+
|
|
16
|
+
/** The four engine tiers, plus the four names the source study published for them. */
|
|
17
|
+
export const QUALITY_ALIASES = {
|
|
18
|
+
balanced: "balanced",
|
|
19
|
+
cinematic: "ultra",
|
|
20
|
+
high: "high",
|
|
21
|
+
low: "performance",
|
|
22
|
+
performance: "performance",
|
|
23
|
+
ultra: "ultra",
|
|
24
|
+
} as const satisfies Record<string, QualityName>;
|
|
25
|
+
|
|
26
|
+
export type QualityRequest = keyof typeof QUALITY_ALIASES;
|
|
27
|
+
|
|
28
|
+
/** The engine tier one requested name means. Throws on a name in neither vocabulary. */
|
|
29
|
+
export function qualityTier(name: unknown): QualityName {
|
|
30
|
+
if (typeof name !== "string" || !Object.hasOwn(QUALITY_ALIASES, name)) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`TN_RAIN_QUALITY_UNKNOWN ${String(name)}: expected low, balanced, high or cinematic`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return QUALITY_ALIASES[name as QualityRequest];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface IAutomationRequest {
|
|
39
|
+
/** `?still` — freeze the simulation instead of running it. Honoured after the first real frame. */
|
|
40
|
+
readonly still: boolean;
|
|
41
|
+
/** The tier `?quality=` asked for, in engine names. */
|
|
42
|
+
readonly quality?: QualityName;
|
|
43
|
+
/** A `?quality=` this build cannot honour, reported rather than quietly defaulted. */
|
|
44
|
+
readonly rejectedQuality?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* What the query asks for. An unreadable tier is named in `rejectedQuality` instead of thrown: a
|
|
49
|
+
* URL is a place somebody typed, and the page still has to open.
|
|
50
|
+
*/
|
|
51
|
+
export function automationRequest(search: string): IAutomationRequest {
|
|
52
|
+
const query = new URLSearchParams(search);
|
|
53
|
+
const asked = query.get("quality");
|
|
54
|
+
if (asked === null) return { still: query.has("still") };
|
|
55
|
+
try {
|
|
56
|
+
return { still: query.has("still"), quality: qualityTier(asked) };
|
|
57
|
+
} catch {
|
|
58
|
+
return { still: query.has("still"), rejectedQuality: asked };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The source study's `window.tempest`, rebuilt on this framework's own doors.
|
|
3
|
+
*
|
|
4
|
+
* The source was one HTML file with its own render loop, so `render()` drew a frame and `step(dt)`
|
|
5
|
+
* advanced the simulation by hand. Here the engine owns the loop and draws every frame anyway, so
|
|
6
|
+
* `render()` resolves once the scene has really drawn another one, and `step(dt)` hands the next
|
|
7
|
+
* frame `dt` seconds of simulation through the same intent door the buttons use. `stop()` freezes
|
|
8
|
+
* the simulation clock rather than the loop, so a stopped study can still be stepped and rendered,
|
|
9
|
+
* which is what the source's `stop` + `step` pairing was for. Every value it reports is read back
|
|
10
|
+
* from the store the simulation wrote.
|
|
11
|
+
*
|
|
12
|
+
* It lives in the UI realm because `window`, `document` and the UI end of the state bridge are
|
|
13
|
+
* browser APIs. `src/game.ts` stays portable: this sends the same validated intents the buttons do.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { IGame } from "@threenative/core";
|
|
17
|
+
import { connectUiBridge, sendUiIntent, subscribeUiState } from "@threenative/core/ui-layer";
|
|
18
|
+
import type { GameState, PresetName, WeatherKey } from "../state.js";
|
|
19
|
+
import type { ICaptureResult, ISceneSizes } from "./Hud.js";
|
|
20
|
+
import { captureScene, sceneCanvas } from "./Hud.js";
|
|
21
|
+
import { automationRequest, qualityTier } from "./automation.js";
|
|
22
|
+
|
|
23
|
+
/** One automation verb, mapped to the intent the interface already sends. */
|
|
24
|
+
type IntentName =
|
|
25
|
+
| "setFrozen"
|
|
26
|
+
| "setPreset"
|
|
27
|
+
| "setQuality"
|
|
28
|
+
| "setSafe"
|
|
29
|
+
| "setWeather"
|
|
30
|
+
| "step"
|
|
31
|
+
| "strike";
|
|
32
|
+
|
|
33
|
+
export interface ITempestApi {
|
|
34
|
+
/** Frames the scene has actually simulated and drawn, as it counted them. */
|
|
35
|
+
readonly frames: number;
|
|
36
|
+
/** The lightning envelope the last drawn frame carried, or 0 in photosensitivity mode. */
|
|
37
|
+
readonly flash: number;
|
|
38
|
+
/** The stage the renderer is really drawing, in device pixels. */
|
|
39
|
+
readonly sizes: ISceneSizes;
|
|
40
|
+
/** The live published state, so a script reads what the simulation is actually doing. */
|
|
41
|
+
readonly state: GameState;
|
|
42
|
+
readonly setPreset: (name: PresetName) => void;
|
|
43
|
+
/** Accepts the source's `low`/`balanced`/`high`/`cinematic` and the engine's four names. */
|
|
44
|
+
readonly setQuality: (name: string) => void;
|
|
45
|
+
readonly setSafe: (on: boolean) => void;
|
|
46
|
+
readonly setWeather: (values: Partial<Record<WeatherKey, number>>) => void;
|
|
47
|
+
/** Freeze the simulation clock. Frames still draw; only `step` moves it on. */
|
|
48
|
+
readonly stop: () => void;
|
|
49
|
+
/** Advance the simulation by `dt` seconds (clamped to 0..60) and resolve on the frame that drew it. */
|
|
50
|
+
readonly step: (dt: number) => Promise<number>;
|
|
51
|
+
/** Resolve with the frame count once the scene has drawn at least one more frame. */
|
|
52
|
+
readonly render: () => Promise<number>;
|
|
53
|
+
readonly triggerLightning: () => void;
|
|
54
|
+
/** Save the frame. Resolves with the image that was really encoded, or why there was none. */
|
|
55
|
+
readonly capture: () => Promise<ICaptureResult>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const say = (text: string): void => {
|
|
59
|
+
console.info(`TN_TEMPEST ${text}`);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const canvasSize = (canvas: HTMLCanvasElement): ISceneSizes => ({
|
|
63
|
+
height: canvas.height,
|
|
64
|
+
width: canvas.width,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Publish the facade and honour the query.
|
|
69
|
+
*
|
|
70
|
+
* `?still` waits for a real frame before it stops the loop. The source simply never started one,
|
|
71
|
+
* which could leave a canvas that had never been presented; here the loop belongs to the engine,
|
|
72
|
+
* so the only faithful still is the loop stopped after the first frame it actually drew, with the
|
|
73
|
+
* simulation clock where the source started it.
|
|
74
|
+
*/
|
|
75
|
+
export function installTempest(game: IGame<GameState>): ITempestApi {
|
|
76
|
+
const bridge = connectUiBridge({ end: "ui" });
|
|
77
|
+
const mirror = subscribeUiState<GameState>(bridge);
|
|
78
|
+
const send = (intent: IntentName, payload?: unknown): void => {
|
|
79
|
+
sendUiIntent(bridge, intent, payload);
|
|
80
|
+
};
|
|
81
|
+
const query = new URLSearchParams(window.location.search);
|
|
82
|
+
const request = automationRequest(window.location.search);
|
|
83
|
+
if (request.rejectedQuality !== undefined) {
|
|
84
|
+
say(
|
|
85
|
+
`?quality=${request.rejectedQuality} is not a tier: expected low, balanced, high or cinematic`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (request.quality !== undefined) send("setQuality", request.quality);
|
|
89
|
+
if (query.has("offline")) {
|
|
90
|
+
// The source's offline WebGL2 adapter stood in for a Three.js build it could not load from a
|
|
91
|
+
// CDN. This build installs Three locally and never reaches for one, so there is no fallback
|
|
92
|
+
// to select and nothing here pretends otherwise.
|
|
93
|
+
say("?offline selects no adapter: this build loads Three from its own install");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Resolves once the simulation has counted a frame past the one this was called on. */
|
|
97
|
+
const nextFrame = (): Promise<number> => {
|
|
98
|
+
const from = game.state.getState().frame;
|
|
99
|
+
return new Promise((resolve) => {
|
|
100
|
+
const stop = mirror.subscribe(() => {
|
|
101
|
+
const frame = mirror.get()?.frame ?? 0;
|
|
102
|
+
if (frame <= from) return;
|
|
103
|
+
stop();
|
|
104
|
+
resolve(frame);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const api: ITempestApi = {
|
|
110
|
+
get frames() {
|
|
111
|
+
return game.state.getState().frame;
|
|
112
|
+
},
|
|
113
|
+
get flash() {
|
|
114
|
+
return game.state.getState().flash;
|
|
115
|
+
},
|
|
116
|
+
get sizes() {
|
|
117
|
+
const canvas = sceneCanvas();
|
|
118
|
+
return canvas === null ? { height: 0, width: 0 } : canvasSize(canvas);
|
|
119
|
+
},
|
|
120
|
+
get state() {
|
|
121
|
+
return game.state.getState();
|
|
122
|
+
},
|
|
123
|
+
setPreset: (name) => send("setPreset", name),
|
|
124
|
+
setQuality: (name) => send("setQuality", qualityTier(name)),
|
|
125
|
+
setSafe: (on) => send("setSafe", on),
|
|
126
|
+
setWeather: (values) => send("setWeather", values),
|
|
127
|
+
stop: () => send("setFrozen", true),
|
|
128
|
+
step: (dt) => {
|
|
129
|
+
const frame = nextFrame();
|
|
130
|
+
send("step", dt);
|
|
131
|
+
return frame;
|
|
132
|
+
},
|
|
133
|
+
render: nextFrame,
|
|
134
|
+
triggerLightning: () => send("strike"),
|
|
135
|
+
capture: () => captureScene(say),
|
|
136
|
+
};
|
|
137
|
+
if (request.still) {
|
|
138
|
+
const stop = mirror.subscribe(() => {
|
|
139
|
+
if ((mirror.get()?.frame ?? 0) < 1) return;
|
|
140
|
+
stop();
|
|
141
|
+
send("setFrozen", true);
|
|
142
|
+
say(`still · loop stopped on frame ${api.frames} · t=${api.state.elapsed.toFixed(2)}s`);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
(window as unknown as { tempest?: ITempestApi }).tempest = api;
|
|
146
|
+
const { width, height } = api.sizes;
|
|
147
|
+
say(`ready · ${width}x${height} · ${request.still ? "still" : "running"}`);
|
|
148
|
+
return api;
|
|
149
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { IThreeNativeConfig } from "@threenative/core";
|
|
2
|
+
|
|
3
|
+
const config: IThreeNativeConfig = {
|
|
4
|
+
app: {
|
|
5
|
+
id: "com.threenative.__PROJECT_ID__",
|
|
6
|
+
name: "__PROJECT_NAME__",
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
build: 1,
|
|
9
|
+
icon: "public/icon.png",
|
|
10
|
+
icons: { web: { favicon: "public/favicon.svg" } },
|
|
11
|
+
},
|
|
12
|
+
display: {
|
|
13
|
+
orientation: "landscape",
|
|
14
|
+
fullscreen: true,
|
|
15
|
+
keepScreenOn: true,
|
|
16
|
+
maxFps: 60,
|
|
17
|
+
},
|
|
18
|
+
window: {
|
|
19
|
+
title: "__PROJECT_NAME__",
|
|
20
|
+
width: 1280,
|
|
21
|
+
height: 720,
|
|
22
|
+
maximized: false,
|
|
23
|
+
resizable: true,
|
|
24
|
+
},
|
|
25
|
+
bootSplash: { backgroundColor: "#061b2b" },
|
|
26
|
+
nativeEntry: "src/game.ts",
|
|
27
|
+
renderer: {
|
|
28
|
+
preferWebGPU: true,
|
|
29
|
+
resolutionScale: "auto",
|
|
30
|
+
// Multisampling resolves triangle edges. A cutout silhouette — foliage, a fence, hair — is
|
|
31
|
+
// carved inside the triangle by an alpha test, so it resolves through the coverage mask or
|
|
32
|
+
// not at all, which is what this spends the samples above on. It costs no target and no
|
|
33
|
+
// extra pass; set it false for a deliberately hard-edged look. `TN_ALPHA_ANTIALIASING`
|
|
34
|
+
// reports what it did, and says so when a single-sampled surface leaves it nothing to do.
|
|
35
|
+
alphaAntialiasing: true,
|
|
36
|
+
},
|
|
37
|
+
ui: { renderer: "web" },
|
|
38
|
+
assets: {
|
|
39
|
+
audio: {
|
|
40
|
+
// The three storm clips are the authored waveform, not material to be conditioned. Each is
|
|
41
|
+
// a Float32 WAV baked by `tools/make-storm-audio.mjs` from the reference study's own maths,
|
|
42
|
+
// and the default pass would move them: a peak ceiling on the wind bed (which peaks above
|
|
43
|
+
// 1.0 by design) and a Vorbis round trip on all three. `conditioning: "none"` ships the bytes
|
|
44
|
+
// as committed — measurement, the receipt, and each loop's seam assertion all still run, so
|
|
45
|
+
// this buys preservation, not silence.
|
|
46
|
+
overrides: [
|
|
47
|
+
{ conditioning: "none", glob: "rain-loop.wav", loop: true },
|
|
48
|
+
{ conditioning: "none", glob: "thunder.wav" },
|
|
49
|
+
{ conditioning: "none", glob: "wind-loop.wav", loop: true },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
// One asset tree, one compiler, one representation per artifact. Uncomment, then cook:
|
|
54
|
+
// threenative build --target android # cooks defaults.android; --profile <name> beats it
|
|
55
|
+
// buildProfiles: {
|
|
56
|
+
// defaults: { android: "compact" },
|
|
57
|
+
// profiles: {
|
|
58
|
+
// compact: {
|
|
59
|
+
// assets: { textures: { maxSize: 1024 }, models: { textures: { maxSize: 1024 } } },
|
|
60
|
+
// } },
|
|
61
|
+
// },
|
|
62
|
+
// Contract, byte definitions, the build report:
|
|
63
|
+
// node_modules/create-threenative/agent-docs/references/build-profiles.md
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default config;
|