create-threenative 0.2.18 → 0.2.21

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 (186) hide show
  1. package/agent-docs/references/assertion-reference.md +1 -1
  2. package/agent-docs/references/capability-reference.md +792 -5
  3. package/agent-docs/references/kit-racing.md +4 -2
  4. package/agent-docs/references/performance-basics.md +2 -1
  5. package/agent-docs/references/terrain-authoring.md +25 -7
  6. package/agent-files/.agents/skills/prd-creator/SKILL.md +24 -0
  7. package/dist/index.js +268 -237
  8. package/dist/quality.d.ts +5 -1
  9. package/dist/quality.js +75 -6
  10. package/dist/terrain-kit.js +1 -1
  11. package/dist/threenative.js +7 -5
  12. package/dist/web-engine-post-effects.js +6 -0
  13. package/dist/web-engine-runtime.js +407 -38
  14. package/package.json +6 -6
  15. package/template-assets/assets/floor-fern-0.glb +0 -0
  16. package/template-assets/assets/floor-litter-0.glb +0 -0
  17. package/template-assets/assets/floor-log-0.glb +0 -0
  18. package/template-assets/assets/floor-log-1.glb +0 -0
  19. package/template-assets/assets/floor-stump-0.glb +0 -0
  20. package/template-assets/assets/floor-twig-0.glb +0 -0
  21. package/template-assets/patches/three@0.187.0.patch +108 -21
  22. package/template-assets/quality/eslint.config.js +1 -1
  23. package/templates/action-rpg/package.json +7 -7
  24. package/templates/action-rpg/src/loot/drops.ts +3 -7
  25. package/templates/action-rpg/src/render/camera.ts +2 -2
  26. package/templates/action-rpg/src/render/clouds.ts +3 -1
  27. package/templates/action-rpg/src/render/materials.ts +3 -2
  28. package/templates/action-rpg/src/render/touch-controls.ts +7 -6
  29. package/templates/action-rpg/src/scenes/Play.ts +1 -15
  30. package/templates/adventure/AGENTS.md +3 -3
  31. package/templates/adventure/CLAUDE.md +3 -3
  32. package/templates/adventure/native-playtests/survives.playtest.json +12 -0
  33. package/templates/adventure/native-playtests/woodland-floor.playtest.json +61 -0
  34. package/templates/adventure/package.json +7 -7
  35. package/templates/adventure/playtests/grass.playtest.json +61 -0
  36. package/templates/adventure/playtests/performance.playtest.json +1 -1
  37. package/templates/adventure/playtests/survives.playtest.json +2 -2
  38. package/templates/adventure/playtests/woodland-floor.playtest.json +61 -0
  39. package/templates/adventure/src/entities/LockOn.ts +42 -4
  40. package/templates/adventure/src/entities/Warden.ts +12 -3
  41. package/templates/adventure/src/level/Vale.ts +241 -16
  42. package/templates/adventure/src/render/camera.ts +2 -2
  43. package/templates/adventure/src/render/foliage.ts +64 -20
  44. package/templates/adventure/src/render/grass.ts +325 -0
  45. package/templates/adventure/src/render/materials.ts +3 -2
  46. package/templates/adventure/src/render/palette.ts +3 -0
  47. package/templates/adventure/src/render/touch-controls.ts +4 -1
  48. package/templates/adventure/src/scenes/Play.ts +96 -1
  49. package/templates/collectathon/package.json +7 -7
  50. package/templates/collectathon/src/level/Course.ts +2 -7
  51. package/templates/collectathon/src/level/terrain.ts +2 -1
  52. package/templates/collectathon/src/render/camera.ts +2 -2
  53. package/templates/collectathon/src/render/ground.ts +4 -4
  54. package/templates/collectathon/src/render/hero.ts +1 -1
  55. package/templates/collectathon/src/render/materials.ts +0 -1
  56. package/templates/collectathon/src/render/sky.ts +4 -3
  57. package/templates/kart/package.json +6 -6
  58. package/templates/kart/src/entities/Kart.ts +2 -1
  59. package/templates/kart/src/render/course.ts +2 -1
  60. package/templates/kart/src/track/Course.ts +3 -1
  61. package/templates/minimal/package.json +6 -6
  62. package/templates/minimal/src/render/camera.ts +2 -2
  63. package/templates/minimal/src/render/clouds.ts +3 -1
  64. package/templates/minimal/src/render/materials.ts +3 -2
  65. package/templates/minimal/src/render/touch-controls.ts +7 -6
  66. package/templates/platformer/package.json +7 -7
  67. package/templates/platformer/playtests/collect.playtest.json +4 -1
  68. package/templates/platformer/src/level/Stage.ts +2 -6
  69. package/templates/platformer/src/scenes/Play.ts +2 -1
  70. package/templates/puzzle/package.json +7 -7
  71. package/templates/puzzle/src/entities/Warden.ts +3 -3
  72. package/templates/puzzle/src/render/camera.ts +2 -2
  73. package/templates/puzzle/src/render/touch-controls.ts +7 -6
  74. package/templates/racing/AGENTS.md +2 -2
  75. package/templates/racing/CLAUDE.md +2 -2
  76. package/templates/racing/CREDITS.md +29 -0
  77. package/templates/racing/assets/engine-loop.wav +0 -0
  78. package/templates/racing/assets/grass/Grass004_color.jpg +0 -0
  79. package/templates/racing/assets/grass/Grass004_normal.jpg +0 -0
  80. package/templates/racing/assets/grass/Grass004_roughness.jpg +0 -0
  81. package/templates/racing/assets/nitro-burst.wav +0 -0
  82. package/templates/racing/assets/tyre-squeal.wav +0 -0
  83. package/templates/racing/package.json +7 -7
  84. package/templates/racing/playtests/drift-natural.playtest.json +68 -0
  85. package/templates/racing/playtests/drift.playtest.json +100 -0
  86. package/templates/racing/playtests/hud.playtest.json +117 -0
  87. package/templates/racing/playtests/launch-pose.playtest.json +34 -0
  88. package/templates/racing/playtests/nitro.playtest.json +158 -0
  89. package/templates/racing/playtests/outcome.playtest.json +4 -4
  90. package/templates/racing/playtests/performance.playtest.json +1 -1
  91. package/templates/racing/playtests/steady-camera.playtest.json +88 -0
  92. package/templates/racing/src/audio/engine.ts +138 -0
  93. package/templates/racing/src/entities/CarBody.ts +83 -10
  94. package/templates/racing/src/entities/Drift.ts +243 -0
  95. package/templates/racing/src/entities/LineDriver.ts +2 -2
  96. package/templates/racing/src/entities/Nitro.ts +72 -0
  97. package/templates/racing/src/entities/RacingCar.ts +86 -21
  98. package/templates/racing/src/entities/Rival.ts +35 -21
  99. package/templates/racing/src/game.ts +6 -0
  100. package/templates/racing/src/gauges.ts +74 -0
  101. package/templates/racing/src/render/camera.ts +29 -4
  102. package/templates/racing/src/render/clouds.ts +3 -1
  103. package/templates/racing/src/render/effects.ts +244 -0
  104. package/templates/racing/src/render/materials.ts +43 -8
  105. package/templates/racing/src/render/shapes.ts +37 -0
  106. package/templates/racing/src/render/skids.ts +84 -0
  107. package/templates/racing/src/render/touch-controls.ts +10 -10
  108. package/templates/racing/src/scenes/Race.ts +277 -25
  109. package/templates/racing/src/state.ts +35 -0
  110. package/templates/racing/src/style.css +3 -0
  111. package/templates/racing/src/track/Ranking.ts +8 -4
  112. package/templates/racing/src/track/Track.ts +132 -58
  113. package/templates/racing/src/track/TrackSector.ts +19 -1
  114. package/templates/racing/src/track/circuit.ts +21 -15
  115. package/templates/racing/src/ui/GameUi.tsx +0 -2
  116. package/templates/racing/src/ui/Hud.tsx +417 -50
  117. package/templates/racing/threenative.config.ts +15 -0
  118. package/templates/racing/tools/make-racing-audio.mjs +388 -0
  119. package/templates/rain/package.json +6 -6
  120. package/templates/rain/src/render/noise-volume.ts +2 -1
  121. package/templates/rain/src/state.ts +3 -1
  122. package/templates/rain/src/ui/GameUi.tsx +1 -1
  123. package/templates/rain/src/ui/automation.ts +10 -8
  124. package/templates/rain/src/ui/tempest.ts +3 -4
  125. package/templates/rts/package.json +6 -6
  126. package/templates/rts/src/sim/terrain.ts +1 -0
  127. package/templates/rts/src/sim/types.ts +1 -0
  128. package/templates/runner/package.json +7 -7
  129. package/templates/runner/src/render/clouds.ts +3 -1
  130. package/templates/runner/src/render/materials.ts +3 -2
  131. package/templates/runner/src/render/touch-controls.ts +7 -6
  132. package/templates/runner/src/scenes/Run.ts +4 -9
  133. package/templates/sailing/package.json +7 -7
  134. package/templates/sailing/src/render/touch-controls.ts +7 -6
  135. package/templates/shooter/package.json +7 -7
  136. package/templates/shooter/src/render/clouds.ts +3 -1
  137. package/templates/snow/package.json +7 -7
  138. package/templates/snow/src/entities/Explorer.ts +6 -12
  139. package/templates/snow/src/render/bootPrint.ts +3 -1
  140. package/templates/snow/src/render/camera.ts +3 -2
  141. package/templates/snow/src/render/scenery.ts +3 -3
  142. package/templates/snow/src/render/touch-controls.ts +7 -6
  143. package/templates/snow/src/render/weather.ts +3 -5
  144. package/templates/snow/src/terrain.ts +2 -1
  145. package/templates/starter/native-playtests/render-chain.playtest.json +9 -9
  146. package/templates/starter/package.json +7 -7
  147. package/templates/starter/src/entities/Player.ts +10 -2
  148. package/templates/starter/src/render/camera.ts +2 -2
  149. package/templates/starter/src/render/clouds.ts +3 -1
  150. package/templates/starter/src/render/materials.ts +3 -2
  151. package/templates/starter/src/render/touch-controls.ts +7 -6
  152. package/templates/starter/src/scenes/Play.ts +1 -14
  153. package/templates/tower-defense/package.json +7 -7
  154. package/templates/tower-defense/src/render/shapes.ts +1 -2
  155. package/templates/tower-defense/src/scenes/Battle.ts +3 -8
  156. package/template-assets/terrain/alpine/assets.json +0 -12
  157. package/template-assets/terrain/alpine/bake.mjs +0 -6
  158. package/template-assets/terrain/alpine/credits.json +0 -164
  159. package/template-assets/terrain/alpine/heightmap.r16 +0 -0
  160. package/template-assets/terrain/alpine/recipe.json +0 -119
  161. package/template-assets/terrain/alpine/surface.json +0 -53
  162. package/template-assets/terrain/coastal/assets.json +0 -11
  163. package/template-assets/terrain/coastal/bake.mjs +0 -6
  164. package/template-assets/terrain/coastal/credits.json +0 -117
  165. package/template-assets/terrain/coastal/heightmap.r16 +0 -0
  166. package/template-assets/terrain/coastal/recipe.json +0 -113
  167. package/template-assets/terrain/coastal/surface.json +0 -41
  168. package/template-assets/terrain/desert/assets.json +0 -12
  169. package/template-assets/terrain/desert/bake.mjs +0 -6
  170. package/template-assets/terrain/desert/credits.json +0 -164
  171. package/template-assets/terrain/desert/heightmap.r16 +0 -0
  172. package/template-assets/terrain/desert/recipe.json +0 -108
  173. package/template-assets/terrain/desert/surface.json +0 -54
  174. package/template-assets/terrain/forest/assets.json +0 -65
  175. package/template-assets/terrain/forest/bake.mjs +0 -8
  176. package/template-assets/terrain/forest/credits.json +0 -225
  177. package/template-assets/terrain/forest/heightmap.r16 +0 -0
  178. package/template-assets/terrain/forest/recipe.json +0 -350
  179. package/template-assets/terrain/forest/surface.json +0 -79
  180. package/template-assets/terrain/tundra/assets.json +0 -12
  181. package/template-assets/terrain/tundra/bake.mjs +0 -6
  182. package/template-assets/terrain/tundra/credits.json +0 -164
  183. package/template-assets/terrain/tundra/heightmap.r16 +0 -0
  184. package/template-assets/terrain/tundra/recipe.json +0 -277
  185. package/template-assets/terrain/tundra/surface.json +0 -54
  186. package/templates/racing/src/ui/Menu.tsx +0 -7
