create-threenative 0.2.9 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-docs/references/assertion-reference.md +109 -3
- package/agent-docs/references/auto-exposure.md +28 -45
- package/agent-docs/references/build-profiles.md +1 -1
- package/agent-docs/references/capability-reference.md +527 -44
- package/agent-docs/references/debug-surface.md +64 -0
- package/agent-docs/references/finding-assets.md +11 -12
- package/agent-docs/references/performance-basics.md +19 -0
- package/agent-docs/references/trace-a-slow-frame.md +21 -0
- package/agent-docs/references/visual-baseline.md +23 -4
- package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
- package/agent-files/.agents/skills/prd-creator/SKILL.md +17 -6
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +87 -23
- package/agent-files/.agents/skills/threenative-performance/SKILL.md +12 -11
- package/agent-files/.claude/hooks/ponytail-context.mjs +1 -1
- package/agent-files/scripts/reference.mjs +9 -4
- package/capabilities.json +739 -50
- package/dist/index.d.ts +40 -6
- package/dist/index.js +229 -36
- package/dist/quality.d.ts +12 -0
- package/dist/quality.js +166747 -0
- package/dist/threenative.js +60 -44
- package/dist/web-engine-gltf-loader.js +2 -0
- package/dist/web-engine-mesh-bvh-webgpu.js +1 -1
- package/dist/web-engine-mesh-bvh.js +7 -0
- package/dist/web-engine-post-effects.js +645 -19
- package/dist/web-engine-runtime.js +3528 -343
- package/package.json +19 -9
- package/template-assets/assets/bay-PROVENANCE.md +21 -0
- package/template-assets/assets/bay-ground.webp +0 -0
- package/template-assets/assets/bay-metal.webp +0 -0
- package/template-assets/assets/bay-pavement-normal.webp +0 -0
- package/template-assets/assets/bay-pavement.webp +0 -0
- package/template-assets/assets/bay-plaster-normal.webp +0 -0
- package/template-assets/assets/bay-plaster.webp +0 -0
- package/template-assets/assets/bay-wood-normal.webp +0 -0
- package/template-assets/assets/bay-wood.webp +0 -0
- package/template-assets/assets/tex-PROVENANCE.md +25 -0
- package/template-assets/assets/tex-bark-normal.webp +0 -0
- package/template-assets/assets/tex-bark.webp +0 -0
- package/template-assets/assets/tex-birch-bark.webp +0 -0
- package/template-assets/assets/tex-grass.webp +0 -0
- package/template-assets/assets/tex-planks-normal.webp +0 -0
- package/template-assets/assets/tex-planks.webp +0 -0
- package/template-assets/assets/tex-rock-normal.webp +0 -0
- package/template-assets/assets/tex-rock.webp +0 -0
- package/template-assets/assets/tex-roof-tiles-normal.webp +0 -0
- package/template-assets/assets/tex-roof-tiles.webp +0 -0
- package/template-assets/assets/tex-sand-normal.webp +0 -0
- package/template-assets/assets/tex-sand.webp +0 -0
- package/template-assets/assets/tex-stone-wall-normal.webp +0 -0
- package/template-assets/assets/tex-stone-wall.webp +0 -0
- package/template-assets/kitExposure.ts +20 -0
- package/template-assets/patches/three@0.185.1.patch +481 -272
- package/template-assets/quality/biome.json +7 -0
- package/template-assets/quality/eslint.config.js +3 -0
- package/template-assets/realistic-ocean/README.md +113 -0
- package/template-assets/realistic-ocean/install.mjs +56 -0
- package/template-assets/realistic-ocean/src/realisticOcean.ts +151 -0
- package/template-assets/realistic-ocean/src/realisticOceanLifetime.ts +29 -0
- package/template-assets/realistic-ocean/src/render/REALISTIC-OCEAN-LICENSE.txt +25 -0
- package/template-assets/realistic-ocean/src/render/realisticSea.ts +642 -0
- package/template-assets/realistic-ocean/src/render/realisticSeaMaps.ts +311 -0
- package/template-assets/realistic-ocean/src/render/realisticSpectrum.ts +289 -0
- package/templates/AGENTS.md +21 -0
- package/templates/CLAUDE.md +23 -0
- package/templates/action-rpg/.codex/config.toml +6 -2
- package/templates/action-rpg/.cursor/mcp.json +8 -2
- package/templates/action-rpg/.gemini/settings.json +8 -2
- package/templates/action-rpg/.mcp.json +8 -2
- package/templates/action-rpg/.vscode/mcp.json +9 -2
- package/templates/action-rpg/.zed/settings.json +9 -2
- package/templates/action-rpg/AGENTS.md +11 -11
- package/templates/action-rpg/CLAUDE.md +11 -11
- package/templates/action-rpg/opencode.json +10 -2
- package/templates/action-rpg/package.json +17 -11
- package/templates/action-rpg/playtests/combat.playtest.json +6 -0
- package/templates/action-rpg/playtests/inventory.playtest.json +22 -0
- package/templates/action-rpg/playtests/performance.playtest.json +1 -1
- package/templates/action-rpg/playtests/roll.playtest.json +112 -0
- package/templates/action-rpg/playtests/swing.playtest.json +55 -0
- package/templates/action-rpg/playtests/win.playtest.json +4 -4
- package/templates/action-rpg/src/entities/Fighter.ts +44 -4
- package/templates/action-rpg/src/entities/Player.ts +64 -12
- package/templates/action-rpg/src/render/atmosphere.ts +444 -0
- package/templates/action-rpg/src/render/backlightMaterial.ts +49 -18
- package/templates/action-rpg/src/render/clouds.ts +605 -0
- package/templates/action-rpg/src/render/dungeon.ts +8 -6
- package/templates/action-rpg/src/render/exposure.ts +11 -109
- package/templates/action-rpg/src/render/gpuSky.ts +752 -0
- package/templates/action-rpg/src/render/lighting.ts +27 -4
- package/templates/action-rpg/src/render/materialLighting.ts +2 -11
- package/templates/action-rpg/src/render/palette.ts +1 -0
- package/templates/action-rpg/src/render/postprocessing.ts +4 -4
- package/templates/action-rpg/src/render/props.ts +10 -8
- package/templates/action-rpg/src/render/quality.ts +56 -108
- package/templates/action-rpg/src/render/sky.ts +74 -1
- package/templates/action-rpg/src/scenes/Play.ts +16 -12
- package/templates/action-rpg/src/ui/CharacterPanel.tsx +7 -2
- package/templates/action-rpg/src/ui/Hud.tsx +5 -7
- package/templates/action-rpg/src/ui/InventoryPanel.tsx +14 -14
- package/templates/action-rpg/threenative.config.ts +3 -0
- package/templates/adventure/.codex/config.toml +23 -0
- package/templates/adventure/.cursor/mcp.json +38 -0
- package/templates/adventure/.gemini/settings.json +38 -0
- package/templates/adventure/.mcp.json +38 -0
- package/templates/adventure/.vscode/mcp.json +43 -0
- package/templates/adventure/.zed/settings.json +43 -0
- package/templates/adventure/AGENTS.md +60 -0
- package/templates/adventure/CLAUDE.md +62 -0
- package/templates/adventure/index.html +14 -0
- package/templates/adventure/kit.json +8 -0
- package/templates/adventure/native-playtests/survives.playtest.json +52 -0
- package/templates/adventure/opencode.json +49 -0
- package/templates/adventure/package.json +65 -0
- package/templates/adventure/playtests/boss.playtest.json +406 -0
- package/templates/adventure/playtests/combat.playtest.json +342 -0
- package/templates/adventure/playtests/controls.playtest.json +142 -0
- package/templates/adventure/playtests/explore.playtest.json +45 -0
- package/templates/adventure/playtests/flicker.playtest.json +206 -0
- package/templates/adventure/playtests/hearts.playtest.json +171 -0
- package/templates/adventure/playtests/lockon.playtest.json +256 -0
- package/templates/adventure/playtests/look.playtest.json +72 -0
- package/templates/adventure/playtests/move-hollow.playtest.json +106 -0
- package/templates/adventure/playtests/move.playtest.json +84 -0
- package/templates/adventure/playtests/performance.playtest.json +55 -0
- package/templates/adventure/playtests/puzzle.playtest.json +250 -0
- package/templates/adventure/playtests/stride.playtest.json +67 -0
- package/templates/adventure/playtests/survives.playtest.json +171 -0
- package/templates/adventure/playtests/thornback.playtest.json +267 -0
- package/templates/adventure/public/favicon.svg +4 -0
- package/templates/adventure/src/entities/Block.ts +114 -0
- package/templates/adventure/src/entities/Chest.ts +69 -0
- package/templates/adventure/src/entities/Door.ts +81 -0
- package/templates/adventure/src/entities/Dummy.ts +69 -0
- package/templates/adventure/src/entities/Flicker.ts +239 -0
- package/templates/adventure/src/entities/Hero.ts +561 -0
- package/templates/adventure/src/entities/LockOn.ts +180 -0
- package/templates/adventure/src/entities/Mossling.ts +249 -0
- package/templates/adventure/src/entities/Switch.ts +49 -0
- package/templates/adventure/src/entities/Thornback.ts +238 -0
- package/templates/adventure/src/entities/Warden.ts +196 -0
- package/templates/adventure/src/game.ts +65 -0
- package/templates/adventure/src/interact.ts +63 -0
- package/templates/adventure/src/level/Hollow.ts +240 -0
- package/templates/adventure/src/level/Vale.ts +383 -0
- package/templates/adventure/src/main.ts +18 -0
- package/templates/adventure/src/render/camera.ts +416 -0
- package/templates/adventure/src/render/creatures.ts +405 -0
- package/templates/adventure/src/render/effects.ts +333 -0
- package/templates/adventure/src/render/foliage.ts +1072 -0
- package/templates/adventure/src/render/hero.ts +1447 -0
- package/templates/adventure/src/render/kitExposure.ts +20 -0
- package/templates/adventure/src/render/lighting.ts +74 -0
- package/templates/adventure/src/render/loading.ts +332 -0
- package/templates/adventure/src/render/materials.ts +179 -0
- package/templates/adventure/src/render/palette.ts +137 -0
- package/templates/adventure/src/render/postprocessing.ts +70 -0
- package/templates/adventure/src/render/props.ts +383 -0
- package/templates/adventure/src/render/quality.ts +46 -0
- package/templates/adventure/src/render/sky.ts +271 -0
- package/templates/adventure/src/render/surface.ts +259 -0
- package/templates/adventure/src/render/touch-controls.ts +137 -0
- package/templates/adventure/src/scenes/Play.ts +959 -0
- package/templates/adventure/src/state.ts +113 -0
- package/templates/adventure/src/style.css +98 -0
- package/templates/adventure/src/ui/App.tsx +22 -0
- package/templates/adventure/src/ui/GameUi.tsx +20 -0
- package/templates/adventure/src/ui/Hud.tsx +70 -0
- package/templates/adventure/src/ui/Menu.tsx +15 -0
- package/templates/adventure/src/ui/main.tsx +14 -0
- package/templates/adventure/tailwind.config.ts +2 -0
- package/templates/adventure/threenative.config.ts +62 -0
- package/templates/adventure/tsconfig.json +17 -0
- package/templates/adventure/vite.config.ts +49 -0
- package/templates/collectathon/.codex/config.toml +23 -0
- package/templates/collectathon/.cursor/mcp.json +38 -0
- package/templates/collectathon/.gemini/settings.json +38 -0
- package/templates/collectathon/.mcp.json +38 -0
- package/templates/collectathon/.vscode/mcp.json +43 -0
- package/templates/collectathon/.zed/settings.json +43 -0
- package/templates/collectathon/AGENTS.md +58 -0
- package/templates/collectathon/CLAUDE.md +60 -0
- package/templates/collectathon/index.html +14 -0
- package/templates/collectathon/kit.json +8 -0
- package/templates/collectathon/native-playtests/survives.playtest.json +52 -0
- package/templates/collectathon/opencode.json +49 -0
- package/templates/collectathon/package.json +65 -0
- package/templates/collectathon/playtests/acrobatics.playtest.json +238 -0
- package/templates/collectathon/playtests/camera.playtest.json +80 -0
- package/templates/collectathon/playtests/clipped-probe.playtest.json +101 -0
- package/templates/collectathon/playtests/collect.playtest.json +196 -0
- package/templates/collectathon/playtests/combat.playtest.json +246 -0
- package/templates/collectathon/playtests/double-tap-air.playtest.json +198 -0
- package/templates/collectathon/playtests/double-tap.playtest.json +136 -0
- package/templates/collectathon/playtests/effects.playtest.json +124 -0
- package/templates/collectathon/playtests/enemies.playtest.json +295 -0
- package/templates/collectathon/playtests/explore.playtest.json +45 -0
- package/templates/collectathon/playtests/hop-reach.playtest.json +117 -0
- package/templates/collectathon/playtests/jump-chain.playtest.json +274 -0
- package/templates/collectathon/playtests/ledge-angle.playtest.json +107 -0
- package/templates/collectathon/playtests/ledge-too-high.playtest.json +115 -0
- package/templates/collectathon/playtests/ledge.playtest.json +100 -0
- package/templates/collectathon/playtests/look.playtest.json +64 -0
- package/templates/collectathon/playtests/performance.playtest.json +55 -0
- package/templates/collectathon/playtests/stride.playtest.json +111 -0
- package/templates/collectathon/playtests/survives.playtest.json +123 -0
- package/templates/collectathon/playtests/telegraphs.playtest.json +132 -0
- package/templates/collectathon/playtests/thornback.playtest.json +157 -0
- package/templates/collectathon/playtests/wall-kick.playtest.json +206 -0
- package/templates/collectathon/playtests/win.playtest.json +166 -0
- package/templates/collectathon/public/favicon.svg +4 -0
- package/templates/collectathon/src/entities/Hero.ts +915 -0
- package/templates/collectathon/src/entities/Pickup.ts +63 -0
- package/templates/collectathon/src/entities/Walker.ts +248 -0
- package/templates/collectathon/src/game.ts +51 -0
- package/templates/collectathon/src/level/Course.ts +590 -0
- package/templates/collectathon/src/level/terrain.ts +144 -0
- package/templates/collectathon/src/main.ts +14 -0
- package/templates/collectathon/src/playtest-events.ts +15 -0
- package/templates/collectathon/src/render/camera.ts +163 -0
- package/templates/collectathon/src/render/castle.ts +408 -0
- package/templates/collectathon/src/render/effects.ts +284 -0
- package/templates/collectathon/src/render/foliage.ts +744 -0
- package/templates/collectathon/src/render/ground.ts +139 -0
- package/templates/collectathon/src/render/hero.ts +452 -0
- package/templates/collectathon/src/render/kitExposure.ts +20 -0
- package/templates/collectathon/src/render/lighting.ts +65 -0
- package/templates/collectathon/src/render/loading.ts +332 -0
- package/templates/collectathon/src/render/materials.ts +196 -0
- package/templates/collectathon/src/render/palette.ts +82 -0
- package/templates/collectathon/src/render/postprocessing.ts +79 -0
- package/templates/collectathon/src/render/props.ts +218 -0
- package/templates/collectathon/src/render/quality.ts +54 -0
- package/templates/collectathon/src/render/sky.ts +262 -0
- package/templates/collectathon/src/render/surface.ts +269 -0
- package/templates/collectathon/src/render/touch-controls.ts +179 -0
- package/templates/collectathon/src/render/touch-layout.ts +48 -0
- package/templates/collectathon/src/render/water.ts +191 -0
- package/templates/collectathon/src/scenes/Play.ts +481 -0
- package/templates/collectathon/src/state.ts +38 -0
- package/templates/collectathon/src/style.css +106 -0
- package/templates/collectathon/src/ui/App.tsx +22 -0
- package/templates/collectathon/src/ui/GameUi.tsx +20 -0
- package/templates/collectathon/src/ui/Hud.tsx +77 -0
- package/templates/collectathon/src/ui/Menu.tsx +13 -0
- package/templates/collectathon/src/ui/main.tsx +14 -0
- package/templates/collectathon/tailwind.config.ts +2 -0
- package/templates/collectathon/threenative.config.ts +62 -0
- package/templates/collectathon/tsconfig.json +17 -0
- package/templates/collectathon/vite.config.ts +49 -0
- package/templates/kart/.codex/config.toml +23 -0
- package/templates/kart/.cursor/mcp.json +38 -0
- package/templates/kart/.gemini/settings.json +38 -0
- package/templates/kart/.mcp.json +38 -0
- package/templates/kart/.vscode/mcp.json +43 -0
- package/templates/kart/.zed/settings.json +43 -0
- package/templates/kart/AGENTS.md +58 -0
- package/templates/kart/CLAUDE.md +60 -0
- package/templates/kart/index.html +14 -0
- package/templates/kart/kit.json +8 -0
- package/templates/kart/native-playtests/survives.playtest.json +65 -0
- package/templates/kart/opencode.json +49 -0
- package/templates/kart/package.json +64 -0
- package/templates/kart/playtests/drift.playtest.json +226 -0
- package/templates/kart/playtests/explore.playtest.json +45 -0
- package/templates/kart/playtests/hit-stays-above-road.playtest.json +92 -0
- package/templates/kart/playtests/item-key.playtest.json +108 -0
- package/templates/kart/playtests/items.playtest.json +143 -0
- package/templates/kart/playtests/lap-times.playtest.json +138 -0
- package/templates/kart/playtests/laps.playtest.json +149 -0
- package/templates/kart/playtests/performance.playtest.json +57 -0
- package/templates/kart/playtests/race.playtest.json +294 -0
- package/templates/kart/playtests/restart.playtest.json +87 -0
- package/templates/kart/playtests/rocket-start.playtest.json +56 -0
- package/templates/kart/playtests/smooth-drive.playtest.json +101 -0
- package/templates/kart/playtests/surfaces.playtest.json +113 -0
- package/templates/kart/playtests/survives.playtest.json +116 -0
- package/templates/kart/playtests/wall.playtest.json +118 -0
- package/templates/kart/public/favicon.svg +4 -0
- package/templates/kart/src/entities/Driver.ts +123 -0
- package/templates/kart/src/entities/Items.ts +194 -0
- package/templates/kart/src/entities/Kart.ts +517 -0
- package/templates/kart/src/game.ts +45 -0
- package/templates/kart/src/main.ts +14 -0
- package/templates/kart/src/playtest-events.ts +15 -0
- package/templates/kart/src/render/camera.ts +83 -0
- package/templates/kart/src/render/course.ts +579 -0
- package/templates/kart/src/render/effects.ts +266 -0
- package/templates/kart/src/render/items.ts +163 -0
- package/templates/kart/src/render/kart.ts +256 -0
- package/templates/kart/src/render/kitExposure.ts +20 -0
- package/templates/kart/src/render/lighting.ts +58 -0
- package/templates/kart/src/render/loading.ts +332 -0
- package/templates/kart/src/render/materials.ts +119 -0
- package/templates/kart/src/render/palette.ts +74 -0
- package/templates/kart/src/render/postprocessing.ts +79 -0
- package/templates/kart/src/render/quality.ts +54 -0
- package/templates/kart/src/render/skids.ts +86 -0
- package/templates/kart/src/render/sky.ts +105 -0
- package/templates/kart/src/render/touch-controls.ts +168 -0
- package/templates/kart/src/render/touch-layout.ts +48 -0
- package/templates/kart/src/scenes/Race.ts +850 -0
- package/templates/kart/src/state.ts +53 -0
- package/templates/kart/src/style.css +106 -0
- package/templates/kart/src/track/Course.ts +276 -0
- package/templates/kart/src/track/Race.ts +133 -0
- package/templates/kart/src/ui/App.tsx +21 -0
- package/templates/kart/src/ui/GameUi.tsx +20 -0
- package/templates/kart/src/ui/Hud.tsx +172 -0
- package/templates/kart/src/ui/Menu.tsx +13 -0
- package/templates/kart/src/ui/main.tsx +14 -0
- package/templates/kart/tailwind.config.ts +2 -0
- package/templates/kart/threenative.config.ts +62 -0
- package/templates/kart/tsconfig.json +17 -0
- package/templates/kart/vite.config.ts +49 -0
- package/templates/minimal/.codex/config.toml +6 -2
- package/templates/minimal/.cursor/mcp.json +8 -2
- package/templates/minimal/.gemini/settings.json +8 -2
- package/templates/minimal/.mcp.json +8 -2
- package/templates/minimal/.vscode/mcp.json +9 -2
- package/templates/minimal/.zed/settings.json +9 -2
- package/templates/minimal/AGENTS.md +11 -13
- package/templates/minimal/CLAUDE.md +11 -13
- package/templates/minimal/opencode.json +10 -2
- package/templates/minimal/package.json +16 -10
- package/templates/minimal/playtests/camera-wall.playtest.json +36 -0
- package/templates/minimal/playtests/jump.playtest.json +45 -0
- package/templates/minimal/playtests/play.playtest.json +1 -1
- package/templates/minimal/src/game.ts +2 -0
- package/templates/minimal/src/render/atmosphere.ts +444 -0
- package/templates/minimal/src/render/backlightMaterial.ts +49 -18
- package/templates/minimal/src/render/camera.ts +35 -4
- package/templates/minimal/src/render/clouds.ts +605 -0
- package/templates/minimal/src/render/exposure.ts +7 -111
- package/templates/minimal/src/render/gpuSky.ts +752 -0
- package/templates/minimal/src/render/lighting.ts +26 -4
- package/templates/minimal/src/render/materialLighting.ts +2 -10
- package/templates/minimal/src/render/postprocessing.ts +4 -4
- package/templates/minimal/src/render/quality.ts +10 -116
- package/templates/minimal/src/render/sky.ts +73 -1
- package/templates/minimal/src/scenes/Play.ts +18 -7
- package/templates/platformer/.codex/config.toml +6 -2
- package/templates/platformer/.cursor/mcp.json +8 -2
- package/templates/platformer/.gemini/settings.json +8 -2
- package/templates/platformer/.mcp.json +8 -2
- package/templates/platformer/.vscode/mcp.json +9 -2
- package/templates/platformer/.zed/settings.json +9 -2
- package/templates/platformer/AGENTS.md +13 -9
- package/templates/platformer/CLAUDE.md +13 -9
- package/templates/platformer/opencode.json +10 -2
- package/templates/platformer/package.json +17 -11
- package/templates/platformer/playtests/dash-jump.playtest.json +34 -0
- package/templates/platformer/playtests/finish.playtest.json +58 -0
- package/templates/platformer/playtests/idle.playtest.json +44 -0
- package/templates/platformer/playtests/performance.playtest.json +1 -1
- package/templates/platformer/src/entities/Fox.ts +19 -6
- package/templates/platformer/src/game.ts +1 -0
- package/templates/platformer/src/level/Stage.ts +4 -1
- package/templates/platformer/src/render/backlightMaterial.ts +49 -18
- package/templates/platformer/src/render/camera.ts +30 -1
- package/templates/platformer/src/render/exposure.ts +6 -111
- package/templates/platformer/src/render/fox.ts +5 -2
- package/templates/platformer/src/render/kitExposure.ts +20 -0
- package/templates/platformer/src/render/materialLighting.ts +2 -11
- package/templates/platformer/src/render/postprocessing.ts +4 -4
- package/templates/platformer/src/render/props.ts +1 -2
- package/templates/platformer/src/render/quality.ts +10 -118
- package/templates/platformer/src/scenes/Play.ts +31 -15
- package/templates/platformer/src/ui/Menu.tsx +1 -1
- package/templates/puzzle/.codex/config.toml +6 -2
- package/templates/puzzle/.cursor/mcp.json +8 -2
- package/templates/puzzle/.gemini/settings.json +8 -2
- package/templates/puzzle/.mcp.json +8 -2
- package/templates/puzzle/.vscode/mcp.json +9 -2
- package/templates/puzzle/.zed/settings.json +9 -2
- package/templates/puzzle/AGENTS.md +14 -17
- package/templates/puzzle/CLAUDE.md +14 -17
- package/templates/puzzle/opencode.json +10 -2
- package/templates/puzzle/package.json +17 -11
- package/templates/puzzle/playtests/performance.playtest.json +1 -1
- package/templates/puzzle/playtests/replay-keeps-progress.playtest.json +78 -0
- package/templates/puzzle/src/render/backlightMaterial.ts +49 -18
- package/templates/puzzle/src/render/exposure.ts +11 -109
- package/templates/puzzle/src/render/lighting.ts +3 -3
- package/templates/puzzle/src/render/materialLighting.ts +2 -11
- package/templates/puzzle/src/render/palette.ts +1 -1
- package/templates/puzzle/src/render/postprocessing.ts +4 -4
- package/templates/puzzle/src/render/quality.ts +44 -153
- package/templates/puzzle/src/render/vault.ts +18 -6
- package/templates/puzzle/src/scenes/Play.ts +6 -1
- package/templates/puzzle/src/ui/Hud.tsx +8 -43
- package/templates/racing/.codex/config.toml +6 -2
- package/templates/racing/.cursor/mcp.json +8 -2
- package/templates/racing/.gemini/settings.json +8 -2
- package/templates/racing/.mcp.json +8 -2
- package/templates/racing/.vscode/mcp.json +9 -2
- package/templates/racing/.zed/settings.json +9 -2
- package/templates/racing/AGENTS.md +10 -12
- package/templates/racing/CLAUDE.md +10 -12
- package/templates/racing/opencode.json +10 -2
- package/templates/racing/package.json +17 -11
- package/templates/racing/playtests/brake.playtest.json +54 -0
- package/templates/racing/playtests/outcome.playtest.json +19 -0
- package/templates/racing/playtests/performance.playtest.json +1 -1
- package/templates/racing/playtests/stopped-car-is-not-rescued.playtest.json +59 -0
- package/templates/racing/src/entities/RacingCar.ts +12 -3
- package/templates/racing/src/entities/Rival.ts +11 -2
- package/templates/racing/src/render/atmosphere.ts +444 -0
- package/templates/racing/src/render/backlightMaterial.ts +49 -18
- package/templates/racing/src/render/clouds.ts +605 -0
- package/templates/racing/src/render/exposure.ts +6 -111
- package/templates/racing/src/render/gpuSky.ts +752 -0
- package/templates/racing/src/render/kitExposure.ts +20 -0
- package/templates/racing/src/render/lighting.ts +26 -4
- package/templates/racing/src/render/materialLighting.ts +2 -11
- package/templates/racing/src/render/materials.ts +2 -1
- package/templates/racing/src/render/postprocessing.ts +4 -4
- package/templates/racing/src/render/quality.ts +27 -115
- package/templates/racing/src/render/sky.ts +76 -5
- package/templates/racing/src/scenes/Race.ts +53 -42
- package/templates/racing/src/track/TrackSector.ts +5 -2
- package/templates/racing/src/ui/Hud.tsx +12 -7
- package/templates/rain/.codex/config.toml +6 -2
- package/templates/rain/.cursor/mcp.json +8 -2
- package/templates/rain/.gemini/settings.json +8 -2
- package/templates/rain/.mcp.json +8 -2
- package/templates/rain/.vscode/mcp.json +9 -2
- package/templates/rain/.zed/settings.json +9 -2
- package/templates/rain/AGENTS.md +12 -12
- package/templates/rain/CLAUDE.md +12 -12
- package/templates/rain/opencode.json +10 -2
- package/templates/rain/package.json +16 -10
- package/templates/rain/playtests/performance.playtest.json +1 -1
- package/templates/rain/src/game.ts +1 -1
- package/templates/rain/src/render/bloom-shader.ts +1 -1
- package/templates/rain/src/render/clouds-shader.ts +2 -2
- package/templates/rain/src/render/clouds.ts +2 -1
- package/templates/rain/src/render/exposure.ts +11 -109
- package/templates/rain/src/render/post-shader.ts +7 -11
- package/templates/rain/src/render/postprocessing.ts +8 -24
- package/templates/rain/src/render/quality.ts +44 -98
- package/templates/rain/src/render/world-shader.ts +281 -97
- package/templates/rain/src/render/world.ts +82 -2
- package/templates/rain/src/style.css +1 -1
- package/templates/rain/src/ui/GameUi.tsx +6 -2
- package/templates/rain/src/ui/Hud.tsx +1 -1
- package/templates/rain/tools/generate-shaders.mjs +2 -2
- package/templates/rain/tools/tempest-post.frag +4 -6
- package/templates/rain/tools/tempest-world.frag +80 -12
- package/templates/rts/.codex/config.toml +6 -2
- package/templates/rts/.cursor/mcp.json +8 -2
- package/templates/rts/.gemini/settings.json +8 -2
- package/templates/rts/.mcp.json +8 -2
- package/templates/rts/.vscode/mcp.json +9 -2
- package/templates/rts/.zed/settings.json +9 -2
- package/templates/rts/AGENTS.md +15 -16
- package/templates/rts/CLAUDE.md +15 -16
- package/templates/rts/opencode.json +10 -2
- package/templates/rts/package.json +16 -10
- package/templates/rts/playtests/performance.playtest.json +1 -1
- package/templates/rts/playtests/rts-attack.playtest.json +5 -0
- package/templates/rts/playtests/rts-build.playtest.json +20 -1
- package/templates/rts/playtests/rts-orders.playtest.json +1 -1
- package/templates/rts/playtests/rts-pause.playtest.json +112 -0
- package/templates/rts/playtests/rts-train.playtest.json +1 -1
- package/templates/rts/playtests/rts-zoom.playtest.json +81 -0
- package/templates/rts/src/game.ts +29 -7
- package/templates/rts/src/render/army.ts +181 -49
- package/templates/rts/src/render/backlightMaterial.ts +49 -18
- package/templates/rts/src/render/environment.ts +276 -0
- package/templates/rts/src/render/exposure.ts +3 -65
- package/templates/rts/src/render/ground.ts +478 -0
- package/templates/rts/src/render/lighting.ts +62 -11
- package/templates/rts/src/render/materialLighting.ts +2 -11
- package/templates/rts/src/render/materials.ts +47 -118
- package/templates/rts/src/render/palette.ts +30 -13
- package/templates/rts/src/render/picking.ts +18 -0
- package/templates/rts/src/render/postprocessing.ts +4 -4
- package/templates/rts/src/render/quality.ts +64 -85
- package/templates/rts/src/render/resources.ts +21 -22
- package/templates/rts/src/render/sky.ts +9 -12
- package/templates/rts/src/render/terrain.ts +36 -11
- package/templates/rts/src/scenes/Play.ts +373 -38
- package/templates/rts/src/sim/ai.ts +0 -11
- package/templates/rts/src/state.ts +46 -0
- package/templates/rts/src/style.css +1543 -0
- package/templates/rts/src/ui/Commands.tsx +204 -107
- package/templates/rts/src/ui/GameUi.tsx +12 -5
- package/templates/rts/src/ui/Hud.tsx +611 -116
- package/templates/rts/src/ui/Minimap.tsx +103 -37
- package/templates/rts/src/ui/icons.tsx +116 -0
- package/templates/rts/src/ui/labels.ts +73 -0
- package/templates/rts/src/ui/minimapPoint.ts +30 -0
- package/templates/rts/threenative.config.ts +1 -1
- package/templates/runner/.codex/config.toml +6 -2
- package/templates/runner/.cursor/mcp.json +8 -2
- package/templates/runner/.gemini/settings.json +8 -2
- package/templates/runner/.mcp.json +8 -2
- package/templates/runner/.vscode/mcp.json +9 -2
- package/templates/runner/.zed/settings.json +9 -2
- package/templates/runner/AGENTS.md +12 -12
- package/templates/runner/CLAUDE.md +12 -12
- package/templates/runner/opencode.json +10 -2
- package/templates/runner/package.json +17 -11
- package/templates/runner/playtests/near-miss.playtest.json +48 -0
- package/templates/runner/playtests/performance.playtest.json +2 -2
- package/templates/runner/playtests/stride.playtest.json +27 -0
- package/templates/runner/playtests/survives.playtest.json +2 -2
- package/templates/runner/src/conventions.ts +3 -1
- package/templates/runner/src/entities/Runner.ts +11 -5
- package/templates/runner/src/render/atmosphere.ts +444 -0
- package/templates/runner/src/render/backlightMaterial.ts +49 -18
- package/templates/runner/src/render/clouds.ts +605 -0
- package/templates/runner/src/render/exposure.ts +6 -111
- package/templates/runner/src/render/gpuSky.ts +752 -0
- package/templates/runner/src/render/kitExposure.ts +20 -0
- package/templates/runner/src/render/lighting.ts +26 -4
- package/templates/runner/src/render/materialLighting.ts +2 -11
- package/templates/runner/src/render/postprocessing.ts +4 -4
- package/templates/runner/src/render/quality.ts +26 -114
- package/templates/runner/src/render/sky.ts +73 -1
- package/templates/runner/src/scenes/Run.ts +19 -15
- package/templates/runner/src/track.ts +12 -3
- package/templates/sailing/.codex/config.toml +6 -2
- package/templates/sailing/.cursor/mcp.json +8 -2
- package/templates/sailing/.gemini/settings.json +8 -2
- package/templates/sailing/.mcp.json +8 -2
- package/templates/sailing/.vscode/mcp.json +9 -2
- package/templates/sailing/.zed/settings.json +9 -2
- package/templates/sailing/AGENTS.md +10 -11
- package/templates/sailing/CLAUDE.md +10 -11
- package/templates/sailing/opencode.json +10 -2
- package/templates/sailing/package.json +17 -11
- package/templates/sailing/playtests/fail.playtest.json +46 -5
- package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +7 -0
- package/templates/sailing/playtests/performance.playtest.json +1 -1
- package/templates/sailing/src/game.ts +1 -0
- package/templates/sailing/src/render/backlightMaterial.ts +49 -18
- package/templates/sailing/src/render/exposure.ts +6 -111
- package/templates/sailing/src/render/kitExposure.ts +20 -0
- package/templates/sailing/src/render/materialLighting.ts +2 -11
- package/templates/sailing/src/render/ocean.ts +0 -1
- package/templates/sailing/src/render/postprocessing.ts +4 -4
- package/templates/sailing/src/render/quality.ts +31 -138
- package/templates/sailing/src/scenes/Sailing.ts +12 -4
- package/templates/sailing/src/ui/Hud.tsx +6 -2
- package/templates/sailing/src/ui/Menu.tsx +1 -1
- package/templates/shooter/.codex/config.toml +6 -2
- package/templates/shooter/.cursor/mcp.json +8 -2
- package/templates/shooter/.gemini/settings.json +8 -2
- package/templates/shooter/.mcp.json +8 -2
- package/templates/shooter/.vscode/mcp.json +9 -2
- package/templates/shooter/.zed/settings.json +9 -2
- package/templates/shooter/AGENTS.md +13 -12
- package/templates/shooter/CLAUDE.md +13 -12
- package/templates/shooter/index.html +1 -1
- package/templates/shooter/main.html +13 -0
- package/templates/shooter/opencode.json +10 -2
- package/templates/shooter/package.json +17 -11
- package/templates/shooter/playtests/breakable-shatters.playtest.json +6 -0
- package/templates/shooter/playtests/enemy-body-is-a-body.playtest.json +6 -0
- package/templates/shooter/playtests/hands-authored-rate.playtest.json +54 -0
- package/templates/shooter/playtests/movement-eases.playtest.json +53 -0
- package/templates/shooter/playtests/performance.playtest.json +3 -3
- package/templates/shooter/playtests/stairs-smooth-the-eye.playtest.json +56 -0
- package/templates/shooter/playtests/weapon-sharp-while-turning.playtest.json +206 -0
- package/templates/shooter/src/entities/Breakables.ts +34 -10
- package/templates/shooter/src/entities/Enemy.ts +176 -54
- package/templates/shooter/src/entities/FpsPlayer.ts +55 -16
- package/templates/shooter/src/entities/Rifle.ts +83 -9
- package/templates/shooter/src/entities/movement.ts +96 -0
- package/templates/shooter/src/render/atmosphere.ts +444 -0
- package/templates/shooter/src/render/backlightMaterial.ts +49 -18
- package/templates/shooter/src/render/camera.ts +3 -1
- package/templates/shooter/src/render/clouds.ts +605 -0
- package/templates/shooter/src/render/exposure.ts +10 -109
- package/templates/shooter/src/render/facade.ts +26 -68
- package/templates/shooter/src/render/gpuSky.ts +752 -0
- package/templates/shooter/src/render/lighting.ts +27 -4
- package/templates/shooter/src/render/materialAssignments.ts +9 -1
- package/templates/shooter/src/render/materialLighting.ts +2 -11
- package/templates/shooter/src/render/occlusion.ts +13 -4
- package/templates/shooter/src/render/palette.ts +1 -0
- package/templates/shooter/src/render/postprocessing.ts +4 -4
- package/templates/shooter/src/render/quality.ts +50 -108
- package/templates/shooter/src/render/scale.ts +0 -11
- package/templates/shooter/src/render/sky.ts +103 -2
- package/templates/shooter/src/render/surface.ts +140 -0
- package/templates/shooter/src/render/town.ts +3 -6
- package/templates/shooter/src/render/townMaterials.ts +95 -42
- package/templates/shooter/src/render/vehicles.ts +2 -0
- package/templates/shooter/src/scenes/Play.ts +83 -23
- package/templates/shooter/src/ui/Hud.tsx +268 -193
- package/templates/shooter/src/worker-page.ts +29 -0
- package/templates/shooter/src/worker.ts +5 -0
- package/templates/shooter/threenative.config.ts +3 -0
- package/templates/shooter/vite.config.ts +2 -0
- package/templates/snow/.codex/config.toml +6 -2
- package/templates/snow/.cursor/mcp.json +8 -2
- package/templates/snow/.gemini/settings.json +8 -2
- package/templates/snow/.mcp.json +8 -2
- package/templates/snow/.vscode/mcp.json +9 -2
- package/templates/snow/.zed/settings.json +9 -2
- package/templates/snow/AGENTS.md +12 -10
- package/templates/snow/CLAUDE.md +12 -10
- package/templates/snow/opencode.json +10 -2
- package/templates/snow/package.json +17 -11
- package/templates/snow/playtests/performance.playtest.json +1 -1
- package/templates/snow/src/render/backlightMaterial.ts +49 -18
- package/templates/snow/src/render/exposure.ts +17 -106
- package/templates/snow/src/render/materialLighting.ts +2 -11
- package/templates/snow/src/render/postprocessing.ts +11 -5
- package/templates/snow/src/render/quality.ts +46 -126
- package/templates/snow/src/render/snowSurface.ts +32 -15
- package/templates/snow/src/scenes/Snow.ts +2 -1
- package/templates/starter/.codex/config.toml +6 -2
- package/templates/starter/.cursor/mcp.json +8 -2
- package/templates/starter/.gemini/settings.json +8 -2
- package/templates/starter/.mcp.json +8 -2
- package/templates/starter/.vscode/mcp.json +9 -2
- package/templates/starter/.zed/settings.json +9 -2
- package/templates/starter/AGENTS.md +18 -14
- package/templates/starter/CLAUDE.md +18 -14
- package/templates/starter/index.html +1 -1
- package/templates/starter/main.html +12 -0
- package/templates/starter/native-playtests/react-hud.playtest.json +1 -0
- package/templates/starter/native-playtests/render-chain.playtest.json +34 -21
- package/templates/starter/opencode.json +10 -2
- package/templates/starter/package.json +17 -11
- package/templates/starter/playtests/play.playtest.json +22 -2
- package/templates/starter/playtests/production-readiness.playtest.json +56 -0
- package/templates/starter/src/entities/Crate.ts +19 -1
- package/templates/starter/src/render/arena.ts +2 -2
- package/templates/starter/src/render/atmosphere.ts +444 -0
- package/templates/starter/src/render/backlightMaterial.ts +49 -18
- package/templates/starter/src/render/camera.ts +28 -0
- package/templates/starter/src/render/clouds.ts +605 -0
- package/templates/starter/src/render/contactShadow.ts +50 -0
- package/templates/starter/src/render/exposure.ts +9 -111
- package/templates/starter/src/render/gpuSky.ts +752 -0
- package/templates/starter/src/render/grade.ts +1 -1
- package/templates/starter/src/render/lighting.ts +34 -6
- package/templates/starter/src/render/materialLighting.ts +2 -11
- package/templates/starter/src/render/postprocessing.ts +53 -34
- package/templates/starter/src/render/quality.ts +18 -147
- package/templates/starter/src/render/sky.ts +90 -40
- package/templates/starter/src/render/temporalAA.ts +1 -1
- package/templates/starter/src/render/temporalAAStage.ts +1 -1
- package/templates/starter/src/render/temporalCurrentFootprint.ts +0 -1
- package/templates/starter/src/render/temporalDetailStage.ts +106 -0
- package/templates/starter/src/render/temporalRejectionCounter.ts +2 -2
- package/templates/starter/src/render/volumetricFogCamera.ts +32 -0
- package/templates/starter/src/render/volumetricFogOptions.ts +7 -0
- package/templates/starter/src/render/volumetricFogTransport.ts +27 -19
- package/templates/starter/src/render/volumetricFogVolume.ts +31 -7
- package/templates/starter/src/scenes/Play.ts +11 -8
- package/templates/starter/src/ui/Hud.tsx +1 -1
- package/templates/starter/src/worker-page.ts +29 -0
- package/templates/starter/src/worker.ts +5 -0
- package/templates/starter/vite.config.ts +2 -0
- package/templates/tower-defense/.codex/config.toml +6 -2
- package/templates/tower-defense/.cursor/mcp.json +8 -2
- package/templates/tower-defense/.gemini/settings.json +8 -2
- package/templates/tower-defense/.mcp.json +8 -2
- package/templates/tower-defense/.vscode/mcp.json +9 -2
- package/templates/tower-defense/.zed/settings.json +9 -2
- package/templates/tower-defense/AGENTS.md +10 -12
- package/templates/tower-defense/CLAUDE.md +10 -12
- package/templates/tower-defense/opencode.json +10 -2
- package/templates/tower-defense/package.json +17 -11
- package/templates/tower-defense/playtests/chill-tint.playtest.json +387 -0
- package/templates/tower-defense/playtests/performance.playtest.json +1 -1
- package/templates/tower-defense/src/enemies/Enemy.ts +9 -0
- package/templates/tower-defense/src/render/backlightMaterial.ts +49 -18
- package/templates/tower-defense/src/render/exposure.ts +11 -109
- package/templates/tower-defense/src/render/lighting.ts +4 -2
- package/templates/tower-defense/src/render/materialLighting.ts +2 -11
- package/templates/tower-defense/src/render/postprocessing.ts +4 -4
- package/templates/tower-defense/src/render/quality.ts +10 -116
- package/templates/tower-defense/src/render/sky.ts +2 -2
- package/templates/tower-defense/src/scenes/Battle.ts +4 -0
- package/template-assets/autoExposure.ts +0 -225
- package/template-assets/exposureGraph.ts +0 -178
- package/template-assets/exposureReadback.ts +0 -79
- package/template-assets/worldEnvironment.ts +0 -1212
- package/templates/action-rpg/src/render/autoExposure.ts +0 -225
- package/templates/action-rpg/src/render/exposureGraph.ts +0 -178
- package/templates/action-rpg/src/render/exposureReadback.ts +0 -79
- package/templates/action-rpg/src/render/worldEnvironment.ts +0 -1212
- package/templates/minimal/src/render/autoExposure.ts +0 -225
- package/templates/minimal/src/render/exposureGraph.ts +0 -178
- package/templates/minimal/src/render/exposureReadback.ts +0 -79
- package/templates/minimal/src/render/worldEnvironment.ts +0 -1212
- package/templates/platformer/src/render/autoExposure.ts +0 -225
- package/templates/platformer/src/render/exposureGraph.ts +0 -178
- package/templates/platformer/src/render/exposureReadback.ts +0 -79
- package/templates/platformer/src/render/worldEnvironment.ts +0 -1212
- package/templates/puzzle/src/render/autoExposure.ts +0 -225
- package/templates/puzzle/src/render/exposureGraph.ts +0 -178
- package/templates/puzzle/src/render/exposureReadback.ts +0 -79
- package/templates/puzzle/src/render/worldEnvironment.ts +0 -1212
- package/templates/racing/src/render/autoExposure.ts +0 -225
- package/templates/racing/src/render/exposureGraph.ts +0 -178
- package/templates/racing/src/render/exposureReadback.ts +0 -79
- package/templates/racing/src/render/worldEnvironment.ts +0 -1212
- package/templates/rain/src/render/autoExposure.ts +0 -225
- package/templates/rain/src/render/exposureGraph.ts +0 -178
- package/templates/rain/src/render/exposureReadback.ts +0 -79
- package/templates/rain/src/render/worldEnvironment.ts +0 -1212
- package/templates/rts/src/render/autoExposure.ts +0 -225
- package/templates/rts/src/render/exposureGraph.ts +0 -178
- package/templates/rts/src/render/exposureReadback.ts +0 -79
- package/templates/rts/src/render/worldEnvironment.ts +0 -1212
- package/templates/runner/src/render/autoExposure.ts +0 -225
- package/templates/runner/src/render/exposureGraph.ts +0 -178
- package/templates/runner/src/render/exposureReadback.ts +0 -79
- package/templates/runner/src/render/worldEnvironment.ts +0 -1212
- package/templates/sailing/src/render/autoExposure.ts +0 -225
- package/templates/sailing/src/render/exposureGraph.ts +0 -178
- package/templates/sailing/src/render/exposureReadback.ts +0 -79
- package/templates/sailing/src/render/worldEnvironment.ts +0 -1212
- package/templates/shooter/src/render/autoExposure.ts +0 -225
- package/templates/shooter/src/render/exposureGraph.ts +0 -178
- package/templates/shooter/src/render/exposureReadback.ts +0 -79
- package/templates/shooter/src/render/worldEnvironment.ts +0 -1212
- package/templates/snow/src/render/autoExposure.ts +0 -225
- package/templates/snow/src/render/exposureGraph.ts +0 -178
- package/templates/snow/src/render/exposureReadback.ts +0 -79
- package/templates/snow/src/render/worldEnvironment.ts +0 -1212
- package/templates/starter/src/render/autoExposure.ts +0 -225
- package/templates/starter/src/render/exposureGraph.ts +0 -178
- package/templates/starter/src/render/exposureReadback.ts +0 -79
- package/templates/starter/src/render/worldEnvironment.ts +0 -1212
- package/templates/tower-defense/src/render/autoExposure.ts +0 -225
- package/templates/tower-defense/src/render/exposureGraph.ts +0 -178
- package/templates/tower-defense/src/render/exposureReadback.ts +0 -79
- package/templates/tower-defense/src/render/worldEnvironment.ts +0 -1212
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Generated for you. This is ordinary Three.js — edit or delete it freely.
|
|
2
|
+
//
|
|
3
|
+
// The island's ground: one terrain mesh whose vertex attributes say where grass, worn grass, the
|
|
4
|
+
// sandy dirt path, beach sand and rock lie, by height, slope and distance to the path. The textures
|
|
5
|
+
// and the blend are `groundMaterial` in surface.ts.
|
|
6
|
+
import { BufferAttribute, BufferGeometry, Color, Mesh } from "three";
|
|
7
|
+
import { lit, seeded } from "./materials.js";
|
|
8
|
+
import { C } from "./palette.js";
|
|
9
|
+
|
|
10
|
+
/** What the ground's paint reads from the level, in metres. */
|
|
11
|
+
export interface IGroundSite {
|
|
12
|
+
/** The up component of the ground's normal: 1 flat, under 0.7 steeper than the hero can climb. */
|
|
13
|
+
flatness(x: number, z: number): number;
|
|
14
|
+
pathDistance(x: number, z: number): number;
|
|
15
|
+
readonly seaLevel: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Metres one tile of the ground's normal map covers. */
|
|
19
|
+
const TILE = 2;
|
|
20
|
+
|
|
21
|
+
/** Tileable value noise: `cells` lattice cells per tile, from a fixed seed. */
|
|
22
|
+
export function valueNoise(cells: number, seed: number): (u: number, v: number) => number {
|
|
23
|
+
const rng = seeded(seed);
|
|
24
|
+
const lattice = Float32Array.from({ length: cells * cells }, rng);
|
|
25
|
+
const at = (i: number, j: number): number =>
|
|
26
|
+
lattice[(((j % cells) + cells) % cells) * cells + (((i % cells) + cells) % cells)] ?? 0;
|
|
27
|
+
return (u, v) => {
|
|
28
|
+
const x = u * cells;
|
|
29
|
+
const y = v * cells;
|
|
30
|
+
const i = Math.floor(x);
|
|
31
|
+
const j = Math.floor(y);
|
|
32
|
+
const fx = (x - i) * (x - i) * (3 - 2 * (x - i));
|
|
33
|
+
const fy = (y - j) * (y - j) * (3 - 2 * (y - j));
|
|
34
|
+
const top = at(i, j) + (at(i + 1, j) - at(i, j)) * fx;
|
|
35
|
+
const bottom = at(i, j + 1) + (at(i + 1, j + 1) - at(i, j + 1)) * fx;
|
|
36
|
+
return top + (bottom - top) * fy;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const smooth = (from: number, to: number, value: number): number => {
|
|
41
|
+
const t = Math.min(1, Math.max(0, (value - from) / (to - from)));
|
|
42
|
+
return t * t * (3 - 2 * t);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Writes what `groundMaterial` in surface.ts blends, per vertex of a terrain geometry in world
|
|
47
|
+
* space (positions already translated to the world): `layer` is (sand, rock, worn grass) — the
|
|
48
|
+
* path's sandy dirt and the beach, rock where the slope passes about 50° (a grassy hill keeps its turf), and trodden grass beside the
|
|
49
|
+
* path — and `tint` the lawn's broad yellow-to-blue-green patches. `uv` tiles every 2 m for the
|
|
50
|
+
* normal map. (`tint`, not `color`: a node reading an attribute named `color` fails to compile on
|
|
51
|
+
* the Wasm engine.)
|
|
52
|
+
*/
|
|
53
|
+
export function paintGround(geometry: BufferGeometry, site: IGroundSite): BufferGeometry {
|
|
54
|
+
const position = geometry.attributes.position;
|
|
55
|
+
const count = position?.count ?? 0;
|
|
56
|
+
const colors = new Float32Array(count * 3);
|
|
57
|
+
const layers = new Float32Array(count * 3);
|
|
58
|
+
const uvs = new Float32Array(count * 2);
|
|
59
|
+
for (let i = 0; i < count; i += 1) {
|
|
60
|
+
const x = position?.getX(i) ?? 0;
|
|
61
|
+
const y = position?.getY(i) ?? 0;
|
|
62
|
+
const z = position?.getZ(i) ?? 0;
|
|
63
|
+
uvs[i * 2] = x / TILE;
|
|
64
|
+
uvs[i * 2 + 1] = z / TILE;
|
|
65
|
+
// Grass patches, as `patches()` in materials.ts paints the drum lawns.
|
|
66
|
+
const value =
|
|
67
|
+
1 + 0.14 * Math.sin(x * 0.31 + Math.sin(z * 0.23) * 2) * Math.cos(z * 0.27 - x * 0.09);
|
|
68
|
+
const hue = 0.5 + 0.5 * Math.sin(x * 0.13 - z * 0.17 + 1.3);
|
|
69
|
+
colors.set([value * (1.1 - 0.25 * hue), value, value * (0.8 + 0.4 * hue)], i * 3);
|
|
70
|
+
const path = site.pathDistance(x, z);
|
|
71
|
+
const sand = Math.max(
|
|
72
|
+
1 - smooth(0.8, 1.6, path),
|
|
73
|
+
1 - smooth(site.seaLevel + 0.6, site.seaLevel + 1.4, y),
|
|
74
|
+
);
|
|
75
|
+
layers.set(
|
|
76
|
+
[sand, 1 - smooth(0.55, 0.7, site.flatness(x, z)), 1 - smooth(1.2, 2.8, path)],
|
|
77
|
+
i * 3,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
geometry.setAttribute("tint", new BufferAttribute(colors, 3));
|
|
81
|
+
geometry.setAttribute("layer", new BufferAttribute(layers, 3));
|
|
82
|
+
geometry.setAttribute("uv", new BufferAttribute(uvs, 2));
|
|
83
|
+
return geometry;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Far hills round the sea, 170 to 330 m out: a low ring of green ridges the haze turns blue, so
|
|
88
|
+
* the horizon has layers instead of one sea line. Scenery only, nothing reaches it.
|
|
89
|
+
*/
|
|
90
|
+
export function farHills(seaLevel: number): Mesh {
|
|
91
|
+
const segments = 240;
|
|
92
|
+
const rings = 12;
|
|
93
|
+
// Two scales of tiling noise round the ring: knolls and gullies on the slopes, so the sun models
|
|
94
|
+
// them, and the colour drifts between meadow and wood instead of one flat green.
|
|
95
|
+
const coarse = valueNoise(24, 41);
|
|
96
|
+
const fine = valueNoise(96, 43);
|
|
97
|
+
const positions: number[] = [];
|
|
98
|
+
const colors: number[] = [];
|
|
99
|
+
const near = new Color(C.canopyDeep);
|
|
100
|
+
const far = new Color(C.grass);
|
|
101
|
+
for (let r = 0; r <= rings; r += 1) {
|
|
102
|
+
const t = r / rings;
|
|
103
|
+
for (let s = 0; s <= segments; s += 1) {
|
|
104
|
+
const a = (s / segments) * Math.PI * 2;
|
|
105
|
+
const ridge = Math.max(
|
|
106
|
+
0,
|
|
107
|
+
Math.sin(a * 3 + 1.1) * 0.6 + Math.sin(a * 7 + 0.4) * 0.3 + Math.sin(a * 13) * 0.15 + 0.35,
|
|
108
|
+
);
|
|
109
|
+
const radius = 170 + t * 160;
|
|
110
|
+
// Rise from the sea to the crest at 70% of the depth, then fall a little behind it.
|
|
111
|
+
const lift = Math.sin(Math.min(1, t / 0.7) * Math.PI * 0.5) * (1 - Math.max(0, t - 0.7));
|
|
112
|
+
const u = s / segments;
|
|
113
|
+
const knoll = coarse(u, t * 0.25) * 0.6 + fine(u, t * 0.5) * 0.4;
|
|
114
|
+
const height = ridge * lift * 46 * (0.7 + 0.6 * knoll) + lift * fine(u, t) * 5;
|
|
115
|
+
positions.push(Math.cos(a) * radius, seaLevel - 1 + height, Math.sin(a) * radius);
|
|
116
|
+
const c = near
|
|
117
|
+
.clone()
|
|
118
|
+
.lerp(far, t * 0.6 * coarse(u + 0.5, t * 0.3))
|
|
119
|
+
.multiplyScalar(0.8 + 0.4 * fine(u + 0.25, t * 0.7));
|
|
120
|
+
colors.push(c.r, c.g, c.b);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const index: number[] = [];
|
|
124
|
+
for (let r = 0; r < rings; r += 1) {
|
|
125
|
+
for (let s = 0; s < segments; s += 1) {
|
|
126
|
+
const a = r * (segments + 1) + s;
|
|
127
|
+
const b = a + segments + 1;
|
|
128
|
+
index.push(a, a + 1, b, a + 1, b + 1, b);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const geometry = new BufferGeometry();
|
|
132
|
+
geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
|
|
133
|
+
geometry.setAttribute("color", new BufferAttribute(new Float32Array(colors), 3));
|
|
134
|
+
geometry.setIndex(index);
|
|
135
|
+
geometry.computeVertexNormals();
|
|
136
|
+
const hills = new Mesh(geometry, lit(0xffffff, { roughness: 1, vertexColors: true }));
|
|
137
|
+
hills.name = "far-hills";
|
|
138
|
+
return hills;
|
|
139
|
+
}
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
// Generated for you. This is ordinary Three.js — edit or delete it freely.
|
|
2
|
+
//
|
|
3
|
+
// Pip, the hero: a stout sprout-keeper in a teal knit beanie and a belted mustard tunic, modelled from
|
|
4
|
+
// primitives — no mesh file and no skin. The silhouette is a chunky toy (big head,
|
|
5
|
+
// round nose, round torso, stubby limbs, big shoes); the beanie, the leaf patch and the palette are
|
|
6
|
+
// this game's own. Arms and legs are groups pivoting at the shoulder and the hip. The idle, walk and
|
|
7
|
+
// run are `AnimationClip`s built here from a few rotations; `Hero.ts` plays them through
|
|
8
|
+
// `AnimationPlayer`, which times the walk and run to the ground the body covers. Jumps, flips and
|
|
9
|
+
// the hang are posed procedurally on top. Local space is feet at y = 0, facing -Z (Three.js
|
|
10
|
+
// forward); `createHero` returns the group, its clips and the function that poses the rest.
|
|
11
|
+
import {
|
|
12
|
+
AnimationClip,
|
|
13
|
+
CircleGeometry,
|
|
14
|
+
ConeGeometry,
|
|
15
|
+
CylinderGeometry,
|
|
16
|
+
Group,
|
|
17
|
+
MathUtils,
|
|
18
|
+
Mesh,
|
|
19
|
+
type MeshBasicMaterial,
|
|
20
|
+
MeshStandardMaterial,
|
|
21
|
+
Quaternion,
|
|
22
|
+
QuaternionKeyframeTrack,
|
|
23
|
+
Shape,
|
|
24
|
+
ShapeGeometry,
|
|
25
|
+
SphereGeometry,
|
|
26
|
+
TorusGeometry,
|
|
27
|
+
Vector3,
|
|
28
|
+
VectorKeyframeTrack,
|
|
29
|
+
} from "three";
|
|
30
|
+
import { flat, lit, paintedTexture } from "./materials.js";
|
|
31
|
+
import { C } from "./palette.js";
|
|
32
|
+
|
|
33
|
+
export interface IHeroPose {
|
|
34
|
+
/** The action `Hero.ts` is in: "idle", "run", "triple", "backflip", "dive", "ledgeHang"… */
|
|
35
|
+
readonly action: string;
|
|
36
|
+
readonly dt: number;
|
|
37
|
+
/** Seconds since the action started, which is what a flip's spin is timed on. */
|
|
38
|
+
readonly actionTime: number;
|
|
39
|
+
/** Metres between the feet and the ground under them, for the contact shadow. */
|
|
40
|
+
readonly drop: number;
|
|
41
|
+
readonly speed: number;
|
|
42
|
+
readonly vy: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface IHero {
|
|
46
|
+
readonly group: Group;
|
|
47
|
+
/** "idle", "walk", "run" and "air" (the neutral pose the procedural jumps bend). */
|
|
48
|
+
readonly clips: readonly AnimationClip[];
|
|
49
|
+
/** The two soles, for measuring whether a planted foot slides. */
|
|
50
|
+
readonly soles: readonly Mesh[];
|
|
51
|
+
update(pose: IHeroPose): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** One key of a cycle: each limb's swing about its joint (+ is forward), each foot's lift, the body. */
|
|
55
|
+
interface ICycleKey {
|
|
56
|
+
readonly legs: readonly [number, number];
|
|
57
|
+
readonly lift: readonly [number, number];
|
|
58
|
+
readonly arms: readonly [number, number];
|
|
59
|
+
readonly bob: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const SWINGS = ["legSwingL", "legSwingR", "armSwingL", "armSwingR"] as const;
|
|
63
|
+
const X_AXIS = new Vector3(1, 0, 0);
|
|
64
|
+
|
|
65
|
+
/** A looping clip sampled from `key(p)` at 33 keys over one cycle, p from 0 to 1. */
|
|
66
|
+
function cycleClip(name: string, period: number, key: (p: number) => ICycleKey): AnimationClip {
|
|
67
|
+
const keys = Array.from({ length: 33 }, (_, i) => key((i / 32) % 1));
|
|
68
|
+
const times = keys.map((_, i) => (i / 32) * period);
|
|
69
|
+
const q = new Quaternion();
|
|
70
|
+
const turn = (axis: Vector3, angle: (k: ICycleKey) => number) =>
|
|
71
|
+
keys.flatMap((k) => q.setFromAxisAngle(axis, angle(k)).toArray());
|
|
72
|
+
const angles = [
|
|
73
|
+
(k: ICycleKey) => k.legs[0],
|
|
74
|
+
(k: ICycleKey) => k.legs[1],
|
|
75
|
+
(k: ICycleKey) => k.arms[0],
|
|
76
|
+
(k: ICycleKey) => k.arms[1],
|
|
77
|
+
];
|
|
78
|
+
return new AnimationClip(name, period, [
|
|
79
|
+
...SWINGS.map(
|
|
80
|
+
(swing, i) =>
|
|
81
|
+
new QuaternionKeyframeTrack(
|
|
82
|
+
`${swing}.quaternion`,
|
|
83
|
+
times,
|
|
84
|
+
turn(X_AXIS, angles[i] as (k: ICycleKey) => number),
|
|
85
|
+
),
|
|
86
|
+
),
|
|
87
|
+
...[0, 1].map(
|
|
88
|
+
(side) =>
|
|
89
|
+
new VectorKeyframeTrack(
|
|
90
|
+
`${SWINGS[side]}.position`,
|
|
91
|
+
times,
|
|
92
|
+
keys.flatMap((k) => [0, k.lift[side] ?? 0, 0]),
|
|
93
|
+
),
|
|
94
|
+
),
|
|
95
|
+
new VectorKeyframeTrack(
|
|
96
|
+
"bounce.position",
|
|
97
|
+
times,
|
|
98
|
+
keys.flatMap((k) => [0, k.bob, 0]),
|
|
99
|
+
),
|
|
100
|
+
]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* A stride: each foot is planted for `stance` of the cycle, sweeping back from `reach` ahead of the
|
|
105
|
+
* hip to `reach` behind it, then swings forward lifted by `lift`. The body is lowest at each
|
|
106
|
+
* mid-stance and rises `bob` between them. The arms swing against the legs.
|
|
107
|
+
*
|
|
108
|
+
* The planted foot slides back at one steady speed (the angle is the arcsine of a linear sweep):
|
|
109
|
+
* a leg turning at a steady rate moves its foot fastest under the hip, so the foot would skate
|
|
110
|
+
* whatever rate the clip played at. The hips do not twist: a turn of the body about the vertical
|
|
111
|
+
* swings a planted foot sideways, which `playtests/stride.playtest.json` reads as a slide.
|
|
112
|
+
*/
|
|
113
|
+
function gait(stance: number, reach: number, lift: number, arms: number, bob: number) {
|
|
114
|
+
const leg = (p: number) => {
|
|
115
|
+
if (p < stance) return [Math.asin(Math.sin(reach) * (1 - (2 * p) / stance)), 0] as const;
|
|
116
|
+
const s = (p - stance) / (1 - stance);
|
|
117
|
+
return [-reach + reach * (1 - Math.cos(Math.PI * s)), lift * Math.sin(Math.PI * s)] as const;
|
|
118
|
+
};
|
|
119
|
+
return (p: number): ICycleKey => {
|
|
120
|
+
const [l, liftL] = leg(p);
|
|
121
|
+
const [r, liftR] = leg((p + 0.5) % 1);
|
|
122
|
+
const swing = Math.cos(Math.PI * 2 * p);
|
|
123
|
+
return {
|
|
124
|
+
arms: [-arms * swing, arms * swing],
|
|
125
|
+
bob: (bob * (1 - Math.cos(Math.PI * 4 * (p - stance / 2)))) / 2,
|
|
126
|
+
legs: [l, r],
|
|
127
|
+
lift: [liftL, liftR],
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const CLIPS = [
|
|
133
|
+
cycleClip("idle", 2.4, (p) => {
|
|
134
|
+
const breath = Math.sin(Math.PI * 2 * p);
|
|
135
|
+
return {
|
|
136
|
+
arms: [0.04 * breath, -0.04 * breath],
|
|
137
|
+
bob: 0.012 * breath,
|
|
138
|
+
legs: [0, 0],
|
|
139
|
+
lift: [0, 0],
|
|
140
|
+
};
|
|
141
|
+
}),
|
|
142
|
+
// The walk lifts its swing foot 16 cm: at 6 cm it stayed inside the band a run plants in.
|
|
143
|
+
cycleClip("walk", 0.5, gait(0.5, 0.6, 0.16, 0.45, 0.03)),
|
|
144
|
+
cycleClip("run", 0.45, gait(0.15, 0.85, 0.14, 1.1, 0.1)),
|
|
145
|
+
cycleClip("air", 1, () => ({ arms: [0, 0], bob: 0, legs: [0, 0], lift: [0, 0] })),
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
/** The pivot every flip and squash turns about: the middle of the torso, above the feet. */
|
|
149
|
+
const BODY_Y = 0.8;
|
|
150
|
+
/** Shoulder joint, from the pivot. */
|
|
151
|
+
const SHOULDER = { x: 0.32, y: 0.14 };
|
|
152
|
+
/** Shoulder to glove centre at rest. */
|
|
153
|
+
const ARM = 0.3;
|
|
154
|
+
/**
|
|
155
|
+
* The hang, from the feet: `Hero.ts` holds the capsule (radius 0.35) 0.37 m off the wall, with the
|
|
156
|
+
* lip 1.3 m above the feet. The body lifts and leans back off the wall, and each arm reaches its
|
|
157
|
+
* glove onto the lip, stretching like a cartoon arm does.
|
|
158
|
+
*/
|
|
159
|
+
const HANG = (() => {
|
|
160
|
+
const lift = 0.15;
|
|
161
|
+
const back = 0.12;
|
|
162
|
+
const glove = { y: 1.3 + 0.12, z: -0.36 };
|
|
163
|
+
const dy = glove.y - (BODY_Y + lift + SHOULDER.y);
|
|
164
|
+
const dz = glove.z - back;
|
|
165
|
+
return { angle: Math.atan2(-dz, -dy), back, lift, stretch: Math.hypot(dy, dz) / ARM };
|
|
166
|
+
})();
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Woven cloth: a fine diagonal twill, and with `seams` a stitched seam down each side and the front
|
|
170
|
+
* and back (a sphere's u = 0, 1/4, 1/2, 3/4), a darker fold with a dashed paler thread beside it.
|
|
171
|
+
*/
|
|
172
|
+
function fabric(color: number, seams: boolean): MeshStandardMaterial {
|
|
173
|
+
const size = 128;
|
|
174
|
+
const map = paintedTexture(
|
|
175
|
+
size,
|
|
176
|
+
size,
|
|
177
|
+
(x, y) => {
|
|
178
|
+
const twill = 0.94 + 0.06 * Math.sin(((x + y) / size) * Math.PI * 2 * 48);
|
|
179
|
+
const u = (x % (size / 4)) / (size / 4);
|
|
180
|
+
const fold = seams ? Math.min(u, 1 - u) * (size / 4) : 99;
|
|
181
|
+
const stitch = fold > 1.5 && fold < 2.6 && y % 6 < 3 ? 1.12 : 1;
|
|
182
|
+
const v = twill * (fold < 1.2 ? 0.72 : 1) * stitch;
|
|
183
|
+
return [v, v, v];
|
|
184
|
+
},
|
|
185
|
+
true,
|
|
186
|
+
);
|
|
187
|
+
return new MeshStandardMaterial({ color, map, roughness: 0.95 });
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function createHero(): IHero {
|
|
191
|
+
const root = new Group();
|
|
192
|
+
// The clips bob `bounce`; the procedural poses own `pivot` inside it.
|
|
193
|
+
const bounce = new Group();
|
|
194
|
+
bounce.name = "bounce";
|
|
195
|
+
root.add(bounce);
|
|
196
|
+
const pivot = new Group();
|
|
197
|
+
pivot.position.y = BODY_Y;
|
|
198
|
+
bounce.add(pivot);
|
|
199
|
+
/** A primitive on `parent`; small details skip the shadow map. */
|
|
200
|
+
const part = (
|
|
201
|
+
geometry: SphereGeometry | CylinderGeometry | ConeGeometry,
|
|
202
|
+
color: number,
|
|
203
|
+
parent: Group,
|
|
204
|
+
at: readonly [number, number, number],
|
|
205
|
+
scale: readonly [number, number, number] = [1, 1, 1],
|
|
206
|
+
shadow = true,
|
|
207
|
+
): Mesh => {
|
|
208
|
+
const mesh = new Mesh(geometry, lit(color));
|
|
209
|
+
mesh.position.set(...at);
|
|
210
|
+
mesh.scale.set(...scale);
|
|
211
|
+
mesh.castShadow = shadow;
|
|
212
|
+
parent.add(mesh);
|
|
213
|
+
return mesh;
|
|
214
|
+
};
|
|
215
|
+
const ball = (radius: number) => new SphereGeometry(radius, 24, 16);
|
|
216
|
+
const tunic = fabric(C.tunic, true);
|
|
217
|
+
const shirt = fabric(C.shirt, false);
|
|
218
|
+
|
|
219
|
+
// Torso: a round shirt under a round tunic, cinched by a leather belt with a brass buckle. It
|
|
220
|
+
// sits low, so the legs stay stubby and the head is a third of the hero.
|
|
221
|
+
part(ball(0.31), C.shirt, pivot, [0, 0.08, 0]).material = shirt;
|
|
222
|
+
part(ball(0.35), C.tunic, pivot, [0, -0.08, 0], [1, 0.9, 0.9]).material = tunic;
|
|
223
|
+
const belt = new Mesh(new TorusGeometry(0.345, 0.035, 8, 28), lit(C.boots, { roughness: 0.5 }));
|
|
224
|
+
belt.position.y = -0.03;
|
|
225
|
+
belt.rotation.x = Math.PI / 2;
|
|
226
|
+
belt.scale.set(1, 0.9, 1);
|
|
227
|
+
pivot.add(belt);
|
|
228
|
+
part(ball(0.055), C.gold, pivot, [0, -0.03, -0.325], [1.2, 1, 0.5], false);
|
|
229
|
+
|
|
230
|
+
// Head: big and round, ears, a round nose and eyes below the beanie's cuff; no moustache.
|
|
231
|
+
const R = 0.37;
|
|
232
|
+
const HEAD_Y = 0.6;
|
|
233
|
+
const FACE = -0.02 - R;
|
|
234
|
+
part(ball(R), C.skin, pivot, [0, HEAD_Y, -0.02]);
|
|
235
|
+
for (const side of [-1, 1]) {
|
|
236
|
+
part(ball(0.075), C.skin, pivot, [(R - 0.01) * side, HEAD_Y - 0.03, 0], [0.6, 1, 1], false);
|
|
237
|
+
// The whites glow a little, so the eyes read under the cuff's shade at any exposure.
|
|
238
|
+
part(
|
|
239
|
+
ball(0.092),
|
|
240
|
+
C.white,
|
|
241
|
+
pivot,
|
|
242
|
+
[0.112 * side, HEAD_Y - 0.005, FACE + 0.035],
|
|
243
|
+
[0.82, 1.2, 0.5],
|
|
244
|
+
false,
|
|
245
|
+
).material = lit(C.white, { emissive: 0.45 });
|
|
246
|
+
part(
|
|
247
|
+
ball(0.044),
|
|
248
|
+
C.ink,
|
|
249
|
+
pivot,
|
|
250
|
+
[0.122 * side, HEAD_Y - 0.012, FACE - 0.008],
|
|
251
|
+
[1, 1.3, 0.6],
|
|
252
|
+
false,
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
// The nose sits below the eye whites, clear of them, and a small smile under it gives the face an
|
|
256
|
+
// expression: a flattened half ring laid on the head's surface (tilted 0.55 rad, the face's slope
|
|
257
|
+
// there), high enough to stay clear of the collar.
|
|
258
|
+
part(ball(0.072), C.nose, pivot, [0, HEAD_Y - 0.13, FACE + 0.015], [1, 0.88, 0.85], false);
|
|
259
|
+
const smile = new Mesh(new TorusGeometry(0.075, 0.019, 6, 16, Math.PI), lit(C.mouth));
|
|
260
|
+
smile.position.set(0, HEAD_Y - 0.19, -0.338);
|
|
261
|
+
smile.rotation.set(-0.55, 0, Math.PI);
|
|
262
|
+
smile.scale.y = 0.57;
|
|
263
|
+
pivot.add(smile);
|
|
264
|
+
// Hair below the back of the beanie's cuff: wide and tucked under it, so from behind it reads
|
|
265
|
+
// as hair and never as a second face.
|
|
266
|
+
part(ball(0.15), C.hair, pivot, [0, HEAD_Y + 0.06, 0.24], [2, 0.6, 0.8], false);
|
|
267
|
+
// A slouchy knit beanie: a tall soft crown over a rolled cuff that sits above the eyes, a leaf
|
|
268
|
+
// patch on its front and a sprout stem on top. Matte, like wool.
|
|
269
|
+
const cap = lit(C.cap, { roughness: 0.85 });
|
|
270
|
+
part(
|
|
271
|
+
new SphereGeometry(R - 0.01, 22, 10, 0, Math.PI * 2, 0, Math.PI / 2),
|
|
272
|
+
C.cap,
|
|
273
|
+
pivot,
|
|
274
|
+
[0, HEAD_Y + 0.16, 0],
|
|
275
|
+
[1, 1.05, 1],
|
|
276
|
+
).material = cap;
|
|
277
|
+
const cuff = new Mesh(new TorusGeometry(0.34, 0.055, 10, 28), cap);
|
|
278
|
+
cuff.position.set(0, HEAD_Y + 0.16, -0.01);
|
|
279
|
+
cuff.rotation.x = Math.PI / 2;
|
|
280
|
+
cuff.castShadow = true;
|
|
281
|
+
pivot.add(cuff);
|
|
282
|
+
// The patch: a leaf (two arcs meeting in points) in a pale teal, laid on the crown's front just
|
|
283
|
+
// proud of it, tipped back 0.47 rad to follow the curve.
|
|
284
|
+
const outline = new Shape()
|
|
285
|
+
.moveTo(0, -0.11)
|
|
286
|
+
.quadraticCurveTo(0.09, 0, 0, 0.11)
|
|
287
|
+
.quadraticCurveTo(-0.09, 0, 0, -0.11);
|
|
288
|
+
const patch = new Mesh(new ShapeGeometry(outline).rotateZ(-0.6).rotateY(Math.PI), lit(C.badge));
|
|
289
|
+
patch.position.set(0, HEAD_Y + 0.34, -0.337);
|
|
290
|
+
patch.rotation.x = 0.47;
|
|
291
|
+
pivot.add(patch);
|
|
292
|
+
const sprout = part(new ConeGeometry(0.05, 0.24, 8), C.leaf, pivot, [0.03, HEAD_Y + 0.6, 0]);
|
|
293
|
+
sprout.rotation.z = -0.4;
|
|
294
|
+
|
|
295
|
+
// Arms: a sleeve and a glove on a shoulder joint. Legs: an overall leg and a big shoe on a hip.
|
|
296
|
+
const arms: Group[] = [];
|
|
297
|
+
const legs: Group[] = [];
|
|
298
|
+
const soles: Mesh[] = [];
|
|
299
|
+
// Each limb is a joint the procedural poses turn, holding a swing the clips turn.
|
|
300
|
+
const joint = (parent: Group, name: string): [Group, Group] => {
|
|
301
|
+
const outer = new Group();
|
|
302
|
+
const swing = new Group();
|
|
303
|
+
swing.name = name;
|
|
304
|
+
outer.add(swing);
|
|
305
|
+
parent.add(outer);
|
|
306
|
+
return [outer, swing];
|
|
307
|
+
};
|
|
308
|
+
for (const side of [-1, 1]) {
|
|
309
|
+
const tag = side < 0 ? "L" : "R";
|
|
310
|
+
const [arm, armSwing] = joint(pivot, `armSwing${tag}`);
|
|
311
|
+
arm.position.set(SHOULDER.x * side, SHOULDER.y, 0);
|
|
312
|
+
arm.rotation.z = 0.35 * side;
|
|
313
|
+
part(new CylinderGeometry(0.075, 0.07, 0.22, 16), C.shirt, armSwing, [0, -0.11, 0]).material =
|
|
314
|
+
shirt;
|
|
315
|
+
// A soft leather glove with a rolled cuff at the wrist.
|
|
316
|
+
const glove = lit(C.gloves, { roughness: 0.55 });
|
|
317
|
+
part(ball(0.12), C.gloves, armSwing, [0, -ARM, 0]).material = glove;
|
|
318
|
+
const cuff = new Mesh(new TorusGeometry(0.085, 0.03, 10, 20), glove);
|
|
319
|
+
cuff.position.y = -ARM + 0.1;
|
|
320
|
+
cuff.rotation.x = Math.PI / 2;
|
|
321
|
+
armSwing.add(cuff);
|
|
322
|
+
arms.push(arm);
|
|
323
|
+
|
|
324
|
+
// Hip 0.42 m above the feet; the shoe's sole is on the floor.
|
|
325
|
+
const [leg, legSwing] = joint(pivot, `legSwing${tag}`);
|
|
326
|
+
leg.position.set(0.15 * side, -0.38, 0);
|
|
327
|
+
part(new CylinderGeometry(0.1, 0.1, 0.18, 16), C.tunic, legSwing, [0, -0.09, 0]).material =
|
|
328
|
+
tunic;
|
|
329
|
+
// Polished leather on a darker, flat rubber sole. Both meshes have their origin where the sole
|
|
330
|
+
// meets the floor, so `AnimationPlayer` reads the stride at the contact point, not the boot's
|
|
331
|
+
// middle (which sweeps a smaller circle and would make the planted foot skate).
|
|
332
|
+
const contact: [number, number, number] = [0, -0.419, -0.06];
|
|
333
|
+
const boot = ball(0.17).scale(1, 0.66, 1.45).translate(0, 0.129, 0);
|
|
334
|
+
part(boot, C.boots, legSwing, contact).material = lit(C.boots, { roughness: 0.42 });
|
|
335
|
+
const sole = part(
|
|
336
|
+
ball(0.17).scale(1.04, 0.2, 1.5).translate(0, 0.034, 0),
|
|
337
|
+
C.sole,
|
|
338
|
+
legSwing,
|
|
339
|
+
contact,
|
|
340
|
+
);
|
|
341
|
+
// Named for the playtest's `footSlip` assertion, which follows these nodes by name.
|
|
342
|
+
sole.name = `foot${tag}`;
|
|
343
|
+
soles.push(sole);
|
|
344
|
+
sole.material = lit(C.sole, { roughness: 0.85 });
|
|
345
|
+
legs.push(leg);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// The contact shadow: a blob that shrinks with the drop, so a jump reads against the grass even
|
|
349
|
+
// where the shadow map's own shadow is a few texels across.
|
|
350
|
+
const blob = new Mesh(
|
|
351
|
+
new CircleGeometry(0.55, 20),
|
|
352
|
+
flat(C.ink, { depthWrite: false, opacity: 0.32 }),
|
|
353
|
+
);
|
|
354
|
+
blob.rotation.x = -Math.PI / 2;
|
|
355
|
+
blob.renderOrder = 2;
|
|
356
|
+
root.add(blob);
|
|
357
|
+
|
|
358
|
+
let time = 0;
|
|
359
|
+
const [armL, armR] = arms as [Group, Group];
|
|
360
|
+
const [legL, legR] = legs as [Group, Group];
|
|
361
|
+
const ease = (from: number, to: number, k: number) => MathUtils.lerp(from, to, k);
|
|
362
|
+
return {
|
|
363
|
+
clips: CLIPS,
|
|
364
|
+
group: root,
|
|
365
|
+
soles,
|
|
366
|
+
update(pose: IHeroPose): void {
|
|
367
|
+
time += pose.dt;
|
|
368
|
+
const run = Math.min(1, pose.speed / 9.6);
|
|
369
|
+
const k = 1 - Math.exp(-pose.dt * 18);
|
|
370
|
+
let pitch = 0;
|
|
371
|
+
let roll = 0;
|
|
372
|
+
let squash = 1;
|
|
373
|
+
/** Arm swing about the shoulder: 0 hangs down, π/2 points forward, π points up. */
|
|
374
|
+
let reachAngle: number | undefined;
|
|
375
|
+
let spread = 0.35;
|
|
376
|
+
let stretch = 1;
|
|
377
|
+
const hang = pose.action === "ledgeHang" || pose.action === "ledgeClimb";
|
|
378
|
+
const t = pose.actionTime;
|
|
379
|
+
switch (pose.action) {
|
|
380
|
+
case "triple":
|
|
381
|
+
case "backflip":
|
|
382
|
+
// A full forward (triple) or backward (backflip) somersault over the first 0.6 s.
|
|
383
|
+
pitch = (pose.action === "triple" ? -1 : 1) * Math.min(1, t / 0.6) * Math.PI * 2;
|
|
384
|
+
spread = 1.1;
|
|
385
|
+
break;
|
|
386
|
+
case "sideflip":
|
|
387
|
+
roll = Math.min(1, t / 0.6) * Math.PI * 2;
|
|
388
|
+
spread = 1.1;
|
|
389
|
+
break;
|
|
390
|
+
case "dive":
|
|
391
|
+
case "diveSlide":
|
|
392
|
+
pitch = -1.25;
|
|
393
|
+
reachAngle = Math.PI;
|
|
394
|
+
spread = 0.15;
|
|
395
|
+
break;
|
|
396
|
+
case "longJump":
|
|
397
|
+
pitch = -0.55;
|
|
398
|
+
reachAngle = 2.4;
|
|
399
|
+
spread = 0.2;
|
|
400
|
+
break;
|
|
401
|
+
case "groundPound":
|
|
402
|
+
pitch = t < 0.25 ? -(t / 0.25) * Math.PI * 2 : 0;
|
|
403
|
+
squash = t < 0.25 ? 0.85 : 0.9;
|
|
404
|
+
spread = 1.2;
|
|
405
|
+
break;
|
|
406
|
+
case "crouch":
|
|
407
|
+
case "crouchSlide":
|
|
408
|
+
squash = 0.72;
|
|
409
|
+
break;
|
|
410
|
+
default:
|
|
411
|
+
if (hang) {
|
|
412
|
+
reachAngle = HANG.angle;
|
|
413
|
+
spread = 0.12;
|
|
414
|
+
stretch = HANG.stretch;
|
|
415
|
+
}
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
const grounded = pose.action === "idle" || pose.action === "run" || pose.action === "skid";
|
|
419
|
+
if (grounded) {
|
|
420
|
+
// The idle, walk and run clips swing the limbs; the joints settle back to rest under them.
|
|
421
|
+
for (const limb of [legL, legR, armL, armR]) limb.rotation.x = ease(limb.rotation.x, 0, k);
|
|
422
|
+
pitch = pose.action === "skid" ? 0.35 : -run * 0.2;
|
|
423
|
+
} else {
|
|
424
|
+
const rise = MathUtils.clamp(pose.vy / 12, -1, 1);
|
|
425
|
+
// Hanging, the legs dangle back off the wall and kick slowly, so they show below the body
|
|
426
|
+
// instead of folding into the wall under it.
|
|
427
|
+
const kick = Math.sin(time * 3.2) * 0.22;
|
|
428
|
+
legL.rotation.x = ease(legL.rotation.x, hang ? -0.55 + kick : 0.7 - rise * 0.3, k);
|
|
429
|
+
legR.rotation.x = ease(legR.rotation.x, hang ? -0.35 - kick : -0.3 + rise * 0.2, k);
|
|
430
|
+
// A rising jump throws one fist up; falling, both arms float out.
|
|
431
|
+
const up = reachAngle ?? (rise > 0.2 ? 2.6 : 0.4);
|
|
432
|
+
armL.rotation.x = ease(armL.rotation.x, reachAngle ?? 0.4, k);
|
|
433
|
+
armR.rotation.x = ease(armR.rotation.x, up, k);
|
|
434
|
+
}
|
|
435
|
+
armL.rotation.z = ease(armL.rotation.z, -spread, k);
|
|
436
|
+
armR.rotation.z = ease(armR.rotation.z, spread, k);
|
|
437
|
+
legL.rotation.z = ease(legL.rotation.z, hang ? -0.25 : 0, k);
|
|
438
|
+
legR.rotation.z = ease(legR.rotation.z, hang ? 0.25 : 0, k);
|
|
439
|
+
for (const arm of arms) arm.scale.y = ease(arm.scale.y, stretch, k);
|
|
440
|
+
pivot.position.z = ease(pivot.position.z, hang ? HANG.back : 0, k);
|
|
441
|
+
pivot.position.y = BODY_Y * squash + (hang ? HANG.lift : 0);
|
|
442
|
+
pivot.scale.set(1 / Math.sqrt(squash), squash, 1 / Math.sqrt(squash));
|
|
443
|
+
pivot.rotation.x = pitch;
|
|
444
|
+
pivot.rotation.z = roll;
|
|
445
|
+
blob.position.y = -pose.drop + 0.02;
|
|
446
|
+
blob.visible = pose.drop < 9;
|
|
447
|
+
const shade = MathUtils.clamp(1 - pose.drop / 9, 0.25, 1);
|
|
448
|
+
blob.scale.setScalar(shade);
|
|
449
|
+
(blob.material as MeshBasicMaterial).opacity = 0.32 * shade;
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Generated for you. The starter kits share this meter; `pnpm stamp:template-render` copies it into
|
|
2
|
+
// each kit that ships it. Override it for one game in `exposure.ts`, not here.
|
|
3
|
+
//
|
|
4
|
+
// Core's meter is stock Unreal 5.8.3, exposure compensation +1 EV (key 0.36,
|
|
5
|
+
// r.DefaultFeature.AutoExposure.Bias 1.0, UE 5.8.3: Engine/Source/Runtime/Engine/Private/SceneView.cpp:196-199).
|
|
6
|
+
// The kits use 0 EV (key 0.18) instead. Their bright stylised scenes read pastel and veiled at
|
|
7
|
+
// +1 EV. At 0 EV a fresh Opus judge read IMPROVEMENT on 9 of 9 kits (PRD-747, 2026-10-26).
|
|
8
|
+
// The range keeps Unreal's -10..+20 EV100 window around the new key.
|
|
9
|
+
import {
|
|
10
|
+
type IExposureSettings,
|
|
11
|
+
exposureSettings as coreExposureSettings,
|
|
12
|
+
} from "@threenative/core";
|
|
13
|
+
|
|
14
|
+
const KEY = 0.18;
|
|
15
|
+
export const kitExposureSettings: Readonly<IExposureSettings> = {
|
|
16
|
+
...coreExposureSettings,
|
|
17
|
+
key: KEY,
|
|
18
|
+
minStops: Math.log2(KEY) - 20,
|
|
19
|
+
maxStops: Math.log2(KEY) + 10,
|
|
20
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Generated for you. This is ordinary Three.js — edit or delete it freely.
|
|
2
|
+
// ThreeNative does not read this file.
|
|
3
|
+
//
|
|
4
|
+
// One sun, and the sky in `sky.ts` is the fill — a fresh Unreal level's directional light and sky
|
|
5
|
+
// light, and nothing stacked on top. A hemisphere or ambient light next to an image-based
|
|
6
|
+
// environment fills the same faces twice and flattens the shadow side the sun is there to make.
|
|
7
|
+
import { DirectionalLight, PCFShadowMap, type Scene, Vector3 } from "three";
|
|
8
|
+
import { SUN_DIRECTION } from "./sky.js";
|
|
9
|
+
|
|
10
|
+
type ShadowRenderer = { shadowMap: { enabled: boolean; type: number } };
|
|
11
|
+
|
|
12
|
+
export interface ILighting {
|
|
13
|
+
/** Aimed at the hero every frame, so one shadow map covers the play space around it. */
|
|
14
|
+
readonly key: DirectionalLight;
|
|
15
|
+
follow(target: Vector3, forward?: Vector3): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function setupLighting(scene: Scene, renderer: ShadowRenderer, mobile = false): ILighting {
|
|
19
|
+
renderer.shadowMap.enabled = true;
|
|
20
|
+
// PCF with a radius: three's soft variant ignores `shadow.radius` and leaves a hard edge.
|
|
21
|
+
renderer.shadowMap.type = PCFShadowMap;
|
|
22
|
+
// A 4,000 K golden-hour sun. The level is the meter's: auto exposure scales the frame, so this
|
|
23
|
+
// number sets the sun against the sky, not how bright the picture is.
|
|
24
|
+
const key = new DirectionalLight(0xffcf9e, 6);
|
|
25
|
+
key.castShadow = true;
|
|
26
|
+
// The camera sees about 30 m of island ahead of the hero; the map is fitted to that and travels.
|
|
27
|
+
// A 2.5 cm texel and a 4-texel filter give a 10 cm soft edge, a morning sun's, not a cut-out.
|
|
28
|
+
// The 52 m window sits 14 m ahead of the hero, so the ground the camera sees keeps its shadows
|
|
29
|
+
// without paying for a wider map or a heavier shadow pass.
|
|
30
|
+
const size = mobile ? 1024 : 2048;
|
|
31
|
+
const extent = mobile ? 16 : 26;
|
|
32
|
+
key.shadow.mapSize.set(size, size);
|
|
33
|
+
key.shadow.radius = 4;
|
|
34
|
+
key.shadow.camera.near = 1;
|
|
35
|
+
key.shadow.camera.far = 140;
|
|
36
|
+
key.shadow.camera.left = -extent;
|
|
37
|
+
key.shadow.camera.right = extent;
|
|
38
|
+
key.shadow.camera.top = extent;
|
|
39
|
+
key.shadow.camera.bottom = -extent;
|
|
40
|
+
// Small biases: a large normal bias lifts the shadow off the feet of whatever casts it.
|
|
41
|
+
key.shadow.bias = -0.0002;
|
|
42
|
+
key.shadow.normalBias = 0.02;
|
|
43
|
+
scene.add(key);
|
|
44
|
+
scene.add(key.target);
|
|
45
|
+
const offset = SUN_DIRECTION.clone().multiplyScalar(60);
|
|
46
|
+
const ahead = new Vector3();
|
|
47
|
+
return {
|
|
48
|
+
follow(target: Vector3, forward?: Vector3): void {
|
|
49
|
+
ahead.set(0, 0, 0);
|
|
50
|
+
if (forward !== undefined) {
|
|
51
|
+
ahead.copy(forward);
|
|
52
|
+
ahead.y = 0;
|
|
53
|
+
if (ahead.lengthSq() > 1e-6) ahead.normalize().multiplyScalar(14);
|
|
54
|
+
}
|
|
55
|
+
key.position.set(
|
|
56
|
+
target.x + ahead.x + offset.x,
|
|
57
|
+
target.y + offset.y,
|
|
58
|
+
target.z + ahead.z + offset.z,
|
|
59
|
+
);
|
|
60
|
+
key.target.position.copy(target).add(ahead);
|
|
61
|
+
key.target.updateMatrixWorld();
|
|
62
|
+
},
|
|
63
|
+
key,
|
|
64
|
+
};
|
|
65
|
+
}
|