create-threenative 0.2.6 → 0.2.8
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 +5 -3
- package/agent-docs/references/build-profiles.md +126 -0
- package/agent-docs/references/capability-reference.md +607 -26
- package/agent-docs/references/performance-basics.md +8 -5
- package/agent-docs/references/sculpt-from-a-reference.md +1 -1
- package/agent-docs/references/trace-a-slow-frame.md +1 -1
- package/agent-docs/references/visual-baseline.md +8 -4
- package/agent-files/.agents/skills/file-engine-bug/SKILL.md +15 -4
- package/agent-files/.agents/skills/threenative-assets/SKILL.md +5 -5
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-context/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-performance/SKILL.md +3 -3
- package/agent-files/.agents/skills/threenative-playtest/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-ui/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-visuals/SKILL.md +4 -4
- package/capabilities.json +801 -24
- package/dist/index.d.ts +30 -1
- package/dist/index.js +300 -56
- package/dist/threenative.js +717 -156
- package/package.json +6 -6
- package/template-assets/assets/mannequin-combat.glb +0 -0
- package/template-assets/assets/mannequin.glb +0 -0
- package/template-assets/assets/player-viewmodel.glb +0 -0
- package/template-assets/assets/sky.jpg +0 -0
- package/template-assets/clearwater/README.md +141 -0
- package/template-assets/clearwater/install.mjs +50 -0
- package/template-assets/clearwater/src/clearwater.ts +180 -0
- package/template-assets/clearwater/src/clearwaterDemo.ts +28 -0
- package/template-assets/clearwater/src/clearwaterLifetime.ts +28 -0
- package/{LICENSE → template-assets/clearwater/src/render/CLEARWATER-LICENSE.txt} +4 -1
- package/template-assets/clearwater/src/render/clearwater.ts +278 -0
- package/template-assets/clearwater/src/render/clearwaterCaustics.ts +138 -0
- package/template-assets/clearwater/src/render/clearwaterDemo.ts +65 -0
- package/template-assets/clearwater/src/render/clearwaterOptics.ts +33 -0
- package/template-assets/clearwater/src/render/clearwaterOptions.ts +177 -0
- package/template-assets/clearwater/src/render/clearwaterPass.ts +51 -0
- package/template-assets/patches/three@0.185.1.patch +2101 -138
- package/template-assets/worldEnvironment.ts +52 -1
- package/templates/action-rpg/AGENTS.md +42 -42
- package/templates/action-rpg/CLAUDE.md +42 -42
- package/templates/action-rpg/kit.json +1 -1
- package/templates/action-rpg/package.json +13 -7
- package/templates/action-rpg/playtests/combat.playtest.json +162 -23
- package/templates/action-rpg/playtests/performance.playtest.json +4 -3
- package/templates/action-rpg/playtests/survives.playtest.json +25 -8
- package/templates/action-rpg/src/conventions.ts +24 -18
- package/templates/action-rpg/src/entities/Enemy.ts +74 -24
- package/templates/action-rpg/src/entities/Fighter.ts +127 -0
- package/templates/action-rpg/src/entities/Player.ts +102 -32
- package/templates/action-rpg/src/game.ts +3 -3
- package/templates/action-rpg/src/render/camera.ts +18 -16
- package/templates/action-rpg/src/render/dungeon.ts +192 -0
- package/templates/action-rpg/src/render/lighting.ts +45 -28
- package/templates/action-rpg/src/render/loading.ts +4 -4
- package/templates/action-rpg/src/render/materials.ts +191 -47
- package/templates/action-rpg/src/render/palette.ts +14 -13
- package/templates/action-rpg/src/render/postprocessing.ts +12 -2
- package/templates/action-rpg/src/render/props.ts +117 -0
- package/templates/action-rpg/src/render/quality.ts +40 -82
- package/templates/action-rpg/src/render/sky.ts +36 -13
- package/templates/action-rpg/src/render/touch-controls.ts +1 -1
- package/templates/action-rpg/src/render/worldEnvironment.ts +52 -1
- package/templates/action-rpg/src/scenes/Play.ts +61 -39
- package/templates/action-rpg/src/style.css +9 -7
- package/templates/action-rpg/src/ui/AbilityBar.tsx +3 -1
- package/templates/action-rpg/src/ui/Hud.tsx +3 -3
- package/templates/action-rpg/threenative.config.ts +14 -1
- package/templates/action-rpg/vite.config.ts +4 -1
- package/templates/minimal/AGENTS.md +10 -10
- package/templates/minimal/CLAUDE.md +10 -10
- package/templates/minimal/package.json +12 -6
- package/templates/minimal/playtests/play.playtest.json +6 -5
- package/templates/minimal/playtests/sky.playtest.json +27 -0
- package/templates/minimal/src/conventions.ts +6 -3
- package/templates/minimal/src/entities/Player.ts +73 -27
- package/templates/minimal/src/main.ts +2 -3
- package/templates/minimal/src/render/camera.ts +22 -4
- package/templates/minimal/src/render/lighting.ts +24 -48
- package/templates/minimal/src/render/materials.ts +158 -13
- package/templates/minimal/src/render/palette.ts +10 -7
- package/templates/minimal/src/render/postprocessing.ts +12 -25
- package/templates/minimal/src/render/quality.ts +35 -69
- package/templates/minimal/src/render/sky.ts +35 -54
- package/templates/minimal/src/render/touch-controls.ts +1 -1
- package/templates/minimal/src/render/worldEnvironment.ts +52 -1
- package/templates/minimal/src/scenes/Play.ts +121 -111
- package/templates/minimal/src/state.ts +0 -4
- package/templates/minimal/src/style.css +0 -10
- package/templates/minimal/threenative.config.ts +14 -1
- package/templates/minimal/vite.config.ts +4 -1
- package/templates/platformer/AGENTS.md +18 -56
- package/templates/platformer/CLAUDE.md +18 -56
- package/templates/platformer/kit.json +2 -2
- package/templates/platformer/package.json +13 -9
- package/templates/platformer/playtests/buffer.playtest.json +15 -5
- package/templates/platformer/playtests/collect.playtest.json +8 -34
- package/templates/platformer/playtests/coyote.playtest.json +12 -34
- package/templates/platformer/playtests/damage.playtest.json +40 -15
- package/templates/platformer/playtests/hud.playtest.json +34 -0
- package/templates/platformer/playtests/move.playtest.json +24 -0
- package/templates/platformer/playtests/performance.playtest.json +24 -7
- package/templates/platformer/playtests/respawn.playtest.json +46 -11
- package/templates/platformer/playtests/stomp.playtest.json +49 -12
- package/templates/platformer/playtests/survives.playtest.json +3 -19
- package/templates/platformer/playtests/world.playtest.json +26 -0
- package/templates/platformer/src/entities/Fox.ts +273 -0
- package/templates/platformer/src/entities/Pickup.ts +43 -60
- package/templates/platformer/src/entities/Walker.ts +88 -0
- package/templates/platformer/src/game.ts +11 -8
- package/templates/platformer/src/level/Checkpoints.ts +29 -16
- package/templates/platformer/src/level/Stage.ts +469 -0
- package/templates/platformer/src/render/blocks.ts +94 -0
- package/templates/platformer/src/render/camera.ts +28 -3
- package/templates/platformer/src/render/fox.ts +196 -0
- package/templates/platformer/src/render/lighting.ts +42 -33
- package/templates/platformer/src/render/materials.ts +115 -5
- package/templates/platformer/src/render/palette.ts +68 -53
- package/templates/platformer/src/render/pickups.ts +142 -0
- package/templates/platformer/src/render/postprocessing.ts +12 -2
- package/templates/platformer/src/render/props.ts +147 -0
- package/templates/platformer/src/render/quality.ts +47 -99
- package/templates/platformer/src/render/scenery.ts +172 -0
- package/templates/platformer/src/render/sky.ts +120 -31
- package/templates/platformer/src/render/touch-controls.ts +5 -2
- package/templates/platformer/src/render/walkers.ts +96 -0
- package/templates/platformer/src/render/waterfall.ts +85 -0
- package/templates/platformer/src/render/worldEnvironment.ts +52 -1
- package/templates/platformer/src/scenes/Boot.ts +3 -4
- package/templates/platformer/src/scenes/Play.ts +362 -0
- package/templates/platformer/src/state.ts +16 -14
- package/templates/platformer/src/style.css +9 -8
- package/templates/platformer/src/ui/Hud.tsx +62 -29
- package/templates/platformer/src/ui/Menu.tsx +2 -2
- package/templates/platformer/threenative.config.ts +14 -1
- package/templates/platformer/vite.config.ts +4 -1
- package/templates/puzzle/AGENTS.md +19 -20
- package/templates/puzzle/CLAUDE.md +19 -20
- package/templates/puzzle/assets/native-proof.glb +0 -0
- package/templates/puzzle/assets/native-proof.png +0 -0
- package/templates/puzzle/kit.json +1 -1
- package/templates/puzzle/package.json +13 -7
- package/templates/puzzle/playtests/axis.playtest.json +20 -0
- package/templates/puzzle/playtests/blocked.playtest.json +73 -0
- package/templates/puzzle/playtests/caused.playtest.json +65 -0
- package/templates/puzzle/playtests/lit.playtest.json +74 -0
- package/templates/puzzle/playtests/performance.playtest.json +24 -7
- package/templates/{starter/playtests/respawn.playtest.json → puzzle/playtests/push.playtest.json} +24 -19
- package/templates/puzzle/playtests/replay.playtest.json +81 -0
- package/templates/puzzle/playtests/restart.playtest.json +108 -0
- package/templates/puzzle/playtests/seal.playtest.json +98 -0
- package/templates/puzzle/playtests/settle.playtest.json +100 -0
- package/templates/puzzle/playtests/survives.playtest.json +6 -29
- package/templates/{starter/playtests/hot-reload.playtest.json → puzzle/playtests/travel.playtest.json} +6 -5
- package/templates/puzzle/src/entities/Crate.ts +99 -42
- package/templates/puzzle/src/entities/Seal.ts +69 -0
- package/templates/puzzle/src/entities/Warden.ts +135 -0
- package/templates/puzzle/src/game.ts +15 -11
- package/templates/puzzle/src/render/camera.ts +66 -31
- package/templates/puzzle/src/render/crateShape.ts +70 -0
- package/templates/puzzle/src/render/lighting.ts +41 -41
- package/templates/puzzle/src/render/loading.ts +4 -4
- package/templates/puzzle/src/render/materials.ts +131 -27
- package/templates/puzzle/src/render/palette.ts +19 -29
- package/templates/puzzle/src/render/postprocessing.ts +15 -3
- package/templates/puzzle/src/render/quality.ts +71 -80
- package/templates/puzzle/src/render/shapes.ts +109 -108
- package/templates/puzzle/src/render/sky.ts +18 -10
- package/templates/puzzle/src/render/touch-controls.ts +8 -51
- package/templates/puzzle/src/render/vault.ts +315 -0
- package/templates/puzzle/src/render/warden.ts +46 -0
- package/templates/puzzle/src/render/worldEnvironment.ts +52 -1
- package/templates/puzzle/src/scenes/Play.ts +793 -0
- package/templates/puzzle/src/state.ts +55 -24
- package/templates/puzzle/src/style.css +7 -8
- package/templates/puzzle/src/ui/App.tsx +2 -2
- package/templates/puzzle/src/ui/Hud.tsx +92 -40
- package/templates/puzzle/src/ui/Menu.tsx +40 -2
- package/templates/puzzle/threenative.config.ts +14 -1
- package/templates/puzzle/vite.config.ts +4 -1
- package/templates/racing/AGENTS.md +19 -20
- package/templates/racing/CLAUDE.md +19 -20
- package/templates/racing/package.json +13 -7
- package/templates/racing/playtests/boost.playtest.json +33 -12
- package/templates/racing/playtests/outcome.playtest.json +32 -50
- package/templates/racing/playtests/performance.playtest.json +2 -1
- package/templates/racing/playtests/ranking.playtest.json +5 -14
- package/templates/racing/playtests/rescue.playtest.json +2 -2
- package/templates/racing/playtests/reverse.playtest.json +30 -8
- package/templates/racing/playtests/shortcut.playtest.json +54 -9
- package/templates/racing/playtests/touch-controls.playtest.json +32 -5
- package/templates/racing/src/entities/CarBody.ts +327 -0
- package/templates/racing/src/entities/LineDriver.ts +220 -0
- package/templates/racing/src/entities/RacingCar.ts +150 -89
- package/templates/racing/src/entities/Rival.ts +61 -24
- package/templates/racing/src/game.ts +5 -0
- package/templates/racing/src/render/camera.ts +49 -7
- package/templates/racing/src/render/lighting.ts +36 -37
- package/templates/racing/src/render/materials.ts +239 -19
- package/templates/racing/src/render/palette.ts +19 -21
- package/templates/racing/src/render/postprocessing.ts +12 -2
- package/templates/racing/src/render/quality.ts +43 -82
- package/templates/racing/src/render/shapes.ts +20 -6
- package/templates/racing/src/render/sky.ts +47 -39
- package/templates/racing/src/render/touch-controls.ts +1 -1
- package/templates/racing/src/render/worldEnvironment.ts +52 -1
- package/templates/racing/src/scenes/Race.ts +107 -54
- package/templates/racing/src/state.ts +2 -0
- package/templates/racing/src/track/Checkline.ts +22 -7
- package/templates/racing/src/track/Lap.ts +64 -36
- package/templates/racing/src/track/Ranking.ts +20 -11
- package/templates/racing/src/track/Track.ts +809 -361
- package/templates/racing/src/track/TrackSector.ts +40 -11
- package/templates/racing/src/track/circuit.ts +477 -0
- package/templates/racing/src/track/rescue.ts +16 -4
- package/templates/racing/threenative.config.ts +14 -1
- package/templates/racing/vite.config.ts +4 -1
- package/templates/rain/AGENTS.md +96 -0
- package/templates/rain/CLAUDE.md +98 -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 +13 -0
- package/templates/rain/native-playtests/lightning.playtest.json +173 -0
- package/templates/rain/package.json +56 -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 +22 -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 +179 -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 +114 -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/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 +226 -0
- package/templates/rain/src/render/quality.ts +135 -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/{defense → rain}/src/render/worldEnvironment.ts +52 -1
- package/templates/rain/src/scenes/Boot.ts +334 -0
- package/templates/rain/src/state.ts +257 -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 +37 -0
- package/templates/rts/.codex/config.toml +19 -0
- package/templates/rts/.cursor/mcp.json +32 -0
- package/templates/rts/.gemini/settings.json +32 -0
- package/templates/rts/.mcp.json +32 -0
- package/templates/rts/.vscode/mcp.json +36 -0
- package/templates/rts/.zed/settings.json +36 -0
- package/templates/rts/AGENTS.md +96 -0
- package/templates/rts/CLAUDE.md +98 -0
- package/templates/rts/kit.json +7 -0
- package/templates/rts/opencode.json +41 -0
- package/templates/{defense → rts}/package.json +13 -7
- package/templates/rts/playtests/performance.playtest.json +41 -0
- package/templates/rts/playtests/rts-ai-attack.playtest.json +24 -0
- package/templates/rts/playtests/rts-attack.playtest.json +75 -0
- package/templates/rts/playtests/rts-build.playtest.json +68 -0
- package/templates/rts/playtests/rts-orders.playtest.json +150 -0
- package/templates/rts/playtests/rts-train.playtest.json +62 -0
- package/templates/rts/playtests/survives.playtest.json +58 -0
- package/templates/rts/public/favicon.svg +4 -0
- package/templates/rts/src/game.ts +64 -0
- package/templates/rts/src/main.ts +15 -0
- package/templates/rts/src/orders.ts +22 -0
- package/templates/rts/src/render/army.ts +346 -0
- package/templates/rts/src/render/camera.ts +123 -0
- package/templates/rts/src/render/lighting.ts +61 -0
- package/templates/rts/src/render/loading.ts +33 -0
- package/templates/rts/src/render/materials.ts +152 -0
- package/templates/rts/src/render/models.ts +705 -0
- package/templates/rts/src/render/palette.ts +17 -0
- package/templates/rts/src/render/picking.ts +93 -0
- package/templates/rts/src/render/postprocessing.ts +46 -0
- package/templates/rts/src/render/quality.ts +128 -0
- package/templates/rts/src/render/resources.ts +141 -0
- package/templates/rts/src/render/sky.ts +44 -0
- package/templates/rts/src/render/terrain.ts +116 -0
- package/templates/rts/src/render/worldEnvironment.ts +809 -0
- package/templates/rts/src/scenes/Play.ts +650 -0
- package/templates/rts/src/sim/ai.ts +1140 -0
- package/templates/rts/src/sim/combat.ts +416 -0
- package/templates/rts/src/sim/construction.ts +374 -0
- package/templates/rts/src/sim/economy.ts +167 -0
- package/templates/rts/src/sim/game.ts +1082 -0
- package/templates/rts/src/sim/movement.ts +371 -0
- package/templates/rts/src/sim/nav.ts +276 -0
- package/templates/rts/src/sim/production.ts +180 -0
- package/templates/rts/src/sim/terrain.ts +170 -0
- package/templates/rts/src/sim/types.ts +647 -0
- package/templates/rts/src/sim/vision.ts +46 -0
- package/templates/rts/src/state.ts +100 -0
- package/templates/{defense → rts}/src/style.css +21 -8
- package/templates/rts/src/ui/App.tsx +21 -0
- package/templates/rts/src/ui/Commands.tsx +129 -0
- package/templates/rts/src/ui/GameUi.tsx +22 -0
- package/templates/rts/src/ui/Hud.tsx +165 -0
- package/templates/rts/src/ui/Minimap.tsx +84 -0
- package/templates/rts/tailwind.config.ts +2 -0
- package/templates/rts/threenative.config.ts +56 -0
- package/templates/rts/tsconfig.json +17 -0
- package/templates/{defense → rts}/vite.config.ts +4 -1
- package/templates/runner/AGENTS.md +6 -10
- package/templates/runner/CLAUDE.md +6 -10
- package/templates/runner/README.md +3 -3
- package/templates/runner/package.json +13 -7
- package/templates/runner/playtests/performance.playtest.json +2 -2
- package/templates/runner/src/conventions.ts +4 -3
- package/templates/runner/src/entities/Runner.ts +54 -7
- package/templates/runner/src/game.ts +2 -0
- package/templates/runner/src/render/camera.ts +4 -2
- package/templates/runner/src/render/dust.ts +5 -2
- package/templates/runner/src/render/lighting.ts +41 -45
- package/templates/runner/src/render/loading.ts +2 -2
- package/templates/runner/src/render/materials.ts +165 -25
- package/templates/runner/src/render/palette.ts +17 -28
- package/templates/runner/src/render/postprocessing.ts +12 -2
- package/templates/runner/src/render/quality.ts +42 -96
- package/templates/runner/src/render/shapes.ts +59 -37
- package/templates/runner/src/render/sky.ts +32 -41
- package/templates/runner/src/render/touch-controls.ts +1 -1
- package/templates/runner/src/render/worldEnvironment.ts +52 -1
- package/templates/runner/src/scenes/Run.ts +26 -6
- package/templates/runner/src/track.ts +6 -1
- package/templates/runner/threenative.config.ts +14 -1
- package/templates/runner/vite.config.ts +4 -1
- package/templates/sailing/AGENTS.md +12 -12
- package/templates/sailing/CLAUDE.md +12 -12
- package/templates/sailing/assets/ship.glb +0 -0
- package/templates/sailing/package.json +13 -7
- package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +10 -6
- package/templates/sailing/playtests/sails.playtest.json +33 -0
- package/templates/sailing/playtests/win.playtest.json +156 -8
- package/templates/sailing/src/conventions.ts +29 -2
- package/templates/sailing/src/entities/Ship.ts +381 -57
- package/templates/sailing/src/game.ts +14 -0
- package/templates/sailing/src/render/camera.ts +63 -9
- package/templates/sailing/src/render/lighting.ts +49 -27
- package/templates/sailing/src/render/materials.ts +50 -15
- package/templates/sailing/src/render/ocean.ts +647 -60
- package/templates/sailing/src/render/palette.ts +16 -12
- package/templates/sailing/src/render/postprocessing.ts +12 -2
- package/templates/sailing/src/render/props.ts +316 -442
- package/templates/sailing/src/render/quality.ts +14 -4
- package/templates/sailing/src/render/sky.ts +116 -23
- package/templates/sailing/src/render/worldEnvironment.ts +52 -1
- package/templates/sailing/src/scenes/Boot.ts +21 -0
- package/templates/sailing/src/scenes/Sailing.ts +173 -39
- package/templates/sailing/src/state.ts +6 -0
- package/templates/sailing/src/ui/Hud.tsx +41 -9
- package/templates/sailing/threenative.config.ts +14 -1
- package/templates/sailing/vite.config.ts +4 -1
- package/templates/shooter/AGENTS.md +27 -42
- package/templates/shooter/CLAUDE.md +27 -42
- package/templates/shooter/index.html +1 -0
- package/templates/shooter/package.json +13 -7
- package/templates/shooter/playtests/aim-alignment.playtest.json +58 -0
- package/templates/shooter/playtests/breakable-shatters.playtest.json +62 -0
- package/templates/shooter/playtests/bullet-holes.playtest.json +56 -0
- package/templates/shooter/playtests/camera-tracks-body-vertically.playtest.json +61 -0
- package/templates/shooter/playtests/crouch-lowers-the-eye.playtest.json +41 -0
- package/templates/shooter/playtests/death-no-snap.playtest.json +77 -0
- package/templates/shooter/playtests/debug-ads.playtest.json +58 -0
- package/templates/shooter/playtests/debug-clear.playtest.json +383 -0
- package/templates/shooter/playtests/debug-endurance.playtest.json +61 -0
- package/templates/shooter/playtests/debug-fire.playtest.json +119 -0
- package/templates/shooter/playtests/debug-restart.playtest.json +24 -0
- package/templates/shooter/playtests/enemy-body-is-a-body.playtest.json +79 -0
- package/templates/shooter/playtests/enemy-death-settles.playtest.json +64 -0
- package/templates/shooter/playtests/enemy-flinches-when-hit.playtest.json +75 -0
- package/templates/shooter/playtests/enemy-foot-contact.playtest.json +41 -0
- package/templates/shooter/playtests/enemy-material-is-not-shared.playtest.json +59 -0
- package/templates/shooter/playtests/enemy-reaches-walkway.playtest.json +80 -0
- package/templates/shooter/playtests/enemy-rifle-grip.playtest.json +101 -0
- package/templates/shooter/playtests/enemy-scale.playtest.json +56 -0
- package/templates/shooter/playtests/enemy-stops-without-snapping.playtest.json +486 -0
- package/templates/shooter/playtests/enemy-stride-matches-speed.playtest.json +198 -0
- package/templates/shooter/playtests/enemy-stride-under-crouch.playtest.json +87 -0
- package/templates/shooter/playtests/enemy-uses-crouch-clips.playtest.json +74 -0
- package/templates/shooter/playtests/five-soldiers.playtest.json +83 -0
- package/templates/shooter/playtests/flash-retires.playtest.json +62 -0
- package/templates/shooter/playtests/headshot-hits-head.playtest.json +132 -0
- package/templates/shooter/playtests/hold-to-fire.playtest.json +45 -0
- package/templates/shooter/playtests/input-control.playtest.json +43 -98
- package/templates/shooter/playtests/minimap-state.playtest.json +75 -0
- package/templates/shooter/playtests/performance.playtest.json +62 -26
- package/templates/{starter/playtests/forward.playtest.json → shooter/playtests/round-clock.playtest.json} +11 -16
- package/templates/shooter/playtests/shot-tracks-crosshair.playtest.json +79 -0
- package/templates/shooter/playtests/survives.playtest.json +36 -30
- package/templates/shooter/playtests/walkway-reachable.playtest.json +67 -0
- package/templates/shooter/src/entities/Breakables.ts +412 -0
- package/templates/shooter/src/entities/Enemy.ts +2095 -0
- package/templates/shooter/src/entities/FpsPlayer.ts +283 -0
- package/templates/shooter/src/entities/Rifle.ts +442 -0
- package/templates/shooter/src/entities/Target.ts +199 -83
- package/templates/shooter/src/entities/TouchControls.ts +276 -0
- package/templates/shooter/src/game.ts +75 -41
- package/templates/shooter/src/main.ts +0 -1
- package/templates/shooter/src/postPhysics.ts +36 -0
- package/templates/shooter/src/render/camera.ts +78 -74
- package/templates/shooter/src/render/decals.ts +142 -82
- package/templates/shooter/src/render/facade.ts +1373 -0
- package/templates/shooter/src/render/gunfx.ts +704 -0
- package/templates/shooter/src/render/lighting.ts +52 -38
- package/templates/shooter/src/render/loading.ts +2 -2
- package/templates/shooter/src/render/materials.ts +100 -88
- package/templates/shooter/src/render/occlusion.ts +108 -0
- package/templates/shooter/src/render/palette.ts +10 -10
- package/templates/shooter/src/render/palm.ts +455 -0
- package/templates/shooter/src/render/pooled-billboards.ts +144 -0
- package/templates/shooter/src/render/postprocessing.ts +15 -3
- package/templates/shooter/src/render/quality.ts +40 -82
- package/templates/shooter/src/render/scale.ts +148 -15
- package/templates/shooter/src/render/shapes.ts +138 -613
- package/templates/shooter/src/render/sky.ts +35 -35
- package/templates/shooter/src/render/town-schematic.ts +120 -0
- package/templates/shooter/src/render/town.ts +986 -0
- package/templates/shooter/src/render/townMaterials.ts +160 -0
- package/templates/shooter/src/render/vehicles.ts +741 -0
- package/templates/shooter/src/render/worldEnvironment.ts +52 -1
- package/templates/shooter/src/scenes/Play.ts +727 -650
- package/templates/shooter/src/state.ts +26 -41
- package/templates/shooter/src/style.css +207 -11
- package/templates/shooter/src/surfaces.ts +131 -0
- package/templates/shooter/src/ui/App.tsx +9 -10
- package/templates/shooter/src/ui/Crosshair.tsx +25 -18
- package/templates/shooter/src/ui/GameUi.tsx +6 -9
- package/templates/shooter/src/ui/Hud.tsx +428 -39
- package/templates/shooter/src/ui/Minimap.tsx +164 -0
- package/templates/shooter/src/ui/TouchOverlay.tsx +54 -0
- package/templates/shooter/src/ui/main.tsx +2 -3
- package/templates/shooter/threenative.config.ts +14 -1
- package/templates/shooter/vite.config.ts +4 -1
- 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 +88 -0
- package/templates/snow/CLAUDE.md +90 -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 +58 -0
- package/templates/snow/playtests/footsteps.playtest.json +95 -0
- package/templates/{defense → snow}/playtests/performance.playtest.json +4 -7
- package/templates/snow/playtests/snow-physics.playtest.json +154 -0
- package/templates/{defense → snow}/playtests/survives.playtest.json +26 -6
- 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/bootPrint.ts +50 -0
- package/templates/snow/src/render/camera.ts +84 -0
- package/templates/snow/src/render/explorer.ts +321 -0
- package/templates/snow/src/render/lighting.ts +50 -0
- package/templates/snow/src/render/loading.ts +325 -0
- package/templates/snow/src/render/materials.ts +36 -0
- package/templates/snow/src/render/palette.ts +17 -0
- package/templates/{defense → snow}/src/render/postprocessing.ts +12 -2
- package/templates/snow/src/render/props.ts +42 -0
- package/templates/{defense → snow}/src/render/quality.ts +37 -72
- package/templates/snow/src/render/scenery.ts +244 -0
- package/templates/snow/src/render/sky.ts +57 -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 +809 -0
- package/templates/{defense → snow}/src/scenes/Boot.ts +4 -4
- package/templates/snow/src/scenes/Snow.ts +635 -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 +51 -0
- package/templates/snow/tsconfig.json +17 -0
- package/templates/snow/vite.config.ts +37 -0
- package/templates/starter/AGENTS.md +17 -17
- package/templates/starter/CLAUDE.md +17 -17
- package/templates/starter/native-playtests/render-chain.playtest.json +13 -45
- package/templates/starter/package.json +13 -7
- package/templates/starter/playtests/play.playtest.json +2 -1
- package/templates/starter/playtests/survives.playtest.json +1 -1
- package/templates/starter/src/conventions.ts +6 -3
- package/templates/starter/src/entities/Goal.ts +35 -42
- package/templates/starter/src/entities/Player.ts +99 -16
- package/templates/starter/src/render/arena.ts +131 -0
- package/templates/starter/src/render/lighting.ts +27 -44
- package/templates/starter/src/render/materials.ts +164 -35
- package/templates/starter/src/render/palette.ts +16 -16
- package/templates/starter/src/render/postprocessing.ts +6 -7
- package/templates/starter/src/render/quality.ts +43 -101
- package/templates/starter/src/render/shapes.ts +1 -1
- package/templates/starter/src/render/sky.ts +39 -45
- package/templates/starter/src/render/touch-controls.ts +3 -1
- package/templates/starter/src/render/worldEnvironment.ts +52 -1
- package/templates/starter/src/scenes/Play.ts +82 -81
- package/templates/starter/threenative.config.ts +14 -1
- package/templates/starter/vite.config.ts +4 -1
- package/templates/tower-defense/.codex/config.toml +19 -0
- package/templates/tower-defense/.cursor/mcp.json +32 -0
- package/templates/tower-defense/.gemini/settings.json +32 -0
- package/templates/tower-defense/.mcp.json +32 -0
- package/templates/tower-defense/.vscode/mcp.json +36 -0
- package/templates/tower-defense/.zed/settings.json +36 -0
- package/templates/{defense → tower-defense}/AGENTS.md +14 -12
- package/templates/{defense → tower-defense}/CLAUDE.md +14 -12
- package/templates/tower-defense/README.md +16 -0
- package/templates/tower-defense/index.html +12 -0
- package/templates/tower-defense/kit.json +7 -0
- package/templates/tower-defense/opencode.json +41 -0
- package/templates/tower-defense/package.json +56 -0
- package/templates/tower-defense/playtests/arsenal.playtest.json +214 -0
- package/templates/tower-defense/playtests/defeat.playtest.json +85 -0
- package/templates/tower-defense/playtests/look.playtest.json +130 -0
- package/templates/tower-defense/playtests/performance.playtest.json +77 -0
- package/templates/tower-defense/playtests/placement.playtest.json +115 -0
- package/templates/{defense → tower-defense}/playtests/pointer-placement.playtest.json +21 -49
- package/templates/tower-defense/playtests/strike.playtest.json +98 -0
- package/templates/tower-defense/playtests/survives.playtest.json +85 -0
- package/templates/tower-defense/playtests/target-priority.playtest.json +177 -0
- package/templates/tower-defense/playtests/upgrade-recycle.playtest.json +124 -0
- package/templates/tower-defense/playtests/victory.playtest.json +810 -0
- package/templates/tower-defense/src/balance.ts +187 -0
- package/templates/tower-defense/src/board/Board.ts +100 -0
- package/templates/tower-defense/src/board/Route.ts +84 -0
- package/templates/tower-defense/src/camera-rig.ts +62 -0
- package/templates/tower-defense/src/economy.ts +64 -0
- package/templates/tower-defense/src/effects/Effects.ts +284 -0
- package/templates/tower-defense/src/enemies/Enemy.ts +198 -0
- package/templates/tower-defense/src/game.ts +72 -0
- package/templates/tower-defense/src/intents.ts +21 -0
- package/templates/tower-defense/src/main.ts +15 -0
- package/templates/tower-defense/src/physics.ts +6 -0
- package/templates/tower-defense/src/render/camera.ts +38 -0
- package/templates/tower-defense/src/render/lighting.ts +42 -0
- package/templates/{defense → tower-defense}/src/render/loading.ts +3 -3
- package/templates/tower-defense/src/render/materials.ts +103 -0
- package/templates/tower-defense/src/render/palette.ts +58 -0
- package/templates/tower-defense/src/render/postprocessing.ts +46 -0
- package/templates/tower-defense/src/render/quality.ts +128 -0
- package/templates/tower-defense/src/render/shapes.ts +550 -0
- package/templates/tower-defense/src/render/sky.ts +27 -0
- package/templates/tower-defense/src/render/worldEnvironment.ts +809 -0
- package/templates/tower-defense/src/scenes/Battle.ts +539 -0
- package/templates/{shooter → tower-defense}/src/scenes/Boot.ts +3 -3
- package/templates/tower-defense/src/state.ts +88 -0
- package/templates/tower-defense/src/style.css +137 -0
- package/templates/tower-defense/src/towers/Tower.ts +230 -0
- package/templates/tower-defense/src/towers/targeting.ts +97 -0
- package/templates/tower-defense/src/ui/Hud.tsx +270 -0
- package/templates/tower-defense/src/ui/Menu.tsx +134 -0
- package/templates/tower-defense/src/ui/icons.tsx +54 -0
- package/templates/tower-defense/src/ui/main.tsx +14 -0
- package/templates/tower-defense/src/waves.ts +90 -0
- package/templates/{defense → tower-defense}/threenative.config.ts +14 -1
- package/templates/tower-defense/vite.config.ts +41 -0
- package/agent-files/.claude/skills/file-engine-bug/SKILL.md +0 -59
- package/agent-files/.claude/skills/ponytail/SKILL.md +0 -68
- package/agent-files/.claude/skills/prd-creator/SKILL.md +0 -40
- package/agent-files/.claude/skills/threenative-assets/SKILL.md +0 -53
- package/agent-files/.claude/skills/threenative-capabilities/SKILL.md +0 -27
- package/agent-files/.claude/skills/threenative-context/SKILL.md +0 -65
- package/agent-files/.claude/skills/threenative-performance/SKILL.md +0 -58
- package/agent-files/.claude/skills/threenative-playtest/SKILL.md +0 -44
- package/agent-files/.claude/skills/threenative-ui/SKILL.md +0 -20
- package/agent-files/.claude/skills/threenative-visuals/SKILL.md +0 -41
- package/agent-files/AGENT-ROLES.md +0 -26
- package/templates/action-rpg/src/render/shapes.ts +0 -269
- package/templates/action-rpg/src/render/types.ts +0 -3
- package/templates/action-rpg/src/scenes/Boot.ts +0 -12
- package/templates/defense/README.md +0 -10
- package/templates/defense/kit.json +0 -7
- package/templates/defense/playtests/leak.playtest.json +0 -23
- package/templates/defense/playtests/placement.playtest.json +0 -40
- package/templates/defense/playtests/scan.playtest.json +0 -20
- package/templates/defense/playtests/survive.playtest.json +0 -45
- package/templates/defense/src/attackers/Attacker.ts +0 -120
- package/templates/defense/src/board/Route.ts +0 -94
- package/templates/defense/src/conventions.ts +0 -18
- package/templates/defense/src/economy.ts +0 -36
- package/templates/defense/src/entities/Player.ts +0 -52
- package/templates/defense/src/game.ts +0 -51
- package/templates/defense/src/physics.ts +0 -13
- package/templates/defense/src/placement/Buildable.ts +0 -49
- package/templates/defense/src/render/camera.ts +0 -16
- package/templates/defense/src/render/lighting.ts +0 -37
- package/templates/defense/src/render/materials.ts +0 -22
- package/templates/defense/src/render/palette.ts +0 -28
- package/templates/defense/src/render/shapes.ts +0 -246
- package/templates/defense/src/render/sky.ts +0 -45
- package/templates/defense/src/scenes/Defense.ts +0 -231
- package/templates/defense/src/state.ts +0 -56
- package/templates/defense/src/towers/Tower.ts +0 -95
- package/templates/defense/src/towers/targeting.ts +0 -53
- package/templates/defense/src/ui/Hud.tsx +0 -62
- package/templates/defense/src/ui/Menu.tsx +0 -7
- package/templates/defense/src/waves.ts +0 -40
- package/templates/minimal/playtests/atmosphere.playtest.json +0 -32
- package/templates/minimal/src/render/hud.ts +0 -69
- package/templates/platformer/playtests/avoidance.playtest.json +0 -28
- package/templates/platformer/playtests/chase.playtest.json +0 -21
- package/templates/platformer/playtests/collision-layers.playtest.json +0 -36
- package/templates/platformer/playtests/oneway.playtest.json +0 -44
- package/templates/platformer/playtests/patrol.playtest.json +0 -13
- package/templates/platformer/playtests/physics.playtest.json +0 -14
- package/templates/platformer/playtests/stomp-rise.playtest.json +0 -55
- package/templates/platformer/playtests/terminal-loop-fail.playtest.json +0 -41
- package/templates/platformer/playtests/terminal-loop-win.playtest.json +0 -52
- package/templates/platformer/src/conventions.ts +0 -18
- package/templates/platformer/src/entities/Character.ts +0 -286
- package/templates/platformer/src/entities/Chaser.ts +0 -118
- package/templates/platformer/src/entities/Patrol.ts +0 -93
- package/templates/platformer/src/level/Platform.ts +0 -46
- package/templates/platformer/src/render/rig.ts +0 -60
- package/templates/platformer/src/render/terrain.ts +0 -31
- package/templates/platformer/src/scenes/Level.ts +0 -241
- package/templates/puzzle/README.md +0 -43
- package/templates/puzzle/playtests/carry.playtest.json +0 -71
- package/templates/puzzle/playtests/swing.playtest.json +0 -38
- package/templates/puzzle/src/conventions.ts +0 -25
- package/templates/puzzle/src/entities/Ball.ts +0 -70
- package/templates/puzzle/src/entities/Gripper.ts +0 -69
- package/templates/puzzle/src/entities/Pendulum.ts +0 -89
- package/templates/puzzle/src/physics.ts +0 -19
- package/templates/puzzle/src/room.ts +0 -83
- package/templates/puzzle/src/scenes/Boot.ts +0 -12
- package/templates/puzzle/src/scenes/Puzzle.ts +0 -158
- package/templates/shooter/playtests/combat.playtest.json +0 -48
- package/templates/shooter/playtests/fail.playtest.json +0 -31
- package/templates/shooter/playtests/per-item.playtest.json +0 -59
- package/templates/shooter/playtests/shooter.playtest.json +0 -99
- package/templates/shooter/playtests/touch-controls.playtest.json +0 -42
- package/templates/shooter/playtests/weapon-cycle.playtest.json +0 -164
- package/templates/shooter/src/combat/damage.ts +0 -40
- package/templates/shooter/src/conventions.ts +0 -51
- package/templates/shooter/src/entities/Pickup.ts +0 -70
- package/templates/shooter/src/entities/Player.ts +0 -310
- package/templates/shooter/src/level/SpawnPoints.ts +0 -28
- package/templates/shooter/src/playtest-events.ts +0 -15
- package/templates/shooter/src/render/touch-controls.ts +0 -305
- package/templates/shooter/src/render/types.ts +0 -3
- package/templates/shooter/src/render/ui.css +0 -330
- package/templates/shooter/src/render/ui.ts +0 -75
- package/templates/shooter/src/render/vfx.ts +0 -215
- package/templates/shooter/src/ui/Menu.tsx +0 -41
- package/templates/shooter/src/waves.ts +0 -50
- package/templates/shooter/src/weapons/Hitscan.ts +0 -42
- package/templates/shooter/src/weapons/Projectile.ts +0 -92
- package/templates/shooter/src/weapons/Viewmodel.ts +0 -275
- package/templates/starter/playtests/assets.playtest.json +0 -65
- package/templates/starter/playtests/buffer.playtest.json +0 -79
- package/templates/starter/playtests/cloth.playtest.json +0 -113
- package/templates/starter/playtests/coyote.playtest.json +0 -87
- package/templates/starter/playtests/gameover.playtest.json +0 -66
- package/templates/starter/playtests/goal.playtest.json +0 -67
- package/templates/starter/playtests/look.playtest.json +0 -175
- package/templates/starter/playtests/models-baseline.png +0 -0
- package/templates/starter/playtests/models.playtest.json +0 -74
- package/templates/starter/playtests/monitoring.playtest.json +0 -72
- package/templates/starter/playtests/odometer.playtest.json +0 -54
- package/templates/starter/playtests/restart.playtest.json +0 -91
- package/templates/starter/playtests/seed.playtest.json +0 -54
- package/templates/starter/playtests/textures-baseline.png +0 -0
- package/templates/starter/playtests/textures.playtest.json +0 -74
- package/templates/starter/playtests/touch-controls.playtest.json +0 -42
- package/templates/starter/playtests/zoom-pinch.playtest.json +0 -86
- package/templates/starter/playtests/zoom-wheel.playtest.json +0 -59
- package/templates/starter/src/render/coast.ts +0 -199
- package/templates/starter/src/render/hero.ts +0 -88
- package/templates/starter/src/render/implicitSurface.ts +0 -199
- package/templates/starter/src/render/kuwahara.ts +0 -174
- package/templates/starter/src/render/outline.ts +0 -141
- package/templates/starter/src/render/painterly.ts +0 -86
- package/templates/starter/src/render/rockRidge.ts +0 -198
- package/templates/starter/src/render/rockRidge.worker.ts +0 -77
- package/templates/starter/src/render/scenery.ts +0 -40
- package/templates/starter/src/render/textureLifetime.ts +0 -53
- package/templates/starter/src/render/water.ts +0 -38
- package/templates/starter/src/render/watercolor.ts +0 -85
- /package/templates/{starter → puzzle}/playtests/boot-failure.playtest.json +0 -0
- /package/templates/{starter → puzzle}/playtests/pause.playtest.json +0 -0
- /package/templates/{defense → rain}/.codex/config.toml +0 -0
- /package/templates/{defense → rain}/.cursor/mcp.json +0 -0
- /package/templates/{defense → rain}/.gemini/settings.json +0 -0
- /package/templates/{defense → rain}/.mcp.json +0 -0
- /package/templates/{defense → rain}/.vscode/mcp.json +0 -0
- /package/templates/{defense → rain}/.zed/settings.json +0 -0
- /package/templates/{defense → rain}/opencode.json +0 -0
- /package/templates/{defense → rain}/src/main.ts +0 -0
- /package/templates/{defense → rts}/index.html +0 -0
- /package/templates/{defense → rts}/src/ui/main.tsx +0 -0
- /package/templates/{defense → tower-defense}/public/favicon.svg +0 -0
- /package/templates/{defense → tower-defense}/src/playtest-events.ts +0 -0
- /package/templates/{defense → tower-defense}/src/ui/App.tsx +0 -0
- /package/templates/{defense → tower-defense}/src/ui/GameUi.tsx +0 -0
- /package/templates/{defense → tower-defense}/tailwind.config.ts +0 -0
- /package/templates/{defense → tower-defense}/tsconfig.json +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Generated for you. This file owns the coast's surface decisions that are worth a name.
|
|
2
|
+
//
|
|
3
|
+
// The coast is one ray-marched shader, so its materials are colours the march reads rather than
|
|
4
|
+
// Three material objects. The ones a storm is recognised by are here; the rest of the albedos
|
|
5
|
+
// (moss, conifers, asphalt, paint) sit in `tools/tempest-world.frag` beside the shapes they colour.
|
|
6
|
+
import { Color } from "three";
|
|
7
|
+
import { palette } from "./palette.js";
|
|
8
|
+
import * as world from "./world-shader.js";
|
|
9
|
+
|
|
10
|
+
/** How bright the lamp heads burn: the study's own HDR colour, far above 1 so they bloom. */
|
|
11
|
+
const LAMP_GLOW = { b: 0.72, g: 2.75, r: 6 } as const;
|
|
12
|
+
|
|
13
|
+
export function setupMaterials(): void {
|
|
14
|
+
const lamp = new Color(palette.lamp);
|
|
15
|
+
world.uLampLight.value.set(lamp.r, lamp.g, lamp.b);
|
|
16
|
+
world.uLampGlow.value.set(LAMP_GLOW.r, LAMP_GLOW.g, LAMP_GLOW.b);
|
|
17
|
+
const water = new Color(palette.water);
|
|
18
|
+
world.uWater.value.set(water.r, water.g, water.b);
|
|
19
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Generated for you. Ordinary Three.js, and this is the storm's shape: the 64³ RGBA volume the
|
|
2
|
+
// cloud shader samples three times per step. Appearance lives here and in `tools/tempest-clouds.frag`
|
|
3
|
+
// — change the seed or the octave weights and every cloud in the storm changes with them.
|
|
4
|
+
import {
|
|
5
|
+
Data3DTexture,
|
|
6
|
+
LinearFilter,
|
|
7
|
+
NoColorSpace,
|
|
8
|
+
RGBAFormat,
|
|
9
|
+
RepeatWrapping,
|
|
10
|
+
UnsignedByteType,
|
|
11
|
+
} from "three";
|
|
12
|
+
|
|
13
|
+
/** Voxels per side. 64³ of RGBA is 1 MiB, and the source used exactly this. */
|
|
14
|
+
export const NOISE_SIZE = 64;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The source's generator seed, as `const r=rng(13291)` inside `noiseVolume`. Written here rather
|
|
18
|
+
* than taken from a caller because the sequence is this volume's identity: a different generator
|
|
19
|
+
* makes a different storm, and the engine's seeded RNG is an LCG, not this mulberry32.
|
|
20
|
+
*/
|
|
21
|
+
export const SEED = 13291;
|
|
22
|
+
|
|
23
|
+
/** `function rng(seed=1)` verbatim from the source, so a given seed draws the same stream it did. */
|
|
24
|
+
function mulberry32(seed: number): () => number {
|
|
25
|
+
let a = seed | 0;
|
|
26
|
+
return () => {
|
|
27
|
+
a += 0x6d2b79f5;
|
|
28
|
+
let t = a;
|
|
29
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
30
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
31
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface INoiseVolume {
|
|
36
|
+
/** RGBA voxels, x fastest then y then z. One byte each. */
|
|
37
|
+
readonly data: Uint8Array;
|
|
38
|
+
readonly texture: Data3DTexture;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ILattice {
|
|
42
|
+
readonly n: number;
|
|
43
|
+
readonly values: Float32Array;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The source's four octave lattices — 4³, 8³, 16³, 32³ — each one random float per voxel, all drawn
|
|
48
|
+
* from the same stream in this order. The order is the contract: it is what makes a given seed
|
|
49
|
+
* reproduce a given storm, so it is written out rather than mapped over a list.
|
|
50
|
+
*/
|
|
51
|
+
function fillLattices(random: () => number): [ILattice, ILattice, ILattice, ILattice] {
|
|
52
|
+
const lattice = (n: number): ILattice => {
|
|
53
|
+
const values = new Float32Array(n * n * n);
|
|
54
|
+
for (let index = 0; index < values.length; index += 1) values[index] = random();
|
|
55
|
+
return { n, values };
|
|
56
|
+
};
|
|
57
|
+
return [lattice(4), lattice(8), lattice(16), lattice(32)];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Trilinear value noise on one lattice, in `[0, 1)³`. Indices wrap at every face, which is what
|
|
62
|
+
* makes the volume tile, and the fractional part is smoothed by `f²(3 − 2f)` so the lattice edges
|
|
63
|
+
* do not show as creases in the cloud.
|
|
64
|
+
*/
|
|
65
|
+
function sampleLattice(lattice: ILattice, x: number, y: number, z: number): number {
|
|
66
|
+
const { n, values } = lattice;
|
|
67
|
+
const sx = x * n;
|
|
68
|
+
const sy = y * n;
|
|
69
|
+
const sz = z * n;
|
|
70
|
+
const ix = Math.floor(sx);
|
|
71
|
+
const iy = Math.floor(sy);
|
|
72
|
+
const iz = Math.floor(sz);
|
|
73
|
+
// The index is in range by construction — every component is folded into `[0, n)` above — so the
|
|
74
|
+
// cast is about the type checker, not about a value that might be missing.
|
|
75
|
+
const at = (a: number, b: number, c: number): number =>
|
|
76
|
+
values[((c % n) * n + (b % n)) * n + (a % n)] as number;
|
|
77
|
+
const lerp = (a: number, b: number, t: number): number => a + (b - a) * t;
|
|
78
|
+
const blend = (fx: number, fy: number, fz: number): number => {
|
|
79
|
+
const smooth = (f: number): number => f * f * (3 - 2 * f);
|
|
80
|
+
const tx = smooth(fx);
|
|
81
|
+
const ty = smooth(fy);
|
|
82
|
+
const tz = smooth(fz);
|
|
83
|
+
return lerp(
|
|
84
|
+
lerp(
|
|
85
|
+
lerp(at(ix, iy, iz), at(ix + 1, iy, iz), tx),
|
|
86
|
+
lerp(at(ix, iy + 1, iz), at(ix + 1, iy + 1, iz), tx),
|
|
87
|
+
ty,
|
|
88
|
+
),
|
|
89
|
+
lerp(
|
|
90
|
+
lerp(at(ix, iy, iz + 1), at(ix + 1, iy, iz + 1), tx),
|
|
91
|
+
lerp(at(ix, iy + 1, iz + 1), at(ix + 1, iy + 1, iz + 1), tx),
|
|
92
|
+
ty,
|
|
93
|
+
),
|
|
94
|
+
tz,
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
return blend(sx - ix, sy - iy, sz - iz);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Builds the volume the cloud shader samples. The four channels carry four different octave
|
|
102
|
+
* combinations, which is why the shader reads `broad` from red, its billow detail from blue and the
|
|
103
|
+
* rest as it goes: one texture, four scales, and the shader picks which mix it wants.
|
|
104
|
+
*
|
|
105
|
+
* Fails closed. The channel weights are the shader's contract — red is the broad shape the coverage
|
|
106
|
+
* threshold is measured against — so a volume of the wrong length is a bug to stop on rather than a
|
|
107
|
+
* texture to upload and watch read as transparent.
|
|
108
|
+
*/
|
|
109
|
+
export function createNoiseVolume(): INoiseVolume {
|
|
110
|
+
const random = mulberry32(SEED);
|
|
111
|
+
const [coarseLattice, mediumLattice, fineLattice, finestLattice] = fillLattices(random);
|
|
112
|
+
const data = new Uint8Array(NOISE_SIZE * NOISE_SIZE * NOISE_SIZE * 4);
|
|
113
|
+
const byte = (value: number): number => {
|
|
114
|
+
const scaled = Math.round(255 * value);
|
|
115
|
+
if (!(scaled >= 0 && scaled <= 255)) {
|
|
116
|
+
throw new Error(`TN_NOISE_CHANNEL: ${value} does not fit a byte`);
|
|
117
|
+
}
|
|
118
|
+
return scaled;
|
|
119
|
+
};
|
|
120
|
+
let cursor = 0;
|
|
121
|
+
for (let z = 0; z < NOISE_SIZE; z += 1) {
|
|
122
|
+
for (let y = 0; y < NOISE_SIZE; y += 1) {
|
|
123
|
+
for (let x = 0; x < NOISE_SIZE; x += 1) {
|
|
124
|
+
const px = x / NOISE_SIZE;
|
|
125
|
+
const py = y / NOISE_SIZE;
|
|
126
|
+
const pz = z / NOISE_SIZE;
|
|
127
|
+
const coarse = sampleLattice(coarseLattice, px, py, pz);
|
|
128
|
+
const medium = sampleLattice(mediumLattice, px, py, pz);
|
|
129
|
+
const fine = sampleLattice(fineLattice, px, py, pz);
|
|
130
|
+
const finest = sampleLattice(finestLattice, px, py, pz);
|
|
131
|
+
data[cursor] = byte(coarse * 0.74 + medium * 0.19 + fine * 0.07);
|
|
132
|
+
data[cursor + 1] = byte(medium);
|
|
133
|
+
data[cursor + 2] = byte(fine * 0.75 + finest * 0.25);
|
|
134
|
+
data[cursor + 3] = byte(finest);
|
|
135
|
+
cursor += 4;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (cursor !== data.length) {
|
|
140
|
+
throw new Error(`TN_NOISE_LENGTH: wrote ${cursor} bytes into a ${data.length}-byte volume`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const texture = new Data3DTexture(data, NOISE_SIZE, NOISE_SIZE, NOISE_SIZE);
|
|
144
|
+
texture.format = RGBAFormat;
|
|
145
|
+
texture.type = UnsignedByteType;
|
|
146
|
+
texture.minFilter = LinearFilter;
|
|
147
|
+
texture.magFilter = LinearFilter;
|
|
148
|
+
// Every face repeats: the shader drifts through the volume forever, and a clamped edge would put
|
|
149
|
+
// a hard plane across the sky where the drift ran out of volume.
|
|
150
|
+
texture.wrapS = RepeatWrapping;
|
|
151
|
+
texture.wrapT = RepeatWrapping;
|
|
152
|
+
texture.wrapR = RepeatWrapping;
|
|
153
|
+
texture.unpackAlignment = 1;
|
|
154
|
+
// The shader mixes the sampled values into its own lighting rather than reading them as colour, so
|
|
155
|
+
// there is no transfer function to undo.
|
|
156
|
+
texture.colorSpace = NoColorSpace;
|
|
157
|
+
texture.needsUpdate = true;
|
|
158
|
+
return { data, texture };
|
|
159
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated for you. These six roles are the storm's editable colour vocabulary.
|
|
2
|
+
//
|
|
3
|
+
// Hex is sRGB, as a colour picker shows it; `sky.ts` and `materials.ts` hand the shaders the linear
|
|
4
|
+
// value Three converts each to, which is the reference study's own number to within 0.002.
|
|
5
|
+
export const palette = {
|
|
6
|
+
/** Haze at the horizon: the fog the coast fades into, and the lower half of the haze. */
|
|
7
|
+
horizon: 0x6c808b,
|
|
8
|
+
/** Haze looking up, where it thins towards the deck. */
|
|
9
|
+
zenith: 0x4d5f73,
|
|
10
|
+
/** Sodium street lamps: the light they cast on the wet road. */
|
|
11
|
+
lamp: 0xffba65,
|
|
12
|
+
/** Deep sea water, before the sky is reflected in it. */
|
|
13
|
+
water: 0x1e3237,
|
|
14
|
+
/** The night behind the loading screen. */
|
|
15
|
+
night: 0x101c24,
|
|
16
|
+
/** The one accent: the interface mint, also the loading bar. */
|
|
17
|
+
accent: 0xb6d9cc,
|
|
18
|
+
} as const;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// Transcribed once by Three.js's own GLSL to TSL transpiler from tools/tempest-post.frag, and maintained
|
|
2
|
+
// here by hand since: `tools/generate-shaders.mjs` regenerates only the coast and cloud shaders.
|
|
3
|
+
// Keep the .frag in step when you change this file.
|
|
4
|
+
//
|
|
5
|
+
// The demo's filmic half in one pass: twelve animated refractive beads near the lens edges, a
|
|
6
|
+
// five-tap luma-edge antialias over the warped coordinate, the bloom added, the weather exposure,
|
|
7
|
+
// the ACES fit, the cool-shadow/warm-highlight grade, the vignette, gamma 1/2.2 and the dither.
|
|
8
|
+
// Nothing here is a framework default; every constant is the demo's.
|
|
9
|
+
import { DataTexture, Vector2, Vector3, Vector4 } from "three";
|
|
10
|
+
import {
|
|
11
|
+
Continue,
|
|
12
|
+
Fn,
|
|
13
|
+
If,
|
|
14
|
+
Loop,
|
|
15
|
+
abs,
|
|
16
|
+
add,
|
|
17
|
+
clamp,
|
|
18
|
+
depth,
|
|
19
|
+
div,
|
|
20
|
+
dot,
|
|
21
|
+
exp,
|
|
22
|
+
float,
|
|
23
|
+
floor,
|
|
24
|
+
fract,
|
|
25
|
+
frameGroup,
|
|
26
|
+
int,
|
|
27
|
+
length,
|
|
28
|
+
max,
|
|
29
|
+
min,
|
|
30
|
+
mul,
|
|
31
|
+
pow,
|
|
32
|
+
screenCoordinate,
|
|
33
|
+
select,
|
|
34
|
+
sin,
|
|
35
|
+
smoothstep,
|
|
36
|
+
sub,
|
|
37
|
+
texture,
|
|
38
|
+
uniform,
|
|
39
|
+
uv,
|
|
40
|
+
vec2,
|
|
41
|
+
vec3,
|
|
42
|
+
vec4,
|
|
43
|
+
} from "three/tsl";
|
|
44
|
+
import type { Node, TextureNode } from "three/webgpu";
|
|
45
|
+
|
|
46
|
+
// Uniforms the shader reads. Values are assigned by src/render/world.ts and src/render/clouds.ts,
|
|
47
|
+
// which own the camera basis and the weather; the generated module only holds the nodes.
|
|
48
|
+
const uScenePlaceholder = new DataTexture(new Uint8Array([0, 0, 0, 255]), 1, 1);
|
|
49
|
+
uScenePlaceholder.needsUpdate = true;
|
|
50
|
+
export let uScene: TextureNode = texture(uScenePlaceholder).setGroup(frameGroup);
|
|
51
|
+
export function setScene(value: TextureNode): void {
|
|
52
|
+
uScene = value;
|
|
53
|
+
}
|
|
54
|
+
const uBloomPlaceholder = new DataTexture(new Uint8Array([0, 0, 0, 255]), 1, 1);
|
|
55
|
+
uBloomPlaceholder.needsUpdate = true;
|
|
56
|
+
export let uBloom: TextureNode = texture(uBloomPlaceholder).setGroup(frameGroup);
|
|
57
|
+
export function setBloom(value: TextureNode): void {
|
|
58
|
+
uBloom = value;
|
|
59
|
+
}
|
|
60
|
+
export const uRes = uniform(new Vector2(), "vec2").setGroup(frameGroup);
|
|
61
|
+
export const uTime = uniform(0, "float").setGroup(frameGroup);
|
|
62
|
+
export const uExposure = uniform(0, "float").setGroup(frameGroup);
|
|
63
|
+
export const uRain = uniform(0, "float").setGroup(frameGroup);
|
|
64
|
+
export const uLens = uniform(0, "float").setGroup(frameGroup);
|
|
65
|
+
|
|
66
|
+
// Three.js Transpiler r185
|
|
67
|
+
|
|
68
|
+
// Polyfills
|
|
69
|
+
|
|
70
|
+
const gl_FragCoord = vec3(screenCoordinate.x, screenCoordinate.y.oneMinus(), depth);
|
|
71
|
+
|
|
72
|
+
export const hash = /*@__PURE__*/ Fn(([p]: [Node<"vec2">]) => {
|
|
73
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))).mul(43758.5453123));
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export const aces = /*@__PURE__*/ Fn(([x]: [Node<"vec3">]) => {
|
|
77
|
+
return clamp(x.mul(mul(2.51, x).add(0.03)).div(x.mul(mul(2.43, x).add(0.59)).add(0.14)), 0, 1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const antialias = /*@__PURE__*/ Fn(([uv]: [Node<"vec2">]) => {
|
|
81
|
+
const px = div(1, uRes).toVar();
|
|
82
|
+
const m = uScene.sample(uv).rgb.toVar();
|
|
83
|
+
const nw = uScene.sample(uv.add(vec2(-1, -1).mul(px))).rgb.toVar();
|
|
84
|
+
const ne = uScene.sample(uv.add(vec2(1, -1).mul(px))).rgb.toVar();
|
|
85
|
+
const sw = uScene.sample(uv.add(vec2(-1, 1).mul(px))).rgb.toVar();
|
|
86
|
+
const se = uScene.sample(uv.add(vec2(1, 1).mul(px))).rgb.toVar();
|
|
87
|
+
const lum = vec3(0.299, 0.587, 0.114).toVar();
|
|
88
|
+
const l0 = dot(m, lum).toVar();
|
|
89
|
+
const l1 = dot(nw, lum).toVar();
|
|
90
|
+
const l2 = dot(ne, lum).toVar();
|
|
91
|
+
const l3 = dot(sw, lum).toVar();
|
|
92
|
+
const l4 = dot(se, lum).toVar();
|
|
93
|
+
const dir = vec2(l1.add(l2).sub(l3.add(l4)).negate(), l1.add(l3).sub(l2.add(l4))).toVar();
|
|
94
|
+
const reduce = max(l1.add(l2).add(l3).add(l4).mul(0.03125), 0.0078125).toVar();
|
|
95
|
+
const rcp = div(1, min(abs(dir.x), abs(dir.y)).add(reduce)).toVar();
|
|
96
|
+
dir.assign(clamp(dir.mul(rcp), vec2(-6), vec2(6)).mul(px));
|
|
97
|
+
const a = mul(
|
|
98
|
+
0.5,
|
|
99
|
+
uScene.sample(uv.add(dir.mul(-0.166667))).rgb.add(uScene.sample(uv.add(dir.mul(0.166667))).rgb),
|
|
100
|
+
).toVar();
|
|
101
|
+
const b = a
|
|
102
|
+
.mul(0.5)
|
|
103
|
+
.add(
|
|
104
|
+
mul(
|
|
105
|
+
0.25,
|
|
106
|
+
uScene.sample(uv.sub(dir.mul(0.5))).rgb.add(uScene.sample(uv.add(dir.mul(0.5))).rgb),
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
.toVar();
|
|
110
|
+
const lb = dot(b, lum).toVar();
|
|
111
|
+
const lo = min(l0, min(min(l1, l2), min(l3, l4))).toVar();
|
|
112
|
+
const hi = max(l0, max(max(l1, l2), max(l3, l4))).toVar();
|
|
113
|
+
|
|
114
|
+
return select(lb.lessThan(lo).or(lb.greaterThan(hi)), a, b);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const tempestPost = /*@__PURE__*/ Fn(([vUv]: [Node<"vec2">]) => {
|
|
118
|
+
const uv = vUv.toVar();
|
|
119
|
+
const warp = vec2(0).toVar();
|
|
120
|
+
const dropHighlight = float(0).toVar();
|
|
121
|
+
|
|
122
|
+
// Sparse refractive beads near the lens edges, not a full-screen blur.
|
|
123
|
+
|
|
124
|
+
If(uLens.greaterThan(0.5), () => {
|
|
125
|
+
Loop({ start: int(0), end: 12 }, ({ i }) => {
|
|
126
|
+
const f = float(i).toVar();
|
|
127
|
+
const p = vec2(hash(vec2(f, 3)), hash(vec2(f, 7))).toVar();
|
|
128
|
+
p.y.assign(fract(p.y.sub(uTime.mul(add(0.008, hash(vec2(f, 11)).mul(0.01))))));
|
|
129
|
+
|
|
130
|
+
If(p.x.greaterThan(0.18).and(p.x.lessThan(0.82)), () => {
|
|
131
|
+
Continue();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const d = uv
|
|
135
|
+
.sub(p)
|
|
136
|
+
.mul(vec2(uRes.x.div(uRes.y), 1))
|
|
137
|
+
.toVar();
|
|
138
|
+
const rad = add(0.008, hash(vec2(f, 9)).mul(0.006)).toVar();
|
|
139
|
+
const dist = length(d.mul(vec2(1, 0.75))).toVar();
|
|
140
|
+
const mask = sub(1, smoothstep(rad.mul(0.7), rad, dist)).toVar();
|
|
141
|
+
warp.addAssign(d.mul(mask).mul(uRain).mul(0.5));
|
|
142
|
+
dropHighlight.addAssign(
|
|
143
|
+
pow(max(0, sub(1, abs(dist.sub(rad.mul(0.8))).div(rad.mul(0.1)))), 4)
|
|
144
|
+
.mul(0.017)
|
|
145
|
+
.mul(uRain),
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const col = antialias(clamp(uv.add(warp), 0, 1)).toVar();
|
|
151
|
+
const bloom = vec3(0).toVar();
|
|
152
|
+
const wt = float(0).toVar();
|
|
153
|
+
|
|
154
|
+
Loop({ start: int(-3), end: int(3), condition: "<=" }, ({ i }) => {
|
|
155
|
+
const w = exp(float(i.mul(i)).negate().mul(0.26)).toVar();
|
|
156
|
+
bloom.addAssign(uBloom.sample(uv.add(vec2(0, float(i).mul(3)).div(uRes))).rgb.mul(w));
|
|
157
|
+
wt.addAssign(w);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
col.addAssign(bloom.div(wt).mul(0.22));
|
|
161
|
+
col.mulAssign(uExposure);
|
|
162
|
+
col.assign(aces(col));
|
|
163
|
+
|
|
164
|
+
// Cool shadow / warm practical-light grade, retaining neutral highlights.
|
|
165
|
+
|
|
166
|
+
col.assign(pow(max(col, vec3(0)), vec3(1.015, 1, 0.975)));
|
|
167
|
+
const vign = sub(1, mul(0.28, pow(length(uv.sub(0.5).mul(vec2(1.05, 1))), 1.65))).toVar();
|
|
168
|
+
col.mulAssign(vign);
|
|
169
|
+
col.assign(pow(col, vec3(1 / 2.2)));
|
|
170
|
+
col.addAssign(
|
|
171
|
+
hash(gl_FragCoord.xy.add(floor(uTime.mul(24))))
|
|
172
|
+
.sub(0.5)
|
|
173
|
+
.mul(0.005)
|
|
174
|
+
.add(dropHighlight),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
return vec4(clamp(col, 0, 1), 1);
|
|
178
|
+
});
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// Generated for you: ordinary Three.js; ThreeNative does not read this file.
|
|
2
|
+
//
|
|
3
|
+
// This is the storm's filmic half — the demo's own `BLOOM` and `POST` passes, ported rather than
|
|
4
|
+
// approximated. `bloom-shader.ts` and `post-shader.ts` hold the maths, transpiled from
|
|
5
|
+
// `tools/tempest-bloom.frag` and `tools/tempest-post.frag`; this file owns only where those two
|
|
6
|
+
// runs and what feeds them.
|
|
7
|
+
//
|
|
8
|
+
// Every engine stage that would double a job the demo's own pass already does exactly is off:
|
|
9
|
+
// `quality.ts` decides those, and the built-in bloom is a mip pyramid rather than the demo's 5x5
|
|
10
|
+
// quarter-resolution threshold kernel. The engine's tone curve and sRGB encode are applied by the
|
|
11
|
+
// render pipeline *after* the graph, so the demo's ACES fit, its grade and its `pow(1/2.2)` would
|
|
12
|
+
// otherwise be applied twice — hence `NoToneMapping` and the working colour space below, which is
|
|
13
|
+
// what the source's own Three.js driver sets for the same reason.
|
|
14
|
+
//
|
|
15
|
+
// To change how the storm looks, edit the two `.frag` sources and run the generator. To change how
|
|
16
|
+
// much of it there is, edit `quality.ts`.
|
|
17
|
+
import {
|
|
18
|
+
type Camera,
|
|
19
|
+
DoubleSide,
|
|
20
|
+
LinearSRGBColorSpace,
|
|
21
|
+
Mesh,
|
|
22
|
+
NoToneMapping,
|
|
23
|
+
OrthographicCamera,
|
|
24
|
+
PlaneGeometry,
|
|
25
|
+
Scene,
|
|
26
|
+
} from "three";
|
|
27
|
+
import { convertToTexture, positionGeometry, uv, vec4 } from "three/tsl";
|
|
28
|
+
import { MeshBasicNodeMaterial, PassNode } from "three/webgpu";
|
|
29
|
+
import { setScene as setBloomScene, tempestBloom, uRes as uBloomRes } from "./bloom-shader.js";
|
|
30
|
+
import {
|
|
31
|
+
setBloom,
|
|
32
|
+
setScene,
|
|
33
|
+
tempestPost,
|
|
34
|
+
uExposure,
|
|
35
|
+
uLens,
|
|
36
|
+
uRain,
|
|
37
|
+
uRes,
|
|
38
|
+
uTime,
|
|
39
|
+
} from "./post-shader.js";
|
|
40
|
+
import { type QualityTier, qualityPreset, resolveQualityTier } from "./quality.js";
|
|
41
|
+
import type { ChainStage, OutputRenderer } from "./worldEnvironment.js";
|
|
42
|
+
import { WorldEnvironment } from "./worldEnvironment.js";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The bloom target's resolution, as a fraction of the frame: the demo's own
|
|
46
|
+
* `round(width / 4)`, and the reason that pass is five taps rather than a mip pyramid.
|
|
47
|
+
*/
|
|
48
|
+
const BLOOM_SCALE = 0.25;
|
|
49
|
+
|
|
50
|
+
/** What one frame's post pass needs from the game. Every value is the demo's, unconverted. */
|
|
51
|
+
export interface IStormPostFrame {
|
|
52
|
+
/** Seconds since the storm began: the bead drift and the dither's frame index. */
|
|
53
|
+
readonly elapsed: number;
|
|
54
|
+
/** Weather exposure, 0…n. The demo applies it after the bloom add, and so does this. */
|
|
55
|
+
readonly exposure: number;
|
|
56
|
+
/** Weather rain, 0…1. Bead refraction and highlight scale with it. */
|
|
57
|
+
readonly rain: number;
|
|
58
|
+
/** The demo's `lens` toggle: the refractive beads on or off. */
|
|
59
|
+
readonly droplets: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The two numbers `uRes` needs, as the renderer reports them. Read through the renderer's own
|
|
64
|
+
* `surface()` rather than the canvas, so a resolution scale or a device pixel ratio is already
|
|
65
|
+
* accounted for. Required rather than probed: `ctx.renderer` declares it, so a renderer without it
|
|
66
|
+
* is a type error here instead of a frame that is wrong.
|
|
67
|
+
*/
|
|
68
|
+
interface IRendererSurface {
|
|
69
|
+
surface(): { readonly drawingBufferWidth: number; readonly drawingBufferHeight: number };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** What a scene keeps. `update` is per frame; `dispose` releases everything built here. */
|
|
73
|
+
export interface IStormPost {
|
|
74
|
+
/** The engine chain's own report: every stage as applied or refused, with a reason. */
|
|
75
|
+
readonly applied: {
|
|
76
|
+
readonly dropped: readonly { name: string; reason: string }[];
|
|
77
|
+
readonly stages: readonly string[];
|
|
78
|
+
dispose?: () => void;
|
|
79
|
+
};
|
|
80
|
+
update(frame: IStormPostFrame): void;
|
|
81
|
+
dispose(): void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Installs the storm's post chain and returns its handle.
|
|
86
|
+
*
|
|
87
|
+
* `renderer`, `scene` and `camera` are the three the scene passes to everything else in
|
|
88
|
+
* `src/render/`. Nothing here reads the DOM, runs a second render loop, or owns a render target:
|
|
89
|
+
* the engine's render chain owns the pipeline and the scene pass, and the bloom threshold pass is
|
|
90
|
+
* a `PassNode` over a private one-quad scene, so its quarter-resolution target is sized and
|
|
91
|
+
* updated by the renderer that draws the frame.
|
|
92
|
+
*/
|
|
93
|
+
export function setupPost(
|
|
94
|
+
renderer: OutputRenderer & IRendererSurface,
|
|
95
|
+
scene: Scene,
|
|
96
|
+
camera: Camera,
|
|
97
|
+
environment: {
|
|
98
|
+
/** The renderer named a software adapter; this game's answer is its `low` tier. */
|
|
99
|
+
software?: boolean;
|
|
100
|
+
/** Forces a tier, ignoring `mobile`. An unknown name throws rather than falling back. */
|
|
101
|
+
tier?: QualityTier;
|
|
102
|
+
mobile?: boolean;
|
|
103
|
+
} = {},
|
|
104
|
+
): IStormPost {
|
|
105
|
+
const tier = resolveQualityTier({
|
|
106
|
+
mobile: environment.mobile,
|
|
107
|
+
software: environment.software,
|
|
108
|
+
tier: environment.tier,
|
|
109
|
+
});
|
|
110
|
+
const source = environment.tier === undefined ? "platform" : "override";
|
|
111
|
+
console.info(
|
|
112
|
+
`TN_QUALITY_TIER ${tier} mobile=${environment.mobile === true} software=${
|
|
113
|
+
environment.software === true
|
|
114
|
+
} source=${source}`,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// The private bloom scene: one screen quad and a camera whose projection nothing reads, which is
|
|
118
|
+
// what the demo's full-screen triangle was. The frame's own scene is never added here — the
|
|
119
|
+
// final image is an output node, not a quad in the root scene, so nothing captures itself.
|
|
120
|
+
const bloomScene = new Scene();
|
|
121
|
+
const bloomCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
122
|
+
const bloomGeometry = new PlaneGeometry(2, 2);
|
|
123
|
+
const bloomMaterial = new MeshBasicNodeMaterial();
|
|
124
|
+
bloomMaterial.side = DoubleSide;
|
|
125
|
+
bloomMaterial.vertexNode = vec4(positionGeometry.xy, 0, 1);
|
|
126
|
+
const bloomQuad = new Mesh(bloomGeometry, bloomMaterial);
|
|
127
|
+
bloomQuad.frustumCulled = false;
|
|
128
|
+
bloomScene.add(bloomQuad);
|
|
129
|
+
const bloomPass = new PassNode(PassNode.COLOR, bloomScene, bloomCamera);
|
|
130
|
+
bloomPass.setResolutionScale(BLOOM_SCALE);
|
|
131
|
+
|
|
132
|
+
let applied: IStormPost["applied"] = { dropped: [], stages: [] };
|
|
133
|
+
let disposed = false;
|
|
134
|
+
const world = new WorldEnvironment({
|
|
135
|
+
...qualityPreset(tier),
|
|
136
|
+
authoredStageNames: ["stormPost"],
|
|
137
|
+
authoredStages: () => [stormStage()],
|
|
138
|
+
});
|
|
139
|
+
applied = world.apply(renderer, scene, camera);
|
|
140
|
+
if (!applied.stages.includes("stormPost")) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`setupPost: the engine chain did not run stormPost (${applied.dropped
|
|
143
|
+
.map((entry) => `${entry.name}: ${entry.reason}`)
|
|
144
|
+
.join("; ")}). The storm's look would silently be the engine's default.`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// The demo grades and gamma-encodes inside `POST`. The pipeline would tone map and encode again,
|
|
149
|
+
// so both are switched off here — the source's own driver does the same two lines.
|
|
150
|
+
const raw = renderer.raw as { toneMapping: number; outputColorSpace: string } | undefined;
|
|
151
|
+
if (raw === undefined)
|
|
152
|
+
throw new Error("setupPost: the renderer has no raw renderer to un-tone-map.");
|
|
153
|
+
raw.toneMapping = NoToneMapping;
|
|
154
|
+
raw.outputColorSpace = LinearSRGBColorSpace;
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
get applied(): IStormPost["applied"] {
|
|
158
|
+
return applied;
|
|
159
|
+
},
|
|
160
|
+
update({ elapsed, exposure, rain, droplets }): void {
|
|
161
|
+
if (disposed) throw new Error("setupPost: update() called after dispose().");
|
|
162
|
+
// The scene pass's own texture size, read from the renderer: the kernel's offsets and the
|
|
163
|
+
// lens aspect are texel quantities, so a number that is not the input target's is a wrong
|
|
164
|
+
// picture rather than a slower one. The requested CSS size is not that number.
|
|
165
|
+
const { drawingBufferWidth: width, drawingBufferHeight: height } = renderer.surface();
|
|
166
|
+
if (
|
|
167
|
+
!Number.isFinite(width) ||
|
|
168
|
+
!Number.isFinite(height) ||
|
|
169
|
+
(width as number) < 1 ||
|
|
170
|
+
(height as number) < 1
|
|
171
|
+
) {
|
|
172
|
+
throw new Error(
|
|
173
|
+
`setupPost: the frame is ${String(width)}x${String(height)}; the post pass needs the input target's real size.`,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (![elapsed, exposure, rain].every((value) => Number.isFinite(value))) {
|
|
177
|
+
throw new Error("setupPost: elapsed, exposure and rain must all be finite numbers.");
|
|
178
|
+
}
|
|
179
|
+
uRes.value.set(width, height);
|
|
180
|
+
// The bright pass reads the full-resolution scene at two of its texels per tap, as the study
|
|
181
|
+
// did, so it needs the same size; left at zero its kernel divides by zero.
|
|
182
|
+
uBloomRes.value.set(width, height);
|
|
183
|
+
uTime.value = elapsed;
|
|
184
|
+
uExposure.value = exposure;
|
|
185
|
+
uRain.value = rain;
|
|
186
|
+
uLens.value = droplets ? 1 : 0;
|
|
187
|
+
},
|
|
188
|
+
dispose(): void {
|
|
189
|
+
if (disposed) return;
|
|
190
|
+
disposed = true;
|
|
191
|
+
applied.dispose?.();
|
|
192
|
+
bloomPass.dispose();
|
|
193
|
+
bloomGeometry.dispose();
|
|
194
|
+
bloomMaterial.dispose();
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The one authored stage: the demo's bloom and `POST`, in that order, as the last thing in the
|
|
200
|
+
* chain. It reads the chain's input — the scene pass's colour, coast, cloud, rain and lightning
|
|
201
|
+
* already composited — and returns the finished frame.
|
|
202
|
+
*/
|
|
203
|
+
function stormStage(): ChainStage {
|
|
204
|
+
return {
|
|
205
|
+
name: "stormPost",
|
|
206
|
+
// Anchored after the last built-in stage: this is the frame the player sees, so nothing may
|
|
207
|
+
// run after it. `before`/`after` is how the chain orders an authored stage at all.
|
|
208
|
+
after: "gradualBackground",
|
|
209
|
+
build: (input: unknown) => {
|
|
210
|
+
// The chain carries its own colour as `unknown`; this is the one place that becomes a node.
|
|
211
|
+
const colour = input as Parameters<typeof convertToTexture>[0];
|
|
212
|
+
// Materialised as a node in this graph, never copied out: a copied texture has no updater
|
|
213
|
+
// behind it and freezes on its first frame. The same node feeds the threshold pass and the
|
|
214
|
+
// final pass, so the bloom is computed from exactly the image the output grades.
|
|
215
|
+
const sceneTexture = convertToTexture(colour);
|
|
216
|
+
// Read inside each generated `Fn` body, so both samplers are bound before the fragment
|
|
217
|
+
// nodes are called — that call is the moment the graph is built.
|
|
218
|
+
setBloomScene(sceneTexture);
|
|
219
|
+
setScene(sceneTexture);
|
|
220
|
+
setBloom(bloomPass.getTextureNode());
|
|
221
|
+
bloomMaterial.fragmentNode = tempestBloom(uv());
|
|
222
|
+
return tempestPost(uv());
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|