create-threenative 0.2.0
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 +16 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +283 -0
- package/dist/threenative.d.ts +6 -0
- package/dist/threenative.js +757 -0
- package/package.json +44 -0
- package/templates/action-rpg/.mcp.json +16 -0
- package/templates/action-rpg/AGENTS.md +40 -0
- package/templates/action-rpg/CLAUDE.md +42 -0
- package/templates/action-rpg/index.html +13 -0
- package/templates/action-rpg/kit.json +7 -0
- package/templates/action-rpg/package.json +47 -0
- package/templates/action-rpg/playtests/combat.playtest.json +61 -0
- package/templates/action-rpg/playtests/fail.playtest.json +21 -0
- package/templates/action-rpg/playtests/inventory.playtest.json +111 -0
- package/templates/action-rpg/playtests/progress.playtest.json +99 -0
- package/templates/action-rpg/playtests/survives.playtest.json +32 -0
- package/templates/action-rpg/playtests/win.playtest.json +30 -0
- package/templates/action-rpg/public/favicon.svg +5 -0
- package/templates/action-rpg/src/abilities/Ability.ts +45 -0
- package/templates/action-rpg/src/entities/Enemy.ts +143 -0
- package/templates/action-rpg/src/entities/Player.ts +83 -0
- package/templates/action-rpg/src/game.ts +40 -0
- package/templates/action-rpg/src/items/Inventory.ts +163 -0
- package/templates/action-rpg/src/loot/drops.ts +40 -0
- package/templates/action-rpg/src/main.ts +15 -0
- package/templates/action-rpg/src/physics.ts +40 -0
- package/templates/action-rpg/src/playtest-events.ts +15 -0
- package/templates/action-rpg/src/progress.ts +35 -0
- package/templates/action-rpg/src/render/camera.ts +26 -0
- package/templates/action-rpg/src/render/lighting.ts +30 -0
- package/templates/action-rpg/src/render/loading.ts +90 -0
- package/templates/action-rpg/src/render/materials.ts +40 -0
- package/templates/action-rpg/src/render/palette.ts +9 -0
- package/templates/action-rpg/src/render/postprocessing.ts +18 -0
- package/templates/action-rpg/src/render/shapes.ts +110 -0
- package/templates/action-rpg/src/render/sky.ts +18 -0
- package/templates/action-rpg/src/render/types.ts +3 -0
- package/templates/action-rpg/src/scenes/Boot.ts +12 -0
- package/templates/action-rpg/src/scenes/Play.ts +449 -0
- package/templates/action-rpg/src/state.ts +40 -0
- package/templates/action-rpg/src/stats/StatBlock.ts +57 -0
- package/templates/action-rpg/src/style.css +32 -0
- package/templates/action-rpg/src/ui/AbilityBar.tsx +28 -0
- package/templates/action-rpg/src/ui/App.tsx +21 -0
- package/templates/action-rpg/src/ui/CharacterPanel.tsx +31 -0
- package/templates/action-rpg/src/ui/Hud.tsx +29 -0
- package/templates/action-rpg/src/ui/InventoryPanel.tsx +37 -0
- package/templates/action-rpg/tailwind.config.ts +7 -0
- package/templates/action-rpg/threenative.config.ts +29 -0
- package/templates/action-rpg/tsconfig.json +17 -0
- package/templates/action-rpg/vite.config.ts +8 -0
- package/templates/defense/.mcp.json +16 -0
- package/templates/defense/AGENTS.md +53 -0
- package/templates/defense/CLAUDE.md +55 -0
- package/templates/defense/README.md +9 -0
- package/templates/defense/index.html +13 -0
- package/templates/defense/kit.json +7 -0
- package/templates/defense/package.json +46 -0
- package/templates/defense/playtests/leak.playtest.json +18 -0
- package/templates/defense/playtests/placement.playtest.json +40 -0
- package/templates/defense/playtests/scan.playtest.json +20 -0
- package/templates/defense/playtests/survive.playtest.json +26 -0
- package/templates/defense/playtests/survives.playtest.json +36 -0
- package/templates/defense/public/favicon.svg +5 -0
- package/templates/defense/src/attackers/Attacker.ts +104 -0
- package/templates/defense/src/board/Route.ts +80 -0
- package/templates/defense/src/economy.ts +36 -0
- package/templates/defense/src/entities/Player.ts +44 -0
- package/templates/defense/src/game.ts +30 -0
- package/templates/defense/src/main.ts +15 -0
- package/templates/defense/src/physics.ts +43 -0
- package/templates/defense/src/placement/Buildable.ts +49 -0
- package/templates/defense/src/playtest-events.ts +15 -0
- package/templates/defense/src/render/camera.ts +10 -0
- package/templates/defense/src/render/lighting.ts +32 -0
- package/templates/defense/src/render/loading.ts +89 -0
- package/templates/defense/src/render/materials.ts +13 -0
- package/templates/defense/src/render/palette.ts +21 -0
- package/templates/defense/src/render/postprocessing.ts +14 -0
- package/templates/defense/src/render/shapes.ts +89 -0
- package/templates/defense/src/render/sky.ts +45 -0
- package/templates/defense/src/scenes/Boot.ts +12 -0
- package/templates/defense/src/scenes/Defense.ts +165 -0
- package/templates/defense/src/state.ts +50 -0
- package/templates/defense/src/style.css +32 -0
- package/templates/defense/src/towers/Tower.ts +96 -0
- package/templates/defense/src/towers/targeting.ts +53 -0
- package/templates/defense/src/ui/App.tsx +17 -0
- package/templates/defense/src/ui/Hud.tsx +61 -0
- package/templates/defense/src/ui/Menu.tsx +7 -0
- package/templates/defense/src/waves.ts +40 -0
- package/templates/defense/tailwind.config.ts +1 -0
- package/templates/defense/threenative.config.ts +29 -0
- package/templates/defense/tsconfig.json +17 -0
- package/templates/defense/vite.config.ts +5 -0
- package/templates/minimal/.mcp.json +16 -0
- package/templates/minimal/AGENTS.md +400 -0
- package/templates/minimal/CLAUDE.md +402 -0
- package/templates/minimal/assets/.gitkeep +0 -0
- package/templates/minimal/index.html +14 -0
- package/templates/minimal/kit.json +7 -0
- package/templates/minimal/package.json +40 -0
- package/templates/minimal/playtests/play.playtest.json +32 -0
- package/templates/minimal/playtests/survives.playtest.json +32 -0
- package/templates/minimal/public/.gitkeep +0 -0
- package/templates/minimal/public/favicon.svg +4 -0
- package/templates/minimal/public/icon.png +0 -0
- package/templates/minimal/src/entities/Player.ts +66 -0
- package/templates/minimal/src/game.ts +28 -0
- package/templates/minimal/src/main.ts +17 -0
- package/templates/minimal/src/render/camera.ts +11 -0
- package/templates/minimal/src/render/hud.ts +53 -0
- package/templates/minimal/src/render/lighting.ts +46 -0
- package/templates/minimal/src/render/loading.ts +113 -0
- package/templates/minimal/src/render/materials.ts +16 -0
- package/templates/minimal/src/render/palette.ts +9 -0
- package/templates/minimal/src/render/postprocessing.ts +20 -0
- package/templates/minimal/src/render/sky.ts +41 -0
- package/templates/minimal/src/scenes/Boot.ts +5 -0
- package/templates/minimal/src/scenes/Play.ts +65 -0
- package/templates/minimal/src/state.ts +1 -0
- package/templates/minimal/src/style.css +41 -0
- package/templates/minimal/threenative.config.ts +32 -0
- package/templates/minimal/tsconfig.json +16 -0
- package/templates/minimal/vite.config.ts +3 -0
- package/templates/platformer/.mcp.json +16 -0
- package/templates/platformer/AGENTS.md +199 -0
- package/templates/platformer/CLAUDE.md +201 -0
- package/templates/platformer/assets/.gitkeep +0 -0
- package/templates/platformer/index.html +13 -0
- package/templates/platformer/kit.json +7 -0
- package/templates/platformer/package.json +50 -0
- package/templates/platformer/playtests/avoidance.playtest.json +23 -0
- package/templates/platformer/playtests/buffer.playtest.json +17 -0
- package/templates/platformer/playtests/chase.playtest.json +21 -0
- package/templates/platformer/playtests/collect.playtest.json +56 -0
- package/templates/platformer/playtests/collision-layers.playtest.json +36 -0
- package/templates/platformer/playtests/coyote.playtest.json +21 -0
- package/templates/platformer/playtests/damage.playtest.json +31 -0
- package/templates/platformer/playtests/dash.playtest.json +21 -0
- package/templates/platformer/playtests/jump.playtest.json +21 -0
- package/templates/platformer/playtests/oneway.playtest.json +17 -0
- package/templates/platformer/playtests/patrol.playtest.json +13 -0
- package/templates/platformer/playtests/performance.playtest.json +21 -0
- package/templates/platformer/playtests/physics.playtest.json +14 -0
- package/templates/platformer/playtests/respawn.playtest.json +31 -0
- package/templates/platformer/playtests/stomp-rise.playtest.json +41 -0
- package/templates/platformer/playtests/stomp.playtest.json +34 -0
- package/templates/platformer/playtests/survives.playtest.json +32 -0
- package/templates/platformer/playtests/terminal-loop-fail.playtest.json +29 -0
- package/templates/platformer/playtests/terminal-loop-win.playtest.json +52 -0
- package/templates/platformer/public/.gitkeep +0 -0
- package/templates/platformer/public/favicon.svg +4 -0
- package/templates/platformer/public/icon.png +0 -0
- package/templates/platformer/src/entities/Character.ts +218 -0
- package/templates/platformer/src/entities/Chaser.ts +118 -0
- package/templates/platformer/src/entities/Patrol.ts +88 -0
- package/templates/platformer/src/entities/Pickup.ts +72 -0
- package/templates/platformer/src/game.ts +27 -0
- package/templates/platformer/src/level/Checkpoints.ts +66 -0
- package/templates/platformer/src/level/Platform.ts +34 -0
- package/templates/platformer/src/main.ts +14 -0
- package/templates/platformer/src/playtest-events.ts +15 -0
- package/templates/platformer/src/render/camera.ts +8 -0
- package/templates/platformer/src/render/lighting.ts +38 -0
- package/templates/platformer/src/render/loading.ts +113 -0
- package/templates/platformer/src/render/materials.ts +11 -0
- package/templates/platformer/src/render/palette.ts +54 -0
- package/templates/platformer/src/render/postprocessing.ts +18 -0
- package/templates/platformer/src/render/rig.ts +60 -0
- package/templates/platformer/src/render/sky.ts +47 -0
- package/templates/platformer/src/render/terrain.ts +31 -0
- package/templates/platformer/src/render/touch-controls.ts +157 -0
- package/templates/platformer/src/render/touch-layout.ts +63 -0
- package/templates/platformer/src/scenes/Boot.ts +12 -0
- package/templates/platformer/src/scenes/Level.ts +176 -0
- package/templates/platformer/src/state.ts +23 -0
- package/templates/platformer/src/style.css +31 -0
- package/templates/platformer/src/ui/App.tsx +17 -0
- package/templates/platformer/src/ui/Hud.tsx +41 -0
- package/templates/platformer/src/ui/Menu.tsx +7 -0
- package/templates/platformer/tailwind.config.ts +2 -0
- package/templates/platformer/threenative.config.ts +32 -0
- package/templates/platformer/tsconfig.json +17 -0
- package/templates/platformer/vite.config.ts +5 -0
- package/templates/racing/.mcp.json +16 -0
- package/templates/racing/AGENTS.md +48 -0
- package/templates/racing/CLAUDE.md +50 -0
- package/templates/racing/index.html +13 -0
- package/templates/racing/kit.json +7 -0
- package/templates/racing/package.json +46 -0
- package/templates/racing/playtests/boost.playtest.json +45 -0
- package/templates/racing/playtests/outcome.playtest.json +78 -0
- package/templates/racing/playtests/ranking.playtest.json +37 -0
- package/templates/racing/playtests/rescue.playtest.json +28 -0
- package/templates/racing/playtests/reverse.playtest.json +37 -0
- package/templates/racing/playtests/shortcut.playtest.json +44 -0
- package/templates/racing/playtests/survives.playtest.json +32 -0
- package/templates/racing/public/favicon.svg +6 -0
- package/templates/racing/src/entities/RacingCar.ts +114 -0
- package/templates/racing/src/entities/Rival.ts +46 -0
- package/templates/racing/src/game.ts +29 -0
- package/templates/racing/src/kart/boost.ts +38 -0
- package/templates/racing/src/main.ts +15 -0
- package/templates/racing/src/playtest-events.ts +15 -0
- package/templates/racing/src/render/camera.ts +28 -0
- package/templates/racing/src/render/lighting.ts +32 -0
- package/templates/racing/src/render/loading.ts +58 -0
- package/templates/racing/src/render/materials.ts +15 -0
- package/templates/racing/src/render/palette.ts +30 -0
- package/templates/racing/src/render/postprocessing.ts +14 -0
- package/templates/racing/src/render/shapes.ts +37 -0
- package/templates/racing/src/render/sky.ts +45 -0
- package/templates/racing/src/scenes/Boot.ts +12 -0
- package/templates/racing/src/scenes/Race.ts +180 -0
- package/templates/racing/src/state.ts +35 -0
- package/templates/racing/src/style.css +32 -0
- package/templates/racing/src/track/Checkline.ts +19 -0
- package/templates/racing/src/track/Lap.ts +104 -0
- package/templates/racing/src/track/Ranking.ts +35 -0
- package/templates/racing/src/track/Track.ts +229 -0
- package/templates/racing/src/track/TrackSector.ts +77 -0
- package/templates/racing/src/track/rescue.ts +21 -0
- package/templates/racing/src/ui/App.tsx +17 -0
- package/templates/racing/src/ui/Hud.tsx +71 -0
- package/templates/racing/src/ui/Menu.tsx +7 -0
- package/templates/racing/tailwind.config.ts +2 -0
- package/templates/racing/threenative.config.ts +29 -0
- package/templates/racing/tsconfig.json +17 -0
- package/templates/racing/vite.config.ts +5 -0
- package/templates/shooter/.mcp.json +16 -0
- package/templates/shooter/AGENTS.md +69 -0
- package/templates/shooter/CLAUDE.md +71 -0
- package/templates/shooter/index.html +13 -0
- package/templates/shooter/kit.json +7 -0
- package/templates/shooter/package.json +46 -0
- package/templates/shooter/playtests/fail.playtest.json +30 -0
- package/templates/shooter/playtests/shooter.playtest.json +89 -0
- package/templates/shooter/playtests/survives.playtest.json +32 -0
- package/templates/shooter/public/favicon.svg +4 -0
- package/templates/shooter/src/combat/damage.ts +41 -0
- package/templates/shooter/src/entities/Pickup.ts +70 -0
- package/templates/shooter/src/entities/Player.ts +93 -0
- package/templates/shooter/src/entities/Target.ts +103 -0
- package/templates/shooter/src/game.ts +36 -0
- package/templates/shooter/src/level/SpawnPoints.ts +28 -0
- package/templates/shooter/src/main.ts +26 -0
- package/templates/shooter/src/physics.ts +49 -0
- package/templates/shooter/src/playtest-events.ts +15 -0
- package/templates/shooter/src/render/camera.ts +29 -0
- package/templates/shooter/src/render/lighting.ts +38 -0
- package/templates/shooter/src/render/loading.ts +86 -0
- package/templates/shooter/src/render/materials.ts +38 -0
- package/templates/shooter/src/render/palette.ts +9 -0
- package/templates/shooter/src/render/postprocessing.ts +19 -0
- package/templates/shooter/src/render/shapes.ts +194 -0
- package/templates/shooter/src/render/sky.ts +37 -0
- package/templates/shooter/src/render/types.ts +3 -0
- package/templates/shooter/src/render/ui.css +212 -0
- package/templates/shooter/src/render/ui.ts +59 -0
- package/templates/shooter/src/scenes/Boot.ts +12 -0
- package/templates/shooter/src/scenes/Play.ts +428 -0
- package/templates/shooter/src/state.ts +29 -0
- package/templates/shooter/src/ui/App.tsx +25 -0
- package/templates/shooter/src/ui/Hud.tsx +49 -0
- package/templates/shooter/src/ui/Menu.tsx +26 -0
- package/templates/shooter/src/waves.ts +50 -0
- package/templates/shooter/src/weapons/Hitscan.ts +43 -0
- package/templates/shooter/src/weapons/Projectile.ts +76 -0
- package/templates/shooter/tailwind.config.ts +5 -0
- package/templates/shooter/threenative.config.ts +29 -0
- package/templates/shooter/tsconfig.json +17 -0
- package/templates/shooter/vite.config.ts +8 -0
- package/templates/starter/.mcp.json +16 -0
- package/templates/starter/AGENTS.md +450 -0
- package/templates/starter/CLAUDE.md +452 -0
- package/templates/starter/assets/.gitkeep +0 -0
- package/templates/starter/index.html +13 -0
- package/templates/starter/kit.json +7 -0
- package/templates/starter/package.json +49 -0
- package/templates/starter/playtests/buffer.playtest.json +29 -0
- package/templates/starter/playtests/coyote.playtest.json +35 -0
- package/templates/starter/playtests/forward.playtest.json +15 -0
- package/templates/starter/playtests/hot-reload.playtest.json +28 -0
- package/templates/starter/playtests/look.playtest.json +43 -0
- package/templates/starter/playtests/monitoring.playtest.json +41 -0
- package/templates/starter/playtests/pause.playtest.json +33 -0
- package/templates/starter/playtests/play.playtest.json +16 -0
- package/templates/starter/playtests/respawn.playtest.json +28 -0
- package/templates/starter/playtests/restart.playtest.json +36 -0
- package/templates/starter/playtests/seed.playtest.json +18 -0
- package/templates/starter/playtests/survives.playtest.json +32 -0
- package/templates/starter/public/.gitkeep +0 -0
- package/templates/starter/public/favicon.svg +4 -0
- package/templates/starter/public/icon.png +0 -0
- package/templates/starter/public/native-proof.glb +0 -0
- package/templates/starter/public/native-proof.png +0 -0
- package/templates/starter/public/pickup.ogg +0 -0
- package/templates/starter/src/entities/Crate.ts +34 -0
- package/templates/starter/src/entities/Player.ts +80 -0
- package/templates/starter/src/game.ts +30 -0
- package/templates/starter/src/main.ts +15 -0
- package/templates/starter/src/render/camera.ts +57 -0
- package/templates/starter/src/render/lighting.ts +55 -0
- package/templates/starter/src/render/materials.ts +12 -0
- package/templates/starter/src/render/palette.ts +9 -0
- package/templates/starter/src/render/postprocessing.ts +18 -0
- package/templates/starter/src/render/shapes.ts +147 -0
- package/templates/starter/src/render/sky.ts +56 -0
- package/templates/starter/src/scenes/Play.ts +161 -0
- package/templates/starter/src/state.ts +10 -0
- package/templates/starter/src/style.css +45 -0
- package/templates/starter/src/ui/App.tsx +19 -0
- package/templates/starter/src/ui/Hud.tsx +37 -0
- package/templates/starter/src/ui/Menu.tsx +43 -0
- package/templates/starter/tailwind.config.ts +2 -0
- package/templates/starter/threenative.config.ts +31 -0
- package/templates/starter/tsconfig.json +17 -0
- package/templates/starter/vite.config.ts +8 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Generated for you. All arena silhouettes and gameplay visuals start here.
|
|
2
|
+
import {
|
|
3
|
+
BufferAttribute,
|
|
4
|
+
BufferGeometry,
|
|
5
|
+
CylinderGeometry,
|
|
6
|
+
Group,
|
|
7
|
+
type Material,
|
|
8
|
+
Mesh,
|
|
9
|
+
SphereGeometry,
|
|
10
|
+
} from "three";
|
|
11
|
+
|
|
12
|
+
import type { ReturnTypeOfMaterials } from "./types.js";
|
|
13
|
+
|
|
14
|
+
const roundedCache = new Map<string, BufferGeometry>();
|
|
15
|
+
|
|
16
|
+
export type ShooterMaterials = ReturnTypeOfMaterials;
|
|
17
|
+
|
|
18
|
+
function compactBox(width: number, height: number, depth: number): BufferGeometry {
|
|
19
|
+
const halfX = width / 2;
|
|
20
|
+
const halfY = height / 2;
|
|
21
|
+
const halfZ = depth / 2;
|
|
22
|
+
const positions = new Float32Array([
|
|
23
|
+
-halfX,
|
|
24
|
+
-halfY,
|
|
25
|
+
-halfZ,
|
|
26
|
+
halfX,
|
|
27
|
+
-halfY,
|
|
28
|
+
-halfZ,
|
|
29
|
+
halfX,
|
|
30
|
+
halfY,
|
|
31
|
+
-halfZ,
|
|
32
|
+
-halfX,
|
|
33
|
+
halfY,
|
|
34
|
+
-halfZ,
|
|
35
|
+
-halfX,
|
|
36
|
+
-halfY,
|
|
37
|
+
halfZ,
|
|
38
|
+
halfX,
|
|
39
|
+
-halfY,
|
|
40
|
+
halfZ,
|
|
41
|
+
halfX,
|
|
42
|
+
halfY,
|
|
43
|
+
halfZ,
|
|
44
|
+
-halfX,
|
|
45
|
+
halfY,
|
|
46
|
+
halfZ,
|
|
47
|
+
]);
|
|
48
|
+
const normals = new Float32Array(positions.length);
|
|
49
|
+
for (let index = 0; index < positions.length; index += 3) {
|
|
50
|
+
const x = positions[index] ?? 0;
|
|
51
|
+
const y = positions[index + 1] ?? 0;
|
|
52
|
+
const z = positions[index + 2] ?? 0;
|
|
53
|
+
const length = Math.hypot(x, y, z) || 1;
|
|
54
|
+
normals[index] = x / length;
|
|
55
|
+
normals[index + 1] = y / length;
|
|
56
|
+
normals[index + 2] = z / length;
|
|
57
|
+
}
|
|
58
|
+
const geometry = new BufferGeometry();
|
|
59
|
+
geometry.setAttribute("position", new BufferAttribute(positions, 3));
|
|
60
|
+
geometry.setAttribute("normal", new BufferAttribute(normals, 3));
|
|
61
|
+
geometry.setIndex([
|
|
62
|
+
0, 1, 2, 0, 2, 3, 4, 6, 5, 4, 7, 6, 0, 4, 5, 0, 5, 1, 1, 5, 6, 1, 6, 2, 2, 6, 7, 2, 7, 3, 4, 0,
|
|
63
|
+
3, 4, 3, 7,
|
|
64
|
+
]);
|
|
65
|
+
return geometry;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function roundedBox(
|
|
69
|
+
width: number,
|
|
70
|
+
height: number,
|
|
71
|
+
depth: number,
|
|
72
|
+
radius = 0.12,
|
|
73
|
+
segments = 1,
|
|
74
|
+
): BufferGeometry {
|
|
75
|
+
const key = `${width},${height},${depth},${radius},${segments}`;
|
|
76
|
+
const cached = roundedCache.get(key);
|
|
77
|
+
if (cached !== undefined) return cached;
|
|
78
|
+
const geometry = compactBox(width, height, depth);
|
|
79
|
+
roundedCache.set(key, geometry);
|
|
80
|
+
return geometry;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function shadowed(mesh: Mesh, cast = true): Mesh {
|
|
84
|
+
mesh.castShadow = cast;
|
|
85
|
+
mesh.receiveShadow = true;
|
|
86
|
+
return mesh;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function block(width: number, height: number, depth: number, material: Material): Mesh {
|
|
90
|
+
return shadowed(new Mesh(roundedBox(width, height, depth), material));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function createArena(materials: ShooterMaterials) {
|
|
94
|
+
const group = new Group();
|
|
95
|
+
group.name = "arena";
|
|
96
|
+
const floor = block(22, 0.4, 20, materials.arena);
|
|
97
|
+
floor.name = "arena-floor";
|
|
98
|
+
floor.position.set(0, -0.2, -2);
|
|
99
|
+
group.add(floor);
|
|
100
|
+
const walls = [
|
|
101
|
+
{ depth: 20, position: [-11, 1.7, -2] as const, width: 0.4 },
|
|
102
|
+
{ depth: 20, position: [11, 1.7, -2] as const, width: 0.4 },
|
|
103
|
+
{ depth: 0.4, position: [0, 1.7, -12] as const, width: 22 },
|
|
104
|
+
].map(({ depth, position, width }, index) => {
|
|
105
|
+
const wall = block(width, 3.8, depth, materials.shadow);
|
|
106
|
+
wall.name = `arena-wall-${index}`;
|
|
107
|
+
wall.position.set(position[0], position[1], position[2]);
|
|
108
|
+
group.add(wall);
|
|
109
|
+
return wall;
|
|
110
|
+
});
|
|
111
|
+
for (let x = -9; x <= 9; x += 3) {
|
|
112
|
+
const strip = new Mesh(compactBox(0.035, 0.012, 19), materials.trim);
|
|
113
|
+
strip.position.set(x, 0.012, -2);
|
|
114
|
+
strip.castShadow = false;
|
|
115
|
+
strip.receiveShadow = false;
|
|
116
|
+
group.add(strip);
|
|
117
|
+
}
|
|
118
|
+
for (let z = -11; z <= 7; z += 3) {
|
|
119
|
+
const strip = new Mesh(compactBox(21, 0.012, 0.035), materials.trim);
|
|
120
|
+
strip.position.set(0, 0.014, z);
|
|
121
|
+
strip.castShadow = false;
|
|
122
|
+
strip.receiveShadow = false;
|
|
123
|
+
group.add(strip);
|
|
124
|
+
}
|
|
125
|
+
return { floor, group, walls };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function createPlayerVisual(materials: ShooterMaterials): Group {
|
|
129
|
+
const group = new Group();
|
|
130
|
+
group.name = "player-visual";
|
|
131
|
+
const body = block(0.76, 1.35, 0.76, materials.player);
|
|
132
|
+
body.position.y = 0.62;
|
|
133
|
+
group.add(body);
|
|
134
|
+
const visor = new Mesh(compactBox(0.56, 0.22, 0.08), materials.trim);
|
|
135
|
+
visor.position.set(0, 0.88, -0.4);
|
|
136
|
+
visor.castShadow = true;
|
|
137
|
+
group.add(visor);
|
|
138
|
+
const muzzle = new Mesh(
|
|
139
|
+
new CylinderGeometry(0.08, 0.1, 0.5, 6).rotateX(Math.PI / 2),
|
|
140
|
+
materials.shadow,
|
|
141
|
+
);
|
|
142
|
+
muzzle.position.set(0, 0.52, -0.55);
|
|
143
|
+
muzzle.castShadow = true;
|
|
144
|
+
group.add(muzzle);
|
|
145
|
+
return group;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function createTargetVisual(materials: ShooterMaterials): Group {
|
|
149
|
+
const group = new Group();
|
|
150
|
+
group.name = "target-visual";
|
|
151
|
+
const body = block(1.2, 1.8, 1, materials.hostile);
|
|
152
|
+
body.position.y = 0.9;
|
|
153
|
+
group.add(body);
|
|
154
|
+
const ring = new Mesh(compactBox(1.4, 0.08, 0.08), materials.trim);
|
|
155
|
+
ring.position.y = 0.9;
|
|
156
|
+
ring.castShadow = true;
|
|
157
|
+
group.add(ring);
|
|
158
|
+
const crossbar = new Mesh(compactBox(0.08, 0.08, 1.4), materials.trim);
|
|
159
|
+
crossbar.position.y = 0.9;
|
|
160
|
+
crossbar.castShadow = true;
|
|
161
|
+
group.add(crossbar);
|
|
162
|
+
return group;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function createFriendlyVisual(materials: ShooterMaterials): Group {
|
|
166
|
+
const group = new Group();
|
|
167
|
+
const body = block(0.9, 1.4, 0.9, materials.player);
|
|
168
|
+
body.position.y = 0.7;
|
|
169
|
+
group.add(body);
|
|
170
|
+
const antenna = new Mesh(new CylinderGeometry(0.04, 0.04, 0.5, 8), materials.trim);
|
|
171
|
+
antenna.position.y = 1.65;
|
|
172
|
+
group.add(antenna);
|
|
173
|
+
return group;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function createWallVisual(materials: ShooterMaterials): Mesh {
|
|
177
|
+
return block(0.65, 2.8, 2.8, materials.shadow);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function createPickupVisual(materials: ShooterMaterials): Group {
|
|
181
|
+
const group = new Group();
|
|
182
|
+
const base = block(0.65, 0.12, 0.65, materials.trim);
|
|
183
|
+
base.position.y = 0.06;
|
|
184
|
+
group.add(base);
|
|
185
|
+
const orb = new Mesh(new SphereGeometry(0.25, 4, 3), materials.player);
|
|
186
|
+
orb.position.y = 0.45;
|
|
187
|
+
orb.castShadow = true;
|
|
188
|
+
group.add(orb);
|
|
189
|
+
return group;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function createProjectileVisual(materials: ShooterMaterials): Mesh {
|
|
193
|
+
return shadowed(new Mesh(new SphereGeometry(0.12, 4, 3), materials.trim), false);
|
|
194
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Generated for you. This ordinary Three.js sky is yours to rewrite.
|
|
2
|
+
import {
|
|
3
|
+
BackSide,
|
|
4
|
+
BufferAttribute,
|
|
5
|
+
Color,
|
|
6
|
+
Fog,
|
|
7
|
+
MathUtils,
|
|
8
|
+
Mesh,
|
|
9
|
+
MeshBasicMaterial,
|
|
10
|
+
type Scene,
|
|
11
|
+
SphereGeometry,
|
|
12
|
+
} from "three";
|
|
13
|
+
import { palette } from "./palette.js";
|
|
14
|
+
|
|
15
|
+
export function setupSky(scene: Scene): void {
|
|
16
|
+
const radius = 90;
|
|
17
|
+
const geometry = new SphereGeometry(radius, 4, 3);
|
|
18
|
+
const positions = geometry.getAttribute("position");
|
|
19
|
+
const colors = new Float32Array(positions.count * 3);
|
|
20
|
+
const high = new Color(palette.skyHigh);
|
|
21
|
+
const low = new Color(palette.skyLow);
|
|
22
|
+
const color = new Color();
|
|
23
|
+
for (let index = 0; index < positions.count; index += 1) {
|
|
24
|
+
const height = MathUtils.clamp((positions.getY(index) / radius + 0.2) / 0.65, 0, 1);
|
|
25
|
+
color.copy(low).lerp(high, height);
|
|
26
|
+
colors.set([color.r, color.g, color.b], index * 3);
|
|
27
|
+
}
|
|
28
|
+
geometry.setAttribute("color", new BufferAttribute(colors, 3));
|
|
29
|
+
const dome = new Mesh(
|
|
30
|
+
geometry,
|
|
31
|
+
new MeshBasicMaterial({ fog: false, side: BackSide, toneMapped: false, vertexColors: true }),
|
|
32
|
+
);
|
|
33
|
+
dome.frustumCulled = false;
|
|
34
|
+
scene.background = high;
|
|
35
|
+
scene.fog = new Fog(palette.skyLow, 24, 90);
|
|
36
|
+
scene.add(dome);
|
|
37
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--shooter-void: #090d13;
|
|
5
|
+
--shooter-panel: #101923;
|
|
6
|
+
--shooter-line: #263746;
|
|
7
|
+
--shooter-amber: #f6c85f;
|
|
8
|
+
--shooter-cyan: #64d8cb;
|
|
9
|
+
--shooter-red: #ff6b7a;
|
|
10
|
+
--shooter-text: #d6e0e5;
|
|
11
|
+
--shooter-dim: #718493;
|
|
12
|
+
--shooter-font: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
html,
|
|
16
|
+
body,
|
|
17
|
+
#root {
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
margin: 0;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
body {
|
|
25
|
+
background: var(--shooter-void);
|
|
26
|
+
color: var(--shooter-text);
|
|
27
|
+
font-family: var(--shooter-font);
|
|
28
|
+
-webkit-font-smoothing: antialiased;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.shooter-app {
|
|
32
|
+
position: relative;
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.shooter-canvas {
|
|
39
|
+
position: absolute;
|
|
40
|
+
inset: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.shooter-hud {
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
position: absolute;
|
|
46
|
+
top: 1.5rem;
|
|
47
|
+
left: 1.5rem;
|
|
48
|
+
width: 16rem;
|
|
49
|
+
font-size: 0.6875rem;
|
|
50
|
+
text-transform: uppercase;
|
|
51
|
+
letter-spacing: 0.16em;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.shooter-hud__eyebrow {
|
|
55
|
+
color: var(--shooter-dim);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.shooter-hud__wave {
|
|
59
|
+
margin-top: 0.5rem;
|
|
60
|
+
color: var(--shooter-amber);
|
|
61
|
+
font-size: 1.875rem;
|
|
62
|
+
line-height: 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.shooter-hud__rules {
|
|
66
|
+
margin-top: 0.25rem;
|
|
67
|
+
color: var(--shooter-cyan);
|
|
68
|
+
font-size: 0.625rem;
|
|
69
|
+
letter-spacing: 0.2em;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.shooter-meter {
|
|
73
|
+
width: 14rem;
|
|
74
|
+
margin-top: 0.5rem;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.shooter-meter__label,
|
|
78
|
+
.shooter-hud__summary {
|
|
79
|
+
display: flex;
|
|
80
|
+
justify-content: space-between;
|
|
81
|
+
gap: 0.5rem;
|
|
82
|
+
color: var(--shooter-dim);
|
|
83
|
+
font-size: 0.625rem;
|
|
84
|
+
text-transform: uppercase;
|
|
85
|
+
letter-spacing: 0.18em;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.shooter-meter__value {
|
|
89
|
+
color: var(--shooter-text);
|
|
90
|
+
font-weight: 400;
|
|
91
|
+
font-variant-numeric: tabular-nums;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.shooter-meter__track {
|
|
95
|
+
height: 0.25rem;
|
|
96
|
+
margin-top: 0.25rem;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
border: 1px solid var(--shooter-line);
|
|
99
|
+
background: var(--shooter-panel);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.shooter-meter__fill {
|
|
103
|
+
display: block;
|
|
104
|
+
height: 100%;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.shooter-meter__fill--amber {
|
|
108
|
+
background: var(--shooter-amber);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.shooter-meter__fill--cyan {
|
|
112
|
+
background: var(--shooter-cyan);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.shooter-hud__summary {
|
|
116
|
+
margin-top: 0.75rem;
|
|
117
|
+
padding-top: 0.5rem;
|
|
118
|
+
border-top: 1px solid var(--shooter-line);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.shooter-phase {
|
|
122
|
+
margin-top: 1rem;
|
|
123
|
+
padding: 0.5rem 0.75rem;
|
|
124
|
+
border: 1px solid currentColor;
|
|
125
|
+
text-align: center;
|
|
126
|
+
font-size: 0.875rem;
|
|
127
|
+
letter-spacing: 0.28em;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.shooter-phase--danger {
|
|
131
|
+
color: var(--shooter-red);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.shooter-phase--success {
|
|
135
|
+
color: var(--shooter-amber);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.shooter-menu {
|
|
139
|
+
pointer-events: none;
|
|
140
|
+
position: absolute;
|
|
141
|
+
right: 1.5rem;
|
|
142
|
+
bottom: 1.25rem;
|
|
143
|
+
left: 1.5rem;
|
|
144
|
+
display: flex;
|
|
145
|
+
align-items: flex-end;
|
|
146
|
+
justify-content: space-between;
|
|
147
|
+
gap: 1rem;
|
|
148
|
+
color: var(--shooter-dim);
|
|
149
|
+
font-size: 0.625rem;
|
|
150
|
+
text-transform: uppercase;
|
|
151
|
+
letter-spacing: 0.16em;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.shooter-menu__help {
|
|
155
|
+
max-width: 42rem;
|
|
156
|
+
padding: 0.5rem 0.75rem;
|
|
157
|
+
border: 1px solid var(--shooter-line);
|
|
158
|
+
background: rgb(16 25 35 / 80%);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.shooter-menu__help-primary {
|
|
162
|
+
color: var(--shooter-text);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.shooter-menu__help-secondary {
|
|
166
|
+
margin-top: 0.25rem;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.shooter-menu__actions {
|
|
170
|
+
pointer-events: auto;
|
|
171
|
+
display: flex;
|
|
172
|
+
gap: 0.5rem;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.shooter-menu__button {
|
|
176
|
+
border: 1px solid var(--shooter-line);
|
|
177
|
+
padding: 0.5rem 0.75rem;
|
|
178
|
+
background: var(--shooter-panel);
|
|
179
|
+
color: var(--shooter-text);
|
|
180
|
+
font: inherit;
|
|
181
|
+
cursor: pointer;
|
|
182
|
+
transition: border-color 160ms ease, transform 160ms ease;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.shooter-menu__button:hover,
|
|
186
|
+
.shooter-menu__button:focus-visible {
|
|
187
|
+
border-color: var(--shooter-amber);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.shooter-menu__button:active {
|
|
191
|
+
transform: translateY(1px) scale(0.98);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@media (max-width: 720px) {
|
|
195
|
+
.shooter-hud {
|
|
196
|
+
top: 1rem;
|
|
197
|
+
left: 1rem;
|
|
198
|
+
width: min(16rem, calc(100% - 2rem));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.shooter-menu {
|
|
202
|
+
right: 1rem;
|
|
203
|
+
bottom: 1rem;
|
|
204
|
+
left: 1rem;
|
|
205
|
+
align-items: stretch;
|
|
206
|
+
flex-direction: column;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.shooter-menu__actions {
|
|
210
|
+
align-self: flex-end;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const shooterUi = {
|
|
2
|
+
app: {
|
|
3
|
+
canvas: "shooter-canvas",
|
|
4
|
+
root: "shooter-app",
|
|
5
|
+
},
|
|
6
|
+
hud: {
|
|
7
|
+
copy: {
|
|
8
|
+
clear: (wavesCleared: number) => `clear ${wavesCleared}`,
|
|
9
|
+
eyebrow: "arena / shooter",
|
|
10
|
+
health: "health",
|
|
11
|
+
lives: "lives",
|
|
12
|
+
rules: "clear 5 waves · fail 0 lives",
|
|
13
|
+
targets: (targets: number) => `targets ${targets}`,
|
|
14
|
+
wave: (wave: number) => `wave ${wave} / 5`,
|
|
15
|
+
},
|
|
16
|
+
eyebrow: "shooter-hud__eyebrow",
|
|
17
|
+
meter: {
|
|
18
|
+
fill: {
|
|
19
|
+
amber: "shooter-meter__fill shooter-meter__fill--amber",
|
|
20
|
+
cyan: "shooter-meter__fill shooter-meter__fill--cyan",
|
|
21
|
+
},
|
|
22
|
+
label: "shooter-meter__label",
|
|
23
|
+
root: "shooter-meter",
|
|
24
|
+
track: "shooter-meter__track",
|
|
25
|
+
value: "shooter-meter__value",
|
|
26
|
+
},
|
|
27
|
+
phase: {
|
|
28
|
+
dead: "shooter-phase shooter-phase--danger",
|
|
29
|
+
lost: "shooter-phase shooter-phase--danger",
|
|
30
|
+
playing: "",
|
|
31
|
+
won: "shooter-phase shooter-phase--success",
|
|
32
|
+
},
|
|
33
|
+
phaseCopy: {
|
|
34
|
+
dead: "respawning",
|
|
35
|
+
lost: "run failed",
|
|
36
|
+
playing: "",
|
|
37
|
+
won: "arena clear",
|
|
38
|
+
},
|
|
39
|
+
root: "shooter-hud",
|
|
40
|
+
rules: "shooter-hud__rules",
|
|
41
|
+
summary: "shooter-hud__summary",
|
|
42
|
+
wave: "shooter-hud__wave",
|
|
43
|
+
},
|
|
44
|
+
menu: {
|
|
45
|
+
actions: "shooter-menu__actions",
|
|
46
|
+
button: "shooter-menu__button",
|
|
47
|
+
copy: {
|
|
48
|
+
pause: "pause",
|
|
49
|
+
primary: "WASD / arrows move · F hitscan · G projectile",
|
|
50
|
+
restart: "restart",
|
|
51
|
+
resume: "resume",
|
|
52
|
+
secondary: "E radius test · C wall probe · H damage · X lethal · R restart",
|
|
53
|
+
},
|
|
54
|
+
help: "shooter-menu__help",
|
|
55
|
+
helpPrimary: "shooter-menu__help-primary",
|
|
56
|
+
helpSecondary: "shooter-menu__help-secondary",
|
|
57
|
+
root: "shooter-menu",
|
|
58
|
+
},
|
|
59
|
+
} as const;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Scene } from "@threenative/core";
|
|
2
|
+
import type { IPhysicsContext } from "@threenative/physics";
|
|
3
|
+
import type { GameState } from "../state.js";
|
|
4
|
+
import { type GameCtx, Play } from "./Play.js";
|
|
5
|
+
|
|
6
|
+
export class Boot extends Scene<GameState, IPhysicsContext> {
|
|
7
|
+
static override readonly initialState = Play.initialState;
|
|
8
|
+
|
|
9
|
+
override enter(ctx: GameCtx): void {
|
|
10
|
+
void ctx.goto("play");
|
|
11
|
+
}
|
|
12
|
+
}
|