threedog 2.0.0 → 2.1.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/core/assets/assetEntry.js +1 -1
  3. package/core/assets/assetPart.js +1 -1
  4. package/core/base/events.generated.js +1 -2
  5. package/core/engine/Engine.js +9 -5
  6. package/core/engine/copies.js +1 -1
  7. package/core/engine/modules.js +4 -4
  8. package/core/engine/services.js +5 -4
  9. package/core/inspect/DebugOverrides.js +2 -2
  10. package/core/inspect/describeRender.js +0 -7
  11. package/core/inspect/metadata.generated.js +106 -36
  12. package/core/inspect/pictureChecks.js +2 -27
  13. package/core/ops/sharedPoint.js +11 -2
  14. package/core/saves/saveApply.js +1 -1
  15. package/core/scene/adaptive.js +3 -2
  16. package/core/scene/pixelRatio.js +39 -17
  17. package/core/scene/sceneMethods.js +1 -1
  18. package/core/scene/tier.js +2 -33
  19. package/core/scene/view.js +14 -0
  20. package/core/time/skip.js +1 -1
  21. package/docs/CODEMAP.md +3 -3
  22. package/docs/api/ambience.md +2 -2
  23. package/docs/api/cameraRig.md +7 -0
  24. package/docs/api/engine.md +1 -1
  25. package/docs/api/events.md +1 -2
  26. package/docs/api/photo.md +5 -0
  27. package/docs/api/sky.md +10 -0
  28. package/docs/api/terrain.md +19 -0
  29. package/docs/api/tools.md +1 -1
  30. package/docs/recipes/05-props-bake.md +1 -1
  31. package/docs/recipes/07-flow-scenes-pause.md +3 -3
  32. package/docs/recipes/09-materials-lights-models.md +1 -1
  33. package/docs/recipes/14-custom-module.md +1 -1
  34. package/docs/recipes/15-perf.md +1 -1
  35. package/docs/recipes/16-dev-bridge.md +1 -1
  36. package/docs/recipes/18-world.md +1 -1
  37. package/docs/recipes/26-ui-parts.md +2 -2
  38. package/docs/recipes/40-scene.md +1 -1
  39. package/docs/recipes/51-capability-catalog.md +1 -1
  40. package/docs/recipes/52-around-the-picture.md +2 -2
  41. package/docs/recipes/55-mods-time-wrap.md +3 -3
  42. package/docs/recipes/57-control.md +1 -1
  43. package/docs/recipes/59-depth-post-effects.md +1 -1
  44. package/docs/recipes/60-judge-the-picture.md +5 -5
  45. package/examples/techniques/interior-light/README.md +1 -1
  46. package/examples/techniques/night-lights/README.md +1 -1
  47. package/examples/techniques/outlines-and-rim/README.md +1 -1
  48. package/examples/techniques/procedural-animation/README.md +1 -1
  49. package/examples/techniques/procedural-surface/README.md +1 -1
  50. package/examples/techniques/wet-road/README.md +1 -1
  51. package/modules/camera/contract.js +1 -1
  52. package/modules/characters/mover.contract.js +1 -1
  53. package/modules/characters/movers/rapier.js +7 -9
  54. package/modules/characters/player.js +1 -1
  55. package/modules/collision/Collision.js +1 -1
  56. package/modules/collision/grid.js +1 -1
  57. package/modules/content/index.js +2 -2
  58. package/modules/content/models.js +1 -1
  59. package/modules/flow/index.js +3 -3
  60. package/modules/gameplay/inventory.contract.js +1 -1
  61. package/modules/grid/tiles.js +6 -3
  62. package/modules/level/contract.js +2 -2
  63. package/modules/particles/Particles.js +1 -2
  64. package/modules/photo/pathTrace.js +1 -1
  65. package/modules/rigid/RigidBodies.js +13 -0
  66. package/modules/rigid/ragdoll.js +1 -1
  67. package/modules/settings/Settings.js +3 -2
  68. package/modules/settings/apply.js +4 -3
  69. package/modules/settings/sections.js +1 -1
  70. package/modules/sky/environment.js +1 -1
  71. package/modules/terrain/index.js +1 -2
  72. package/modules/timeline/Timeline.js +8 -4
  73. package/modules/vegetation/Vegetation.js +1 -1
  74. package/modules/vegetation/index.js +1 -1
  75. package/modules/weather/weatherDraw.js +1 -2
  76. package/package.json +1 -1
  77. package/render/PostFX.js +7 -7
  78. package/render/lightmap.js +1 -1
  79. package/render/lights.js +1 -2
  80. package/render/neutral.js +1 -1
  81. package/render/patches.js +3 -3
  82. package/render/probes.js +27 -2
  83. package/render/shaderErrors.js +1 -1
  84. package/render/shadows.js +1 -3
  85. package/types/core.d.ts +2 -4
  86. package/types/gameplay.d.ts +7 -2
  87. package/types/generated/ui/UI.d.ts +2 -1
  88. package/types/world.d.ts +4 -2
  89. package/ui/UI.js +18 -14
  90. package/ui/cursor.js +2 -2
  91. package/examples/action/.threedog/content-index.json +0 -1
  92. package/examples/perf-island/.threedog/content-index.json +0 -1
  93. package/examples/plain-picture/.threedog/content-index.json +0 -1
  94. package/examples/rc2d/.threedog/content-index.json +0 -1
  95. package/examples/styletest/.threedog/content-index.json +0 -1
  96. package/examples/webgpu-tsl/.threedog/content-index.json +0 -1
  97. package/examples/world/.threedog/content-index.json +0 -1
@@ -76,4 +76,4 @@ Sources: written for this example; no code copied. Background: distance-driven g
76
76
  stretch are common practice (David Rosen, "An Indie Approach to Procedural Animation", GDC 2014; the squash-and-stretch principle from
77
77
  Thomas and Johnston, *The Illusion of Life*, 1981).
78
78
 
79
- This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). A game on the default WebGPU route writes the same ideas in TSL (recipe 56).
79
+ This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). TSL version: recipe 56.
@@ -66,4 +66,4 @@ Rules (correctness):
66
66
  Sources: triplanar mapping as commonly described (Ben Golus, "Normal Mapping for a Triplanar Shader", 2017); vertex AO and edge wear as
67
67
  standard game-art practice. Code written for this engine; nothing copied.
68
68
 
