create-threenative 0.2.7 → 0.2.8

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.
Files changed (154) hide show
  1. package/README.md +3 -1
  2. package/agent-docs/references/capability-reference.md +177 -7
  3. package/capabilities.json +247 -4
  4. package/dist/index.js +6 -1
  5. package/dist/threenative.js +3 -2
  6. package/package.json +4 -4
  7. package/templates/action-rpg/package.json +1 -1
  8. package/templates/minimal/package.json +1 -1
  9. package/templates/platformer/package.json +1 -1
  10. package/templates/puzzle/package.json +1 -1
  11. package/templates/racing/package.json +1 -1
  12. package/templates/rain/.codex/config.toml +19 -0
  13. package/templates/rain/.cursor/mcp.json +32 -0
  14. package/templates/rain/.gemini/settings.json +32 -0
  15. package/templates/rain/.mcp.json +32 -0
  16. package/templates/rain/.vscode/mcp.json +36 -0
  17. package/templates/rain/.zed/settings.json +36 -0
  18. package/templates/rain/AGENTS.md +96 -0
  19. package/templates/rain/CLAUDE.md +98 -0
  20. package/templates/rain/assets/rain-loop.wav +0 -0
  21. package/templates/rain/assets/thunder.wav +0 -0
  22. package/templates/rain/assets/wind-loop.wav +0 -0
  23. package/templates/rain/index.html +18 -0
  24. package/templates/rain/kit.json +7 -0
  25. package/templates/rain/native-playtests/boot.playtest.json +13 -0
  26. package/templates/rain/native-playtests/lightning.playtest.json +173 -0
  27. package/templates/rain/opencode.json +41 -0
  28. package/templates/rain/package.json +56 -0
  29. package/templates/rain/playtests/auto-lightning-clear.playtest.json +66 -0
  30. package/templates/rain/playtests/auto-lightning.playtest.json +26 -0
  31. package/templates/rain/playtests/automation.playtest.json +133 -0
  32. package/templates/rain/playtests/cinematic.playtest.json +59 -0
  33. package/templates/rain/playtests/flash.playtest.json +27 -0
  34. package/templates/rain/playtests/fly.playtest.json +54 -0
  35. package/templates/rain/playtests/lightning.playtest.json +220 -0
  36. package/templates/rain/playtests/loading.playtest.json +57 -0
  37. package/templates/rain/playtests/paused.playtest.json +59 -0
  38. package/templates/rain/playtests/performance.playtest.json +22 -0
  39. package/templates/rain/playtests/reduced-motion.playtest.json +87 -0
  40. package/templates/rain/playtests/simulation.playtest.json +20 -0
  41. package/templates/rain/playtests/storm.playtest.json +150 -0
  42. package/templates/rain/playtests/survives.playtest.json +58 -0
  43. package/templates/rain/playtests/tiers.playtest.json +179 -0
  44. package/templates/rain/playtests/weather.playtest.json +77 -0
  45. package/templates/rain/public/favicon.svg +5 -0
  46. package/templates/rain/src/audio/storm.ts +314 -0
  47. package/templates/rain/src/game.ts +114 -0
  48. package/templates/rain/src/main.ts +15 -0
  49. package/templates/rain/src/render/bloom-shader.ts +65 -0
  50. package/templates/rain/src/render/camera.ts +160 -0
  51. package/templates/rain/src/render/clouds-shader.ts +242 -0
  52. package/templates/rain/src/render/clouds.ts +142 -0
  53. package/templates/rain/src/render/lighting.ts +39 -0
  54. package/templates/rain/src/render/lightning.ts +360 -0
  55. package/templates/rain/src/render/loading.ts +327 -0
  56. package/templates/rain/src/render/materials.ts +19 -0
  57. package/templates/rain/src/render/noise-volume.ts +159 -0
  58. package/templates/rain/src/render/palette.ts +18 -0
  59. package/templates/rain/src/render/post-shader.ts +178 -0
  60. package/templates/rain/src/render/postprocessing.ts +226 -0
  61. package/templates/rain/src/render/quality.ts +135 -0
  62. package/templates/rain/src/render/rain.ts +299 -0
  63. package/templates/rain/src/render/sky.ts +28 -0
  64. package/templates/rain/src/render/world-shader.ts +680 -0
  65. package/templates/rain/src/render/world.ts +146 -0
  66. package/templates/rain/src/render/worldEnvironment.ts +809 -0
  67. package/templates/rain/src/scenes/Boot.ts +334 -0
  68. package/templates/rain/src/state.ts +257 -0
  69. package/templates/rain/src/style.css +1160 -0
  70. package/templates/rain/src/ui/App.tsx +29 -0
  71. package/templates/rain/src/ui/GameUi.tsx +187 -0
  72. package/templates/rain/src/ui/Hud.tsx +327 -0
  73. package/templates/rain/src/ui/LoadingOverlay.tsx +46 -0
  74. package/templates/rain/src/ui/Menu.tsx +370 -0
  75. package/templates/rain/src/ui/automation.ts +60 -0
  76. package/templates/rain/src/ui/main.tsx +7 -0
  77. package/templates/rain/src/ui/tempest.ts +149 -0
  78. package/templates/rain/tailwind.config.ts +2 -0
  79. package/templates/rain/threenative.config.ts +66 -0
  80. package/templates/rain/tools/generate-shaders.mjs +656 -0
  81. package/templates/rain/tools/make-storm-audio.mjs +387 -0
  82. package/templates/rain/tools/storm-dsp.mjs +177 -0
  83. package/templates/rain/tools/tempest-bloom.frag +10 -0
  84. package/templates/rain/tools/tempest-clouds.frag +86 -0
  85. package/templates/rain/tools/tempest-post.frag +47 -0
  86. package/templates/rain/tools/tempest-world.frag +210 -0
  87. package/templates/rain/tools/verify-noise-volume.mjs +61 -0
  88. package/templates/rain/tsconfig.json +17 -0
  89. package/templates/rain/vite.config.ts +37 -0
  90. package/templates/rts/package.json +1 -1
  91. package/templates/runner/package.json +1 -1
  92. package/templates/sailing/package.json +1 -1
  93. package/templates/shooter/package.json +1 -1
  94. package/templates/snow/.codex/config.toml +19 -0
  95. package/templates/snow/.cursor/mcp.json +32 -0
  96. package/templates/snow/.gemini/settings.json +32 -0
  97. package/templates/snow/.mcp.json +32 -0
  98. package/templates/snow/.vscode/mcp.json +36 -0
  99. package/templates/snow/.zed/settings.json +36 -0
  100. package/templates/snow/AGENTS.md +88 -0
  101. package/templates/snow/CLAUDE.md +90 -0
  102. package/templates/snow/README.md +26 -0
  103. package/templates/snow/assets/crunch.wav +0 -0
  104. package/templates/snow/assets/wind.wav +0 -0
  105. package/templates/snow/index.html +12 -0
  106. package/templates/snow/kit.json +7 -0
  107. package/templates/snow/native-playtests/snow-physics.playtest.json +150 -0
  108. package/templates/snow/native-playtests/survives.playtest.json +47 -0
  109. package/templates/snow/opencode.json +41 -0
  110. package/templates/snow/package.json +58 -0
  111. package/templates/snow/playtests/footsteps.playtest.json +95 -0
  112. package/templates/snow/playtests/performance.playtest.json +36 -0
  113. package/templates/snow/playtests/snow-physics.playtest.json +154 -0
  114. package/templates/snow/playtests/survives.playtest.json +56 -0
  115. package/templates/snow/playtests/touch-controls.playtest.json +71 -0
  116. package/templates/snow/playtests/weather.playtest.json +119 -0
  117. package/templates/snow/public/favicon.svg +5 -0
  118. package/templates/snow/src/audio.ts +58 -0
  119. package/templates/snow/src/commands.ts +8 -0
  120. package/templates/snow/src/entities/Explorer.ts +279 -0
  121. package/templates/snow/src/game.ts +69 -0
  122. package/templates/snow/src/main.ts +15 -0
  123. package/templates/snow/src/render/bootPrint.ts +50 -0
  124. package/templates/snow/src/render/camera.ts +84 -0
  125. package/templates/snow/src/render/explorer.ts +321 -0
  126. package/templates/snow/src/render/lighting.ts +50 -0
  127. package/templates/snow/src/render/loading.ts +325 -0
  128. package/templates/snow/src/render/materials.ts +36 -0
  129. package/templates/snow/src/render/palette.ts +17 -0
  130. package/templates/snow/src/render/postprocessing.ts +44 -0
  131. package/templates/snow/src/render/props.ts +42 -0
  132. package/templates/snow/src/render/quality.ts +135 -0
  133. package/templates/snow/src/render/scenery.ts +244 -0
  134. package/templates/snow/src/render/sky.ts +57 -0
  135. package/templates/snow/src/render/snowSurface.ts +259 -0
  136. package/templates/snow/src/render/touch-controls.ts +143 -0
  137. package/templates/snow/src/render/weather.ts +279 -0
  138. package/templates/snow/src/render/worldEnvironment.ts +809 -0
  139. package/templates/snow/src/scenes/Boot.ts +12 -0
  140. package/templates/snow/src/scenes/Snow.ts +635 -0
  141. package/templates/snow/src/state.ts +46 -0
  142. package/templates/snow/src/style.css +143 -0
  143. package/templates/snow/src/terrain.ts +64 -0
  144. package/templates/snow/src/ui/App.tsx +15 -0
  145. package/templates/snow/src/ui/Controls.tsx +322 -0
  146. package/templates/snow/src/ui/GameUi.tsx +354 -0
  147. package/templates/snow/src/ui/icons.tsx +54 -0
  148. package/templates/snow/src/ui/main.tsx +7 -0
  149. package/templates/snow/tailwind.config.ts +2 -0
  150. package/templates/snow/threenative.config.ts +51 -0
  151. package/templates/snow/tsconfig.json +17 -0
  152. package/templates/snow/vite.config.ts +37 -0
  153. package/templates/starter/package.json +1 -1
  154. package/templates/tower-defense/package.json +1 -1
