create-threenative 0.2.18 → 0.2.20

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 (183) hide show
  1. package/agent-docs/references/capability-reference.md +212 -4
  2. package/agent-docs/references/kit-racing.md +4 -2
  3. package/agent-docs/references/performance-basics.md +2 -1
  4. package/agent-docs/references/terrain-authoring.md +21 -7
  5. package/agent-files/.agents/skills/prd-creator/SKILL.md +24 -0
  6. package/dist/index.js +255 -236
  7. package/dist/quality.d.ts +5 -1
  8. package/dist/quality.js +75 -6
  9. package/dist/terrain-kit.js +1 -1
  10. package/dist/threenative.js +6 -4
  11. package/dist/web-engine-post-effects.js +6 -0
  12. package/dist/web-engine-runtime.js +211 -36
  13. package/package.json +6 -6
  14. package/template-assets/assets/floor-fern-0.glb +0 -0
  15. package/template-assets/assets/floor-litter-0.glb +0 -0
  16. package/template-assets/assets/floor-log-0.glb +0 -0
  17. package/template-assets/assets/floor-log-1.glb +0 -0
  18. package/template-assets/assets/floor-stump-0.glb +0 -0
  19. package/template-assets/assets/floor-twig-0.glb +0 -0
  20. package/template-assets/quality/eslint.config.js +1 -1
  21. package/templates/action-rpg/package.json +7 -7
  22. package/templates/action-rpg/src/loot/drops.ts +3 -7
  23. package/templates/action-rpg/src/render/camera.ts +2 -2
  24. package/templates/action-rpg/src/render/clouds.ts +3 -1
  25. package/templates/action-rpg/src/render/materials.ts +3 -2
  26. package/templates/action-rpg/src/render/touch-controls.ts +7 -6
  27. package/templates/action-rpg/src/scenes/Play.ts +1 -15
  28. package/templates/adventure/AGENTS.md +3 -3
  29. package/templates/adventure/CLAUDE.md +3 -3
  30. package/templates/adventure/native-playtests/survives.playtest.json +12 -0
  31. package/templates/adventure/native-playtests/woodland-floor.playtest.json +61 -0
  32. package/templates/adventure/package.json +7 -7
  33. package/templates/adventure/playtests/grass.playtest.json +61 -0
  34. package/templates/adventure/playtests/performance.playtest.json +1 -1
  35. package/templates/adventure/playtests/survives.playtest.json +2 -2
  36. package/templates/adventure/playtests/woodland-floor.playtest.json +61 -0
  37. package/templates/adventure/src/entities/LockOn.ts +42 -4
  38. package/templates/adventure/src/entities/Warden.ts +4 -1
  39. package/templates/adventure/src/level/Vale.ts +241 -16
  40. package/templates/adventure/src/render/camera.ts +2 -2
  41. package/templates/adventure/src/render/foliage.ts +64 -20
  42. package/templates/adventure/src/render/grass.ts +325 -0
  43. package/templates/adventure/src/render/materials.ts +3 -2
  44. package/templates/adventure/src/render/palette.ts +3 -0
  45. package/templates/adventure/src/render/touch-controls.ts +4 -1
  46. package/templates/adventure/src/scenes/Play.ts +96 -1
  47. package/templates/collectathon/package.json +7 -7
  48. package/templates/collectathon/src/level/Course.ts +2 -7
  49. package/templates/collectathon/src/level/terrain.ts +2 -1
  50. package/templates/collectathon/src/render/camera.ts +2 -2
  51. package/templates/collectathon/src/render/ground.ts +4 -4
  52. package/templates/collectathon/src/render/hero.ts +1 -1
  53. package/templates/collectathon/src/render/materials.ts +0 -1
  54. package/templates/collectathon/src/render/sky.ts +4 -3
  55. package/templates/kart/package.json +6 -6
  56. package/templates/kart/src/entities/Kart.ts +2 -1
  57. package/templates/kart/src/render/course.ts +2 -1
  58. package/templates/kart/src/track/Course.ts +3 -1
  59. package/templates/minimal/package.json +6 -6
  60. package/templates/minimal/src/render/camera.ts +2 -2
  61. package/templates/minimal/src/render/clouds.ts +3 -1
  62. package/templates/minimal/src/render/materials.ts +3 -2
  63. package/templates/minimal/src/render/touch-controls.ts +7 -6
  64. package/templates/platformer/package.json +7 -7
  65. package/templates/platformer/playtests/collect.playtest.json +4 -1
  66. package/templates/platformer/src/level/Stage.ts +2 -6
  67. package/templates/platformer/src/scenes/Play.ts +2 -1
  68. package/templates/puzzle/package.json +7 -7
  69. package/templates/puzzle/src/entities/Warden.ts +3 -3
  70. package/templates/puzzle/src/render/camera.ts +2 -2
  71. package/templates/puzzle/src/render/touch-controls.ts +7 -6
  72. package/templates/racing/AGENTS.md +2 -2
  73. package/templates/racing/CLAUDE.md +2 -2
  74. package/templates/racing/CREDITS.md +29 -0
  75. package/templates/racing/assets/engine-loop.wav +0 -0
  76. package/templates/racing/assets/grass/Grass004_color.jpg +0 -0
  77. package/templates/racing/assets/grass/Grass004_normal.jpg +0 -0
  78. package/templates/racing/assets/grass/Grass004_roughness.jpg +0 -0
  79. package/templates/racing/assets/nitro-burst.wav +0 -0
  80. package/templates/racing/assets/tyre-squeal.wav +0 -0
  81. package/templates/racing/package.json +7 -7
  82. package/templates/racing/playtests/drift-natural.playtest.json +68 -0
  83. package/templates/racing/playtests/drift.playtest.json +100 -0
  84. package/templates/racing/playtests/hud.playtest.json +117 -0
  85. package/templates/racing/playtests/launch-pose.playtest.json +34 -0
  86. package/templates/racing/playtests/nitro.playtest.json +158 -0
  87. package/templates/racing/playtests/outcome.playtest.json +4 -4
  88. package/templates/racing/playtests/performance.playtest.json +1 -1
  89. package/templates/racing/playtests/steady-camera.playtest.json +88 -0
  90. package/templates/racing/src/audio/engine.ts +138 -0
  91. package/templates/racing/src/entities/CarBody.ts +83 -10
  92. package/templates/racing/src/entities/Drift.ts +243 -0
  93. package/templates/racing/src/entities/LineDriver.ts +2 -2
  94. package/templates/racing/src/entities/Nitro.ts +72 -0
  95. package/templates/racing/src/entities/RacingCar.ts +86 -21
  96. package/templates/racing/src/entities/Rival.ts +35 -21
  97. package/templates/racing/src/game.ts +6 -0
  98. package/templates/racing/src/gauges.ts +74 -0
  99. package/templates/racing/src/render/camera.ts +29 -4
  100. package/templates/racing/src/render/clouds.ts +3 -1
  101. package/templates/racing/src/render/effects.ts +244 -0
  102. package/templates/racing/src/render/materials.ts +43 -8
  103. package/templates/racing/src/render/shapes.ts +37 -0
  104. package/templates/racing/src/render/skids.ts +84 -0
  105. package/templates/racing/src/render/touch-controls.ts +10 -10
  106. package/templates/racing/src/scenes/Race.ts +277 -25
  107. package/templates/racing/src/state.ts +35 -0
  108. package/templates/racing/src/style.css +3 -0
  109. package/templates/racing/src/track/Track.ts +132 -58
  110. package/templates/racing/src/track/TrackSector.ts +19 -1
  111. package/templates/racing/src/track/circuit.ts +21 -15
  112. package/templates/racing/src/ui/GameUi.tsx +0 -2
  113. package/templates/racing/src/ui/Hud.tsx +417 -50
  114. package/templates/racing/threenative.config.ts +15 -0
  115. package/templates/racing/tools/make-racing-audio.mjs +388 -0
  116. package/templates/rain/package.json +6 -6
  117. package/templates/rain/src/render/noise-volume.ts +2 -1
  118. package/templates/rain/src/state.ts +3 -1
  119. package/templates/rain/src/ui/GameUi.tsx +1 -1
  120. package/templates/rain/src/ui/automation.ts +10 -8
  121. package/templates/rain/src/ui/tempest.ts +3 -4
  122. package/templates/rts/package.json +6 -6
  123. package/templates/rts/src/sim/terrain.ts +1 -0
  124. package/templates/rts/src/sim/types.ts +1 -0
  125. package/templates/runner/package.json +7 -7
  126. package/templates/runner/src/render/clouds.ts +3 -1
  127. package/templates/runner/src/render/materials.ts +3 -2
  128. package/templates/runner/src/render/touch-controls.ts +7 -6
  129. package/templates/runner/src/scenes/Run.ts +4 -9
  130. package/templates/sailing/package.json +7 -7
  131. package/templates/sailing/src/render/touch-controls.ts +7 -6
  132. package/templates/shooter/package.json +7 -7
  133. package/templates/shooter/src/render/clouds.ts +3 -1
  134. package/templates/snow/package.json +7 -7
  135. package/templates/snow/src/entities/Explorer.ts +6 -12
  136. package/templates/snow/src/render/bootPrint.ts +3 -1
  137. package/templates/snow/src/render/camera.ts +3 -2
  138. package/templates/snow/src/render/scenery.ts +3 -3
  139. package/templates/snow/src/render/touch-controls.ts +7 -6
  140. package/templates/snow/src/render/weather.ts +3 -5
  141. package/templates/snow/src/terrain.ts +2 -1
  142. package/templates/starter/native-playtests/render-chain.playtest.json +9 -9
  143. package/templates/starter/package.json +7 -7
  144. package/templates/starter/src/entities/Player.ts +10 -2
  145. package/templates/starter/src/render/camera.ts +2 -2
  146. package/templates/starter/src/render/clouds.ts +3 -1
  147. package/templates/starter/src/render/materials.ts +3 -2
  148. package/templates/starter/src/render/touch-controls.ts +7 -6
  149. package/templates/starter/src/scenes/Play.ts +1 -14
  150. package/templates/tower-defense/package.json +7 -7
  151. package/templates/tower-defense/src/render/shapes.ts +1 -2
  152. package/templates/tower-defense/src/scenes/Battle.ts +3 -8
  153. package/template-assets/terrain/alpine/assets.json +0 -12
  154. package/template-assets/terrain/alpine/bake.mjs +0 -6
  155. package/template-assets/terrain/alpine/credits.json +0 -164
  156. package/template-assets/terrain/alpine/heightmap.r16 +0 -0
  157. package/template-assets/terrain/alpine/recipe.json +0 -119
  158. package/template-assets/terrain/alpine/surface.json +0 -53
  159. package/template-assets/terrain/coastal/assets.json +0 -11
  160. package/template-assets/terrain/coastal/bake.mjs +0 -6
  161. package/template-assets/terrain/coastal/credits.json +0 -117
  162. package/template-assets/terrain/coastal/heightmap.r16 +0 -0
  163. package/template-assets/terrain/coastal/recipe.json +0 -113
  164. package/template-assets/terrain/coastal/surface.json +0 -41
  165. package/template-assets/terrain/desert/assets.json +0 -12
  166. package/template-assets/terrain/desert/bake.mjs +0 -6
  167. package/template-assets/terrain/desert/credits.json +0 -164
  168. package/template-assets/terrain/desert/heightmap.r16 +0 -0
  169. package/template-assets/terrain/desert/recipe.json +0 -108
  170. package/template-assets/terrain/desert/surface.json +0 -54
  171. package/template-assets/terrain/forest/assets.json +0 -65
  172. package/template-assets/terrain/forest/bake.mjs +0 -8
  173. package/template-assets/terrain/forest/credits.json +0 -225
  174. package/template-assets/terrain/forest/heightmap.r16 +0 -0
  175. package/template-assets/terrain/forest/recipe.json +0 -350
  176. package/template-assets/terrain/forest/surface.json +0 -79
  177. package/template-assets/terrain/tundra/assets.json +0 -12
  178. package/template-assets/terrain/tundra/bake.mjs +0 -6
  179. package/template-assets/terrain/tundra/credits.json +0 -164
  180. package/template-assets/terrain/tundra/heightmap.r16 +0 -0
  181. package/template-assets/terrain/tundra/recipe.json +0 -277
  182. package/template-assets/terrain/tundra/surface.json +0 -54
  183. package/templates/racing/src/ui/Menu.tsx +0 -7
