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,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Camera,
|
|
3
|
+
Mesh,
|
|
4
|
+
MeshBasicMaterial,
|
|
5
|
+
type OrthographicCamera,
|
|
6
|
+
PlaneGeometry,
|
|
7
|
+
type Scene,
|
|
8
|
+
} from "three";
|
|
9
|
+
import { palette } from "./palette.js";
|
|
10
|
+
|
|
11
|
+
interface LoadingHost {
|
|
12
|
+
readonly camera: Camera;
|
|
13
|
+
readonly canvasLayer: {
|
|
14
|
+
readonly camera: OrthographicCamera;
|
|
15
|
+
readonly scene: Scene;
|
|
16
|
+
opaque: boolean;
|
|
17
|
+
};
|
|
18
|
+
readonly renderer: { compileAsync(scene: Scene, camera: Camera): Promise<void> };
|
|
19
|
+
readonly scene: Scene;
|
|
20
|
+
readonly startup: { readonly progress: number; whenReady(): Promise<void> };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createLoadingScreen(host: LoadingHost) {
|
|
24
|
+
const layer = host.canvasLayer;
|
|
25
|
+
const cover = (color: number, order: number): Mesh => {
|
|
26
|
+
const mesh = new Mesh(
|
|
27
|
+
new PlaneGeometry(1, 1),
|
|
28
|
+
new MeshBasicMaterial({ color, depthTest: false, depthWrite: false }),
|
|
29
|
+
);
|
|
30
|
+
mesh.frustumCulled = false;
|
|
31
|
+
mesh.renderOrder = order;
|
|
32
|
+
layer.scene.add(mesh);
|
|
33
|
+
return mesh;
|
|
34
|
+
};
|
|
35
|
+
const backdrop = cover(palette.skyLow, 0);
|
|
36
|
+
const track = cover(palette.skyHigh, 1);
|
|
37
|
+
const fill = cover(palette.accent, 2);
|
|
38
|
+
const parts = [backdrop, track, fill];
|
|
39
|
+
layer.opaque = true;
|
|
40
|
+
let width = 1;
|
|
41
|
+
let height = 1;
|
|
42
|
+
let lastProgress = 0;
|
|
43
|
+
|
|
44
|
+
const layout = (): void => {
|
|
45
|
+
width = Math.max(1, layer.camera.right - layer.camera.left);
|
|
46
|
+
height = Math.max(1, layer.camera.top - layer.camera.bottom);
|
|
47
|
+
backdrop.scale.set(width, height, 1);
|
|
48
|
+
track.scale.set(width * 0.5, height * 0.012, 1);
|
|
49
|
+
track.position.set(0, -height * 0.05, 0);
|
|
50
|
+
};
|
|
51
|
+
const progress = (value: number): void => {
|
|
52
|
+
lastProgress = Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : 0;
|
|
53
|
+
const full = width * 0.5;
|
|
54
|
+
const bar = Math.max(full * 0.002, full * lastProgress);
|
|
55
|
+
fill.scale.set(bar, height * 0.012, 1);
|
|
56
|
+
fill.position.set(-full / 2 + bar / 2, -height * 0.05, 0);
|
|
57
|
+
};
|
|
58
|
+
layout();
|
|
59
|
+
progress(0);
|
|
60
|
+
let done = false;
|
|
61
|
+
const finish = (): void => {
|
|
62
|
+
if (done) return;
|
|
63
|
+
done = true;
|
|
64
|
+
for (const mesh of parts) {
|
|
65
|
+
mesh.removeFromParent();
|
|
66
|
+
mesh.geometry.dispose();
|
|
67
|
+
if (Array.isArray(mesh.material)) {
|
|
68
|
+
for (const material of mesh.material) material.dispose();
|
|
69
|
+
} else {
|
|
70
|
+
mesh.material.dispose();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
layer.opaque = false;
|
|
74
|
+
};
|
|
75
|
+
void (async () => {
|
|
76
|
+
await host.startup.whenReady();
|
|
77
|
+
// Keep shader warm-up off the reveal path: custom TSL post graphs may never settle under
|
|
78
|
+
// SwiftShader, while the scene itself is already safe to show after the startup verdict.
|
|
79
|
+
void host.renderer.compileAsync(host.scene, host.camera).catch(() => undefined);
|
|
80
|
+
finish();
|
|
81
|
+
})();
|
|
82
|
+
return {
|
|
83
|
+
update(): void {
|
|
84
|
+
if (done) return;
|
|
85
|
+
layout();
|
|
86
|
+
progress(host.startup.progress);
|
|
87
|
+
},
|
|
88
|
+
finish,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { MeshStandardMaterial } from "three";
|
|
2
|
+
import { palette } from "./palette.js";
|
|
3
|
+
|
|
4
|
+
export function createMaterials() {
|
|
5
|
+
return {
|
|
6
|
+
accent: new MeshStandardMaterial({
|
|
7
|
+
color: palette.accent,
|
|
8
|
+
emissive: palette.accent,
|
|
9
|
+
emissiveIntensity: 0.34,
|
|
10
|
+
metalness: 0.42,
|
|
11
|
+
roughness: 0.3,
|
|
12
|
+
}),
|
|
13
|
+
enemy: new MeshStandardMaterial({
|
|
14
|
+
color: palette.hostile,
|
|
15
|
+
emissive: palette.hostile,
|
|
16
|
+
emissiveIntensity: 0.38,
|
|
17
|
+
metalness: 0.08,
|
|
18
|
+
roughness: 0.46,
|
|
19
|
+
}),
|
|
20
|
+
player: new MeshStandardMaterial({
|
|
21
|
+
color: palette.player,
|
|
22
|
+
emissive: palette.player,
|
|
23
|
+
emissiveIntensity: 0.2,
|
|
24
|
+
metalness: 0.28,
|
|
25
|
+
roughness: 0.38,
|
|
26
|
+
}),
|
|
27
|
+
stone: new MeshStandardMaterial({
|
|
28
|
+
color: palette.stone,
|
|
29
|
+
metalness: 0.26,
|
|
30
|
+
roughness: 0.72,
|
|
31
|
+
}),
|
|
32
|
+
trim: new MeshStandardMaterial({
|
|
33
|
+
color: palette.accent,
|
|
34
|
+
emissive: palette.accent,
|
|
35
|
+
emissiveIntensity: 0.75,
|
|
36
|
+
metalness: 0.55,
|
|
37
|
+
roughness: 0.24,
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ACESFilmicToneMapping, type Camera, type Scene } from "three";
|
|
2
|
+
import { bloom } from "three/addons/tsl/display/BloomNode.js";
|
|
3
|
+
import { pass } from "three/tsl";
|
|
4
|
+
|
|
5
|
+
type OutputRenderer = {
|
|
6
|
+
readonly kind: string;
|
|
7
|
+
readonly raw: unknown;
|
|
8
|
+
setOutputNode(node: unknown): void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function setupPost(renderer: OutputRenderer, scene: Scene, camera: Camera): void {
|
|
12
|
+
const raw = renderer.raw as { toneMapping?: number; toneMappingExposure?: number };
|
|
13
|
+
raw.toneMapping = ACESFilmicToneMapping;
|
|
14
|
+
raw.toneMappingExposure = 1.08;
|
|
15
|
+
if (renderer.kind !== "webgpu") return;
|
|
16
|
+
const colour = pass(scene, camera).getTextureNode();
|
|
17
|
+
renderer.setOutputNode(colour.add(bloom(colour, 0.72, 0.42, 0.18)));
|
|
18
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { BoxGeometry, CylinderGeometry, Group, type Material, Mesh, SphereGeometry } from "three";
|
|
2
|
+
import type { ReturnTypeOfMaterials } from "./types.js";
|
|
3
|
+
|
|
4
|
+
export type RpgMaterials = ReturnTypeOfMaterials;
|
|
5
|
+
|
|
6
|
+
function block(
|
|
7
|
+
width: number,
|
|
8
|
+
height: number,
|
|
9
|
+
depth: number,
|
|
10
|
+
material: Material,
|
|
11
|
+
castShadow = true,
|
|
12
|
+
): Mesh {
|
|
13
|
+
const mesh = new Mesh(new BoxGeometry(width, height, depth), material);
|
|
14
|
+
mesh.castShadow = castShadow;
|
|
15
|
+
mesh.receiveShadow = true;
|
|
16
|
+
return mesh;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createDungeon(materials: RpgMaterials) {
|
|
20
|
+
const group = new Group();
|
|
21
|
+
group.name = "three-room-dungeon";
|
|
22
|
+
const floor = block(36, 0.3, 12, materials.stone, false);
|
|
23
|
+
floor.name = "dungeon-floor";
|
|
24
|
+
floor.position.set(6, -0.15, 0);
|
|
25
|
+
group.add(floor);
|
|
26
|
+
|
|
27
|
+
const walls = [
|
|
28
|
+
{ name: "north-wall", size: [36, 2.8, 0.35] as const, position: [6, 1.4, -6] as const },
|
|
29
|
+
{ name: "south-wall", size: [36, 2.8, 0.35] as const, position: [6, 1.4, 6] as const },
|
|
30
|
+
{ name: "west-wall", size: [0.35, 2.8, 12] as const, position: [-12, 1.4, 0] as const },
|
|
31
|
+
{ name: "east-wall", size: [0.35, 2.8, 12] as const, position: [24, 1.4, 0] as const },
|
|
32
|
+
].map(({ name, position, size }) => {
|
|
33
|
+
const wall = block(size[0], size[1], size[2], materials.stone);
|
|
34
|
+
wall.name = name;
|
|
35
|
+
wall.position.set(position[0], position[1], position[2]);
|
|
36
|
+
group.add(wall);
|
|
37
|
+
return wall;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const roomPillars: Mesh[] = [];
|
|
41
|
+
for (const x of [0, 12]) {
|
|
42
|
+
for (const z of [-4.5, 4.5]) {
|
|
43
|
+
const pillar = block(0.7, 3.6, 1.2, materials.stone);
|
|
44
|
+
pillar.position.set(x, 1.8, z);
|
|
45
|
+
group.add(pillar);
|
|
46
|
+
roomPillars.push(pillar);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const lineOfSightWall = block(2.4, 2.1, 0.5, materials.stone);
|
|
50
|
+
lineOfSightWall.name = "line-of-sight-wall";
|
|
51
|
+
lineOfSightWall.position.set(-8, 1.05, -1.5);
|
|
52
|
+
group.add(lineOfSightWall);
|
|
53
|
+
|
|
54
|
+
for (const x of [-6, 6, 18]) {
|
|
55
|
+
const rune = block(3.2, 0.04, 0.08, materials.trim, false);
|
|
56
|
+
rune.position.set(x, 0.025, 0);
|
|
57
|
+
group.add(rune);
|
|
58
|
+
}
|
|
59
|
+
return { floor, group, lineOfSightWall, roomPillars, walls };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function createPlayerVisual(materials: RpgMaterials): Group {
|
|
63
|
+
const group = new Group();
|
|
64
|
+
group.name = "hero-visual";
|
|
65
|
+
const body = block(0.72, 1.25, 0.72, materials.player);
|
|
66
|
+
body.position.y = 0.65;
|
|
67
|
+
group.add(body);
|
|
68
|
+
const head = new Mesh(new SphereGeometry(0.32, 8, 6), materials.player);
|
|
69
|
+
head.position.y = 1.42;
|
|
70
|
+
head.castShadow = true;
|
|
71
|
+
group.add(head);
|
|
72
|
+
const blade = new Mesh(new BoxGeometry(0.08, 0.75, 0.16), materials.accent);
|
|
73
|
+
blade.position.set(0.52, 0.66, -0.1);
|
|
74
|
+
blade.rotation.z = -0.32;
|
|
75
|
+
blade.castShadow = true;
|
|
76
|
+
group.add(blade);
|
|
77
|
+
return group;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function createEnemyVisual(materials: RpgMaterials, boss: boolean): Group {
|
|
81
|
+
const group = new Group();
|
|
82
|
+
group.name = boss ? "boss-visual" : "enemy-visual";
|
|
83
|
+
const size = boss ? 1.2 : 0.82;
|
|
84
|
+
const body = block(size, boss ? 1.9 : 1.35, size, materials.enemy);
|
|
85
|
+
body.position.y = boss ? 0.95 : 0.67;
|
|
86
|
+
group.add(body);
|
|
87
|
+
const eye = new Mesh(new SphereGeometry(boss ? 0.18 : 0.12, 6, 4), materials.trim);
|
|
88
|
+
eye.position.set(0, boss ? 1.45 : 1.08, -size / 2 - 0.03);
|
|
89
|
+
eye.castShadow = true;
|
|
90
|
+
group.add(eye);
|
|
91
|
+
if (boss) {
|
|
92
|
+
const crown = new Mesh(new CylinderGeometry(0.48, 0.24, 0.42, 6), materials.accent);
|
|
93
|
+
crown.position.y = 2.0;
|
|
94
|
+
crown.castShadow = true;
|
|
95
|
+
group.add(crown);
|
|
96
|
+
}
|
|
97
|
+
return group;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function createLootVisual(materials: RpgMaterials): Group {
|
|
101
|
+
const group = new Group();
|
|
102
|
+
const base = block(0.55, 0.12, 0.55, materials.accent);
|
|
103
|
+
base.position.y = 0.06;
|
|
104
|
+
group.add(base);
|
|
105
|
+
const gem = new Mesh(new SphereGeometry(0.2, 6, 4), materials.player);
|
|
106
|
+
gem.position.y = 0.36;
|
|
107
|
+
gem.castShadow = true;
|
|
108
|
+
group.add(gem);
|
|
109
|
+
return group;
|
|
110
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BackSide, Color, Fog, Mesh, MeshBasicMaterial, type Scene, SphereGeometry } from "three";
|
|
2
|
+
import { palette } from "./palette.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The dungeon has no visible sky. This dome is the dark ambient envelope and fog colour;
|
|
6
|
+
* the interior's key, rim, and fill lights do the actual work on the stone.
|
|
7
|
+
*/
|
|
8
|
+
export function setupSky(scene: Scene): void {
|
|
9
|
+
const dome = new Mesh(
|
|
10
|
+
new SphereGeometry(80, 8, 4),
|
|
11
|
+
new MeshBasicMaterial({ color: palette.skyLow, fog: false, side: BackSide, toneMapped: false }),
|
|
12
|
+
);
|
|
13
|
+
dome.frustumCulled = false;
|
|
14
|
+
dome.name = "dungeon-ambient-dome";
|
|
15
|
+
scene.background = new Color(palette.skyLow);
|
|
16
|
+
scene.fog = new Fog(palette.skyLow, 18, 58);
|
|
17
|
+
scene.add(dome);
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ICtx, Scene } from "@threenative/core";
|
|
2
|
+
import type { IPhysicsContext } from "@threenative/physics";
|
|
3
|
+
import type { GameState } from "../state.js";
|
|
4
|
+
import { 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: ICtx<GameState, IPhysicsContext>): void {
|
|
10
|
+
void ctx.goto("play");
|
|
11
|
+
}
|
|
12
|
+
}
|