create-threenative 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -2
- package/agent-docs/references/assertion-reference.md +173 -6
- package/agent-docs/references/capability-reference.md +1303 -99
- package/agent-docs/references/capture-the-frame.md +7 -0
- package/agent-docs/references/creating-creatures.md +215 -0
- package/agent-docs/references/ctx-cookbook.md +69 -0
- package/agent-docs/references/debug-surface.md +8 -3
- package/agent-docs/references/dream-loop.md +150 -0
- package/agent-docs/references/finding-assets.md +70 -2
- package/agent-docs/references/sculpt-from-a-reference.md +3 -2
- package/agent-docs/references/trace-a-slow-frame.md +99 -0
- package/agent-docs/references/visual-baseline.md +41 -0
- package/agent-files/.agents/skills/file-engine-bug/SKILL.md +59 -0
- package/agent-files/.agents/skills/prd-creator/SKILL.md +40 -0
- package/agent-files/.agents/skills/threenative-assets/SKILL.md +45 -0
- package/agent-files/.agents/skills/threenative-builder/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +27 -0
- package/agent-files/.agents/skills/threenative-context/SKILL.md +57 -0
- package/agent-files/.agents/skills/threenative-performance/SKILL.md +42 -0
- package/agent-files/.agents/skills/threenative-playtest/SKILL.md +44 -0
- package/agent-files/.agents/skills/threenative-ui/SKILL.md +20 -0
- package/agent-files/.agents/skills/threenative-verifier/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-visuals/SKILL.md +41 -0
- package/agent-files/.claude/skills/file-engine-bug/SKILL.md +59 -0
- package/agent-files/.claude/skills/prd-creator/SKILL.md +40 -0
- package/agent-files/.claude/skills/threenative-assets/SKILL.md +45 -0
- package/agent-files/.claude/skills/threenative-capabilities/SKILL.md +27 -0
- package/agent-files/.claude/skills/threenative-context/SKILL.md +57 -0
- package/agent-files/.claude/skills/threenative-performance/SKILL.md +42 -0
- package/agent-files/.claude/skills/threenative-playtest/SKILL.md +44 -0
- package/agent-files/.claude/skills/threenative-ui/SKILL.md +20 -0
- package/agent-files/.claude/skills/threenative-visuals/SKILL.md +41 -0
- package/agent-files/scripts/reference.mjs +705 -0
- package/agent-files/scripts/visual-loop.mjs +382 -0
- package/capabilities.json +1881 -131
- package/dist/index.d.ts +39 -6
- package/dist/index.js +297 -32
- package/dist/threenative.js +822 -105
- package/package.json +30 -5
- package/template-assets/loading.ts +12 -2
- package/template-assets/patches/three@0.185.1.patch +249 -14
- package/template-assets/worldEnvironment.ts +758 -0
- package/templates/action-rpg/.codex/config.toml +4 -0
- package/templates/action-rpg/.cursor/mcp.json +32 -0
- package/templates/action-rpg/.gemini/settings.json +32 -0
- package/templates/action-rpg/.mcp.json +15 -3
- package/templates/action-rpg/.vscode/mcp.json +36 -0
- package/templates/action-rpg/.zed/settings.json +36 -0
- package/templates/action-rpg/AGENTS.md +69 -378
- package/templates/action-rpg/CLAUDE.md +69 -378
- package/templates/action-rpg/opencode.json +41 -0
- package/templates/action-rpg/package.json +7 -7
- package/templates/action-rpg/playtests/combat.playtest.json +9 -0
- package/templates/action-rpg/playtests/performance.playtest.json +24 -7
- package/templates/action-rpg/playtests/survives.playtest.json +27 -0
- package/templates/action-rpg/playtests/touch-controls.playtest.json +42 -0
- package/templates/action-rpg/src/conventions.ts +35 -0
- package/templates/action-rpg/src/entities/Enemy.ts +2 -3
- package/templates/action-rpg/src/entities/Player.ts +20 -3
- package/templates/action-rpg/src/render/camera.ts +7 -2
- package/templates/action-rpg/src/render/lighting.ts +5 -3
- package/templates/action-rpg/src/render/loading.ts +12 -2
- package/templates/action-rpg/src/render/materials.ts +11 -0
- package/templates/action-rpg/src/render/palette.ts +10 -3
- package/templates/action-rpg/src/render/postprocessing.ts +21 -58
- package/templates/action-rpg/src/render/quality.ts +170 -0
- package/templates/action-rpg/src/render/shapes.ts +185 -26
- package/templates/action-rpg/src/render/touch-controls.ts +185 -0
- package/templates/action-rpg/src/render/vfx.ts +257 -0
- package/templates/action-rpg/src/render/worldEnvironment.ts +208 -33
- package/templates/action-rpg/src/scenes/Play.ts +43 -6
- package/templates/action-rpg/src/style.css +20 -0
- package/templates/action-rpg/threenative.config.ts +7 -0
- package/templates/defense/.codex/config.toml +4 -0
- package/templates/defense/.cursor/mcp.json +32 -0
- package/templates/defense/.gemini/settings.json +32 -0
- package/templates/defense/.mcp.json +15 -3
- package/templates/defense/.vscode/mcp.json +36 -0
- package/templates/defense/.zed/settings.json +36 -0
- package/templates/defense/AGENTS.md +62 -385
- package/templates/defense/CLAUDE.md +62 -385
- package/templates/defense/opencode.json +41 -0
- package/templates/defense/package.json +7 -7
- package/templates/defense/playtests/performance.playtest.json +24 -7
- package/templates/defense/playtests/pointer-placement.playtest.json +87 -20
- package/templates/defense/playtests/scan.playtest.json +1 -1
- package/templates/defense/playtests/survive.playtest.json +14 -0
- package/templates/defense/src/attackers/Attacker.ts +4 -4
- package/templates/defense/src/board/Route.ts +22 -8
- package/templates/defense/src/conventions.ts +18 -0
- package/templates/defense/src/entities/Player.ts +11 -3
- package/templates/defense/src/game.ts +2 -3
- package/templates/defense/src/physics.ts +9 -39
- package/templates/defense/src/placement/Buildable.ts +4 -4
- package/templates/defense/src/render/camera.ts +9 -3
- package/templates/defense/src/render/loading.ts +12 -2
- package/templates/defense/src/render/materials.ts +9 -0
- package/templates/defense/src/render/palette.ts +12 -5
- package/templates/defense/src/render/postprocessing.ts +21 -58
- package/templates/defense/src/render/quality.ts +170 -0
- package/templates/defense/src/render/shapes.ts +142 -23
- package/templates/defense/src/render/sky.ts +2 -2
- package/templates/defense/src/render/worldEnvironment.ts +208 -33
- package/templates/defense/src/scenes/Boot.ts +2 -2
- package/templates/defense/src/scenes/Defense.ts +13 -6
- package/templates/defense/src/style.css +20 -0
- package/templates/defense/src/towers/Tower.ts +11 -12
- package/templates/defense/src/towers/targeting.ts +1 -1
- package/templates/defense/src/ui/App.tsx +2 -2
- package/templates/defense/threenative.config.ts +7 -0
- package/templates/minimal/.codex/config.toml +4 -0
- package/templates/minimal/.cursor/mcp.json +32 -0
- package/templates/minimal/.gemini/settings.json +32 -0
- package/templates/minimal/.mcp.json +15 -3
- package/templates/minimal/.vscode/mcp.json +36 -0
- package/templates/minimal/.zed/settings.json +36 -0
- package/templates/minimal/AGENTS.md +76 -485
- package/templates/minimal/CLAUDE.md +76 -485
- package/templates/minimal/opencode.json +41 -0
- package/templates/minimal/package.json +6 -6
- package/templates/minimal/playtests/play.playtest.json +2 -1
- package/templates/minimal/playtests/survives.playtest.json +48 -4
- package/templates/minimal/playtests/touch-controls.playtest.json +42 -0
- package/templates/minimal/src/conventions.ts +18 -0
- package/templates/minimal/src/entities/Player.ts +39 -6
- package/templates/minimal/src/main.ts +14 -4
- package/templates/minimal/src/render/materials.ts +7 -0
- package/templates/minimal/src/render/palette.ts +3 -3
- package/templates/minimal/src/render/postprocessing.ts +17 -56
- package/templates/minimal/src/render/quality.ts +162 -0
- package/templates/minimal/src/render/sky.ts +23 -9
- package/templates/minimal/src/render/touch-controls.ts +165 -0
- package/templates/minimal/src/render/worldEnvironment.ts +208 -33
- package/templates/minimal/src/scenes/Play.ts +47 -11
- package/templates/minimal/src/style.css +20 -0
- package/templates/minimal/threenative.config.ts +7 -0
- package/templates/platformer/.codex/config.toml +4 -0
- package/templates/platformer/.cursor/mcp.json +32 -0
- package/templates/platformer/.gemini/settings.json +32 -0
- package/templates/platformer/.mcp.json +15 -3
- package/templates/platformer/.vscode/mcp.json +36 -0
- package/templates/platformer/.zed/settings.json +36 -0
- package/templates/platformer/AGENTS.md +70 -430
- package/templates/platformer/CLAUDE.md +70 -430
- package/templates/platformer/opencode.json +41 -0
- package/templates/platformer/package.json +7 -7
- package/templates/platformer/playtests/oneway.playtest.json +29 -2
- package/templates/platformer/playtests/performance.playtest.json +2 -1
- package/templates/platformer/playtests/survives.playtest.json +31 -0
- package/templates/platformer/playtests/terminal-loop-fail.playtest.json +3 -0
- package/templates/platformer/playtests/touch-controls-web.playtest.json +15 -4
- package/templates/platformer/src/conventions.ts +18 -0
- package/templates/platformer/src/entities/Character.ts +63 -1
- package/templates/platformer/src/game.ts +3 -1
- package/templates/platformer/src/level/Platform.ts +13 -1
- package/templates/platformer/src/render/lighting.ts +7 -4
- package/templates/platformer/src/render/loading.ts +12 -2
- package/templates/platformer/src/render/palette.ts +4 -1
- package/templates/platformer/src/render/postprocessing.ts +32 -57
- package/templates/platformer/src/render/quality.ts +170 -0
- package/templates/platformer/src/render/worldEnvironment.ts +208 -33
- package/templates/platformer/src/scenes/Level.ts +52 -12
- package/templates/platformer/src/style.css +20 -0
- package/templates/platformer/threenative.config.ts +7 -0
- package/templates/puzzle/.codex/config.toml +19 -0
- package/templates/puzzle/.cursor/mcp.json +32 -0
- package/templates/puzzle/.gemini/settings.json +32 -0
- package/templates/puzzle/.mcp.json +32 -0
- package/templates/puzzle/.vscode/mcp.json +36 -0
- package/templates/puzzle/.zed/settings.json +36 -0
- package/templates/puzzle/AGENTS.md +96 -0
- package/templates/puzzle/CLAUDE.md +98 -0
- package/templates/puzzle/README.md +43 -0
- package/templates/puzzle/index.html +12 -0
- package/templates/puzzle/kit.json +7 -0
- package/templates/puzzle/opencode.json +41 -0
- package/templates/puzzle/package.json +50 -0
- package/templates/puzzle/playtests/carry.playtest.json +71 -0
- package/templates/puzzle/playtests/performance.playtest.json +23 -0
- package/templates/puzzle/playtests/survives.playtest.json +51 -0
- package/templates/puzzle/playtests/swing.playtest.json +38 -0
- package/templates/puzzle/public/favicon.svg +5 -0
- package/templates/puzzle/src/conventions.ts +25 -0
- package/templates/puzzle/src/entities/Ball.ts +70 -0
- package/templates/puzzle/src/entities/Crate.ts +76 -0
- package/templates/puzzle/src/entities/Gripper.ts +69 -0
- package/templates/puzzle/src/entities/Pendulum.ts +89 -0
- package/templates/puzzle/src/game.ts +48 -0
- package/templates/puzzle/src/main.ts +15 -0
- package/templates/puzzle/src/physics.ts +19 -0
- package/templates/puzzle/src/render/camera.ts +37 -0
- package/templates/puzzle/src/render/lighting.ts +55 -0
- package/templates/puzzle/src/render/loading.ts +325 -0
- package/templates/puzzle/src/render/materials.ts +28 -0
- package/templates/puzzle/src/render/palette.ts +31 -0
- package/templates/puzzle/src/render/postprocessing.ts +34 -0
- package/templates/puzzle/src/render/quality.ts +170 -0
- package/templates/puzzle/src/render/shapes.ts +134 -0
- package/templates/puzzle/src/render/sky.ts +16 -0
- package/templates/puzzle/src/render/touch-controls.ts +185 -0
- package/templates/puzzle/src/render/worldEnvironment.ts +758 -0
- package/templates/puzzle/src/room.ts +83 -0
- package/templates/puzzle/src/scenes/Boot.ts +12 -0
- package/templates/puzzle/src/scenes/Puzzle.ts +158 -0
- package/templates/puzzle/src/state.ts +30 -0
- package/templates/puzzle/src/style.css +96 -0
- package/templates/puzzle/src/ui/App.tsx +22 -0
- package/templates/puzzle/src/ui/GameUi.tsx +20 -0
- package/templates/puzzle/src/ui/Hud.tsx +57 -0
- package/templates/puzzle/src/ui/Menu.tsx +7 -0
- package/templates/puzzle/src/ui/main.tsx +14 -0
- package/templates/puzzle/tailwind.config.ts +1 -0
- package/templates/puzzle/threenative.config.ts +49 -0
- package/templates/puzzle/tsconfig.json +17 -0
- package/templates/puzzle/vite.config.ts +38 -0
- package/templates/racing/.codex/config.toml +4 -0
- package/templates/racing/.cursor/mcp.json +32 -0
- package/templates/racing/.gemini/settings.json +32 -0
- package/templates/racing/.mcp.json +15 -3
- package/templates/racing/.vscode/mcp.json +36 -0
- package/templates/racing/.zed/settings.json +36 -0
- package/templates/racing/AGENTS.md +63 -379
- package/templates/racing/CLAUDE.md +63 -379
- package/templates/racing/native-playtests/survives.playtest.json +43 -0
- package/templates/racing/opencode.json +41 -0
- package/templates/racing/package.json +8 -7
- package/templates/racing/playtests/performance.playtest.json +24 -7
- package/templates/racing/playtests/survives.playtest.json +36 -4
- package/templates/racing/playtests/touch-controls.playtest.json +41 -0
- package/templates/racing/src/conventions.ts +6 -0
- package/templates/racing/src/entities/RacingCar.ts +16 -4
- package/templates/racing/src/entities/Rival.ts +5 -2
- package/templates/racing/src/render/camera.ts +7 -4
- package/templates/racing/src/render/lighting.ts +22 -13
- package/templates/racing/src/render/loading.ts +12 -2
- package/templates/racing/src/render/materials.ts +54 -4
- package/templates/racing/src/render/palette.ts +23 -6
- package/templates/racing/src/render/postprocessing.ts +21 -58
- package/templates/racing/src/render/quality.ts +170 -0
- package/templates/racing/src/render/shapes.ts +537 -26
- package/templates/racing/src/render/sky.ts +5 -2
- package/templates/racing/src/render/touch-controls.ts +185 -0
- package/templates/racing/src/render/worldEnvironment.ts +208 -33
- package/templates/racing/src/scenes/Race.ts +17 -2
- package/templates/racing/src/style.css +20 -0
- package/templates/racing/src/track/Track.ts +270 -31
- package/templates/racing/threenative.config.ts +7 -0
- package/templates/runner/.codex/config.toml +19 -0
- package/templates/runner/.cursor/mcp.json +32 -0
- package/templates/runner/.gemini/settings.json +32 -0
- package/templates/runner/.mcp.json +32 -0
- package/templates/runner/.vscode/mcp.json +36 -0
- package/templates/runner/.zed/settings.json +36 -0
- package/templates/runner/AGENTS.md +96 -0
- package/templates/runner/CLAUDE.md +98 -0
- package/templates/runner/README.md +43 -0
- package/templates/runner/index.html +12 -0
- package/templates/runner/kit.json +7 -0
- package/templates/runner/opencode.json +41 -0
- package/templates/runner/package.json +50 -0
- package/templates/runner/playtests/performance.playtest.json +23 -0
- package/templates/runner/playtests/streams.playtest.json +38 -0
- package/templates/runner/playtests/survives.playtest.json +51 -0
- package/templates/runner/public/favicon.svg +5 -0
- package/templates/runner/src/conventions.ts +24 -0
- package/templates/runner/src/entities/Runner.ts +135 -0
- package/templates/runner/src/game.ts +50 -0
- package/templates/runner/src/main.ts +15 -0
- package/templates/runner/src/physics.ts +13 -0
- package/templates/runner/src/render/camera.ts +39 -0
- package/templates/runner/src/render/dust.ts +131 -0
- package/templates/runner/src/render/lighting.ts +57 -0
- package/templates/runner/src/render/loading.ts +325 -0
- package/templates/runner/src/render/materials.ts +27 -0
- package/templates/runner/src/render/palette.ts +30 -0
- package/templates/runner/src/render/postprocessing.ts +34 -0
- package/templates/runner/src/render/quality.ts +170 -0
- package/templates/runner/src/render/shapes.ts +68 -0
- package/templates/runner/src/render/sky.ts +51 -0
- package/templates/runner/src/render/touch-controls.ts +185 -0
- package/templates/runner/src/render/worldEnvironment.ts +758 -0
- package/templates/runner/src/scenes/Boot.ts +12 -0
- package/templates/runner/src/scenes/Run.ts +142 -0
- package/templates/runner/src/state.ts +29 -0
- package/templates/runner/src/style.css +96 -0
- package/templates/runner/src/track.ts +176 -0
- package/templates/runner/src/ui/App.tsx +22 -0
- package/templates/runner/src/ui/GameUi.tsx +20 -0
- package/templates/runner/src/ui/Hud.tsx +55 -0
- package/templates/runner/src/ui/Menu.tsx +7 -0
- package/templates/runner/src/ui/main.tsx +14 -0
- package/templates/runner/tailwind.config.ts +1 -0
- package/templates/runner/threenative.config.ts +49 -0
- package/templates/runner/tsconfig.json +17 -0
- package/templates/runner/vite.config.ts +38 -0
- package/templates/sailing/.codex/config.toml +4 -0
- package/templates/sailing/.cursor/mcp.json +32 -0
- package/templates/sailing/.gemini/settings.json +32 -0
- package/templates/sailing/.mcp.json +15 -3
- package/templates/sailing/.vscode/mcp.json +36 -0
- package/templates/sailing/.zed/settings.json +36 -0
- package/templates/sailing/AGENTS.md +62 -355
- package/templates/sailing/CLAUDE.md +62 -355
- package/templates/sailing/README.md +12 -9
- package/templates/sailing/native-playtests/float.playtest.json +55 -0
- package/templates/sailing/native-playtests/survives.playtest.json +20 -3
- package/templates/sailing/opencode.json +41 -0
- package/templates/sailing/package.json +8 -8
- package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +75 -0
- package/templates/sailing/playtests/float.playtest.json +59 -0
- package/templates/sailing/playtests/performance.playtest.json +21 -6
- package/templates/sailing/playtests/survives.playtest.json +8 -0
- package/templates/sailing/playtests/touch-controls.playtest.json +48 -0
- package/templates/sailing/src/conventions.ts +8 -0
- package/templates/sailing/src/entities/Ship.ts +150 -13
- package/templates/sailing/src/render/camera.ts +15 -8
- package/templates/sailing/src/render/lighting.ts +10 -5
- package/templates/sailing/src/render/loading.ts +12 -2
- package/templates/sailing/src/render/materials.ts +24 -8
- package/templates/sailing/src/render/ocean.ts +179 -0
- package/templates/sailing/src/render/palette.ts +14 -21
- package/templates/sailing/src/render/postprocessing.ts +23 -22
- package/templates/sailing/src/render/props.ts +584 -34
- package/templates/sailing/src/render/quality.ts +140 -0
- package/templates/sailing/src/render/sky.ts +8 -3
- package/templates/sailing/src/render/touch-controls.ts +142 -0
- package/templates/sailing/src/render/worldEnvironment.ts +206 -38
- package/templates/sailing/src/scenes/Sailing.ts +43 -16
- package/templates/sailing/src/style.css +20 -0
- package/templates/sailing/threenative.config.ts +7 -1
- package/templates/shooter/.codex/config.toml +4 -0
- package/templates/shooter/.cursor/mcp.json +32 -0
- package/templates/shooter/.gemini/settings.json +32 -0
- package/templates/shooter/.mcp.json +15 -3
- package/templates/shooter/.vscode/mcp.json +36 -0
- package/templates/shooter/.zed/settings.json +36 -0
- package/templates/shooter/AGENTS.md +76 -415
- package/templates/shooter/CLAUDE.md +76 -415
- package/templates/shooter/kit.json +2 -2
- package/templates/shooter/opencode.json +41 -0
- package/templates/shooter/package.json +7 -7
- package/templates/shooter/playtests/combat.playtest.json +48 -0
- package/templates/shooter/playtests/input-control.playtest.json +165 -35
- package/templates/shooter/playtests/per-item.playtest.json +3 -3
- package/templates/shooter/playtests/performance.playtest.json +24 -7
- package/templates/shooter/playtests/shooter.playtest.json +13 -7
- package/templates/shooter/playtests/survives.playtest.json +27 -0
- package/templates/shooter/playtests/touch-controls.playtest.json +42 -0
- package/templates/shooter/playtests/weapon-cycle.playtest.json +164 -0
- package/templates/shooter/src/combat/damage.ts +1 -2
- package/templates/shooter/src/conventions.ts +51 -0
- package/templates/shooter/src/entities/Player.ts +235 -18
- package/templates/shooter/src/entities/Target.ts +2 -2
- package/templates/shooter/src/game.ts +13 -4
- package/templates/shooter/src/render/camera.ts +49 -39
- package/templates/shooter/src/render/decals.ts +211 -0
- package/templates/shooter/src/render/lighting.ts +7 -3
- package/templates/shooter/src/render/loading.ts +12 -2
- package/templates/shooter/src/render/materials.ts +56 -3
- package/templates/shooter/src/render/palette.ts +6 -3
- package/templates/shooter/src/render/postprocessing.ts +21 -58
- package/templates/shooter/src/render/quality.ts +170 -0
- package/templates/shooter/src/render/scale.ts +22 -0
- package/templates/shooter/src/render/shapes.ts +343 -62
- package/templates/shooter/src/render/sky.ts +5 -1
- package/templates/shooter/src/render/touch-controls.ts +305 -0
- package/templates/shooter/src/render/ui.css +85 -0
- package/templates/shooter/src/render/ui.ts +19 -3
- package/templates/shooter/src/render/vfx.ts +215 -0
- package/templates/shooter/src/render/worldEnvironment.ts +208 -33
- package/templates/shooter/src/scenes/Play.ts +171 -56
- package/templates/shooter/src/state.ts +5 -0
- package/templates/shooter/src/style.css +20 -0
- package/templates/shooter/src/ui/Crosshair.tsx +25 -0
- package/templates/shooter/src/ui/GameUi.tsx +2 -0
- package/templates/shooter/src/ui/Hud.tsx +7 -1
- package/templates/shooter/src/weapons/Hitscan.ts +3 -4
- package/templates/shooter/src/weapons/Projectile.ts +8 -3
- package/templates/shooter/src/weapons/Viewmodel.ts +275 -0
- package/templates/shooter/threenative.config.ts +7 -0
- package/templates/starter/.codex/config.toml +4 -0
- package/templates/starter/.cursor/mcp.json +32 -0
- package/templates/starter/.gemini/settings.json +32 -0
- package/templates/starter/.mcp.json +15 -3
- package/templates/starter/.vscode/mcp.json +36 -0
- package/templates/starter/.zed/settings.json +36 -0
- package/templates/starter/AGENTS.md +70 -527
- package/templates/starter/CLAUDE.md +70 -527
- package/templates/starter/native-playtests/render-chain.playtest.json +73 -4
- package/templates/starter/opencode.json +41 -0
- package/templates/starter/package.json +7 -7
- package/templates/starter/playtests/boot-failure.playtest.json +45 -0
- package/templates/starter/playtests/look.playtest.json +110 -6
- package/templates/starter/playtests/play.playtest.json +3 -2
- package/templates/starter/playtests/survives.playtest.json +21 -0
- package/templates/starter/playtests/touch-controls.playtest.json +42 -0
- package/templates/starter/src/conventions.ts +18 -0
- package/templates/starter/src/entities/Goal.ts +18 -3
- package/templates/starter/src/entities/Player.ts +72 -9
- package/templates/starter/src/game.ts +2 -0
- package/templates/starter/src/render/adaptiveQuality.ts +195 -0
- package/templates/starter/src/render/camera.ts +1 -1
- package/templates/starter/src/render/coast.ts +199 -0
- package/templates/starter/src/render/hero.ts +88 -0
- package/templates/starter/src/render/implicitSurface.ts +199 -0
- package/templates/starter/src/render/kuwahara.ts +174 -0
- package/templates/starter/src/render/lighting.ts +4 -4
- package/templates/starter/src/render/loading.ts +12 -2
- package/templates/starter/src/render/materials.ts +25 -6
- package/templates/starter/src/render/outline.ts +141 -0
- package/templates/starter/src/render/painterly.ts +86 -0
- package/templates/starter/src/render/palette.ts +15 -6
- package/templates/starter/src/render/postprocessing.ts +87 -36
- package/templates/starter/src/render/quality.ts +185 -0
- package/templates/starter/src/render/rockRidge.ts +198 -0
- package/templates/starter/src/render/rockRidge.worker.ts +77 -0
- package/templates/starter/src/render/scenery.ts +16 -59
- package/templates/starter/src/render/textureLifetime.ts +53 -0
- package/templates/starter/src/render/touch-controls.ts +165 -0
- package/templates/starter/src/render/water.ts +38 -0
- package/templates/starter/src/render/watercolor.ts +85 -0
- package/templates/starter/src/render/worldEnvironment.ts +208 -33
- package/templates/starter/src/scenes/Play.ts +103 -16
- package/templates/starter/src/style.css +27 -7
- package/templates/starter/threenative.config.ts +7 -7
- package/agent-docs/asset-mcp-loop.md +0 -33
- package/agent-docs/ctx-surface.md +0 -69
- package/agent-docs/engine-capabilities.md +0 -4
- package/agent-docs/framework-blocks-you.md +0 -60
- package/agent-docs/look-at-it-and-budget-the-look.md +0 -27
- package/agent-docs/performance-default.md +0 -42
- package/agent-docs/pixel-budget.md +0 -20
- package/agent-docs/playtest-fail-closed.md +0 -23
- package/agent-docs/sculpt-loop.md +0 -16
- package/templates/action-rpg/src/physics.ts +0 -40
- package/templates/defense/public/icon.png +0 -0
- package/templates/minimal/public/icon.png +0 -0
- package/templates/platformer/public/icon.png +0 -0
- package/templates/racing/public/icon.png +0 -0
- package/templates/sailing/public/icon.png +0 -0
- package/templates/sailing/src/render/water-material.ts +0 -14
- package/templates/sailing/src/render/water-shaders.ts +0 -12
- package/templates/sailing/src/render/wave-nodes.ts +0 -10
- package/templates/shooter/public/icon.png +0 -0
- package/templates/shooter/src/physics.ts +0 -49
- package/templates/starter/public/icon.png +0 -0
- /package/{templates/action-rpg/public → template-assets}/icon.png +0 -0
|
@@ -1,52 +1,602 @@
|
|
|
1
|
-
// Generated for you. Geometry and surface choices for the sailing kit live in this file
|
|
2
|
-
|
|
1
|
+
// Generated for you. Geometry and surface choices for the sailing kit live in this file, and
|
|
2
|
+
// ThreeNative does not read it.
|
|
3
|
+
//
|
|
4
|
+
// The ship is a **lofted hull with a rig**. What used to be here was a lathe cylinder lying on its
|
|
5
|
+
// side, a box and one flat plane, and the first frame of the template showed a brown log with a
|
|
6
|
+
// sheet of paper propped against it. A hull is a series of cross-sections whose beam and rail
|
|
7
|
+
// height change along the keel — that is the whole idea, and `loftHull` below is nineteen lines of
|
|
8
|
+
// it. Every dimension is a number in `HULL_STATIONS`; every colour comes from `materials.ts`.
|
|
9
|
+
import {
|
|
10
|
+
BoxGeometry,
|
|
11
|
+
BufferAttribute,
|
|
12
|
+
BufferGeometry,
|
|
13
|
+
ConeGeometry,
|
|
14
|
+
CylinderGeometry,
|
|
15
|
+
Group,
|
|
16
|
+
type Material,
|
|
17
|
+
MathUtils,
|
|
18
|
+
Mesh,
|
|
19
|
+
SphereGeometry,
|
|
20
|
+
} from "three";
|
|
21
|
+
import { mergeGeometries } from "three/addons/utils/BufferGeometryUtils.js";
|
|
3
22
|
import type { ISailingMaterials } from "./materials.js";
|
|
4
23
|
|
|
24
|
+
/**
|
|
25
|
+
* One cross-section of the hull, at a station along the keel.
|
|
26
|
+
*
|
|
27
|
+
* `tumblehome` below 1 draws the section in above the widest point, so the deck is narrower than
|
|
28
|
+
* the beam. It is a small number with a large effect: at 1 the hull is a tub, and no amount of rig
|
|
29
|
+
* on top of a tub reads as a ship.
|
|
30
|
+
*/
|
|
31
|
+
interface IHullStation {
|
|
32
|
+
readonly halfBeam: number;
|
|
33
|
+
readonly keel: number;
|
|
34
|
+
readonly rail: number;
|
|
35
|
+
readonly tumblehome: number;
|
|
36
|
+
readonly z: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Ring resolution. Half the points draw the deck line, half draw the submerged section. */
|
|
40
|
+
const RING_SEGMENTS = 22;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* One point on a station's section, going clockwise from the starboard rail.
|
|
44
|
+
*
|
|
45
|
+
* The first half of the ring is the **deck line**: a straight run at rail height from starboard to
|
|
46
|
+
* port. The second half is the hull proper, bulging to its full beam a little below the rail and
|
|
47
|
+
* drawing in to the keel. Parameterised as one smooth loop instead — which is what this was — the
|
|
48
|
+
* section closes to a point at the top as well as the bottom, and the hull comes out as a
|
|
49
|
+
* symmetrical almond with a ridge down the middle. It photographed exactly like that: a wooden
|
|
50
|
+
* lens floating on its side with the rig apparently pointing sideways out of it.
|
|
51
|
+
*/
|
|
52
|
+
function ringPoint(station: IHullStation, index: number): [number, number, number] {
|
|
53
|
+
const deckHalf = station.halfBeam * station.tumblehome;
|
|
54
|
+
const t = index / RING_SEGMENTS;
|
|
55
|
+
if (t < 0.5) {
|
|
56
|
+
const u = t / 0.5;
|
|
57
|
+
return [(1 - 2 * u) * deckHalf, station.rail, station.z];
|
|
58
|
+
}
|
|
59
|
+
const u = (t - 0.5) / 0.5;
|
|
60
|
+
const angle = Math.PI * u;
|
|
61
|
+
const across = -Math.cos(angle);
|
|
62
|
+
// `depth` in [0, 1]: 0 at the rail, 1 at the keel. The 1.5 power holds the section full for
|
|
63
|
+
// most of the draught and turns it into a V only near the keel.
|
|
64
|
+
const depth = Math.sin(angle) ** 1.5;
|
|
65
|
+
// 0.55 keeps the topsides fairly upright rather than rounding them off into a barrel.
|
|
66
|
+
const spread = Math.sign(across) * Math.abs(across) ** 0.55;
|
|
67
|
+
// Tumblehome applies only in the top third; below that the section carries its full beam.
|
|
68
|
+
const width = depth < 0.3 ? MathUtils.lerp(station.tumblehome, 1, depth / 0.3) : 1;
|
|
69
|
+
return [
|
|
70
|
+
spread * station.halfBeam * width,
|
|
71
|
+
station.rail - depth * (station.rail - station.keel),
|
|
72
|
+
station.z,
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Stitch the stations into a closed hull, capped at both ends.
|
|
78
|
+
*
|
|
79
|
+
* Stations are sorted by z first: the winding that makes a face point outwards depends on the sign
|
|
80
|
+
* of the step along the keel, so a list authored bow-first would build the whole hull inside-out
|
|
81
|
+
* and backface culling would then show its interior.
|
|
82
|
+
*/
|
|
83
|
+
function loftHull(input: readonly IHullStation[]): BufferGeometry {
|
|
84
|
+
const stations = [...input].sort((a, b) => a.z - b.z);
|
|
85
|
+
const positions: number[] = [];
|
|
86
|
+
const push = (point: readonly [number, number, number]): void => {
|
|
87
|
+
positions.push(point[0], point[1], point[2]);
|
|
88
|
+
};
|
|
89
|
+
for (let s = 0; s < stations.length - 1; s += 1) {
|
|
90
|
+
const near = stations[s];
|
|
91
|
+
const far = stations[s + 1];
|
|
92
|
+
if (near === undefined || far === undefined) continue;
|
|
93
|
+
for (let i = 0; i < RING_SEGMENTS; i += 1) {
|
|
94
|
+
const next = (i + 1) % RING_SEGMENTS;
|
|
95
|
+
const a = ringPoint(near, i);
|
|
96
|
+
const b = ringPoint(far, i);
|
|
97
|
+
const c = ringPoint(far, next);
|
|
98
|
+
const d = ringPoint(near, next);
|
|
99
|
+
push(a);
|
|
100
|
+
push(c);
|
|
101
|
+
push(b);
|
|
102
|
+
push(a);
|
|
103
|
+
push(d);
|
|
104
|
+
push(c);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const cap = (station: IHullStation, forwards: boolean): void => {
|
|
108
|
+
const centre: [number, number, number] = [0, (station.rail + station.keel) / 2, station.z];
|
|
109
|
+
for (let i = 0; i < RING_SEGMENTS; i += 1) {
|
|
110
|
+
const next = (i + 1) % RING_SEGMENTS;
|
|
111
|
+
push(centre);
|
|
112
|
+
push(ringPoint(station, forwards ? next : i));
|
|
113
|
+
push(ringPoint(station, forwards ? i : next));
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const first = stations[0];
|
|
117
|
+
const last = stations[stations.length - 1];
|
|
118
|
+
if (first !== undefined) cap(first, false);
|
|
119
|
+
if (last !== undefined) cap(last, true);
|
|
120
|
+
const geometry = new BufferGeometry();
|
|
121
|
+
geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
|
|
122
|
+
geometry.computeVertexNormals();
|
|
123
|
+
return geometry;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Bow at -Z, stern at +Z, y = 0 at the design waterline.
|
|
128
|
+
*
|
|
129
|
+
* **Freeboard is the number that matters here.** The rails used to sit 0.46 above the waterline
|
|
130
|
+
* against a 0.66 draught, which after normalising to the template's 4.6 m convention is 29 cm of
|
|
131
|
+
* hull showing and 41 cm submerged — the ship photographed as though it were sinking, decks awash,
|
|
132
|
+
* and no amount of buoyancy tuning could raise it because the hull genuinely was that shape. The
|
|
133
|
+
* rails now stand about twice the draught, which is what a caravel looks like.
|
|
134
|
+
*
|
|
135
|
+
* The waterline matters beyond looks: `Ship.ts` writes `Buoyancy3D` hull points against this
|
|
136
|
+
* origin, so moving y = 0 here silently changes how the ship floats.
|
|
137
|
+
*
|
|
138
|
+
* Read down `rail` and the sheer is visible — high at both ends, lowest in the waist. Read down
|
|
139
|
+
* `halfBeam` and so is the plan: a fine entry, full amidships, drawn in to a narrow transom.
|
|
140
|
+
*/
|
|
141
|
+
const HULL_STATIONS: readonly IHullStation[] = [
|
|
142
|
+
{ halfBeam: 0.1, keel: -0.4, rail: 1.16, tumblehome: 0.95, z: -3.2 },
|
|
143
|
+
{ halfBeam: 0.34, keel: -0.56, rail: 1.02, tumblehome: 0.88, z: -2.6 },
|
|
144
|
+
{ halfBeam: 0.66, keel: -0.66, rail: 0.89, tumblehome: 0.84, z: -1.8 },
|
|
145
|
+
{ halfBeam: 0.86, keel: -0.72, rail: 0.82, tumblehome: 0.82, z: -0.8 },
|
|
146
|
+
{ halfBeam: 0.94, keel: -0.73, rail: 0.8, tumblehome: 0.82, z: 0.2 },
|
|
147
|
+
{ halfBeam: 0.91, keel: -0.7, rail: 0.84, tumblehome: 0.83, z: 1.2 },
|
|
148
|
+
{ halfBeam: 0.78, keel: -0.61, rail: 1, tumblehome: 0.85, z: 2.1 },
|
|
149
|
+
{ halfBeam: 0.62, keel: -0.5, rail: 1.18, tumblehome: 0.9, z: 2.8 },
|
|
150
|
+
{ halfBeam: 0.5, keel: -0.36, rail: 1.24, tumblehome: 0.96, z: 3.2 },
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
/** Rail height at a station, for hanging the wale and the gunwale on the same curve. */
|
|
154
|
+
function railAt(z: number): number {
|
|
155
|
+
let previous = HULL_STATIONS[0];
|
|
156
|
+
if (previous === undefined) return 0.5;
|
|
157
|
+
for (const station of HULL_STATIONS) {
|
|
158
|
+
if (station.z >= z) {
|
|
159
|
+
const span = station.z - previous.z;
|
|
160
|
+
const t = span === 0 ? 0 : (z - previous.z) / span;
|
|
161
|
+
return MathUtils.lerp(previous.rail, station.rail, t);
|
|
162
|
+
}
|
|
163
|
+
previous = station;
|
|
164
|
+
}
|
|
165
|
+
return previous.rail;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function halfBeamAt(z: number): number {
|
|
169
|
+
let previous = HULL_STATIONS[0];
|
|
170
|
+
if (previous === undefined) return 0.5;
|
|
171
|
+
for (const station of HULL_STATIONS) {
|
|
172
|
+
if (station.z >= z) {
|
|
173
|
+
const span = station.z - previous.z;
|
|
174
|
+
const t = span === 0 ? 0 : (z - previous.z) / span;
|
|
175
|
+
return MathUtils.lerp(previous.halfBeam, station.halfBeam, t);
|
|
176
|
+
}
|
|
177
|
+
previous = station;
|
|
178
|
+
}
|
|
179
|
+
return previous.halfBeam;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* A sail with a belly in it.
|
|
184
|
+
*
|
|
185
|
+
* A `PlaneGeometry` is the wrong shape for canvas under load and it shows: flat, it catches the
|
|
186
|
+
* key light as one even value and reads as card. Bulging the grid on its own normal gives the
|
|
187
|
+
* gradient across the cloth that says "this is full of wind", and it is one `sin` per axis.
|
|
188
|
+
*/
|
|
189
|
+
function belliedSail(width: number, height: number, belly: number, taper = 1): BufferGeometry {
|
|
190
|
+
const columns = 8;
|
|
191
|
+
const rows = 6;
|
|
192
|
+
const positions: number[] = [];
|
|
193
|
+
const at = (u: number, v: number): [number, number, number] => {
|
|
194
|
+
// `taper` narrows the head, which is the difference between a square course and a lateen.
|
|
195
|
+
const spread = MathUtils.lerp(1, taper, v);
|
|
196
|
+
return [
|
|
197
|
+
(u - 0.5) * width * spread,
|
|
198
|
+
(v - 0.5) * height,
|
|
199
|
+
Math.sin(Math.PI * u) * Math.sin(Math.PI * v) * belly,
|
|
200
|
+
];
|
|
201
|
+
};
|
|
202
|
+
for (let row = 0; row < rows; row += 1) {
|
|
203
|
+
for (let column = 0; column < columns; column += 1) {
|
|
204
|
+
const u0 = column / columns;
|
|
205
|
+
const u1 = (column + 1) / columns;
|
|
206
|
+
const v0 = row / rows;
|
|
207
|
+
const v1 = (row + 1) / rows;
|
|
208
|
+
const a = at(u0, v0);
|
|
209
|
+
const b = at(u1, v0);
|
|
210
|
+
const c = at(u1, v1);
|
|
211
|
+
const d = at(u0, v1);
|
|
212
|
+
positions.push(...a, ...b, ...c, ...a, ...c, ...d);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const geometry = new BufferGeometry();
|
|
216
|
+
geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
|
|
217
|
+
geometry.computeVertexNormals();
|
|
218
|
+
return geometry;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function piece(geometry: BufferGeometry, material: Material, shadow = true): Mesh {
|
|
222
|
+
const mesh = new Mesh(geometry, material);
|
|
223
|
+
mesh.castShadow = shadow;
|
|
224
|
+
mesh.receiveShadow = shadow;
|
|
225
|
+
return mesh;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Collects rigid pieces and emits one mesh per material.
|
|
230
|
+
*
|
|
231
|
+
* A ship authored as a hundred and thirty little meshes is a hundred and thirty draw calls, and
|
|
232
|
+
* with the shadow pass that put the production-performance playtest at eight hundred against a
|
|
233
|
+
* budget of a hundred and twenty. None of the hull, rig or trim ever moves relative to the ship,
|
|
234
|
+
* so baking them costs nothing: the six materials stay separate and separately editable. Anything
|
|
235
|
+
* a game might want to animate — the sails, the pennant — is added outside this and stays its own
|
|
236
|
+
* transform.
|
|
237
|
+
*/
|
|
238
|
+
class RigidAssembly {
|
|
239
|
+
readonly #byMaterial = new Map<Material, Mesh[]>();
|
|
240
|
+
|
|
241
|
+
add(mesh: Mesh): void {
|
|
242
|
+
const bucket = this.#byMaterial.get(mesh.material as Material);
|
|
243
|
+
if (bucket === undefined) this.#byMaterial.set(mesh.material as Material, [mesh]);
|
|
244
|
+
else bucket.push(mesh);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
attachTo(root: Group): void {
|
|
248
|
+
for (const [material, meshes] of this.#byMaterial) {
|
|
249
|
+
const geometry = mergeGeometries(
|
|
250
|
+
meshes.map((mesh) => {
|
|
251
|
+
mesh.updateMatrix();
|
|
252
|
+
// `mergeGeometries` refuses a mix of indexed and non-indexed inputs, and a lofted hull is
|
|
253
|
+
// non-indexed while every Three.js primitive is indexed.
|
|
254
|
+
const placed = mesh.geometry.clone().applyMatrix4(mesh.matrix);
|
|
255
|
+
const cloned = placed.index === null ? placed : placed.toNonIndexed();
|
|
256
|
+
for (const name of Object.keys(cloned.attributes)) {
|
|
257
|
+
if (name !== "position") cloned.deleteAttribute(name);
|
|
258
|
+
}
|
|
259
|
+
return cloned;
|
|
260
|
+
}),
|
|
261
|
+
false,
|
|
262
|
+
);
|
|
263
|
+
if (geometry === null) throw new Error("mergeGeometries returned null for a ship part.");
|
|
264
|
+
geometry.computeVertexNormals();
|
|
265
|
+
const merged = new Mesh(geometry, material);
|
|
266
|
+
merged.castShadow = meshes[0]?.castShadow ?? true;
|
|
267
|
+
merged.receiveShadow = true;
|
|
268
|
+
root.add(merged);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** A mast with its yard, sail, shrouds and truck. Returns the group so a game can reach the sail. */
|
|
274
|
+
function mast(
|
|
275
|
+
materials: ISailingMaterials,
|
|
276
|
+
rigid: RigidAssembly,
|
|
277
|
+
options: {
|
|
278
|
+
readonly height: number;
|
|
279
|
+
readonly sail: BufferGeometry;
|
|
280
|
+
readonly sailY: number;
|
|
281
|
+
readonly yardWidth: number;
|
|
282
|
+
readonly yardY: number;
|
|
283
|
+
readonly z: number;
|
|
284
|
+
},
|
|
285
|
+
): Group {
|
|
286
|
+
const group = new Group();
|
|
287
|
+
const foot = railAt(options.z) - 0.1;
|
|
288
|
+
const pole = piece(new CylinderGeometry(0.035, 0.055, options.height, 7), materials.spar);
|
|
289
|
+
pole.position.set(0, foot + options.height / 2, options.z);
|
|
290
|
+
rigid.add(pole);
|
|
291
|
+
|
|
292
|
+
const yard = piece(new CylinderGeometry(0.03, 0.03, options.yardWidth, 6), materials.spar);
|
|
293
|
+
yard.rotation.z = Math.PI / 2;
|
|
294
|
+
yard.position.set(0, options.yardY, options.z);
|
|
295
|
+
rigid.add(yard);
|
|
296
|
+
|
|
297
|
+
const canvas = piece(options.sail, materials.sail, true);
|
|
298
|
+
canvas.position.set(0, options.sailY, options.z + 0.06);
|
|
299
|
+
canvas.name = "sail";
|
|
300
|
+
group.add(canvas);
|
|
301
|
+
|
|
302
|
+
// Shrouds: one line authored, placed to both rails. Without them the masts look stuck on.
|
|
303
|
+
const head = foot + options.height * 0.92;
|
|
304
|
+
for (const side of [-1, 1]) {
|
|
305
|
+
for (const aft of [-0.9, 0.9]) {
|
|
306
|
+
const anchorZ = options.z + aft;
|
|
307
|
+
const beam = halfBeamAt(anchorZ) * 0.86;
|
|
308
|
+
const anchorY = railAt(anchorZ);
|
|
309
|
+
const drop = head - anchorY;
|
|
310
|
+
const run = Math.hypot(side * beam, aft);
|
|
311
|
+
const shroud = piece(
|
|
312
|
+
new CylinderGeometry(0.009, 0.009, Math.hypot(drop, run), 4),
|
|
313
|
+
materials.cordage,
|
|
314
|
+
false,
|
|
315
|
+
);
|
|
316
|
+
shroud.position.set((side * beam) / 2, (head + anchorY) / 2, (options.z + anchorZ) / 2);
|
|
317
|
+
shroud.rotation.z = Math.atan2(side * beam, drop);
|
|
318
|
+
shroud.rotation.x = -Math.atan2(aft, drop);
|
|
319
|
+
rigid.add(shroud);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return group;
|
|
323
|
+
}
|
|
324
|
+
|
|
5
325
|
export function createShipModel(materials: ISailingMaterials): Group {
|
|
6
326
|
const ship = new Group();
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
hull
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
327
|
+
const rigid = new RigidAssembly();
|
|
328
|
+
|
|
329
|
+
// blockout: the hull itself.
|
|
330
|
+
rigid.add(piece(loftHull(HULL_STATIONS), materials.hull));
|
|
331
|
+
|
|
332
|
+
// A planked weather deck, set below the rail so the gunwale stands proud of it.
|
|
333
|
+
for (let index = 0; index < 9; index += 1) {
|
|
334
|
+
const z = MathUtils.lerp(-2.5, 2.6, index / 8);
|
|
335
|
+
const plank = piece(new BoxGeometry(halfBeamAt(z) * 1.62, 0.05, 0.56), materials.deck);
|
|
336
|
+
plank.position.set(0, railAt(z) + 0.02, z);
|
|
337
|
+
rigid.add(plank);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Gunwale and wale strakes, both following the sheer. Two curves, twelve boxes, and the hull
|
|
341
|
+
// stops being a smooth blob.
|
|
342
|
+
for (let index = 0; index < 24; index += 1) {
|
|
343
|
+
const z = MathUtils.lerp(-2.9, 3.1, index / 23);
|
|
344
|
+
const beam = halfBeamAt(z);
|
|
345
|
+
for (const side of [-1, 1]) {
|
|
346
|
+
const rail = piece(new BoxGeometry(0.07, 0.12, 0.3), materials.trim);
|
|
347
|
+
rail.position.set(side * beam * 0.9, railAt(z) + 0.05, z);
|
|
348
|
+
rigid.add(rail);
|
|
349
|
+
const wale = piece(new BoxGeometry(0.055, 0.08, 0.3), materials.trim);
|
|
350
|
+
wale.position.set(side * beam * 1.0, railAt(z) - 0.34, z);
|
|
351
|
+
rigid.add(wale);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Sterncastle: a raised deck aft, and the things that stand on it.
|
|
356
|
+
//
|
|
357
|
+
// It used to be a box, a deck plate and two rails — an empty tray at the back of the ship, which
|
|
358
|
+
// is the one part of a caravel the chase camera looks straight into. A quarterdeck carries a
|
|
359
|
+
// lantern, a binnacle, a helm, a companionway and stowage, and each of those is three boxes.
|
|
360
|
+
const castle = piece(new BoxGeometry(1.12, 0.78, 1.7), materials.hull);
|
|
361
|
+
castle.position.set(0, 1.32, 2.4);
|
|
362
|
+
rigid.add(castle);
|
|
363
|
+
const castleDeck = piece(new BoxGeometry(1.2, 0.08, 1.78), materials.deck);
|
|
364
|
+
castleDeck.position.set(0, 1.75, 2.4);
|
|
365
|
+
rigid.add(castleDeck);
|
|
366
|
+
|
|
367
|
+
// A balustered rail around the quarterdeck rather than two slabs: the gaps are the read.
|
|
368
|
+
for (const [x, z, along] of [
|
|
369
|
+
[-0.58, 2.4, true],
|
|
370
|
+
[0.58, 2.4, true],
|
|
371
|
+
[0, 3.24, false],
|
|
372
|
+
] as const) {
|
|
373
|
+
const cap = piece(
|
|
374
|
+
along ? new BoxGeometry(0.08, 0.08, 1.78) : new BoxGeometry(1.24, 0.08, 0.08),
|
|
375
|
+
materials.trim,
|
|
376
|
+
);
|
|
377
|
+
cap.position.set(x, 2.12, z);
|
|
378
|
+
rigid.add(cap);
|
|
379
|
+
const count = along ? 7 : 5;
|
|
380
|
+
for (let index = 0; index < count; index += 1) {
|
|
381
|
+
const t = index / (count - 1);
|
|
382
|
+
const baluster = piece(new BoxGeometry(0.06, 0.3, 0.06), materials.trim);
|
|
383
|
+
baluster.position.set(
|
|
384
|
+
along ? x : MathUtils.lerp(-0.56, 0.56, t),
|
|
385
|
+
1.94,
|
|
386
|
+
along ? MathUtils.lerp(1.56, 3.24, t) : z,
|
|
387
|
+
);
|
|
388
|
+
rigid.add(baluster);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Quarter windows in the transom, and a wale across it.
|
|
393
|
+
for (const x of [-0.34, 0, 0.34]) {
|
|
394
|
+
const window = piece(new BoxGeometry(0.24, 0.28, 0.06), materials.trim);
|
|
395
|
+
window.position.set(x, 1.36, 3.28);
|
|
396
|
+
rigid.add(window);
|
|
397
|
+
}
|
|
398
|
+
const transomWale = piece(new BoxGeometry(1.18, 0.09, 0.07), materials.trim);
|
|
399
|
+
transomWale.position.set(0, 1.66, 3.28);
|
|
400
|
+
rigid.add(transomWale);
|
|
401
|
+
|
|
402
|
+
// The stern lantern on the taffrail — the single most recognisable thing on the back of a ship.
|
|
403
|
+
const lanternPost = piece(new CylinderGeometry(0.035, 0.045, 0.34, 6), materials.spar);
|
|
404
|
+
lanternPost.position.set(0, 2.28, 3.2);
|
|
405
|
+
rigid.add(lanternPost);
|
|
406
|
+
const lantern = piece(new CylinderGeometry(0.11, 0.14, 0.24, 6), materials.trim);
|
|
407
|
+
lantern.position.set(0, 2.56, 3.2);
|
|
408
|
+
rigid.add(lantern);
|
|
409
|
+
const lanternCap = piece(new ConeGeometry(0.16, 0.14, 6), materials.trim);
|
|
410
|
+
lanternCap.position.set(0, 2.74, 3.2);
|
|
411
|
+
rigid.add(lanternCap);
|
|
412
|
+
|
|
413
|
+
// Binnacle and whipstaff, where the helmsman stands.
|
|
414
|
+
const binnacle = piece(new BoxGeometry(0.3, 0.34, 0.26), materials.deck);
|
|
415
|
+
binnacle.position.set(0, 1.96, 2.62);
|
|
416
|
+
rigid.add(binnacle);
|
|
417
|
+
const whipstaff = piece(new CylinderGeometry(0.035, 0.045, 0.8, 6), materials.spar);
|
|
418
|
+
whipstaff.rotation.x = -0.22;
|
|
419
|
+
whipstaff.position.set(0, 2.14, 2.16);
|
|
420
|
+
rigid.add(whipstaff);
|
|
421
|
+
|
|
422
|
+
// A companionway down off the quarterdeck, and stowage in the waist.
|
|
423
|
+
const companion = piece(new BoxGeometry(0.5, 0.26, 0.36), materials.deck);
|
|
424
|
+
companion.position.set(0, 1.9, 1.68);
|
|
425
|
+
rigid.add(companion);
|
|
426
|
+
const companionRoof = piece(new BoxGeometry(0.56, 0.06, 0.42), materials.trim);
|
|
427
|
+
companionRoof.position.set(0, 2.05, 1.68);
|
|
428
|
+
rigid.add(companionRoof);
|
|
429
|
+
const hatch = piece(new BoxGeometry(0.56, 0.1, 0.6), materials.deck);
|
|
430
|
+
hatch.position.set(0, railAt(-0.6) + 0.06, -0.6);
|
|
431
|
+
rigid.add(hatch);
|
|
432
|
+
const hatchRim = piece(new BoxGeometry(0.64, 0.06, 0.68), materials.trim);
|
|
433
|
+
hatchRim.position.set(0, railAt(-0.6) + 0.13, -0.6);
|
|
434
|
+
rigid.add(hatchRim);
|
|
435
|
+
for (const [x, z] of [
|
|
436
|
+
[-0.42, 0.9],
|
|
437
|
+
[0.42, 0.86],
|
|
438
|
+
[-0.36, -1.3],
|
|
439
|
+
] as const) {
|
|
440
|
+
const barrel = piece(new CylinderGeometry(0.17, 0.15, 0.36, 8), materials.spar);
|
|
441
|
+
barrel.position.set(x, railAt(z) + 0.2, z);
|
|
442
|
+
rigid.add(barrel);
|
|
443
|
+
const band = piece(new CylinderGeometry(0.18, 0.18, 0.05, 8), materials.trim);
|
|
444
|
+
band.position.set(x, railAt(z) + 0.2, z);
|
|
445
|
+
rigid.add(band);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const beak = piece(new ConeGeometry(0.2, 0.9, 6), materials.hull);
|
|
449
|
+
beak.rotation.x = -Math.PI / 2;
|
|
450
|
+
beak.position.set(0, 0.42, -3.5);
|
|
451
|
+
rigid.add(beak);
|
|
452
|
+
|
|
453
|
+
// Bowsprit, raked up over the beakhead.
|
|
454
|
+
const bowsprit = piece(new CylinderGeometry(0.03, 0.05, 2.1, 6), materials.spar);
|
|
455
|
+
bowsprit.rotation.x = Math.PI / 2 - 0.38;
|
|
456
|
+
bowsprit.position.set(0, 1.36, -3.5);
|
|
457
|
+
rigid.add(bowsprit);
|
|
458
|
+
|
|
459
|
+
// Rudder and tiller, hung on the transom.
|
|
460
|
+
const rudder = piece(new BoxGeometry(0.08, 1.02, 0.3), materials.hull);
|
|
461
|
+
rudder.position.set(0, -0.02, 3.26);
|
|
462
|
+
rigid.add(rudder);
|
|
463
|
+
const tiller = piece(new CylinderGeometry(0.025, 0.025, 0.7, 5), materials.spar);
|
|
464
|
+
tiller.rotation.x = Math.PI / 2 - 0.25;
|
|
465
|
+
tiller.position.set(0, 2.0, 2.72);
|
|
466
|
+
rigid.add(tiller);
|
|
467
|
+
|
|
468
|
+
// The rig: two square courses of falling size and a raked lateen on the mizzen.
|
|
469
|
+
ship.add(
|
|
470
|
+
mast(materials, rigid, {
|
|
471
|
+
height: 3.2,
|
|
472
|
+
sail: belliedSail(1.5, 1.35, 0.4),
|
|
473
|
+
sailY: 2.8,
|
|
474
|
+
yardWidth: 1.7,
|
|
475
|
+
yardY: 3.5,
|
|
476
|
+
z: -1.55,
|
|
477
|
+
}),
|
|
478
|
+
);
|
|
479
|
+
ship.add(
|
|
480
|
+
mast(materials, rigid, {
|
|
481
|
+
height: 4.3,
|
|
482
|
+
sail: belliedSail(1.85, 1.8, 0.5),
|
|
483
|
+
sailY: 3.4,
|
|
484
|
+
yardWidth: 2.1,
|
|
485
|
+
yardY: 4.33,
|
|
486
|
+
z: 0.1,
|
|
487
|
+
}),
|
|
488
|
+
);
|
|
489
|
+
|
|
490
|
+
// Crow's nest on the main.
|
|
491
|
+
const nest = piece(new CylinderGeometry(0.26, 0.2, 0.24, 9), materials.deck);
|
|
492
|
+
nest.position.set(0, 4.51, 0.1);
|
|
493
|
+
rigid.add(nest);
|
|
494
|
+
|
|
495
|
+
// Mizzen: a lateen yard raked steeply, with a triangular sail hung from it.
|
|
496
|
+
const mizzen = piece(new CylinderGeometry(0.03, 0.045, 2.4, 6), materials.spar);
|
|
497
|
+
mizzen.position.set(0, 2.45, 1.9);
|
|
498
|
+
rigid.add(mizzen);
|
|
499
|
+
const lateenYard = piece(new CylinderGeometry(0.025, 0.025, 3.1, 5), materials.spar);
|
|
500
|
+
lateenYard.rotation.x = 0.85;
|
|
501
|
+
lateenYard.position.set(0, 3.05, 1.9);
|
|
502
|
+
rigid.add(lateenYard);
|
|
503
|
+
const lateen = piece(belliedSail(1.15, 2.3, 0.3, 0.12), materials.sail);
|
|
504
|
+
lateen.rotation.x = 0.85;
|
|
505
|
+
lateen.rotation.y = Math.PI / 2;
|
|
506
|
+
lateen.position.set(0.1, 2.95, 1.95);
|
|
507
|
+
lateen.name = "lateen";
|
|
508
|
+
ship.add(lateen);
|
|
509
|
+
|
|
510
|
+
// Pennant at the main truck: the one part of the silhouette that is meant to be seen moving.
|
|
511
|
+
const pennant = piece(belliedSail(0.62, 0.2, 0.05, 0.25), materials.trim, false);
|
|
512
|
+
pennant.position.set(0.34, 4.95, 0.1);
|
|
513
|
+
pennant.name = "pennant";
|
|
514
|
+
ship.add(pennant);
|
|
515
|
+
|
|
516
|
+
rigid.attachTo(ship);
|
|
27
517
|
return ship;
|
|
28
518
|
}
|
|
29
519
|
|
|
520
|
+
/** A course marker: a float with a banded topmark and a small flag. */
|
|
30
521
|
export function createBuoy(materials: ISailingMaterials): Group {
|
|
31
522
|
const buoy = new Group();
|
|
32
|
-
const
|
|
33
|
-
body
|
|
523
|
+
const rigid = new RigidAssembly();
|
|
524
|
+
const body = new Mesh(new CylinderGeometry(0.2, 0.26, 0.66, 10), materials.buoy);
|
|
525
|
+
body.position.y = 0.16;
|
|
34
526
|
body.castShadow = true;
|
|
35
|
-
const
|
|
36
|
-
|
|
527
|
+
const band = new Mesh(new CylinderGeometry(0.22, 0.22, 0.13, 10), materials.trim);
|
|
528
|
+
band.position.y = 0.28;
|
|
529
|
+
band.castShadow = true;
|
|
530
|
+
const cap = new Mesh(new SphereGeometry(0.23, 10, 7), materials.buoy);
|
|
531
|
+
cap.position.y = 0.51;
|
|
37
532
|
cap.scale.y = 0.6;
|
|
38
533
|
cap.castShadow = true;
|
|
39
|
-
const
|
|
40
|
-
|
|
534
|
+
const pole = new Mesh(new CylinderGeometry(0.025, 0.025, 0.7, 5), materials.spar);
|
|
535
|
+
pole.position.y = 0.85;
|
|
536
|
+
const flag = new Mesh(belliedSail(0.4, 0.24, 0.05, 0.4), materials.trim);
|
|
41
537
|
flag.rotation.y = Math.PI / 2;
|
|
42
|
-
|
|
538
|
+
flag.position.set(0, 1.04, 0.17);
|
|
539
|
+
for (const part of [body, band, cap, pole, flag]) rigid.add(part);
|
|
540
|
+
rigid.attachTo(buoy);
|
|
43
541
|
return buoy;
|
|
44
542
|
}
|
|
45
543
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
544
|
+
/**
|
|
545
|
+
* A headland: a beach shelf, a rock mass and a stand of palms.
|
|
546
|
+
*
|
|
547
|
+
* The island this replaces sat at y = -0.88 with a height of 1.5, so its crown was thirteen
|
|
548
|
+
* centimetres *below* the waterline and the frame contained no land at all. The sea needs
|
|
549
|
+
* something with a horizon behind it or there is no sense of a passage being sailed.
|
|
550
|
+
*/
|
|
551
|
+
export function createIsland(materials: ISailingMaterials): Group {
|
|
552
|
+
const island = new Group();
|
|
553
|
+
const rigid = new RigidAssembly();
|
|
554
|
+
const beach = new Mesh(new CylinderGeometry(9.5, 11.5, 1.6, 22), materials.sand);
|
|
555
|
+
beach.position.y = -0.4;
|
|
556
|
+
beach.scale.z = 0.72;
|
|
557
|
+
beach.receiveShadow = true;
|
|
558
|
+
rigid.add(beach);
|
|
559
|
+
|
|
560
|
+
const headland = new Mesh(new SphereGeometry(4.6, 14, 9), materials.island);
|
|
561
|
+
headland.position.set(-1.4, 0.1, -1.2);
|
|
562
|
+
headland.scale.set(1, 0.62, 0.78);
|
|
563
|
+
headland.castShadow = true;
|
|
564
|
+
headland.receiveShadow = true;
|
|
565
|
+
rigid.add(headland);
|
|
566
|
+
const knoll = new Mesh(new SphereGeometry(2.7, 12, 8), materials.island);
|
|
567
|
+
knoll.position.set(3.4, 0.1, 1.1);
|
|
568
|
+
knoll.scale.set(1, 0.5, 0.85);
|
|
569
|
+
knoll.castShadow = true;
|
|
570
|
+
rigid.add(knoll);
|
|
571
|
+
|
|
572
|
+
// A stand of palms, placed by a seeded jitter so two captures frame the same headland.
|
|
573
|
+
let seed = 41;
|
|
574
|
+
const jitter = (): number => {
|
|
575
|
+
seed = (seed * 1103515245 + 12345) & 0x7fffffff;
|
|
576
|
+
return seed / 0x7fffffff;
|
|
577
|
+
};
|
|
578
|
+
for (let index = 0; index < 7; index += 1) {
|
|
579
|
+
const angle = (index / 7) * Math.PI * 2 + jitter();
|
|
580
|
+
const radius = 3 + jitter() * 3.5;
|
|
581
|
+
const height = 1.9 + jitter() * 1.1;
|
|
582
|
+
const trunk = new Mesh(new CylinderGeometry(0.09, 0.15, height, 5), materials.spar);
|
|
583
|
+
trunk.position.set(Math.cos(angle) * radius, 0.9 + height / 2, Math.sin(angle) * radius * 0.7);
|
|
584
|
+
trunk.rotation.z = (jitter() - 0.5) * 0.24;
|
|
585
|
+
trunk.castShadow = true;
|
|
586
|
+
rigid.add(trunk);
|
|
587
|
+
for (let frond = 0; frond < 5; frond += 1) {
|
|
588
|
+
const blade = new Mesh(new ConeGeometry(0.24, 1.5, 4), materials.foliage);
|
|
589
|
+
blade.position.copy(trunk.position);
|
|
590
|
+
blade.position.y += height / 2 + 0.1;
|
|
591
|
+
blade.rotation.z = Math.PI / 2 - 0.5;
|
|
592
|
+
blade.rotation.y = (frond / 5) * Math.PI * 2;
|
|
593
|
+
blade.translateY(0.6);
|
|
594
|
+
blade.castShadow = true;
|
|
595
|
+
rigid.add(blade);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
rigid.attachTo(island);
|
|
600
|
+
island.position.set(-13, 0, -17);
|
|
51
601
|
return island;
|
|
52
602
|
}
|