create-threenative 0.2.17 → 0.2.20
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/kit-mcp.md +1 -1
- package/agent-docs/kit-router.md +1 -1
- package/agent-docs/references/assertion-reference.md +54 -110
- package/agent-docs/references/capability-reference.md +790 -24
- package/agent-docs/references/conventions.md +28 -0
- package/agent-docs/references/kit-racing.md +4 -2
- package/agent-docs/references/performance-basics.md +10 -5
- package/agent-docs/references/terrain-authoring.md +21 -7
- package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
- package/agent-files/.agents/skills/prd-creator/SKILL.md +24 -0
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +7 -4
- package/agent-files/.claude/hooks/discovery-gate.mjs +2 -2
- package/dist/index.d.ts +97 -6
- package/dist/index.js +1040 -529
- package/dist/quality.d.ts +5 -1
- package/dist/quality.js +75 -6
- package/dist/terrain-kit.js +1 -1
- package/dist/threenative.js +98 -17
- package/dist/web-engine-ccd-ik-solver.js +127 -0
- package/dist/web-engine-gltf-loader.js +52 -14
- package/dist/web-engine-post-effects.js +11 -10
- package/dist/web-engine-runtime.js +3638 -361
- package/package.json +8 -7
- package/template-assets/assets/floor-fern-0.glb +0 -0
- package/template-assets/assets/floor-litter-0.glb +0 -0
- package/template-assets/assets/floor-log-0.glb +0 -0
- package/template-assets/assets/floor-log-1.glb +0 -0
- package/template-assets/assets/floor-stump-0.glb +0 -0
- package/template-assets/assets/floor-twig-0.glb +0 -0
- package/template-assets/clearwater/README.md +1 -1
- package/template-assets/patches/manifest.json +18 -0
- package/template-assets/quality/eslint.config.js +1 -1
- package/templates/action-rpg/AGENTS.md +8 -4
- package/templates/action-rpg/CLAUDE.md +8 -4
- package/templates/action-rpg/package.json +7 -7
- package/templates/action-rpg/src/game.ts +1 -1
- package/templates/action-rpg/src/loot/drops.ts +3 -7
- package/templates/action-rpg/src/render/atmosphere.ts +6 -0
- package/templates/action-rpg/src/render/backlightControls.ts +10 -0
- package/templates/action-rpg/src/render/backlightMaterial.ts +4 -4
- package/templates/action-rpg/src/render/camera.ts +2 -2
- package/templates/action-rpg/src/render/clouds.ts +16 -1
- package/templates/action-rpg/src/render/materialLighting.ts +5 -5
- package/templates/action-rpg/src/render/materials.ts +3 -2
- package/templates/action-rpg/src/render/quality.ts +7 -32
- package/templates/action-rpg/src/render/touch-controls.ts +7 -6
- package/templates/action-rpg/src/scenes/Play.ts +5 -16
- package/templates/action-rpg/src/style.css +4 -0
- package/templates/action-rpg/vite.config.ts +2 -0
- package/templates/adventure/AGENTS.md +10 -5
- package/templates/adventure/CLAUDE.md +10 -5
- package/templates/adventure/kit.json +5 -1
- package/templates/adventure/native-playtests/survives.playtest.json +12 -0
- package/templates/adventure/native-playtests/woodland-floor.playtest.json +61 -0
- package/templates/adventure/package.json +7 -7
- package/templates/adventure/playtests/grass.playtest.json +61 -0
- package/templates/adventure/playtests/performance.playtest.json +1 -1
- package/templates/adventure/playtests/survives.playtest.json +2 -2
- package/templates/adventure/playtests/woodland-floor.playtest.json +61 -0
- package/templates/adventure/src/entities/LockOn.ts +42 -4
- package/templates/adventure/src/entities/Warden.ts +4 -1
- package/templates/adventure/src/game.ts +1 -1
- package/templates/adventure/src/level/Vale.ts +241 -16
- package/templates/adventure/src/render/camera.ts +2 -2
- package/templates/adventure/src/render/foliage.ts +64 -20
- package/templates/adventure/src/render/grass.ts +325 -0
- package/templates/adventure/src/render/materials.ts +3 -2
- package/templates/adventure/src/render/palette.ts +3 -0
- package/templates/adventure/src/render/touch-controls.ts +4 -1
- package/templates/adventure/src/scenes/Play.ts +96 -1
- package/templates/adventure/src/style.css +4 -0
- package/templates/adventure/tsconfig.json +1 -1
- package/templates/adventure/vite.config.ts +2 -0
- package/templates/collectathon/AGENTS.md +7 -2
- package/templates/collectathon/CLAUDE.md +7 -2
- package/templates/collectathon/package.json +7 -7
- package/templates/collectathon/src/game.ts +1 -1
- package/templates/collectathon/src/level/Course.ts +55 -14
- package/templates/collectathon/src/level/terrain.ts +29 -7
- package/templates/collectathon/src/main.ts +1 -0
- package/templates/collectathon/src/render/camera.ts +2 -2
- package/templates/collectathon/src/render/foliage.ts +359 -98
- package/templates/collectathon/src/render/ground.ts +4 -4
- package/templates/collectathon/src/render/hero.ts +1 -1
- package/templates/collectathon/src/render/materials.ts +0 -1
- package/templates/collectathon/src/render/sky.ts +80 -15
- package/templates/collectathon/src/render/water.ts +32 -10
- package/templates/collectathon/src/scenes/Play.ts +18 -5
- package/templates/collectathon/src/style.css +4 -0
- package/templates/collectathon/tsconfig.json +1 -1
- package/templates/collectathon/vite.config.ts +2 -0
- package/templates/kart/AGENTS.md +7 -2
- package/templates/kart/CLAUDE.md +7 -2
- package/templates/kart/package.json +6 -6
- package/templates/kart/src/entities/Kart.ts +2 -1
- package/templates/kart/src/game.ts +1 -1
- package/templates/kart/src/main.ts +1 -0
- package/templates/kart/src/render/course.ts +2 -1
- package/templates/kart/src/style.css +4 -0
- package/templates/kart/src/track/Course.ts +3 -1
- package/templates/kart/tsconfig.json +1 -1
- package/templates/kart/vite.config.ts +2 -0
- package/templates/minimal/AGENTS.md +8 -3
- package/templates/minimal/CLAUDE.md +8 -3
- package/templates/minimal/package.json +6 -6
- package/templates/minimal/playtests/stands-still.playtest.json +30 -0
- package/templates/minimal/src/game.ts +1 -1
- package/templates/minimal/src/render/atmosphere.ts +6 -0
- package/templates/minimal/src/render/backlightControls.ts +10 -0
- package/templates/minimal/src/render/backlightMaterial.ts +4 -4
- package/templates/minimal/src/render/camera.ts +14 -3
- package/templates/minimal/src/render/clouds.ts +16 -1
- package/templates/minimal/src/render/lighting.ts +4 -2
- package/templates/minimal/src/render/materialLighting.ts +5 -5
- package/templates/minimal/src/render/materials.ts +13 -2
- package/templates/minimal/src/render/quality.ts +7 -32
- package/templates/minimal/src/render/touch-controls.ts +7 -6
- package/templates/minimal/src/scenes/Play.ts +4 -1
- package/templates/minimal/vite.config.ts +7 -1
- package/templates/platformer/AGENTS.md +9 -4
- package/templates/platformer/CLAUDE.md +9 -4
- package/templates/platformer/index.html +1 -1
- package/templates/platformer/main.html +12 -0
- package/templates/platformer/package.json +7 -7
- package/templates/platformer/playtests/collect.playtest.json +4 -1
- package/templates/platformer/playtests/gamepad-idle.playtest.json +21 -0
- package/templates/platformer/playtests/gamepad.playtest.json +30 -0
- package/templates/platformer/src/entities/Fox.ts +21 -6
- package/templates/platformer/src/game.ts +1 -1
- package/templates/platformer/src/level/Stage.ts +2 -6
- package/templates/platformer/src/main.ts +1 -0
- package/templates/platformer/src/render/backlightControls.ts +10 -0
- package/templates/platformer/src/render/backlightMaterial.ts +4 -4
- package/templates/platformer/src/render/materialLighting.ts +5 -5
- package/templates/platformer/src/render/quality.ts +7 -32
- package/templates/platformer/src/scenes/Play.ts +4 -2
- package/templates/platformer/src/style.css +4 -0
- package/templates/platformer/src/worker-page.ts +29 -0
- package/templates/platformer/src/worker.ts +5 -0
- package/templates/platformer/tsconfig.json +1 -1
- package/templates/platformer/vite.config.ts +4 -0
- package/templates/puzzle/AGENTS.md +7 -2
- package/templates/puzzle/CLAUDE.md +7 -2
- package/templates/puzzle/package.json +7 -7
- package/templates/puzzle/src/entities/Warden.ts +3 -3
- package/templates/puzzle/src/game.ts +1 -1
- package/templates/puzzle/src/render/backlightControls.ts +10 -0
- package/templates/puzzle/src/render/backlightMaterial.ts +4 -4
- package/templates/puzzle/src/render/camera.ts +2 -2
- package/templates/puzzle/src/render/materialLighting.ts +5 -5
- package/templates/puzzle/src/render/quality.ts +7 -32
- package/templates/puzzle/src/render/touch-controls.ts +7 -6
- package/templates/puzzle/src/scenes/Play.ts +1 -1
- package/templates/puzzle/src/style.css +4 -0
- package/templates/puzzle/tsconfig.json +1 -1
- package/templates/puzzle/vite.config.ts +2 -0
- package/templates/racing/AGENTS.md +9 -4
- package/templates/racing/CLAUDE.md +9 -4
- package/templates/racing/CREDITS.md +29 -0
- package/templates/racing/assets/engine-loop.wav +0 -0
- package/templates/racing/assets/grass/Grass004_color.jpg +0 -0
- package/templates/racing/assets/grass/Grass004_normal.jpg +0 -0
- package/templates/racing/assets/grass/Grass004_roughness.jpg +0 -0
- package/templates/racing/assets/nitro-burst.wav +0 -0
- package/templates/racing/assets/tyre-squeal.wav +0 -0
- package/templates/racing/package.json +7 -7
- package/templates/racing/playtests/drift-natural.playtest.json +68 -0
- package/templates/racing/playtests/drift.playtest.json +100 -0
- package/templates/racing/playtests/hud.playtest.json +117 -0
- package/templates/racing/playtests/launch-pose.playtest.json +34 -0
- package/templates/racing/playtests/nitro.playtest.json +158 -0
- package/templates/racing/playtests/outcome.playtest.json +4 -4
- package/templates/racing/playtests/performance.playtest.json +1 -1
- package/templates/racing/playtests/steady-camera.playtest.json +88 -0
- package/templates/racing/src/audio/engine.ts +138 -0
- package/templates/racing/src/entities/CarBody.ts +83 -10
- package/templates/racing/src/entities/Drift.ts +243 -0
- package/templates/racing/src/entities/LineDriver.ts +2 -2
- package/templates/racing/src/entities/Nitro.ts +72 -0
- package/templates/racing/src/entities/RacingCar.ts +86 -21
- package/templates/racing/src/entities/Rival.ts +35 -21
- package/templates/racing/src/game.ts +7 -1
- package/templates/racing/src/gauges.ts +74 -0
- package/templates/racing/src/render/atmosphere.ts +6 -0
- package/templates/racing/src/render/backlightControls.ts +10 -0
- package/templates/racing/src/render/backlightMaterial.ts +4 -4
- package/templates/racing/src/render/camera.ts +29 -4
- package/templates/racing/src/render/clouds.ts +16 -1
- package/templates/racing/src/render/effects.ts +244 -0
- package/templates/racing/src/render/materialLighting.ts +5 -5
- package/templates/racing/src/render/materials.ts +43 -8
- package/templates/racing/src/render/quality.ts +7 -32
- package/templates/racing/src/render/shapes.ts +37 -0
- package/templates/racing/src/render/skids.ts +84 -0
- package/templates/racing/src/render/touch-controls.ts +10 -10
- package/templates/racing/src/scenes/Race.ts +281 -26
- package/templates/racing/src/state.ts +35 -0
- package/templates/racing/src/style.css +7 -0
- package/templates/racing/src/track/Track.ts +132 -58
- package/templates/racing/src/track/TrackSector.ts +19 -1
- package/templates/racing/src/track/circuit.ts +21 -15
- package/templates/racing/src/ui/GameUi.tsx +0 -2
- package/templates/racing/src/ui/Hud.tsx +417 -50
- package/templates/racing/threenative.config.ts +15 -0
- package/templates/racing/tools/make-racing-audio.mjs +388 -0
- package/templates/racing/tsconfig.json +1 -1
- package/templates/racing/vite.config.ts +2 -0
- package/templates/rain/AGENTS.md +6 -2
- package/templates/rain/CLAUDE.md +6 -2
- package/templates/rain/package.json +6 -6
- package/templates/rain/src/game.ts +1 -1
- package/templates/rain/src/render/noise-volume.ts +2 -1
- package/templates/rain/src/state.ts +3 -1
- package/templates/rain/src/ui/GameUi.tsx +1 -1
- package/templates/rain/src/ui/automation.ts +10 -8
- package/templates/rain/src/ui/tempest.ts +3 -4
- package/templates/rain/vite.config.ts +6 -0
- package/templates/rts/AGENTS.md +6 -2
- package/templates/rts/CLAUDE.md +6 -2
- package/templates/rts/package.json +6 -6
- package/templates/rts/src/game.ts +1 -1
- package/templates/rts/src/render/backlightControls.ts +10 -0
- package/templates/rts/src/render/backlightMaterial.ts +4 -4
- package/templates/rts/src/render/materialLighting.ts +5 -5
- package/templates/rts/src/render/quality.ts +7 -31
- package/templates/rts/src/scenes/Play.ts +1 -1
- package/templates/rts/src/sim/terrain.ts +1 -0
- package/templates/rts/src/sim/types.ts +1 -0
- package/templates/rts/src/style.css +4 -0
- package/templates/rts/vite.config.ts +2 -0
- package/templates/runner/AGENTS.md +7 -2
- package/templates/runner/CLAUDE.md +7 -2
- package/templates/runner/package.json +7 -7
- package/templates/runner/src/game.ts +1 -1
- package/templates/runner/src/render/atmosphere.ts +6 -0
- package/templates/runner/src/render/backlightControls.ts +10 -0
- package/templates/runner/src/render/backlightMaterial.ts +4 -4
- package/templates/runner/src/render/clouds.ts +16 -1
- package/templates/runner/src/render/materialLighting.ts +5 -5
- package/templates/runner/src/render/materials.ts +3 -2
- package/templates/runner/src/render/quality.ts +7 -32
- package/templates/runner/src/render/touch-controls.ts +7 -6
- package/templates/runner/src/scenes/Run.ts +8 -10
- package/templates/runner/src/style.css +4 -0
- package/templates/runner/tsconfig.json +1 -1
- package/templates/runner/vite.config.ts +2 -0
- package/templates/sailing/AGENTS.md +7 -2
- package/templates/sailing/CLAUDE.md +7 -2
- package/templates/sailing/package.json +7 -7
- package/templates/sailing/src/game.ts +1 -1
- package/templates/sailing/src/render/backlightControls.ts +10 -0
- package/templates/sailing/src/render/backlightMaterial.ts +4 -4
- package/templates/sailing/src/render/environmentSetup.ts +1 -1
- package/templates/sailing/src/render/materialLighting.ts +5 -5
- package/templates/sailing/src/render/quality.ts +7 -32
- package/templates/sailing/src/render/touch-controls.ts +7 -6
- package/templates/sailing/src/style.css +5 -0
- package/templates/sailing/vite.config.ts +6 -0
- package/templates/shooter/AGENTS.md +6 -2
- package/templates/shooter/CLAUDE.md +6 -2
- package/templates/shooter/package.json +7 -7
- package/templates/shooter/src/game.ts +3 -2
- package/templates/shooter/src/render/atmosphere.ts +6 -0
- package/templates/shooter/src/render/backlightControls.ts +10 -0
- package/templates/shooter/src/render/backlightMaterial.ts +4 -4
- package/templates/shooter/src/render/clouds.ts +16 -1
- package/templates/shooter/src/render/materialLighting.ts +5 -5
- package/templates/shooter/src/render/quality.ts +7 -32
- package/templates/shooter/src/scenes/Play.ts +4 -1
- package/templates/shooter/src/style.css +4 -0
- package/templates/shooter/vite.config.ts +2 -0
- package/templates/snow/AGENTS.md +7 -2
- package/templates/snow/CLAUDE.md +7 -2
- package/templates/snow/package.json +7 -7
- package/templates/snow/src/entities/Explorer.ts +6 -12
- package/templates/snow/src/game.ts +1 -1
- package/templates/snow/src/render/backlightControls.ts +10 -0
- package/templates/snow/src/render/backlightMaterial.ts +4 -4
- package/templates/snow/src/render/bootPrint.ts +3 -1
- package/templates/snow/src/render/camera.ts +3 -2
- package/templates/snow/src/render/materialLighting.ts +5 -5
- package/templates/snow/src/render/quality.ts +7 -32
- package/templates/snow/src/render/scenery.ts +3 -3
- package/templates/snow/src/render/touch-controls.ts +7 -6
- package/templates/snow/src/render/weather.ts +3 -5
- package/templates/snow/src/style.css +5 -0
- package/templates/snow/src/terrain.ts +2 -1
- package/templates/snow/vite.config.ts +6 -0
- package/templates/starter/AGENTS.md +8 -3
- package/templates/starter/CLAUDE.md +8 -3
- package/templates/starter/native-playtests/render-chain.playtest.json +9 -9
- package/templates/starter/package.json +7 -7
- package/templates/starter/src/entities/Crate.ts +5 -2
- package/templates/starter/src/entities/Player.ts +10 -2
- package/templates/starter/src/game.ts +4 -3
- package/templates/starter/src/render/adaptiveQuality.ts +17 -0
- package/templates/starter/src/render/atmosphere.ts +6 -0
- package/templates/starter/src/render/backlightControls.ts +10 -0
- package/templates/starter/src/render/backlightMaterial.ts +4 -4
- package/templates/starter/src/render/camera.ts +2 -2
- package/templates/starter/src/render/clouds.ts +16 -1
- package/templates/starter/src/render/contactShadow.ts +1 -1
- package/templates/starter/src/render/materialLighting.ts +5 -5
- package/templates/starter/src/render/materials.ts +3 -2
- package/templates/starter/src/render/postprocessing.ts +11 -10
- package/templates/starter/src/render/quality.ts +14 -1
- package/templates/starter/src/render/touch-controls.ts +7 -6
- package/templates/starter/src/scenes/Play.ts +13 -17
- package/templates/starter/src/state.ts +2 -0
- package/templates/starter/src/style.css +4 -0
- package/templates/starter/src/ui/Menu.tsx +5 -1
- package/templates/starter/vite.config.ts +2 -0
- package/templates/tower-defense/AGENTS.md +7 -2
- package/templates/tower-defense/CLAUDE.md +7 -2
- package/templates/tower-defense/package.json +7 -7
- package/templates/tower-defense/src/game.ts +1 -1
- package/templates/tower-defense/src/render/backlightControls.ts +10 -0
- package/templates/tower-defense/src/render/backlightMaterial.ts +4 -4
- package/templates/tower-defense/src/render/materialLighting.ts +5 -5
- package/templates/tower-defense/src/render/quality.ts +7 -32
- package/templates/tower-defense/src/render/shapes.ts +1 -2
- package/templates/tower-defense/src/scenes/Battle.ts +4 -9
- package/templates/tower-defense/src/style.css +4 -0
- package/templates/tower-defense/tsconfig.json +1 -1
- package/templates/tower-defense/vite.config.ts +2 -0
- package/templates/action-rpg/src/render/environmentContribution.ts +0 -188
- package/templates/action-rpg/src/render/environmentRadiance.ts +0 -36
- package/templates/action-rpg/src/render/environmentSampleCache.ts +0 -43
- package/templates/action-rpg/src/render/environmentSampling.ts +0 -193
- package/templates/action-rpg/src/render/environmentSnapshot.ts +0 -53
- package/templates/minimal/src/render/environmentContribution.ts +0 -188
- package/templates/minimal/src/render/environmentRadiance.ts +0 -36
- package/templates/minimal/src/render/environmentSampleCache.ts +0 -43
- package/templates/minimal/src/render/environmentSampling.ts +0 -193
- package/templates/minimal/src/render/environmentSnapshot.ts +0 -53
- package/templates/platformer/src/render/environmentContribution.ts +0 -188
- package/templates/platformer/src/render/environmentRadiance.ts +0 -36
- package/templates/platformer/src/render/environmentSampleCache.ts +0 -43
- package/templates/platformer/src/render/environmentSampling.ts +0 -193
- package/templates/platformer/src/render/environmentSnapshot.ts +0 -53
- package/templates/puzzle/src/render/environmentContribution.ts +0 -188
- package/templates/puzzle/src/render/environmentRadiance.ts +0 -36
- package/templates/puzzle/src/render/environmentSampleCache.ts +0 -43
- package/templates/puzzle/src/render/environmentSampling.ts +0 -193
- package/templates/puzzle/src/render/environmentSnapshot.ts +0 -53
- package/templates/racing/src/render/environmentContribution.ts +0 -188
- package/templates/racing/src/render/environmentRadiance.ts +0 -36
- package/templates/racing/src/render/environmentSampleCache.ts +0 -43
- package/templates/racing/src/render/environmentSampling.ts +0 -193
- package/templates/racing/src/render/environmentSnapshot.ts +0 -53
- package/templates/racing/src/ui/Menu.tsx +0 -7
- package/templates/rts/src/render/environmentContribution.ts +0 -188
- package/templates/rts/src/render/environmentRadiance.ts +0 -36
- package/templates/rts/src/render/environmentSampleCache.ts +0 -43
- package/templates/rts/src/render/environmentSampling.ts +0 -193
- package/templates/rts/src/render/environmentSnapshot.ts +0 -53
- package/templates/runner/src/render/environmentContribution.ts +0 -188
- package/templates/runner/src/render/environmentRadiance.ts +0 -36
- package/templates/runner/src/render/environmentSampleCache.ts +0 -43
- package/templates/runner/src/render/environmentSampling.ts +0 -193
- package/templates/runner/src/render/environmentSnapshot.ts +0 -53
- package/templates/sailing/src/render/environmentContribution.ts +0 -188
- package/templates/sailing/src/render/environmentRadiance.ts +0 -36
- package/templates/sailing/src/render/environmentSampleCache.ts +0 -43
- package/templates/sailing/src/render/environmentSampling.ts +0 -193
- package/templates/sailing/src/render/environmentSnapshot.ts +0 -53
- package/templates/shooter/src/render/environmentContribution.ts +0 -188
- package/templates/shooter/src/render/environmentRadiance.ts +0 -36
- package/templates/shooter/src/render/environmentSampleCache.ts +0 -43
- package/templates/shooter/src/render/environmentSampling.ts +0 -193
- package/templates/shooter/src/render/environmentSnapshot.ts +0 -53
- package/templates/snow/src/render/environmentContribution.ts +0 -188
- package/templates/snow/src/render/environmentRadiance.ts +0 -36
- package/templates/snow/src/render/environmentSampleCache.ts +0 -43
- package/templates/snow/src/render/environmentSampling.ts +0 -193
- package/templates/snow/src/render/environmentSnapshot.ts +0 -53
- package/templates/starter/src/render/environmentContribution.ts +0 -188
- package/templates/starter/src/render/environmentRadiance.ts +0 -36
- package/templates/starter/src/render/environmentSampleCache.ts +0 -43
- package/templates/starter/src/render/environmentSampling.ts +0 -193
- package/templates/starter/src/render/environmentSnapshot.ts +0 -53
- package/templates/starter/src/render/rendererGate.ts +0 -36
- package/templates/tower-defense/src/render/environmentContribution.ts +0 -188
- package/templates/tower-defense/src/render/environmentRadiance.ts +0 -36
- package/templates/tower-defense/src/render/environmentSampleCache.ts +0 -43
- package/templates/tower-defense/src/render/environmentSampling.ts +0 -193
- package/templates/tower-defense/src/render/environmentSnapshot.ts +0 -53
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hud",
|
|
3
|
+
"target": "web",
|
|
4
|
+
"schemaVersion": 1,
|
|
5
|
+
"viewport": {
|
|
6
|
+
"width": 1280,
|
|
7
|
+
"height": 720
|
|
8
|
+
},
|
|
9
|
+
"warmupFrames": 10,
|
|
10
|
+
"subject": "player",
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"kind": "wait",
|
|
14
|
+
"label": "idle",
|
|
15
|
+
"waitTicks": 30
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"kind": "input",
|
|
19
|
+
"label": "drive",
|
|
20
|
+
"press": ["ArrowUp"],
|
|
21
|
+
"holdTicks": 240,
|
|
22
|
+
"release": false
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"kind": "input",
|
|
26
|
+
"label": "kick",
|
|
27
|
+
"press": ["ArrowUp", "ArrowRight", "ShiftLeft"],
|
|
28
|
+
"holdTicks": 8,
|
|
29
|
+
"release": false
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"kind": "input",
|
|
33
|
+
"label": "hold",
|
|
34
|
+
"press": ["ArrowUp", "ArrowRight"],
|
|
35
|
+
"holdTicks": 30,
|
|
36
|
+
"release": false
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"kind": "input",
|
|
40
|
+
"label": "catch",
|
|
41
|
+
"press": ["ArrowUp", "ArrowLeft"],
|
|
42
|
+
"holdTicks": 14,
|
|
43
|
+
"release": false
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"kind": "input",
|
|
47
|
+
"label": "straighten",
|
|
48
|
+
"press": ["ArrowUp"],
|
|
49
|
+
"holdTicks": 40,
|
|
50
|
+
"release": true
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"assert": {
|
|
54
|
+
"diagnostics": {
|
|
55
|
+
"noConsoleErrors": true,
|
|
56
|
+
"runtimeReady": true
|
|
57
|
+
},
|
|
58
|
+
"resources": [
|
|
59
|
+
{
|
|
60
|
+
"id": "state",
|
|
61
|
+
"path": "gear",
|
|
62
|
+
"gte": 3,
|
|
63
|
+
"changed": true
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "state",
|
|
67
|
+
"path": "rpm",
|
|
68
|
+
"gte": 0.3,
|
|
69
|
+
"changed": true
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "state",
|
|
73
|
+
"path": "topSpeed",
|
|
74
|
+
"gte": 15
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": "state",
|
|
78
|
+
"path": "driftsBanked",
|
|
79
|
+
"gte": 1,
|
|
80
|
+
"changed": true
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "state",
|
|
84
|
+
"path": "driftLast",
|
|
85
|
+
"gte": 5,
|
|
86
|
+
"changed": true
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "state",
|
|
90
|
+
"path": "engineRate",
|
|
91
|
+
"gte": 1,
|
|
92
|
+
"changed": true
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"id": "state",
|
|
96
|
+
"path": "engineRate",
|
|
97
|
+
"atSteps": [
|
|
98
|
+
{
|
|
99
|
+
"label": "idle",
|
|
100
|
+
"lte": 0.8
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "state",
|
|
106
|
+
"path": "driftPopup",
|
|
107
|
+
"gte": 0.3,
|
|
108
|
+
"atSteps": [
|
|
109
|
+
{
|
|
110
|
+
"label": "idle",
|
|
111
|
+
"lte": 0
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "launch-pose",
|
|
3
|
+
"target": "web",
|
|
4
|
+
"schemaVersion": 1,
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "label": "launch", "press": ["ArrowUp"], "holdTicks": 45, "release": false }
|
|
10
|
+
],
|
|
11
|
+
"assert": {
|
|
12
|
+
"diagnostics": {
|
|
13
|
+
"noConsoleErrors": true,
|
|
14
|
+
"noNetworkErrors": true,
|
|
15
|
+
"noRuntimeDiagnostics": true,
|
|
16
|
+
"runtimeReady": true
|
|
17
|
+
},
|
|
18
|
+
"components": [
|
|
19
|
+
{
|
|
20
|
+
"entity": "camera-rig",
|
|
21
|
+
"component": "leanRoll",
|
|
22
|
+
"lte": 0.2,
|
|
23
|
+
"gte": -0.2,
|
|
24
|
+
"allowTrivial": "A straight launch has no lateral load, so the body stays level side to side. With the lean axes swapped the forward load rolled the car sideways about 1 deg on every launch."
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"entity": "camera-rig",
|
|
28
|
+
"component": "leanPitch",
|
|
29
|
+
"gte": 0.3,
|
|
30
|
+
"allowTrivial": "Full throttle from the grid is about 11 m/s2 of forward load, so the nose lifts. With the lean axes swapped the launch pitch read zero."
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nitro",
|
|
3
|
+
"target": "web",
|
|
4
|
+
"schemaVersion": 1,
|
|
5
|
+
"viewport": {
|
|
6
|
+
"width": 1280,
|
|
7
|
+
"height": 720
|
|
8
|
+
},
|
|
9
|
+
"warmupFrames": 10,
|
|
10
|
+
"subject": "player",
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"kind": "input",
|
|
14
|
+
"label": "cruise",
|
|
15
|
+
"press": ["ArrowUp"],
|
|
16
|
+
"holdTicks": 30,
|
|
17
|
+
"release": false
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"kind": "input",
|
|
21
|
+
"label": "nitro",
|
|
22
|
+
"press": ["ArrowUp", "Space"],
|
|
23
|
+
"holdTicks": 120,
|
|
24
|
+
"release": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"kind": "input",
|
|
28
|
+
"label": "coast",
|
|
29
|
+
"press": ["ArrowUp"],
|
|
30
|
+
"holdTicks": 90,
|
|
31
|
+
"release": false
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"kind": "input",
|
|
35
|
+
"label": "kick",
|
|
36
|
+
"press": ["ArrowUp", "ArrowRight", "ShiftLeft"],
|
|
37
|
+
"holdTicks": 8,
|
|
38
|
+
"release": false
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"kind": "input",
|
|
42
|
+
"label": "hold",
|
|
43
|
+
"press": ["ArrowUp", "ArrowRight"],
|
|
44
|
+
"holdTicks": 30,
|
|
45
|
+
"release": false
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"kind": "input",
|
|
49
|
+
"label": "catch",
|
|
50
|
+
"press": ["ArrowUp", "ArrowLeft"],
|
|
51
|
+
"holdTicks": 14,
|
|
52
|
+
"release": false
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"kind": "input",
|
|
56
|
+
"label": "straighten",
|
|
57
|
+
"press": ["ArrowUp"],
|
|
58
|
+
"holdTicks": 40,
|
|
59
|
+
"release": true
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"assert": {
|
|
63
|
+
"diagnostics": {
|
|
64
|
+
"noConsoleErrors": true,
|
|
65
|
+
"runtimeReady": true
|
|
66
|
+
},
|
|
67
|
+
"resources": [
|
|
68
|
+
{
|
|
69
|
+
"id": "state",
|
|
70
|
+
"path": "nitro",
|
|
71
|
+
"lte": 0.7,
|
|
72
|
+
"changed": true
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "state",
|
|
76
|
+
"path": "nitroActive",
|
|
77
|
+
"atSteps": [
|
|
78
|
+
{
|
|
79
|
+
"label": "cruise",
|
|
80
|
+
"equals": false
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"label": "nitro",
|
|
84
|
+
"equals": true
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"label": "coast",
|
|
88
|
+
"equals": false
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "state",
|
|
94
|
+
"path": "topSpeed",
|
|
95
|
+
"gte": 26.5
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"id": "state",
|
|
99
|
+
"path": "nitro",
|
|
100
|
+
"atSteps": [
|
|
101
|
+
{
|
|
102
|
+
"label": "coast",
|
|
103
|
+
"lte": 0.35
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "state",
|
|
109
|
+
"path": "nitroDriftGain",
|
|
110
|
+
"gte": 0.1,
|
|
111
|
+
"changed": true
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "state",
|
|
115
|
+
"path": "drifting",
|
|
116
|
+
"atSteps": [
|
|
117
|
+
{
|
|
118
|
+
"label": "coast",
|
|
119
|
+
"equals": false
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"label": "hold",
|
|
123
|
+
"equals": true
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "state",
|
|
129
|
+
"path": "driftSpins",
|
|
130
|
+
"equals": 0,
|
|
131
|
+
"allowTrivial": "A spin is the failure this scenario looks for; zero is the held invariant while the drift-refill gain above proves the slide happened."
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"id": "state",
|
|
135
|
+
"path": "fovPeak",
|
|
136
|
+
"gte": 64,
|
|
137
|
+
"changed": true
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"id": "state",
|
|
141
|
+
"path": "fov",
|
|
142
|
+
"atSteps": [
|
|
143
|
+
{
|
|
144
|
+
"label": "coast",
|
|
145
|
+
"lte": 57
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"components": [
|
|
151
|
+
{
|
|
152
|
+
"entity": "effects",
|
|
153
|
+
"component": "flameTicks",
|
|
154
|
+
"gte": 60
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
{
|
|
51
51
|
"id": "state",
|
|
52
52
|
"path": "place",
|
|
53
|
-
"equals":
|
|
54
|
-
"allowTrivial": "The demo driver starts
|
|
53
|
+
"equals": 6,
|
|
54
|
+
"allowTrivial": "The demo driver starts last on the grid, slower than every rival, and stays there, so the place is a held invariant; the DNF transition below is what proves the finish."
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
"id": "state",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"hud": [
|
|
82
82
|
{
|
|
83
83
|
"id": "outcome",
|
|
84
|
-
"equals": "
|
|
85
|
-
"allowTrivial": "The player finished every lap behind the
|
|
84
|
+
"equals": "P6",
|
|
85
|
+
"allowTrivial": "The player finished every lap behind the field: the panel names the place, not DNF, which reads as did-not-finish."
|
|
86
86
|
}
|
|
87
87
|
]
|
|
88
88
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "steady-camera",
|
|
3
|
+
"target": "web",
|
|
4
|
+
"schemaVersion": 1,
|
|
5
|
+
"viewport": {
|
|
6
|
+
"width": 1280,
|
|
7
|
+
"height": 720
|
|
8
|
+
},
|
|
9
|
+
"warmupFrames": 10,
|
|
10
|
+
"subject": "player",
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"kind": "input",
|
|
14
|
+
"label": "straight",
|
|
15
|
+
"press": ["ArrowUp"],
|
|
16
|
+
"holdTicks": 240,
|
|
17
|
+
"release": false
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"kind": "input",
|
|
21
|
+
"label": "right",
|
|
22
|
+
"press": ["ArrowUp", "ArrowRight"],
|
|
23
|
+
"holdTicks": 60,
|
|
24
|
+
"release": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"kind": "input",
|
|
28
|
+
"label": "left",
|
|
29
|
+
"press": ["ArrowUp", "ArrowLeft"],
|
|
30
|
+
"holdTicks": 60,
|
|
31
|
+
"release": false
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"kind": "input",
|
|
35
|
+
"label": "right-again",
|
|
36
|
+
"press": ["ArrowUp", "ArrowRight"],
|
|
37
|
+
"holdTicks": 60,
|
|
38
|
+
"release": true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"kind": "input",
|
|
42
|
+
"label": "autopilot",
|
|
43
|
+
"press": ["KeyP"],
|
|
44
|
+
"holdTicks": 2,
|
|
45
|
+
"release": true
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"kind": "wait",
|
|
49
|
+
"label": "long-drive",
|
|
50
|
+
"waitTicks": 1200,
|
|
51
|
+
"release": true
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"assert": {
|
|
55
|
+
"diagnostics": {
|
|
56
|
+
"noConsoleErrors": true,
|
|
57
|
+
"noNetworkErrors": true,
|
|
58
|
+
"noRuntimeDiagnostics": true,
|
|
59
|
+
"runtimeReady": true
|
|
60
|
+
},
|
|
61
|
+
"components": [
|
|
62
|
+
{
|
|
63
|
+
"entity": "camera-rig",
|
|
64
|
+
"component": "cameraRollStep",
|
|
65
|
+
"lte": 1.5,
|
|
66
|
+
"allowTrivial": "The meter starts at zero on the grid. Before the fix the bank read the raw per-tick tyre load and flipped its full +-3.15 deg in one tick mid-corner, 6.2 deg measured; smoothed it measured 0.51 deg, so 1.5 deg catches the flip."
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"entity": "camera-rig",
|
|
70
|
+
"component": "cameraYawJerk",
|
|
71
|
+
"lte": 15,
|
|
72
|
+
"allowTrivial": "The second difference of the camera yaw, teleport cuts excluded. The raw velocity heading jerked 84 deg in one tick; eased like the kart camera it measured 5.7 deg at a full right-to-left steer reversal, so 15 deg catches a snap."
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"entity": "camera-rig",
|
|
76
|
+
"component": "leanRollStep",
|
|
77
|
+
"lte": 2,
|
|
78
|
+
"allowTrivial": "The body lean read the same raw load and flipped its full +-5 deg, 10 deg in one tick, the shake on the car. Smoothed it measured 0.81 deg, so 2 deg catches the flip and leaves the real lean room."
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"entity": "player",
|
|
82
|
+
"component": "topSpeed",
|
|
83
|
+
"gte": 12,
|
|
84
|
+
"allowTrivial": "Four seconds of full throttle reach racing speed, so the corners the meter reads are taken at speed and not on the parked grid."
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { AudioBus } from "@threenative/core";
|
|
2
|
+
import type { Audio, Object3D } from "three";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The race's sound: an engine bed that pitches with the revs, a tyre squeal that opens with the
|
|
6
|
+
* drift angle, and a nitro burst on the button press.
|
|
7
|
+
*
|
|
8
|
+
* Every clip is baked from maths by `tools/make-racing-audio.mjs` — an engine loop has to be
|
|
9
|
+
* tonal and exactly periodic to be pitched live, and a recording of a real engine is neither. The
|
|
10
|
+
* contested part of this file is the **pitch law**: `engineRate` is the single place the needle
|
|
11
|
+
* becomes a frequency, and the playtest asserts it rises with speed.
|
|
12
|
+
*
|
|
13
|
+
* One runtime gap, named rather than papered over. Pitch is a `playbackRate` write, and the native
|
|
14
|
+
* host binds `playbackRate` on an audio source as a *passive* parameter
|
|
15
|
+
* (`runtime-native/src/audio/audio_bindings.cpp` `createPassiveAudioParamJS`): the write lands and
|
|
16
|
+
* nothing moves, so on native the bed plays at rate 1 with the same volume, squeal and burst. That
|
|
17
|
+
* is a degraded engine note, not a silent game, and no part of this file claims otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export const ENGINE_SOUND = {
|
|
20
|
+
/** The bed's playback rate at a standstill and at the rev limit. */
|
|
21
|
+
idleRate: 0.62,
|
|
22
|
+
redlineRate: 2.05,
|
|
23
|
+
/** The bed's level with the throttle closed, and the extra it gains under a nitro burn. */
|
|
24
|
+
volume: 0.34,
|
|
25
|
+
nitroVolume: 0.62,
|
|
26
|
+
/** The squeal's level at full lock in a slide, and the slip angle that counts as full lock. */
|
|
27
|
+
squealVolume: 0.5,
|
|
28
|
+
squealAngle: 0.55,
|
|
29
|
+
/** The burst's level. */
|
|
30
|
+
burstVolume: 0.85,
|
|
31
|
+
/** Baked by `tools/make-racing-audio.mjs`, logical paths into `assets/`. */
|
|
32
|
+
clips: {
|
|
33
|
+
engine: "engine-loop.wav",
|
|
34
|
+
squeal: "tyre-squeal.wav",
|
|
35
|
+
nitro: "nitro-burst.wav",
|
|
36
|
+
},
|
|
37
|
+
} as const;
|
|
38
|
+
|
|
39
|
+
/** The bed's pitch for one needle reading, 0 to 1: geometric, because pitch is logarithmic. */
|
|
40
|
+
export function engineRate(rpm: number): number {
|
|
41
|
+
const reading = Math.min(1, Math.max(0, rpm));
|
|
42
|
+
return ENGINE_SOUND.idleRate * (ENGINE_SOUND.redlineRate / ENGINE_SOUND.idleRate) ** reading;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface IEngineAudioInput {
|
|
46
|
+
/** Whether the race is running sound at all: a pause or the outcome panel silences the car. */
|
|
47
|
+
readonly running: boolean;
|
|
48
|
+
/** The needle, 0 to 1, from `gauges.ts`. */
|
|
49
|
+
readonly rpm: number;
|
|
50
|
+
/** The rear slip in radians and whether a tyre is sliding this tick. */
|
|
51
|
+
readonly driftAngle: number;
|
|
52
|
+
readonly sliding: boolean;
|
|
53
|
+
readonly nitroActive: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The bus a pause intent mutes: one race sounds at a time, so there is one handle to reach.
|
|
58
|
+
*
|
|
59
|
+
* A muted mix rather than a stopped one. `bus.pause()` holds every voice where it stands and
|
|
60
|
+
* `resume()` starts it again, which is right for a menu bed and wrong for an engine: a paused
|
|
61
|
+
* race must not be audible, and the frame loop does not tick while paused, so nothing would
|
|
62
|
+
* unmute a stopped voice from inside the scene.
|
|
63
|
+
*/
|
|
64
|
+
let sounding: EngineAudio | undefined;
|
|
65
|
+
|
|
66
|
+
export function setRaceAudioMuted(muted: boolean): void {
|
|
67
|
+
sounding?.bus.setVolume(muted ? 0 : 1, 0.15);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The car's own sound, over one `AudioBus`.
|
|
72
|
+
*
|
|
73
|
+
* `AudioBus` queues a cue played before the first gesture and starts it on the browser's unlock
|
|
74
|
+
* (`keydown`/`pointerdown`/`touchstart`, installed by the bus itself), so nothing here needs a
|
|
75
|
+
* "click to start" gate of its own.
|
|
76
|
+
*/
|
|
77
|
+
export class EngineAudio {
|
|
78
|
+
readonly bus: AudioBus;
|
|
79
|
+
/** The rate last written to the bed. 0 until the clip has loaded: a claim needs a sound. */
|
|
80
|
+
rate = 0;
|
|
81
|
+
#engine: Audio | undefined;
|
|
82
|
+
#squeal: Audio | undefined;
|
|
83
|
+
#nitro: AudioBuffer | undefined;
|
|
84
|
+
#nitroWasActive = false;
|
|
85
|
+
|
|
86
|
+
constructor(camera: Object3D, load: (name: string) => Promise<AudioBuffer>) {
|
|
87
|
+
this.bus = new AudioBus({ camera });
|
|
88
|
+
sounding = this;
|
|
89
|
+
const start = (name: keyof typeof ENGINE_SOUND.clips, cue: string, volume: number): void => {
|
|
90
|
+
void load(ENGINE_SOUND.clips[name])
|
|
91
|
+
.then((buffer) => {
|
|
92
|
+
if (name === "nitro") {
|
|
93
|
+
this.#nitro = buffer;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const voice = this.bus.play(buffer, { cue, loop: true, volume });
|
|
97
|
+
if (name === "engine") this.#engine = voice;
|
|
98
|
+
else this.#squeal = voice;
|
|
99
|
+
})
|
|
100
|
+
.catch((error: unknown) => {
|
|
101
|
+
// Sound is not the race. A missing clip is reported once, by name, and the rest plays.
|
|
102
|
+
console.warn(
|
|
103
|
+
`TN_RACING_AUDIO_MISSING ${name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
start("engine", "engine", ENGINE_SOUND.volume);
|
|
108
|
+
start("squeal", "tyre-squeal", 0);
|
|
109
|
+
start("nitro", "nitro-burst", 0);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
update(input: IEngineAudioInput): void {
|
|
113
|
+
const target = input.running ? engineRate(input.rpm) : ENGINE_SOUND.idleRate * 0.7;
|
|
114
|
+
if (this.#engine !== undefined && Math.abs(target - this.rate) > 0.004) {
|
|
115
|
+
this.#engine.setPlaybackRate(target);
|
|
116
|
+
this.rate = target;
|
|
117
|
+
}
|
|
118
|
+
// Three's own `setVolume` is a 10 ms `setTargetAtTime` ramp on the voice's gain, on every
|
|
119
|
+
// runtime: a step in a sounding loop is a click, and smoothing it twice only makes the swell
|
|
120
|
+
// late. The bed swells under a burn and settles back.
|
|
121
|
+
this.#engine?.setVolume(
|
|
122
|
+
input.running ? ENGINE_SOUND.volume + (input.nitroActive ? ENGINE_SOUND.nitroVolume : 0) : 0,
|
|
123
|
+
);
|
|
124
|
+
const squeal = input.running
|
|
125
|
+
? Math.min(1, Math.abs(input.driftAngle) / ENGINE_SOUND.squealAngle) *
|
|
126
|
+
ENGINE_SOUND.squealVolume
|
|
127
|
+
: 0;
|
|
128
|
+
this.#squeal?.setVolume(squeal * (input.sliding ? 1 : 0));
|
|
129
|
+
if (input.nitroActive && !this.#nitroWasActive && input.running && this.#nitro !== undefined)
|
|
130
|
+
this.bus.play(this.#nitro, { cue: "nitro-burst", volume: ENGINE_SOUND.burstVolume });
|
|
131
|
+
this.#nitroWasActive = input.nitroActive;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
dispose(): void {
|
|
135
|
+
if (sounding === this) sounding = undefined;
|
|
136
|
+
this.bus.dispose();
|
|
137
|
+
}
|
|
138
|
+
}
|