@@ -0,0 +1,146 @@
1
+ // Generated for you. Ordinary Three.js, and the whole coastal look lives in this file.
2
+ //
3
+ // The coast is not a set of meshes. It is one raymarched distance field — terrain, the road down
4
+ // it, the double yellow line, the sea, the island, the forest, the six lamps, the rail, the cabin
5
+ // with its lit window and its antenna, the wet reflections and the rain ripples — evaluated in the
6
+ // fragment shader, which is why the whole thing is a single screen-sized quad. Its maths lives in
7
+ // `world-shader.ts`, which `tools/generate-shaders.mjs` transpiles from GLSL; this file
8
+ // owns the camera basis, the weather uniforms and the sky it reflects, and nothing else.
9
+ //
10
+ // Conventions: one world unit is one metre, +x is out to sea, -z runs down the coast.
11
+ import {
12
+ DoubleSide,
13
+ Mesh,
14
+ type PerspectiveCamera,
15
+ PlaneGeometry,
16
+ type Scene,
17
+ Vector3,
18
+ } from "three";
19
+ import { cameraFar, cameraNear, clamp, float, positionGeometry, uv, vec4 } from "three/tsl";
20
+ import { MeshBasicNodeMaterial } from "three/webgpu";
21
+ import type { QualityName, Weather } from "../state.js";
22
+ import { type ICloudPass, createCloudPass } from "./clouds.js";
23
+ import { setupLighting } from "./lighting.js";
24
+ import { setupMaterials } from "./materials.js";
25
+ import { studyTier } from "./quality.js";
26
+ import { setupSky } from "./sky.js";
27
+ import {
28
+ tempestWorld,
29
+ uAspect,
30
+ uCam,
31
+ uFlash,
32
+ uFog,
33
+ uForward,
34
+ uRain,
35
+ uReflect,
36
+ uRight,
37
+ uStrike,
38
+ uTan,
39
+ uTime,
40
+ uUp,
41
+ uWet,
42
+ } from "./world-shader.js";
43
+
44
+ export interface IWeatherWorldOptions {
45
+ /** Absolute seconds, so the weather phase does not depend on how the frame was scheduled. */
46
+ readonly elapsed: number;
47
+ /** Current flash envelope, already gated on the photosensitivity switch by the caller. */
48
+ readonly flash: number;
49
+ readonly weather: Weather;
50
+ /** Where the last strike landed, in metres. Only visible while `flash` is above zero. */
51
+ readonly strike: Vector3;
52
+ /** The player's tier: `quality.ts` decides whether it runs the 36-step reflection march. */
53
+ readonly quality: QualityName;
54
+ }
55
+
56
+ export interface IWeatherWorld {
57
+ /** The screen quad, for the engine's culling pass: see the engine's `alwaysRender`. */
58
+ readonly quad: Mesh;
59
+ /** What the cloud pass really drew last frame: its target size and its march steps. */
60
+ readonly clouds: ICloudPass["measured"];
61
+ dispose(): void;
62
+ update(options: IWeatherWorldOptions): void;
63
+ }
64
+
65
+ /**
66
+ * The cloud pass is built first because it is what the world samples: `createCloudPass` binds the
67
+ * pass's texture node to the world's `uSky`, and the world shader's own functions read that binding
68
+ * when this call below builds their graph. The order of these two lines is the whole dependency.
69
+ */
70
+ export function createWeatherWorld(scene: Scene, camera: PerspectiveCamera): IWeatherWorld {
71
+ const clouds: ICloudPass = createCloudPass({ camera });
72
+ // The look the two passes read: sky and haze colours, the sun and the flash light, and the lamp
73
+ // and sea colours. Set once; nothing here changes per frame.
74
+ setupSky(scene);
75
+ setupLighting();
76
+ setupMaterials();
77
+
78
+ const world = tempestWorld(uv());
79
+ // The shader's own depth is a curve fitted to the source's camera; the closed form is reversible,
80
+ // so the engine's near/far decide the real clip depth and anything drawn after this quad — rain,
81
+ // then lightning — is occluded by the coast rather than floating through it.
82
+ const viewDistance = float(0.150009).div(float(1.00006).sub(world.w));
83
+ const material = new MeshBasicNodeMaterial();
84
+ // The source driver drew its coast quad with both faces, so the vertex stage is written to flip
85
+ // the corner order; a single-face material would cull whichever way that lands.
86
+ material.side = DoubleSide;
87
+ material.vertexNode = vec4(positionGeometry.xy, 0, 1);
88
+ material.fragmentNode = world.xyz;
89
+ material.depthNode = clamp(
90
+ cameraNear
91
+ .add(cameraFar)
92
+ .sub(cameraNear.mul(cameraFar).mul(2).div(viewDistance))
93
+ .div(cameraFar.sub(cameraNear))
94
+ .add(1)
95
+ .mul(0.5),
96
+ 0,
97
+ 1,
98
+ );
99
+
100
+ const geometry = new PlaneGeometry(2, 2);
101
+ const quad = new Mesh(geometry, material);
102
+ // The quad's own bounds are two metres wide and sit at the origin, so both frustum tests would
103
+ // throw it away the moment the camera looks along the coast.
104
+ quad.frustumCulled = false;
105
+ scene.add(quad);
106
+
107
+ const forward = new Vector3();
108
+ const right = new Vector3();
109
+ const up = new Vector3();
110
+
111
+ return {
112
+ quad,
113
+ clouds: clouds.measured,
114
+ dispose(): void {
115
+ scene.remove(quad);
116
+ geometry.dispose();
117
+ material.dispose();
118
+ clouds.dispose();
119
+ },
120
+ update({ elapsed, flash, quality, strike, weather }): void {
121
+ // The camera basis the shader raymarches from: the same three axes the renderer draws with,
122
+ // and the same field of view, so the coast lines up with anything the engine adds later.
123
+ camera.getWorldDirection(forward);
124
+ right.set(1, 0, 0).applyQuaternion(camera.quaternion);
125
+ up.set(0, 1, 0).applyQuaternion(camera.quaternion);
126
+ uCam.value.copy(camera.position);
127
+ uForward.value.copy(forward);
128
+ uRight.value.copy(right);
129
+ uUp.value.copy(up);
130
+ uAspect.value = camera.aspect;
131
+ uTan.value = Math.tan((camera.fov * Math.PI) / 360);
132
+ uTime.value = elapsed;
133
+
134
+ uRain.value = weather.rain;
135
+ uFog.value = weather.fog;
136
+ uWet.value = weather.wet;
137
+ uFlash.value = flash;
138
+ uStrike.value.copy(strike);
139
+ uReflect.value = studyTier(quality).reflections ? 1 : 0;
140
+
141
+ // The sky the shader draws and reflects is the cloud target, so the same weather that steers
142
+ // the rain also lights the ceiling, and a flash reaches both from one value.
143
+ clouds.update({ elapsed, flash, quality, strike, weather });
144
+ },
145
+ };
146
+ }