create-threenative 0.2.6 → 0.2.7
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 +2 -2
- package/agent-docs/references/build-profiles.md +126 -0
- package/agent-docs/references/capability-reference.md +431 -20
- 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 +555 -21
- package/dist/index.d.ts +30 -1
- package/dist/index.js +294 -55
- package/dist/threenative.js +714 -154
- 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/rts/AGENTS.md +96 -0
- package/templates/rts/CLAUDE.md +98 -0
- package/templates/rts/kit.json +7 -0
- package/templates/{defense → rts}/package.json +13 -7
- package/templates/{defense → rts}/playtests/performance.playtest.json +28 -26
- 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/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/{defense → rts}/src/render/postprocessing.ts +15 -3
- 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/{defense → rts}/src/render/worldEnvironment.ts +52 -1
- 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/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/playtests/survives.playtest.json +0 -36
- 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/quality.ts +0 -170
- package/templates/defense/src/render/shapes.ts +0 -246
- package/templates/defense/src/render/sky.ts +0 -45
- package/templates/defense/src/scenes/Boot.ts +0 -12
- 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 → rts}/.codex/config.toml +0 -0
- /package/templates/{defense → rts}/.cursor/mcp.json +0 -0
- /package/templates/{defense → rts}/.gemini/settings.json +0 -0
- /package/templates/{defense → rts}/.mcp.json +0 -0
- /package/templates/{defense → rts}/.vscode/mcp.json +0 -0
- /package/templates/{defense → rts}/.zed/settings.json +0 -0
- /package/templates/{defense → rts}/index.html +0 -0
- /package/templates/{defense → rts}/opencode.json +0 -0
- /package/templates/{defense → rts}/src/main.ts +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,793 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ICtx,
|
|
3
|
+
type IRandom,
|
|
4
|
+
Scene,
|
|
5
|
+
type SceneFrame,
|
|
6
|
+
isMobile,
|
|
7
|
+
isTouchscreenAvailable,
|
|
8
|
+
} from "@threenative/core";
|
|
9
|
+
import { CollisionShape3D, type IPhysicsContext, RigidBody3D } from "@threenative/physics";
|
|
10
|
+
import {
|
|
11
|
+
BufferAttribute,
|
|
12
|
+
type Group,
|
|
13
|
+
type Material,
|
|
14
|
+
Mesh,
|
|
15
|
+
NearestFilter,
|
|
16
|
+
type PerspectiveCamera,
|
|
17
|
+
type Quaternion,
|
|
18
|
+
Vector3,
|
|
19
|
+
} from "three";
|
|
20
|
+
import { Crate, type CrateKind, WORLD_LAYER } from "../entities/Crate.js";
|
|
21
|
+
import { Seal } from "../entities/Seal.js";
|
|
22
|
+
import { WARDEN_SPAWN, Warden } from "../entities/Warden.js";
|
|
23
|
+
import { createVaultCamera } from "../render/camera.js";
|
|
24
|
+
import { CRATE_SIZE } from "../render/crateShape.js";
|
|
25
|
+
import { setupLighting } from "../render/lighting.js";
|
|
26
|
+
import { createLoadingScreen } from "../render/loading.js";
|
|
27
|
+
import {
|
|
28
|
+
crateBraceMaterial,
|
|
29
|
+
crateMaterials,
|
|
30
|
+
createBannerMaterial,
|
|
31
|
+
phaseCoreMaterial,
|
|
32
|
+
phaseMaterial,
|
|
33
|
+
} from "../render/materials.js";
|
|
34
|
+
import { setupPost } from "../render/postprocessing.js";
|
|
35
|
+
import { setupSky } from "../render/sky.js";
|
|
36
|
+
import { TouchControls } from "../render/touch-controls.js";
|
|
37
|
+
import { SEAL, VAULT, createVaultRoom } from "../render/vault.js";
|
|
38
|
+
import type { GameState } from "../state.js";
|
|
39
|
+
|
|
40
|
+
export type GameCtx = ICtx<GameState, IPhysicsContext>;
|
|
41
|
+
|
|
42
|
+
/** Below this linear speed a body counts as at rest. */
|
|
43
|
+
const REST_SPEED = 0.06;
|
|
44
|
+
/** Consecutive at-rest ticks before the opening drop is declared over. */
|
|
45
|
+
const REST_TICKS = 24;
|
|
46
|
+
/** How far a crate must move after the drop before it counts as shoved. */
|
|
47
|
+
const PUSH_THRESHOLD = 0.25;
|
|
48
|
+
|
|
49
|
+
/** The deterministic check: this many fixed steps, twice, on the script below. */
|
|
50
|
+
const REPLAY_TICKS = 70;
|
|
51
|
+
/**
|
|
52
|
+
* How far the two passes may disagree on any one position or rotation component and still count
|
|
53
|
+
* as the same run. Reported as `replayDrift` either way, so the number is never hidden behind the
|
|
54
|
+
* verdict: a tolerance nobody can see is a tolerance that can be widened until anything passes.
|
|
55
|
+
*/
|
|
56
|
+
const REPLAY_TOLERANCE = 1e-4;
|
|
57
|
+
/** Steps each pass is given, before it is timed, to place the warden in an otherwise empty room. */
|
|
58
|
+
const REPLAY_ARM_TICKS = 8;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The three bodies the determinism check actually runs on, and why it is three and not forty-four.
|
|
62
|
+
*
|
|
63
|
+
* A dynamic `RigidBody3D` cannot be repositioned. There is no `teleport` (the character body has
|
|
64
|
+
* one), no position setter, and `syncToPhysics()` does not write a dynamic body's transform back
|
|
65
|
+
* to the backend — measured: after a pose reset and ninety settling steps the pile was still
|
|
66
|
+
* 0.80 m from the pose it had been handed. So "put the world back and run it again" can only be
|
|
67
|
+
* done by destroying the bodies and building new ones — and *that* changes the order the backend
|
|
68
|
+
* hands out handles, which changes the simulation. Rebuilding forty-four crates has two stable
|
|
69
|
+
* outcomes that alternate: the two passes disagreed by 0.2818 m on 220 of 308 recorded components,
|
|
70
|
+
* to the same sixteen digits on every run, and swapped places when a throwaway rebuild was moved
|
|
71
|
+
* from one side to the other.
|
|
72
|
+
*
|
|
73
|
+
* So the check runs on a rig small enough to be built identically twice, in a vault emptied for
|
|
74
|
+
* the duration: the warden shoves one crate into a stack of two. It is a real character push
|
|
75
|
+
* against real contacts under the same fixed step — and it is three bodies, which is why
|
|
76
|
+
* `replayBodies` is published beside the verdict rather than left for a reader to assume.
|
|
77
|
+
*/
|
|
78
|
+
const REPLAY_RIG: readonly { readonly x: number; readonly y: number; readonly z: number }[] = [
|
|
79
|
+
{ x: 0.3, y: 0.5, z: 2.1 },
|
|
80
|
+
{ x: 2.0, y: 0.5, z: 2.1 },
|
|
81
|
+
{ x: 2.0, y: 1.45, z: 2.1 },
|
|
82
|
+
];
|
|
83
|
+
const REPLAY_START = { x: -1.1, y: 0.62, z: 2.1 } as const;
|
|
84
|
+
|
|
85
|
+
/** The scripted input both replay passes are driven by. A pure function of the tick index. */
|
|
86
|
+
function replayInput(tick: number): { readonly x: number; readonly z: number } {
|
|
87
|
+
return tick < 8 ? { x: 0, z: 0 } : { x: 1, z: 0 };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The one crate allowed in the lane: the one the warden starts against. */
|
|
91
|
+
const PUSH_CRATE_INDEX = 22;
|
|
92
|
+
|
|
93
|
+
interface ICrateAuthoring {
|
|
94
|
+
/** Which of the three crate tints this body wears. */
|
|
95
|
+
readonly colour: number;
|
|
96
|
+
readonly kind: CrateKind;
|
|
97
|
+
readonly rotationY: number;
|
|
98
|
+
readonly x: number;
|
|
99
|
+
readonly y: number;
|
|
100
|
+
readonly z: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface IPose {
|
|
104
|
+
readonly position: Vector3;
|
|
105
|
+
readonly quaternion: Quaternion;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class Play extends Scene<GameState, IPhysicsContext> {
|
|
109
|
+
#banner: Mesh | undefined;
|
|
110
|
+
#statics: RigidBody3D[] = [];
|
|
111
|
+
|
|
112
|
+
static override readonly initialState: GameState = {
|
|
113
|
+
blockedTicks: 0,
|
|
114
|
+
crates: 0,
|
|
115
|
+
odometer: 0,
|
|
116
|
+
passThroughs: 0,
|
|
117
|
+
wardenFall: 0,
|
|
118
|
+
wardenGrounded: false,
|
|
119
|
+
paused: false,
|
|
120
|
+
phaseCrates: 0,
|
|
121
|
+
playerX: WARDEN_SPAWN.x,
|
|
122
|
+
playerZ: WARDEN_SPAWN.z,
|
|
123
|
+
pushDistance: 0,
|
|
124
|
+
pushedCrates: 0,
|
|
125
|
+
replayBodies: 0,
|
|
126
|
+
replayDrift: 0,
|
|
127
|
+
replayMatch: false,
|
|
128
|
+
replayPhase: "idle",
|
|
129
|
+
replayTicks: REPLAY_TICKS,
|
|
130
|
+
seed: 6132,
|
|
131
|
+
sealContacts: 0,
|
|
132
|
+
sealedBy: "none",
|
|
133
|
+
settled: false,
|
|
134
|
+
settledCrates: 0,
|
|
135
|
+
status: "playing",
|
|
136
|
+
uiReady: false,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
override async load(ctx: GameCtx): Promise<void> {
|
|
140
|
+
// The packaged proof pair still loads, and still prints the marker the desktop asset gate
|
|
141
|
+
// greps for. In this game the triangle earns its place as the pennant on the east wall
|
|
142
|
+
// rather than as a debug object parked over the level.
|
|
143
|
+
const [texture, model] = await Promise.all([
|
|
144
|
+
ctx.assets.texture("native-proof.png"),
|
|
145
|
+
ctx.assets.model<{ scene: Group }>("native-proof.glb"),
|
|
146
|
+
]);
|
|
147
|
+
// A 16-pixel check filtered smoothly is a grey smear at banner size; nearest keeps it square.
|
|
148
|
+
texture.magFilter = NearestFilter;
|
|
149
|
+
let banner: Mesh | undefined;
|
|
150
|
+
model.scene.traverse((object) => {
|
|
151
|
+
if (!(object instanceof Mesh)) return;
|
|
152
|
+
if (banner !== undefined) throw new Error("Proof glTF must contain exactly one mesh.");
|
|
153
|
+
object.material = createBannerMaterial(texture);
|
|
154
|
+
// The packaged proof carries positions and indices only. Without UVs the sampler reads one
|
|
155
|
+
// corner texel for every fragment and it renders flat white — a loaded texture that proves
|
|
156
|
+
// nothing you can see. Plane-project the triangle, measuring each axis from the array so a
|
|
157
|
+
// quantized (KHR_mesh_quantization) build projects identically.
|
|
158
|
+
const position = object.geometry.getAttribute("position");
|
|
159
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
160
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
161
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
162
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
163
|
+
for (let index = 0; index < position.count; index += 1) {
|
|
164
|
+
minX = Math.min(minX, position.getX(index));
|
|
165
|
+
maxX = Math.max(maxX, position.getX(index));
|
|
166
|
+
minY = Math.min(minY, position.getY(index));
|
|
167
|
+
maxY = Math.max(maxY, position.getY(index));
|
|
168
|
+
}
|
|
169
|
+
const spanX = Math.max(maxX - minX, Number.EPSILON);
|
|
170
|
+
const spanY = Math.max(maxY - minY, Number.EPSILON);
|
|
171
|
+
const uv = new Float32Array(position.count * 2);
|
|
172
|
+
for (let index = 0; index < position.count; index += 1) {
|
|
173
|
+
uv[index * 2] = (position.getX(index) - minX) / spanX;
|
|
174
|
+
uv[index * 2 + 1] = (position.getY(index) - minY) / spanY;
|
|
175
|
+
}
|
|
176
|
+
object.geometry.setAttribute("uv", new BufferAttribute(uv, 2));
|
|
177
|
+
// A clone, because `ctx.add` REPARENTS what it is handed. Adding the loaded mesh itself
|
|
178
|
+
// empties `model.scene`, the asset loader hands the same cached object back on the next
|
|
179
|
+
// load, and the scene `R` rebuilds throws "did not contain a mesh" — leaving the game dead
|
|
180
|
+
// on a keypress the HUD advertises. The clone shares geometry and material, so nothing is
|
|
181
|
+
// duplicated but the node.
|
|
182
|
+
banner = object.clone();
|
|
183
|
+
});
|
|
184
|
+
if (banner === undefined) throw new Error("Proof glTF did not contain a mesh.");
|
|
185
|
+
this.#banner = banner;
|
|
186
|
+
console.info("TN_NATIVE_STARTER_ASSETS_LOADED:texture,glb");
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
override enter(ctx: GameCtx): SceneFrame<GameState, IPhysicsContext> {
|
|
190
|
+
const bannerMesh = this.#banner;
|
|
191
|
+
if (bannerMesh === undefined) throw new Error("Vault scene did not finish loading.");
|
|
192
|
+
|
|
193
|
+
// --- room ------------------------------------------------------------------------------
|
|
194
|
+
setupSky(ctx.scene);
|
|
195
|
+
const sun = setupLighting(
|
|
196
|
+
ctx.scene,
|
|
197
|
+
ctx.renderer.raw as Parameters<typeof setupLighting>[1],
|
|
198
|
+
isMobile(),
|
|
199
|
+
);
|
|
200
|
+
// isMobile() arrives as an argument because src/render/ imports no framework package: the
|
|
201
|
+
// platform decision is made here, in portable game code.
|
|
202
|
+
setupPost(ctx.renderer, ctx.scene, ctx.camera, {
|
|
203
|
+
godraysLight: sun,
|
|
204
|
+
mobile: isMobile(),
|
|
205
|
+
software: ctx.renderer.softwareAdapter !== undefined,
|
|
206
|
+
});
|
|
207
|
+
const loading = createLoadingScreen(ctx);
|
|
208
|
+
const room = createVaultRoom();
|
|
209
|
+
ctx.add(room.object);
|
|
210
|
+
ctx.entities.add("seal", room.seal);
|
|
211
|
+
// The room's solid boxes become fixed bodies here, in the scene, so `src/render/` never has
|
|
212
|
+
// to import a framework package to describe what is walkable.
|
|
213
|
+
this.#statics = room.solids.map(
|
|
214
|
+
(solid) =>
|
|
215
|
+
new RigidBody3D({
|
|
216
|
+
collisionLayer: WORLD_LAYER,
|
|
217
|
+
physics: ctx.physics,
|
|
218
|
+
position: { x: solid.x, y: solid.y, z: solid.z },
|
|
219
|
+
shape: CollisionShape3D.box(solid.width, solid.height, solid.depth),
|
|
220
|
+
type: "fixed",
|
|
221
|
+
}),
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
bannerMesh.scale.setScalar(0.24);
|
|
225
|
+
bannerMesh.position.set(VAULT.halfX - 0.1, 1.38, 2.6);
|
|
226
|
+
bannerMesh.rotation.set(0, -Math.PI / 2, 0);
|
|
227
|
+
ctx.add(bannerMesh);
|
|
228
|
+
|
|
229
|
+
const camera = createVaultCamera(ctx.camera as PerspectiveCamera);
|
|
230
|
+
camera.snap();
|
|
231
|
+
ctx.add(ctx.camera);
|
|
232
|
+
// The vault is a room the player walks around in, so a phone needs the same stick the
|
|
233
|
+
// keyboard has. `isMobile() && isTouchscreenAvailable()` is the one place that decision is
|
|
234
|
+
// made, and it is made here, in portable game code.
|
|
235
|
+
const touchControls =
|
|
236
|
+
isMobile() && isTouchscreenAvailable()
|
|
237
|
+
? ctx.entities.add("touch-controls", new TouchControls(ctx.camera as PerspectiveCamera))
|
|
238
|
+
: undefined;
|
|
239
|
+
|
|
240
|
+
// --- bodies ----------------------------------------------------------------------------
|
|
241
|
+
const authored = authorCrates(ctx.random);
|
|
242
|
+
let crates: Crate[] = [];
|
|
243
|
+
// The seal reports every body that overlaps it, and the floor slab is one of them: its top
|
|
244
|
+
// face is exactly the plane the seal plate sits on, so an area authored from y = 0 upward is
|
|
245
|
+
// *already* intersecting a fixed body on the first step and the run is won before the warden
|
|
246
|
+
// moves. Keeping the live crate bodies in a set is what makes "was that a crate" answerable
|
|
247
|
+
// without guessing from a body id.
|
|
248
|
+
const crateBodies = new Set<unknown>();
|
|
249
|
+
const clearCrates = (): void => {
|
|
250
|
+
for (const crate of crates) crate.dispose();
|
|
251
|
+
crates = [];
|
|
252
|
+
crateBodies.clear();
|
|
253
|
+
};
|
|
254
|
+
const buildCrates = (poses?: readonly IPose[]): void => {
|
|
255
|
+
clearCrates();
|
|
256
|
+
crates = authored.map((plan, index) => {
|
|
257
|
+
const pose = poses?.[index];
|
|
258
|
+
return new Crate(ctx, crateFinishes(plan), {
|
|
259
|
+
entity: `crate.${index}`,
|
|
260
|
+
kind: plan.kind,
|
|
261
|
+
quaternion: pose?.quaternion,
|
|
262
|
+
rotationY: plan.rotationY,
|
|
263
|
+
x: pose?.position.x ?? plan.x,
|
|
264
|
+
y: pose?.position.y ?? plan.y,
|
|
265
|
+
z: pose?.position.z ?? plan.z,
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
for (const crate of crates) crateBodies.add(crate.body);
|
|
269
|
+
};
|
|
270
|
+
// The vault opens when the runtime is ready — but only on the run that is still booting.
|
|
271
|
+
//
|
|
272
|
+
// The runner takes its first observation after `startup.whenReady()` resolves, which here was
|
|
273
|
+
// 3.0 s in — by which time crates built in `enter()` have already fallen, collided and gone to
|
|
274
|
+
// sleep. Every assertion about the opening drop was reported
|
|
275
|
+
// `TN_PLAYTEST_ASSERTION_TRIVIAL: already satisfied before the scenario ran`, because it was.
|
|
276
|
+
// Dropping the pile on the first observed frame makes the settle provable, and it is a better
|
|
277
|
+
// opening for a player too: the room assembles itself instead of already being over.
|
|
278
|
+
//
|
|
279
|
+
// Startup readiness is a boot milestone, not a per-scene one. On the rebuild that `R` causes
|
|
280
|
+
// it has already happened and never happens again, so a scene that waits for it a second time
|
|
281
|
+
// waits forever: pressing R left an empty vault with `crates: 0` and a warden alone in a lit
|
|
282
|
+
// room. The scenario found that; nothing else would have.
|
|
283
|
+
if (ctx.startup.progress >= 1) buildCrates();
|
|
284
|
+
else void ctx.startup.whenReady().then(() => buildCrates());
|
|
285
|
+
const solidCount = authored.filter((plan) => plan.kind === "solid").length;
|
|
286
|
+
if (solidCount < 30 || authored.length - solidCount < 1)
|
|
287
|
+
throw new Error(
|
|
288
|
+
`The vault needs at least 30 solid bodies and one the warden walks through; this layout has ${solidCount} and ${authored.length - solidCount}.`,
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
const warden = ctx.entities.add("player", new Warden(ctx));
|
|
292
|
+
const seal = ctx.entities.add("seal.area", new Seal(ctx, room.seal));
|
|
293
|
+
|
|
294
|
+
// --- the run's own bookkeeping ----------------------------------------------------------
|
|
295
|
+
let status: GameState["status"] = "playing";
|
|
296
|
+
let sealedBy: GameState["sealedBy"] = "none";
|
|
297
|
+
let passThroughs = 0;
|
|
298
|
+
let insidePhaseWall = false;
|
|
299
|
+
let settled = false;
|
|
300
|
+
let restTicks = 0;
|
|
301
|
+
let replayPhase: GameState["replayPhase"] = "idle";
|
|
302
|
+
let replayMatch = false;
|
|
303
|
+
let replayTick = 0;
|
|
304
|
+
let replayDigest: readonly number[] = [];
|
|
305
|
+
let replayDrift = 0;
|
|
306
|
+
let armTicks = 0;
|
|
307
|
+
/**
|
|
308
|
+
* Both passes start from the poses the opening drop left, not from the authored heights.
|
|
309
|
+
*
|
|
310
|
+
* Re-dropping forty-four crates is a chaotic opening: a difference of one ULP in the order the
|
|
311
|
+
* backend resolves two contacts becomes centimetres by the time the pile settles, and the
|
|
312
|
+
* check then measures the backend's allocator rather than the game's determinism. Starting
|
|
313
|
+
* both passes from the same *settled* pile keeps the thing under test — the warden's scripted
|
|
314
|
+
* shove — and drops the amplifier.
|
|
315
|
+
*/
|
|
316
|
+
let snapshot: readonly IPose[] = [];
|
|
317
|
+
let wardenSnapshot = new Vector3(WARDEN_SPAWN.x, WARDEN_SPAWN.y, WARDEN_SPAWN.z);
|
|
318
|
+
/** V pressed before the opening drop finished: honoured as soon as it has. */
|
|
319
|
+
let replayRequested = false;
|
|
320
|
+
|
|
321
|
+
const unwatch = seal.watch({
|
|
322
|
+
isCrate: (body) => crateBodies.has(body),
|
|
323
|
+
onContact: (by) => {
|
|
324
|
+
// The seal is switched off for the duration of the replay, so anything that reaches it
|
|
325
|
+
// here reached it in the run the player is actually playing.
|
|
326
|
+
if (status === "won") return;
|
|
327
|
+
status = "won";
|
|
328
|
+
sealedBy = by;
|
|
329
|
+
room.setSealLit(true);
|
|
330
|
+
ctx.state.set({ sealedBy: by, status: "won" });
|
|
331
|
+
ctx.state.flush();
|
|
332
|
+
},
|
|
333
|
+
warden: warden.body,
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
const phaseWall = phaseWallBounds();
|
|
337
|
+
/** Seven numbers per rig body — position then rotation — plus the warden's, in build order. */
|
|
338
|
+
const digest = (): readonly number[] => {
|
|
339
|
+
const values: number[] = [];
|
|
340
|
+
const p = warden.mesh.position;
|
|
341
|
+
values.push(p.x, p.y, p.z);
|
|
342
|
+
for (const crate of rig) {
|
|
343
|
+
const p = crate.mesh.position;
|
|
344
|
+
const q = crate.mesh.quaternion;
|
|
345
|
+
values.push(p.x, p.y, p.z, q.x, q.y, q.z, q.w);
|
|
346
|
+
}
|
|
347
|
+
return values;
|
|
348
|
+
};
|
|
349
|
+
/** The largest single component the two passes disagree on. Zero is bit-identical. */
|
|
350
|
+
const drift = (a: readonly number[], b: readonly number[]): number => {
|
|
351
|
+
if (a.length !== b.length || a.length === 0) return Number.POSITIVE_INFINITY;
|
|
352
|
+
let worst = 0;
|
|
353
|
+
for (let index = 0; index < a.length; index += 1)
|
|
354
|
+
worst = Math.max(worst, Math.abs((a[index] as number) - (b[index] as number)));
|
|
355
|
+
return worst;
|
|
356
|
+
};
|
|
357
|
+
const capture = (): readonly IPose[] =>
|
|
358
|
+
crates.map((crate) => ({
|
|
359
|
+
position: crate.mesh.position.clone(),
|
|
360
|
+
quaternion: crate.mesh.quaternion.clone(),
|
|
361
|
+
}));
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Clear the vault, put the warden back, and give the solver a few steps to place it before a
|
|
365
|
+
* single crate exists.
|
|
366
|
+
*
|
|
367
|
+
* `teleport` is queued for the bulk step like every other motion, so a pass that begins on the
|
|
368
|
+
* same frame as the teleport begins with the warden still at its *previous* position for one
|
|
369
|
+
* step. Pass one's previous position was the spawn it was already standing on; pass two's was
|
|
370
|
+
* wherever pass one ended. Arming both passes the same way is what makes them comparable.
|
|
371
|
+
*/
|
|
372
|
+
let rig: Crate[] = [];
|
|
373
|
+
const clearRig = (): void => {
|
|
374
|
+
for (const crate of rig) crate.dispose();
|
|
375
|
+
rig = [];
|
|
376
|
+
};
|
|
377
|
+
const buildRig = (): void => {
|
|
378
|
+
clearRig();
|
|
379
|
+
rig = REPLAY_RIG.map(
|
|
380
|
+
(pose, index) =>
|
|
381
|
+
new Crate(ctx, crateFinishes({ colour: 2, kind: "solid" }), {
|
|
382
|
+
entity: `rig.${index}`,
|
|
383
|
+
kind: "solid",
|
|
384
|
+
rotationY: 0,
|
|
385
|
+
x: pose.x,
|
|
386
|
+
y: pose.y,
|
|
387
|
+
z: pose.z,
|
|
388
|
+
}),
|
|
389
|
+
);
|
|
390
|
+
};
|
|
391
|
+
const startReplayPass = (phase: "first" | "second"): void => {
|
|
392
|
+
buildRig();
|
|
393
|
+
warden.teleport(REPLAY_START);
|
|
394
|
+
replayPhase = phase;
|
|
395
|
+
replayTick = 0;
|
|
396
|
+
armTicks = REPLAY_ARM_TICKS;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
ctx.state.set({ ...Play.initialState, replayTicks: REPLAY_TICKS, status });
|
|
400
|
+
|
|
401
|
+
const frameState: Partial<GameState> = {};
|
|
402
|
+
|
|
403
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: the frame is the vault's whole
|
|
404
|
+
// per-tick bookkeeping — the two replay passes, the settle test, the push tally and the state
|
|
405
|
+
// flush — and splitting it would move the wiring between three closures that all share it.
|
|
406
|
+
return (frame, dt) => {
|
|
407
|
+
loading.update();
|
|
408
|
+
if (frame.input.justPressed("restart")) {
|
|
409
|
+
frame.state.set(Play.initialState);
|
|
410
|
+
frame.state.flush();
|
|
411
|
+
void frame.goto("play");
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// --- the deterministic double run -----------------------------------------------------
|
|
416
|
+
if (replayPhase === "first" || replayPhase === "second") {
|
|
417
|
+
if (armTicks > 0) {
|
|
418
|
+
armTicks -= 1;
|
|
419
|
+
warden.update(dt, { x: 0, z: 0 });
|
|
420
|
+
camera.follow(warden.mesh.position, dt);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
// The pass ends at the TOP of a frame, before anything is queued for the solver.
|
|
424
|
+
//
|
|
425
|
+
// Ending it at the bottom made the two passes different shapes: pass one began on a frame
|
|
426
|
+
// that ran no character step, and pass two began on a frame that had already queued one
|
|
427
|
+
// from the end of pass one. That single extra queued step, resolved against the freshly
|
|
428
|
+
// rebuilt pile, was 0.28 m of divergence in a check whose entire job is to report zero.
|
|
429
|
+
if (replayTick >= REPLAY_TICKS) {
|
|
430
|
+
if (replayPhase === "first") {
|
|
431
|
+
replayDigest = digest();
|
|
432
|
+
// One extra build-and-discard, so pass two's three bodies are an EVEN number of
|
|
433
|
+
// allocate/free cycles after pass one's. Consecutive rebuilds alternate.
|
|
434
|
+
buildRig();
|
|
435
|
+
startReplayPass("second");
|
|
436
|
+
} else {
|
|
437
|
+
const second = digest();
|
|
438
|
+
replayDrift = drift(second, replayDigest);
|
|
439
|
+
// The marker carries the shape of the comparison, not just its verdict: how many
|
|
440
|
+
// numbers were compared and how many of them disagreed at all.
|
|
441
|
+
let differing = 0;
|
|
442
|
+
for (let index = 0; index < second.length; index += 1)
|
|
443
|
+
if (Math.abs((second[index] as number) - (replayDigest[index] ?? 0)) > 1e-9)
|
|
444
|
+
differing += 1;
|
|
445
|
+
console.info(
|
|
446
|
+
`WV_REPLAY bodies=${rig.length} components=${second.length} differing=${differing} drift=${replayDrift}`,
|
|
447
|
+
);
|
|
448
|
+
// A tolerance, not equality. Reported beside the verdict so a reader can see whether
|
|
449
|
+
// the two passes agreed to the last bit or merely to a millimetre.
|
|
450
|
+
replayMatch = replayDrift <= REPLAY_TOLERANCE;
|
|
451
|
+
replayPhase = "done";
|
|
452
|
+
// Put the vault back exactly as the player left it, then let the seal watch again.
|
|
453
|
+
clearRig();
|
|
454
|
+
buildCrates(snapshot);
|
|
455
|
+
warden.teleport(wardenSnapshot);
|
|
456
|
+
seal.area.monitoring = true;
|
|
457
|
+
frame.state.set({ replayBodies: rig.length, replayDrift, replayMatch, replayPhase });
|
|
458
|
+
frame.state.flush();
|
|
459
|
+
}
|
|
460
|
+
camera.follow(warden.mesh.position, dt);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
warden.update(dt, replayInput(replayTick));
|
|
464
|
+
replayTick += 1;
|
|
465
|
+
camera.follow(warden.mesh.position, dt);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (frame.input.justPressed("verify")) replayRequested = true;
|
|
470
|
+
if (replayRequested && replayPhase === "idle" && settled) {
|
|
471
|
+
replayRequested = false;
|
|
472
|
+
snapshot = capture();
|
|
473
|
+
|
|
474
|
+
wardenSnapshot = warden.mesh.position.clone();
|
|
475
|
+
// Nothing that happens during the two passes may end the run.
|
|
476
|
+
seal.area.monitoring = false;
|
|
477
|
+
// Empty the vault, then build and discard one rig, so that BOTH passes allocate their
|
|
478
|
+
// three bodies from a free list of exactly three rather than pass one from a free list of
|
|
479
|
+
// forty-four. Two consecutive rebuilds do not otherwise get the same handles.
|
|
480
|
+
clearCrates();
|
|
481
|
+
buildRig();
|
|
482
|
+
startReplayPass("first");
|
|
483
|
+
frame.state.set({ replayPhase: "first" });
|
|
484
|
+
frame.state.flush();
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// --- ordinary play --------------------------------------------------------------------
|
|
489
|
+
const touch = touchControls?.update(frame.input.raw.pointers, frame.viewport.size);
|
|
490
|
+
const move = touch?.move ?? frame.input.vector("move");
|
|
491
|
+
// `input.vector("move").y` is +up on the screen, which is -Z in the world. The thumbstick
|
|
492
|
+
// reports the same convention, so the one conversion covers both.
|
|
493
|
+
warden.update(dt, { x: move.x, z: -move.y });
|
|
494
|
+
camera.follow(warden.mesh.position, dt);
|
|
495
|
+
|
|
496
|
+
let atRest = 0;
|
|
497
|
+
let pushed = 0;
|
|
498
|
+
let pushDistance = 0;
|
|
499
|
+
let solid = 0;
|
|
500
|
+
let phase = 0;
|
|
501
|
+
for (const crate of crates) {
|
|
502
|
+
if (crate.kind === "phase") phase += 1;
|
|
503
|
+
else solid += 1;
|
|
504
|
+
if (crate.speed < REST_SPEED) atRest += 1;
|
|
505
|
+
if (settled && crate.kind === "solid") {
|
|
506
|
+
const moved = crate.displacement();
|
|
507
|
+
if (moved > PUSH_THRESHOLD) pushed += 1;
|
|
508
|
+
pushDistance = Math.max(pushDistance, moved);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (!settled && crates.length > 0) {
|
|
512
|
+
restTicks = atRest === crates.length ? restTicks + 1 : 0;
|
|
513
|
+
if (restTicks >= REST_TICKS) {
|
|
514
|
+
settled = true;
|
|
515
|
+
for (const crate of crates) crate.markRest();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Pass-through is counted as an event, not a frame: the warden's capsule centre entering
|
|
520
|
+
// the glowing wall's volume once is one pass, however long it stands inside it.
|
|
521
|
+
const inside =
|
|
522
|
+
warden.mesh.position.x > phaseWall.minX &&
|
|
523
|
+
warden.mesh.position.x < phaseWall.maxX &&
|
|
524
|
+
warden.mesh.position.z > phaseWall.minZ &&
|
|
525
|
+
warden.mesh.position.z < phaseWall.maxZ;
|
|
526
|
+
if (inside && !insidePhaseWall) passThroughs += 1;
|
|
527
|
+
insidePhaseWall = inside;
|
|
528
|
+
|
|
529
|
+
// Counted from the live array rather than published once from the authoring plan: the
|
|
530
|
+
// vault does not contain 38 crates until it has dropped them, and a number that is right
|
|
531
|
+
// before the thing it describes exists is a number no scenario can prove anything with.
|
|
532
|
+
frameState.crates = solid;
|
|
533
|
+
frameState.phaseCrates = phase;
|
|
534
|
+
frameState.blockedTicks = warden.blockedTicks;
|
|
535
|
+
frameState.odometer = warden.odometer;
|
|
536
|
+
frameState.wardenFall = warden.fallSpeed;
|
|
537
|
+
frameState.wardenGrounded = warden.grounded;
|
|
538
|
+
frameState.passThroughs = passThroughs;
|
|
539
|
+
frameState.playerX = warden.mesh.position.x;
|
|
540
|
+
frameState.playerZ = warden.mesh.position.z;
|
|
541
|
+
frameState.pushDistance = pushDistance;
|
|
542
|
+
frameState.pushedCrates = pushed;
|
|
543
|
+
frameState.sealContacts = seal.contacts;
|
|
544
|
+
frameState.sealedBy = sealedBy;
|
|
545
|
+
frameState.settled = settled;
|
|
546
|
+
frameState.settledCrates = atRest;
|
|
547
|
+
frameState.status = status;
|
|
548
|
+
frame.state.set(frameState);
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
override exit(ctx: GameCtx): void {
|
|
553
|
+
for (const body of this.#statics) body.dispose();
|
|
554
|
+
this.#statics = [];
|
|
555
|
+
super.exit(ctx);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* The two finishes a crate is built from: its own face, and the battens nailed across it.
|
|
561
|
+
*
|
|
562
|
+
* A solid crate wears one of the three tints cycled across the pile — forty bodies in one colour
|
|
563
|
+
* are forty of the same thing — while a phase crate swaps the pair outright: it is the one body a
|
|
564
|
+
* capsule does not collide with, and its glass shell is the only thing that says so before the
|
|
565
|
+
* player tries.
|
|
566
|
+
*/
|
|
567
|
+
function crateFinishes(plan: Pick<ICrateAuthoring, "colour" | "kind">): readonly Material[] {
|
|
568
|
+
if (plan.kind === "phase") return [phaseMaterial, phaseCoreMaterial];
|
|
569
|
+
const tint = crateMaterials[plan.colour % crateMaterials.length];
|
|
570
|
+
if (tint === undefined) throw new Error("Crate colour index fell outside the palette.");
|
|
571
|
+
return [tint, crateBraceMaterial];
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/** The glowing ward's footprint, used to count the warden walking through it. */
|
|
575
|
+
function phaseWallBounds(): {
|
|
576
|
+
readonly maxX: number;
|
|
577
|
+
readonly maxZ: number;
|
|
578
|
+
readonly minX: number;
|
|
579
|
+
readonly minZ: number;
|
|
580
|
+
} {
|
|
581
|
+
return { maxX: 5.5, maxZ: 0.85 + CRATE_SIZE / 2, minX: 2.69, minZ: 0.85 - CRATE_SIZE / 2 };
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Where every body starts, drawn from the seeded source so two loads of seed 6132 build the same
|
|
586
|
+
* vault. Nothing is authored at its resting height: the whole field is dropped a few centimetres
|
|
587
|
+
* so the opening seconds are a real settle, and three of them are authored off-balance so
|
|
588
|
+
* something visibly topples while it happens.
|
|
589
|
+
*
|
|
590
|
+
* Two lanes are deliberately empty. The warden's spawn row (z about 3.0) is clear all the way
|
|
591
|
+
* east, and the approach to the seal carries nothing solid — the only thing standing in it is the
|
|
592
|
+
* glowing ward, which is the one wall the warden can walk through.
|
|
593
|
+
*/
|
|
594
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: the layout is one table of authored
|
|
595
|
+
// positions, and each of its four groups is a loop that pushes a plan; the invariants below are what
|
|
596
|
+
// read it, so the table stays in one place.
|
|
597
|
+
function authorCrates(random: IRandom): readonly ICrateAuthoring[] {
|
|
598
|
+
const plans: ICrateAuthoring[] = [];
|
|
599
|
+
// A seeded rotation through the three tints rather than three independent draws. Random draws
|
|
600
|
+
// clumped: one load came up amber-heavy on the whole east half of the pile, which reads as a
|
|
601
|
+
// palette with two colours in it rather than three.
|
|
602
|
+
const start = Math.floor(random.range(0, 2.999));
|
|
603
|
+
let drawn = 0;
|
|
604
|
+
const colour = (): number => (start + drawn++) % 3;
|
|
605
|
+
const jitter = (amount: number): number => random.range(-amount, amount);
|
|
606
|
+
|
|
607
|
+
// The pile: four columns, two deep, three high, in the middle of the room.
|
|
608
|
+
for (let column = 0; column < 4; column += 1) {
|
|
609
|
+
for (let row = 0; row < 2; row += 1) {
|
|
610
|
+
for (let level = 0; level < 3; level += 1) {
|
|
611
|
+
// Two gaps knocked out of the top course. A four-by-three block with every cell filled
|
|
612
|
+
// reads as a wall, and the silhouette is most of what makes a pile look like a pile.
|
|
613
|
+
if (level === 2 && ((column === 3 && row === 0) || (column === 0 && row === 1))) continue;
|
|
614
|
+
plans.push({
|
|
615
|
+
colour: colour(),
|
|
616
|
+
kind: "solid",
|
|
617
|
+
rotationY: jitter(0.05),
|
|
618
|
+
x: -2.55 + column * 0.95 + jitter(0.03),
|
|
619
|
+
y: 0.5 + level * 0.95,
|
|
620
|
+
z: -1.45 + row * 0.95 + jitter(0.03),
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// The crate the warden is already leaning on when the vault opens. It is directly in the lane,
|
|
627
|
+
// so the first press of ArrowRight shoves it — which is the mechanic, not decoration.
|
|
628
|
+
// Half a crate off the warden's centre line, which is the whole difference between shoving a
|
|
629
|
+
// crate aside and carrying it the length of the room. Head-on, the character controller pushed
|
|
630
|
+
// it the entire crossing and covered 6.8 m of a 9.5 m lane in the time a proof allows; offset,
|
|
631
|
+
// the first contact deflects it north and the warden walks on. It is still the first thing the
|
|
632
|
+
// player touches, and it is still what the reference picture shows.
|
|
633
|
+
plans.push({
|
|
634
|
+
colour: colour(),
|
|
635
|
+
kind: "solid",
|
|
636
|
+
rotationY: jitter(0.1),
|
|
637
|
+
x: -2.9,
|
|
638
|
+
y: 0.5,
|
|
639
|
+
z: WARDEN_SPAWN.z - 0.44,
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
// Singles around the room, clear of the seal's footprint.
|
|
643
|
+
// The warden's lane runs the length of the room at z = 2.0, and the three crates nearest it are
|
|
644
|
+
// held to a sixth of a radian: a crate yawed half a radian has a 0.62 m footprint half-extent
|
|
645
|
+
// rather than 0.46, and three of those turned the crossing into a bulldoze that stalled the
|
|
646
|
+
// warden five metres short of the seal.
|
|
647
|
+
// The four crates nearest the aisle are held to a sixth of a radian: a crate yawed half a
|
|
648
|
+
// radian has a 0.62 m footprint half-extent rather than 0.46, and the lane check has to leave
|
|
649
|
+
// room for the worst case of every crate in the room.
|
|
650
|
+
// The four crates nearest the aisle are held to a sixth of a radian: a crate yawed half a
|
|
651
|
+
// radian has a 0.62 m footprint half-extent rather than 0.46, and the lane check has to leave
|
|
652
|
+
// room for the worst case of every crate in the room.
|
|
653
|
+
const laneAdjacent = new Set([9, 10, 11, 13]);
|
|
654
|
+
const singles: readonly (readonly [number, number])[] = [
|
|
655
|
+
[-4.5, -2.6],
|
|
656
|
+
[-3.5, -0.4],
|
|
657
|
+
[-0.9, 0.6],
|
|
658
|
+
[-4.3, 0.9],
|
|
659
|
+
[1.4, -2.7],
|
|
660
|
+
[-0.3, -3.1],
|
|
661
|
+
[1.25, -3.4],
|
|
662
|
+
[-5.0, -1.6],
|
|
663
|
+
[1.9, 0.45],
|
|
664
|
+
[-4.6, 1.1],
|
|
665
|
+
[-1.3, 1.15],
|
|
666
|
+
[1.3, 1.1],
|
|
667
|
+
[-2.6, -3.3],
|
|
668
|
+
[0.4, 1.1],
|
|
669
|
+
[3.0, -0.3],
|
|
670
|
+
];
|
|
671
|
+
for (const [index, [x, z]] of singles.entries())
|
|
672
|
+
plans.push({
|
|
673
|
+
colour: colour(),
|
|
674
|
+
kind: "solid",
|
|
675
|
+
rotationY: laneAdjacent.has(index) ? random.range(-0.16, 0.16) : random.range(-0.5, 0.5),
|
|
676
|
+
x: x + jitter(0.05),
|
|
677
|
+
y: 0.52,
|
|
678
|
+
z: z + jitter(0.05),
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
// Three off-balance crates: authored above and beside a neighbour so the drop tips them over.
|
|
682
|
+
const topplers: readonly (readonly [number, number, number])[] = [
|
|
683
|
+
[-2.0, 1.55, 0.55],
|
|
684
|
+
[0.5, 1.5, -2.9],
|
|
685
|
+
[0.55, 2.45, -1.3],
|
|
686
|
+
];
|
|
687
|
+
for (const [x, y, z] of topplers)
|
|
688
|
+
plans.push({ colour: colour(), kind: "solid", rotationY: random.range(0.3, 0.45), x, y, z });
|
|
689
|
+
|
|
690
|
+
// The ward: three wide, two high, standing across the seal's approach. Every route from the
|
|
691
|
+
// warden's lane to the seal goes through it, and none of it stops the warden.
|
|
692
|
+
for (let column = 0; column < 3; column += 1)
|
|
693
|
+
plans.push({
|
|
694
|
+
colour: 0,
|
|
695
|
+
kind: "phase",
|
|
696
|
+
rotationY: 0,
|
|
697
|
+
x: 3.15 + column * 0.94,
|
|
698
|
+
y: 0.5,
|
|
699
|
+
z: 0.85,
|
|
700
|
+
});
|
|
701
|
+
plans.push({ colour: 0, kind: "phase", rotationY: 0, x: 4.09, y: 1.44, z: 0.85 });
|
|
702
|
+
|
|
703
|
+
assertClearOfSeal(plans);
|
|
704
|
+
assertLaneClear(plans);
|
|
705
|
+
assertClearOfWard(plans);
|
|
706
|
+
return plans;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/** The ward's footprint, so nothing solid is authored inside a body it cannot collide with. */
|
|
710
|
+
const WARD = { centreX: 4.09, centreZ: 0.85, halfX: 1.41, halfZ: 0.46 } as const;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Refuses a layout with a solid crate standing inside the ward.
|
|
714
|
+
*
|
|
715
|
+
* The ward is transparent to every movable body, which is what stops a shoved crate wedging
|
|
716
|
+
* against it and dead-ending the level. The cost is that a crate authored on top of it simply
|
|
717
|
+
* interpenetrates, and on the first screen that does not read as a ghost — it reads as two boxes
|
|
718
|
+
* clipping through each other. A crate *pushed* into it is fine and is the point; a crate that
|
|
719
|
+
* starts there is a mistake.
|
|
720
|
+
*/
|
|
721
|
+
function assertClearOfWard(plans: readonly ICrateAuthoring[]): void {
|
|
722
|
+
for (const [index, plan] of plans.entries()) {
|
|
723
|
+
if (plan.kind === "phase") continue;
|
|
724
|
+
const reach = footprint(plan.rotationY);
|
|
725
|
+
if (
|
|
726
|
+
Math.abs(plan.x - WARD.centreX) < WARD.halfX + reach &&
|
|
727
|
+
Math.abs(plan.z - WARD.centreZ) < WARD.halfZ + reach
|
|
728
|
+
)
|
|
729
|
+
throw new Error(
|
|
730
|
+
`Crate ${index} is authored inside the ward at (${plan.x.toFixed(2)}, ${plan.z.toFixed(2)}). The ward collides with nothing movable, so it would clip through it on the first frame.`,
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/** The strip the warden crosses. Nothing but the crate it starts against may stand in it. */
|
|
736
|
+
/**
|
|
737
|
+
* The aisle along the front of the vault, and why it is where it is.
|
|
738
|
+
*
|
|
739
|
+
* The near wall is 1.9 m of stone between the camera and the front of the room, and at this
|
|
740
|
+
* elevation it hides everything within about 1.3 m of it: the warden spawned at z 3.15 and only
|
|
741
|
+
* the top of its head cleared the rail. Anything the player has to see stands at z 2.4 or less.
|
|
742
|
+
*/
|
|
743
|
+
export const LANE = { halfWidth: 0.5, z: WARDEN_SPAWN.z } as const;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Refuses a layout that blocks the crossing.
|
|
747
|
+
*
|
|
748
|
+
* The route from the spawn to the seal is the only route the game guarantees, and it turned out to
|
|
749
|
+
* be a hostage to the seeded jitter: adding two decorative crates changed how many numbers the
|
|
750
|
+
* authoring drew from `ctx.random`, every later rotation shifted, and two crates that had been
|
|
751
|
+
* clear of the lane by centimetres moved into it. The warden then bulldozed instead of walking and
|
|
752
|
+
* stopped six metres short of the seal — a level that had been finishable for six runs became
|
|
753
|
+
* unfinishable because of two crates placed nowhere near the lane.
|
|
754
|
+
*
|
|
755
|
+
* So the lane is an invariant with a check, not an intention with a comment.
|
|
756
|
+
*/
|
|
757
|
+
function assertLaneClear(plans: readonly ICrateAuthoring[]): void {
|
|
758
|
+
for (const [index, plan] of plans.entries()) {
|
|
759
|
+
if (index === PUSH_CRATE_INDEX) continue;
|
|
760
|
+
const reach = footprint(plan.rotationY);
|
|
761
|
+
if (Math.abs(plan.z - LANE.z) < LANE.halfWidth + reach)
|
|
762
|
+
throw new Error(
|
|
763
|
+
`Crate ${index} stands in the warden's lane: z ${plan.z.toFixed(2)} with a ${reach.toFixed(2)} m footprint is inside ${(LANE.z - LANE.halfWidth).toFixed(2)}..${(LANE.z + LANE.halfWidth).toFixed(2)}. The crossing to the seal is the only route this level guarantees.`,
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/** Half-extent of a crate's footprint along either axis once it is yawed. */
|
|
769
|
+
function footprint(rotationY: number): number {
|
|
770
|
+
return (CRATE_SIZE / 2) * (Math.abs(Math.cos(rotationY)) + Math.abs(Math.sin(rotationY)));
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Refuses a layout in which any authored crate already overlaps the seal.
|
|
775
|
+
*
|
|
776
|
+
* This is not defensive tidiness — it is the third time this exact bug shipped. A crate authored
|
|
777
|
+
* with up to half a radian of yaw has a footprint half-extent of 0.46 * (|cos| + |sin|), which is
|
|
778
|
+
* 0.62 m, not 0.46 m; three separate singles cleared the seal on paper and clipped it by a
|
|
779
|
+
* centimetre or two in the world, and the run reported `won` on the opening drop with the warden
|
|
780
|
+
* still standing at its spawn. Reading the number off the screenshot took a build each time.
|
|
781
|
+
* Fail closed at authoring instead, and name the crate.
|
|
782
|
+
*/
|
|
783
|
+
function assertClearOfSeal(plans: readonly ICrateAuthoring[]): void {
|
|
784
|
+
for (const [index, plan] of plans.entries()) {
|
|
785
|
+
const reach = footprint(plan.rotationY);
|
|
786
|
+
const overlapsX = Math.abs(plan.x - SEAL.x) < SEAL.half + reach;
|
|
787
|
+
const overlapsZ = Math.abs(plan.z - SEAL.z) < SEAL.half + reach;
|
|
788
|
+
if (overlapsX && overlapsZ)
|
|
789
|
+
throw new Error(
|
|
790
|
+
`Crate ${index} is authored inside the seal: (${plan.x.toFixed(2)}, ${plan.z.toFixed(2)}) with a ${reach.toFixed(2)} m footprint reaches the seal at (${SEAL.x}, ${SEAL.z}) half ${SEAL.half}. The run would report won before the warden moves.`,
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
}
|