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
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Group,
|
|
10
10
|
InstancedMesh,
|
|
11
11
|
LineSegments,
|
|
12
|
+
MathUtils,
|
|
12
13
|
Mesh,
|
|
13
14
|
Object3D,
|
|
14
15
|
PlaneGeometry,
|
|
@@ -27,16 +28,15 @@ export interface IObstacle {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
function seededRandom(seed: number): () => number {
|
|
30
|
-
let state = seed;
|
|
31
|
+
let state = seed >>> 0;
|
|
31
32
|
return () => {
|
|
32
33
|
state = (state * 1664525 + 1013904223) >>> 0;
|
|
33
34
|
return state / 4294967296;
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
|
-
|
|
37
37
|
const smoothstep = (edge0: number, edge1: number, value: number) => {
|
|
38
38
|
const t = Math.max(0, Math.min(1, (value - edge0) / (edge1 - edge0)));
|
|
39
|
-
return t
|
|
39
|
+
return MathUtils.smoothstep(t, 0, 1);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
/** Glade-edge pines by hand, then a ring of forest further out. `[x, z, height]`. */
|
|
@@ -14,6 +14,9 @@ import { palette } from "./palette.js";
|
|
|
14
14
|
const MOVE_RADIUS = 72;
|
|
15
15
|
const EDGE = 36;
|
|
16
16
|
|
|
17
|
+
/** The knob's next point: `update` runs every frame, so it uses one instance. */
|
|
18
|
+
const knobPosition = new Vector2();
|
|
19
|
+
|
|
17
20
|
export interface ITouchPointer {
|
|
18
21
|
readonly position: Vector2;
|
|
19
22
|
}
|
|
@@ -101,13 +104,11 @@ export class TouchControls {
|
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
const center = this.#hasMoveAnchor ? this.#moveAnchor : this.#resting;
|
|
104
|
-
|
|
105
|
-
this.#
|
|
106
|
-
|
|
107
|
-
center.x + this.#input.move.x * MOVE_RADIUS,
|
|
108
|
-
center.y - this.#input.move.y * MOVE_RADIUS,
|
|
109
|
-
),
|
|
107
|
+
knobPosition.set(
|
|
108
|
+
center.x + this.#input.move.x * MOVE_RADIUS,
|
|
109
|
+
center.y - this.#input.move.y * MOVE_RADIUS,
|
|
110
110
|
);
|
|
111
|
+
place(this.#moveKnob, knobPosition);
|
|
111
112
|
this.#moveKnob.material = this.#hasMoveAnchor ? this.#activeMaterial : this.#idleMaterial;
|
|
112
113
|
this.#layout(size);
|
|
113
114
|
return this.#input;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated for you. Snowfall, the blizzard and the powder a boot kicks up. `GPUParticles3D` (the
|
|
2
2
|
// scene passes it in) owns
|
|
3
3
|
// the buffers, dispatch and lifetime; the flake's shape, colour, size, drift and fall are here.
|
|
4
|
-
import { type Sprite, Vector2 } from "three";
|
|
4
|
+
import { MathUtils, type Sprite, Vector2 } from "three";
|
|
5
5
|
import {
|
|
6
6
|
Fn,
|
|
7
7
|
atan,
|
|
@@ -233,8 +233,6 @@ export function createWeather(options: {
|
|
|
233
233
|
let wind = 0.4;
|
|
234
234
|
let drifted = { x: 0, z: 0 };
|
|
235
235
|
let fallen = 0;
|
|
236
|
-
const damp = (a: number, b: number, rate: number, dt: number) =>
|
|
237
|
-
a + (b - a) * (1 - Math.exp(-rate * Math.max(0, dt)));
|
|
238
236
|
return {
|
|
239
237
|
bursts: bursts.map((burst) => burst.particles),
|
|
240
238
|
burst(at, strength) {
|
|
@@ -253,10 +251,10 @@ export function createWeather(options: {
|
|
|
253
251
|
update(dt, centre, pixelScale, settings) {
|
|
254
252
|
fall.pixelScale.value = pixelScale;
|
|
255
253
|
time += dt;
|
|
256
|
-
storm = damp(storm, settings.blizzard ? 1 : 0, 0.95, dt);
|
|
254
|
+
storm = MathUtils.damp(storm, settings.blizzard ? 1 : 0, 0.95, dt);
|
|
257
255
|
const gust = 1 + 0.22 * Math.sin(time * 1.1) + 0.12 * Math.sin(time * 2.73 + 1.6);
|
|
258
256
|
const target = (settings.wind * (1 - storm) + (9.5 + settings.wind * 0.5) * storm) * gust;
|
|
259
|
-
wind = damp(wind, target, 2.3, dt);
|
|
257
|
+
wind = MathUtils.damp(wind, target, 2.3, dt);
|
|
260
258
|
drifted = { x: drifted.x + wind * dt, z: drifted.z + wind * 0.24 * dt };
|
|
261
259
|
fallen += settings.fallSpeed * (0.95 + storm * 0.7) * dt;
|
|
262
260
|
fall.drift.value.set(drifted.x, drifted.z);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
@import "tailwindcss";
|
|
2
2
|
|
|
3
|
+
/* `src/render/` is shader and material source: a word in its comments ("blur", "filter",
|
|
4
|
+
"table") became a real utility rule, which is what made a clean HUD look like a native-css
|
|
5
|
+
profile failure. Tailwind scans what it is told to scan. */
|
|
6
|
+
@source not "./render";
|
|
7
|
+
|
|
3
8
|
@theme {
|
|
4
9
|
--font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
5
10
|
--color-ink: #0c1c28;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Heightfield, SnowField } from "@threenative/core/world";
|
|
2
|
+
import { MathUtils } from "three";
|
|
2
3
|
|
|
3
4
|
/** The playable snowfield is a square this many metres across, centred on the origin. */
|
|
4
5
|
export const FIELD_SIZE = 24;
|
|
@@ -22,7 +23,7 @@ export const EXPLORER_LAYER = 0b1000;
|
|
|
22
23
|
|
|
23
24
|
function smoothstep(edge0: number, edge1: number, value: number): number {
|
|
24
25
|
const t = Math.max(0, Math.min(1, (value - edge0) / (edge1 - edge0)));
|
|
25
|
-
return t
|
|
26
|
+
return MathUtils.smoothstep(t, 0, 1);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/** Rolling ground under the snow: gentle swells in the glade, hills beyond it. */
|
|
@@ -2,6 +2,7 @@ import tailwindcss from "@tailwindcss/vite";
|
|
|
2
2
|
import { watchAssets } from "@threenative/assets";
|
|
3
3
|
import react from "@vitejs/plugin-react";
|
|
4
4
|
import {
|
|
5
|
+
createEngineCatalogPlugin,
|
|
5
6
|
createEngineFreshnessPlugin,
|
|
6
7
|
createWebBrandPlugin,
|
|
7
8
|
webRuntimeDecoders,
|
|
@@ -10,6 +11,10 @@ import { defineConfig } from "vite";
|
|
|
10
11
|
import type { Plugin } from "vite";
|
|
11
12
|
import config from "./threenative.config.js";
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Recompiles assets/ into public/ while the dev server runs, so editing a texture does not
|
|
16
|
+
* need a rebuild. Serve-only by declaration: builds compile through `threenative build`.
|
|
17
|
+
*/
|
|
13
18
|
function assetsWatchPlugin(): Plugin {
|
|
14
19
|
return {
|
|
15
20
|
name: "threenative-assets-watch",
|
|
@@ -32,6 +37,7 @@ export default defineConfig({
|
|
|
32
37
|
plugins: [
|
|
33
38
|
createEngineFreshnessPlugin(),
|
|
34
39
|
createWebBrandPlugin(),
|
|
40
|
+
createEngineCatalogPlugin(),
|
|
35
41
|
react(),
|
|
36
42
|
tailwindcss(),
|
|
37
43
|
assetsWatchPlugin(),
|
|
@@ -11,7 +11,7 @@ Detail for each step: `threenative-capabilities` skill. Do the steps in order. A
|
|
|
11
11
|
|
|
12
12
|
1. **Kit** (new game only): `engine_search_capabilities {situation: "<the whole request>", scope: "request"}` returns the matching starter kit first. This folder is already a kit.
|
|
13
13
|
2. **Mechanics**: per mechanic, `engine_search_references {situation}`, then `engine_reference_detail` on each hit for pinned constants and feel. To see a mechanic move, `engine_watch_reference {query: "<game> <mechanic>"}` returns a contact sheet of real gameplay. Borrow mechanics only: no code, level layouts, character names or art. Cite `file:line`.
|
|
14
|
-
3. **Built-ins**: per mechanic, system or symptom, `engine_search_capabilities {situation, scope: "mechanic"}
|
|
14
|
+
3. **Built-ins**: per mechanic, system or symptom, `engine_search_capabilities {situation, scope: "mechanic"}`; rows answer; `engine_capability_detail` only for omitted symbols. Constraints are binding. `verdict: "none"` means the game writes it in `src/`.
|
|
15
15
|
4. **Plan** (new game, or a change to several systems): `prd-creator` with the kit, references and built-ins. With a user, wait for explicit approval, then implement. With no user (`claude -p`, a script), record the plan and assumptions, then continue.
|
|
16
16
|
5. **Assets**: `asset_search_sources`, the source's search tool, then `asset_download_file`; record source and licence in `CREDITS.md`. Nothing fits: `sculpt_plan`. A rigged GLB: `animation_inspect` (`threenative-assets` skill).
|
|
17
17
|
6. **Build**: gameplay in `src/`, look in `src/render/` (`threenative-context` and `threenative-ui` skills). For parallel work, give each subagent one area and its files, then integrate.
|
|
@@ -30,7 +30,7 @@ A change to an existing game repeats steps 2-3 for that change, then steps 5-8.
|
|
|
30
30
|
- `threenative-assets`: a texture, HDRI, sound or model. `asset_search_sources`, `asset_download_file`, `audio_search_assets`, `mesh_optimize`.
|
|
31
31
|
- `threenative-sculpt`: a bespoke mesh or character from a reference image. `sculpt_plan`, `sculpt_spec_gate`, `sculpt_compare`, `sculpt_pass_gate`.
|
|
32
32
|
- `threenative-animation`: a rigged GLB with a held prop, foot slide or loop seam. `animation_inspect`, `animation_attach`, `animation_verify`.
|
|
33
|
-
- `threenative-terrain`:
|
|
33
|
+
- `threenative-terrain`: any terrain, from words. `terrain_generate`.
|
|
34
34
|
- `threenative-devtools`: after `npx @threenative/playtest trace` names no cause. `performance_start_trace`, `performance_analyze_insight`.
|
|
35
35
|
<!-- /shared -->
|
|
36
36
|
|
|
@@ -43,7 +43,7 @@ Exposure policy: `src/render/exposure.ts` (`node_modules/create-threenative/agen
|
|
|
43
43
|
Kit notes: `node_modules/create-threenative/agent-docs/references/kit-starter.md`.
|
|
44
44
|
<!-- /shared -->
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
`Play`: a grid test arena (`src/render/arena.ts`) with a pickup, crate, jump gap and spawn; `platform()` builds both course ends.
|
|
47
47
|
React mounts from `src/main.ts`; `src/game.ts` is portable. This repository owns gameplay and every visible choice in `src/render/`.
|
|
48
48
|
|
|
49
49
|
<!-- shared: kit-commands -->
|
|
@@ -56,6 +56,7 @@ pnpm build --target desktop # also: web, android, ios
|
|
|
56
56
|
pnpm studio # open the game in Studio
|
|
57
57
|
pnpm test:native # native proof
|
|
58
58
|
npx threenative doctor # build, import, device or blank-frame failure
|
|
59
|
+
npx threenative doctor --fix # refresh agent files
|
|
59
60
|
```
|
|
60
61
|
<!-- /shared -->
|
|
61
62
|
|
|
@@ -65,6 +66,7 @@ npx threenative doctor # build, import, device or blank-frame failure
|
|
|
65
66
|
Each is on by default with a named override. Detail: `node_modules/create-threenative/agent-docs/references/conventions.md#<id>`.
|
|
66
67
|
|
|
67
68
|
- **Look** `#look`: filmic curve, metered auto exposure. Override: `tonemapMode: "aces"`; `autoExposureEnabled: false` + `exposure`. Marker: `TN_WORLD_ENVIRONMENT`.
|
|
69
|
+
- **Ambient occlusion** `#ao-indirect`: darkens indirect light only, not the sun. Override: `gtaoIndirectOnly: false`; `gtaoEnabled: false`. Marker: `TN_WORLD_ENVIRONMENT`.
|
|
68
70
|
- **Quality tier (`src/render/quality.ts`)** `#quality`: GPU class picks `high`, `medium` or `low`. Override: `setupPost(..., { tier: "low" })`. Marker: `TN_QUALITY_TIER`.
|
|
69
71
|
- **Resolution scale** `#resolution`: `"auto"`, 0.85 on mobile-low. Override: numeric `resolutionScale`. Marker: `TN_FRAME_BUDGET`.
|
|
70
72
|
- **Budget real time for the look** `#frame-budget`: frame meter and scene verdict on. Override: `frameBudget: false`. Marker: `TN_FRAME_BUDGET`, `TN_SCENE_WARNING`.
|
|
@@ -92,12 +94,15 @@ Each is on by default with a named override. Detail: `node_modules/create-threen
|
|
|
92
94
|
- **Frame spans** `#spans`: off. Override: `TN_FRAME_SPANS=1`. Marker: `TN_FRAME_SPANS`.
|
|
93
95
|
- **Multiplayer** `#net`: none; unsupported transport rejects. Override: `connect` from `@threenative/core/net` with four limits. Marker: `TN_NET_UNAVAILABLE`.
|
|
94
96
|
- **Desktop window** `#desktop-mode`: CLI, then `display.fullscreen`, then `window.maximized`. Override: `--windowed`; `--maximized`; `--fullscreen`.
|
|
97
|
+
- **CPU priority** `#cpu-priority`: game threads first. Override: `display.priority: "normal"`. Marker: `TN_PROCESS_PRIORITY`.
|
|
95
98
|
- **Terrain** `#terrain`: authored in the game. Override: optional `@threenative/terrain`; `references/terrain-authoring.md`.
|
|
96
99
|
- **Navigation** `#navigation`: none; browser-only WASM. Override: import `@threenative/physics/navigation` on purpose.
|
|
100
|
+
- **Controller** `#gamepad`: W3C standard mapping on every pad, radial dead zone `0.2`, and a button press or a decisive stick move claims which pad is read. Override: `gamepadDeadZone: 0` for raw axes. Marker: `TN_GAMEPAD`.
|
|
97
101
|
- **Move input** `#move-axis`: `input.vector("move").y` is +up. Override: one explicit `-move.y` conversion.
|
|
98
102
|
- **Scene change** `#scene-change`: `ctx.goto(name)` keeps state. Override: `game.goto(name)` resets state.
|
|
99
103
|
- **Randomness** `#seed`: unseeded. Override: `defineGame({ seed })`.
|
|
100
104
|
- **Engine** `#engine`: owned C++ engine. Override: `engine: "threejs"` only when the user asks. Marker: `TN_NATIVE_ENGINE_UNBOUND`.
|
|
105
|
+
- **Refused imports** `#engine-catalog`: refused `three` imports fail at their line. Override: `createEngineCatalogPlugin({ mode: "warn" })`. Marker: `TN_ENGINE_CATALOG`.
|
|
101
106
|
<!-- /shared -->
|
|
102
107
|
|
|
103
108
|
<!-- shared: kit-stuck -->
|
|
@@ -13,7 +13,7 @@ Detail for each step: `threenative-capabilities` skill. Do the steps in order. A
|
|
|
13
13
|
|
|
14
14
|
1. **Kit** (new game only): `engine_search_capabilities {situation: "<the whole request>", scope: "request"}` returns the matching starter kit first. This folder is already a kit.
|
|
15
15
|
2. **Mechanics**: per mechanic, `engine_search_references {situation}`, then `engine_reference_detail` on each hit for pinned constants and feel. To see a mechanic move, `engine_watch_reference {query: "<game> <mechanic>"}` returns a contact sheet of real gameplay. Borrow mechanics only: no code, level layouts, character names or art. Cite `file:line`.
|
|
16
|
-
3. **Built-ins**: per mechanic, system or symptom, `engine_search_capabilities {situation, scope: "mechanic"}
|
|
16
|
+
3. **Built-ins**: per mechanic, system or symptom, `engine_search_capabilities {situation, scope: "mechanic"}`; rows answer; `engine_capability_detail` only for omitted symbols. Constraints are binding. `verdict: "none"` means the game writes it in `src/`.
|
|
17
17
|
4. **Plan** (new game, or a change to several systems): `prd-creator` with the kit, references and built-ins. With a user, wait for explicit approval, then implement. With no user (`claude -p`, a script), record the plan and assumptions, then continue.
|
|
18
18
|
5. **Assets**: `asset_search_sources`, the source's search tool, then `asset_download_file`; record source and licence in `CREDITS.md`. Nothing fits: `sculpt_plan`. A rigged GLB: `animation_inspect` (`threenative-assets` skill).
|
|
19
19
|
6. **Build**: gameplay in `src/`, look in `src/render/` (`threenative-context` and `threenative-ui` skills). For parallel work, give each subagent one area and its files, then integrate.
|
|
@@ -32,7 +32,7 @@ A change to an existing game repeats steps 2-3 for that change, then steps 5-8.
|
|
|
32
32
|
- `threenative-assets`: a texture, HDRI, sound or model. `asset_search_sources`, `asset_download_file`, `audio_search_assets`, `mesh_optimize`.
|
|
33
33
|
- `threenative-sculpt`: a bespoke mesh or character from a reference image. `sculpt_plan`, `sculpt_spec_gate`, `sculpt_compare`, `sculpt_pass_gate`.
|
|
34
34
|
- `threenative-animation`: a rigged GLB with a held prop, foot slide or loop seam. `animation_inspect`, `animation_attach`, `animation_verify`.
|
|
35
|
-
- `threenative-terrain`:
|
|
35
|
+
- `threenative-terrain`: any terrain, from words. `terrain_generate`.
|
|
36
36
|
- `threenative-devtools`: after `npx @threenative/playtest trace` names no cause. `performance_start_trace`, `performance_analyze_insight`.
|
|
37
37
|
<!-- /shared -->
|
|
38
38
|
|
|
@@ -45,7 +45,7 @@ Exposure policy: `src/render/exposure.ts` (`node_modules/create-threenative/agen
|
|
|
45
45
|
Kit notes: `node_modules/create-threenative/agent-docs/references/kit-starter.md`.
|
|
46
46
|
<!-- /shared -->
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
`Play`: a grid test arena (`src/render/arena.ts`) with a pickup, crate, jump gap and spawn; `platform()` builds both course ends.
|
|
49
49
|
React mounts from `src/main.ts`; `src/game.ts` is portable. This repository owns gameplay and every visible choice in `src/render/`.
|
|
50
50
|
|
|
51
51
|
<!-- shared: kit-commands -->
|
|
@@ -58,6 +58,7 @@ pnpm build --target desktop # also: web, android, ios
|
|
|
58
58
|
pnpm studio # open the game in Studio
|
|
59
59
|
pnpm test:native # native proof
|
|
60
60
|
npx threenative doctor # build, import, device or blank-frame failure
|
|
61
|
+
npx threenative doctor --fix # refresh agent files
|
|
61
62
|
```
|
|
62
63
|
<!-- /shared -->
|
|
63
64
|
|
|
@@ -67,6 +68,7 @@ npx threenative doctor # build, import, device or blank-frame failure
|
|
|
67
68
|
Each is on by default with a named override. Detail: `node_modules/create-threenative/agent-docs/references/conventions.md#<id>`.
|
|
68
69
|
|
|
69
70
|
- **Look** `#look`: filmic curve, metered auto exposure. Override: `tonemapMode: "aces"`; `autoExposureEnabled: false` + `exposure`. Marker: `TN_WORLD_ENVIRONMENT`.
|
|
71
|
+
- **Ambient occlusion** `#ao-indirect`: darkens indirect light only, not the sun. Override: `gtaoIndirectOnly: false`; `gtaoEnabled: false`. Marker: `TN_WORLD_ENVIRONMENT`.
|
|
70
72
|
- **Quality tier (`src/render/quality.ts`)** `#quality`: GPU class picks `high`, `medium` or `low`. Override: `setupPost(..., { tier: "low" })`. Marker: `TN_QUALITY_TIER`.
|
|
71
73
|
- **Resolution scale** `#resolution`: `"auto"`, 0.85 on mobile-low. Override: numeric `resolutionScale`. Marker: `TN_FRAME_BUDGET`.
|
|
72
74
|
- **Budget real time for the look** `#frame-budget`: frame meter and scene verdict on. Override: `frameBudget: false`. Marker: `TN_FRAME_BUDGET`, `TN_SCENE_WARNING`.
|
|
@@ -94,12 +96,15 @@ Each is on by default with a named override. Detail: `node_modules/create-threen
|
|
|
94
96
|
- **Frame spans** `#spans`: off. Override: `TN_FRAME_SPANS=1`. Marker: `TN_FRAME_SPANS`.
|
|
95
97
|
- **Multiplayer** `#net`: none; unsupported transport rejects. Override: `connect` from `@threenative/core/net` with four limits. Marker: `TN_NET_UNAVAILABLE`.
|
|
96
98
|
- **Desktop window** `#desktop-mode`: CLI, then `display.fullscreen`, then `window.maximized`. Override: `--windowed`; `--maximized`; `--fullscreen`.
|
|
99
|
+
- **CPU priority** `#cpu-priority`: game threads first. Override: `display.priority: "normal"`. Marker: `TN_PROCESS_PRIORITY`.
|
|
97
100
|
- **Terrain** `#terrain`: authored in the game. Override: optional `@threenative/terrain`; `references/terrain-authoring.md`.
|
|
98
101
|
- **Navigation** `#navigation`: none; browser-only WASM. Override: import `@threenative/physics/navigation` on purpose.
|
|
102
|
+
- **Controller** `#gamepad`: W3C standard mapping on every pad, radial dead zone `0.2`, and a button press or a decisive stick move claims which pad is read. Override: `gamepadDeadZone: 0` for raw axes. Marker: `TN_GAMEPAD`.
|
|
99
103
|
- **Move input** `#move-axis`: `input.vector("move").y` is +up. Override: one explicit `-move.y` conversion.
|
|
100
104
|
- **Scene change** `#scene-change`: `ctx.goto(name)` keeps state. Override: `game.goto(name)` resets state.
|
|
101
105
|
- **Randomness** `#seed`: unseeded. Override: `defineGame({ seed })`.
|
|
102
106
|
- **Engine** `#engine`: owned C++ engine. Override: `engine: "threejs"` only when the user asks. Marker: `TN_NATIVE_ENGINE_UNBOUND`.
|
|
107
|
+
- **Refused imports** `#engine-catalog`: refused `three` imports fail at their line. Override: `createEngineCatalogPlugin({ mode: "warn" })`. Marker: `TN_ENGINE_CATALOG`.
|
|
103
108
|
<!-- /shared -->
|
|
104
109
|
|
|
105
110
|
<!-- shared: kit-stuck -->
|
|
@@ -52,34 +52,34 @@
|
|
|
52
52
|
},
|
|
53
53
|
"mobile-low": {
|
|
54
54
|
"contributions": {
|
|
55
|
-
"graphOutputChanged": ["
|
|
55
|
+
"graphOutputChanged": ["bloom", "vignette", "antialias"]
|
|
56
56
|
},
|
|
57
57
|
"stages": {
|
|
58
58
|
"excludes": ["ambientOcclusion", "ssgi", "traa", "motionBlur", "grade", "grain"],
|
|
59
|
-
"includes": ["
|
|
60
|
-
"order": ["
|
|
59
|
+
"includes": ["bloom", "vignette", "antialias"],
|
|
60
|
+
"order": ["bloom", "vignette", "antialias"]
|
|
61
61
|
},
|
|
62
62
|
"tier": "low"
|
|
63
63
|
},
|
|
64
64
|
"mobile-mid": {
|
|
65
65
|
"contributions": {
|
|
66
|
-
"graphOutputChanged": ["
|
|
66
|
+
"graphOutputChanged": ["bloom", "vignette", "antialias"]
|
|
67
67
|
},
|
|
68
68
|
"stages": {
|
|
69
69
|
"excludes": ["ambientOcclusion", "ssgi", "traa", "motionBlur", "grade", "grain"],
|
|
70
|
-
"includes": ["
|
|
71
|
-
"order": ["
|
|
70
|
+
"includes": ["bloom", "vignette", "antialias"],
|
|
71
|
+
"order": ["bloom", "vignette", "antialias"]
|
|
72
72
|
},
|
|
73
73
|
"tier": "low"
|
|
74
74
|
},
|
|
75
75
|
"software": {
|
|
76
76
|
"contributions": {
|
|
77
|
-
"graphOutputChanged": ["
|
|
77
|
+
"graphOutputChanged": ["bloom", "vignette", "antialias"]
|
|
78
78
|
},
|
|
79
79
|
"stages": {
|
|
80
80
|
"excludes": ["ambientOcclusion", "ssgi", "traa", "motionBlur", "grade", "grain"],
|
|
81
|
-
"includes": ["
|
|
82
|
-
"order": ["
|
|
81
|
+
"includes": ["bloom", "vignette", "antialias"],
|
|
82
|
+
"order": ["bloom", "vignette", "antialias"]
|
|
83
83
|
},
|
|
84
84
|
"tier": "low"
|
|
85
85
|
}
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"format:check": "biome format src"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@threenative/core": "0.3.
|
|
24
|
-
"@threenative/physics": "0.3.
|
|
25
|
-
"@threenative/ui": "0.3.
|
|
23
|
+
"@threenative/core": ">=0.3.15",
|
|
24
|
+
"@threenative/physics": ">=0.3.15",
|
|
25
|
+
"@threenative/ui": ">=0.3.15",
|
|
26
26
|
"react": "19.2.0",
|
|
27
27
|
"react-dom": "19.2.0",
|
|
28
28
|
"react-reconciler": "0.33.0",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@tailwindcss/vite": "4.3.3",
|
|
33
|
-
"@threenative/assets": "0.3.
|
|
34
|
-
"@threenative/playtest": "0.3.
|
|
33
|
+
"@threenative/assets": ">=0.3.16",
|
|
34
|
+
"@threenative/playtest": ">=0.3.15",
|
|
35
35
|
"@types/react": "19.2.0",
|
|
36
36
|
"@types/react-dom": "19.2.0",
|
|
37
37
|
"@types/three": "0.187.0",
|
|
38
38
|
"@vitejs/plugin-react": "6.0.5",
|
|
39
|
-
"create-threenative": "0.2.
|
|
39
|
+
"create-threenative": "0.2.20",
|
|
40
40
|
"esbuild": "0.27.0",
|
|
41
41
|
"playwright": "1.62.1",
|
|
42
42
|
"tailwindcss": "4.3.3",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"eslint": "10.13.0"
|
|
48
48
|
},
|
|
49
49
|
"optionalDependencies": {
|
|
50
|
-
"@threenative/runtime-native": "0.3.
|
|
50
|
+
"@threenative/runtime-native": ">=0.3.15"
|
|
51
51
|
},
|
|
52
52
|
"overrides": {
|
|
53
53
|
"sharp": ">=0.35.4",
|
|
@@ -16,6 +16,9 @@ export class Crate {
|
|
|
16
16
|
y: number,
|
|
17
17
|
z: number,
|
|
18
18
|
material: Material,
|
|
19
|
+
// On a tier with a sun shadow sharp enough to ground it, the blob is a second, blurred shadow
|
|
20
|
+
// beside the sun's; Play.ts draws it only on `low`, which has no ambient occlusion pass.
|
|
21
|
+
contactShadow: () => boolean = () => true,
|
|
19
22
|
) {
|
|
20
23
|
this.mesh = new Mesh(roundedBox(1, 1, 1), material);
|
|
21
24
|
this.mesh.position.set(x, y, z);
|
|
@@ -31,8 +34,8 @@ export class Crate {
|
|
|
31
34
|
from.set(x, y, z);
|
|
32
35
|
to.set(x, y - 6, z);
|
|
33
36
|
const gap = ctx.physics.directSpaceState.intersectRay({ from, to })?.distance;
|
|
34
|
-
this.#shadow.object.visible = gap !== undefined;
|
|
35
|
-
if (gap === undefined) return;
|
|
37
|
+
this.#shadow.object.visible = gap !== undefined && contactShadow();
|
|
38
|
+
if (!this.#shadow.object.visible || gap === undefined) return;
|
|
36
39
|
this.#shadow.object.position.set(x, y - gap + 0.03, z);
|
|
37
40
|
this.#shadow.fade(Math.max(0, 1 - (gap - 0.5) / 1.5));
|
|
38
41
|
});
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { BlendSpace1D, type ICtx, SkeletalMesh3D } from "@threenative/core";
|
|
2
2
|
import { CharacterBody3D, CollisionShape3D, type IPhysicsContext } from "@threenative/physics";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type AnimationClip,
|
|
5
|
+
Group,
|
|
6
|
+
MathUtils,
|
|
7
|
+
type Mesh,
|
|
8
|
+
type Object3D,
|
|
9
|
+
Quaternion,
|
|
10
|
+
Vector3,
|
|
11
|
+
} from "three";
|
|
4
12
|
import { type IStarterConventions, preparePlayerConventions } from "../conventions.js";
|
|
5
13
|
import type { ITouchInput } from "../render/touch-controls.js";
|
|
6
14
|
import type { GameState } from "../state.js";
|
|
@@ -143,7 +151,7 @@ export class Player {
|
|
|
143
151
|
// Touch walks until the stick is fully deflected; no separate run button.
|
|
144
152
|
const running = ctx.input.pressed("run") || (touch?.move.length() ?? 0) >= 1;
|
|
145
153
|
const speed = running ? RUN_SPEED : WALK_SPEED;
|
|
146
|
-
const ease = 1
|
|
154
|
+
const ease = MathUtils.damp(0, 1, 1 / 0.15, dt);
|
|
147
155
|
const moveZ = -move.y;
|
|
148
156
|
this.body.velocity.x += (move.x * speed - this.body.velocity.x) * ease;
|
|
149
157
|
this.body.velocity.z += (moveZ * speed - this.body.velocity.z) * ease;
|
|
@@ -19,17 +19,18 @@ const game = defineGame<GameState, IPhysicsContext>({
|
|
|
19
19
|
right: ["ArrowRight", "KeyD"],
|
|
20
20
|
up: ["ArrowUp", "KeyW"],
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
// Pad buttons use the W3C standard numbers: 0 is ✕ on a DualShock, 7 is R2, 9 is OPTIONS.
|
|
23
|
+
run: { buttons: [7], keys: ["ShiftLeft", "ShiftRight"] },
|
|
23
24
|
jump: { buttons: [0], keys: ["Space"] },
|
|
24
25
|
flagGust: { keys: ["KeyG"] },
|
|
25
|
-
restart: { keys: ["KeyR"] },
|
|
26
|
+
restart: { buttons: [9], keys: ["KeyR"] },
|
|
26
27
|
// Wheel, pinch and the right stick share one portable camera intent. Negative DOM deltaY
|
|
27
28
|
// (toward-user) is positive scroll intent on browser and native; the scene owns the framing.
|
|
28
29
|
zoom: { gamepadAxes: [3], pinch: true, scroll: true },
|
|
29
30
|
},
|
|
30
31
|
plugins: [rapier(), replay(), playtest()],
|
|
31
32
|
display: config.display,
|
|
32
|
-
|
|
33
|
+
renderer: config.renderer,
|
|
33
34
|
scenes: { play: Play },
|
|
34
35
|
seed: 90210,
|
|
35
36
|
start: "play",
|
|
@@ -66,6 +66,11 @@ export function createAdaptiveQuality(
|
|
|
66
66
|
let lastChange = Number.NEGATIVE_INFINITY;
|
|
67
67
|
let overloaded = 0;
|
|
68
68
|
let healthy = 0;
|
|
69
|
+
// What a raise that failed cost, as a ratio of the cost before it, by the tier it fell back to. A raise from that
|
|
70
|
+
// tier waits until the predicted cost fits: retrying on headroom alone switched medium's shadows on and off every
|
|
71
|
+
// few seconds where low fits only without them (PRD-871).
|
|
72
|
+
const raiseCost = new Map<QualityTier, number>();
|
|
73
|
+
let raisedFrom: { tier: QualityTier; costMs: number } | undefined;
|
|
69
74
|
const finite = (value: number | undefined): value is number =>
|
|
70
75
|
value !== undefined && Number.isFinite(value);
|
|
71
76
|
return {
|
|
@@ -156,6 +161,15 @@ export function createAdaptiveQuality(
|
|
|
156
161
|
if (direction === 0) return report("steady");
|
|
157
162
|
const next = QUALITY_TIERS[QUALITY_TIERS.indexOf(tier) + direction];
|
|
158
163
|
if (next === undefined) return report(direction < 0 ? "at-floor" : "at-ceiling");
|
|
164
|
+
const ratio = raiseCost.get(tier);
|
|
165
|
+
if (
|
|
166
|
+
direction > 0 &&
|
|
167
|
+
ratio !== undefined &&
|
|
168
|
+
costMs * ratio > budgetMs * (1 - policy.headroom)
|
|
169
|
+
) {
|
|
170
|
+
healthy = 0;
|
|
171
|
+
return report("predicted");
|
|
172
|
+
}
|
|
159
173
|
const time = now();
|
|
160
174
|
if (!Number.isFinite(time)) throw new Error("quality clock must return finite milliseconds.");
|
|
161
175
|
if (time - lastChange < policy.cooldownMs) {
|
|
@@ -163,6 +177,9 @@ export function createAdaptiveQuality(
|
|
|
163
177
|
healthy = 0;
|
|
164
178
|
return report("cooldown");
|
|
165
179
|
}
|
|
180
|
+
if (direction < 0 && raisedFrom?.tier === next)
|
|
181
|
+
raiseCost.set(next, costMs / raisedFrom.costMs);
|
|
182
|
+
raisedFrom = direction > 0 ? { tier, costMs } : undefined;
|
|
166
183
|
tier = next;
|
|
167
184
|
lastChange = time;
|
|
168
185
|
overloaded = 0;
|
|
@@ -235,7 +235,13 @@ function march(
|
|
|
235
235
|
* approximation in RenderMultiScatteredLuminanceLutCS); the full sphere gather overestimated the
|
|
236
236
|
* ground bounce against the Unreal frames by up to 1.6x, so this uses the same two rays.
|
|
237
237
|
*/
|
|
238
|
+
// The table depends on no input: build it once a run, not once a sky refresh.
|
|
239
|
+
let multipleScattering: Multi | undefined;
|
|
238
240
|
function multipleScatteringTable(): Multi {
|
|
241
|
+
multipleScattering ??= buildMultipleScatteringTable();
|
|
242
|
+
return multipleScattering;
|
|
243
|
+
}
|
|
244
|
+
function buildMultipleScatteringTable(): Multi {
|
|
239
245
|
const nh = 12;
|
|
240
246
|
const nc = 16;
|
|
241
247
|
const dirs: Vec3[] = [
|
|
@@ -10,6 +10,11 @@ function finiteColor(color: Color) {
|
|
|
10
10
|
color.b >= 0
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Throws when a `IBacklightControls` is missing a light or names a non-finite gain.
|
|
15
|
+
*
|
|
16
|
+
* @situation fail loudly instead of drawing an unlit material when a backlight has no key light
|
|
17
|
+
*/
|
|
13
18
|
export function validateControls(controls: IBacklightControls) {
|
|
14
19
|
if (
|
|
15
20
|
!Number.isFinite(controls.rimGain) ||
|
|
@@ -30,6 +35,11 @@ export function validateControls(controls: IBacklightControls) {
|
|
|
30
35
|
"Backlight controls require finite nonnegative gains, a direction and angular size in (0, 1.5].",
|
|
31
36
|
);
|
|
32
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* The light and camera a backlit material reads its key direction from.
|
|
40
|
+
*
|
|
41
|
+
* @situation point the backlight at the sun the scene actually has
|
|
42
|
+
*/
|
|
33
43
|
export function resolveKey(
|
|
34
44
|
controls: IBacklightControls,
|
|
35
45
|
direction: Vector3,
|
|
@@ -48,10 +48,10 @@ export interface IBacklightControls {
|
|
|
48
48
|
const graphs = new WeakMap<IBacklightControls, ReturnType<typeof createGraph>>();
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
51
|
+
* The game's material, wrapped in a node twin that adds the backlit sheen it was given.
|
|
52
|
+
*
|
|
53
|
+
* @situation give a material a launcher's glow without editing its colour, texture or roughness
|
|
54
|
+
* @constraint every colour, gain and angular size is the caller's; this copies the game's material and adds light
|
|
55
55
|
*/
|
|
56
56
|
export function backlightMaterial(source: MeshStandardMaterial, controls: IBacklightControls) {
|
|
57
57
|
if (
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// Camera framing is one of the loudest things in a screenshot, so it lives
|
|
10
10
|
// here in your repo rather than behind a framework option.
|
|
11
11
|
import type { PerspectiveCamera, Vector3 } from "three";
|
|
12
|
-
import { Vector3 as Vec3 } from "three";
|
|
12
|
+
import { MathUtils, Vector3 as Vec3 } from "three";
|
|
13
13
|
|
|
14
14
|
export interface ISpringArmOptions {
|
|
15
15
|
/** Where the camera sits relative to its target, before smoothing. */
|
|
@@ -102,7 +102,7 @@ export function createSpringArm(
|
|
|
102
102
|
desired.copy(target).add(targetOffset());
|
|
103
103
|
// 1 - e^(-dt/damping): the frame-rate-independent form of a lerp. At 30fps
|
|
104
104
|
// and 120fps the camera ends up in the same place after the same second.
|
|
105
|
-
camera.position.lerp(desired, 1
|
|
105
|
+
camera.position.lerp(desired, MathUtils.damp(0, 1, 1 / damping, dt));
|
|
106
106
|
clear(target);
|
|
107
107
|
camera.lookAt(aim.copy(target).add(lookAhead));
|
|
108
108
|
};
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// Independent CPU implementation. The material samples four Unreal textures that this repository
|
|
7
7
|
// must not carry, so each one is regenerated here from a seeded noise whose per-channel value
|
|
8
8
|
// quantiles and correlation lengths match the Unreal texture (measured, see the spec).
|
|
9
|
+
import { MathUtils } from "three";
|
|
10
|
+
|
|
9
11
|
import {
|
|
10
12
|
BOTTOM_KM,
|
|
11
13
|
CAMERA_KM,
|
|
@@ -110,7 +112,7 @@ const PROFILE_COEFFICIENTS = [
|
|
|
110
112
|
const clamp = (v: number): number => Math.max(0, Math.min(1, v));
|
|
111
113
|
const smooth = (v: number): number => {
|
|
112
114
|
const t = clamp(v);
|
|
113
|
-
return t
|
|
115
|
+
return MathUtils.smoothstep(t, 0, 1);
|
|
114
116
|
};
|
|
115
117
|
const mod = (a: number, n: number): number => ((a % n) + n) % n;
|
|
116
118
|
|
|
@@ -282,6 +284,19 @@ export interface ICloudTextures {
|
|
|
282
284
|
}
|
|
283
285
|
const textureCache = new Map<number, ICloudTextures>();
|
|
284
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Hand back the textures an earlier run generated, so `cloudTextures(seed)` skips ~0.6 s of noise
|
|
289
|
+
* on the main thread. The scene keeps them between runs with `ctx.assets.memo`.
|
|
290
|
+
*/
|
|
291
|
+
export function primeCloudTextures(textures: ICloudTextures, seed = 631): void {
|
|
292
|
+
if (
|
|
293
|
+
textures.pattern.length !== PATTERN_SIZE ** 2 * 4 ||
|
|
294
|
+
textures.volume.length !== VOLUME_SIZE ** 3 * 2
|
|
295
|
+
)
|
|
296
|
+
throw new Error("cloud textures do not match PATTERN_SIZE and VOLUME_SIZE.");
|
|
297
|
+
textureCache.set(seed, textures);
|
|
298
|
+
}
|
|
299
|
+
|
|
285
300
|
export function cloudTextures(seed = 631): ICloudTextures {
|
|
286
301
|
const cached = textureCache.get(seed);
|
|
287
302
|
if (cached) return cached;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated for you. This is ordinary Three.js — edit or delete it freely.
|
|
2
2
|
// ThreeNative does not read this file.
|
|
3
3
|
//
|
|
4
|
-
// A baked blob under a prop: what makes a crate sit on the floor on
|
|
4
|
+
// A baked blob under a prop: what makes a crate sit on the floor on the `low` tier. Unreal grounds a
|
|
5
5
|
// contact with ambient occlusion, which is on by default (UE 5.8.3: Engine/Source/Runtime/Engine/
|
|
6
6
|
// Private/SceneView.cpp:168-173, Scene.cpp:567) and off at its Low scalability level
|
|
7
7
|
// (Engine/Config/BaseScalability.ini:568-569); its lights add no contact shadow of their own
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// Generated for you. Scene-owned material assignments; no engine appearance hooks.
|
|
2
|
-
import type { Camera, DirectionalLight, Object3D, Scene, Texture } from "three";
|
|
3
|
-
import type { IBacklightControls } from "./backlightMaterial.js";
|
|
4
1
|
import {
|
|
5
2
|
type IEnvironmentMeasurement,
|
|
6
3
|
measureEnvironment,
|
|
7
4
|
reportEnvironmentContribution,
|
|
8
|
-
} from "
|
|
5
|
+
} from "@threenative/core/render/environment";
|
|
9
6
|
import {
|
|
10
7
|
type IEnvironmentSourceSnapshot,
|
|
11
8
|
captureEnvironmentSnapshot,
|
|
12
9
|
environmentSnapshotCurrent,
|
|
13
|
-
} from "
|
|
10
|
+
} from "@threenative/core/render/environment";
|
|
11
|
+
// Generated for you. Scene-owned material assignments; no engine appearance hooks.
|
|
12
|
+
import type { Camera, DirectionalLight, Object3D, Scene, Texture } from "three";
|
|
13
|
+
import type { IBacklightControls } from "./backlightMaterial.js";
|
|
14
14
|
import { type ILightingConvention, createLightingConvention } from "./lighting.js";
|
|
15
15
|
import { createMaterialAssignments } from "./materialAssignments.js";
|
|
16
16
|
import { type IMaterialLightingEnvironment, materialLightingEnabled } from "./quality.js";
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
DoubleSide,
|
|
12
12
|
Float32BufferAttribute,
|
|
13
13
|
LinearMipmapLinearFilter,
|
|
14
|
+
MathUtils,
|
|
14
15
|
MeshStandardMaterial,
|
|
15
16
|
RepeatWrapping,
|
|
16
17
|
SRGBColorSpace,
|
|
@@ -86,8 +87,8 @@ function grainNormalTexture(size = 128): DataTexture {
|
|
|
86
87
|
const y0 = Math.floor(v);
|
|
87
88
|
const fx = u - x0;
|
|
88
89
|
const fy = v - y0;
|
|
89
|
-
const sx = fx
|
|
90
|
-
const sy = fy
|
|
90
|
+
const sx = MathUtils.smoothstep(fx, 0, 1);
|
|
91
|
+
const sy = MathUtils.smoothstep(fy, 0, 1);
|
|
91
92
|
const at = (i: number, j: number): number =>
|
|
92
93
|
values[(((j % count) + count) % count) * count + (((i % count) + count) % count)] ?? 0;
|
|
93
94
|
const top = at(x0, y0) + (at(x0 + 1, y0) - at(x0, y0)) * sx;
|