@@ -11,6 +11,7 @@ import {
11
11
  EquirectangularReflectionMapping,
12
12
  FogExp2,
13
13
  LinearFilter,
14
+ MathUtils,
14
15
  RGBAFormat,
15
16
  SRGBColorSpace,
16
17
  type Scene,
@@ -39,8 +40,8 @@ const LATTICE = (() => {
39
40
  function noise(x: number, y: number): number {
40
41
  const i = Math.floor(x);
41
42
  const j = Math.floor(y);
42
- const fx = (x - i) * (x - i) * (3 - 2 * (x - i));
43
- const fy = (y - j) * (y - j) * (3 - 2 * (y - j));
43
+ const fx = MathUtils.smoothstep(x - i, 0, 1);
44
+ const fy = MathUtils.smoothstep(y - j, 0, 1);
44
45
  const i0 = i & 255;
45
46
  const i1 = (i + 1) & 255;
46
47
  const j0 = (j & 255) << 8;
@@ -79,7 +80,7 @@ function density(x: number, y: number): number {
79
80
 
80
81
  const smooth = (from: number, to: number, value: number): number => {
81
82
  const t = Math.min(1, Math.max(0, (value - from) / (to - from)));
82
- return t * t * (3 - 2 * t);
83
+ return MathUtils.smoothstep(t, 0, 1);
83
84
  };
84
85
 
85
86
  /**
@@ -19,8 +19,8 @@
19
19
  "format:check": "biome format src"
20
20
  },
21
21
  "dependencies": {
22
- "@threenative/core": "0.3.13",
23
- "@threenative/ui": "0.3.13",
22
+ "@threenative/core": ">=0.3.15",
23
+ "@threenative/ui": ">=0.3.15",
24
24
  "react": "19.2.0",
25
25
  "react-dom": "19.2.0",
26
26
  "three": "0.187.0"
@@ -29,11 +29,11 @@
29
29
  "@tailwindcss/vite": "4.3.3",
30
30
  "@vitejs/plugin-react": "6.0.5",
31
31
  "@types/three": "0.187.0",
32
- "@threenative/assets": "0.3.14",
33
- "@threenative/playtest": "0.3.13",
32
+ "@threenative/assets": ">=0.3.16",
33
+ "@threenative/playtest": ">=0.3.15",
34
34
  "@types/react": "19.2.0",
35
35
  "@types/react-dom": "19.2.0",
36
- "create-threenative": "0.2.18",
36
+ "create-threenative": "0.2.20",
37
37
  "esbuild": "0.27.0",
38
38
  "playwright": "1.62.1",
39
39
  "tailwindcss": "4.3.3",
@@ -44,7 +44,7 @@
44
44
  "eslint": "10.13.0"
45
45
  },
46
46
  "optionalDependencies": {
47
- "@threenative/runtime-native": "0.3.13"
47
+ "@threenative/runtime-native": ">=0.3.15"
48
48
  },
49
49
  "overrides": {
50
50
  "sharp": ">=0.35.4",
@@ -1,3 +1,4 @@
1
+ import { MathUtils } from "three";
1
2
  import { type ICourse, SURFACE_DRAG, type Surface } from "../track/Course.js";
2
3
 
3
4
  /**
@@ -327,7 +328,7 @@ export class Kart {
327
328
  Math.max(0, 1 - resist) *
328
329
  (1 + this.boost + this.miniTurbo + this.catchUp);
329
330
  if (brake && this.throttle === 0 && this.speed < 0.5) target = -f.reverse;
330
- this.speed += (target - this.speed) * (1 - Math.exp(-ticks / f.lagTicks));
331
+ this.speed = MathUtils.damp(this.speed, target, 1 / f.lagTicks, ticks);
331
332
  }
332
333
 
333
334
  // Hop and drift. A press while grounded hops; with the stick held and enough speed the hop
@@ -15,6 +15,7 @@ import {
15
15
  Group,
16
16
  IcosahedronGeometry,
17
17
  InstancedMesh,
18
+ MathUtils,
18
19
  Matrix4,
19
20
  Mesh,
20
21
  MeshStandardMaterial,
@@ -521,7 +522,7 @@ export function buildCourseView(course: ICourse, seed = 734): ICourseView {
521
522
 
522
523
  function smooth(edge0: number, edge1: number, x: number): number {
523
524
  const t = Math.min(1, Math.max(0, (x - edge0) / (edge1 - edge0)));
524
- return t * t * (3 - 2 * t);
525
+ return MathUtils.smoothstep(t, 0, 1);
525
526
  }
526
527
 
527
528
  /** True when x/z is at least `clearance` metres from every sample of the line. */
@@ -10,6 +10,8 @@
10
10
  */
11
11
 
12
12
  /** Metres between samples of the centre line. */
13
+ import { MathUtils } from "three";
14
+
13
15
  export const STEP = 1;
14
16
 
15
17
  /** The lateral profile, in metres from the centre line. */
@@ -69,7 +71,7 @@ function plateau(s: number, at: number, length: number, flat: number, ramp: numb
69
71
 
70
72
  function smooth(edge0: number, edge1: number, x: number): number {
71
73
  const t = Math.min(1, Math.max(0, (x - edge0) / (edge1 - edge0)));
72
- return t * t * (3 - 2 * t);
74
+ return MathUtils.smoothstep(t, 0, 1);
73
75
  }
74
76
 
75
77
  export interface ICourse {
@@ -19,15 +19,15 @@
19
19
  "format:check": "biome format src"
20
20
  },
21
21
  "dependencies": {
22
- "@threenative/core": "0.3.13",
23
- "@threenative/physics": "0.3.13",
22
+ "@threenative/core": ">=0.3.15",
23
+ "@threenative/physics": ">=0.3.15",
24
24
  "three": "0.187.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@threenative/assets": "0.3.14",
28
- "@threenative/playtest": "0.3.13",
27
+ "@threenative/assets": ">=0.3.16",
28
+ "@threenative/playtest": ">=0.3.15",
29
29
  "@types/three": "0.187.0",
30
- "create-threenative": "0.2.18",
30
+ "create-threenative": "0.2.20",
31
31
  "esbuild": "0.27.0",
32
32
  "playwright": "1.62.1",
33
33
  "typescript": "7.0.2",
@@ -37,7 +37,7 @@
37
37
  "eslint": "10.13.0"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@threenative/runtime-native": "0.3.13"
40
+ "@threenative/runtime-native": ">=0.3.15"
41
41
  },
42
42
  "overrides": {
43
43
  "sharp": ">=0.35.4",
@@ -1,5 +1,5 @@
1
1
  // Generated for you. Camera framing is yours to edit.
2
- import { type PerspectiveCamera, Vector3 } from "three";
2
+ import { MathUtils, type PerspectiveCamera, Vector3 } from "three";
3
3
 
4
4
  /** Where the camera sits relative to the player's body centre: up and behind, over the shoulder. */
5
5
  const OFFSET = new Vector3(0.6, 1.4, 4.6);
@@ -51,7 +51,7 @@ export function followCamera(
51
51
  const wall = probe(_aim, _desired);
52
52
  if (wall === undefined) {
53
53
  const gap = camera.position.distanceTo(_desired);
54
- const step = Math.max(gap * (1 - Math.exp(-dt * 8)), SETTLE_SPEED * dt);
54
+ const step = Math.max(gap * MathUtils.damp(0, 1, 8, dt), SETTLE_SPEED * dt);
55
55
  if (gap <= 2 * step) camera.position.copy(_desired);
56
56
  else camera.position.lerp(_desired, step / gap);
57
57
  } else {
@@ -6,6 +6,8 @@
6
6
  // Independent CPU implementation. The material samples four Unreal textures that this repository
7
7
  // must not carry, so each one is regenerated here from a seeded noise whose per-channel value
8
8
  // quantiles and correlation lengths match the Unreal texture (measured, see the spec).
9
+ import { MathUtils } from "three";
10
+
9
11
  import {
10
12
  BOTTOM_KM,
11
13
  CAMERA_KM,
@@ -110,7 +112,7 @@ const PROFILE_COEFFICIENTS = [
110
112
  const clamp = (v: number): number => Math.max(0, Math.min(1, v));
111
113
  const smooth = (v: number): number => {
112
114
  const t = clamp(v);
113
- return t * t * (3 - 2 * t);
115
+ return MathUtils.smoothstep(t, 0, 1);
114
116
  };
115
117
  const mod = (a: number, n: number): number => ((a % n) + n) % n;
116
118
 
@@ -11,6 +11,7 @@ import {
11
11
  Float32BufferAttribute,
12
12
  FrontSide,
13
13
  LinearMipmapLinearFilter,
14
+ MathUtils,
14
15
  MeshStandardMaterial,
15
16
  RepeatWrapping,
16
17
  SRGBColorSpace,
@@ -84,8 +85,8 @@ function grainNormalTexture(size = 128): DataTexture {
84
85
  const y0 = Math.floor(v);
85
86
  const fx = u - x0;
86
87
  const fy = v - y0;
87
- const sx = fx * fx * (3 - 2 * fx);
88
- const sy = fy * fy * (3 - 2 * fy);
88
+ const sx = MathUtils.smoothstep(fx, 0, 1);
89
+ const sy = MathUtils.smoothstep(fy, 0, 1);
89
90
  const at = (i: number, j: number): number =>
90
91
  values[(((j % count) + count) % count) * count + (((i % count) + count) % count)] ?? 0;
91
92
  const top = at(x0, y0) + (at(x0 + 1, y0) - at(x0, y0)) * sx;
@@ -15,6 +15,9 @@ const MOVE_RADIUS = 72;
15
15
  const BUTTON_RADIUS = 62;
16
16
  const EDGE = 36;
17
17
 
18
+ /** The knob's next point: `update` runs every frame, so it uses one instance. */
19
+ const knobPosition = new Vector2();
20
+
18
21
  export interface ITouchPointer {
19
22
  readonly position: Vector2;
20
23
  }
@@ -111,13 +114,11 @@ export class TouchControls {
111
114
  }
112
115
 
113
116
  const center = this.#hasMoveAnchor ? this.#moveAnchor : this.#resting;
114
- place(
115
- this.#moveKnob,
116
- new Vector2(
117
- center.x + this.#input.move.x * MOVE_RADIUS,
118
- center.y - this.#input.move.y * MOVE_RADIUS,
119
- ),
117
+ knobPosition.set(
118
+ center.x + this.#input.move.x * MOVE_RADIUS,
119
+ center.y - this.#input.move.y * MOVE_RADIUS,
120
120
  );
121
+ place(this.#moveKnob, knobPosition);
121
122
  this.#jump.material = jump ? this.#activeMaterial : this.#idleMaterial;
122
123
  this.#input.jumpPressed = jump && !this.#wasJump;
123
124
  this.#wasJump = jump;
@@ -19,9 +19,9 @@
19
19
  "format:check": "biome format src"
20
20
  },
21
21
  "dependencies": {
22
- "@threenative/core": "0.3.13",
23
- "@threenative/physics": "0.3.13",
24
- "@threenative/ui": "0.3.13",
22
+ "@threenative/core": ">=0.3.15",
23
+ "@threenative/physics": ">=0.3.15",
24
+ "@threenative/ui": ">=0.3.15",
25
25
  "react": "19.2.0",
26
26
  "react-dom": "19.2.0",
27
27
  "three": "0.187.0"
@@ -30,11 +30,11 @@
30
30
  "@tailwindcss/vite": "4.3.3",
31
31
  "@vitejs/plugin-react": "6.0.5",
32
32
  "@types/three": "0.187.0",
33
- "@threenative/assets": "0.3.14",
34
- "@threenative/playtest": "0.3.13",
33
+ "@threenative/assets": ">=0.3.16",
34
+ "@threenative/playtest": ">=0.3.15",
35
35
  "@types/react": "19.2.0",
36
36
  "@types/react-dom": "19.2.0",
37
- "create-threenative": "0.2.18",
37
+ "create-threenative": "0.2.20",
38
38
  "esbuild": "0.27.0",
39
39
  "playwright": "1.62.1",
40
40
  "tailwindcss": "4.3.3",
@@ -45,7 +45,7 @@
45
45
  "eslint": "10.13.0"
46
46
  },
47
47
  "optionalDependencies": {
48
- "@threenative/runtime-native": "0.3.13"
48
+ "@threenative/runtime-native": ">=0.3.15"
49
49
  },
50
50
  "overrides": {
51
51
  "sharp": ">=0.35.4",
@@ -24,7 +24,10 @@
24
24
  ],
25
25
  "assert": {
26
26
  "diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
27
- "resources": [{ "changed": true, "gte": 3, "id": "state", "path": "coins" }],
27
+ "resources": [
28
+ { "changed": true, "gte": 3, "id": "state", "path": "coins" },
29
+ { "changed": true, "gte": 1, "id": "state", "path": "coins" }
30
+ ],
28
31
  "signals": [{ "entity": "player", "minCount": 3, "name": "collected" }]
29
32
  }
30
33
  }
@@ -1,3 +1,4 @@
1
+ import { createRandom } from "@threenative/core";
1
2
  import {
2
3
  BoxGeometry,
3
4
  ConeGeometry,
@@ -18,13 +19,8 @@ import { waterfall } from "../render/waterfall.js";
18
19
 
19
20
  /** Deterministic, so the route is the same course every run. */
20
21
  export function makeRng(seed = 90210): () => number {
21
- let state = seed >>> 0;
22
- return () => {
23
- state = (state * 1664525 + 1013904223) >>> 0;
24
- return state / 4294967296;
25
- };
22
+ return createRandom(seed);
26
23
  }
27
-
28
24
  export interface IStage {
29
25
  /** The one root to add to the scene and hand to `buildStaticColliders`. */
30
26
  readonly group: Group;
@@ -217,7 +217,8 @@ export class Play extends Scene<GameState, IPhysicsContext> {
217
217
  // The coin lines are the route's teaching: one along the floor, one arced over every jump.
218
218
  // The opening nine weave, but inside the reach a straight run actually collects: a coin the
219
219
  // player can see and cannot take is worse than no coin at all.
220
- for (let i = 0; i < 9; i += 1) addPickup("coin", -5 + i * 1.6, 1.25, Math.sin(i * 0.9) * 0.6);
220
+ // The line starts one step past the spawn: a coin under the spawn was collected on frame 1.
221
+ for (let i = 1; i <= 9; i += 1) addPickup("coin", -5 + i * 1.6, 1.25, Math.sin(i * 0.9) * 0.6);
221
222
  for (let i = 0; i < 8; i += 1) addPickup("coin", 12 + i * 2, 1.25, i % 2 ? 1.6 : -1.4);
222
223
  for (const point of coinArc([30, 1.3, 0], [34, 2.8, 0], 6, 1.6))
223
224
  addPickup("coin", point.x, point.y, point.z);
@@ -18,9 +18,9 @@
18
18
  "format:check": "biome format src"
19
19
  },
20
20
  "dependencies": {
21
- "@threenative/core": "0.3.13",
22
- "@threenative/physics": "0.3.13",
23
- "@threenative/ui": "0.3.13",
21
+ "@threenative/core": ">=0.3.15",
22
+ "@threenative/physics": ">=0.3.15",
23
+ "@threenative/ui": ">=0.3.15",
24
24
  "react": "19.2.0",
25
25
  "react-dom": "19.2.0",
26
26
  "three": "0.187.0"
@@ -28,13 +28,13 @@
28
28
  "devDependencies": {
29
29
  "@gltf-transform/cli": "4.4.2",
30
30
  "@tailwindcss/vite": "4.3.3",
31
- "@threenative/assets": "0.3.14",
32
- "@threenative/playtest": "0.3.13",
31
+ "@threenative/assets": ">=0.3.16",
32
+ "@threenative/playtest": ">=0.3.15",
33
33
  "@types/react": "19.2.0",
34
34
  "@types/react-dom": "19.2.0",
35
35
  "@types/three": "0.187.0",
36
36
  "@vitejs/plugin-react": "6.0.5",
37
- "create-threenative": "0.2.18",
37
+ "create-threenative": "0.2.20",
38
38
  "esbuild": "0.27.0",
39
39
  "playwright": "1.62.1",
40
40
  "tailwindcss": "4.3.3",
@@ -44,7 +44,7 @@
44
44
  "eslint": "10.13.0"
45
45
  },
46
46
  "optionalDependencies": {
47
- "@threenative/runtime-native": "0.3.13"
47
+ "@threenative/runtime-native": ">=0.3.15"
48
48
  },
49
49
  "overrides": {
50
50
  "sharp": ">=0.35.4",
@@ -1,6 +1,6 @@
1
1
  import type { ICtx } from "@threenative/core";
2
2
  import { CharacterBody3D, CollisionShape3D, type IPhysicsContext } from "@threenative/physics";
3
- import { Group, Vector3 } from "three";
3
+ import { Group, MathUtils, Vector3 } from "three";
4
4
  import { wardenFigure } from "../render/warden.js";
5
5
  import type { GameState } from "../state.js";
6
6
  import { WARDEN_MASK } from "./Crate.js";
@@ -90,12 +90,12 @@ export class Warden {
90
90
  // Shortest-arc turn, framerate independent, so the figure faces the shove rather than
91
91
  // snapping between the four arrow directions.
92
92
  const delta = Math.atan2(Math.sin(target - this.#facing), Math.cos(target - this.#facing));
93
- this.#facing += delta * (1 - Math.exp(-dt / 0.06));
93
+ this.#facing = MathUtils.damp(this.#facing, this.#facing + delta, 1 / 0.06, dt);
94
94
  this.#figure.rotation.y = this.#facing;
95
95
  }
96
96
  // Lean into the push. Purely cosmetic, and it is most of what makes the shove read.
97
97
  const lean = Math.min(0.28, Math.hypot(move.x, move.z) * 0.28);
98
- this.#figure.rotation.x += (lean - this.#figure.rotation.x) * (1 - Math.exp(-dt / 0.09));
98
+ this.#figure.rotation.x = MathUtils.damp(this.#figure.rotation.x, lean, 1 / 0.09, dt);
99
99
  }
100
100
 
101
101
  teleport(position: { readonly x: number; readonly y: number; readonly z: number }): void {
@@ -7,7 +7,7 @@
7
7
  // It still breathes. `settle` eases the framing in over the opening drop, and `nudge` lets the
8
8
  // shot drift a fraction of a metre toward the warden so the picture is not completely static.
9
9
  import type { PerspectiveCamera, Vector3 } from "three";
10
- import { Vector3 as Vec3 } from "three";
10
+ import { MathUtils, Vector3 as Vec3 } from "three";
11
11
 
12
12
  export const VAULT_SHOT = {
13
13
  fov: 31,
@@ -64,7 +64,7 @@ export function createVaultCamera(camera: PerspectiveCamera): IVaultCamera {
64
64
  desired.copy(VAULT_SHOT.position).add(aim);
65
65
  // 1 - e^(-dt/tau) is the framerate-independent form of a lerp: the same second of drift at
66
66
  // 30 fps and at 120 fps ends in the same place.
67
- camera.position.lerp(desired, 1 - Math.exp(-dt / 0.9));
67
+ camera.position.lerp(desired, MathUtils.damp(0, 1, 1 / 0.9, dt));
68
68
  camera.lookAt(currentAim);
69
69
  };
70
70
 
@@ -14,6 +14,9 @@ import { palette } from "./palette.js";
14
14
  const MOVE_RADIUS = 72;
15
15
  const EDGE = 36;
16
16
 
17
+ /** The knob's next point: `update` runs every frame, so it uses one instance. */
18
+ const knobPosition = new Vector2();
19
+
17
20
  export interface ITouchPointer {
18
21
  readonly position: Vector2;
19
22
  }
@@ -101,13 +104,11 @@ export class TouchControls {
101
104
  }
102
105
 
103
106
  const center = this.#hasMoveAnchor ? this.#moveAnchor : this.#resting;
104
- place(
105
- this.#moveKnob,
106
- new Vector2(
107
- center.x + this.#input.move.x * MOVE_RADIUS,
108
- center.y - this.#input.move.y * MOVE_RADIUS,
109
- ),
107
+ knobPosition.set(
108
+ center.x + this.#input.move.x * MOVE_RADIUS,
109
+ center.y - this.#input.move.y * MOVE_RADIUS,
110
110
  );
111
+ place(this.#moveKnob, knobPosition);
111
112
  this.#layout(size);
112
113
  return this.#input;
113
114
  }
@@ -37,8 +37,8 @@ A change to an existing game repeats steps 2-3 for that change, then steps 5-8.
37
37
  ## This kit
38
38
 
39
39
  <!-- shared: kit-files -->
40
- Source in `src/`: `conventions.ts`, `entities/`, `game.ts`, `kart/`, `main.ts`, `playtest-events.ts`, `render/`, `scenes/`, `state.ts`, `track/`, `ui/`.
41
- 11 scenarios in `playtests/`; `playtests/survives.playtest.json` is the smoke proof.
40
+ Source in `src/`: `audio/`, `conventions.ts`, `entities/`, `game.ts`, `gauges.ts`, `kart/`, `main.ts`, `playtest-events.ts`, `render/`, `scenes/`, `state.ts`, `track/`, `ui/`.
41
+ 17 scenarios in `playtests/`; `playtests/survives.playtest.json` is the smoke proof.
42
42
  Exposure policy: `src/render/exposure.ts` (`node_modules/create-threenative/agent-docs/references/auto-exposure.md`).
43
43
  Kit notes: `node_modules/create-threenative/agent-docs/references/kit-racing.md`.
44
44
  <!-- /shared -->
@@ -39,8 +39,8 @@ A change to an existing game repeats steps 2-3 for that change, then steps 5-8.
39
39
  ## This kit
40
40
 
41
41
  <!-- shared: kit-files -->
42
- Source in `src/`: `conventions.ts`, `entities/`, `game.ts`, `kart/`, `main.ts`, `playtest-events.ts`, `render/`, `scenes/`, `state.ts`, `track/`, `ui/`.
43
- 11 scenarios in `playtests/`; `playtests/survives.playtest.json` is the smoke proof.
42
+ Source in `src/`: `audio/`, `conventions.ts`, `entities/`, `game.ts`, `gauges.ts`, `kart/`, `main.ts`, `playtest-events.ts`, `render/`, `scenes/`, `state.ts`, `track/`, `ui/`.
43
+ 17 scenarios in `playtests/`; `playtests/survives.playtest.json` is the smoke proof.
44
44
  Exposure policy: `src/render/exposure.ts` (`node_modules/create-threenative/agent-docs/references/auto-exposure.md`).
45
45
  Kit notes: `node_modules/create-threenative/agent-docs/references/kit-racing.md`.
46
46
  <!-- /shared -->
@@ -0,0 +1,29 @@
1
+ # Credits
2
+
3
+ ## Audio
4
+
5
+ Every clip in `assets/` is **generated by this project's own tool**, `tools/make-racing-audio.mjs`,
6
+ from the maths in that file. They are original works of this repository under its MIT licence —
7
+ there is no third-party recording in them, and nothing to attribute.
8
+
9
+ | File | Made by | Licence | Source |
10
+ | --- | --- | --- | --- |
11
+ | `assets/engine-loop.wav` | `node tools/make-racing-audio.mjs` | MIT (this repository) | none — synthesised |
12
+ | `assets/tyre-squeal.wav` | `node tools/make-racing-audio.mjs` | MIT (this repository) | none — synthesised |
13
+ | `assets/nitro-burst.wav` | `node tools/make-racing-audio.mjs` | MIT (this repository) | none — synthesised |
14
+
15
+ Why not a downloaded clip: the audio catalogue the asset tools reach was searched for an engine, a
16
+ tyre and a boost (`audio_search_assets`). It returns seven items — two Kenney packs, "Interface
17
+ Sounds" and "Music Jingles", both CC0, and the five Sonniss GDC 2026 bundles, whose stated licence
18
+ is the "Sonniss GDC Game Audio Bundle License" and whose download is one multi-gigabyte archive per
19
+ part. None of them is an engine bed, a tyre squeal or a nitro burst.
20
+
21
+ An engine bed also cannot be a recording here, for a second reason: it is pitched live from 0.62×
22
+ to 2.05× (`src/audio/engine.ts`), so the loop has to be tonal and exactly periodic, and a recording
23
+ of a real engine is neither. `tools/make-racing-audio.mjs` builds the seam in — every frequency is a
24
+ whole number of cycles per loop — and the bake proves it before it writes a byte.
25
+
26
+ Swap any file for a recording without touching the game: the paths are named in `ENGINE_SOUND.clips`
27
+ and the levels in the same object. If you do, add the recording's source, licence and URL to this
28
+ file, and keep `loop: true` for the two beds in `threenative.config.ts` so the audio pass keeps
29
+ checking the join.
@@ -19,9 +19,9 @@
19
19
  "format:check": "biome format src"
20
20
  },
21
21
  "dependencies": {
22
- "@threenative/core": "0.3.13",
23
- "@threenative/physics": "0.3.13",
24
- "@threenative/ui": "0.3.13",
22
+ "@threenative/core": ">=0.3.15",
23
+ "@threenative/physics": ">=0.3.15",
24
+ "@threenative/ui": ">=0.3.15",
25
25
  "react": "19.2.0",
26
26
  "react-dom": "19.2.0",
27
27
  "three": "0.187.0"
@@ -29,13 +29,13 @@
29
29
  "devDependencies": {
30
30
  "@gltf-transform/cli": "4.4.2",
31
31
  "@tailwindcss/vite": "4.3.3",
32
- "@threenative/assets": "0.3.14",
33
- "@threenative/playtest": "0.3.13",
32
+ "@threenative/assets": ">=0.3.16",
33
+ "@threenative/playtest": ">=0.3.15",
34
34
  "@types/react": "19.2.0",
35
35
  "@types/react-dom": "19.2.0",
36
36
  "@types/three": "0.187.0",
37
37
  "@vitejs/plugin-react": "6.0.5",
38
- "create-threenative": "0.2.18",
38
+ "create-threenative": "0.2.20",
39
39
  "esbuild": "0.27.0",
40
40
  "playwright": "1.62.1",
41
41
  "tailwindcss": "4.3.3",
@@ -45,7 +45,7 @@
45
45
  "eslint": "10.13.0"
46
46
  },
47
47
  "optionalDependencies": {
48
- "@threenative/runtime-native": "0.3.13"
48
+ "@threenative/runtime-native": ">=0.3.15"
49
49
  },
50
50
  "overrides": {
51
51
  "sharp": ">=0.35.4",
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "drift-natural",
3
+ "target": "web",
4
+ "schemaVersion": 1,
5
+ "viewport": {
6
+ "width": 1280,
7
+ "height": 720
8
+ },
9
+ "warmupFrames": 10,
10
+ "subject": "player",
11
+ "steps": [
12
+ {
13
+ "kind": "input",
14
+ "label": "straight",
15
+ "press": ["ArrowUp"],
16
+ "holdTicks": 240,
17
+ "release": false
18
+ },
19
+ {
20
+ "kind": "input",
21
+ "label": "full-lock",
22
+ "press": ["ArrowUp", "ArrowRight"],
23
+ "holdTicks": 30,
24
+ "release": false
25
+ },
26
+ {
27
+ "kind": "input",
28
+ "label": "catch",
29
+ "press": ["ArrowUp", "ArrowLeft"],
30
+ "holdTicks": 14,
31
+ "release": false
32
+ },
33
+ {
34
+ "kind": "input",
35
+ "label": "straighten",
36
+ "press": ["ArrowUp"],
37
+ "holdTicks": 60,
38
+ "release": true
39
+ }
40
+ ],
41
+ "assert": {
42
+ "diagnostics": {
43
+ "noConsoleErrors": true,
44
+ "runtimeReady": true
45
+ },
46
+ "resources": [
47
+ {
48
+ "id": "state",
49
+ "path": "driftsBanked",
50
+ "gte": 1,
51
+ "changed": true
52
+ },
53
+ {
54
+ "id": "state",
55
+ "path": "driftSpins",
56
+ "equals": 0,
57
+ "allowTrivial": "A spin is the failure this scenario looks for; zero is the held invariant while the banked drift above proves the tail let go with no handbrake."
58
+ }
59
+ ],
60
+ "components": [
61
+ {
62
+ "entity": "effects",
63
+ "component": "skidMarks",
64
+ "gte": 5
65
+ }
66
+ ]
67
+ }
68
+ }