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
|
@@ -38,7 +38,7 @@ bridge; avoid DOM globals, dynamic `import()`, and raw physics handles. **Report
|
|
|
38
38
|
- `.agents/skills/threenative-performance/SKILL.md` / `.claude/skills/threenative-performance/SKILL.md` — measured budgets.
|
|
39
39
|
- `.agents/skills/threenative-ui/SKILL.md` / `.claude/skills/threenative-ui/SKILL.md` — native-safe UI.
|
|
40
40
|
- `.agents/skills/threenative-context/SKILL.md` / `.claude/skills/threenative-context/SKILL.md` — portable ctx APIs.
|
|
41
|
-
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro. Lazy-first: `.agents/skills/ponytail/SKILL.md` / `.claude/skills/ponytail/SKILL.md` — smallest correct change, and its reuse rung is the capability search above.
|
|
41
|
+
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro. A game-side `patches/` fix is temporary: once it is settled, it moves into the engine in one PR. Lazy-first: `.agents/skills/ponytail/SKILL.md` / `.claude/skills/ponytail/SKILL.md` — smallest correct change, and its reuse rung is the capability search above.
|
|
42
42
|
|
|
43
43
|
## Commands and map
|
|
44
44
|
|
|
@@ -53,17 +53,13 @@ pnpm typecheck
|
|
|
53
53
|
`src/track.ts` is a ring of six chunks **moved and rewritten**, never rebuilt: each chunk's
|
|
54
54
|
obstacle `InstancedMesh` is built once at a fixed slot count and its matrices rewritten on
|
|
55
55
|
recycle. The obstacle *bodies* are the exception — disposed and recreated, because `RigidBody3D`
|
|
56
|
-
cannot reposition a fixed body. The runner is not a rigid body — a lane snap and a jump
|
|
57
|
-
arc feel worse in a solver — but the collision is real: `src/entities/Runner.ts` carries an
|
|
58
|
-
`Area3D` masked to the obstacle layer and listens for `bodyEntered`, so a hit is an overlap the
|
|
59
|
-
engine reports rather than a hand-maintained distance check. Gravity is zero in `src/game.ts` on purpose;
|
|
60
|
-
nothing falls. The track comes from `ctx.random`, so `defineGame({ seed })` **is** the level.
|
|
56
|
+
cannot reposition a fixed body. The runner is not a rigid body — a lane snap and a jump arc feel worse in a solver — but the collision is real: `src/entities/Runner.ts` carries an `Area3D` masked to the obstacle layer and listens for `bodyEntered`, so a hit is an overlap the engine reports, not a hand-kept distance check. Its figure is `assets/mannequin.glb` (the file `minimal` ships) through `SkeletalMesh3D`; `CLIPS` names the four clips it plays. Gravity is zero in `src/game.ts` on purpose; nothing falls. The track comes from `ctx.random`, so `defineGame({ seed })` **is** the level.
|
|
61
57
|
Register entities with `ctx.entities`; the React HUD reads `GameState`, never an entity. Keep `playtests/survives.playtest.json` as smoke proof, and `streams` honest
|
|
62
58
|
when chunk recycling changes.
|
|
63
59
|
|
|
64
60
|
## Portable authoring contracts
|
|
65
61
|
|
|
66
|
-
Leave `assets` absent: the cook selects target-decodable passes, with `models.sharedImages: true` deduplicating images. `sharedImages: false` embeds duplicate copies; `models: "none"` / `textures: "none"` / `audio: "none"` skip those passes and report uncooked bytes. Android/iOS currently skip compression and model dedupe. `assets.exclude` defaults to `[]`; source-relative globs (for example `["unused/**"]`) omit matching files and report saved bytes. `assets.budget` accepts `{ uncooked?: number | "none", total?: number | "none" }`, default `{ uncooked: 64_000_000, total: "none" }`: only bytes left uncooked where cooking was possible count toward `uncooked`. A number sets that ceiling; `"none"` disables both gates. Either disabled gate still reports bytes. Automatic texture cooking retains unaligned source images unchanged and reports `block-size`; those bytes still count toward the uncooked budget. An explicit compression codec override must satisfy four-pixel block alignment; `codec: "none"` opts out. Cooking never silently resizes an image to fix alignment.
|
|
62
|
+
Leave `assets` absent: the cook selects target-decodable passes, with `models.sharedImages: true` deduplicating images. `sharedImages: false` embeds duplicate copies; `models.compact` (default `{ flatten: true, join: true, instance: true }`) flattens the scene graph, merges primitives by material and batches a mesh shared by several nodes as `EXT_mesh_gpu_instancing` — all lossless, keeping any node matching `protectedPattern` (or named in `protectedNames`), an animation target, or a skin joint individually addressable; `compact: false` ships the scene graph as authored. `models: "none"` / `textures: "none"` / `audio: "none"` skip those passes and report uncooked bytes. Android/iOS currently skip compression and model dedupe. `assets.exclude` defaults to `[]`; source-relative globs (for example `["unused/**"]`) omit matching files and report saved bytes. `assets.budget` accepts `{ uncooked?: number | "none", total?: number | "none" }`, default `{ uncooked: 64_000_000, total: "none" }`: only bytes left uncooked where cooking was possible count toward `uncooked`. A number sets that ceiling; `"none"` disables both gates. Either disabled gate still reports bytes. Automatic texture cooking retains unaligned source images unchanged and reports `block-size`; those bytes still count toward the uncooked budget. An explicit compression codec override must satisfy four-pixel block alignment; `codec: "none"` opts out. Cooking never silently resizes an image to fix alignment.
|
|
67
63
|
|
|
68
64
|
Relative look capture: a binding with `pointerRelative: true` captures the canvas on click by default; set `captureOnClick: false` and call `ctx.input.captureMouse()` from your own gesture to opt out. Desktop mode precedence is CLI (`--windowed`, `--maximized`, `--fullscreen`) over `display.fullscreen` over `window.maximized`; with both false, `window.width`/`height` size the normal window.
|
|
69
65
|
Scenes use `load`, `enter`, `update`, `exit`, `render`; physics nodes are Godot-named and disposable. Generated conventions call `GroundSnap` for floor contact and `normaliseToMetres` for authored model scale.
|
|
@@ -84,13 +80,13 @@ caught where a bone-direction check reads zero. `clipTrackBindings` names tracks
|
|
|
84
80
|
clip's pose, and `boneContact` reports in metres whether a named bone reaches the prop it is
|
|
85
81
|
supposed to be touching. Two loading conventions come from `@threenative/core`, not from your own loops: `loadAll(items, load)` fetches six at a time and returns results **in the input's order** (a pool that pushes returns completion order, so a positional pick lands a different asset every load), and `addInSlices(objects, (object) => ctx.add(object))` attaches 256 per presented frame so hundreds of objects never land in one long frame; override `concurrency`/`sliceSize`, pass `while: () => alive` to stop a torn-down scene without throwing, and `marker: false` silences `TN_LOAD_ALL`/`TN_ADD_SLICES` but never the measurement.
|
|
86
82
|
|
|
87
|
-
## Budget real time for the look — see `agent-docs/dream-loop.md`
|
|
83
|
+
## Budget real time for the look — see `node_modules/create-threenative/agent-docs/references/dream-loop.md`
|
|
88
84
|
|
|
89
85
|
Edit `src/render/` directly; `postprocessing.ts` reports stages but decides no game colour. Quality
|
|
90
86
|
tiers live in `src/render/quality.ts`: `low`, `medium`, `high`; `isMobile()` chooses `low`, otherwise
|
|
91
87
|
`high`; override with `setupPost(..., { tier: "low" })`. Unknown tiers throw and `TN_QUALITY_TIER`
|
|
92
|
-
reports the source. A scenario with no assertions or missing observations fails; open a real capture. The engine warns you before a human does: `TN_SCENE_WARNING` fires when the GPU used under a third of the frame while the JS render phase ran longer than the display's own period, and names the census behind it — objects considered, draws per pass, triangles per draw, shadow-exempt casters. It is a scene-shape verdict, so answer it by moving the draw and object counts, not the engine: read the bucket census before promising a merge. `npx threenative doctor` repeats the last verdict and the `DEV_MODE=true` chip shows it
|
|
88
|
+
reports the source. A scenario with no assertions or missing observations fails; open a real capture. The engine warns you before a human does: `TN_SCENE_WARNING` fires when the GPU used under a third of the frame while the JS render phase ran longer than the display's own period, and names the census behind it — objects considered, draws per pass, triangles per draw, shadow-exempt casters. It is a scene-shape verdict, so answer it by moving the draw and object counts, not the engine: read the bucket census before promising a merge. `npx threenative doctor` repeats the last verdict and the `DEV_MODE=true` chip shows it on screen (it draws the verdict alone — no frame rate, which reads throttled under a compositor or a virtual display; see `agent-docs/references/performance-basics.md`); `TN_FRAME_SPANS=1` adds the render phase's own span tree when you need to know which part costs the milliseconds. The cheapest static object is one whose transform you never write: measured on 1,561 objects, leaving them alone costs 10.10 ms of render phase against 17.45 ms when the game rewrites every transform each frame, because three skips the per-object binding update when nothing changed. So do not touch a transform you do not need to — that is worth ~7 ms where `markStatic(root)`, which additionally composes a never-moving subtree once, measured 0.009 ms. Use it for scenery you are sure of, and `invalidateStatic(object)` to announce a write inside one; it deletes matrix arithmetic, not the walk. `TN_RENDERLIST_VALIDATE=1` recomputes every world matrix the long way each frame and throws on the first that disagrees, which is how you prove a freeze did not leave something stale on screen.
|
|
93
89
|
|
|
94
|
-
Recipes
|
|
90
|
+
Recipes in the installed create-threenative: `node_modules/create-threenative/agent-docs/references/assertion-reference.md`, `node_modules/create-threenative/agent-docs/references/build-profiles.md`, `node_modules/create-threenative/agent-docs/references/capability-reference.md`, `node_modules/create-threenative/agent-docs/references/capture-the-frame.md`, `node_modules/create-threenative/agent-docs/references/creating-creatures.md`, `node_modules/create-threenative/agent-docs/references/ctx-cookbook.md`, `node_modules/create-threenative/agent-docs/references/debug-surface.md`, `node_modules/create-threenative/agent-docs/references/finding-assets.md`, `node_modules/create-threenative/agent-docs/references/gameplay-recipes.md`, `node_modules/create-threenative/agent-docs/references/menu-screens.md`, `node_modules/create-threenative/agent-docs/references/mobile-memory-budget.md`, `node_modules/create-threenative/agent-docs/references/performance-basics.md`, `node_modules/create-threenative/agent-docs/references/rigging-characters.md`, `node_modules/create-threenative/agent-docs/references/sculpt-from-a-reference.md`, `node_modules/create-threenative/agent-docs/references/trace-a-slow-frame.md`, `node_modules/create-threenative/agent-docs/references/visual-baseline.md`, and `node_modules/create-threenative/agent-docs/references/webview-ui.md`.
|
|
95
91
|
## Optional multiplayer transport
|
|
96
92
|
For online play only, import `connect` from `@threenative/core/net` with an HTTPS URL and nonempty identity credential; configure `connectTimeoutMs`, `maxReliableMessageBytes`, `maxQueuedReliableBytes`, and `maxQueuedDatagrams` (10s/65,536/1 MiB/256), use `reliable-ordered` for ordered reliable messages and bounded `unreliable` datagrams that may drop, and keep serialization, replication, prediction, interpolation, snapshots and rejoin in this game's `src/` and server. There is no fallback: unsupported WebTransport/native rejects with `TN_NET_UNAVAILABLE`; reference Go server: `packages/runtime-native/examples/webtransport/server`.
|
|
@@ -40,7 +40,7 @@ bridge; avoid DOM globals, dynamic `import()`, and raw physics handles. **Report
|
|
|
40
40
|
- `.agents/skills/threenative-performance/SKILL.md` / `.claude/skills/threenative-performance/SKILL.md` — measured budgets.
|
|
41
41
|
- `.agents/skills/threenative-ui/SKILL.md` / `.claude/skills/threenative-ui/SKILL.md` — native-safe UI.
|
|
42
42
|
- `.agents/skills/threenative-context/SKILL.md` / `.claude/skills/threenative-context/SKILL.md` — portable ctx APIs.
|
|
43
|
-
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro. Lazy-first: `.agents/skills/ponytail/SKILL.md` / `.claude/skills/ponytail/SKILL.md` — smallest correct change, and its reuse rung is the capability search above.
|
|
43
|
+
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro. A game-side `patches/` fix is temporary: once it is settled, it moves into the engine in one PR. Lazy-first: `.agents/skills/ponytail/SKILL.md` / `.claude/skills/ponytail/SKILL.md` — smallest correct change, and its reuse rung is the capability search above.
|
|
44
44
|
|
|
45
45
|
## Commands and map
|
|
46
46
|
|
|
@@ -55,17 +55,13 @@ pnpm typecheck
|
|
|
55
55
|
`src/track.ts` is a ring of six chunks **moved and rewritten**, never rebuilt: each chunk's
|
|
56
56
|
obstacle `InstancedMesh` is built once at a fixed slot count and its matrices rewritten on
|
|
57
57
|
recycle. The obstacle *bodies* are the exception — disposed and recreated, because `RigidBody3D`
|
|
58
|
-
cannot reposition a fixed body. The runner is not a rigid body — a lane snap and a jump
|
|
59
|
-
arc feel worse in a solver — but the collision is real: `src/entities/Runner.ts` carries an
|
|
60
|
-
`Area3D` masked to the obstacle layer and listens for `bodyEntered`, so a hit is an overlap the
|
|
61
|
-
engine reports rather than a hand-maintained distance check. Gravity is zero in `src/game.ts` on purpose;
|
|
62
|
-
nothing falls. The track comes from `ctx.random`, so `defineGame({ seed })` **is** the level.
|
|
58
|
+
cannot reposition a fixed body. The runner is not a rigid body — a lane snap and a jump arc feel worse in a solver — but the collision is real: `src/entities/Runner.ts` carries an `Area3D` masked to the obstacle layer and listens for `bodyEntered`, so a hit is an overlap the engine reports, not a hand-kept distance check. Its figure is `assets/mannequin.glb` (the file `minimal` ships) through `SkeletalMesh3D`; `CLIPS` names the four clips it plays. Gravity is zero in `src/game.ts` on purpose; nothing falls. The track comes from `ctx.random`, so `defineGame({ seed })` **is** the level.
|
|
63
59
|
Register entities with `ctx.entities`; the React HUD reads `GameState`, never an entity. Keep `playtests/survives.playtest.json` as smoke proof, and `streams` honest
|
|
64
60
|
when chunk recycling changes.
|
|
65
61
|
|
|
66
62
|
## Portable authoring contracts
|
|
67
63
|
|
|
68
|
-
Leave `assets` absent: the cook selects target-decodable passes, with `models.sharedImages: true` deduplicating images. `sharedImages: false` embeds duplicate copies; `models: "none"` / `textures: "none"` / `audio: "none"` skip those passes and report uncooked bytes. Android/iOS currently skip compression and model dedupe. `assets.exclude` defaults to `[]`; source-relative globs (for example `["unused/**"]`) omit matching files and report saved bytes. `assets.budget` accepts `{ uncooked?: number | "none", total?: number | "none" }`, default `{ uncooked: 64_000_000, total: "none" }`: only bytes left uncooked where cooking was possible count toward `uncooked`. A number sets that ceiling; `"none"` disables both gates. Either disabled gate still reports bytes. Automatic texture cooking retains unaligned source images unchanged and reports `block-size`; those bytes still count toward the uncooked budget. An explicit compression codec override must satisfy four-pixel block alignment; `codec: "none"` opts out. Cooking never silently resizes an image to fix alignment.
|
|
64
|
+
Leave `assets` absent: the cook selects target-decodable passes, with `models.sharedImages: true` deduplicating images. `sharedImages: false` embeds duplicate copies; `models.compact` (default `{ flatten: true, join: true, instance: true }`) flattens the scene graph, merges primitives by material and batches a mesh shared by several nodes as `EXT_mesh_gpu_instancing` — all lossless, keeping any node matching `protectedPattern` (or named in `protectedNames`), an animation target, or a skin joint individually addressable; `compact: false` ships the scene graph as authored. `models: "none"` / `textures: "none"` / `audio: "none"` skip those passes and report uncooked bytes. Android/iOS currently skip compression and model dedupe. `assets.exclude` defaults to `[]`; source-relative globs (for example `["unused/**"]`) omit matching files and report saved bytes. `assets.budget` accepts `{ uncooked?: number | "none", total?: number | "none" }`, default `{ uncooked: 64_000_000, total: "none" }`: only bytes left uncooked where cooking was possible count toward `uncooked`. A number sets that ceiling; `"none"` disables both gates. Either disabled gate still reports bytes. Automatic texture cooking retains unaligned source images unchanged and reports `block-size`; those bytes still count toward the uncooked budget. An explicit compression codec override must satisfy four-pixel block alignment; `codec: "none"` opts out. Cooking never silently resizes an image to fix alignment.
|
|
69
65
|
|
|
70
66
|
Relative look capture: a binding with `pointerRelative: true` captures the canvas on click by default; set `captureOnClick: false` and call `ctx.input.captureMouse()` from your own gesture to opt out. Desktop mode precedence is CLI (`--windowed`, `--maximized`, `--fullscreen`) over `display.fullscreen` over `window.maximized`; with both false, `window.width`/`height` size the normal window.
|
|
71
67
|
Scenes use `load`, `enter`, `update`, `exit`, `render`; physics nodes are Godot-named and disposable. Generated conventions call `GroundSnap` for floor contact and `normaliseToMetres` for authored model scale.
|
|
@@ -86,13 +82,13 @@ caught where a bone-direction check reads zero. `clipTrackBindings` names tracks
|
|
|
86
82
|
clip's pose, and `boneContact` reports in metres whether a named bone reaches the prop it is
|
|
87
83
|
supposed to be touching. Two loading conventions come from `@threenative/core`, not from your own loops: `loadAll(items, load)` fetches six at a time and returns results **in the input's order** (a pool that pushes returns completion order, so a positional pick lands a different asset every load), and `addInSlices(objects, (object) => ctx.add(object))` attaches 256 per presented frame so hundreds of objects never land in one long frame; override `concurrency`/`sliceSize`, pass `while: () => alive` to stop a torn-down scene without throwing, and `marker: false` silences `TN_LOAD_ALL`/`TN_ADD_SLICES` but never the measurement.
|
|
88
84
|
|
|
89
|
-
## Budget real time for the look — see `agent-docs/dream-loop.md`
|
|
85
|
+
## Budget real time for the look — see `node_modules/create-threenative/agent-docs/references/dream-loop.md`
|
|
90
86
|
|
|
91
87
|
Edit `src/render/` directly; `postprocessing.ts` reports stages but decides no game colour. Quality
|
|
92
88
|
tiers live in `src/render/quality.ts`: `low`, `medium`, `high`; `isMobile()` chooses `low`, otherwise
|
|
93
89
|
`high`; override with `setupPost(..., { tier: "low" })`. Unknown tiers throw and `TN_QUALITY_TIER`
|
|
94
|
-
reports the source. A scenario with no assertions or missing observations fails; open a real capture. The engine warns you before a human does: `TN_SCENE_WARNING` fires when the GPU used under a third of the frame while the JS render phase ran longer than the display's own period, and names the census behind it — objects considered, draws per pass, triangles per draw, shadow-exempt casters. It is a scene-shape verdict, so answer it by moving the draw and object counts, not the engine: read the bucket census before promising a merge. `npx threenative doctor` repeats the last verdict and the `DEV_MODE=true` chip shows it
|
|
90
|
+
reports the source. A scenario with no assertions or missing observations fails; open a real capture. The engine warns you before a human does: `TN_SCENE_WARNING` fires when the GPU used under a third of the frame while the JS render phase ran longer than the display's own period, and names the census behind it — objects considered, draws per pass, triangles per draw, shadow-exempt casters. It is a scene-shape verdict, so answer it by moving the draw and object counts, not the engine: read the bucket census before promising a merge. `npx threenative doctor` repeats the last verdict and the `DEV_MODE=true` chip shows it on screen (it draws the verdict alone — no frame rate, which reads throttled under a compositor or a virtual display; see `agent-docs/references/performance-basics.md`); `TN_FRAME_SPANS=1` adds the render phase's own span tree when you need to know which part costs the milliseconds. The cheapest static object is one whose transform you never write: measured on 1,561 objects, leaving them alone costs 10.10 ms of render phase against 17.45 ms when the game rewrites every transform each frame, because three skips the per-object binding update when nothing changed. So do not touch a transform you do not need to — that is worth ~7 ms where `markStatic(root)`, which additionally composes a never-moving subtree once, measured 0.009 ms. Use it for scenery you are sure of, and `invalidateStatic(object)` to announce a write inside one; it deletes matrix arithmetic, not the walk. `TN_RENDERLIST_VALIDATE=1` recomputes every world matrix the long way each frame and throws on the first that disagrees, which is how you prove a freeze did not leave something stale on screen.
|
|
95
91
|
|
|
96
|
-
Recipes
|
|
92
|
+
Recipes in the installed create-threenative: `node_modules/create-threenative/agent-docs/references/assertion-reference.md`, `node_modules/create-threenative/agent-docs/references/build-profiles.md`, `node_modules/create-threenative/agent-docs/references/capability-reference.md`, `node_modules/create-threenative/agent-docs/references/capture-the-frame.md`, `node_modules/create-threenative/agent-docs/references/creating-creatures.md`, `node_modules/create-threenative/agent-docs/references/ctx-cookbook.md`, `node_modules/create-threenative/agent-docs/references/debug-surface.md`, `node_modules/create-threenative/agent-docs/references/finding-assets.md`, `node_modules/create-threenative/agent-docs/references/gameplay-recipes.md`, `node_modules/create-threenative/agent-docs/references/menu-screens.md`, `node_modules/create-threenative/agent-docs/references/mobile-memory-budget.md`, `node_modules/create-threenative/agent-docs/references/performance-basics.md`, `node_modules/create-threenative/agent-docs/references/rigging-characters.md`, `node_modules/create-threenative/agent-docs/references/sculpt-from-a-reference.md`, `node_modules/create-threenative/agent-docs/references/trace-a-slow-frame.md`, `node_modules/create-threenative/agent-docs/references/visual-baseline.md`, and `node_modules/create-threenative/agent-docs/references/webview-ui.md`.
|
|
97
93
|
## Optional multiplayer transport
|
|
98
94
|
For online play only, import `connect` from `@threenative/core/net` with an HTTPS URL and nonempty identity credential; configure `connectTimeoutMs`, `maxReliableMessageBytes`, `maxQueuedReliableBytes`, and `maxQueuedDatagrams` (10s/65,536/1 MiB/256), use `reliable-ordered` for ordered reliable messages and bounded `unreliable` datagrams that may drop, and keep serialization, replication, prediction, interpolation, snapshots and rejoin in this game's `src/` and server. There is no fallback: unsupported WebTransport/native rejects with `TN_NET_UNAVAILABLE`; reference Go server: `packages/runtime-native/examples/webtransport/server`.
|
|
@@ -4,9 +4,9 @@ Three lanes and a track that builds itself ahead of you. Obstacles end the run;
|
|
|
4
4
|
close shakes the camera. The track is a ring of six chunks that get moved and rebuilt, so a
|
|
5
5
|
ten-minute run costs what a ten-second one does.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
The sky (`assets/sky.jpg`, Poly Haven, CC0) and the runner (`assets/mannequin.glb`, Quaternius,
|
|
8
|
+
CC0) are the same two files the `minimal` arena opens on. The track is a box and rail built in
|
|
9
|
+
`src/render/shapes.ts`, and the dust is a TSL particle surface in `src/render/dust.ts`.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
pnpm dev # play it
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@threenative/core": "0.3.
|
|
19
|
-
"@threenative/physics": "0.3.
|
|
20
|
-
"@threenative/ui": "0.3.
|
|
18
|
+
"@threenative/core": "0.3.4",
|
|
19
|
+
"@threenative/physics": "0.3.4",
|
|
20
|
+
"@threenative/ui": "0.3.4",
|
|
21
21
|
"react": "19.2.0",
|
|
22
22
|
"react-dom": "19.2.0",
|
|
23
23
|
"three": "0.185.1"
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@gltf-transform/cli": "4.4.2",
|
|
27
27
|
"@tailwindcss/vite": "4.3.3",
|
|
28
|
-
"@threenative/assets": "0.3.
|
|
29
|
-
"@threenative/playtest": "0.3.
|
|
28
|
+
"@threenative/assets": "0.3.5",
|
|
29
|
+
"@threenative/playtest": "0.3.4",
|
|
30
30
|
"@types/react": "19.2.0",
|
|
31
31
|
"@types/react-dom": "19.2.0",
|
|
32
32
|
"@types/three": "0.185.3",
|
|
33
33
|
"@vitejs/plugin-react": "6.0.5",
|
|
34
|
-
"create-threenative": "0.2.
|
|
34
|
+
"create-threenative": "0.2.7",
|
|
35
35
|
"esbuild": "0.27.0",
|
|
36
36
|
"playwright": "1.62.1",
|
|
37
37
|
"tailwindcss": "4.3.3",
|
|
@@ -39,9 +39,15 @@
|
|
|
39
39
|
"vite": "8.2.0"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
|
-
"@threenative/runtime-native": "0.3.
|
|
42
|
+
"@threenative/runtime-native": "0.3.4"
|
|
43
|
+
},
|
|
44
|
+
"overrides": {
|
|
45
|
+
"sharp": ">=0.35.4"
|
|
43
46
|
},
|
|
44
47
|
"pnpm": {
|
|
48
|
+
"overrides": {
|
|
49
|
+
"sharp": ">=0.35.4"
|
|
50
|
+
},
|
|
45
51
|
"onlyBuiltDependencies": ["@threenative/core", "@threenative/runtime-native"],
|
|
46
52
|
"patchedDependencies": {
|
|
47
53
|
"three@0.185.1": "patches/three@0.185.1.patch"
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
"performance": {
|
|
6
6
|
"maxDrawCalls": 145,
|
|
7
7
|
"maxFrameMsP95": 33,
|
|
8
|
-
"maxTriangles":
|
|
8
|
+
"maxTriangles": 45000,
|
|
9
9
|
"minFps": 30
|
|
10
10
|
},
|
|
11
|
-
"renderChain": { "tier": "high" }
|
|
11
|
+
"renderChain": { "tier": "high", "perAdapter": { "software": { "tier": "low" } } }
|
|
12
12
|
},
|
|
13
13
|
"name": "production-performance",
|
|
14
14
|
"schemaVersion": 1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GroundSnap, normaliseToMetres } from "@threenative/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Object3D } from "three";
|
|
3
3
|
|
|
4
4
|
export interface IRunnerConventions {
|
|
5
5
|
readonly applyGrounding: (surfaceY: number, dt: number) => void;
|
|
@@ -13,8 +13,9 @@ export interface IRunnerConventions {
|
|
|
13
13
|
* `GroundSnap` takes the surface height as an argument, so a jump is a *surface that moved*
|
|
14
14
|
* rather than an exception to grounding. That is what keeps the landing exact at any frame rate.
|
|
15
15
|
*/
|
|
16
|
-
export function prepareRunnerConventions(model:
|
|
17
|
-
|
|
16
|
+
export function prepareRunnerConventions(model: Object3D): IRunnerConventions {
|
|
17
|
+
// Measured to the mannequin's `Head` joint, the base of the skull: 1.545 m there is a 1.8 m figure.
|
|
18
|
+
const normaliseFactor = normaliseToMetres(model, { axis: "height", metres: 1.545 });
|
|
18
19
|
const groundSnap = new GroundSnap(model);
|
|
19
20
|
return {
|
|
20
21
|
applyGrounding: (surfaceY, dt) => groundSnap.apply(model, surfaceY, dt),
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ICtx, SkeletalMesh3D } from "@threenative/core";
|
|
2
2
|
import { Area3D, CollisionShape3D } from "@threenative/physics";
|
|
3
|
-
import { type Group, MathUtils } from "three";
|
|
3
|
+
import { type AnimationClip, Group, MathUtils, type Object3D } from "three";
|
|
4
4
|
import { type IRunnerConventions, prepareRunnerConventions } from "../conventions.js";
|
|
5
5
|
import { OBSTACLE_LAYER, type RunnerPhysics } from "../physics.js";
|
|
6
|
-
import { runner as runnerMesh } from "../render/shapes.js";
|
|
7
6
|
import type { ITouchInput } from "../render/touch-controls.js";
|
|
8
7
|
import type { GameState } from "../state.js";
|
|
9
8
|
import { LANE_X } from "../track.js";
|
|
@@ -16,6 +15,19 @@ const GRAVITY = -19;
|
|
|
16
15
|
/** Within this many metres of an obstacle's centre and still alive: a near miss. */
|
|
17
16
|
const NEAR_MISS = 1.5;
|
|
18
17
|
|
|
18
|
+
/** The clips `assets/mannequin.glb` ships, by the name this file plays them under. */
|
|
19
|
+
const CLIPS = {
|
|
20
|
+
jog: "Jog_Fwd_Loop",
|
|
21
|
+
jumpStart: "Jump_Start",
|
|
22
|
+
jumpLoop: "Jump_Loop",
|
|
23
|
+
jumpLand: "Jump_Land",
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
export interface IRunnerModel {
|
|
27
|
+
readonly scene: Object3D;
|
|
28
|
+
readonly animations: readonly AnimationClip[];
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
/**
|
|
20
32
|
* The player.
|
|
21
33
|
*
|
|
@@ -23,9 +35,14 @@ const NEAR_MISS = 1.5;
|
|
|
23
35
|
* solver makes both worse. What *is* physics is the collision — the runner carries an `Area3D`
|
|
24
36
|
* that scans the obstacle layer, so a hit is an overlap the engine reports rather than a distance
|
|
25
37
|
* check this file would have to keep in sync with the obstacle geometry.
|
|
38
|
+
*
|
|
39
|
+
* The figure is `assets/mannequin.glb`, the same CC0 mannequin the `minimal` arena opens on.
|
|
40
|
+
* Swap in any rigged glTF with the same clip roles by editing `CLIPS`; `requiredClips` fails the
|
|
41
|
+
* load, by name, if one is missing.
|
|
26
42
|
*/
|
|
27
43
|
export class Runner {
|
|
28
44
|
readonly mesh: Group;
|
|
45
|
+
readonly character: SkeletalMesh3D;
|
|
29
46
|
readonly tags = ["player", "runner"];
|
|
30
47
|
readonly hitbox: Area3D;
|
|
31
48
|
#conventions: IRunnerConventions;
|
|
@@ -35,10 +52,24 @@ export class Runner {
|
|
|
35
52
|
#crashed = false;
|
|
36
53
|
#nearMisses = 0;
|
|
37
54
|
|
|
38
|
-
constructor(ctx: GameCtx) {
|
|
39
|
-
this.mesh =
|
|
55
|
+
constructor(ctx: GameCtx, model: IRunnerModel) {
|
|
56
|
+
this.mesh = new Group();
|
|
40
57
|
this.mesh.name = "player";
|
|
41
|
-
this
|
|
58
|
+
this.character = new SkeletalMesh3D({
|
|
59
|
+
source: model.scene,
|
|
60
|
+
clips: model.animations,
|
|
61
|
+
requiredClips: Object.values(CLIPS),
|
|
62
|
+
strideRoot: this.mesh,
|
|
63
|
+
});
|
|
64
|
+
const figure = this.character.root;
|
|
65
|
+
figure.traverse((object) => {
|
|
66
|
+
object.castShadow = true;
|
|
67
|
+
});
|
|
68
|
+
// The model faces +Z; the track runs toward -Z, so turn the figure to face down it.
|
|
69
|
+
figure.rotation.y = Math.PI;
|
|
70
|
+
this.mesh.add(figure);
|
|
71
|
+
this.#conventions = prepareRunnerConventions(figure);
|
|
72
|
+
this.character.play(CLIPS.jog);
|
|
42
73
|
ctx.add(this.mesh);
|
|
43
74
|
this.hitbox = new Area3D({
|
|
44
75
|
collisionLayer: 0,
|
|
@@ -91,16 +122,21 @@ export class Runner {
|
|
|
91
122
|
this.#lane = MathUtils.clamp(this.#lane, 0, LANE_X.length - 1);
|
|
92
123
|
|
|
93
124
|
const stickJump = (touch?.move.y ?? 0) > 0.65;
|
|
94
|
-
|
|
125
|
+
const jumped = (ctx.input.justPressed("jump") || stickJump) && !this.airborne;
|
|
126
|
+
if (jumped) this.#vertical = JUMP_SPEED;
|
|
127
|
+
const wasAirborne = this.airborne;
|
|
95
128
|
this.#height = Math.max(0, this.#height + this.#vertical * dt);
|
|
96
129
|
this.#vertical = this.#height > 0 ? this.#vertical + GRAVITY * dt : 0;
|
|
130
|
+
this.#animate(jumped, wasAirborne);
|
|
97
131
|
|
|
98
132
|
const targetX = LANE_X[this.#lane] ?? 0;
|
|
99
133
|
const blend = Math.min(1, Math.max(0, dt) * LANE_BLEND);
|
|
100
134
|
this.mesh.position.x += (targetX - this.mesh.position.x) * blend;
|
|
135
|
+
this.mesh.position.y = this.#height;
|
|
101
136
|
this.mesh.position.z = -distance;
|
|
102
137
|
this.mesh.rotation.z = (targetX - this.mesh.position.x) * 0.35;
|
|
103
138
|
this.#conventions.applyGrounding(this.#height, dt);
|
|
139
|
+
this.character.update(dt);
|
|
104
140
|
this.hitbox.setPosition({
|
|
105
141
|
x: this.mesh.position.x,
|
|
106
142
|
y: this.#height + 0.7,
|
|
@@ -108,6 +144,17 @@ export class Runner {
|
|
|
108
144
|
});
|
|
109
145
|
}
|
|
110
146
|
|
|
147
|
+
/** Picks a clip from what the runner is doing: run, take off, hang, land, run again. */
|
|
148
|
+
#animate(jumped: boolean, wasAirborne: boolean): void {
|
|
149
|
+
if (jumped) this.character.play(CLIPS.jumpStart, { fade: 0.08, mode: "once" });
|
|
150
|
+
else if (this.airborne && this.character.finished)
|
|
151
|
+
this.character.play(CLIPS.jumpLoop, { fade: 0.15 });
|
|
152
|
+
else if (wasAirborne && !this.airborne)
|
|
153
|
+
this.character.play(CLIPS.jumpLand, { fade: 0.06, mode: "once" });
|
|
154
|
+
else if (!this.airborne && this.character.finished)
|
|
155
|
+
this.character.play(CLIPS.jog, { fade: 0.2 });
|
|
156
|
+
}
|
|
157
|
+
|
|
111
158
|
/** True when the runner is beside, rather than on top of, an obstacle at `x` on this stretch. */
|
|
112
159
|
isNearMiss(obstacleX: number): boolean {
|
|
113
160
|
const gap = Math.abs(obstacleX - this.mesh.position.x);
|
|
@@ -20,6 +20,8 @@ const game = defineGame<GameState, RunnerPhysics>({
|
|
|
20
20
|
},
|
|
21
21
|
// Gravity is zero on purpose: nothing in this game falls. The jump is an authored arc in
|
|
22
22
|
// `Runner`, and the only physics the runner needs is the overlap query its `Area3D` performs.
|
|
23
|
+
// The look is the arena's: `sky.jpg` lights and fogs the scene, the track is the light metre
|
|
24
|
+
// grid, and the accent belongs to obstacles — never to the runner.
|
|
23
25
|
plugins: [rapier({ gravity: { x: 0, y: 0, z: 0 } }), playtest()],
|
|
24
26
|
display: config.display,
|
|
25
27
|
render: config.renderer,
|
|
@@ -7,9 +7,11 @@ const LOOK_AHEAD = 22;
|
|
|
7
7
|
const LOOK_HEIGHT = -0.2;
|
|
8
8
|
|
|
9
9
|
export function setupCamera(camera: PerspectiveCamera): void {
|
|
10
|
-
|
|
10
|
+
// 60° vertical is Unreal's 90° horizontal at 16:9 — the framing a third-person game is judged
|
|
11
|
+
// by, and the arena look whose horizon it was authored against.
|
|
12
|
+
camera.fov = 60;
|
|
11
13
|
camera.near = 0.1;
|
|
12
|
-
camera.far =
|
|
14
|
+
camera.far = 20_000;
|
|
13
15
|
camera.position.set(0, HEIGHT, BACK);
|
|
14
16
|
camera.lookAt(0, LOOK_HEIGHT, -LOOK_AHEAD);
|
|
15
17
|
camera.updateProjectionMatrix();
|
|
@@ -90,14 +90,17 @@ export function createDustTrail(): IDustOptions {
|
|
|
90
90
|
toneMapped: false,
|
|
91
91
|
transparent: true,
|
|
92
92
|
});
|
|
93
|
+
// Fragments below this alpha are discarded, so the quad's transparent corners write nothing to
|
|
94
|
+
// the scene pass's depth and normal buffers — AO would otherwise darken the whole square.
|
|
95
|
+
material.alphaTest = 0.15;
|
|
93
96
|
const life = varying(phase());
|
|
94
97
|
material.scaleNode = vec2(0.42).mul(mix(0.5, 1.5, life));
|
|
95
98
|
const birth = new Array(3)
|
|
96
99
|
.fill(0)
|
|
97
|
-
.map((_, index) => ((palette.
|
|
100
|
+
.map((_, index) => ((palette.structure >> (16 - index * 8)) & 255) / 255);
|
|
98
101
|
const death = new Array(3)
|
|
99
102
|
.fill(0)
|
|
100
|
-
.map((_, index) => ((palette.
|
|
103
|
+
.map((_, index) => ((palette.horizon >> (16 - index * 8)) & 255) / 255);
|
|
101
104
|
material.colorNode = vec4(
|
|
102
105
|
mix(
|
|
103
106
|
vec3(birth[0] ?? 0, birth[1] ?? 0, birth[2] ?? 0),
|
|
@@ -1,57 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
1
|
+
// Generated for you. This is ordinary Three.js — edit or delete it freely.
|
|
2
|
+
// ThreeNative does not read this file.
|
|
3
|
+
//
|
|
4
|
+
// One sun. The sky image in `sky.ts` is the fill light — its environment reaches every face the
|
|
5
|
+
// sun misses — so there is no hemisphere or ambient light stacked on top to flatten the frame.
|
|
6
|
+
// The rig is returned because `WorldEnvironment`'s godrays stage raymarches against a shadow map,
|
|
7
|
+
// so `setupPost` needs the key light itself; a shadowless one is refused by name.
|
|
8
|
+
import { DirectionalLight, PCFSoftShadowMap, type Scene } from "three";
|
|
9
|
+
import { SUN_DIRECTION } from "./sky.js";
|
|
9
10
|
|
|
10
11
|
type ShadowRenderer = { shadowMap: { enabled: boolean; type: number } };
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* before the block does, and it is the only warning the player gets in time to use.
|
|
18
|
-
*
|
|
19
|
-
* Returns the key light: `WorldEnvironment`'s godrays stage raymarches against a shadow map, so
|
|
20
|
-
* the scene hands the sun to `setupPost` and a shadowless light is refused by name instead of
|
|
21
|
-
* rendering a black pass.
|
|
22
|
-
*/
|
|
23
|
-
export function setupLighting(scene: Scene, renderer: ShadowRenderer): DirectionalLight {
|
|
13
|
+
export function setupLighting(
|
|
14
|
+
scene: Scene,
|
|
15
|
+
renderer: ShadowRenderer,
|
|
16
|
+
mobile = false,
|
|
17
|
+
): { key: DirectionalLight; fill: DirectionalLight } {
|
|
24
18
|
renderer.shadowMap.enabled = true;
|
|
25
19
|
renderer.shadowMap.type = PCFSoftShadowMap;
|
|
26
|
-
// The sky half is the *rail* grey, not the horizon orange. Taking the horizon colour flooded
|
|
27
|
-
// the road with it and the track stopped being cool at all.
|
|
28
|
-
scene.add(new HemisphereLight(palette.rail, palette.track, 1.2));
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
// Warm white, matched by eye to the photographed midday sun against its own sky. Aimed low and
|
|
22
|
+
// down-track so it rakes across the obstacles and throws each one's shadow back toward the
|
|
23
|
+
// player: at speed the shadow arrives before the block does, which is the only warning in time.
|
|
24
|
+
const key = new DirectionalLight(0xfff1e0, 4.5);
|
|
25
|
+
key.position.copy(SUN_DIRECTION).multiplyScalar(30);
|
|
32
26
|
key.castShadow = true;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
key.shadow.
|
|
37
|
-
key.shadow.
|
|
38
|
-
key.shadow.camera.
|
|
39
|
-
key.shadow.camera.
|
|
40
|
-
|
|
27
|
+
// One map fitted to what the chase camera can see from the runner: 4096² is well under a
|
|
28
|
+
// centimetre a texel, so every shadow has the same softness. Phones take 2048².
|
|
29
|
+
const size = mobile ? 2048 : 4096;
|
|
30
|
+
key.shadow.mapSize.set(size, size);
|
|
31
|
+
key.shadow.radius = 2;
|
|
32
|
+
key.shadow.camera.near = 1;
|
|
33
|
+
key.shadow.camera.far = 140;
|
|
34
|
+
const extent = 28;
|
|
35
|
+
key.shadow.camera.left = -extent;
|
|
36
|
+
key.shadow.camera.right = extent;
|
|
37
|
+
key.shadow.camera.top = extent;
|
|
38
|
+
key.shadow.camera.bottom = -extent;
|
|
39
|
+
// Small biases: a large normal bias is what lifted the runner's shadow off its own skirt.
|
|
40
|
+
key.shadow.bias = -0.0002;
|
|
41
|
+
key.shadow.normalBias = 0.005;
|
|
41
42
|
scene.add(key);
|
|
42
43
|
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
const fill = new DirectionalLight(
|
|
48
|
-
fill.position.set(
|
|
44
|
+
// The sky alone leaves every down-track face in its own shade, so the runner reads as a dark
|
|
45
|
+
// silhouette against the obstacle it is about to hit — the one comparison the game asks the
|
|
46
|
+
// player to make. A soft fill from ahead of the camera lifts those faces without flattening the
|
|
47
|
+
// sun's own shadows.
|
|
48
|
+
const fill = new DirectionalLight(0xdfe8ff, 0.9);
|
|
49
|
+
fill.position.set(0, 8, 20);
|
|
49
50
|
scene.add(fill);
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
rim.position.set(-8, 4, 6);
|
|
53
|
-
scene.add(rim);
|
|
54
|
-
scene.add(new AmbientLight(palette.skyHigh, 0.6));
|
|
55
|
-
|
|
56
|
-
return key;
|
|
52
|
+
return { key, fill };
|
|
57
53
|
}
|
|
@@ -14,14 +14,14 @@ import { palette } from "./palette.js";
|
|
|
14
14
|
/* BEGIN THREENATIVE LOADING APPEARANCE */
|
|
15
15
|
/** Runner look and composition; edit this generated source to change the screen. */
|
|
16
16
|
export const loading = {
|
|
17
|
-
backgroundColor: palette.
|
|
17
|
+
backgroundColor: palette.horizon,
|
|
18
18
|
backgroundImage: undefined as string | undefined,
|
|
19
19
|
enabled: true,
|
|
20
20
|
fillImage: undefined as string | undefined,
|
|
21
21
|
logoImage: undefined as string | undefined,
|
|
22
22
|
progressColor: palette.accent,
|
|
23
23
|
showStatus: false,
|
|
24
|
-
trackColor: palette.
|
|
24
|
+
trackColor: palette.gridLine,
|
|
25
25
|
bar: { anchorX: 0.5, anchorY: 0.76, height: 11, maxWidth: 520, minWidth: 1, width: 0.6 },
|
|
26
26
|
} as const;
|
|
27
27
|
/* END THREENATIVE LOADING APPEARANCE */
|