package/dist/quality.js CHANGED
@@ -166368,6 +166368,7 @@ var import_parser = __toESM(require_dist9());
166368
166368
 
166369
166369
  // src/quality/hotCallbacks.ts
166370
166370
  var FRAME_METHODS = /* @__PURE__ */ new Set(["render", "update"]);
166371
+ var ENTITY_FRAME_METHODS = /* @__PURE__ */ new Set(["fixedUpdate", "step", "tick", "update"]);
166371
166372
  var FRAME_HOOKS = /* @__PURE__ */ new Map([
166372
166373
  ["afterPhysics", "ctx.afterPhysics"],
166373
166374
  ["beforeRender", "ctx.beforeRender"],
@@ -166402,16 +166403,25 @@ function hookName(parent, node) {
166402
166403
  const name = calleeMember(parent, node);
166403
166404
  return name === void 0 ? void 0 : FRAME_HOOKS.get(name);
166404
166405
  }
166406
+ function methodLabel(parent, sceneLocals) {
166407
+ if (parent.type !== "MethodDefinition" || parent.static || parent.key.type !== "Identifier")
166408
+ return void 0;
166409
+ const owner = parent.parent?.parent ?? void 0;
166410
+ const base = owner?.superClass;
166411
+ const isSceneBase = base?.type === "Identifier" && sceneLocals.has(base.name);
166412
+ if (isSceneBase)
166413
+ return FRAME_METHODS.has(parent.key.name) ? `Scene.${parent.key.name}` : void 0;
166414
+ if (!ENTITY_FRAME_METHODS.has(parent.key.name)) return void 0;
166415
+ const className2 = owner?.id?.name;
166416
+ return className2 === void 0 ? parent.key.name : `${className2}.${parent.key.name}`;
166417
+ }
166405
166418
  function trackHotCallbacks() {
166406
166419
  const sceneLocals = /* @__PURE__ */ new Set();
166407
166420
  const frames = [];
166408
166421
  const frameName = (node) => {
166409
166422
  const parent = node.parent;
166410
- if (parent.type === "MethodDefinition" && !parent.static && parent.key.type === "Identifier") {
166411
- const base = parent.parent?.parent?.superClass;
166412
- const isSceneBase = base?.type === "Identifier" && sceneLocals.has(base.name);
166413
- if (isSceneBase && FRAME_METHODS.has(parent.key.name)) return `Scene.${parent.key.name}`;
166414
- }
166423
+ const method = methodLabel(parent, sceneLocals);
166424
+ if (method !== void 0) return method;
166415
166425
  const hook = hookName(parent, node);
166416
166426
  if (hook !== void 0) return hook;
166417
166427
  const member = calleeMember(parent, node);
@@ -166634,6 +166644,64 @@ var threenativePlugin = {
166634
166644
  }
166635
166645
  };
166636
166646
 
166647
+ // src/quality/reinventions.ts
166648
+ var PRNG_OUTSIDE = ["src/audio.ts", "src/audio/**", "src/render/**", "src/ui/**"];
166649
+ var REINVENTIONS = [
166650
+ {
166651
+ selector: ':matches(CallExpression[callee.object.name="Math"][callee.property.name="random"], Literal[value=1664525], Literal[value=1013904223], Literal[value=1831565813])',
166652
+ capability: "createRandom",
166653
+ source: "core",
166654
+ outside: PRNG_OUTSIDE,
166655
+ message: "A hand-written PRNG (Math.random or the LCG constants) is a capability the engine ships: use `createRandom(seed)` from `@threenative/core`, or `ctx.random`, so the same seed replays the same game."
166656
+ },
166657
+ {
166658
+ selector: 'BinaryExpression[operator="-"][left.value=1][right.callee.object.name="Math"][right.callee.property.name="exp"]',
166659
+ capability: "MathUtils.damp",
166660
+ source: "three",
166661
+ message: "`1 - Math.exp(-\u2026)` is a damp factor the engine ships: use `MathUtils.damp(current, target, rate, dt)` from `three`, which is the same curve with the rate named."
166662
+ },
166663
+ {
166664
+ selector: ':matches(MemberExpression[object.name="location"][property.name="search"], MemberExpression[object.property.name="location"][property.name="search"])',
166665
+ capability: "debugFlag",
166666
+ source: "core",
166667
+ message: "Reading `location.search` by hand is a launch seam the engine owns: use `debugFlag(name)` or `debugValue(name)` from `@threenative/core` (`?name` on web, `TN_DEBUG_NAME` on native)."
166668
+ },
166669
+ {
166670
+ selector: 'AssignmentExpression[left.property.name="matrixWorldAutoUpdate"][right.value=false]',
166671
+ capability: "renderer.matrixWorld",
166672
+ source: "core",
166673
+ message: "Turning `matrixWorldAutoUpdate` off by hand is the engine's own walk: set `renderer.matrixWorld` in the game config for a whole scene, or `markStatic(node)` for one node that never moves."
166674
+ },
166675
+ {
166676
+ selector: 'BinaryExpression[operator="-"][left.type="ConditionalExpression"][left.consequent.value=1][left.alternate.value=0][right.type="ConditionalExpression"][right.consequent.value=1][right.alternate.value=0]',
166677
+ capability: "InputMap.axis",
166678
+ source: "core",
166679
+ message: "An axis built from raw keys is a binding the engine already reads: declare it in `defineGame({ input })` and use `ctx.input.axis(name)` from `@threenative/core`."
166680
+ },
166681
+ {
166682
+ selector: 'BinaryExpression[operator="*"][right.type="BinaryExpression"][right.operator="-"][right.left.value=3][right.right.type="BinaryExpression"][right.right.operator="*"][right.right.left.value=2]',
166683
+ capability: "MathUtils.smoothstep",
166684
+ source: "three",
166685
+ message: "`x * x * (3 - 2 * x)` is the engine's smoothstep: use `MathUtils.smoothstep(x, 0, 1)` from `three`, which clamps the same way."
166686
+ }
166687
+ ];
166688
+ function reinventionRules(rows) {
166689
+ return {
166690
+ "no-restricted-syntax": [
166691
+ "error",
166692
+ ...rows.map(({ selector, message }) => ({ selector, message }))
166693
+ ]
166694
+ };
166695
+ }
166696
+ function reinventionConfigs(files) {
166697
+ const always = REINVENTIONS.filter((row) => row.outside === void 0);
166698
+ const ignores = [...new Set(REINVENTIONS.flatMap((row) => row.outside ?? []))];
166699
+ return [
166700
+ { files: [...files], rules: reinventionRules(always) },
166701
+ { files: [...files], ignores, rules: reinventionRules(REINVENTIONS) }
166702
+ ];
166703
+ }
166704
+
166637
166705
  // src/quality/index.ts
166638
166706
  var asPlugin = (plugin) => plugin;
166639
166707
  var SOURCE = ["src/**/*.ts", "src/**/*.tsx"];
@@ -166641,7 +166709,7 @@ function hasReact(root) {
166641
166709
  const manifest = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));
166642
166710
  return ["dependencies", "devDependencies"].some((field) => manifest[field]?.react !== void 0);
166643
166711
  }
166644
- function qualityConfig({ root }) {
166712
+ function qualityConfig({ root, reinventions = false }) {
166645
166713
  const config = [
166646
166714
  { ignores: ["**/node_modules/**", "**/dist/**", "**/.threenative/**", "**/dist-native/**"] },
166647
166715
  {
@@ -166675,6 +166743,7 @@ function qualityConfig({ root }) {
166675
166743
  }
166676
166744
  }
166677
166745
  ];
166746
+ if (reinventions) config.push(...reinventionConfigs(SOURCE));
166678
166747
  if (hasReact(root)) {
166679
166748
  config.push({
166680
166749
  files: ["src/**/*.tsx"],
@@ -4,7 +4,7 @@ import path from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
 
6
6
  createRequire(import.meta.url);
7
- var KITS = ["alpine", "coastal", "desert", "forest", "tundra"];
7
+ var KITS = ["alpine", "coastal", "desert", "tundra"];
8
8
  var COPIED = [
9
9
  "assets.json",
10
10
  "bake.mjs",
@@ -2708,6 +2708,8 @@ async function buildEngineDesktop(cwd, config, entry) {
2708
2708
  config.window.title,
2709
2709
  "--priority",
2710
2710
  config.display.priority,
2711
+ "--fullscreen",
2712
+ String(config.display.fullscreen),
2711
2713
  "--output",
2712
2714
  output
2713
2715
  ]);
@@ -3267,11 +3269,11 @@ var MCP_SERVERS = Object.freeze({
3267
3269
  })
3268
3270
  });
3269
3271
  var MCP_PACKAGES = Object.freeze({
3270
- assets: Object.freeze({ name: "threenative-asset-mcp", version: "0.16.0" }),
3271
- terrain: Object.freeze({ name: "@threenative/terrain", version: "0.1.9" }),
3272
+ assets: Object.freeze({ name: "threenative-asset-mcp", version: "0.17.0" }),
3273
+ terrain: Object.freeze({ name: "@threenative/terrain", version: "0.1.12" }),
3272
3274
  sculpt: Object.freeze({ name: "threenative-sculpt-mcp", version: "0.2.2" }),
3273
- engine: Object.freeze({ name: "threenative-engine-mcp", version: "0.2.13" }),
3274
- animation: Object.freeze({ name: "threenative-animation-mcp", version: "0.1.10" }),
3275
+ engine: Object.freeze({ name: "threenative-engine-mcp", version: "0.2.16" }),
3276
+ animation: Object.freeze({ name: "threenative-animation-mcp", version: "0.1.13" }),
3275
3277
  // `args` fixes the launch for every host. The Chrome flags are `WEBGPU_BROWSER_ARGS` from
3276
3278
  // `@threenative/playtest`, so a DevTools trace profiles the same adapter a playtest does and not
3277
3279
  // SwiftShader. An isolated profile keeps the user's own Chrome profile out, and the two opt-outs
@@ -3385,7 +3387,7 @@ var MCP_HOSTS = Object.freeze([
3385
3387
  ]);
3386
3388
 
3387
3389
  // ../core/src/version.ts
3388
- var CORE_VERSION = "0.3.13";
3390
+ var CORE_VERSION = "0.3.16";
3389
3391
 
3390
3392
  // src/mcp-servers.ts
3391
3393
  var CORE_PACKAGE_NAME = "@threenative/core";
@@ -616,6 +616,9 @@ function defineScreenSpaceGi(tsl) {
616
616
  const fallback = options.fallback?.(position, direction, normal) ?? vec3(0, 0, 0);
617
617
  gathered.assign(gathered.add(hit.radiance.sub(fallback).mul(hit.weight)));
618
618
  hits.assign(hits.add(hit.weight));
619
+ }).Else(() => {
620
+ const past = options.miss?.(position, direction, normal);
621
+ if (past !== void 0) gathered.assign(gathered.add(past));
619
622
  });
620
623
  }
621
624
  );
@@ -715,6 +718,9 @@ function defineScreenProbes(tsl, input) {
715
718
  const hit = shade(trace.hitCoordinate, trace.hitDistance, direction);
716
719
  const believed = options.fallback?.(position, direction, normal) ?? vec3(0, 0, 0);
717
720
  result.assign(vec4(hit.radiance.sub(believed).mul(hit.weight), hit.weight));
721
+ }).Else(() => {
722
+ const past = options.miss?.(position, direction, normal);
723
+ if (past !== void 0) result.assign(vec4(past, 0));
718
724
  });
719
725
  });
720
726
  return result;