69
- This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). A game on the default WebGPU route writes the same ideas in TSL (recipe 56).
69
+ This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). TSL version: recipe 56.
@@ -99,4 +99,4 @@ Sources: written for this example; no code copied. Background: the mirror-image
99
99
  the common darken + lower-roughness approach discussed in Sébastien Lagarde, "Water drop 2a / 2b – Dynamic rain and its effects" (2013);
100
100
  `Reflector` and SSR as found in the three.js examples (`webgl_mirror`, `webgl_postprocessing_ssr`).
101
101
 
102
- This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). A game on the default WebGPU route writes the same ideas in TSL (recipe 56).
102
+ This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). TSL version: recipe 56.
@@ -9,7 +9,7 @@ export default {
9
9
  fields: ['target'], // what follow() follows: a ragdoll checks it before borrowing the camera, and leaves a camera the game moved elsewhere
10
10
  ops: [],
11
11
  events: [],
12
- saves: {},
12
+ saves: { cameraRig: 1 },
13
13
  describe: true,
14
14
  options: {},
15
15
  probe: { setup: [], emits: [], state: null },
@@ -10,5 +10,5 @@ export default {
10
10
  api: ['move'],
11
11
  fields: ['name'],
12
12
  position: { authority: 'solver', writers: { mover: 'move() writes character.root.position while the holder of the control slot drives it; it writes no record' } },
13
- optional: { dispose: v => typeof v === 'function', leave: v => typeof v === 'function' },
13
+ optional: { dispose: v => typeof v === 'function', leave: v => typeof v === 'function', collider: v => typeof v === 'object', world: v => typeof v === 'object' },
14
14
  };
@@ -6,6 +6,7 @@ import { steer, water, float, tryJump, tickJump, leaveGround, land, finish, stat
6
6
  import { beginMove, endMove } from './support.js';
7
7
  import { passesThrough } from '../../collision/grid.js';
8
8
  import { warnOnce, DEV } from '../../../core/base/validate.js';
9
+ import { coded } from '../../../core/base/errorHints.js';
9
10
 
10
11
  /** Create the 'rapier' mover (c is the character, fallback is the simple mover used when not ready) */
11
12
  export function rapierMover(c, fallback) {
@@ -13,6 +14,7 @@ export function rapierMover(c, fallback) {
13
14
  name: 'rapier', controller: null, body: null, collider: null,
14
15
  move(dirX, dirZ, run, dt) {
15
16
  const e = c.engine, r = e.rigid, p = c.root.position;
17
+ if (!r && e.ready && DEV) warnOnce(coded('module-requires', "character mover 'rapier' needs the rigid module: without it this character walks with the simple mover. Fix: engine.use(collision(), rigid())"));
16
18
  if (!r?.ready || !r.readyAt(p)) return fallback.move(dirX, dirZ, run, dt);
17
19
  const fresh = !m.controller || m.world !== r.world; // another world (newGame / load rebuilt it, a replaced rigid brought its own): the old controller went with the old one
18
20
  if (fresh) setup(e, r);
@@ -34,8 +36,8 @@ export function rapierMover(c, fallback) {
34
36
  else { c.vy += stat(c, 'gravity') * dt; dy = c.vy * dt; }
35
37
  }
36
38
  const wasGrounded = c.grounded;
37
- // a collision-module collider with a layer this body passes is skipped (the same passesThrough the simple mover and paths use); no layers anywhere: no predicate, as before
38
- const through = c.passes && r._layered.size ? m.through : undefined;
39
+ // a collision-module collider with a layer this body passes is skipped (the same passesThrough the simple mover and paths use); no layers anywhere: no predicate
40
+ const through = c.passes && r.layered ? m.through : undefined;
39
41
  m.controller.computeColliderMovement(col, { x: (c.velocity.x + (inh?.x ?? 0)) * dt, y: dy, z: (c.velocity.y + (inh?.y ?? 0)) * dt }, r.rapier.QueryFilterFlags.EXCLUDE_DYNAMIC | r.rapier.QueryFilterFlags.EXCLUDE_SENSORS, undefined, through);
40
42
  const mv = m.controller.computedMovement();
41
43
  p.x += mv.x; p.y += mv.y; p.z += mv.z;
@@ -75,16 +77,12 @@ export function rapierMover(c, fallback) {
75
77
  const R = r.rapier, w = r.world, p = c.root.position;
76
78
  m.world = w; // what the handles below belong to: the world object itself, since a count would match across two rigid modules
77
79
  // built with the controller: a replaced rigid keeps its layered colliders in its own map, and a test kept from the first one would read every collider as "no layer"
78
- m.through = hit => { const o = r._layered.get(hit); return !(o && passesThrough(o, c.passes)); };
80
+ m.through = hit => { const o = r.layerOf(hit); return !(o && passesThrough(o, c.passes)); };
79
81
  if (c === e.player) {
80
82
  m.body = r.playerBody; m.collider = r.playerCollider;
81
83
  // the capsule is the character's radius (as for every other character, and for simple movers and paths), unless the game set rigid({ playerCapsule: { radius } }): that wins.
82
- // Written back, so a rebuilt world (rigid _newWorld) makes the same capsule
83
- if (r._capsuleRadiusGiven) { if (DEV && c.radius !== r.playerCapsule.radius) warnOnce(`rigid({ playerCapsule: { radius: ${r.playerCapsule.radius} } }) differs from the player's radius ${c.radius}: the rapier collider uses ${r.playerCapsule.radius}, paths and the simple mover ${c.radius}. Set one of them, or make them equal`); }
84
- else if (c.radius !== r.playerCapsule.radius) {
85
- r.playerCapsule = { ...r.playerCapsule, radius: c.radius };
86
- m.collider.setRadius(c.radius); m.collider.setTranslationWrtParent({ x: 0, y: r.playerCapsule.halfHeight + c.radius, z: 0 });
87
- }
84
+ const used = r.fitPlayerCapsule(c.radius);
85
+ if (DEV && used !== c.radius) warnOnce(`rigid({ playerCapsule: { radius: ${used} } }) differs from the player's radius ${c.radius}: the rapier collider uses ${used}, paths and the simple mover ${c.radius}. Set one of them, or make them equal`);
88
86
  }
89
87
  else {
90
88
  const hh = r.playerCapsule.halfHeight;
@@ -8,7 +8,7 @@ import { DEV_STRINGS, validControl } from './playerStrings.js';
8
8
  import { vehicleById, seatFromRecord } from './seat.js';
9
9
 
10
10
  /** The player's world record: its id and its kind */
11
- export const PLAYER = 'player';
11
+ const PLAYER = 'player';
12
12
 
13
13
  /** Everything addPlayer refuses, before it touches the old player */
14
14
  function checkOptions(e, st, opts) {
@@ -22,7 +22,7 @@ function slab(S, o, d, h) {
22
22
 
23
23
  const BOX_KEYS = ['halfWidth', 'halfDepth', 'rotation', 'height', 'y', 'occluder', 'layer'], CIRCLE_KEYS = ['radius', 'height', 'occluder', 'layer'], SEG_KEYS = ['thickness', 'height', 'y', 'occluder', 'layer'], BLOCK_KEYS = ['bounds'];
24
24
 
25
- /** A collider's layer option: one name, or undefined for "stops every mover" (what every collider did before layers) */
25
+ /** A collider's layer option: one name, or undefined for "stops every mover" */
26
26
  function layerOf(where, v) {
27
27
  if (v === undefined || (typeof v === 'string' && v)) return v;
28
28
  throw codedError('collision-misuse', `${where}: layer is one name, e.g. { layer: 'gate' } (movers with passes: ['gate'] go through it, every other mover is stopped); got ${JSON.stringify(v)}`, TypeError);
@@ -8,7 +8,7 @@ const CELL = 8, MAX_CELLS = 64, KEY = 1048576; // colliders too large (coverin
8
8
  export const bodyHits = (it, y, body) => !(y >= it.y + it.h || y + body <= it.y);
9
9
  /**
10
10
  * A mover's passes option (character option; findPath, findPathAsync and walkable option): the collider layers it goes through. Read here for every entry,
11
- * sorted and without repeats so one set is one navmesh, never two. Left out or empty: undefined, which every reader takes as "stopped by everything", as before
11
+ * sorted and without repeats so one set is one navmesh, never two. Left out or empty: undefined, which every reader takes as "stopped by everything"
12
12
  */
13
13
  export function passesOf(where, v) {
14
14
  if (v === undefined || v === null) return undefined;
@@ -100,7 +100,7 @@ function contentApi(st) {
100
100
  return done;
101
101
  },
102
102
  /**
103
- * @internal modules a replaces installed fresh, or a failed one put back ('module:restored'): their sections get every pack again, one load each as they came. A fresh install has
103
+ * @internal modules a replaces installed fresh, or a failed one put back ('module:fresh'): their sections get every pack again, one load each as they came. A fresh install has
104
104
  * none of it. A section's format is its holder's, so a newcomer may refuse what was written for the old one: no line of the game asked for this load, so it is told, not thrown
105
105
  */
106
106
  _replay(mods) {
@@ -227,7 +227,7 @@ export function content() {
227
227
  ctx.saves.define('content', { ...marksPart(api, st), atomic: true });
228
228
  for (const holder of ['collision', 'collider3d']) ctx.feeds(holder, () => refit(e));
229
229
  ctx.track(e.events.on('engine:ready', () => { checkOps(e, st); checkRefs(st); }));
230
- ctx.track(e.events.on('module:restored', ({ modules }) => api._replay(modules)));
230
+ ctx.track(e.events.on('module:fresh', ({ modules }) => api._replay(modules)));
231
231
  ctx.track({ remove: () => { for (const m of api.markers.values()) m.remove(); api.markers.clear(); } }); // the marks stay in st.marks and the save part; only what is on screen goes
232
232
  st.checkOps = () => { if (e.ready) checkOps(e, st); };
233
233
  return api;
@@ -36,7 +36,7 @@ function partsOf(root, frame) {
36
36
  * Cached per prototype by the parts themselves (geometry and matrix): copies whose setup only swapped materials share the prototype's base, while a setup that
37
37
  * thickened the trunk under the same crown gets its own. Overall bounds would not tell those two apart. @internal
38
38
  */
39
- export function baseOf(m) {
39
+ function baseOf(m) {
40
40
  if (m.base) return m.base;
41
41
  if (!m.parts) { m.obj.updateMatrix(); m.parts = partsOf(m.obj, m.obj.matrix.clone()); } // a prototype: never placed, its root matrix is its frame
42
42
  const cache = ((m.owner ?? m).bases ??= new Map());
@@ -74,7 +74,7 @@ export function flow(opts = {}) {
74
74
  const lock = lockInput ? e.input.push('transition') : null;
75
75
  let shown = false, turn = null;
76
76
  try {
77
- await fadeScreen(e, 1, { seconds: fade });
77
+ await fadeScreen(e, 1, { seconds: fade, owner: 'flow' });
78
78
  if (sig?.aborted || await gone()) return; // unloaded, or the state replaced, during the fade: no scene swap for what is gone (the finally gives the screen and input back)
79
79
  const m = music === 'fade' ? e.music : null, prev = m?.current;
80
80
  m?.stop({ fade });
@@ -84,10 +84,10 @@ export function flow(opts = {}) {
84
84
  await whenSettled(e, undefined, true);
85
85
  if (sig?.aborted) return;
86
86
  if (m && prev && !m.current && !m.ruled && !replaced()) m.play(prev); // no track rule: resume the previous track after the switch. A new game or load has its own music, however fn started it; a level load nobody awaited is still this playthrough
87
- await fadeScreen(e, 0, { seconds: fade });
87
+ await fadeScreen(e, 0, { seconds: fade, owner: 'flow' });
88
88
  shown = true;
89
89
  } finally {
90
- if (!shown) fadeScreen(e, 0, { seconds: 0 }); // fn threw: don't leave the screen black, fade back in at once (the error still propagates to the caller)
90
+ if (!shown) fadeScreen(e, 0, { seconds: 0, owner: 'flow' }); // fn threw: don't leave the screen black, fade back in at once (the error still propagates to the caller)
91
91
  turn?.remove();
92
92
  lock?.remove();
93
93
  api.transitioning = false;
@@ -11,7 +11,7 @@ export default {
11
11
  'contents', 'setContents', 'renameIds'], // contents / setContents: net syncs containers through these; renameIds: content renames move goods
12
12
  ops: ['inventory.transfer', 'inventory.trade', 'inventory.use', 'inventory.drop'],
13
13
  events: ['item:add', 'item:remove', 'item:use'], // item:add / item:remove carry { container, actor } for every container
14
- saves: { inventory: 1 },
14
+ saves: { inventory: 1, containers: 2 },
15
15
  describe: true,
16
16
  options: {},
17
17
  probe: {
@@ -1,13 +1,14 @@
1
1
  // Crisp per-cell tiles for a layer (a painted floor, a buildable zone, tilled soil): one mesh per layer, each non-empty cell a quad
2
2
  // whose four corners sit on engine.surface + lift, so tiles hug a ramp or terrain and work on any ground provider
3
3
  // (procedural terrain, a Blender level, a flat greenhouse floor). One merged mesh = one draw call; it is rebuilt only when
4
- // the layer version or the ground (level:loaded, a terrain edit's ground:change) changes.
4
+ // the layer version or the ground changes: another ground provider (a level, or engine.setGround) or a terrain edit's ground:change.
5
5
  // Picture: layer option tiles.color(data, cell) -> color | null, else tiles.colors = { field: color }, else the module's table grids({ tiles: { layer: { field: color } } })
6
6
  // (first truthy field in the table's order wins), else neutral gray. tiles: false = off; a function = your own part. layer.material is the three.js material they draw with.
7
7
  import * as THREE from 'three';
8
8
  import { neutralMaterial } from '../../render/neutral.js';
9
9
  import { surfaceOr } from '../../core/scene/ground.js';
10
10
  import { readParams, keysSchema } from '../../core/base/params.js';
11
+ import { follows } from '../../core/base/follows.js';
11
12
 
12
13
  const GAP = 0.03; // fraction of a cell left between tiles: keeps tiles visibly separate (crisp edges)
13
14
  const FALLBACK = 0x9a9a9a;
@@ -34,7 +35,8 @@ export function layerTiles(e, layer, st) {
34
35
  mesh.name = `grid:${layer.grid.name}.${name}`; mesh.receiveShadow = true; mesh.frustumCulled = false;
35
36
  e.add(mesh, { owner: 'engine:grid' });
36
37
  let ver = -1, ground = 0, built = -1;
37
- const offs = ['level:loaded', 'level:unloaded', 'ground:change'].map(n => e.events.on(n, () => { ground++; })); // new ground heights: a level came or left, or dug / raised terrain
38
+ const off = e.events.on('ground:change', () => { ground++; }); // dug / raised terrain: the same ground, new heights
39
+ const src = follows(() => e.ground, G => G.staticVersion?.()); // another ground provider (a level came or left, setGround): the same check the ground chunks use
38
40
  const col = new THREE.Color(), g = layer.grid;
39
41
  function rebuild() {
40
42
  const cells = layer.query(), pos = [], clr = [], idx = [];
@@ -59,9 +61,10 @@ export function layerTiles(e, layer, st) {
59
61
  mesh,
60
62
  frame() {
61
63
  mesh.visible = e.world?.inZone(g) ?? true;
64
+ if (src.sync(() => {})) ground++;
62
65
  if (layer._ver !== ver || ground !== built) { ver = layer._ver; built = ground; rebuild(); }
63
66
  },
64
- dispose() { for (const o of offs) o.remove(); mesh.material = own; e.remove(mesh); }, // one free through e.remove (design 6.2): the part's own geometry and material go with it; a material the game set is taken off first, so it stays the game's
67
+ dispose() { off.remove(); mesh.material = own; e.remove(mesh); }, // one free through e.remove (design 6.2): the part's own geometry and material go with it; a material the game set is taken off first, so it stays the game's
65
68
  };
66
69
  }
67
70
 
@@ -2,14 +2,14 @@
2
2
  // Exactly what other code reads from engine.level: marker(name) (content places, the HUD), track(handle) (a handle that goes when the level unloads),
3
3
  // load (a level change); root / ready (hlod), markers (triggers), heightfield (vegetation's area; null when there is none).
4
4
  // A replacement also claims provides: ['level', 'ground'] and gives the ground with ctx.ground.provide({ height, slope, type }) and emits 'level:loaded' after each load and 'level:unloaded' when a level leaves: nav and the path caches rebuild on
5
- // it (not exercised by the shared check: it needs a scene). A game with several levels registers a 'level' save with first: true, so the level is up before the player lands.
5
+ // it (not exercised by the shared check: it needs a scene). The module registers the 'level' save (first: true, so the level is up before the player lands); a replacement does the same or the contract fails.
6
6
  export default {
7
7
  name: 'level',
8
8
  api: ['marker', 'track', 'load'],
9
9
  fields: ['root', 'markers', 'ready', 'heightfield'],
10
10
  ops: [],
11
11
  events: ['level:loaded', 'level:unloaded', 'level:failed'],
12
- saves: {},
12
+ saves: { level: 1 },
13
13
  describe: true,
14
14
  options: {},
15
15
  probe: { setup: [], emits: [], state: null },
@@ -50,7 +50,6 @@ import { isOptions, isUnder } from '../../core/base/util.js';
50
50
  import { codedError } from '../../core/base/errorHints.js';
51
51
  import { borrowRenderer } from '../../render/backend.js';
52
52
  import { ParticleLights } from './lit.js';
53
- import { onTierChange } from '../../core/scene/tier.js';
54
53
  // one schema per public entry (unknown keys throw in dev with did-you-mean). Effect param values come in many shapes (number or [min, max], color), so most are only checked by key name
55
54
  const FX_PARAMS = keysSchema(KEYS, {}, {
56
55
  ratePerMeter: { type: 'number', optional: true, min: 0, desc: 'particles per meter the emitter moves' },
@@ -286,7 +285,7 @@ export function particles(opts = {}) {
286
285
  }
287
286
  if (opts.default) readFx('particles({ default })', opts.default);
288
287
  let p = null;
289
- return { name: 'particles', skipKind: 'none', type: 'picture', provides: ['particles'], label: 'Particles', params: PARTICLES_PARAMS, options: opts, stage: 'effects', install(e, ctx) { e.i18n.add({ 'zh-CN': { 'module.particles': '粒子' }, en: { 'module.particles': 'particles' } }); p = new Particles(e, opts); ctx.track(onTierChange(e, () => p._tierChanged())); return p; }, frame(dt) { p.update(dt); },
288
+ return { name: 'particles', skipKind: 'none', type: 'picture', provides: ['particles'], label: 'Particles', params: PARTICLES_PARAMS, options: opts, stage: 'effects', install(e, ctx) { e.i18n.add({ 'zh-CN': { 'module.particles': '粒子' }, en: { 'module.particles': 'particles' } }); p = new Particles(e, opts); ctx.track(e.stacks.get('tier').watch(() => p._tierChanged())); return p; }, frame(dt) { p.update(dt); },
290
289
  dispose() { for (const fx of p.effects.values()) fx.dispose(); p.effects.clear(); p.emitters.clear(); p._depth?.target.depthTexture.dispose(); p._depth?.target.dispose(); p._depth?.material.dispose(); },
291
290
  counts() { return { alive: p.count(), emitters: p.emitters.size }; }, // engine.counts().particles
292
291
  // "did the dust burst fire": live particles in total and per effect that has any (idle effects left out to stay short). Kept under `alive`
@@ -17,7 +17,7 @@ const SHOWN = 5; // the untraced list names this many, then "+N more": a line,
17
17
  /** What the tracer will not draw as the game does: it reads Standard / Physical fields by name (any other model becomes a plain Standard surface),
18
18
  * ignores TSL node slots (colorNode, positionNode…) and onBeforeCompile, needs normals, and traces meshes only (on WebGL one instance per InstancedMesh).
19
19
  * skip: the drawOnly parts traceSnapshot hides; each one's own words say what the photo lacks */
20
- export function untracedLine(scene, skip, gpu) {
20
+ function untracedLine(scene, skip, gpu) {
21
21
  const why = new Map(), flat = new Set(); let other = 0, inst = 0;
22
22
  scene.traverseVisible(o => {
23
23
  if (skip.includes(o)) return;
@@ -167,6 +167,19 @@ export class RigidBodies {
167
167
  for (const s of this._solids) this._buildSolid(s);
168
168
  }
169
169
 
170
+ /** @internal some collider has a collision layer: the rapier mover only builds its pass-through filter then */
171
+ get layered() { return this._layered.size > 0; }
172
+ /** @internal the collision-module data behind a collider that has a layer, or undefined */
173
+ layerOf(collider) { return this._layered.get(collider); }
174
+ /** @internal The rapier mover asks for the player capsule to follow the character's radius; a radius the game set in rigid({ playerCapsule }) wins. Returns the radius in use */
175
+ fitPlayerCapsule(radius) {
176
+ if (this._capsuleRadiusGiven || radius === this.playerCapsule.radius) return this.playerCapsule.radius;
177
+ // Written back, so a rebuilt world (_newWorld) makes the same capsule
178
+ this.playerCapsule = { ...this.playerCapsule, radius };
179
+ this.playerCollider.setRadius(radius); this.playerCollider.setTranslationWrtParent({ x: 0, y: this.playerCapsule.halfHeight + radius, z: 0 });
180
+ return radius;
181
+ }
182
+
170
183
  /** @internal Copies of what others own are current, as any read needs them. Every step runs it; a frozen engine runs no step, and queries still ask */
171
184
  _upkeep() { if (syncStatics(this) | syncLevel(this) | syncFloor(this) | dropChunks(this)) this._behind = true; }
172
185
  /**
@@ -264,7 +264,7 @@ export class Ragdolls {
264
264
  if (rd.anchor) this._anchor(rd);
265
265
  }
266
266
 
267
- /** End: tear down the physics and give every slot back to its owner. gone: the character no longer exists, nothing to give back; place: put the character where the body lies */
267
+ /** End: tear down the physics and give every slot back to its owner. gone: the character was already removed, nothing to give back; place: put the character where the body lies */
268
268
  _end(rd, gone = false, place = true) {
269
269
  if (!this.live.delete(rd)) return;
270
270
  const { ch, list, anim, anchor, hold } = rd;
@@ -41,7 +41,7 @@ import { applySetting, allowed, checkLimits, releaseLimits, releaseRow, ROLE_ROW
41
41
  import { readParams, keysSchema } from '../../core/base/params.js';
42
42
  import { codedError, coded } from '../../core/base/errorHints.js';
43
43
  import { warnOnce } from '../../core/base/validate.js';
44
- import { pixelSizeOn } from '../../core/scene/pixelRatio.js';
44
+ import { chooseRatio, pixelSizeOn } from '../../core/scene/pixelRatio.js';
45
45
  import { trackForModule } from '../../core/engine/moduleTypes.js';
46
46
 
47
47
  // Graphics presets. Values are performance steps, not art; a game can override with settings({ presets: { low: {...} } })
@@ -272,6 +272,7 @@ export class Settings extends SettingsView {
272
272
  if (!(k in this._values) || def(k) === undefined) { if (key !== undefined) warnOnce(`settings.reset('${k}'): no setting with this key (known: ${Object.keys(this._values).join(', ')})`); continue; }
273
273
  this.set(k, def(k), { save: false });
274
274
  if (!(k in preset)) delete this._changed[k];
275
+ if (k === 'pixelRatio') chooseRatio(this.engine, null); // a reset hands the ratio back to the game, also where a kept preset stores the default
275
276
  }
276
277
  this.save();
277
278
  }
@@ -373,7 +374,7 @@ export class Settings extends SettingsView {
373
374
  this._ready = true;
374
375
  const picked = this._picked(), e = this.engine;
375
376
  for (const k of this._early) if (!this._hasRow(k)) warnOnce(coded('settings-row', `settings.set('${k}') before start: no row came for this key, so nothing applied it`));
376
- // start() may have learned the real device on the WebGPU route and written its default ratio over the player's
377
+ // a preset's ratio is a share of the device default, which start() may have learned only now (the WebGPU route): worked out again from it
377
378
  this._defaults.pixelRatio = +e.adaptive.base.toFixed(2);
378
379
  this._values.pixelRatio = picked.pixelRatio ?? this._defaults.pixelRatio;
379
380
  if ('pixelRatio' in picked) this._apply('pixelRatio', picked.pixelRatio);
@@ -1,5 +1,6 @@
1
1
  import { reportError } from '../../core/base/errors.js';
2
2
  import { codedError } from '../../core/base/errorHints.js';
3
+ import { chooseRatio, topRatio } from '../../core/scene/pixelRatio.js';
3
4
  // Apply one setting to the engine (helper of Settings.js): the built-in keys (pixel ratio, shadows, post effects, quality tier, audio buses) and the rows of modules and of
4
5
  // the game (define). `s` is the Settings instance.
5
6
 
@@ -40,7 +41,7 @@ function limitRow(s, key, names, val) {
40
41
  /** @internal a row leaves: no control is left to lift its limits, so it gives back every shared value it holds @param {any} s @param {string} key */
41
42
  export function releaseRow(s, key) { for (const n of s._held.get(key) ?? []) lift(s.engine, n); s._held.delete(key); }
42
43
  /** @internal the module leaves: so does every row, and the tier it chose */
43
- export function releaseLimits(s) { for (const key of [...s._held.keys()]) releaseRow(s, key); lift(s.engine, 'tier'); }
44
+ export function releaseLimits(s) { for (const key of [...s._held.keys()]) releaseRow(s, key); lift(s.engine, 'tier'); chooseRatio(s.engine, null); }
44
45
  /** @internal the row's value fits the points it limits: a switch row (boolean) limits switches or numbers, a number row (a factor) only numbers */
45
46
  export function checkLimits(s, key, def, names) {
46
47
  const e = s.engine;
@@ -64,10 +65,10 @@ export function applySetting(s, key, val) {
64
65
  const limits = builtinLimits(e)[key] ?? s.custom.get(key)?.limits;
65
66
  if (limits) limitRow(s, key, limits, typeof val === 'number' ? val : !!val);
66
67
  switch (key) {
67
- case 'pixelRatio': e.setPixelRatio(val); break;
68
+ case 'pixelRatio': chooseRatio(e, val); break; // settings.reset hands the ratio back to the game (chooseRatio(e, null))
68
69
  case 'antialias': e.post.nextAntialias(val); break;
69
70
  case 'tier': if (val) e.mod('tier', { owner: 'settings', layer: 'settings', set: val }); else e.stacks.get('tier').release('settings'); break;
70
- case 'adaptive': if (e.adaptive) { e.adaptive.on = val; if (!val && e.adaptive.max) e.setPixelRatio(e.adaptive.max); } break;
71
+ case 'adaptive': if (e.adaptive) { e.adaptive.on = val; if (!val) topRatio(e); } break;
71
72
  default:
72
73
  // a saved slider for a bus this build no longer has is skipped, not an error
73
74
  if (key.startsWith('vol.')) { if (key.slice(4) in e.audio.levels) e.audio.setVolume(key.slice(4), val); }
@@ -51,7 +51,7 @@ export function settingsTools(engine, esc) {
51
51
  const labelOf = (e, text) => e.i18n.has(text) ? e.t(text) : text;
52
52
  /**
53
53
  * The rows settings.define() draws itself, in the tab its menu option names (default 'options'). Why the engine draws them: a row defined
54
- * and drawn by no tab was a setting the player could never reach, and nothing said so (old-mine's two quality rows). menu: false = the game draws it.
54
+ * and drawn by no tab was a setting the player could never reach, and nothing said so (e.g. a game's own quality rows). menu: false = the game draws it.
55
55
  * @param {any} tools @param {any} e @param {any} s @param {string | null} tab @returns {string}
56
56
  */
57
57
  export function definedRows(tools, e, s, tab) {
@@ -45,7 +45,7 @@ export const environmentMethods = {
45
45
  const e = this.engine, env = this._env = { into, get interval() { return interval ?? (e.tier === 'low' ? DEFAULT_INTERVAL * LOW_TIER_SLOWER : DEFAULT_INTERVAL); }, key: null, since: 0, builds: 0, target: null, deferred: !this._envFramed };
46
46
  // an explicit call takes the map back from a game write; the warning's way back then names this `into`
47
47
  this._oEnv.manual(false); this._oEnv.levels = { ...this._oEnv.levels, back: `engine.sky.environment({ into: ${into === e.scene ? 'engine.scene' : 'into'} })` };
48
- this._oEnv.mark(); // what `into` holds now is the reference: the first build replaces it as before, only a later write by the game is a takeover
48
+ this._oEnv.mark(); // what `into` holds now is the reference: the first build replaces it, only a later write by the game is a takeover
49
49
  if (!env.deferred) this._envBuild();
50
50
  // a lost context takes the map's pixels with it, and the key cannot see that: with the sky standing still (a fixed hour) the map would stay black
51
51
  env.restored = this.engine.events.on('page:contextrestored', () => { env.key = null; env.deferred = true; });
@@ -30,7 +30,6 @@ import { loadGray } from '../../core/scene/grayMap.js';
30
30
  import { prepareShape, voidWatcher } from './terrainShapeMain.js';
31
31
  import { TerrainDraw, checkGround } from './draw.js';
32
32
  import { codedError } from '../../core/base/errorHints.js';
33
- import { onTierChange } from '../../core/scene/tier.js';
34
33
 
35
34
  const NO_HEIGHT = 'terrain(): no height function or height map was given, so the ground is flat gray at y = 0 (a placeholder, not a picture). '
36
35
  + 'Pass terrain({ height, groundType }) or a preset, e.g. terrain({ ...terrainPreset() }) with terrainPreset from @threedog/terrain-noise';
@@ -129,7 +128,7 @@ export function terrain(opts = {}) {
129
128
  // the low-tier color map follows the tier (a stored preset arrives after this install). A resolution the game gave in terrain({}) stays; recolor cannot set one
130
129
  // (it is not in recolor's keys), so the only other writer is this listener. Followed by reinit, the path recolor takes too: every chunk is generated again, which is
131
130
  // fine at a settings change (and before the first frame it is free). Only colorResolution is changed, on the live object: init above may still be loading images into it
132
- ctx.track(onTierChange(e, () => {
131
+ ctx.track(e.stacks.get('tier').watch(() => {
133
132
  const c = state.cfg;
134
133
  if (cfg.colorResolution != null) return;
135
134
  const want = drawConfig(e, { ...c, colorResolution: undefined }).colorResolution;
@@ -132,7 +132,11 @@ export class Timeline {
132
132
  run.error = err?.message ?? String(err);
133
133
  this._stop(run, 'failed'); // a parallel branch beside the throw is still waiting
134
134
  } finally {
135
- if (run.faded && gone(run) && ![...this.runs].some(r => r !== run && r.faded)) fadeScreen(e, 0, { seconds: 0 }); // the steps that would have faded back in will not run
135
+ if (run.faded) { // the run still holds the screen dark
136
+ fadeScreen(e, 0, { seconds: 0, owner: `timeline:${run.id}` });
137
+ // dropped / failed: the steps that would have faded back in will not run. Finished / skipped on a dark step: the cover is handed to the scene change (owner 'flow'), the next flow.transition lifts it
138
+ if (!gone(run)) fadeScreen(e, run.faded, { seconds: 0, owner: 'flow' });
139
+ }
136
140
  turn.remove();
137
141
  releaseCamera(this, run);
138
142
  run.focus.remove();
@@ -230,11 +234,11 @@ export class Timeline {
230
234
 
231
235
  /** Full-screen fade: jumps to the target when skipped. faded: the run holds the screen, so an ending that drops the later steps gives it back @internal */
232
236
  async _fade(seconds, to, run) {
233
- const now = () => fadeScreen(this.engine, to, { seconds: 0 });
234
- run.faded = to > 0;
237
+ const owner = `timeline:${run.id}`, now = () => fadeScreen(this.engine, to, { seconds: 0, owner });
238
+ run.faded = to > 0 ? to : 0;
235
239
  if (run.ending) return now();
236
240
  run.cancels.add(now);
237
- await fadeScreen(this.engine, to, { seconds });
241
+ await fadeScreen(this.engine, to, { seconds, owner });
238
242
  run.cancels.delete(now);
239
243
  }
240
244
 
@@ -168,7 +168,7 @@ export class Vegetation {
168
168
  if (o.positions != null) checkPositions(`vegetation.define('${name}')`, o.positions, o.rule);
169
169
  const density = o.densityMap != null ? makeDensity(o.densityMap, `vegetation.define('${name}')`) : null;
170
170
  // distance fade band of near-only species (nearFade.js), checked here so a bad band throws at define; the draw part draws it
171
- // impostor and lodGeometry both say what is drawn beyond lodRing: one owner (docs/plans/2026-11-09-impostors.md)
171
+ // impostor and lodGeometry both say what is drawn beyond lodRing: one owner (docs/plans/done/2026-11-09-impostors.md)
172
172
  if (o.impostor && o.lodGeometry) throw codedError('vegetation-option', `vegetation.define('${name}'): impostor and lodGeometry both say what is drawn beyond lodRing; keep one`);
173
173
  if (o.impostor != null) checkImpostor(`vegetation.define('${name}')`, o.impostor);
174
174
  if (o.fade && typeof o.fade === 'object') readParams(`vegetation.define('${name}').fade`, keysSchema(['start', 'end']), o.fade);
@@ -54,7 +54,7 @@ export function vegetation(opts = {}) {
54
54
  install(e, ctx) {
55
55
  e.i18n.add({ 'zh-CN': { 'module.vegetation': '植被' }, en: { 'module.vegetation': 'vegetation' } });
56
56
  v = new Vegetation(e, opts, ctx);
57
- ctx.track(e.events.on('settings:shadows', () => v.host.refreshLevels())); // whichever chunks it grows on: each level pass rereads the shadow switch
57
+ ctx.track(e.stacks.get('shadows.enabled').watch(() => v.host.refreshLevels())); // whichever chunks it grows on: each level pass rereads the shadow switch
58
58
  if (v.host !== e.terrain) {
59
59
  own = v.host;
60
60
  ctx.ground.addColliders((x, z, range, fn) => own.forEachCollider(x, z, range, fn)); // collision and path planning see the trees
@@ -8,7 +8,6 @@ import { readParams, keysSchema } from '../../core/base/params.js';
8
8
  import { isOptions } from '../../core/base/util.js';
9
9
  import { codedError } from '../../core/base/errorHints.js';
10
10
  import { onRendererSwap } from '../../render/backend.js';
11
- import { onTierChange } from '../../core/scene/tier.js';
12
11
  import { makeSystem, updateSystem, dropSystem, RAIN, SNOW } from './particles.js';
13
12
 
14
13
  const DRAW_PARAMS = keysSchema(['particles', 'area', 'rain', 'snow']); // the picture options of weather(): the rest are the state's
@@ -144,7 +143,7 @@ export function weatherDrawModule(opts) {
144
143
  L = new WeatherDraw(e, opts);
145
144
  L._ctx = ctx; // the weather's entries on the shared points go with this module (ctx.mod)
146
145
  ctx.track(onRendererSwap(e, () => L._rebuild()));
147
- ctx.track(onTierChange(e, () => L._tierChanged())); // the default particle count follows the tier
146
+ ctx.track(e.stacks.get('tier').watch(() => L._tierChanged())); // the default particle count follows the tier
148
147
  ctx.track(e.audio.condition('weather', v => [].concat(v).includes(e.weather.name))); // audio rule condition { weather: 'rain' | ['rain', 'storm'] }
149
148
  for (const k of ['rain', 'snow', 'wind']) ctx.track(e.audio.measure(k, () => e.weather.current[k])); // data rules: { rain: { lt: 0.2 } }, volume add: { rain: 0.22 }
150
149
  builtInSounds(e.assets, { thunder: (audio, p, out) => { const dur = p.duration ?? 3.5, delay = 0.4 + Math.random() * 1.5; // presentation: thunder delay
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "threedog",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Web 3D game engine on three.js, built to be driven by an AI. Start: npm install threedog three && npm install -D @threedog/tools && npx threedog init (writes the game and its CLAUDE.md). No built-in art",
5
5
  "license": "MIT",
6
6
  "repository": {
package/render/PostFX.js CHANGED
@@ -15,7 +15,7 @@ import { warnOnce } from '../core/base/validate.js';
15
15
  import { reportError } from '../core/base/errors.js';
16
16
  import { readParams, keysSchema } from '../core/base/params.js';
17
17
  import { isWebGPU, webgpuPart, ownMsaa } from './backend.js';
18
- import { MSAA_KEY, onTierChange } from '../core/scene/tier.js';
18
+ import { MSAA_KEY } from '../core/scene/tier.js';
19
19
  import { defineOwned } from '../core/ops/owned.js';
20
20
  import { watchOwnFrame } from './ownFrame.js';
21
21
  import { runsHere, OUTPUT_TWICE } from './postRuns.js';
@@ -123,7 +123,7 @@ export class PostFX {
123
123
  // handed back: the kept WebGPU stages go too, the game may have edited those nodes while it owned them, so the declared chain is rebuilt whole
124
124
  levels: { manual: 'engine.post.own()' }, onChange: o => { if (!o.on) return; if (this._pipe) { this._pipe.key = null; this._pipe.stages = []; } this._sync(); } });
125
125
  this._sync();
126
- onTierChange(engine, () => this._sync()); // effects held by tier (skipOnLowTier) follow it; after the first sync, so a throw there leaves no listener
126
+ engine.stacks.get('tier').watch(() => this._sync()); // effects held by tier (skipOnLowTier) follow it; after the first sync, so a throw there leaves no listener
127
127
  }
128
128
 
129
129
  /**
@@ -214,8 +214,8 @@ export class PostFX {
214
214
  if (odd.length) throw codedError('post-effect', `post effect '${effect.name}': cheaper names ${odd.join(', ')}, not in its params (${Object.keys(effect.params ?? {}).join(', ') || 'none'}); cheaper holds lower values of its own params`);
215
215
  finiteParams(effect.name, effect.params, 'params');
216
216
  const post = this, point = this.switchPoint(`post.${effect.name}.enabled`);
217
- point.release('game'); point.base = effect.enabled ?? true; // only the game's own word starts over: the player's off and any other owner's hold stay on the effect that comes back
218
- let on = !!point.value();
217
+ point.release('game'); point.setBase(effect.enabled ?? true); // only the game's own word starts over: the player's off and any other owner's hold stay on the effect that comes back
218
+ let on = !!point.value(), follow = /** @type {{ remove(): void } | null} */ (null); // follow is set after this effect's own setBase: no extra sync here
219
219
  const h = {
220
220
  name: effect.name, slot: s, order: effect.order ?? 0, seq: this._place(effect.name),
221
221
  params: { ...effect.params }, _def: effect, _impl: /** @type {any} */ (null), _removed: false, _entry: /** @type {any} */ (null), _on: () => on,
@@ -252,7 +252,7 @@ export class PostFX {
252
252
  remove() {
253
253
  if (h._removed) return;
254
254
  h._removed = true;
255
- point.onChange = null; point.release('game');
255
+ follow?.remove(); follow = null; point.release('game');
256
256
  post._change(() => {
257
257
  freeImpl(h);
258
258
  post._list = post._list.filter(e => e !== h);
@@ -262,10 +262,10 @@ export class PostFX {
262
262
  },
263
263
  };
264
264
  // a settings restriction or a hold ending turns it on or off here; a rebuild that throws leaves it as it was
265
- point.onChange = () => { const was = on, now = !!point.value(); if (now !== was) this._change(() => { on = now; }, () => { on = was; }); };
265
+ follow = point.watch(() => { const was = on, now = !!point.value(); if (now !== was) this._change(() => { on = now; }, () => { on = was; }); });
266
266
  // a create() that throws or an order that breaks depth leaves no half-added effect behind
267
267
  try { this._change(() => this._list.push(h), () => { freeImpl(h); this._list = this._list.filter(e => e !== h); }); }
268
- catch (err) { point.onChange = null; if (!this._kept.has(h.name)) this._seq.delete(h.name); throw err; }
268
+ catch (err) { follow?.remove(); follow = null; if (!this._kept.has(h.name)) this._seq.delete(h.name); throw err; }
269
269
  this.engine._picture?.added('post effect', h, h.name); // dev: a picture part removed with this still on is reported (core/inspect/pictureWriters.js)
270
270
  this.engine.events.emit('post:add', h.name); // the settings rows follow an effect by its role, so one added after them still gets the player's choice
271
271
  return h;
@@ -9,7 +9,7 @@ import { readParams } from '../core/base/params.js';
9
9
  import { codedError, coded } from '../core/base/errorHints.js';
10
10
  import { warnOnce, fmt } from '../core/base/validate.js';
11
11
  import { mats } from './lit.js';
12
- import { litTwice } from '../core/inspect/pictureChecks.js';
12
+ import { litTwice } from './probes.js';
13
13
 
14
14
  const FORMAT = 'threedog-lightmap', VERSION = 1, MAGIC = 0x4d4c4454; // 'TDLM'
15
15
  const LOAD = { owner: { type: 'string', default: 'game', desc: 'who loaded it (describe().render.lightmap)' } };
package/render/lights.js CHANGED
@@ -5,7 +5,6 @@
5
5
  import { engineOwned } from '../core/scene/things.js';
6
6
  import * as THREE from 'three';
7
7
  import { defineOwned } from '../core/ops/owned.js';
8
- import { onTierChange } from '../core/scene/tier.js';
9
8
 
10
9
  const BOX = 30, SNAP = 0.5;
11
10
 
@@ -34,7 +33,7 @@ export function createDefaultLights(engine, { add = true } = {}) {
34
33
  // One rule for both tier defaults, size and radius: a value still at the engine's default for the old tier follows the tier, any other value is the
35
34
  // game's and stays. Known edge: a game that writes exactly the engine's default reads as untouched and still follows (no accessor: it would hide the
36
35
  // value from engine.debug.watch / explain, which only hook plain properties)
37
- onTierChange(engine, () => {
36
+ engine.stacks.get('tier').watch(() => {
38
37
  const was = map, next = map = sizeFor(), s = sun.shadow;
39
38
  if (next === was) return;
40
39
  if (s.mapSize.x === was && s.mapSize.y === was) { if (engine.shadows) engine.shadows.mapSize(sun, next); else s.mapSize.set(next, next); }
package/render/neutral.js CHANGED
@@ -6,7 +6,7 @@ import * as THREE from 'three';
6
6
  import { markEngineMade } from './patches.js';
7
7
 
8
8
  /** The gray of everything the engine draws until the game gives it a picture */
9
- export const NEUTRAL = 0x8c8c8c;
9
+ const NEUTRAL = 0x8c8c8c;
10
10
 
11
11
  /**
12
12
  * A plain MeshLambertMaterial for engine code: neutral gray unless params say otherwise. params are three.js material properties.
package/render/patches.js CHANGED
@@ -147,7 +147,7 @@ const PROTO_COMPILE = THREE.Material.prototype.onBeforeCompile, PROTO_KEY = THRE
147
147
  // carries this key: a function handing back the game's part it wraps (null / three's method when the game had none). The WebGPU route names
148
148
  // only the game's GLSL hook by it (render/backend.js), and cloneMaterial carries the game's part instead of a wrapper bound to the original
149
149
  /** @internal */
150
- export const WRAPPED = Symbol.for('threedog.patchWrapper');
150
+ const WRAPPED = Symbol.for('threedog.patchWrapper');
151
151
 
152
152
  function apply(shader, list, m, renderer) {
153
153
  for (const p of list) for (const d of p.needs?.data || []) if (!shader[d]) {
@@ -450,8 +450,8 @@ export function unpatchMaterial(material, name) {
450
450
 
451
451
  // What three's clone leaves behind. NodeMaterial.copy (and Material.copy's fixed list) carries only properties a fresh instance of the class
452
452
  // already has, so what a game set on the instance itself was dropped: its own lighting (mat.setupLightingModel = celLighting, the cel.tsl.js
453
- // example), its own onBeforeCompile, a field its class never declares. The copy then drew with three's plain lighting (Pigforest: every
454
- // vegetation model tree lost its toon look). Skipped as three's copy skips them: '_' internals, is* flags, ids, userData (copied by three)
453
+ // example), its own onBeforeCompile, a field its class never declares. The copy then drew with three's plain lighting (a game's own toon
454
+ // lighting on every cloned model was lost). Skipped as three's copy skips them: '_' internals, is* flags, ids, userData (copied by three)
455
455
  const NOT_CARRIED = /^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/;
456
456
  /** The game's part under engine wrappers (WRAPPED), else the value itself */
457
457
  const gamePart = v => { while (typeof v === 'function' && v[WRAPPED]) v = v[WRAPPED](); return v; };