create-threenative 0.2.10 → 0.2.12
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/agent-docs/references/assertion-reference.md +109 -3
- package/agent-docs/references/auto-exposure.md +28 -45
- package/agent-docs/references/build-profiles.md +1 -1
- package/agent-docs/references/capability-reference.md +527 -44
- package/agent-docs/references/debug-surface.md +64 -0
- package/agent-docs/references/finding-assets.md +11 -12
- package/agent-docs/references/performance-basics.md +19 -0
- package/agent-docs/references/trace-a-slow-frame.md +21 -0
- package/agent-docs/references/visual-baseline.md +23 -4
- package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
- package/agent-files/.agents/skills/prd-creator/SKILL.md +17 -6
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +87 -23
- package/agent-files/.agents/skills/threenative-performance/SKILL.md +12 -11
- package/agent-files/.claude/hooks/ponytail-context.mjs +1 -1
- package/agent-files/scripts/reference.mjs +9 -4
- package/capabilities.json +739 -50
- package/dist/index.d.ts +40 -6
- package/dist/index.js +227 -34
- package/dist/quality.d.ts +12 -0
- package/dist/quality.js +166747 -0
- package/dist/threenative.js +60 -44
- package/dist/web-engine-gltf-loader.js +2 -0
- package/dist/web-engine-mesh-bvh-webgpu.js +1 -1
- package/dist/web-engine-mesh-bvh.js +7 -0
- package/dist/web-engine-post-effects.js +645 -19
- package/dist/web-engine-runtime.js +3528 -343
- package/package.json +19 -9
- package/template-assets/assets/bay-PROVENANCE.md +21 -0
- package/template-assets/assets/bay-ground.webp +0 -0
- package/template-assets/assets/bay-metal.webp +0 -0
- package/template-assets/assets/bay-pavement-normal.webp +0 -0
- package/template-assets/assets/bay-pavement.webp +0 -0
- package/template-assets/assets/bay-plaster-normal.webp +0 -0
- package/template-assets/assets/bay-plaster.webp +0 -0
- package/template-assets/assets/bay-wood-normal.webp +0 -0
- package/template-assets/assets/bay-wood.webp +0 -0
- package/template-assets/assets/tex-PROVENANCE.md +25 -0
- package/template-assets/assets/tex-bark-normal.webp +0 -0
- package/template-assets/assets/tex-bark.webp +0 -0
- package/template-assets/assets/tex-birch-bark.webp +0 -0
- package/template-assets/assets/tex-grass.webp +0 -0
- package/template-assets/assets/tex-planks-normal.webp +0 -0
- package/template-assets/assets/tex-planks.webp +0 -0
- package/template-assets/assets/tex-rock-normal.webp +0 -0
- package/template-assets/assets/tex-rock.webp +0 -0
- package/template-assets/assets/tex-roof-tiles-normal.webp +0 -0
- package/template-assets/assets/tex-roof-tiles.webp +0 -0
- package/template-assets/assets/tex-sand-normal.webp +0 -0
- package/template-assets/assets/tex-sand.webp +0 -0
- package/template-assets/assets/tex-stone-wall-normal.webp +0 -0
- package/template-assets/assets/tex-stone-wall.webp +0 -0
- package/template-assets/kitExposure.ts +20 -0
- package/template-assets/patches/three@0.185.1.patch +481 -272
- package/template-assets/quality/biome.json +7 -0
- package/template-assets/quality/eslint.config.js +3 -0
- package/template-assets/realistic-ocean/README.md +113 -0
- package/template-assets/realistic-ocean/install.mjs +56 -0
- package/template-assets/realistic-ocean/src/realisticOcean.ts +151 -0
- package/template-assets/realistic-ocean/src/realisticOceanLifetime.ts +29 -0
- package/template-assets/realistic-ocean/src/render/REALISTIC-OCEAN-LICENSE.txt +25 -0
- package/template-assets/realistic-ocean/src/render/realisticSea.ts +642 -0
- package/template-assets/realistic-ocean/src/render/realisticSeaMaps.ts +311 -0
- package/template-assets/realistic-ocean/src/render/realisticSpectrum.ts +289 -0
- package/templates/AGENTS.md +21 -0
- package/templates/CLAUDE.md +23 -0
- package/templates/action-rpg/.codex/config.toml +6 -2
- package/templates/action-rpg/.cursor/mcp.json +8 -2
- package/templates/action-rpg/.gemini/settings.json +8 -2
- package/templates/action-rpg/.mcp.json +8 -2
- package/templates/action-rpg/.vscode/mcp.json +9 -2
- package/templates/action-rpg/.zed/settings.json +9 -2
- package/templates/action-rpg/AGENTS.md +11 -11
- package/templates/action-rpg/CLAUDE.md +11 -11
- package/templates/action-rpg/opencode.json +10 -2
- package/templates/action-rpg/package.json +15 -10
- package/templates/action-rpg/playtests/combat.playtest.json +6 -0
- package/templates/action-rpg/playtests/inventory.playtest.json +22 -0
- package/templates/action-rpg/playtests/performance.playtest.json +1 -1
- package/templates/action-rpg/playtests/roll.playtest.json +112 -0
- package/templates/action-rpg/playtests/swing.playtest.json +55 -0
- package/templates/action-rpg/playtests/win.playtest.json +4 -4
- package/templates/action-rpg/src/entities/Fighter.ts +44 -4
- package/templates/action-rpg/src/entities/Player.ts +64 -12
- package/templates/action-rpg/src/render/atmosphere.ts +444 -0
- package/templates/action-rpg/src/render/backlightMaterial.ts +49 -18
- package/templates/action-rpg/src/render/clouds.ts +605 -0
- package/templates/action-rpg/src/render/dungeon.ts +8 -6
- package/templates/action-rpg/src/render/exposure.ts +11 -109
- package/templates/action-rpg/src/render/gpuSky.ts +752 -0
- package/templates/action-rpg/src/render/lighting.ts +27 -4
- package/templates/action-rpg/src/render/materialLighting.ts +2 -11
- package/templates/action-rpg/src/render/palette.ts +1 -0
- package/templates/action-rpg/src/render/postprocessing.ts +4 -4
- package/templates/action-rpg/src/render/props.ts +10 -8
- package/templates/action-rpg/src/render/quality.ts +56 -108
- package/templates/action-rpg/src/render/sky.ts +74 -1
- package/templates/action-rpg/src/scenes/Play.ts +16 -12
- package/templates/action-rpg/src/ui/CharacterPanel.tsx +7 -2
- package/templates/action-rpg/src/ui/Hud.tsx +5 -7
- package/templates/action-rpg/src/ui/InventoryPanel.tsx +14 -14
- package/templates/action-rpg/threenative.config.ts +3 -0
- package/templates/adventure/.codex/config.toml +23 -0
- package/templates/adventure/.cursor/mcp.json +38 -0
- package/templates/adventure/.gemini/settings.json +38 -0
- package/templates/adventure/.mcp.json +38 -0
- package/templates/adventure/.vscode/mcp.json +43 -0
- package/templates/adventure/.zed/settings.json +43 -0
- package/templates/adventure/AGENTS.md +60 -0
- package/templates/adventure/CLAUDE.md +62 -0
- package/templates/adventure/index.html +14 -0
- package/templates/adventure/kit.json +8 -0
- package/templates/adventure/native-playtests/survives.playtest.json +52 -0
- package/templates/adventure/opencode.json +49 -0
- package/templates/adventure/package.json +65 -0
- package/templates/adventure/playtests/boss.playtest.json +406 -0
- package/templates/adventure/playtests/combat.playtest.json +342 -0
- package/templates/adventure/playtests/controls.playtest.json +142 -0
- package/templates/adventure/playtests/explore.playtest.json +45 -0
- package/templates/adventure/playtests/flicker.playtest.json +206 -0
- package/templates/adventure/playtests/hearts.playtest.json +171 -0
- package/templates/adventure/playtests/lockon.playtest.json +256 -0
- package/templates/adventure/playtests/look.playtest.json +72 -0
- package/templates/adventure/playtests/move-hollow.playtest.json +106 -0
- package/templates/adventure/playtests/move.playtest.json +84 -0
- package/templates/adventure/playtests/performance.playtest.json +55 -0
- package/templates/adventure/playtests/puzzle.playtest.json +250 -0
- package/templates/adventure/playtests/stride.playtest.json +67 -0
- package/templates/adventure/playtests/survives.playtest.json +171 -0
- package/templates/adventure/playtests/thornback.playtest.json +267 -0
- package/templates/adventure/public/favicon.svg +4 -0
- package/templates/adventure/src/entities/Block.ts +114 -0
- package/templates/adventure/src/entities/Chest.ts +69 -0
- package/templates/adventure/src/entities/Door.ts +81 -0
- package/templates/adventure/src/entities/Dummy.ts +69 -0
- package/templates/adventure/src/entities/Flicker.ts +239 -0
- package/templates/adventure/src/entities/Hero.ts +561 -0
- package/templates/adventure/src/entities/LockOn.ts +180 -0
- package/templates/adventure/src/entities/Mossling.ts +249 -0
- package/templates/adventure/src/entities/Switch.ts +49 -0
- package/templates/adventure/src/entities/Thornback.ts +238 -0
- package/templates/adventure/src/entities/Warden.ts +196 -0
- package/templates/adventure/src/game.ts +65 -0
- package/templates/adventure/src/interact.ts +63 -0
- package/templates/adventure/src/level/Hollow.ts +240 -0
- package/templates/adventure/src/level/Vale.ts +383 -0
- package/templates/adventure/src/main.ts +18 -0
- package/templates/adventure/src/render/camera.ts +416 -0
- package/templates/adventure/src/render/creatures.ts +405 -0
- package/templates/adventure/src/render/effects.ts +333 -0
- package/templates/adventure/src/render/foliage.ts +1072 -0
- package/templates/adventure/src/render/hero.ts +1447 -0
- package/templates/adventure/src/render/kitExposure.ts +20 -0
- package/templates/adventure/src/render/lighting.ts +74 -0
- package/templates/adventure/src/render/loading.ts +332 -0
- package/templates/adventure/src/render/materials.ts +179 -0
- package/templates/adventure/src/render/palette.ts +137 -0
- package/templates/adventure/src/render/postprocessing.ts +70 -0
- package/templates/adventure/src/render/props.ts +383 -0
- package/templates/adventure/src/render/quality.ts +46 -0
- package/templates/adventure/src/render/sky.ts +271 -0
- package/templates/adventure/src/render/surface.ts +259 -0
- package/templates/adventure/src/render/touch-controls.ts +137 -0
- package/templates/adventure/src/scenes/Play.ts +959 -0
- package/templates/adventure/src/state.ts +113 -0
- package/templates/adventure/src/style.css +98 -0
- package/templates/adventure/src/ui/App.tsx +22 -0
- package/templates/adventure/src/ui/GameUi.tsx +20 -0
- package/templates/adventure/src/ui/Hud.tsx +70 -0
- package/templates/adventure/src/ui/Menu.tsx +15 -0
- package/templates/adventure/src/ui/main.tsx +14 -0
- package/templates/adventure/tailwind.config.ts +2 -0
- package/templates/adventure/threenative.config.ts +62 -0
- package/templates/adventure/tsconfig.json +17 -0
- package/templates/adventure/vite.config.ts +49 -0
- package/templates/collectathon/.codex/config.toml +23 -0
- package/templates/collectathon/.cursor/mcp.json +38 -0
- package/templates/collectathon/.gemini/settings.json +38 -0
- package/templates/collectathon/.mcp.json +38 -0
- package/templates/collectathon/.vscode/mcp.json +43 -0
- package/templates/collectathon/.zed/settings.json +43 -0
- package/templates/collectathon/AGENTS.md +58 -0
- package/templates/collectathon/CLAUDE.md +60 -0
- package/templates/collectathon/index.html +14 -0
- package/templates/collectathon/kit.json +8 -0
- package/templates/collectathon/native-playtests/survives.playtest.json +52 -0
- package/templates/collectathon/opencode.json +49 -0
- package/templates/collectathon/package.json +65 -0
- package/templates/collectathon/playtests/acrobatics.playtest.json +238 -0
- package/templates/collectathon/playtests/camera.playtest.json +80 -0
- package/templates/collectathon/playtests/clipped-probe.playtest.json +101 -0
- package/templates/collectathon/playtests/collect.playtest.json +196 -0
- package/templates/collectathon/playtests/combat.playtest.json +246 -0
- package/templates/collectathon/playtests/double-tap-air.playtest.json +198 -0
- package/templates/collectathon/playtests/double-tap.playtest.json +136 -0
- package/templates/collectathon/playtests/effects.playtest.json +124 -0
- package/templates/collectathon/playtests/enemies.playtest.json +295 -0
- package/templates/collectathon/playtests/explore.playtest.json +45 -0
- package/templates/collectathon/playtests/hop-reach.playtest.json +117 -0
- package/templates/collectathon/playtests/jump-chain.playtest.json +274 -0
- package/templates/collectathon/playtests/ledge-angle.playtest.json +107 -0
- package/templates/collectathon/playtests/ledge-too-high.playtest.json +115 -0
- package/templates/collectathon/playtests/ledge.playtest.json +100 -0
- package/templates/collectathon/playtests/look.playtest.json +64 -0
- package/templates/collectathon/playtests/performance.playtest.json +55 -0
- package/templates/collectathon/playtests/stride.playtest.json +111 -0
- package/templates/collectathon/playtests/survives.playtest.json +123 -0
- package/templates/collectathon/playtests/telegraphs.playtest.json +132 -0
- package/templates/collectathon/playtests/thornback.playtest.json +157 -0
- package/templates/collectathon/playtests/wall-kick.playtest.json +206 -0
- package/templates/collectathon/playtests/win.playtest.json +166 -0
- package/templates/collectathon/public/favicon.svg +4 -0
- package/templates/collectathon/src/entities/Hero.ts +915 -0
- package/templates/collectathon/src/entities/Pickup.ts +63 -0
- package/templates/collectathon/src/entities/Walker.ts +248 -0
- package/templates/collectathon/src/game.ts +51 -0
- package/templates/collectathon/src/level/Course.ts +590 -0
- package/templates/collectathon/src/level/terrain.ts +144 -0
- package/templates/collectathon/src/main.ts +14 -0
- package/templates/collectathon/src/playtest-events.ts +15 -0
- package/templates/collectathon/src/render/camera.ts +163 -0
- package/templates/collectathon/src/render/castle.ts +408 -0
- package/templates/collectathon/src/render/effects.ts +284 -0
- package/templates/collectathon/src/render/foliage.ts +744 -0
- package/templates/collectathon/src/render/ground.ts +139 -0
- package/templates/collectathon/src/render/hero.ts +452 -0
- package/templates/collectathon/src/render/kitExposure.ts +20 -0
- package/templates/collectathon/src/render/lighting.ts +65 -0
- package/templates/collectathon/src/render/loading.ts +332 -0
- package/templates/collectathon/src/render/materials.ts +196 -0
- package/templates/collectathon/src/render/palette.ts +82 -0
- package/templates/collectathon/src/render/postprocessing.ts +79 -0
- package/templates/collectathon/src/render/props.ts +218 -0
- package/templates/collectathon/src/render/quality.ts +54 -0
- package/templates/collectathon/src/render/sky.ts +262 -0
- package/templates/collectathon/src/render/surface.ts +269 -0
- package/templates/collectathon/src/render/touch-controls.ts +179 -0
- package/templates/collectathon/src/render/touch-layout.ts +48 -0
- package/templates/collectathon/src/render/water.ts +191 -0
- package/templates/collectathon/src/scenes/Play.ts +481 -0
- package/templates/collectathon/src/state.ts +38 -0
- package/templates/collectathon/src/style.css +106 -0
- package/templates/collectathon/src/ui/App.tsx +22 -0
- package/templates/collectathon/src/ui/GameUi.tsx +20 -0
- package/templates/collectathon/src/ui/Hud.tsx +77 -0
- package/templates/collectathon/src/ui/Menu.tsx +13 -0
- package/templates/collectathon/src/ui/main.tsx +14 -0
- package/templates/collectathon/tailwind.config.ts +2 -0
- package/templates/collectathon/threenative.config.ts +62 -0
- package/templates/collectathon/tsconfig.json +17 -0
- package/templates/collectathon/vite.config.ts +49 -0
- package/templates/kart/.codex/config.toml +23 -0
- package/templates/kart/.cursor/mcp.json +38 -0
- package/templates/kart/.gemini/settings.json +38 -0
- package/templates/kart/.mcp.json +38 -0
- package/templates/kart/.vscode/mcp.json +43 -0
- package/templates/kart/.zed/settings.json +43 -0
- package/templates/kart/AGENTS.md +58 -0
- package/templates/kart/CLAUDE.md +60 -0
- package/templates/kart/index.html +14 -0
- package/templates/kart/kit.json +8 -0
- package/templates/kart/native-playtests/survives.playtest.json +65 -0
- package/templates/kart/opencode.json +49 -0
- package/templates/kart/package.json +64 -0
- package/templates/kart/playtests/drift.playtest.json +226 -0
- package/templates/kart/playtests/explore.playtest.json +45 -0
- package/templates/kart/playtests/hit-stays-above-road.playtest.json +92 -0
- package/templates/kart/playtests/item-key.playtest.json +108 -0
- package/templates/kart/playtests/items.playtest.json +143 -0
- package/templates/kart/playtests/lap-times.playtest.json +138 -0
- package/templates/kart/playtests/laps.playtest.json +149 -0
- package/templates/kart/playtests/performance.playtest.json +57 -0
- package/templates/kart/playtests/race.playtest.json +294 -0
- package/templates/kart/playtests/restart.playtest.json +87 -0
- package/templates/kart/playtests/rocket-start.playtest.json +56 -0
- package/templates/kart/playtests/smooth-drive.playtest.json +101 -0
- package/templates/kart/playtests/surfaces.playtest.json +113 -0
- package/templates/kart/playtests/survives.playtest.json +116 -0
- package/templates/kart/playtests/wall.playtest.json +118 -0
- package/templates/kart/public/favicon.svg +4 -0
- package/templates/kart/src/entities/Driver.ts +123 -0
- package/templates/kart/src/entities/Items.ts +194 -0
- package/templates/kart/src/entities/Kart.ts +517 -0
- package/templates/kart/src/game.ts +45 -0
- package/templates/kart/src/main.ts +14 -0
- package/templates/kart/src/playtest-events.ts +15 -0
- package/templates/kart/src/render/camera.ts +83 -0
- package/templates/kart/src/render/course.ts +579 -0
- package/templates/kart/src/render/effects.ts +266 -0
- package/templates/kart/src/render/items.ts +163 -0
- package/templates/kart/src/render/kart.ts +256 -0
- package/templates/kart/src/render/kitExposure.ts +20 -0
- package/templates/kart/src/render/lighting.ts +58 -0
- package/templates/kart/src/render/loading.ts +332 -0
- package/templates/kart/src/render/materials.ts +119 -0
- package/templates/kart/src/render/palette.ts +74 -0
- package/templates/kart/src/render/postprocessing.ts +79 -0
- package/templates/kart/src/render/quality.ts +54 -0
- package/templates/kart/src/render/skids.ts +86 -0
- package/templates/kart/src/render/sky.ts +105 -0
- package/templates/kart/src/render/touch-controls.ts +168 -0
- package/templates/kart/src/render/touch-layout.ts +48 -0
- package/templates/kart/src/scenes/Race.ts +850 -0
- package/templates/kart/src/state.ts +53 -0
- package/templates/kart/src/style.css +106 -0
- package/templates/kart/src/track/Course.ts +276 -0
- package/templates/kart/src/track/Race.ts +133 -0
- package/templates/kart/src/ui/App.tsx +21 -0
- package/templates/kart/src/ui/GameUi.tsx +20 -0
- package/templates/kart/src/ui/Hud.tsx +172 -0
- package/templates/kart/src/ui/Menu.tsx +13 -0
- package/templates/kart/src/ui/main.tsx +14 -0
- package/templates/kart/tailwind.config.ts +2 -0
- package/templates/kart/threenative.config.ts +62 -0
- package/templates/kart/tsconfig.json +17 -0
- package/templates/kart/vite.config.ts +49 -0
- package/templates/minimal/.codex/config.toml +6 -2
- package/templates/minimal/.cursor/mcp.json +8 -2
- package/templates/minimal/.gemini/settings.json +8 -2
- package/templates/minimal/.mcp.json +8 -2
- package/templates/minimal/.vscode/mcp.json +9 -2
- package/templates/minimal/.zed/settings.json +9 -2
- package/templates/minimal/AGENTS.md +11 -13
- package/templates/minimal/CLAUDE.md +11 -13
- package/templates/minimal/opencode.json +10 -2
- package/templates/minimal/package.json +14 -9
- package/templates/minimal/playtests/camera-wall.playtest.json +36 -0
- package/templates/minimal/playtests/jump.playtest.json +45 -0
- package/templates/minimal/playtests/play.playtest.json +1 -1
- package/templates/minimal/src/game.ts +2 -0
- package/templates/minimal/src/render/atmosphere.ts +444 -0
- package/templates/minimal/src/render/backlightMaterial.ts +49 -18
- package/templates/minimal/src/render/camera.ts +35 -4
- package/templates/minimal/src/render/clouds.ts +605 -0
- package/templates/minimal/src/render/exposure.ts +7 -111
- package/templates/minimal/src/render/gpuSky.ts +752 -0
- package/templates/minimal/src/render/lighting.ts +26 -4
- package/templates/minimal/src/render/materialLighting.ts +2 -10
- package/templates/minimal/src/render/postprocessing.ts +4 -4
- package/templates/minimal/src/render/quality.ts +10 -116
- package/templates/minimal/src/render/sky.ts +73 -1
- package/templates/minimal/src/scenes/Play.ts +18 -7
- package/templates/platformer/.codex/config.toml +6 -2
- package/templates/platformer/.cursor/mcp.json +8 -2
- package/templates/platformer/.gemini/settings.json +8 -2
- package/templates/platformer/.mcp.json +8 -2
- package/templates/platformer/.vscode/mcp.json +9 -2
- package/templates/platformer/.zed/settings.json +9 -2
- package/templates/platformer/AGENTS.md +13 -9
- package/templates/platformer/CLAUDE.md +13 -9
- package/templates/platformer/opencode.json +10 -2
- package/templates/platformer/package.json +15 -10
- package/templates/platformer/playtests/dash-jump.playtest.json +34 -0
- package/templates/platformer/playtests/finish.playtest.json +58 -0
- package/templates/platformer/playtests/idle.playtest.json +44 -0
- package/templates/platformer/playtests/performance.playtest.json +1 -1
- package/templates/platformer/src/entities/Fox.ts +19 -6
- package/templates/platformer/src/game.ts +1 -0
- package/templates/platformer/src/level/Stage.ts +4 -1
- package/templates/platformer/src/render/backlightMaterial.ts +49 -18
- package/templates/platformer/src/render/camera.ts +30 -1
- package/templates/platformer/src/render/exposure.ts +6 -111
- package/templates/platformer/src/render/fox.ts +5 -2
- package/templates/platformer/src/render/kitExposure.ts +20 -0
- package/templates/platformer/src/render/materialLighting.ts +2 -11
- package/templates/platformer/src/render/postprocessing.ts +4 -4
- package/templates/platformer/src/render/props.ts +1 -2
- package/templates/platformer/src/render/quality.ts +10 -118
- package/templates/platformer/src/scenes/Play.ts +31 -15
- package/templates/platformer/src/ui/Menu.tsx +1 -1
- package/templates/puzzle/.codex/config.toml +6 -2
- package/templates/puzzle/.cursor/mcp.json +8 -2
- package/templates/puzzle/.gemini/settings.json +8 -2
- package/templates/puzzle/.mcp.json +8 -2
- package/templates/puzzle/.vscode/mcp.json +9 -2
- package/templates/puzzle/.zed/settings.json +9 -2
- package/templates/puzzle/AGENTS.md +14 -17
- package/templates/puzzle/CLAUDE.md +14 -17
- package/templates/puzzle/opencode.json +10 -2
- package/templates/puzzle/package.json +15 -10
- package/templates/puzzle/playtests/performance.playtest.json +1 -1
- package/templates/puzzle/playtests/replay-keeps-progress.playtest.json +78 -0
- package/templates/puzzle/src/render/backlightMaterial.ts +49 -18
- package/templates/puzzle/src/render/exposure.ts +11 -109
- package/templates/puzzle/src/render/lighting.ts +3 -3
- package/templates/puzzle/src/render/materialLighting.ts +2 -11
- package/templates/puzzle/src/render/palette.ts +1 -1
- package/templates/puzzle/src/render/postprocessing.ts +4 -4
- package/templates/puzzle/src/render/quality.ts +44 -153
- package/templates/puzzle/src/render/vault.ts +18 -6
- package/templates/puzzle/src/scenes/Play.ts +6 -1
- package/templates/puzzle/src/ui/Hud.tsx +8 -43
- package/templates/racing/.codex/config.toml +6 -2
- package/templates/racing/.cursor/mcp.json +8 -2
- package/templates/racing/.gemini/settings.json +8 -2
- package/templates/racing/.mcp.json +8 -2
- package/templates/racing/.vscode/mcp.json +9 -2
- package/templates/racing/.zed/settings.json +9 -2
- package/templates/racing/AGENTS.md +10 -12
- package/templates/racing/CLAUDE.md +10 -12
- package/templates/racing/opencode.json +10 -2
- package/templates/racing/package.json +15 -10
- package/templates/racing/playtests/brake.playtest.json +54 -0
- package/templates/racing/playtests/outcome.playtest.json +19 -0
- package/templates/racing/playtests/performance.playtest.json +1 -1
- package/templates/racing/playtests/stopped-car-is-not-rescued.playtest.json +59 -0
- package/templates/racing/src/entities/RacingCar.ts +12 -3
- package/templates/racing/src/entities/Rival.ts +11 -2
- package/templates/racing/src/render/atmosphere.ts +444 -0
- package/templates/racing/src/render/backlightMaterial.ts +49 -18
- package/templates/racing/src/render/clouds.ts +605 -0
- package/templates/racing/src/render/exposure.ts +6 -111
- package/templates/racing/src/render/gpuSky.ts +752 -0
- package/templates/racing/src/render/kitExposure.ts +20 -0
- package/templates/racing/src/render/lighting.ts +26 -4
- package/templates/racing/src/render/materialLighting.ts +2 -11
- package/templates/racing/src/render/materials.ts +2 -1
- package/templates/racing/src/render/postprocessing.ts +4 -4
- package/templates/racing/src/render/quality.ts +27 -115
- package/templates/racing/src/render/sky.ts +72 -1
- package/templates/racing/src/scenes/Race.ts +9 -7
- package/templates/racing/src/track/TrackSector.ts +5 -2
- package/templates/racing/src/ui/Hud.tsx +12 -7
- package/templates/rain/.codex/config.toml +6 -2
- package/templates/rain/.cursor/mcp.json +8 -2
- package/templates/rain/.gemini/settings.json +8 -2
- package/templates/rain/.mcp.json +8 -2
- package/templates/rain/.vscode/mcp.json +9 -2
- package/templates/rain/.zed/settings.json +9 -2
- package/templates/rain/AGENTS.md +12 -12
- package/templates/rain/CLAUDE.md +12 -12
- package/templates/rain/opencode.json +10 -2
- package/templates/rain/package.json +14 -9
- package/templates/rain/playtests/performance.playtest.json +1 -1
- package/templates/rain/src/game.ts +1 -1
- package/templates/rain/src/render/bloom-shader.ts +1 -1
- package/templates/rain/src/render/clouds-shader.ts +2 -2
- package/templates/rain/src/render/clouds.ts +2 -1
- package/templates/rain/src/render/exposure.ts +11 -109
- package/templates/rain/src/render/post-shader.ts +7 -11
- package/templates/rain/src/render/postprocessing.ts +8 -24
- package/templates/rain/src/render/quality.ts +44 -98
- package/templates/rain/src/render/world-shader.ts +281 -97
- package/templates/rain/src/render/world.ts +82 -2
- package/templates/rain/src/style.css +1 -1
- package/templates/rain/src/ui/GameUi.tsx +6 -2
- package/templates/rain/src/ui/Hud.tsx +1 -1
- package/templates/rain/tools/generate-shaders.mjs +2 -2
- package/templates/rain/tools/tempest-post.frag +4 -6
- package/templates/rain/tools/tempest-world.frag +80 -12
- package/templates/rts/.codex/config.toml +6 -2
- package/templates/rts/.cursor/mcp.json +8 -2
- package/templates/rts/.gemini/settings.json +8 -2
- package/templates/rts/.mcp.json +8 -2
- package/templates/rts/.vscode/mcp.json +9 -2
- package/templates/rts/.zed/settings.json +9 -2
- package/templates/rts/AGENTS.md +15 -16
- package/templates/rts/CLAUDE.md +15 -16
- package/templates/rts/opencode.json +10 -2
- package/templates/rts/package.json +14 -9
- package/templates/rts/playtests/performance.playtest.json +1 -1
- package/templates/rts/playtests/rts-attack.playtest.json +5 -0
- package/templates/rts/playtests/rts-build.playtest.json +20 -1
- package/templates/rts/playtests/rts-orders.playtest.json +1 -1
- package/templates/rts/playtests/rts-pause.playtest.json +112 -0
- package/templates/rts/playtests/rts-train.playtest.json +1 -1
- package/templates/rts/playtests/rts-zoom.playtest.json +81 -0
- package/templates/rts/src/game.ts +29 -7
- package/templates/rts/src/render/army.ts +181 -49
- package/templates/rts/src/render/backlightMaterial.ts +49 -18
- package/templates/rts/src/render/environment.ts +276 -0
- package/templates/rts/src/render/exposure.ts +3 -65
- package/templates/rts/src/render/ground.ts +478 -0
- package/templates/rts/src/render/lighting.ts +62 -11
- package/templates/rts/src/render/materialLighting.ts +2 -11
- package/templates/rts/src/render/materials.ts +47 -118
- package/templates/rts/src/render/palette.ts +30 -13
- package/templates/rts/src/render/picking.ts +18 -0
- package/templates/rts/src/render/postprocessing.ts +4 -4
- package/templates/rts/src/render/quality.ts +64 -85
- package/templates/rts/src/render/resources.ts +21 -22
- package/templates/rts/src/render/sky.ts +9 -12
- package/templates/rts/src/render/terrain.ts +36 -11
- package/templates/rts/src/scenes/Play.ts +373 -38
- package/templates/rts/src/sim/ai.ts +0 -11
- package/templates/rts/src/state.ts +46 -0
- package/templates/rts/src/style.css +1543 -0
- package/templates/rts/src/ui/Commands.tsx +204 -107
- package/templates/rts/src/ui/GameUi.tsx +12 -5
- package/templates/rts/src/ui/Hud.tsx +611 -116
- package/templates/rts/src/ui/Minimap.tsx +103 -37
- package/templates/rts/src/ui/icons.tsx +116 -0
- package/templates/rts/src/ui/labels.ts +73 -0
- package/templates/rts/src/ui/minimapPoint.ts +30 -0
- package/templates/rts/threenative.config.ts +1 -1
- package/templates/runner/.codex/config.toml +6 -2
- package/templates/runner/.cursor/mcp.json +8 -2
- package/templates/runner/.gemini/settings.json +8 -2
- package/templates/runner/.mcp.json +8 -2
- package/templates/runner/.vscode/mcp.json +9 -2
- package/templates/runner/.zed/settings.json +9 -2
- package/templates/runner/AGENTS.md +12 -12
- package/templates/runner/CLAUDE.md +12 -12
- package/templates/runner/opencode.json +10 -2
- package/templates/runner/package.json +15 -10
- package/templates/runner/playtests/near-miss.playtest.json +48 -0
- package/templates/runner/playtests/performance.playtest.json +2 -2
- package/templates/runner/playtests/stride.playtest.json +27 -0
- package/templates/runner/playtests/survives.playtest.json +2 -2
- package/templates/runner/src/conventions.ts +3 -1
- package/templates/runner/src/entities/Runner.ts +11 -5
- package/templates/runner/src/render/atmosphere.ts +444 -0
- package/templates/runner/src/render/backlightMaterial.ts +49 -18
- package/templates/runner/src/render/clouds.ts +605 -0
- package/templates/runner/src/render/exposure.ts +6 -111
- package/templates/runner/src/render/gpuSky.ts +752 -0
- package/templates/runner/src/render/kitExposure.ts +20 -0
- package/templates/runner/src/render/lighting.ts +26 -4
- package/templates/runner/src/render/materialLighting.ts +2 -11
- package/templates/runner/src/render/postprocessing.ts +4 -4
- package/templates/runner/src/render/quality.ts +26 -114
- package/templates/runner/src/render/sky.ts +73 -1
- package/templates/runner/src/scenes/Run.ts +19 -15
- package/templates/runner/src/track.ts +12 -3
- package/templates/sailing/.codex/config.toml +6 -2
- package/templates/sailing/.cursor/mcp.json +8 -2
- package/templates/sailing/.gemini/settings.json +8 -2
- package/templates/sailing/.mcp.json +8 -2
- package/templates/sailing/.vscode/mcp.json +9 -2
- package/templates/sailing/.zed/settings.json +9 -2
- package/templates/sailing/AGENTS.md +10 -11
- package/templates/sailing/CLAUDE.md +10 -11
- package/templates/sailing/opencode.json +10 -2
- package/templates/sailing/package.json +15 -10
- package/templates/sailing/playtests/fail.playtest.json +46 -5
- package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +7 -0
- package/templates/sailing/playtests/performance.playtest.json +1 -1
- package/templates/sailing/src/game.ts +1 -0
- package/templates/sailing/src/render/backlightMaterial.ts +49 -18
- package/templates/sailing/src/render/exposure.ts +6 -111
- package/templates/sailing/src/render/kitExposure.ts +20 -0
- package/templates/sailing/src/render/materialLighting.ts +2 -11
- package/templates/sailing/src/render/ocean.ts +0 -1
- package/templates/sailing/src/render/postprocessing.ts +4 -4
- package/templates/sailing/src/render/quality.ts +31 -138
- package/templates/sailing/src/scenes/Sailing.ts +12 -4
- package/templates/sailing/src/ui/Hud.tsx +6 -2
- package/templates/sailing/src/ui/Menu.tsx +1 -1
- package/templates/shooter/.codex/config.toml +6 -2
- package/templates/shooter/.cursor/mcp.json +8 -2
- package/templates/shooter/.gemini/settings.json +8 -2
- package/templates/shooter/.mcp.json +8 -2
- package/templates/shooter/.vscode/mcp.json +9 -2
- package/templates/shooter/.zed/settings.json +9 -2
- package/templates/shooter/AGENTS.md +13 -12
- package/templates/shooter/CLAUDE.md +13 -12
- package/templates/shooter/index.html +1 -1
- package/templates/shooter/main.html +13 -0
- package/templates/shooter/opencode.json +10 -2
- package/templates/shooter/package.json +15 -10
- package/templates/shooter/playtests/breakable-shatters.playtest.json +6 -0
- package/templates/shooter/playtests/enemy-body-is-a-body.playtest.json +6 -0
- package/templates/shooter/playtests/hands-authored-rate.playtest.json +54 -0
- package/templates/shooter/playtests/movement-eases.playtest.json +53 -0
- package/templates/shooter/playtests/performance.playtest.json +3 -3
- package/templates/shooter/playtests/stairs-smooth-the-eye.playtest.json +56 -0
- package/templates/shooter/playtests/weapon-sharp-while-turning.playtest.json +206 -0
- package/templates/shooter/src/entities/Breakables.ts +34 -10
- package/templates/shooter/src/entities/Enemy.ts +176 -54
- package/templates/shooter/src/entities/FpsPlayer.ts +55 -16
- package/templates/shooter/src/entities/Rifle.ts +83 -9
- package/templates/shooter/src/entities/movement.ts +96 -0
- package/templates/shooter/src/render/atmosphere.ts +444 -0
- package/templates/shooter/src/render/backlightMaterial.ts +49 -18
- package/templates/shooter/src/render/camera.ts +3 -1
- package/templates/shooter/src/render/clouds.ts +605 -0
- package/templates/shooter/src/render/exposure.ts +10 -109
- package/templates/shooter/src/render/facade.ts +26 -68
- package/templates/shooter/src/render/gpuSky.ts +752 -0
- package/templates/shooter/src/render/lighting.ts +27 -4
- package/templates/shooter/src/render/materialAssignments.ts +9 -1
- package/templates/shooter/src/render/materialLighting.ts +2 -11
- package/templates/shooter/src/render/occlusion.ts +13 -4
- package/templates/shooter/src/render/palette.ts +1 -0
- package/templates/shooter/src/render/postprocessing.ts +4 -4
- package/templates/shooter/src/render/quality.ts +50 -108
- package/templates/shooter/src/render/scale.ts +0 -11
- package/templates/shooter/src/render/sky.ts +103 -2
- package/templates/shooter/src/render/surface.ts +140 -0
- package/templates/shooter/src/render/town.ts +3 -6
- package/templates/shooter/src/render/townMaterials.ts +95 -42
- package/templates/shooter/src/render/vehicles.ts +2 -0
- package/templates/shooter/src/scenes/Play.ts +83 -23
- package/templates/shooter/src/ui/Hud.tsx +268 -193
- package/templates/shooter/src/worker-page.ts +29 -0
- package/templates/shooter/src/worker.ts +5 -0
- package/templates/shooter/threenative.config.ts +3 -0
- package/templates/shooter/vite.config.ts +2 -0
- package/templates/snow/.codex/config.toml +6 -2
- package/templates/snow/.cursor/mcp.json +8 -2
- package/templates/snow/.gemini/settings.json +8 -2
- package/templates/snow/.mcp.json +8 -2
- package/templates/snow/.vscode/mcp.json +9 -2
- package/templates/snow/.zed/settings.json +9 -2
- package/templates/snow/AGENTS.md +12 -10
- package/templates/snow/CLAUDE.md +12 -10
- package/templates/snow/opencode.json +10 -2
- package/templates/snow/package.json +15 -10
- package/templates/snow/playtests/performance.playtest.json +1 -1
- package/templates/snow/src/render/backlightMaterial.ts +49 -18
- package/templates/snow/src/render/exposure.ts +17 -106
- package/templates/snow/src/render/materialLighting.ts +2 -11
- package/templates/snow/src/render/postprocessing.ts +11 -5
- package/templates/snow/src/render/quality.ts +46 -126
- package/templates/snow/src/render/snowSurface.ts +32 -15
- package/templates/snow/src/scenes/Snow.ts +2 -1
- package/templates/starter/.codex/config.toml +6 -2
- package/templates/starter/.cursor/mcp.json +8 -2
- package/templates/starter/.gemini/settings.json +8 -2
- package/templates/starter/.mcp.json +8 -2
- package/templates/starter/.vscode/mcp.json +9 -2
- package/templates/starter/.zed/settings.json +9 -2
- package/templates/starter/AGENTS.md +18 -14
- package/templates/starter/CLAUDE.md +18 -14
- package/templates/starter/index.html +1 -1
- package/templates/starter/main.html +12 -0
- package/templates/starter/native-playtests/react-hud.playtest.json +1 -0
- package/templates/starter/native-playtests/render-chain.playtest.json +34 -21
- package/templates/starter/opencode.json +10 -2
- package/templates/starter/package.json +15 -10
- package/templates/starter/playtests/play.playtest.json +22 -2
- package/templates/starter/playtests/production-readiness.playtest.json +14 -0
- package/templates/starter/src/entities/Crate.ts +19 -1
- package/templates/starter/src/render/arena.ts +2 -2
- package/templates/starter/src/render/atmosphere.ts +444 -0
- package/templates/starter/src/render/backlightMaterial.ts +49 -18
- package/templates/starter/src/render/camera.ts +28 -0
- package/templates/starter/src/render/clouds.ts +605 -0
- package/templates/starter/src/render/contactShadow.ts +50 -0
- package/templates/starter/src/render/exposure.ts +9 -111
- package/templates/starter/src/render/gpuSky.ts +752 -0
- package/templates/starter/src/render/grade.ts +1 -1
- package/templates/starter/src/render/lighting.ts +34 -6
- package/templates/starter/src/render/materialLighting.ts +2 -11
- package/templates/starter/src/render/postprocessing.ts +27 -14
- package/templates/starter/src/render/quality.ts +18 -147
- package/templates/starter/src/render/sky.ts +90 -40
- package/templates/starter/src/render/temporalAA.ts +1 -1
- package/templates/starter/src/render/temporalAAStage.ts +1 -1
- package/templates/starter/src/render/temporalCurrentFootprint.ts +0 -1
- package/templates/starter/src/render/temporalDetailStage.ts +106 -0
- package/templates/starter/src/render/temporalRejectionCounter.ts +2 -2
- package/templates/starter/src/render/volumetricFogCamera.ts +32 -0
- package/templates/starter/src/render/volumetricFogOptions.ts +7 -0
- package/templates/starter/src/render/volumetricFogTransport.ts +27 -19
- package/templates/starter/src/render/volumetricFogVolume.ts +31 -7
- package/templates/starter/src/scenes/Play.ts +11 -8
- package/templates/starter/src/ui/Hud.tsx +1 -1
- package/templates/starter/src/worker-page.ts +29 -0
- package/templates/starter/src/worker.ts +5 -0
- package/templates/starter/vite.config.ts +2 -0
- package/templates/tower-defense/.codex/config.toml +6 -2
- package/templates/tower-defense/.cursor/mcp.json +8 -2
- package/templates/tower-defense/.gemini/settings.json +8 -2
- package/templates/tower-defense/.mcp.json +8 -2
- package/templates/tower-defense/.vscode/mcp.json +9 -2
- package/templates/tower-defense/.zed/settings.json +9 -2
- package/templates/tower-defense/AGENTS.md +10 -12
- package/templates/tower-defense/CLAUDE.md +10 -12
- package/templates/tower-defense/opencode.json +10 -2
- package/templates/tower-defense/package.json +15 -10
- package/templates/tower-defense/playtests/chill-tint.playtest.json +387 -0
- package/templates/tower-defense/playtests/performance.playtest.json +1 -1
- package/templates/tower-defense/src/enemies/Enemy.ts +9 -0
- package/templates/tower-defense/src/render/backlightMaterial.ts +49 -18
- package/templates/tower-defense/src/render/exposure.ts +11 -109
- package/templates/tower-defense/src/render/lighting.ts +4 -2
- package/templates/tower-defense/src/render/materialLighting.ts +2 -11
- package/templates/tower-defense/src/render/postprocessing.ts +4 -4
- package/templates/tower-defense/src/render/quality.ts +10 -116
- package/templates/tower-defense/src/render/sky.ts +2 -2
- package/templates/tower-defense/src/scenes/Battle.ts +4 -0
- package/template-assets/autoExposure.ts +0 -225
- package/template-assets/exposureGraph.ts +0 -178
- package/template-assets/exposureReadback.ts +0 -79
- package/template-assets/worldEnvironment.ts +0 -1212
- package/templates/action-rpg/src/render/autoExposure.ts +0 -225
- package/templates/action-rpg/src/render/exposureGraph.ts +0 -178
- package/templates/action-rpg/src/render/exposureReadback.ts +0 -79
- package/templates/action-rpg/src/render/worldEnvironment.ts +0 -1212
- package/templates/minimal/src/render/autoExposure.ts +0 -225
- package/templates/minimal/src/render/exposureGraph.ts +0 -178
- package/templates/minimal/src/render/exposureReadback.ts +0 -79
- package/templates/minimal/src/render/worldEnvironment.ts +0 -1212
- package/templates/platformer/src/render/autoExposure.ts +0 -225
- package/templates/platformer/src/render/exposureGraph.ts +0 -178
- package/templates/platformer/src/render/exposureReadback.ts +0 -79
- package/templates/platformer/src/render/worldEnvironment.ts +0 -1212
- package/templates/puzzle/src/render/autoExposure.ts +0 -225
- package/templates/puzzle/src/render/exposureGraph.ts +0 -178
- package/templates/puzzle/src/render/exposureReadback.ts +0 -79
- package/templates/puzzle/src/render/worldEnvironment.ts +0 -1212
- package/templates/racing/src/render/autoExposure.ts +0 -225
- package/templates/racing/src/render/exposureGraph.ts +0 -178
- package/templates/racing/src/render/exposureReadback.ts +0 -79
- package/templates/racing/src/render/worldEnvironment.ts +0 -1212
- package/templates/rain/src/render/autoExposure.ts +0 -225
- package/templates/rain/src/render/exposureGraph.ts +0 -178
- package/templates/rain/src/render/exposureReadback.ts +0 -79
- package/templates/rain/src/render/worldEnvironment.ts +0 -1212
- package/templates/rts/src/render/autoExposure.ts +0 -225
- package/templates/rts/src/render/exposureGraph.ts +0 -178
- package/templates/rts/src/render/exposureReadback.ts +0 -79
- package/templates/rts/src/render/worldEnvironment.ts +0 -1212
- package/templates/runner/src/render/autoExposure.ts +0 -225
- package/templates/runner/src/render/exposureGraph.ts +0 -178
- package/templates/runner/src/render/exposureReadback.ts +0 -79
- package/templates/runner/src/render/worldEnvironment.ts +0 -1212
- package/templates/sailing/src/render/autoExposure.ts +0 -225
- package/templates/sailing/src/render/exposureGraph.ts +0 -178
- package/templates/sailing/src/render/exposureReadback.ts +0 -79
- package/templates/sailing/src/render/worldEnvironment.ts +0 -1212
- package/templates/shooter/src/render/autoExposure.ts +0 -225
- package/templates/shooter/src/render/exposureGraph.ts +0 -178
- package/templates/shooter/src/render/exposureReadback.ts +0 -79
- package/templates/shooter/src/render/worldEnvironment.ts +0 -1212
- package/templates/snow/src/render/autoExposure.ts +0 -225
- package/templates/snow/src/render/exposureGraph.ts +0 -178
- package/templates/snow/src/render/exposureReadback.ts +0 -79
- package/templates/snow/src/render/worldEnvironment.ts +0 -1212
- package/templates/starter/src/render/autoExposure.ts +0 -225
- package/templates/starter/src/render/exposureGraph.ts +0 -178
- package/templates/starter/src/render/exposureReadback.ts +0 -79
- package/templates/starter/src/render/worldEnvironment.ts +0 -1212
- package/templates/tower-defense/src/render/autoExposure.ts +0 -225
- package/templates/tower-defense/src/render/exposureGraph.ts +0 -178
- package/templates/tower-defense/src/render/exposureReadback.ts +0 -79
- package/templates/tower-defense/src/render/worldEnvironment.ts +0 -1212
|
@@ -0,0 +1,850 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GPUParticles3D,
|
|
3
|
+
type ICtx,
|
|
4
|
+
Scene,
|
|
5
|
+
type SceneFrame,
|
|
6
|
+
isMobile,
|
|
7
|
+
isTouchscreenAvailable,
|
|
8
|
+
qualityTiers,
|
|
9
|
+
} from "@threenative/core";
|
|
10
|
+
import { type DataTexture, Euler, type PerspectiveCamera, Vector3 } from "three";
|
|
11
|
+
import { Driver } from "../entities/Driver.js";
|
|
12
|
+
import { CourseItem, ITEM_FEEL, ItemSlot, drawItem } from "../entities/Items.js";
|
|
13
|
+
import { type IKartInput, Kart, idleInput } from "../entities/Kart.js";
|
|
14
|
+
import { emitPlaytestEvent } from "../playtest-events.js";
|
|
15
|
+
import { createChaseCamera } from "../render/camera.js";
|
|
16
|
+
import { buildCourseView, makeRng } from "../render/course.js";
|
|
17
|
+
import { BURSTS, EFFECTS } from "../render/effects.js";
|
|
18
|
+
import { ItemBoxes, acornMesh, burrMesh } from "../render/items.js";
|
|
19
|
+
import { KartModel, LIVERIES } from "../render/kart.js";
|
|
20
|
+
import { setupLighting } from "../render/lighting.js";
|
|
21
|
+
import { createLoadingScreen } from "../render/loading.js";
|
|
22
|
+
import { postTier, setupPost } from "../render/postprocessing.js";
|
|
23
|
+
import { SkidMarks } from "../render/skids.js";
|
|
24
|
+
import { setupSky, skyTexture } from "../render/sky.js";
|
|
25
|
+
import { TouchControls } from "../render/touch-controls.js";
|
|
26
|
+
import type { GameState, IMapDot, IResult } from "../state.js";
|
|
27
|
+
import { type ICourse, buildCourse } from "../track/Course.js";
|
|
28
|
+
import { RACE, Racer, rank } from "../track/Race.js";
|
|
29
|
+
|
|
30
|
+
export type GameCtx = ICtx<GameState>;
|
|
31
|
+
|
|
32
|
+
/** One corner of a kart's box at a time, for the sink meter; reused so a step allocates nothing. */
|
|
33
|
+
const scratchCorner = new Vector3();
|
|
34
|
+
/** Seconds from the scene's start to GO: "READY", then the three lamps. */
|
|
35
|
+
const GO_AT = RACE.ready + RACE.light * RACE.lights;
|
|
36
|
+
/** A kart's bump footprint, metres: an ellipse this long and this wide around its centre (the model is 2.15 m by 1.4 m). */
|
|
37
|
+
const BUMP = { length: 2.2, width: 1.5 } as const;
|
|
38
|
+
/** Effects are drawn for karts within this many metres of the camera. */
|
|
39
|
+
const EFFECT_RANGE = 90;
|
|
40
|
+
const POOL = { burrs: ITEM_FEEL.maxBurrs, acorns: 6 } as const;
|
|
41
|
+
|
|
42
|
+
/** A per-frame shake meter: the previous two samples and the worst frame-to-frame step this run. */
|
|
43
|
+
interface IShake {
|
|
44
|
+
y: number;
|
|
45
|
+
y2: number;
|
|
46
|
+
/** The camera's height relative to the kart, player only. */
|
|
47
|
+
offset: number;
|
|
48
|
+
offset2: number;
|
|
49
|
+
/** The rendered model's pitch and roll, radians. */
|
|
50
|
+
pitch: number;
|
|
51
|
+
roll: number;
|
|
52
|
+
/** Frames to skip after leaving the ground: a hop's arc is not a shake. */
|
|
53
|
+
air: number;
|
|
54
|
+
maxY: number;
|
|
55
|
+
maxOffset: number;
|
|
56
|
+
/** Worst frame-to-frame pitch and roll change, degrees. */
|
|
57
|
+
maxPitch: number;
|
|
58
|
+
maxRoll: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A kart in the field: the model, its place in the race, its hand on the wheel and its item. */
|
|
62
|
+
interface IEntrant {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly kart: Kart;
|
|
65
|
+
readonly model: KartModel;
|
|
66
|
+
readonly racer: Racer;
|
|
67
|
+
readonly driver: Driver;
|
|
68
|
+
readonly slot: ItemSlot;
|
|
69
|
+
readonly player: boolean;
|
|
70
|
+
/** CPU: seconds until it uses the item in hand. */
|
|
71
|
+
useIn: number;
|
|
72
|
+
onPad: boolean;
|
|
73
|
+
padHits: number;
|
|
74
|
+
boxes: number;
|
|
75
|
+
/** Seconds the kart has been slower than 1.5 m/s while racing, the worst stretch kept. */
|
|
76
|
+
stuck: number;
|
|
77
|
+
stuckWorst: number;
|
|
78
|
+
sparkClock: number;
|
|
79
|
+
wallClock: number;
|
|
80
|
+
/** Every item this kart used, in order, for the scenarios. */
|
|
81
|
+
used: string[];
|
|
82
|
+
/** Worst depth, metres, the model's world box reached below the road under the kart this run. */
|
|
83
|
+
lowestPointBelowRoad: number;
|
|
84
|
+
readonly shake: IShake;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The sample nearest a world point, height included, so the bridge and the road under it differ. */
|
|
88
|
+
function locate(course: ICourse, x: number, y: number, z: number): number {
|
|
89
|
+
let best = 0;
|
|
90
|
+
let bestD = Number.POSITIVE_INFINITY;
|
|
91
|
+
for (let i = 0; i < course.count; i += 1) {
|
|
92
|
+
const d =
|
|
93
|
+
(x - (course.x[i] ?? 0)) ** 2 +
|
|
94
|
+
(z - (course.z[i] ?? 0)) ** 2 +
|
|
95
|
+
(3 * (y - (course.y[i] ?? 0))) ** 2;
|
|
96
|
+
if (d < bestD) {
|
|
97
|
+
bestD = d;
|
|
98
|
+
best = i;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return best;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class Race extends Scene<GameState> {
|
|
105
|
+
static override readonly initialState: GameState = {
|
|
106
|
+
autopilot: false,
|
|
107
|
+
countdown: 4,
|
|
108
|
+
driftStage: 0,
|
|
109
|
+
finishedCount: 0,
|
|
110
|
+
item: "",
|
|
111
|
+
lap: 1,
|
|
112
|
+
lapTimes: [],
|
|
113
|
+
laps: RACE.laps,
|
|
114
|
+
mapDots: [],
|
|
115
|
+
mapPath: "",
|
|
116
|
+
paused: false,
|
|
117
|
+
phase: "countdown",
|
|
118
|
+
place: 8,
|
|
119
|
+
racers: 8,
|
|
120
|
+
results: [],
|
|
121
|
+
speed: 0,
|
|
122
|
+
time: 0,
|
|
123
|
+
toast: "",
|
|
124
|
+
uiReady: false,
|
|
125
|
+
wrongWay: false,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
#sky: DataTexture | undefined;
|
|
129
|
+
#fill: DataTexture | undefined;
|
|
130
|
+
#course: ICourse | undefined;
|
|
131
|
+
#view: ReturnType<typeof buildCourseView> | undefined;
|
|
132
|
+
#field: IEntrant[] = [];
|
|
133
|
+
#items: CourseItem[] = [];
|
|
134
|
+
#boxes: ItemBoxes | undefined;
|
|
135
|
+
#post: ReturnType<typeof setupPost> | undefined;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Everything a scenario can place is built and registered here: `setup.place` is applied after
|
|
139
|
+
* `load()` and before `enter()`, so a kart or an item placed by a scenario is read back there.
|
|
140
|
+
*/
|
|
141
|
+
override load(ctx: GameCtx): void {
|
|
142
|
+
this.#sky = skyTexture();
|
|
143
|
+
this.#fill = skyTexture(0.3, 128);
|
|
144
|
+
setupSky(ctx.scene, this.#sky, this.#fill);
|
|
145
|
+
const course = buildCourse();
|
|
146
|
+
const view = buildCourseView(course);
|
|
147
|
+
this.#course = course;
|
|
148
|
+
this.#view = view;
|
|
149
|
+
ctx.add(view.group);
|
|
150
|
+
ctx.entities.add("course", {
|
|
151
|
+
debug: () => ({ ...view.audit, count: course.count, length: course.length }),
|
|
152
|
+
});
|
|
153
|
+
this.#boxes = new ItemBoxes(course, view.group);
|
|
154
|
+
|
|
155
|
+
// The grid: two abreast, staggered, behind the line. The player starts last, as in a cup's
|
|
156
|
+
// first race; the CPUs fill the slots ahead.
|
|
157
|
+
const field: IEntrant[] = [];
|
|
158
|
+
LIVERIES.forEach((livery, i) => {
|
|
159
|
+
const player = i === 0;
|
|
160
|
+
const slot = player ? 7 : i - 1;
|
|
161
|
+
const kart = new Kart(course);
|
|
162
|
+
kart.place(
|
|
163
|
+
course.count - 5 - Math.floor(slot / 2) * 6 - (slot % 2) * 3,
|
|
164
|
+
slot % 2 === 0 ? -3 : 3,
|
|
165
|
+
);
|
|
166
|
+
const model = new KartModel(livery);
|
|
167
|
+
model.update(kart, 0, 0);
|
|
168
|
+
ctx.add(model.root);
|
|
169
|
+
// Draw the model between fixed ticks, as the camera already is: a model that only steps
|
|
170
|
+
// stands a whole tick in front of the smoothed chase camera and snaps back every render.
|
|
171
|
+
ctx.interpolate(model.root);
|
|
172
|
+
const entrant: IEntrant = {
|
|
173
|
+
boxes: 0,
|
|
174
|
+
driver: new Driver(kart, slot % 2 === 0 ? -3 : 3, 0.5 + (i % 4) * 0.04),
|
|
175
|
+
kart,
|
|
176
|
+
lowestPointBelowRoad: 0,
|
|
177
|
+
model,
|
|
178
|
+
name: player ? "player" : `cpu.${i}`,
|
|
179
|
+
onPad: false,
|
|
180
|
+
padHits: 0,
|
|
181
|
+
player,
|
|
182
|
+
racer: new Racer(livery.name, kart, course.checkpoints),
|
|
183
|
+
shake: {
|
|
184
|
+
air: 0,
|
|
185
|
+
maxOffset: 0,
|
|
186
|
+
maxPitch: 0,
|
|
187
|
+
maxRoll: 0,
|
|
188
|
+
maxY: 0,
|
|
189
|
+
offset: 0,
|
|
190
|
+
offset2: 0,
|
|
191
|
+
pitch: model.root.rotation.x,
|
|
192
|
+
roll: model.root.rotation.z,
|
|
193
|
+
y: kart.y,
|
|
194
|
+
y2: kart.y,
|
|
195
|
+
},
|
|
196
|
+
slot: new ItemSlot(),
|
|
197
|
+
sparkClock: 0,
|
|
198
|
+
stuck: 0,
|
|
199
|
+
stuckWorst: 0,
|
|
200
|
+
useIn: 0,
|
|
201
|
+
used: [],
|
|
202
|
+
wallClock: 0,
|
|
203
|
+
};
|
|
204
|
+
field.push(entrant);
|
|
205
|
+
ctx.entities.add(entrant.name, {
|
|
206
|
+
debug: () => ({
|
|
207
|
+
...kart.counts,
|
|
208
|
+
airborne: kart.airborne,
|
|
209
|
+
backCrossings: entrant.racer.backCrossings,
|
|
210
|
+
boostLift: kart.boostPeak / kart.topSpeed,
|
|
211
|
+
boostSeconds: kart.boostSeconds,
|
|
212
|
+
boostTicks: kart.boostTicks,
|
|
213
|
+
boxes: entrant.boxes,
|
|
214
|
+
drag: kart.drag,
|
|
215
|
+
driftSide: kart.driftSide,
|
|
216
|
+
driftStage: kart.driftStage,
|
|
217
|
+
driftEntrySpeed: kart.driftEntrySpeed,
|
|
218
|
+
stageLog: kart.driftStages.join(","),
|
|
219
|
+
drifting: kart.drifting,
|
|
220
|
+
finished: entrant.racer.finished,
|
|
221
|
+
groundGap: kart.y - course.heightAt(kart.index, kart.x, kart.z),
|
|
222
|
+
finishTime: entrant.racer.finishTime,
|
|
223
|
+
hit: kart.hit,
|
|
224
|
+
hitSeconds: kart.hitSeconds,
|
|
225
|
+
index: kart.index,
|
|
226
|
+
item: entrant.slot.held ?? (entrant.slot.rolling ? "rolling" : ""),
|
|
227
|
+
itemDraws: entrant.slot.draws,
|
|
228
|
+
lap: entrant.racer.lap,
|
|
229
|
+
lateral: kart.lateral,
|
|
230
|
+
lowestPointBelowRoad: entrant.lowestPointBelowRoad,
|
|
231
|
+
longestAir: kart.longestAir,
|
|
232
|
+
maxLateral: kart.maxLateral,
|
|
233
|
+
maxJump: entrant.racer.maxJump,
|
|
234
|
+
miniTurboTicks: kart.miniTurboTicks,
|
|
235
|
+
name: entrant.racer.name,
|
|
236
|
+
next: entrant.racer.next,
|
|
237
|
+
padHits: entrant.padHits,
|
|
238
|
+
passed: entrant.racer.passed,
|
|
239
|
+
progress: entrant.racer.progress,
|
|
240
|
+
rank: entrant.racer.rank,
|
|
241
|
+
shakeCamera: entrant.shake.maxOffset,
|
|
242
|
+
shakePitch: entrant.shake.maxPitch,
|
|
243
|
+
shakeRoll: entrant.shake.maxRoll,
|
|
244
|
+
shakeY: entrant.shake.maxY,
|
|
245
|
+
settledGrass: kart.settled.grass,
|
|
246
|
+
settledRoad: kart.settled.road,
|
|
247
|
+
speed: kart.speed,
|
|
248
|
+
stuckWorst: entrant.stuckWorst,
|
|
249
|
+
surface: kart.surface,
|
|
250
|
+
throttle: kart.throttle,
|
|
251
|
+
topSpeed: kart.topSpeed,
|
|
252
|
+
turboPeak: kart.turboPeak,
|
|
253
|
+
wallAfter: kart.wallAfter,
|
|
254
|
+
wallHits: kart.wallHits,
|
|
255
|
+
wallInto: kart.wallInto,
|
|
256
|
+
wallThrottleDrop: kart.wallThrottleDrop,
|
|
257
|
+
wrongWay: entrant.racer.wrongWay,
|
|
258
|
+
used: entrant.used.join(","),
|
|
259
|
+
y: kart.y,
|
|
260
|
+
}),
|
|
261
|
+
object: model.root,
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
this.#field = field;
|
|
265
|
+
|
|
266
|
+
// Every burr and acorn is built now and parked under the course, so a scenario can place one.
|
|
267
|
+
const items: CourseItem[] = [];
|
|
268
|
+
const pool = (kind: "burr" | "acorn", count: number): void => {
|
|
269
|
+
for (let i = 0; i < count; i += 1) {
|
|
270
|
+
const item = new CourseItem(kind, kind === "burr" ? burrMesh() : acornMesh());
|
|
271
|
+
ctx.add(item.mesh);
|
|
272
|
+
ctx.entities.add(`${kind}.${i}`, {
|
|
273
|
+
debug: () => ({
|
|
274
|
+
active: item.active,
|
|
275
|
+
bounces: item.bounces,
|
|
276
|
+
hits: item.hits,
|
|
277
|
+
index: item.index,
|
|
278
|
+
}),
|
|
279
|
+
mesh: item.mesh,
|
|
280
|
+
});
|
|
281
|
+
items.push(item);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
pool("burr", POOL.burrs);
|
|
285
|
+
pool("acorn", POOL.acorns);
|
|
286
|
+
this.#items = items;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
override enter(ctx: GameCtx): SceneFrame<GameState> {
|
|
290
|
+
const course = this.#course;
|
|
291
|
+
const view = this.#view;
|
|
292
|
+
const boxes = this.#boxes;
|
|
293
|
+
if (
|
|
294
|
+
course === undefined ||
|
|
295
|
+
view === undefined ||
|
|
296
|
+
boxes === undefined ||
|
|
297
|
+
this.#sky === undefined
|
|
298
|
+
)
|
|
299
|
+
throw new Error("Race.enter ran before load() built the course.");
|
|
300
|
+
const field = this.#field;
|
|
301
|
+
const items = this.#items;
|
|
302
|
+
const player = field.find((entrant) => entrant.player);
|
|
303
|
+
if (player === undefined) throw new Error("Race.enter: the field has no player.");
|
|
304
|
+
setupSky(ctx.scene, this.#sky, this.#fill);
|
|
305
|
+
const environment = {
|
|
306
|
+
gpuClass: ctx.renderer.gpuClass?.class,
|
|
307
|
+
mobile: isMobile(),
|
|
308
|
+
software: ctx.renderer.softwareAdapter !== undefined,
|
|
309
|
+
};
|
|
310
|
+
const tier = postTier(environment);
|
|
311
|
+
const shadows = qualityTiers.shadow(tier).castShadows;
|
|
312
|
+
const lighting = setupLighting(
|
|
313
|
+
ctx.scene,
|
|
314
|
+
ctx.renderer.raw as Parameters<typeof setupLighting>[1],
|
|
315
|
+
shadows,
|
|
316
|
+
);
|
|
317
|
+
this.#post = setupPost(ctx.renderer, ctx.scene, ctx.camera, {
|
|
318
|
+
...environment,
|
|
319
|
+
godraysLight: lighting.key,
|
|
320
|
+
});
|
|
321
|
+
const camera = ctx.camera as PerspectiveCamera;
|
|
322
|
+
ctx.add(camera);
|
|
323
|
+
const loading = createLoadingScreen(ctx);
|
|
324
|
+
// The HUD is page UI the cover cannot hide, so it waits for the same readiness.
|
|
325
|
+
void ctx.startup.whenReady().then(() => ctx.state.set({ loaded: true }));
|
|
326
|
+
const touchControls =
|
|
327
|
+
isMobile() && isTouchscreenAvailable()
|
|
328
|
+
? ctx.entities.add("touch-controls", new TouchControls(camera))
|
|
329
|
+
: undefined;
|
|
330
|
+
|
|
331
|
+
// A scenario may have moved a kart or an item: read each back and put it on the course there.
|
|
332
|
+
const euler = new Euler();
|
|
333
|
+
for (const { kart, model, racer } of field) {
|
|
334
|
+
const root = model.root;
|
|
335
|
+
if (
|
|
336
|
+
Math.hypot(root.position.x - kart.x, root.position.z - kart.z) > 0.01 ||
|
|
337
|
+
Math.abs(euler.setFromQuaternion(root.quaternion, "YXZ").y - kart.yaw) > 1e-3
|
|
338
|
+
) {
|
|
339
|
+
const yaw = euler.setFromQuaternion(root.quaternion, "YXZ").y;
|
|
340
|
+
const index = locate(course, root.position.x, root.position.y, root.position.z);
|
|
341
|
+
const lateral = course.track(index, root.position.x, root.position.z).lateral;
|
|
342
|
+
kart.place(index, lateral);
|
|
343
|
+
kart.x = root.position.x;
|
|
344
|
+
kart.z = root.position.z;
|
|
345
|
+
kart.yaw = yaw;
|
|
346
|
+
kart.velocityYaw = yaw;
|
|
347
|
+
racer.resync();
|
|
348
|
+
}
|
|
349
|
+
model.update(kart, 0, 0);
|
|
350
|
+
}
|
|
351
|
+
for (const item of items) {
|
|
352
|
+
if (!item.placed) continue;
|
|
353
|
+
const p = item.mesh.position;
|
|
354
|
+
const index = locate(course, p.x, p.y, p.z);
|
|
355
|
+
p.y = course.y[index] ?? 0;
|
|
356
|
+
item.activate(
|
|
357
|
+
course,
|
|
358
|
+
index,
|
|
359
|
+
euler.setFromQuaternion(item.mesh.quaternion, "YXZ").y,
|
|
360
|
+
undefined,
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const rig = createChaseCamera(camera);
|
|
365
|
+
rig.snap(player.kart);
|
|
366
|
+
ctx.entities.add("camera-rig", { debug: () => rig.debug() });
|
|
367
|
+
// A scenario may have moved a kart above, so the shake meter starts from the placed pose.
|
|
368
|
+
for (const entrant of field) {
|
|
369
|
+
const s = entrant.shake;
|
|
370
|
+
s.air = 0;
|
|
371
|
+
s.maxOffset = 0;
|
|
372
|
+
s.maxPitch = 0;
|
|
373
|
+
s.maxRoll = 0;
|
|
374
|
+
s.maxY = 0;
|
|
375
|
+
s.pitch = entrant.model.root.rotation.x;
|
|
376
|
+
s.roll = entrant.model.root.rotation.z;
|
|
377
|
+
s.y = entrant.kart.y;
|
|
378
|
+
s.y2 = entrant.kart.y;
|
|
379
|
+
}
|
|
380
|
+
player.shake.offset = camera.position.y - player.kart.y;
|
|
381
|
+
player.shake.offset2 = player.shake.offset;
|
|
382
|
+
|
|
383
|
+
// Effects: five pooled emitters, every look parameter in `render/effects.ts`.
|
|
384
|
+
const make = (name: keyof typeof EFFECTS): GPUParticles3D => {
|
|
385
|
+
const emitter = ctx.add(new GPUParticles3D(EFFECTS[name]()));
|
|
386
|
+
emitter.name = `effects-${name}`;
|
|
387
|
+
return emitter;
|
|
388
|
+
};
|
|
389
|
+
const emitters = {
|
|
390
|
+
dust: make("dust"),
|
|
391
|
+
sparkOrange: make("sparkOrange"),
|
|
392
|
+
sparkWhite: make("sparkWhite"),
|
|
393
|
+
sparkYellow: make("sparkYellow"),
|
|
394
|
+
sparkle: make("sparkle"),
|
|
395
|
+
};
|
|
396
|
+
const fired: Record<string, number> = Object.fromEntries(
|
|
397
|
+
Object.keys(BURSTS).map((kind) => [kind, 0]),
|
|
398
|
+
);
|
|
399
|
+
const burst = (kind: keyof typeof BURSTS, at: { x: number; y: number; z: number }): void => {
|
|
400
|
+
const { count, emitter, shape } = BURSTS[kind];
|
|
401
|
+
emitters[emitter].emitParticle({
|
|
402
|
+
count,
|
|
403
|
+
direction: { x: shape[0], y: shape[1], z: shape[2] },
|
|
404
|
+
origin: { x: at.x, y: at.y, z: at.z },
|
|
405
|
+
});
|
|
406
|
+
fired[kind] = (fired[kind] ?? 0) + 1;
|
|
407
|
+
};
|
|
408
|
+
const skids = new SkidMarks(view.group);
|
|
409
|
+
// Spark ticks with a boost flame shown; the flame is a mesh on the kart (`render/kart.ts`).
|
|
410
|
+
let flames = 0;
|
|
411
|
+
ctx.entities.add("effects", {
|
|
412
|
+
debug: () => ({
|
|
413
|
+
...fired,
|
|
414
|
+
flame: flames,
|
|
415
|
+
skids: skids.laid,
|
|
416
|
+
spawned: Object.fromEntries(Object.entries(emitters).map(([k, e]) => [k, e.stats.spawned])),
|
|
417
|
+
}),
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// The minimap: the course in a 100 × 100 box, north up.
|
|
421
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
422
|
+
let minZ = Number.POSITIVE_INFINITY;
|
|
423
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
424
|
+
let maxZ = Number.NEGATIVE_INFINITY;
|
|
425
|
+
for (let i = 0; i < course.count; i += 1) {
|
|
426
|
+
minX = Math.min(minX, course.x[i] ?? 0);
|
|
427
|
+
maxX = Math.max(maxX, course.x[i] ?? 0);
|
|
428
|
+
minZ = Math.min(minZ, course.z[i] ?? 0);
|
|
429
|
+
maxZ = Math.max(maxZ, course.z[i] ?? 0);
|
|
430
|
+
}
|
|
431
|
+
const mapScale = 92 / Math.max(maxX - minX, maxZ - minZ);
|
|
432
|
+
const mapX = (x: number) => 4 + (x - minX) * mapScale + (92 - (maxX - minX) * mapScale) / 2;
|
|
433
|
+
const mapY = (z: number) => 4 + (z - minZ) * mapScale + (92 - (maxZ - minZ) * mapScale) / 2;
|
|
434
|
+
let mapPath = "";
|
|
435
|
+
for (let i = 0; i <= course.count; i += 6) {
|
|
436
|
+
const k = course.wrap(i);
|
|
437
|
+
mapPath += `${i === 0 ? "M" : "L"}${mapX(course.x[k] ?? 0).toFixed(1)} ${mapY(course.z[k] ?? 0).toFixed(1)} `;
|
|
438
|
+
}
|
|
439
|
+
mapPath += "Z";
|
|
440
|
+
|
|
441
|
+
const random = makeRng(91);
|
|
442
|
+
let elapsed = 0;
|
|
443
|
+
let goTime = -1;
|
|
444
|
+
let throttlePressedAt = Number.NEGATIVE_INFINITY;
|
|
445
|
+
let throttleWasHeld = false;
|
|
446
|
+
let autopilot = false;
|
|
447
|
+
let toastUntil = 0;
|
|
448
|
+
let lastLap = player.racer.lap;
|
|
449
|
+
let lapStart = 0;
|
|
450
|
+
const lapTimes: number[] = [];
|
|
451
|
+
const boxReady = new Array<number>(boxes.spots.length).fill(0);
|
|
452
|
+
const race = {
|
|
453
|
+
finishedCount: 0,
|
|
454
|
+
finishRankMismatches: 0,
|
|
455
|
+
phase: "countdown" as GameState["phase"],
|
|
456
|
+
rocket: false,
|
|
457
|
+
thrown: { burr: 0, nitro: 0, acorn: 0 },
|
|
458
|
+
};
|
|
459
|
+
ctx.entities.add("race", {
|
|
460
|
+
debug: () => ({
|
|
461
|
+
...race,
|
|
462
|
+
elapsed,
|
|
463
|
+
itemsUsed: race.thrown.burr + race.thrown.nitro + race.thrown.acorn,
|
|
464
|
+
lapsTimed: lapTimes.length,
|
|
465
|
+
order: rank(field.map((e) => e.racer)).map((r) => r.name),
|
|
466
|
+
raceTime: goTime < 0 ? 0 : elapsed - goTime,
|
|
467
|
+
stuckWorst: Math.max(...field.filter((e) => !e.player).map((e) => e.stuckWorst)),
|
|
468
|
+
}),
|
|
469
|
+
});
|
|
470
|
+
const toast = (text: string, seconds = 1.6): void => {
|
|
471
|
+
ctx.state.set({ toast: text });
|
|
472
|
+
toastUntil = elapsed + seconds;
|
|
473
|
+
};
|
|
474
|
+
const statePatch: Partial<GameState> = {};
|
|
475
|
+
const at = { x: 0, y: 0, z: 0 };
|
|
476
|
+
const playerInput: IKartInput = idleInput();
|
|
477
|
+
const frozen = idleInput();
|
|
478
|
+
const lamps = view.lamps;
|
|
479
|
+
|
|
480
|
+
const useItem = (entrant: IEntrant): void => {
|
|
481
|
+
const kind = entrant.slot.held;
|
|
482
|
+
if (kind === undefined) return;
|
|
483
|
+
entrant.slot.held = undefined;
|
|
484
|
+
entrant.used.push(kind);
|
|
485
|
+
race.thrown[kind] += 1;
|
|
486
|
+
const kart = entrant.kart;
|
|
487
|
+
if (kind === "nitro") {
|
|
488
|
+
kart.startBoost();
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
const pool = items.filter((item) => item.kind === kind);
|
|
492
|
+
const free = pool.find((item) => !item.active) ?? pool[0];
|
|
493
|
+
if (free === undefined) return;
|
|
494
|
+
const fx = -Math.sin(kart.yaw);
|
|
495
|
+
const fz = -Math.cos(kart.yaw);
|
|
496
|
+
const reach = kind === "burr" ? -ITEM_FEEL.burrBehind : 1.8;
|
|
497
|
+
free.mesh.position.set(kart.x + fx * reach, kart.y, kart.z + fz * reach);
|
|
498
|
+
free.activate(course, kart.index, kart.yaw, kart);
|
|
499
|
+
emitPlaytestEvent({ entity: entrant.name, item: kind, name: "item-used" });
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
const hitKart = (entrant: IEntrant, kind: "burr" | "acorn"): void => {
|
|
503
|
+
if (entrant.kart.hit) return;
|
|
504
|
+
if (kind === "burr") entrant.kart.spinOut();
|
|
505
|
+
else entrant.kart.tumble();
|
|
506
|
+
burst("hit", { x: entrant.kart.x, y: entrant.kart.y + 0.8, z: entrant.kart.z });
|
|
507
|
+
emitPlaytestEvent({ entity: entrant.name, item: kind, name: "hit" });
|
|
508
|
+
if (entrant.player) toast(kind === "burr" ? "SPUN OUT!" : "ACORN HIT!", 1.2);
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
return (frameCtx, rawDt) => {
|
|
512
|
+
loading.update();
|
|
513
|
+
if (frameCtx.input.justPressed("restart")) {
|
|
514
|
+
frameCtx.state.set(Race.initialState);
|
|
515
|
+
frameCtx.state.flush();
|
|
516
|
+
void frameCtx.goto("race");
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
const dt = Math.min(rawDt, 1 / 30);
|
|
520
|
+
elapsed += dt;
|
|
521
|
+
const input = frameCtx.input;
|
|
522
|
+
const touch = touchControls?.update(frameCtx.input.raw.pointers, frameCtx.viewport.size);
|
|
523
|
+
|
|
524
|
+
// ---- The countdown ------------------------------------------------------------------
|
|
525
|
+
const racing = elapsed >= GO_AT;
|
|
526
|
+
const lit = Math.max(
|
|
527
|
+
0,
|
|
528
|
+
Math.min(RACE.lights, Math.floor((elapsed - RACE.ready) / RACE.light) + 1),
|
|
529
|
+
);
|
|
530
|
+
lamps.forEach((lamp, i) => {
|
|
531
|
+
lamp.emissive.setHex(racing ? 0x2aff4a : 0xff2a1a);
|
|
532
|
+
lamp.emissiveIntensity = racing
|
|
533
|
+
? elapsed < GO_AT + 2
|
|
534
|
+
? 3
|
|
535
|
+
: 0
|
|
536
|
+
: i < lit && elapsed >= RACE.ready
|
|
537
|
+
? 3
|
|
538
|
+
: 0;
|
|
539
|
+
});
|
|
540
|
+
const throttleHeld = input.pressed("accel") || touch?.accelHeld === true;
|
|
541
|
+
if (!racing && throttleHeld && !throttleWasHeld) throttlePressedAt = elapsed;
|
|
542
|
+
throttleWasHeld = throttleHeld;
|
|
543
|
+
if (racing && goTime < 0) {
|
|
544
|
+
goTime = elapsed;
|
|
545
|
+
race.phase = "race";
|
|
546
|
+
// A rocket start: the pedal pressed in the last 8 ticks before GO, and still held.
|
|
547
|
+
if (throttleHeld && GO_AT - throttlePressedAt <= RACE.rocketWindow) {
|
|
548
|
+
player.kart.startBoost();
|
|
549
|
+
race.rocket = true;
|
|
550
|
+
// The HUD hides toasts while "GO!" shows (1 s), so the toast outlasts it by 1.2 s.
|
|
551
|
+
toast("ROCKET START!", 1 + 1.2);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
const remaining = GO_AT - elapsed;
|
|
555
|
+
const countdown =
|
|
556
|
+
remaining > RACE.lights
|
|
557
|
+
? 4
|
|
558
|
+
: remaining > 0
|
|
559
|
+
? Math.ceil(remaining)
|
|
560
|
+
: elapsed < GO_AT + 1
|
|
561
|
+
? 0
|
|
562
|
+
: -1;
|
|
563
|
+
|
|
564
|
+
// ---- The player's hands -------------------------------------------------------------
|
|
565
|
+
if (input.justPressed("autopilot")) autopilot = !autopilot;
|
|
566
|
+
const steer = input.vector("move").x + (touch?.move.x ?? 0);
|
|
567
|
+
playerInput.throttle = throttleHeld;
|
|
568
|
+
playerInput.brake = input.pressed("brake") || (touch !== undefined && touch.move.y < -0.5);
|
|
569
|
+
playerInput.steer = Math.max(-1, Math.min(1, steer));
|
|
570
|
+
playerInput.drift = input.pressed("drift") || touch?.driftHeld === true;
|
|
571
|
+
playerInput.item = input.justPressed("item") || touch?.itemPressed === true;
|
|
572
|
+
|
|
573
|
+
// ---- Drive every kart --------------------------------------------------------------
|
|
574
|
+
const leader = player.racer.progress;
|
|
575
|
+
for (const entrant of field) {
|
|
576
|
+
const { kart, racer, driver, slot } = entrant;
|
|
577
|
+
slot.update(dt);
|
|
578
|
+
const ai = !entrant.player || autopilot || racer.finished;
|
|
579
|
+
let control: IKartInput;
|
|
580
|
+
if (!racing) control = frozen;
|
|
581
|
+
else if (ai) {
|
|
582
|
+
if (!entrant.player) {
|
|
583
|
+
// The rubber band, against the player's progress, not the leader's.
|
|
584
|
+
kart.catchingUp = racer.progress < leader - RACE.behind && !player.racer.finished;
|
|
585
|
+
driver.coasting =
|
|
586
|
+
!player.racer.finished &&
|
|
587
|
+
racer.progress > leader + RACE.ahead + RACE.aheadPerPlace * racer.rank;
|
|
588
|
+
}
|
|
589
|
+
control = driver.update(dt, random);
|
|
590
|
+
if (slot.held !== undefined) {
|
|
591
|
+
entrant.useIn -= dt;
|
|
592
|
+
if (entrant.useIn <= 0) control.item = true;
|
|
593
|
+
}
|
|
594
|
+
} else control = playerInput;
|
|
595
|
+
if (racing) {
|
|
596
|
+
kart.step(control, dt);
|
|
597
|
+
if (control.item) useItem(entrant);
|
|
598
|
+
}
|
|
599
|
+
if (!racing) continue;
|
|
600
|
+
// Stuck: a CPU slower than 1.5 m/s while racing and not hit.
|
|
601
|
+
entrant.stuck = !racer.finished && kart.speed < 1.5 && !kart.hit ? entrant.stuck + dt : 0;
|
|
602
|
+
entrant.stuckWorst = Math.max(entrant.stuckWorst, entrant.stuck);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// ---- Karts bump each other ----------------------------------------------------------
|
|
606
|
+
for (let a = 0; a < field.length; a += 1) {
|
|
607
|
+
for (let b = a + 1; b < field.length; b += 1) {
|
|
608
|
+
const ka = field[a]?.kart;
|
|
609
|
+
const kb = field[b]?.kart;
|
|
610
|
+
if (ka === undefined || kb === undefined) continue;
|
|
611
|
+
const dx = kb.x - ka.x;
|
|
612
|
+
const dz = kb.z - ka.z;
|
|
613
|
+
if (Math.abs(ka.y - kb.y) > 1.5) continue;
|
|
614
|
+
// The gap in kart a's frame, scaled so the footprint is the unit circle.
|
|
615
|
+
const fx = -Math.sin(ka.yaw);
|
|
616
|
+
const fz = -Math.cos(ka.yaw);
|
|
617
|
+
const e = Math.hypot(
|
|
618
|
+
(dx * fx + dz * fz) / BUMP.length,
|
|
619
|
+
(dx * -fz + dz * fx) / BUMP.width,
|
|
620
|
+
);
|
|
621
|
+
if (e >= 1 || e < 1e-6) continue;
|
|
622
|
+
// Scale the gap by 1/e to put b on a's footprint, half the move each.
|
|
623
|
+
const push = (1 / e - 1) / 2;
|
|
624
|
+
ka.x -= dx * push;
|
|
625
|
+
ka.z -= dz * push;
|
|
626
|
+
kb.x += dx * push;
|
|
627
|
+
kb.z += dz * push;
|
|
628
|
+
// The kart behind gives a little speed to the one ahead.
|
|
629
|
+
const share = (ka.speed - kb.speed) * 0.15;
|
|
630
|
+
ka.speed -= share;
|
|
631
|
+
kb.speed += share;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// ---- Pads, boxes and items ------------------------------------------------------------
|
|
636
|
+
for (const entrant of field) {
|
|
637
|
+
const kart = entrant.kart;
|
|
638
|
+
const onPad =
|
|
639
|
+
kart.grounded &&
|
|
640
|
+
course.pads.some(
|
|
641
|
+
(pad) =>
|
|
642
|
+
Math.abs(kart.index - pad.index) <= 2 && Math.abs(kart.lateral - pad.lateral) <= 1.7,
|
|
643
|
+
);
|
|
644
|
+
if (onPad && !entrant.onPad) {
|
|
645
|
+
kart.startBoost();
|
|
646
|
+
entrant.padHits += 1;
|
|
647
|
+
if (entrant.player) emitPlaytestEvent({ entity: "player", name: "boost-pad" });
|
|
648
|
+
}
|
|
649
|
+
entrant.onPad = onPad;
|
|
650
|
+
boxes.spots.forEach((spot, i) => {
|
|
651
|
+
if ((boxReady[i] ?? 0) > elapsed) return;
|
|
652
|
+
if ((spot.x - kart.x) ** 2 + (spot.z - kart.z) ** 2 > ITEM_FEEL.boxReach ** 2) return;
|
|
653
|
+
if (Math.abs(spot.y - 1.1 - kart.y) > 2) return;
|
|
654
|
+
boxReady[i] = elapsed + ITEM_FEEL.boxRespawn;
|
|
655
|
+
burst("box", spot);
|
|
656
|
+
entrant.boxes += 1;
|
|
657
|
+
if (entrant.slot.busy) return;
|
|
658
|
+
entrant.slot.roll(drawItem(entrant.racer.rank, random()));
|
|
659
|
+
entrant.useIn = 1 + ITEM_FEEL.roulette + random() * 3;
|
|
660
|
+
if (entrant.player) emitPlaytestEvent({ entity: "player", name: "item-box" });
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
// Thrown and placed items wait for GO like the karts do.
|
|
664
|
+
for (const item of items) {
|
|
665
|
+
if (racing) item.update(course, dt);
|
|
666
|
+
if (!item.active) continue;
|
|
667
|
+
for (const entrant of field) {
|
|
668
|
+
if (!item.touches(entrant.kart)) continue;
|
|
669
|
+
item.hits += 1;
|
|
670
|
+
hitKart(entrant, item.kind);
|
|
671
|
+
item.park();
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
for (const acorn of items) {
|
|
676
|
+
if (acorn.kind !== "acorn" || !acorn.active) continue;
|
|
677
|
+
for (const burr of items) {
|
|
678
|
+
if (burr.kind !== "burr" || !burr.active) continue;
|
|
679
|
+
if (acorn.mesh.position.distanceToSquared(burr.mesh.position) < 1.2) {
|
|
680
|
+
acorn.park();
|
|
681
|
+
burr.park();
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// ---- Race order --------------------------------------------------------------------
|
|
688
|
+
const raceTime = goTime < 0 ? 0 : elapsed - goTime;
|
|
689
|
+
const crossing: [Racer, number][] = [];
|
|
690
|
+
for (const { racer } of field) {
|
|
691
|
+
const was = racer.finished;
|
|
692
|
+
racer.update(course, raceTime);
|
|
693
|
+
if (!was && racer.finished) crossing.push([racer, racer.rank]);
|
|
694
|
+
}
|
|
695
|
+
rank(field.map((e) => e.racer));
|
|
696
|
+
// The HUD's place was honest: each kart finishes in the place the progress ranking gave it.
|
|
697
|
+
for (const [racer, place] of crossing)
|
|
698
|
+
if (racer.rank !== place) race.finishRankMismatches += 1;
|
|
699
|
+
race.finishedCount = field.filter((e) => e.racer.finished).length;
|
|
700
|
+
// `lastLap` is the furthest lap reached, not the last one seen: backing over the line takes a
|
|
701
|
+
// lap back and crossing again returns it, and that return must not time the lap twice.
|
|
702
|
+
if (player.racer.lap > lastLap) {
|
|
703
|
+
if (player.racer.lap >= 1) {
|
|
704
|
+
lapTimes.push(raceTime - lapStart);
|
|
705
|
+
lapStart = raceTime;
|
|
706
|
+
if (player.racer.lap === RACE.laps - 1) toast("FINAL LAP!", 2);
|
|
707
|
+
else if (player.racer.lap < RACE.laps) toast(`LAP ${player.racer.lap + 1}`, 1.4);
|
|
708
|
+
}
|
|
709
|
+
lastLap = player.racer.lap;
|
|
710
|
+
}
|
|
711
|
+
if (player.racer.finished && race.phase !== "finished") {
|
|
712
|
+
race.phase = "finished";
|
|
713
|
+
toast("FINISH!", 3);
|
|
714
|
+
emitPlaytestEvent({ entity: "player", name: "finished" });
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// ---- What the race looks like --------------------------------------------------------
|
|
718
|
+
for (const entrant of field) {
|
|
719
|
+
const { kart, model } = entrant;
|
|
720
|
+
const steering =
|
|
721
|
+
entrant.player && !autopilot ? playerInput.steer : entrant.driver.input.steer;
|
|
722
|
+
model.update(kart, steering, dt);
|
|
723
|
+
if (!racing) continue;
|
|
724
|
+
if (
|
|
725
|
+
(kart.x - camera.position.x) ** 2 + (kart.z - camera.position.z) ** 2 >
|
|
726
|
+
EFFECT_RANGE ** 2
|
|
727
|
+
)
|
|
728
|
+
continue;
|
|
729
|
+
entrant.sparkClock += dt;
|
|
730
|
+
const tick = entrant.sparkClock >= 1 / 30;
|
|
731
|
+
if (tick) entrant.sparkClock = 0;
|
|
732
|
+
if (tick && kart.grounded && kart.drifting) {
|
|
733
|
+
for (const side of [-1, 1] as const) {
|
|
734
|
+
model.rearWheel(side, at);
|
|
735
|
+
if (kart.driftStage > 0)
|
|
736
|
+
burst(
|
|
737
|
+
kart.driftStage === 1 ? "spark1" : kart.driftStage === 2 ? "spark2" : "spark3",
|
|
738
|
+
at,
|
|
739
|
+
);
|
|
740
|
+
else burst("drift", at);
|
|
741
|
+
skids.lay(`${entrant.name}${side}`, at.x, at.y, at.z);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (tick && (kart.boostTicks > 0 || kart.miniTurboTicks > 0)) flames += 1;
|
|
745
|
+
if (tick && kart.grounded && kart.surface !== "road" && Math.abs(kart.speed) > 3) {
|
|
746
|
+
model.rearWheel(kart.index % 2 === 0 ? -1 : 1, at);
|
|
747
|
+
burst(kart.surface === "water" ? "splash" : "grass", at);
|
|
748
|
+
}
|
|
749
|
+
entrant.wallClock -= dt;
|
|
750
|
+
if (kart.onWall && Math.abs(kart.speed) > 4 && entrant.wallClock <= 0) {
|
|
751
|
+
entrant.wallClock = 0.15;
|
|
752
|
+
burst("wall", { x: kart.x, y: kart.y + 0.5, z: kart.z });
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
// The rendered model's lowest point against the road under the kart: a hit must not sink it.
|
|
756
|
+
// The kart's own box (measured once, in the root's frame) is placed by the root's matrix, so
|
|
757
|
+
// a step reads 8 corners, not every vertex: the vertex walk cost 105 ms a step and hung the
|
|
758
|
+
// race on every hit (owner trace, 2026-10-26). A corner sits at or below the mesh it bounds,
|
|
759
|
+
// so this reads a sink no smaller than the real one. Only a spun or tumbled kart is measured.
|
|
760
|
+
for (const entrant of field) {
|
|
761
|
+
const { kart, model } = entrant;
|
|
762
|
+
if (!kart.hit) continue;
|
|
763
|
+
model.root.updateWorldMatrix(true, false);
|
|
764
|
+
const { min, max } = model.bounds;
|
|
765
|
+
let lowest = Number.POSITIVE_INFINITY;
|
|
766
|
+
for (let corner = 0; corner < 8; corner += 1) {
|
|
767
|
+
scratchCorner
|
|
768
|
+
.set(corner & 1 ? max.x : min.x, corner & 2 ? max.y : min.y, corner & 4 ? max.z : min.z)
|
|
769
|
+
.applyMatrix4(model.root.matrixWorld);
|
|
770
|
+
lowest = Math.min(lowest, scratchCorner.y);
|
|
771
|
+
}
|
|
772
|
+
const road = course.heightAt(kart.index, kart.x, kart.z);
|
|
773
|
+
entrant.lowestPointBelowRoad = Math.max(entrant.lowestPointBelowRoad, road - lowest);
|
|
774
|
+
}
|
|
775
|
+
boxes.update(elapsed, (i) => (boxReady[i] ?? 0) <= elapsed, dt, camera.position);
|
|
776
|
+
rig.update(player.kart, dt);
|
|
777
|
+
// Shake meter: the second difference of the kart's height and of the camera's height above
|
|
778
|
+
// it, and the per-frame pitch/roll step the model drew. A hop is a real arc, not a shake, so
|
|
779
|
+
// the air and the two frames that land it are skipped.
|
|
780
|
+
const cameraOffset = camera.position.y - player.kart.y;
|
|
781
|
+
for (const entrant of field) {
|
|
782
|
+
const s = entrant.shake;
|
|
783
|
+
const pitch = entrant.model.root.rotation.x;
|
|
784
|
+
const roll = entrant.model.root.rotation.z;
|
|
785
|
+
const offset = entrant === player ? cameraOffset : s.offset;
|
|
786
|
+
if (s.air === 0 && !entrant.kart.airborne) {
|
|
787
|
+
s.maxY = Math.max(s.maxY, Math.abs(entrant.kart.y - 2 * s.y + s.y2));
|
|
788
|
+
s.maxPitch = Math.max(s.maxPitch, Math.abs(pitch - s.pitch) * (180 / Math.PI));
|
|
789
|
+
s.maxRoll = Math.max(s.maxRoll, Math.abs(roll - s.roll) * (180 / Math.PI));
|
|
790
|
+
if (entrant === player)
|
|
791
|
+
s.maxOffset = Math.max(s.maxOffset, Math.abs(offset - 2 * s.offset + s.offset2));
|
|
792
|
+
}
|
|
793
|
+
s.air = entrant.kart.airborne ? 2 : Math.max(0, s.air - 1);
|
|
794
|
+
s.y2 = s.y;
|
|
795
|
+
s.y = entrant.kart.y;
|
|
796
|
+
s.offset2 = s.offset;
|
|
797
|
+
s.offset = offset;
|
|
798
|
+
s.pitch = pitch;
|
|
799
|
+
s.roll = roll;
|
|
800
|
+
}
|
|
801
|
+
lighting.follow(new Vector3(player.kart.x, player.kart.y, player.kart.z));
|
|
802
|
+
|
|
803
|
+
// ---- What the HUD reads ----------------------------------------------------------------
|
|
804
|
+
if (toastUntil !== 0 && elapsed > toastUntil) {
|
|
805
|
+
toastUntil = 0;
|
|
806
|
+
frameCtx.state.set({ toast: "" });
|
|
807
|
+
}
|
|
808
|
+
const order = rank(field.map((e) => e.racer));
|
|
809
|
+
const results: IResult[] =
|
|
810
|
+
race.phase === "finished"
|
|
811
|
+
? order.map((racer) => ({
|
|
812
|
+
name: racer.name,
|
|
813
|
+
place: racer.rank,
|
|
814
|
+
player: racer === player.racer,
|
|
815
|
+
time: racer.finished ? racer.finishTime : 0,
|
|
816
|
+
}))
|
|
817
|
+
: [];
|
|
818
|
+
const dots: IMapDot[] = field.map((e) => ({
|
|
819
|
+
colour: `#${e.model.livery.body.toString(16).padStart(6, "0")}`,
|
|
820
|
+
player: e.player,
|
|
821
|
+
x: mapX(e.kart.x),
|
|
822
|
+
y: mapY(e.kart.z),
|
|
823
|
+
}));
|
|
824
|
+
statePatch.autopilot = autopilot || player.racer.finished;
|
|
825
|
+
statePatch.countdown = countdown;
|
|
826
|
+
statePatch.driftStage = player.kart.driftStage;
|
|
827
|
+
statePatch.finishedCount = race.finishedCount;
|
|
828
|
+
statePatch.item = player.slot.held ?? (player.slot.rolling ? "rolling" : "");
|
|
829
|
+
statePatch.lap = player.racer.displayLap;
|
|
830
|
+
statePatch.lapTimes = [...lapTimes];
|
|
831
|
+
statePatch.mapDots = dots;
|
|
832
|
+
statePatch.mapPath = mapPath;
|
|
833
|
+
statePatch.phase = race.phase;
|
|
834
|
+
statePatch.place = player.racer.rank;
|
|
835
|
+
statePatch.results = results;
|
|
836
|
+
statePatch.speed = Math.round(Math.abs(player.kart.speed) * 3.6);
|
|
837
|
+
statePatch.time = player.racer.finished ? player.racer.finishTime : raceTime;
|
|
838
|
+
statePatch.wrongWay = player.racer.wrongWay;
|
|
839
|
+
frameCtx.state.set(statePatch);
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
override exit(ctx: GameCtx): void {
|
|
844
|
+
this.#post?.dispose();
|
|
845
|
+
this.#post = undefined;
|
|
846
|
+
this.#field = [];
|
|
847
|
+
this.#items = [];
|
|
848
|
+
super.exit(ctx);
|
|
849
|
+
}
|
|
850
|
+
}
|