@adatechnology/game-shapes-three 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -295,28 +295,29 @@ function mergeByMaterial(THREE, root, space) {
295
295
  // src/cord.ts
296
296
  function catenary(a, b, sag, n = 12) {
297
297
  const count = Math.max(2, Math.floor(n));
298
- const span = Math.hypot(b[0] - a[0], b[2] - a[2]) || Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
299
- const depth = Math.max(0, sag);
298
+ const { span, c } = catenaryOf(a[0], a[1], a[2], b[0], b[1], b[2], sag);
300
299
  const out = [];
301
- let shape = () => 0;
302
- if (depth > 1e-6 && span > 1e-6) {
303
- let lo = 1e-4;
304
- let hi = span * 1e3;
305
- for (let i = 0; i < 80; i++) {
306
- const c2 = (lo + hi) / 2;
307
- const d = c2 * (Math.cosh(span / (2 * c2)) - 1);
308
- if (d > depth) lo = c2;
309
- else hi = c2;
310
- }
311
- const c = (lo + hi) / 2;
312
- shape = (s) => c * (Math.cosh((s - 0.5) * span / c) - Math.cosh(span / (2 * c)));
313
- }
314
300
  for (let i = 0; i < count; i++) {
315
301
  const s = i / (count - 1);
316
- out.push([a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s + shape(s), a[2] + (b[2] - a[2]) * s]);
302
+ out.push([a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s + catenaryDrop(span, c, s), a[2] + (b[2] - a[2]) * s]);
317
303
  }
318
304
  return out;
319
305
  }
306
+ var catenaryOf = (ax, ay, az, bx, by, bz, sag) => {
307
+ const span = Math.hypot(bx - ax, bz - az) || Math.hypot(bx - ax, by - ay, bz - az);
308
+ const depth = Math.max(0, sag);
309
+ if (depth <= 1e-6 || span <= 1e-6) return { span, c: 0 };
310
+ let lo = 1e-4;
311
+ let hi = span * 1e3;
312
+ for (let i = 0; i < 80; i++) {
313
+ const c = (lo + hi) / 2;
314
+ const d = c * (Math.cosh(span / (2 * c)) - 1);
315
+ if (d > depth) lo = c;
316
+ else hi = c;
317
+ }
318
+ return { span, c: (lo + hi) / 2 };
319
+ };
320
+ var catenaryDrop = (span, c, s) => c > 0 ? c * (Math.cosh((s - 0.5) * span / c) - Math.cosh(span / (2 * c))) : 0;
320
321
  function createCord(THREE, points, radius, material, radialSegments = 5) {
321
322
  if (points.length < 2) throw new Error("createCord needs at least two points");
322
323
  const curve = new THREE.CatmullRomCurve3(points.map((p) => new THREE.Vector3(p[0], p[1], p[2])), false, "centripetal");
@@ -326,6 +327,96 @@ function createCord(THREE, points, radius, material, radialSegments = 5) {
326
327
  mesh.castShadow = true;
327
328
  return mesh;
328
329
  }
330
+ function createHangingCord(THREE, options) {
331
+ const segments = Math.max(1, Math.floor(options.segments));
332
+ const radial = Math.max(3, Math.floor(options.radialSegments ?? 5));
333
+ const ring2 = radial + 1;
334
+ const positions = new Float32Array((segments + 1) * ring2 * 3);
335
+ const normals = new Float32Array((segments + 1) * ring2 * 3);
336
+ const index = [];
337
+ for (let i = 0; i < segments; i++) {
338
+ for (let j = 0; j < radial; j++) {
339
+ const a = i * ring2 + j;
340
+ const b = (i + 1) * ring2 + j;
341
+ index.push(a, b, a + 1, b, b + 1, a + 1);
342
+ }
343
+ }
344
+ const geometry = new THREE.BufferGeometry();
345
+ const positionAttribute = new THREE.BufferAttribute(positions, 3);
346
+ const normalAttribute = new THREE.BufferAttribute(normals, 3);
347
+ geometry.setAttribute("position", positionAttribute);
348
+ geometry.setAttribute("normal", normalAttribute);
349
+ geometry.setIndex(index);
350
+ const sphere2 = new THREE.Sphere();
351
+ geometry.boundingSphere = sphere2;
352
+ const mesh = new THREE.Mesh(geometry, options.material);
353
+ mesh.name = "cord";
354
+ mesh.castShadow = true;
355
+ const centre = new Float64Array((segments + 1) * 3);
356
+ const tangent = new THREE.Vector3();
357
+ const normal = new THREE.Vector3();
358
+ const binormal = new THREE.Vector3();
359
+ const previous = new THREE.Vector3();
360
+ const low = new THREE.Vector3();
361
+ const high = new THREE.Vector3();
362
+ const tangentAt = (i) => {
363
+ const from = Math.max(0, i - 1);
364
+ const to = Math.min(segments, i + 1);
365
+ tangent.set(centre[to * 3] - centre[from * 3], centre[to * 3 + 1] - centre[from * 3 + 1], centre[to * 3 + 2] - centre[from * 3 + 2]).normalize();
366
+ };
367
+ return {
368
+ mesh,
369
+ hang(a, b, sag) {
370
+ const { span, c } = catenaryOf(a.x, a.y, a.z, b.x, b.y, b.z, sag);
371
+ for (let i = 0; i <= segments; i++) {
372
+ const s = i / segments;
373
+ centre[i * 3] = a.x + (b.x - a.x) * s;
374
+ centre[i * 3 + 1] = a.y + (b.y - a.y) * s + catenaryDrop(span, c, s);
375
+ centre[i * 3 + 2] = a.z + (b.z - a.z) * s;
376
+ }
377
+ low.set(Infinity, Infinity, Infinity);
378
+ high.set(-Infinity, -Infinity, -Infinity);
379
+ for (let i = 0; i <= segments; i++) {
380
+ tangentAt(i);
381
+ if (i === 0) {
382
+ const ax = Math.abs(tangent.x);
383
+ const ay = Math.abs(tangent.y);
384
+ const az = Math.abs(tangent.z);
385
+ normal.set(ax <= ay && ax <= az ? 1 : 0, ay < ax && ay <= az ? 1 : 0, az < ax && az < ay ? 1 : 0);
386
+ normal.sub(binormal.copy(tangent).multiplyScalar(normal.dot(tangent))).normalize();
387
+ } else {
388
+ normal.copy(previous).sub(binormal.copy(tangent).multiplyScalar(previous.dot(tangent))).normalize();
389
+ }
390
+ previous.copy(normal);
391
+ binormal.crossVectors(tangent, normal);
392
+ const px = centre[i * 3];
393
+ const py = centre[i * 3 + 1];
394
+ const pz = centre[i * 3 + 2];
395
+ for (let j = 0; j <= radial; j++) {
396
+ const angle = j / radial * Math.PI * 2;
397
+ const cos = Math.cos(angle);
398
+ const sin = -Math.sin(angle);
399
+ const nx = cos * normal.x + sin * binormal.x;
400
+ const ny = cos * normal.y + sin * binormal.y;
401
+ const nz = cos * normal.z + sin * binormal.z;
402
+ const at = (i * ring2 + j) * 3;
403
+ normals[at] = nx;
404
+ normals[at + 1] = ny;
405
+ normals[at + 2] = nz;
406
+ positions[at] = px + options.radius * nx;
407
+ positions[at + 1] = py + options.radius * ny;
408
+ positions[at + 2] = pz + options.radius * nz;
409
+ }
410
+ low.set(Math.min(low.x, px), Math.min(low.y, py), Math.min(low.z, pz));
411
+ high.set(Math.max(high.x, px), Math.max(high.y, py), Math.max(high.z, pz));
412
+ }
413
+ positionAttribute.needsUpdate = true;
414
+ normalAttribute.needsUpdate = true;
415
+ sphere2.center.addVectors(low, high).multiplyScalar(0.5);
416
+ sphere2.radius = sphere2.center.distanceTo(high) + options.radius;
417
+ }
418
+ };
419
+ }
329
420
 
330
421
  // src/release.ts
331
422
  var isTexture = (v) => !!v && typeof v === "object" && v.isTexture === true;
@@ -647,6 +738,7 @@ export {
647
738
  coincidentBatchesOf,
648
739
  coincidentFacesOf,
649
740
  createCord,
741
+ createHangingCord,
650
742
  createMaterials,
651
743
  depthResolution,
652
744
  describeCoincidentFaces,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/geometry.ts","../src/namespace.ts","../src/object.ts","../src/merge-by-material.ts","../src/cord.ts","../src/release.ts","../src/guards.ts","../src/position-writes.ts","../src/coincident.ts","../src/stand-out.ts"],"sourcesContent":["import type { PrimitiveBuffers, ShapeBatch } from '@adatechnology/game-shapes'\nimport type * as THREE_NS from 'three'\n\nexport type Three = typeof THREE_NS\n\nexport interface ToGeometryOptions {\n /** Copy the arrays into the attributes (default true). Without a copy the geometry shares the buffers (a cached result is read-only: do not deform it). */\n readonly copy?: boolean\n}\n\n/** The order in which three's generator of each type sets its attributes (toJSON and attribute iteration keep it). */\nconst UV_BEFORE_NORMAL = new Set(['LatheGeometry', 'ExtrudeGeometry'])\n/** Types whose constructor sets the index before the attributes. */\nconst INDEX_FIRST = new Set(['BoxGeometry', 'CylinderGeometry', 'ConeGeometry', 'SphereGeometry', 'PlaneGeometry', 'CircleGeometry', 'RingGeometry', 'LatheGeometry', 'TorusGeometry'])\n\nconst isPrimitive = (value: PrimitiveBuffers | ShapeBatch): value is PrimitiveBuffers => typeof (value as PrimitiveBuffers).type === 'string'\n\n/** Three's own parameters object for a type (lathe points as `Vector2`). */\nfunction threeParameters(THREE: Three, p: PrimitiveBuffers): Record<string, unknown> {\n if (p.type === 'LatheGeometry') {\n const points = (p.parameters.points as Array<{ x: number; y: number }>).map(({ x, y }) => new THREE.Vector2(x, y))\n return { ...p.parameters, points }\n }\n return { ...p.parameters }\n}\n\n/**\n * A `BufferGeometry` from game-shapes buffers. A primitive becomes an instance of the three class it reproduces (`type`, `parameters`, prototype:\n * `instanceof THREE.CylinderGeometry`, `clone()` and `toJSON()` behave as three's), with the same attributes, index and groups. A batch gets\n * `position`, `normal`, `uv`, `color` (when present) and its index.\n */\nexport function toGeometry(THREE: Three, source: PrimitiveBuffers | ShapeBatch, options: ToGeometryOptions = {}): THREE_NS.BufferGeometry {\n const copy = options.copy !== false\n const primitive = isPrimitive(source) ? source : null\n const ThreeClass = primitive && primitive.type !== 'BufferGeometry' ? ((THREE as unknown as Record<string, unknown>)[primitive.type] as (new () => THREE_NS.BufferGeometry) | undefined) : undefined\n // the BufferGeometry constructor only, with the prototype of the class it stands for\n const geometry = (ThreeClass ? Reflect.construct(THREE.BufferGeometry, [], ThreeClass) : new THREE.BufferGeometry()) as THREE_NS.BufferGeometry & { parameters?: Record<string, unknown> }\n if (primitive && ThreeClass) {\n Object.assign(geometry, { type: primitive.type, parameters: threeParameters(THREE, primitive) })\n }\n const attribute = (array: Float32Array, size: number): THREE_NS.BufferAttribute => (copy ? new THREE.Float32BufferAttribute(array, size) : new THREE.BufferAttribute(array, size))\n const index = source.indices\n const setIndex = (): void => {\n if (!index) return\n geometry.setIndex(copy ? (index instanceof Uint32Array ? new THREE.Uint32BufferAttribute(index, 1) : new THREE.Uint16BufferAttribute(index, 1)) : new THREE.BufferAttribute(index, 1))\n }\n const type = primitive?.type ?? 'BufferGeometry'\n if (INDEX_FIRST.has(type)) setIndex()\n geometry.setAttribute('position', attribute(source.positions, 3))\n if (UV_BEFORE_NORMAL.has(type)) {\n geometry.setAttribute('uv', attribute(source.uvs, 2))\n geometry.setAttribute('normal', attribute(source.normals, 3))\n } else {\n geometry.setAttribute('normal', attribute(source.normals, 3))\n geometry.setAttribute('uv', attribute(source.uvs, 2))\n }\n if (!primitive && (source as ShapeBatch).colors) geometry.setAttribute('color', attribute((source as ShapeBatch).colors as Float32Array, 3))\n if (!INDEX_FIRST.has(type)) setIndex()\n if (primitive) for (const group of primitive.groups) geometry.addGroup(group.start, group.count, group.materialIndex)\n return geometry\n}\n","import { box, circle, cone, cylinder, extrude, lathe, plane, ring, sphere, torus } from '@adatechnology/game-shapes'\nimport type { BevelSpec, PrimitiveBuffers, PrimitiveNode, ShapeOutline, Vec2 } from '@adatechnology/game-shapes'\nimport { buildPrimitive } from '@adatechnology/game-shapes'\nimport type * as THREE_NS from 'three'\n\nimport { toGeometry } from './geometry'\nimport type { Three } from './geometry'\n\n/** The geometry constructors `shapeGeometries` replaces. */\nexport const SHAPE_GEOMETRY_TYPES = ['BoxGeometry', 'CylinderGeometry', 'ConeGeometry', 'SphereGeometry', 'PlaneGeometry', 'CircleGeometry', 'RingGeometry', 'LatheGeometry', 'TorusGeometry', 'ExtrudeGeometry'] as const\n\ntype Curve = { isLineCurve?: boolean; v1?: { x: number; y: number }; v2?: { x: number; y: number } }\ntype PathLike = { curves: Curve[]; autoClose?: boolean; holes?: PathLike[] }\n\n/** The point list of a path made only of contiguous `LineCurve`s (what `moveTo` + `lineTo` builds), or null. */\nfunction linePoints(path: PathLike): Vec2[] | null {\n if (path.autoClose || path.curves.length === 0) return null\n const points: Vec2[] = []\n for (const [index, curve] of path.curves.entries()) {\n if (!curve.isLineCurve || !curve.v1 || !curve.v2) return null\n if (index === 0) points.push([curve.v1.x, curve.v1.y])\n else {\n const last = points[points.length - 1] as Vec2\n if (last[0] !== curve.v1.x || last[1] !== curve.v1.y) return null\n }\n points.push([curve.v2.x, curve.v2.y])\n }\n return points\n}\n\ntype ExtrudeOptions = { depth?: number; steps?: number; bevelEnabled?: boolean; bevelThickness?: number; bevelSize?: number; bevelOffset?: number; bevelSegments?: number; extrudePath?: unknown; UVGenerator?: unknown; curveSegments?: number }\n\n/** An extrusion game-shapes can make exactly: one straight-edged shape, no path, the world uvs. */\nfunction extrudeOf(shapes: unknown, options: ExtrudeOptions = {}): PrimitiveBuffers | null {\n if (Array.isArray(shapes) || !shapes || options.extrudePath !== undefined || options.UVGenerator !== undefined) return null\n const shape = shapes as PathLike\n const outer = linePoints(shape)\n if (!outer) return null\n const holes: Vec2[][] = []\n for (const hole of shape.holes ?? []) {\n const points = linePoints(hole)\n if (!points) return null\n holes.push(points)\n }\n const outline: ShapeOutline = holes.length ? { outer, holes } : { outer }\n const bevel: false | BevelSpec =\n options.bevelEnabled === false\n ? false\n : {\n ...(options.bevelThickness !== undefined ? { thickness: options.bevelThickness } : {}),\n ...(options.bevelSize !== undefined ? { size: options.bevelSize } : {}),\n ...(options.bevelOffset !== undefined ? { offset: options.bevelOffset } : {}),\n ...(options.bevelSegments !== undefined ? { segments: options.bevelSegments } : {}),\n }\n return extrude(outline, options.depth, options.steps, bevel)\n}\n\nexport interface ShapeGeometriesOptions {\n /** Go through the template cache of game-shapes (default true): the same primitive is generated once per process. */\n readonly cache?: boolean\n}\n\nconst namespaces = new WeakMap<object, Map<string, Three>>()\n/** The namespaces this module made: wrapping one again gives it back (a package handing its `T` to another). */\nconst shims = new WeakSet<object>()\n\n/**\n * A three namespace whose `BoxGeometry`, `CylinderGeometry`, `ConeGeometry`, `SphereGeometry`, `PlaneGeometry`, `CircleGeometry`, `RingGeometry`,\n * `LatheGeometry`, `TorusGeometry` and (straight-edged) `ExtrudeGeometry` are made by game-shapes, bit-identical to three's and instances of three's\n * classes; everything else is three's own. Hand it to code ported from the teams as `T`, so it keeps reading `new T.CylinderGeometry(...)`.\n * An extrusion with curves, several shapes, a path or a custom uv generator falls back to three.\n */\nexport function shapeGeometries(THREE: Three, options: ShapeGeometriesOptions = {}): Three {\n if (shims.has(THREE)) return THREE\n const cache = options.cache !== false\n const key = cache ? 'cache' : 'nocache'\n let byKey = namespaces.get(THREE)\n if (!byKey) {\n byKey = new Map()\n namespaces.set(THREE, byKey)\n }\n const existing = byKey.get(key)\n if (existing) return existing\n const made = (p: PrimitiveBuffers): THREE_NS.BufferGeometry => toGeometry(THREE, p)\n const viaCache = (node: PrimitiveNode, direct: () => PrimitiveBuffers): PrimitiveBuffers => (cache ? buildPrimitive(node) : direct())\n const defined = <T extends object>(o: T): T => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as T\n const constructors = {\n BoxGeometry: (width?: number, height?: number, depth?: number, ws = 1, hs = 1, ds = 1) =>\n made(viaCache({ kind: 'box', size: [width ?? 1, height ?? 1, depth ?? 1], segments: [ws, hs, ds] }, () => box(width, height, depth, ws, hs, ds))),\n CylinderGeometry: (radiusTop?: number, radiusBottom?: number, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'cylinder', ...defined({ radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength }) }, () => cylinder(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength))),\n ConeGeometry: (radius?: number, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'cone', ...defined({ radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength }) }, () => cone(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength))),\n SphereGeometry: (radius?: number, widthSegments?: number, heightSegments?: number, phiStart?: number, phiLength?: number, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'sphere', ...defined({ radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength }) }, () => sphere(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength))),\n PlaneGeometry: (width?: number, height?: number, widthSegments?: number, heightSegments?: number) =>\n made(viaCache({ kind: 'plane', ...defined({ width, height, widthSegments, heightSegments }) }, () => plane(width, height, widthSegments, heightSegments))),\n CircleGeometry: (radius?: number, segments?: number, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'circle', ...defined({ radius, segments, thetaStart, thetaLength }) }, () => circle(radius, segments, thetaStart, thetaLength))),\n RingGeometry: (innerRadius?: number, outerRadius?: number, thetaSegments?: number, phiSegments?: number, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'ring', ...defined({ innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength }) }, () => ring(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength))),\n LatheGeometry: (points?: Array<{ x: number; y: number }>, segments?: number, phiStart?: number, phiLength?: number) => {\n if (!points) return new THREE.LatheGeometry(undefined, segments, phiStart, phiLength)\n const profile = points.map((p) => [p.x, p.y] as const)\n return made(viaCache({ kind: 'lathe', points: profile, ...defined({ segments, phiStart, phiLength }) }, () => lathe(profile, segments, phiStart, phiLength)))\n },\n TorusGeometry: (radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, arc?: number) =>\n made(viaCache({ kind: 'torus', ...defined({ radius, tube, radialSegments, tubularSegments, arc }) }, () => torus(radius, tube, radialSegments, tubularSegments, arc))),\n ExtrudeGeometry: (shapes?: unknown, extrudeOptions?: ExtrudeOptions) => {\n const buffers = shapes === undefined ? null : extrudeOf(shapes, extrudeOptions)\n if (!buffers) return new THREE.ExtrudeGeometry(shapes as THREE_NS.Shape, extrudeOptions as THREE_NS.ExtrudeGeometryOptions)\n const geometry = toGeometry(THREE, buffers) as THREE_NS.BufferGeometry & { parameters: unknown }\n geometry.parameters = { shapes, options: extrudeOptions ?? {} }\n return geometry\n },\n } satisfies Record<(typeof SHAPE_GEOMETRY_TYPES)[number], (...args: never[]) => THREE_NS.BufferGeometry>\n const namespace: Record<string, unknown> = { ...(THREE as unknown as Record<string, unknown>) }\n for (const type of SHAPE_GEOMETRY_TYPES) {\n // three hands the constructor's own arguments through; each replacement takes the same ones\n const make = constructors[type] as (...args: unknown[]) => THREE_NS.BufferGeometry\n // callable with `new` (the returned object wins), and `instanceof` checks three's prototype\n const Constructor = function (this: unknown, ...args: unknown[]) {\n return make(...args)\n } as unknown as { prototype: unknown }\n Constructor.prototype = (THREE as unknown as Record<string, { prototype: unknown }>)[type]!.prototype\n Object.defineProperty(Constructor, 'name', { value: type })\n namespace[type] = Constructor\n }\n const result = namespace as unknown as Three\n byKey.set(key, result)\n shims.add(result)\n return result\n}\n","import { colorHex } from '@adatechnology/game-shapes'\nimport type { MaterialHint, ShapeBuffers, ShapeLevel, ShapePart, ShapePoint } from '@adatechnology/game-shapes'\nimport type * as THREE_NS from 'three'\n\nimport { toGeometry } from './geometry'\nimport type { Three } from './geometry'\n\n/** A `MeshStandardMaterial` per material id from the schema's hints (vertex colours on unless the hint says otherwise). */\nexport function createMaterials(THREE: Three, hints: Readonly<Record<string, MaterialHint>> = {}, ids: Iterable<string> = []): Record<string, THREE_NS.Material> {\n const out: Record<string, THREE_NS.Material> = {}\n const all = new Set([...Object.keys(hints), ...ids])\n for (const id of all) {\n const hint = hints[id] ?? {}\n const parameters: THREE_NS.MeshStandardMaterialParameters = { vertexColors: hint.vertexColors ?? true }\n if (hint.color !== undefined) parameters.color = colorHex(hint.color)\n if (hint.roughness !== undefined) parameters.roughness = hint.roughness\n if (hint.metalness !== undefined) parameters.metalness = hint.metalness\n if (hint.opacity !== undefined) parameters.opacity = hint.opacity\n if (hint.transparent !== undefined) parameters.transparent = hint.transparent\n if (hint.emissive !== undefined) parameters.emissive = colorHex(hint.emissive)\n if (hint.emissiveIntensity !== undefined) parameters.emissiveIntensity = hint.emissiveIntensity\n if (hint.flatShading !== undefined) parameters.flatShading = hint.flatShading\n if (hint.depthWrite !== undefined) parameters.depthWrite = hint.depthWrite\n if (hint.side !== undefined) parameters.side = hint.side === 'double' ? THREE.DoubleSide : hint.side === 'back' ? THREE.BackSide : THREE.FrontSide\n const material = new THREE.MeshStandardMaterial(parameters)\n material.name = id\n out[id] = material\n }\n return out\n}\n\nexport interface ToObjectOptions {\n /** Materials by id; missing ids get one from the schema hints (`createMaterials`). */\n readonly materials?: Readonly<Record<string, THREE_NS.Material>>\n /** The material of one draw (wins over `materials`): per material id and part (`null` for the static body). */\n readonly materialFor?: (material: string, part: string | null) => THREE_NS.Material | undefined\n /** Cast and receive shadows (default true). */\n readonly shadows?: boolean\n /** Copy the arrays into the attributes (default true; false shares them, read-only). */\n readonly copy?: boolean\n /** Name of the root. */\n readonly name?: string\n}\n\nexport interface ShapeObject {\n /** A `Group`, or a `LOD` when the shape has levels or a cull distance. */\n readonly object: THREE_NS.Object3D\n /** The level 0 group (the root itself without LOD). */\n readonly near: THREE_NS.Group\n /** Part groups of level 0 by id, at their pivots; animate these. */\n readonly parts: Record<string, THREE_NS.Group>\n readonly meshes: THREE_NS.Mesh[]\n readonly instanced: THREE_NS.InstancedMesh[]\n readonly points: readonly ShapePoint[]\n readonly materials: Record<string, THREE_NS.Material>\n}\n\nfunction placePart(THREE: Three, group: THREE_NS.Group, part: ShapePart): void {\n if (part.matrix && part.position === undefined && part.rotation === undefined && part.scale === undefined && part.heading === undefined) {\n new THREE.Matrix4().fromArray(part.matrix as number[]).decompose(group.position, group.quaternion, group.scale)\n return\n }\n if (part.position) group.position.set(part.position[0], part.position[1], part.position[2])\n if (part.heading !== undefined) group.rotation.y = part.heading\n else if (part.rotation) group.rotation.set(part.rotation[0], part.rotation[1], part.rotation[2], part.rotationOrder ?? 'XYZ')\n if (part.scale !== undefined) {\n if (typeof part.scale === 'number') group.scale.setScalar(part.scale)\n else group.scale.set(part.scale[0], part.scale[1], part.scale[2])\n }\n group.updateMatrix()\n}\n\n/**\n * The three objects of a shape: one mesh per batch (`static:<material>` or `part:<id>`, `userData.material`, `userData.part`), part groups at their\n * pivots, an `InstancedMesh` per instanced batch, and a `LOD` (levels at their distances, nothing from `cullDistance`) when there are levels.\n */\nexport function toObject3D(THREE: Three, buffers: ShapeBuffers, options: ToObjectOptions = {}): ShapeObject {\n const shadows = options.shadows !== false\n const ids = new Set<string>()\n for (const level of buffers.levels) {\n for (const b of level.batches) ids.add(b.material)\n for (const b of level.instanced) ids.add(b.material)\n }\n const made = createMaterials(THREE, buffers.materials, [...ids].filter((id) => !options.materials?.[id]))\n const materials: Record<string, THREE_NS.Material> = { ...made, ...(options.materials ?? {}) }\n const materialOf = (id: string, part: string | null): THREE_NS.Material => options.materialFor?.(id, part) ?? (materials[id] as THREE_NS.Material)\n const meshes: THREE_NS.Mesh[] = []\n const instanced: THREE_NS.InstancedMesh[] = []\n\n const build = (level: ShapeLevel, withParts: boolean): { group: THREE_NS.Group; parts: Record<string, THREE_NS.Group> } => {\n const group = new THREE.Group()\n group.name = options.name ?? buffers.name ?? 'shape'\n const parts: Record<string, THREE_NS.Group> = {}\n if (withParts) {\n for (const part of buffers.parts) {\n const g = new THREE.Group()\n g.name = `part:${part.id}`\n g.userData.part = part.id\n placePart(THREE, g, part)\n parts[part.id] = g\n }\n }\n const into = (part: string | null): THREE_NS.Object3D => (part !== null && parts[part]) || group\n for (const batch of level.batches) {\n const mesh = new THREE.Mesh(toGeometry(THREE, batch, { copy: options.copy !== false }), materialOf(batch.material, batch.part))\n mesh.geometry.computeBoundingSphere()\n mesh.geometry.computeBoundingBox()\n mesh.name = batch.part === null ? `static:${batch.material}` : `part:${batch.part}`\n if (batch.part !== null) mesh.userData.part = batch.part\n mesh.userData.material = batch.material\n if (batch.ranges.length) mesh.userData.ranges = batch.ranges\n mesh.castShadow = shadows\n mesh.receiveShadow = shadows\n into(batch.part).add(mesh)\n meshes.push(mesh)\n }\n for (const batch of level.instanced) {\n const mesh = new THREE.InstancedMesh(toGeometry(THREE, batch.geometry, { copy: options.copy !== false }), materialOf(batch.material, batch.part), batch.count)\n mesh.instanceMatrix.array.set(batch.matrices)\n mesh.instanceMatrix.needsUpdate = true\n if (batch.colors) mesh.instanceColor = new THREE.InstancedBufferAttribute(batch.colors.slice(), 3)\n mesh.name = `instanced:${batch.name ?? batch.material}`\n mesh.userData.material = batch.material\n if (batch.part !== null) mesh.userData.part = batch.part\n mesh.castShadow = shadows\n mesh.receiveShadow = shadows\n mesh.computeBoundingSphere()\n into(batch.part).add(mesh)\n instanced.push(mesh)\n }\n for (const part of Object.values(parts)) group.add(part)\n return { group, parts }\n }\n\n const levels = buffers.levels\n const first = build(levels[0] ?? { distance: 0, detail: 1, batches: [], instanced: [] }, true)\n let object: THREE_NS.Object3D = first.group\n if (levels.length > 1 || buffers.cullDistance !== undefined) {\n const lod = new THREE.LOD()\n lod.name = first.group.name\n lod.addLevel(first.group, 0)\n for (const level of levels.slice(1)) lod.addLevel(build(level, false).group, level.distance)\n if (buffers.cullDistance !== undefined) lod.addLevel(new THREE.Group(), buffers.cullDistance)\n object = lod\n }\n object.userData.points = buffers.points\n return { object, near: first.group, parts: first.parts, meshes, instanced, points: buffers.points, materials }\n}\n","import { mergeTransformed } from '@adatechnology/game-shapes'\nimport type { TransformedPiece } from '@adatechnology/game-shapes'\nimport type * as THREE_NS from 'three'\n\nimport type { Three } from './geometry'\n\nconst isVisible = (object: THREE_NS.Object3D): boolean => {\n for (let node: THREE_NS.Object3D | null = object; node; node = node.parent) if (!node.visible) return false\n return true\n}\n\n/** A plain, non-interleaved, not normalised Float32 attribute: what the core merge reads directly. */\nconst plain = (attribute: THREE_NS.BufferAttribute | THREE_NS.InterleavedBufferAttribute | undefined): attribute is THREE_NS.BufferAttribute =>\n attribute !== undefined && !(attribute as THREE_NS.InterleavedBufferAttribute).isInterleavedBufferAttribute && attribute.array instanceof Float32Array && !attribute.normalized\n\n/** Arrays of a geometry the core merge can take as they are; for anything else, the arrays three's own `toNonIndexed` makes (then not indexed). */\nfunction piece(geometry: THREE_NS.BufferGeometry, matrix: THREE_NS.Matrix4): TransformedPiece {\n const position = geometry.getAttribute('position')\n const normal = geometry.getAttribute('normal')\n const uv = geometry.getAttribute('uv')\n const ok = plain(position) && (normal === undefined || plain(normal)) && (uv === undefined || plain(uv)) && position.itemSize === 3 && (uv === undefined || uv.itemSize === 2)\n if (ok) {\n return { positions: position.array, ...(normal ? { normals: normal.array } : {}), ...(uv ? { uvs: uv.array } : {}), indices: geometry.index ? geometry.index.array : null, matrix: matrix.elements }\n }\n const flat = geometry.index ? geometry.toNonIndexed() : geometry\n const read = (name: string, size: number): Float32Array | undefined => {\n const attribute = flat.getAttribute(name)\n if (!attribute) return undefined\n const out = new Float32Array(attribute.count * size)\n for (let i = 0; i < attribute.count; i++) for (let c = 0; c < size; c++) out[i * size + c] = c === 0 ? attribute.getX(i) : c === 1 ? attribute.getY(i) : attribute.getZ(i)\n return out\n }\n const positions = read('position', 3) as Float32Array\n const normals = read('normal', 3)\n const uvs = read('uv', 2)\n if (flat !== geometry) flat.dispose()\n return { positions, ...(normals ? { normals } : {}), ...(uvs ? { uvs } : {}), indices: null, matrix: matrix.elements }\n}\n\n/**\n * Every visible mesh under `root` (whose world matrix must be up to date), baked into the space of `space` and joined by material: one non-indexed\n * mesh per material (position, normal, uv), no shadow cast. The bake is game-shapes' `mergeTransformed`, bit-identical to three's\n * `toNonIndexed` + `applyMatrix4` + join, so the result is the one `game-props3d`'s `mergeByMaterial` always gave.\n */\nexport function mergeByMaterial(THREE: Three, root: THREE_NS.Object3D, space: THREE_NS.Object3D): THREE_NS.Mesh[] {\n const toSpace = space.matrixWorld.clone().invert()\n const byMaterial = new Map<THREE_NS.Material, TransformedPiece[]>()\n root.traverse((object) => {\n const mesh = object as THREE_NS.Mesh\n if (!mesh.isMesh || Array.isArray(mesh.material) || !isVisible(mesh)) return\n const list = byMaterial.get(mesh.material) ?? []\n list.push(piece(mesh.geometry, new THREE.Matrix4().multiplyMatrices(toSpace, mesh.matrixWorld)))\n byMaterial.set(mesh.material, list)\n })\n return [...byMaterial].map(([material, pieces]) => {\n const merged = mergeTransformed(pieces)\n const geometry = new THREE.BufferGeometry()\n geometry.setAttribute('position', new THREE.BufferAttribute(merged.positions, 3))\n geometry.setAttribute('normal', new THREE.BufferAttribute(merged.normals, 3))\n geometry.setAttribute('uv', new THREE.BufferAttribute(merged.uvs, 2))\n const mesh = new THREE.Mesh(geometry, material)\n mesh.castShadow = false\n mesh.receiveShadow = true\n return mesh\n })\n}\n","import type * as ThreeNS from 'three'\n\nexport type Vec3 = [number, number, number]\ntype ThreeLib = typeof ThreeNS\n\n/**\n * Points of a hanging cord between `a` and `b` (n points including both ends, n >= 2). The deepest point sits `sag` meters below\n * the straight line between the ends, on a real catenary (y = a cosh(x/a)); when the ends differ in height the curve is\n * measured against the straight line between them.\n */\nexport function catenary(a: Vec3, b: Vec3, sag: number, n = 12): Vec3[] {\n const count = Math.max(2, Math.floor(n))\n const span = Math.hypot(b[0] - a[0], b[2] - a[2]) || Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2])\n const depth = Math.max(0, sag)\n const out: Vec3[] = []\n // Solve depth = c (cosh(span / 2c) - 1) for c by bisection (depth grows as c shrinks).\n let shape: (s: number) => number = () => 0\n if (depth > 1e-6 && span > 1e-6) {\n let lo = 1e-4\n let hi = span * 1000\n for (let i = 0; i < 80; i++) {\n const c = (lo + hi) / 2\n const d = c * (Math.cosh(span / (2 * c)) - 1)\n if (d > depth) lo = c\n else hi = c\n }\n const c = (lo + hi) / 2\n shape = (s) => c * (Math.cosh(((s - 0.5) * span) / c) - Math.cosh(span / (2 * c)))\n }\n for (let i = 0; i < count; i++) {\n const s = i / (count - 1)\n out.push([a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s + shape(s), a[2] + (b[2] - a[2]) * s])\n }\n return out\n}\n\n/** A thin tube through `points` (Catmull-Rom smoothed) for wires, cords and conduits. */\nexport function createCord(THREE: ThreeLib, points: readonly Vec3[], radius: number, material: ThreeNS.Material, radialSegments = 5): ThreeNS.Mesh {\n if (points.length < 2) throw new Error('createCord needs at least two points')\n const curve = new THREE.CatmullRomCurve3(points.map((p) => new THREE.Vector3(p[0], p[1], p[2])), false, 'centripetal')\n const segments = Math.max(4, (points.length - 1) * 4)\n const mesh = new THREE.Mesh(new THREE.TubeGeometry(curve, segments, radius, radialSegments, false), material)\n mesh.name = 'cord'\n mesh.castShadow = true\n return mesh\n}\n","import type * as THREE_NS from 'three'\n\n/** What `releaseObject3D` freed. */\nexport interface ReleaseReport {\n geometries: number\n materials: number\n textures: number\n}\n\nexport interface ReleaseOptions {\n /**\n * Trees that stay drawn (usually the scene): a geometry, material or texture any of them still uses is kept, so a resource shared by a clone that is\n * still on screen (a catalogue model, a material of the kit's palette) is not freed under it.\n */\n keep?: THREE_NS.Object3D | readonly THREE_NS.Object3D[]\n}\n\ntype Disposable = { dispose(): void; userData?: Record<string, unknown> }\ntype Owner = {\n geometry?: Disposable\n material?: THREE_NS.Material | THREE_NS.Material[]\n skeleton?: { dispose(): void }\n traverse(fn: (o: THREE_NS.Object3D) => void): void\n}\n\nconst isTexture = (v: unknown): v is THREE_NS.Texture => !!v && typeof v === 'object' && (v as { isTexture?: boolean }).isTexture === true\n\nfunction texturesOf(material: THREE_NS.Material, out: Set<THREE_NS.Texture>): void {\n for (const value of Object.values(material)) if (isTexture(value)) out.add(value)\n const uniforms = (material as { uniforms?: Record<string, { value?: unknown }> }).uniforms\n if (uniforms) for (const u of Object.values(uniforms)) if (isTexture(u?.value)) out.add(u.value)\n}\n\nfunction collect(roots: readonly THREE_NS.Object3D[]): { geometries: Set<Disposable>; materials: Set<THREE_NS.Material>; textures: Set<THREE_NS.Texture>; skeletons: Set<{ dispose(): void }> } {\n const geometries = new Set<Disposable>()\n const materials = new Set<THREE_NS.Material>()\n const textures = new Set<THREE_NS.Texture>()\n const skeletons = new Set<{ dispose(): void }>()\n for (const root of roots) {\n root.traverse((object) => {\n const o = object as unknown as Owner\n if (o.geometry && typeof o.geometry.dispose === 'function') geometries.add(o.geometry)\n if (o.skeleton && typeof o.skeleton.dispose === 'function') skeletons.add(o.skeleton)\n const list = Array.isArray(o.material) ? o.material : o.material ? [o.material] : []\n for (const m of list) {\n if (!m || typeof m.dispose !== 'function') continue\n materials.add(m)\n texturesOf(m, textures)\n }\n })\n }\n return { geometries, materials, textures, skeletons }\n}\n\nconst marked = new WeakSet<object>()\n/**\n * Marks geometries, materials or textures as shared on purpose (a palette, a model kit, a catalog): `releaseObject3D` and `discardObject3D` never free\n * them. Same as `userData.shared = true`, without touching the resource (its bytes and userData stay as they were, for digests and goldens).\n */\nexport function markShared<T extends object>(...resources: T[]): T[] {\n for (const resource of resources) marked.add(resource)\n return resources\n}\nconst shared = (r: { userData?: Record<string, unknown> }): boolean => r.userData?.shared === true || marked.has(r)\n\n/**\n * Free the GPU side of trees taken out of the scene: their geometries, materials, textures (maps and shader uniforms) and skeletons. three.js keeps a removed\n * mesh's buffers, programs and textures on the GPU (and the JS objects in its caches) until `dispose()`, so every object a game removes without this stays\n * in memory for good. A resource marked `userData.shared = true`, or still used by a tree in `keep`, is left alone. Disposing a resource that is used again\n * later is safe: three.js uploads it again on the next draw.\n */\nexport function releaseObject3D(roots: THREE_NS.Object3D | readonly THREE_NS.Object3D[], options: ReleaseOptions = {}): ReleaseReport {\n const list = (Array.isArray(roots) ? roots : [roots]) as THREE_NS.Object3D[]\n const report: ReleaseReport = { geometries: 0, materials: 0, textures: 0 }\n if (list.length === 0) return report\n const found = collect(list)\n const keepRoots = options.keep === undefined ? [] : ((Array.isArray(options.keep) ? options.keep : [options.keep]) as THREE_NS.Object3D[])\n // a released tree still hanging under a kept one is not \"kept\": skip it while walking the kept trees\n const releasing = new Set<THREE_NS.Object3D>(list)\n for (const keep of keepRoots) {\n const walk = (o: THREE_NS.Object3D): void => {\n if (releasing.has(o)) return\n const owner = o as unknown as Owner\n if (owner.geometry) found.geometries.delete(owner.geometry)\n if (owner.skeleton) found.skeletons.delete(owner.skeleton)\n const mats = Array.isArray(owner.material) ? owner.material : owner.material ? [owner.material] : []\n for (const m of mats) {\n if (!m) continue\n found.materials.delete(m)\n const t = new Set<THREE_NS.Texture>()\n texturesOf(m, t)\n for (const x of t) found.textures.delete(x)\n }\n for (const c of o.children) walk(c)\n }\n walk(keep)\n }\n for (const g of found.geometries) {\n if (shared(g)) continue\n g.dispose()\n report.geometries++\n }\n for (const m of found.materials) {\n if (shared(m as unknown as Disposable)) continue\n m.dispose()\n report.materials++\n }\n for (const t of found.textures) {\n if (shared(t as unknown as Disposable)) continue\n t.dispose()\n report.textures++\n }\n for (const s of found.skeletons) s.dispose()\n return report\n}\n\n/**\n * Take `objects` out of their trees and free what only they used (`releaseObject3D`, keeping whatever the rest of those trees, usually the scene,\n * still draws). The one call for pieces, fragments, helpers or bodies that leave the game for good. A list costs one walk of each scene, so pass\n * the whole list instead of calling it once per object.\n */\nexport function discardObject3D(objects: THREE_NS.Object3D | readonly THREE_NS.Object3D[], options: ReleaseOptions = {}): ReleaseReport {\n const list = (Array.isArray(objects) ? objects : [objects]) as THREE_NS.Object3D[]\n const keep = options.keep === undefined ? [] : Array.isArray(options.keep) ? [...(options.keep as THREE_NS.Object3D[])] : [options.keep as THREE_NS.Object3D]\n for (const object of list) {\n let top = object\n while (top.parent) top = top.parent\n object.removeFromParent()\n if (top !== object && !keep.includes(top)) keep.push(top)\n }\n return releaseObject3D(list, { keep })\n}\n","import type * as THREE_NS from 'three'\n\n/** A mesh (or a subclass: skinned, instanced) found while walking a tree; three marks them with `isMesh`. */\nexport function isMesh(o: THREE_NS.Object3D | null | undefined): o is THREE_NS.Mesh {\n return !!o && (o as Partial<THREE_NS.Mesh>).isMesh === true\n}\n","import type * as THREE_NS from 'three'\n\n/** How many declared writes a position attribute keeps: a host that missed an older one measures every part of the mesh again. */\nconst KEPT = 256\n\n/** The vertex ranges each declared write covered, by the attribute's `version` right after it. */\nconst declared = new WeakMap<object, Map<number, Array<readonly [number, number]>>>()\n\n/**\n * Flags the mesh's positions for upload (`needsUpdate`) and declares that the write changed the vertices `[v0, v1)`: the write and its declaration share one `version`,\n * so call it once per range written instead of setting `needsUpdate` yourself. A drawing that shares a\n * merged mesh with another that measures its ranges (the house collapsing the range of a wall it draws with holes, under the destruction renderer that measures each\n * part's range as a collider) calls it, so only the parts drawn by that range are measured again, not the whole house (`rangesWrittenSince`). A write that sets `needsUpdate` and declares nothing still counts, for every part of the mesh (`CLAUDE.md` §12).\n */\nexport function markPositionsWritten(mesh: THREE_NS.Mesh, v0: number, v1: number): void {\n const position = mesh.geometry?.getAttribute('position') as THREE_NS.BufferAttribute | undefined\n if (!position) return\n position.needsUpdate = true\n if (v1 <= v0) return\n let log = declared.get(position)\n if (!log) {\n log = new Map()\n declared.set(position, log)\n }\n const ranges = log.get(position.version)\n if (ranges) ranges.push([v0, v1])\n else log.set(position.version, [[v0, v1]])\n if (log.size > KEPT) log.delete(log.keys().next().value as number)\n}\n\n/** The ranges written after `version` up to the attribute's version now, or null when one of those writes declared no range (or is forgotten). */\nexport function rangesWrittenSince(position: THREE_NS.BufferAttribute, version: number): Array<readonly [number, number]> | null {\n const log = declared.get(position)\n const out: Array<readonly [number, number]> = []\n for (let v = version + 1; v <= position.version; v++) {\n const ranges = log?.get(v)\n if (!ranges) return null\n out.push(...ranges)\n }\n return out\n}\n","import type * as THREE_NS from 'three'\nimport { coincidentFaces } from '@adatechnology/game-shapes'\nimport type { CoincidentBatch, CoincidentFaceHit, CoincidentFacesOptions } from '@adatechnology/game-shapes'\n\nexport { GAME_DEPTH_PRECISION, depthResolution, describeCoincidentFaces } from '@adatechnology/game-shapes'\nexport type { CoincidentFaceHit, DepthPrecision } from '@adatechnology/game-shapes'\n\nimport { isMesh } from './guards'\n\nexport interface CoincidentFacesOfOptions extends CoincidentFacesOptions {\n /** Also check meshes that are hidden now (a piece that only shows when the wall breaks). Default false: only what is drawn. */\n readonly includeHidden?: boolean\n}\n\ntype Material = THREE_NS.Material & { polygonOffset?: boolean; name?: string }\n\n/** A LOD draws one level at a time: only the nearest one is checked, the others never share a frame with it. */\nfunction isFartherLevel(o: THREE_NS.Object3D): boolean {\n const lod = o.parent as (THREE_NS.LOD & { isLOD?: boolean }) | null\n return !!lod?.isLOD && lod.levels.length > 0 && lod.levels[0]!.object !== o\n}\n\nfunction isDrawn(node: THREE_NS.Object3D, root: THREE_NS.Object3D): boolean {\n for (let o: THREE_NS.Object3D | null = node; o; o = o.parent) {\n if (!o.visible || isFartherLevel(o)) return false\n if (o === root) return true\n }\n return true\n}\n\n/** A decal pushed forward with polygonOffset lies on its surface by design: the GPU orders it, it does not flicker. */\nfunction isOffsetDecal(mesh: THREE_NS.Mesh): boolean {\n const materials = (Array.isArray(mesh.material) ? mesh.material : [mesh.material]) as Material[]\n return materials.length > 0 && materials.every((m) => m?.polygonOffset === true)\n}\n\nfunction labelOf(mesh: THREE_NS.Mesh, root: THREE_NS.Object3D): string {\n const names: string[] = []\n for (let o: THREE_NS.Object3D | null = mesh; o && o !== root; o = o.parent) {\n const part = (o.userData as { destructionPart?: unknown } | undefined)?.destructionPart\n const name = o.name || (typeof part === 'string' ? part : '')\n if (name) names.unshift(name)\n }\n const material = (Array.isArray(mesh.material) ? mesh.material[0] : mesh.material) as Material | undefined\n const path = names.join('/') || mesh.type\n return material?.name ? `${path} [${material.name}]` : path\n}\n\n/** World-space positions of one mesh (or of one instance of an InstancedMesh). */\nfunction worldPositions(position: THREE_NS.BufferAttribute | THREE_NS.InterleavedBufferAttribute, matrix: THREE_NS.Matrix4): Float64Array {\n const e = matrix.elements\n const out = new Float64Array(position.count * 3)\n for (let i = 0; i < position.count; i++) {\n const x = position.getX(i), y = position.getY(i), z = position.getZ(i)\n const w = e[3]! * x + e[7]! * y + e[11]! * z + e[15]! || 1\n out[i * 3] = (e[0]! * x + e[4]! * y + e[8]! * z + e[12]!) / w\n out[i * 3 + 1] = (e[1]! * x + e[5]! * y + e[9]! * z + e[13]!) / w\n out[i * 3 + 2] = (e[2]! * x + e[6]! * y + e[10]! * z + e[14]!) / w\n }\n return out\n}\n\n/** three's DoubleSide. */\nconst DOUBLE_SIDE = 2\n\nfunction isDoubleSided(mesh: THREE_NS.Mesh): boolean {\n const materials = (Array.isArray(mesh.material) ? mesh.material : [mesh.material]) as THREE_NS.Material[]\n return materials.some((m) => m?.side === DOUBLE_SIDE)\n}\n\ntype Shaded = THREE_NS.Material & { readonly vertexColors?: boolean; readonly map?: unknown; readonly normalMap?: unknown; readonly bumpMap?: unknown; readonly alphaMap?: unknown; readonly roughnessMap?: unknown }\n\nconst attributeValues = (attribute: THREE_NS.BufferAttribute | THREE_NS.InterleavedBufferAttribute, size: number): number[] => {\n const out = new Array<number>(attribute.count * size)\n const read = [(i: number): number => attribute.getX(i), (i: number): number => attribute.getY(i), (i: number): number => attribute.getZ(i)]\n for (let i = 0; i < attribute.count; i++) for (let k = 0; k < size; k++) out[i * size + k] = read[k]!(i)\n return out\n}\n\n/** How the mesh is shaded, for the near mode's test of faces that draw the same pixels: one material (its identity), its vertex colours and, when textured, its UVs. */\nfunction lookOf(mesh: THREE_NS.Mesh, geometry: THREE_NS.BufferGeometry): Pick<CoincidentBatch, 'look' | 'colors' | 'uvs'> {\n if (Array.isArray(mesh.material)) return {}\n const material = mesh.material as Shaded\n const color = material.vertexColors ? geometry.getAttribute('color') : undefined\n const textured = Boolean(material.map || material.normalMap || material.bumpMap || material.alphaMap || material.roughnessMap)\n const uv = textured ? geometry.getAttribute('uv') : undefined\n if (textured && !uv) return {}\n return { look: material.uuid, ...(color ? { colors: attributeValues(color, 3) } : {}), ...(uv ? { uvs: attributeValues(uv, 2) } : {}) }\n}\n\n// only what the GPU draws: a geometry that reuses bigger buffers keeps stale triangles past its draw range\nfunction drawnIndices(geometry: THREE_NS.BufferGeometry): ArrayLike<number> | undefined {\n const { start, count } = geometry.drawRange\n const index = geometry.index?.array\n const total = index ? index.length : geometry.getAttribute('position').count\n const end = Math.min(total, start + (Number.isFinite(count) ? count : total))\n if (index) return start === 0 && end === index.length ? index : Array.from(index).slice(start, end)\n if (start === 0 && end === total) return undefined\n return Array.from({ length: end - start }, (_, i) => start + i)\n}\n\nfunction batchesOfMesh(mesh: THREE_NS.Mesh, label: string): CoincidentBatch[] {\n const doubleSided = isDoubleSided(mesh)\n const geometry = mesh.geometry as THREE_NS.BufferGeometry | undefined\n const position = geometry?.getAttribute('position')\n if (!geometry || !position) return []\n const indices = drawnIndices(geometry)\n const instanced = mesh as THREE_NS.InstancedMesh\n const look = lookOf(mesh, geometry)\n if (!instanced.isInstancedMesh) return [{ positions: worldPositions(position, mesh.matrixWorld), ...(indices ? { indices } : {}), label, doubleSided, ...look }]\n const batches: CoincidentBatch[] = []\n const instance = mesh.matrixWorld.clone()\n // instances of one colour each are told apart by it: an instance colour joins the look\n const tint = instanced.instanceColor\n for (let i = 0; i < instanced.count; i++) {\n instanced.getMatrixAt(i, instance)\n instance.premultiply(mesh.matrixWorld)\n const instanceLook = tint && look.look !== undefined ? { ...look, look: `${look.look}:${tint.getX(i)},${tint.getY(i)},${tint.getZ(i)}` } : look\n batches.push({ positions: worldPositions(position, instance), ...(indices ? { indices } : {}), label: `${label} #${i}`, doubleSided, ...instanceLook })\n }\n return batches\n}\n\nexport interface MeshBatches {\n readonly batches: CoincidentBatch[]\n /** The mesh each batch came from, at the same index. */\n readonly meshes: THREE_NS.Mesh[]\n}\n\n/** The triangles of every drawn mesh under `root`, in world space, with the mesh of each batch. */\nexport function meshBatchesOf(root: THREE_NS.Object3D, options: Pick<CoincidentFacesOfOptions, 'includeHidden'> = {}): MeshBatches {\n root.updateMatrixWorld(true)\n const batches: CoincidentBatch[] = []\n const meshes: THREE_NS.Mesh[] = []\n root.traverse((node) => {\n if (!isMesh(node) || (node as THREE_NS.Object3D & { isSprite?: boolean }).isSprite) return\n if (!options.includeHidden && !isDrawn(node, root)) return\n if (isOffsetDecal(node)) return\n for (const batch of batchesOfMesh(node, labelOf(node, root))) {\n batches.push(batch)\n meshes.push(node)\n }\n })\n return { batches, meshes }\n}\n\n/** The triangles of every drawn mesh under `root`, in world space, ready for `coincidentFaces`. */\nexport function coincidentBatchesOf(root: THREE_NS.Object3D, options: Pick<CoincidentFacesOfOptions, 'includeHidden'> = {}): CoincidentBatch[] {\n return meshBatchesOf(root, options).batches\n}\n\n/**\n * Faces of `root` that z-fight: same plane, same facing, overlapping. Use it in the catalog test of every package that draws pieces, so a\n * piece that comes back with a lining flush to its body fails the test instead of flickering on screen.\n */\nexport function coincidentFacesOf(root: THREE_NS.Object3D, options: CoincidentFacesOfOptions = {}): CoincidentFaceHit[] {\n const { batches, meshes } = meshBatchesOf(root, options)\n return coincidentFaces(batches, options).filter((hit) => writesDepth(meshes[hit.batchA]!) || writesDepth(meshes[hit.batchB]!))\n}\n\n/** Two layers that both leave the depth buffer alone (smoke, glow, sparks) are blended in order: they never fight for a pixel. */\nfunction writesDepth(mesh: THREE_NS.Mesh): boolean {\n const materials = (Array.isArray(mesh.material) ? mesh.material : [mesh.material]) as THREE_NS.Material[]\n return materials.some((m) => m.depthWrite !== false && m.depthTest !== false)\n}\n","import type * as THREE_NS from 'three'\nimport { coincidentFaces } from '@adatechnology/game-shapes'\nimport type { CoincidentFaceHit } from '@adatechnology/game-shapes'\n\nimport { meshBatchesOf } from './coincident'\n\nexport interface StandOutOptions {\n /** How far a fighting face of the smaller piece moves out, in metres. Default 0.002 (CLAUDE.md §13). */\n readonly gap?: number\n /** Rounds of check-and-move; a moved face can meet a third piece. Default 3. */\n readonly rounds?: number\n}\n\nexport interface StandOutReport {\n /** Meshes that were moved out. */\n readonly grown: number\n /** Face pairs still fighting after the last round (0 when it worked). */\n readonly left: number\n}\n\n/** How each side of a mesh's own box moves, `[-x, +x, -y, +y, -z, +z]`: 1 out, -1 in, 0 stays. */\ntype Sides = [number, number, number, number, number, number]\n\nfunction localSize(mesh: THREE_NS.Mesh, out: THREE_NS.Vector3): THREE_NS.Vector3 {\n const geometry = mesh.geometry as THREE_NS.BufferGeometry\n if (!geometry.boundingBox) geometry.computeBoundingBox()\n return geometry.boundingBox!.getSize(out)\n}\n\n/** Volume of the mesh's box in the world: the smaller of a fighting pair is the detail that moves. */\nfunction volumeOf(mesh: THREE_NS.Mesh): number {\n const size = localSize(mesh, mesh.position.clone())\n const scale = mesh.getWorldScale(mesh.position.clone())\n return Math.max(Math.abs(size.x * scale.x), 1e-4) * Math.max(Math.abs(size.y * scale.y), 1e-4) * Math.max(Math.abs(size.z * scale.z), 1e-4)\n}\n\n/** Marks the side of the mesh's box that faces along the world normal of the hit, to go out (1) or in (-1). */\nfunction markSide(mesh: THREE_NS.Mesh, hit: CoincidentFaceHit, sides: Sides, way: 1 | -1): void {\n const inverse = mesh.getWorldQuaternion(mesh.quaternion.clone()).invert()\n const n = mesh.position.clone().set(hit.normal[0], hit.normal[1], hit.normal[2]).applyQuaternion(inverse)\n const scale = mesh.getWorldScale(mesh.position.clone())\n const local = [n.x * Math.sign(scale.x || 1), n.y * Math.sign(scale.y || 1), n.z * Math.sign(scale.z || 1)]\n const axis = local.reduce((best, v, i) => (Math.abs(v) > Math.abs(local[best]!) ? i : best), 0)\n sides[axis * 2 + (local[axis]! > 0 ? 1 : 0)] = way\n}\n\n/** Moves the marked sides of the mesh's box `gap` metres out or in (in the world), keeping the other sides where they are. */\nfunction pushSides(mesh: THREE_NS.Mesh, sides: Sides, gap: number): void {\n const size = localSize(mesh, mesh.position.clone())\n const world = mesh.getWorldScale(mesh.position.clone())\n const shift = mesh.position.clone().set(0, 0, 0)\n const scale = [mesh.scale.x, mesh.scale.y, mesh.scale.z]\n const extent = [size.x, size.y, size.z]\n const worldScale = [Math.abs(world.x), Math.abs(world.y), Math.abs(world.z)]\n const centre = mesh.geometry.boundingBox!.getCenter(mesh.position.clone())\n const centres = [centre.x, centre.y, centre.z]\n for (let axis = 0; axis < 3; axis++) {\n const minus = sides[axis * 2]! * gap, plus = sides[axis * 2 + 1]! * gap\n const s = extent[axis]! * worldScale[axis]!\n if ((!minus && !plus) || s < 1e-6 || s + minus + plus < s / 2) continue\n const oldScale = scale[axis]!\n scale[axis] = (oldScale * (s + minus + plus)) / s\n // in the parent's frame the centre moves by half the difference of the two sides, so a side that is not marked stays where it was\n const parentPerWorld = oldScale / worldScale[axis]!\n const outward = ((plus - minus) / 2) * parentPerWorld\n const recentre = centres[axis]! * (oldScale - scale[axis]!)\n shift.setComponent(axis, outward + recentre)\n }\n mesh.scale.set(scale[0]!, scale[1]!, scale[2]!)\n mesh.position.add(shift.applyQuaternion(mesh.quaternion))\n mesh.updateMatrixWorld(true)\n}\n\n/**\n * Makes the faces of `root` stop fighting: of each pair of meshes with coincident faces, the face of the smaller one (the label, band, rim\n * or lining) moves `gap` out of the bigger one, the rule of `CLAUDE.md` §13 (\"a detail stands out at least 2 mm\"). Only the sides that\n * fight move. For pieces ported as they were drawn, where the detail sits flush on its body; a builder of the kit draws the gap itself.\n * Instanced meshes are left alone.\n */\nexport function standOutCoincident(root: THREE_NS.Object3D, options: StandOutOptions = {}): StandOutReport {\n const gap = options.gap ?? 0.002\n const grown = new Set<THREE_NS.Mesh>()\n const volumes = new Map<THREE_NS.Mesh, number>()\n const volume = (mesh: THREE_NS.Mesh): number => volumes.get(mesh) ?? volumes.set(mesh, volumeOf(mesh)).get(mesh)!\n let left = 0\n for (let round = 0; round < (options.rounds ?? 3); round++) {\n const { batches, meshes } = meshBatchesOf(root)\n const hits = coincidentFaces(batches, { maxHits: Number.POSITIVE_INFINITY })\n left = hits.length\n if (!left) break\n const toPush = new Map<THREE_NS.Mesh, Sides>()\n for (const hit of hits) {\n const a = meshes[hit.batchA]!, b = meshes[hit.batchB]!\n const [smaller, bigger] = volume(a) <= volume(b) ? [a, b] : [b, a]\n // a piece moves once: when the detail already stood out, the piece it now meets moves instead (a piece never grows twice)\n const mesh = grown.has(smaller) ? bigger : smaller\n if (grown.has(mesh) || (mesh as THREE_NS.InstancedMesh).isInstancedMesh) continue\n const sides = toPush.get(mesh) ?? [0, 0, 0, 0, 0, 0]\n markSide(mesh, hit, sides, 1)\n toPush.set(mesh, sides)\n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Q,OAAO;AAC3B,QAAM,QAAQ,oBAAI,IAAmB;AACrC,QAAM,UAAU,oBAAI,IAA2B;AAC/C,QAAM,SAAS,CAAC,SAAgC,QAAQ,IAAI,IAAI,KAAK,QAAQ,IAAI,MAAM,SAAS,IAAI,CAAC,EAAE,IAAI,IAAI;AAC/G,MAAI,OAAO;AACX,WAAS,QAAQ,GAAG,SAAS,QAAQ,UAAU,IAAI,SAAS;AAC1D,UAAM,EAAE,SAAS,OAAO,IAAI,cAAc,IAAI;AAC9C,UAAM,OAAOC,iBAAgB,SAAS,EAAE,SAAS,OAAO,kBAAkB,CAAC;AAC3E,WAAO,KAAK;AACZ,QAAI,CAAC,KAAM;AACX,UAAM,SAAS,oBAAI,IAA0B;AAC7C,eAAW,OAAO,MAAM;AACtB,YAAM,IAAI,OAAO,IAAI,MAAM,GAAI,IAAI,OAAO,IAAI,MAAM;AACpD,YAAM,CAAC,SAAS,MAAM,IAAI,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AAEjE,YAAM,OAAO,MAAM,IAAI,OAAO,IAAI,SAAS;AAC3C,UAAI,MAAM,IAAI,IAAI,KAAM,KAAgC,gBAAiB;AACzE,YAAM,QAAQ,OAAO,IAAI,IAAI,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACnD,eAAS,MAAM,KAAK,OAAO,CAAC;AAC5B,aAAO,IAAI,MAAM,KAAK;AAAA,IACxB;AACA,eAAW,CAAC,MAAM,KAAK,KAAK,QAAQ;AAClC,gBAAU,MAAM,OAAO,GAAG;AAC1B,YAAM,IAAI,IAAI;AAAA,IAChB;AAAA,EACF;AACA,SAAO,EAAE,OAAO,MAAM,MAAM,KAAK;AACnC;","names":["c","coincidentFaces","coincidentFaces"]}
1
+ {"version":3,"sources":["../src/geometry.ts","../src/namespace.ts","../src/object.ts","../src/merge-by-material.ts","../src/cord.ts","../src/release.ts","../src/guards.ts","../src/position-writes.ts","../src/coincident.ts","../src/stand-out.ts"],"sourcesContent":["import type { PrimitiveBuffers, ShapeBatch } from '@adatechnology/game-shapes'\nimport type * as THREE_NS from 'three'\n\nexport type Three = typeof THREE_NS\n\nexport interface ToGeometryOptions {\n /** Copy the arrays into the attributes (default true). Without a copy the geometry shares the buffers (a cached result is read-only: do not deform it). */\n readonly copy?: boolean\n}\n\n/** The order in which three's generator of each type sets its attributes (toJSON and attribute iteration keep it). */\nconst UV_BEFORE_NORMAL = new Set(['LatheGeometry', 'ExtrudeGeometry'])\n/** Types whose constructor sets the index before the attributes. */\nconst INDEX_FIRST = new Set(['BoxGeometry', 'CylinderGeometry', 'ConeGeometry', 'SphereGeometry', 'PlaneGeometry', 'CircleGeometry', 'RingGeometry', 'LatheGeometry', 'TorusGeometry'])\n\nconst isPrimitive = (value: PrimitiveBuffers | ShapeBatch): value is PrimitiveBuffers => typeof (value as PrimitiveBuffers).type === 'string'\n\n/** Three's own parameters object for a type (lathe points as `Vector2`). */\nfunction threeParameters(THREE: Three, p: PrimitiveBuffers): Record<string, unknown> {\n if (p.type === 'LatheGeometry') {\n const points = (p.parameters.points as Array<{ x: number; y: number }>).map(({ x, y }) => new THREE.Vector2(x, y))\n return { ...p.parameters, points }\n }\n return { ...p.parameters }\n}\n\n/**\n * A `BufferGeometry` from game-shapes buffers. A primitive becomes an instance of the three class it reproduces (`type`, `parameters`, prototype:\n * `instanceof THREE.CylinderGeometry`, `clone()` and `toJSON()` behave as three's), with the same attributes, index and groups. A batch gets\n * `position`, `normal`, `uv`, `color` (when present) and its index.\n */\nexport function toGeometry(THREE: Three, source: PrimitiveBuffers | ShapeBatch, options: ToGeometryOptions = {}): THREE_NS.BufferGeometry {\n const copy = options.copy !== false\n const primitive = isPrimitive(source) ? source : null\n const ThreeClass = primitive && primitive.type !== 'BufferGeometry' ? ((THREE as unknown as Record<string, unknown>)[primitive.type] as (new () => THREE_NS.BufferGeometry) | undefined) : undefined\n // the BufferGeometry constructor only, with the prototype of the class it stands for\n const geometry = (ThreeClass ? Reflect.construct(THREE.BufferGeometry, [], ThreeClass) : new THREE.BufferGeometry()) as THREE_NS.BufferGeometry & { parameters?: Record<string, unknown> }\n if (primitive && ThreeClass) {\n Object.assign(geometry, { type: primitive.type, parameters: threeParameters(THREE, primitive) })\n }\n const attribute = (array: Float32Array, size: number): THREE_NS.BufferAttribute => (copy ? new THREE.Float32BufferAttribute(array, size) : new THREE.BufferAttribute(array, size))\n const index = source.indices\n const setIndex = (): void => {\n if (!index) return\n geometry.setIndex(copy ? (index instanceof Uint32Array ? new THREE.Uint32BufferAttribute(index, 1) : new THREE.Uint16BufferAttribute(index, 1)) : new THREE.BufferAttribute(index, 1))\n }\n const type = primitive?.type ?? 'BufferGeometry'\n if (INDEX_FIRST.has(type)) setIndex()\n geometry.setAttribute('position', attribute(source.positions, 3))\n if (UV_BEFORE_NORMAL.has(type)) {\n geometry.setAttribute('uv', attribute(source.uvs, 2))\n geometry.setAttribute('normal', attribute(source.normals, 3))\n } else {\n geometry.setAttribute('normal', attribute(source.normals, 3))\n geometry.setAttribute('uv', attribute(source.uvs, 2))\n }\n if (!primitive && (source as ShapeBatch).colors) geometry.setAttribute('color', attribute((source as ShapeBatch).colors as Float32Array, 3))\n if (!INDEX_FIRST.has(type)) setIndex()\n if (primitive) for (const group of primitive.groups) geometry.addGroup(group.start, group.count, group.materialIndex)\n return geometry\n}\n","import { box, circle, cone, cylinder, extrude, lathe, plane, ring, sphere, torus } from '@adatechnology/game-shapes'\nimport type { BevelSpec, PrimitiveBuffers, PrimitiveNode, ShapeOutline, Vec2 } from '@adatechnology/game-shapes'\nimport { buildPrimitive } from '@adatechnology/game-shapes'\nimport type * as THREE_NS from 'three'\n\nimport { toGeometry } from './geometry'\nimport type { Three } from './geometry'\n\n/** The geometry constructors `shapeGeometries` replaces. */\nexport const SHAPE_GEOMETRY_TYPES = ['BoxGeometry', 'CylinderGeometry', 'ConeGeometry', 'SphereGeometry', 'PlaneGeometry', 'CircleGeometry', 'RingGeometry', 'LatheGeometry', 'TorusGeometry', 'ExtrudeGeometry'] as const\n\ntype Curve = { isLineCurve?: boolean; v1?: { x: number; y: number }; v2?: { x: number; y: number } }\ntype PathLike = { curves: Curve[]; autoClose?: boolean; holes?: PathLike[] }\n\n/** The point list of a path made only of contiguous `LineCurve`s (what `moveTo` + `lineTo` builds), or null. */\nfunction linePoints(path: PathLike): Vec2[] | null {\n if (path.autoClose || path.curves.length === 0) return null\n const points: Vec2[] = []\n for (const [index, curve] of path.curves.entries()) {\n if (!curve.isLineCurve || !curve.v1 || !curve.v2) return null\n if (index === 0) points.push([curve.v1.x, curve.v1.y])\n else {\n const last = points[points.length - 1] as Vec2\n if (last[0] !== curve.v1.x || last[1] !== curve.v1.y) return null\n }\n points.push([curve.v2.x, curve.v2.y])\n }\n return points\n}\n\ntype ExtrudeOptions = { depth?: number; steps?: number; bevelEnabled?: boolean; bevelThickness?: number; bevelSize?: number; bevelOffset?: number; bevelSegments?: number; extrudePath?: unknown; UVGenerator?: unknown; curveSegments?: number }\n\n/** An extrusion game-shapes can make exactly: one straight-edged shape, no path, the world uvs. */\nfunction extrudeOf(shapes: unknown, options: ExtrudeOptions = {}): PrimitiveBuffers | null {\n if (Array.isArray(shapes) || !shapes || options.extrudePath !== undefined || options.UVGenerator !== undefined) return null\n const shape = shapes as PathLike\n const outer = linePoints(shape)\n if (!outer) return null\n const holes: Vec2[][] = []\n for (const hole of shape.holes ?? []) {\n const points = linePoints(hole)\n if (!points) return null\n holes.push(points)\n }\n const outline: ShapeOutline = holes.length ? { outer, holes } : { outer }\n const bevel: false | BevelSpec =\n options.bevelEnabled === false\n ? false\n : {\n ...(options.bevelThickness !== undefined ? { thickness: options.bevelThickness } : {}),\n ...(options.bevelSize !== undefined ? { size: options.bevelSize } : {}),\n ...(options.bevelOffset !== undefined ? { offset: options.bevelOffset } : {}),\n ...(options.bevelSegments !== undefined ? { segments: options.bevelSegments } : {}),\n }\n return extrude(outline, options.depth, options.steps, bevel)\n}\n\nexport interface ShapeGeometriesOptions {\n /** Go through the template cache of game-shapes (default true): the same primitive is generated once per process. */\n readonly cache?: boolean\n}\n\nconst namespaces = new WeakMap<object, Map<string, Three>>()\n/** The namespaces this module made: wrapping one again gives it back (a package handing its `T` to another). */\nconst shims = new WeakSet<object>()\n\n/**\n * A three namespace whose `BoxGeometry`, `CylinderGeometry`, `ConeGeometry`, `SphereGeometry`, `PlaneGeometry`, `CircleGeometry`, `RingGeometry`,\n * `LatheGeometry`, `TorusGeometry` and (straight-edged) `ExtrudeGeometry` are made by game-shapes, bit-identical to three's and instances of three's\n * classes; everything else is three's own. Hand it to code ported from the teams as `T`, so it keeps reading `new T.CylinderGeometry(...)`.\n * An extrusion with curves, several shapes, a path or a custom uv generator falls back to three.\n */\nexport function shapeGeometries(THREE: Three, options: ShapeGeometriesOptions = {}): Three {\n if (shims.has(THREE)) return THREE\n const cache = options.cache !== false\n const key = cache ? 'cache' : 'nocache'\n let byKey = namespaces.get(THREE)\n if (!byKey) {\n byKey = new Map()\n namespaces.set(THREE, byKey)\n }\n const existing = byKey.get(key)\n if (existing) return existing\n const made = (p: PrimitiveBuffers): THREE_NS.BufferGeometry => toGeometry(THREE, p)\n const viaCache = (node: PrimitiveNode, direct: () => PrimitiveBuffers): PrimitiveBuffers => (cache ? buildPrimitive(node) : direct())\n const defined = <T extends object>(o: T): T => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as T\n const constructors = {\n BoxGeometry: (width?: number, height?: number, depth?: number, ws = 1, hs = 1, ds = 1) =>\n made(viaCache({ kind: 'box', size: [width ?? 1, height ?? 1, depth ?? 1], segments: [ws, hs, ds] }, () => box(width, height, depth, ws, hs, ds))),\n CylinderGeometry: (radiusTop?: number, radiusBottom?: number, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'cylinder', ...defined({ radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength }) }, () => cylinder(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength))),\n ConeGeometry: (radius?: number, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'cone', ...defined({ radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength }) }, () => cone(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength))),\n SphereGeometry: (radius?: number, widthSegments?: number, heightSegments?: number, phiStart?: number, phiLength?: number, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'sphere', ...defined({ radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength }) }, () => sphere(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength))),\n PlaneGeometry: (width?: number, height?: number, widthSegments?: number, heightSegments?: number) =>\n made(viaCache({ kind: 'plane', ...defined({ width, height, widthSegments, heightSegments }) }, () => plane(width, height, widthSegments, heightSegments))),\n CircleGeometry: (radius?: number, segments?: number, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'circle', ...defined({ radius, segments, thetaStart, thetaLength }) }, () => circle(radius, segments, thetaStart, thetaLength))),\n RingGeometry: (innerRadius?: number, outerRadius?: number, thetaSegments?: number, phiSegments?: number, thetaStart?: number, thetaLength?: number) =>\n made(viaCache({ kind: 'ring', ...defined({ innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength }) }, () => ring(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength))),\n LatheGeometry: (points?: Array<{ x: number; y: number }>, segments?: number, phiStart?: number, phiLength?: number) => {\n if (!points) return new THREE.LatheGeometry(undefined, segments, phiStart, phiLength)\n const profile = points.map((p) => [p.x, p.y] as const)\n return made(viaCache({ kind: 'lathe', points: profile, ...defined({ segments, phiStart, phiLength }) }, () => lathe(profile, segments, phiStart, phiLength)))\n },\n TorusGeometry: (radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, arc?: number) =>\n made(viaCache({ kind: 'torus', ...defined({ radius, tube, radialSegments, tubularSegments, arc }) }, () => torus(radius, tube, radialSegments, tubularSegments, arc))),\n ExtrudeGeometry: (shapes?: unknown, extrudeOptions?: ExtrudeOptions) => {\n const buffers = shapes === undefined ? null : extrudeOf(shapes, extrudeOptions)\n if (!buffers) return new THREE.ExtrudeGeometry(shapes as THREE_NS.Shape, extrudeOptions as THREE_NS.ExtrudeGeometryOptions)\n const geometry = toGeometry(THREE, buffers) as THREE_NS.BufferGeometry & { parameters: unknown }\n geometry.parameters = { shapes, options: extrudeOptions ?? {} }\n return geometry\n },\n } satisfies Record<(typeof SHAPE_GEOMETRY_TYPES)[number], (...args: never[]) => THREE_NS.BufferGeometry>\n const namespace: Record<string, unknown> = { ...(THREE as unknown as Record<string, unknown>) }\n for (const type of SHAPE_GEOMETRY_TYPES) {\n // three hands the constructor's own arguments through; each replacement takes the same ones\n const make = constructors[type] as (...args: unknown[]) => THREE_NS.BufferGeometry\n // callable with `new` (the returned object wins), and `instanceof` checks three's prototype\n const Constructor = function (this: unknown, ...args: unknown[]) {\n return make(...args)\n } as unknown as { prototype: unknown }\n Constructor.prototype = (THREE as unknown as Record<string, { prototype: unknown }>)[type]!.prototype\n Object.defineProperty(Constructor, 'name', { value: type })\n namespace[type] = Constructor\n }\n const result = namespace as unknown as Three\n byKey.set(key, result)\n shims.add(result)\n return result\n}\n","import { colorHex } from '@adatechnology/game-shapes'\nimport type { MaterialHint, ShapeBuffers, ShapeLevel, ShapePart, ShapePoint } from '@adatechnology/game-shapes'\nimport type * as THREE_NS from 'three'\n\nimport { toGeometry } from './geometry'\nimport type { Three } from './geometry'\n\n/** A `MeshStandardMaterial` per material id from the schema's hints (vertex colours on unless the hint says otherwise). */\nexport function createMaterials(THREE: Three, hints: Readonly<Record<string, MaterialHint>> = {}, ids: Iterable<string> = []): Record<string, THREE_NS.Material> {\n const out: Record<string, THREE_NS.Material> = {}\n const all = new Set([...Object.keys(hints), ...ids])\n for (const id of all) {\n const hint = hints[id] ?? {}\n const parameters: THREE_NS.MeshStandardMaterialParameters = { vertexColors: hint.vertexColors ?? true }\n if (hint.color !== undefined) parameters.color = colorHex(hint.color)\n if (hint.roughness !== undefined) parameters.roughness = hint.roughness\n if (hint.metalness !== undefined) parameters.metalness = hint.metalness\n if (hint.opacity !== undefined) parameters.opacity = hint.opacity\n if (hint.transparent !== undefined) parameters.transparent = hint.transparent\n if (hint.emissive !== undefined) parameters.emissive = colorHex(hint.emissive)\n if (hint.emissiveIntensity !== undefined) parameters.emissiveIntensity = hint.emissiveIntensity\n if (hint.flatShading !== undefined) parameters.flatShading = hint.flatShading\n if (hint.depthWrite !== undefined) parameters.depthWrite = hint.depthWrite\n if (hint.side !== undefined) parameters.side = hint.side === 'double' ? THREE.DoubleSide : hint.side === 'back' ? THREE.BackSide : THREE.FrontSide\n const material = new THREE.MeshStandardMaterial(parameters)\n material.name = id\n out[id] = material\n }\n return out\n}\n\nexport interface ToObjectOptions {\n /** Materials by id; missing ids get one from the schema hints (`createMaterials`). */\n readonly materials?: Readonly<Record<string, THREE_NS.Material>>\n /** The material of one draw (wins over `materials`): per material id and part (`null` for the static body). */\n readonly materialFor?: (material: string, part: string | null) => THREE_NS.Material | undefined\n /** Cast and receive shadows (default true). */\n readonly shadows?: boolean\n /** Copy the arrays into the attributes (default true; false shares them, read-only). */\n readonly copy?: boolean\n /** Name of the root. */\n readonly name?: string\n}\n\nexport interface ShapeObject {\n /** A `Group`, or a `LOD` when the shape has levels or a cull distance. */\n readonly object: THREE_NS.Object3D\n /** The level 0 group (the root itself without LOD). */\n readonly near: THREE_NS.Group\n /** Part groups of level 0 by id, at their pivots; animate these. */\n readonly parts: Record<string, THREE_NS.Group>\n readonly meshes: THREE_NS.Mesh[]\n readonly instanced: THREE_NS.InstancedMesh[]\n readonly points: readonly ShapePoint[]\n readonly materials: Record<string, THREE_NS.Material>\n}\n\nfunction placePart(THREE: Three, group: THREE_NS.Group, part: ShapePart): void {\n if (part.matrix && part.position === undefined && part.rotation === undefined && part.scale === undefined && part.heading === undefined) {\n new THREE.Matrix4().fromArray(part.matrix as number[]).decompose(group.position, group.quaternion, group.scale)\n return\n }\n if (part.position) group.position.set(part.position[0], part.position[1], part.position[2])\n if (part.heading !== undefined) group.rotation.y = part.heading\n else if (part.rotation) group.rotation.set(part.rotation[0], part.rotation[1], part.rotation[2], part.rotationOrder ?? 'XYZ')\n if (part.scale !== undefined) {\n if (typeof part.scale === 'number') group.scale.setScalar(part.scale)\n else group.scale.set(part.scale[0], part.scale[1], part.scale[2])\n }\n group.updateMatrix()\n}\n\n/**\n * The three objects of a shape: one mesh per batch (`static:<material>` or `part:<id>`, `userData.material`, `userData.part`), part groups at their\n * pivots, an `InstancedMesh` per instanced batch, and a `LOD` (levels at their distances, nothing from `cullDistance`) when there are levels.\n */\nexport function toObject3D(THREE: Three, buffers: ShapeBuffers, options: ToObjectOptions = {}): ShapeObject {\n const shadows = options.shadows !== false\n const ids = new Set<string>()\n for (const level of buffers.levels) {\n for (const b of level.batches) ids.add(b.material)\n for (const b of level.instanced) ids.add(b.material)\n }\n const made = createMaterials(THREE, buffers.materials, [...ids].filter((id) => !options.materials?.[id]))\n const materials: Record<string, THREE_NS.Material> = { ...made, ...(options.materials ?? {}) }\n const materialOf = (id: string, part: string | null): THREE_NS.Material => options.materialFor?.(id, part) ?? (materials[id] as THREE_NS.Material)\n const meshes: THREE_NS.Mesh[] = []\n const instanced: THREE_NS.InstancedMesh[] = []\n\n const build = (level: ShapeLevel, withParts: boolean): { group: THREE_NS.Group; parts: Record<string, THREE_NS.Group> } => {\n const group = new THREE.Group()\n group.name = options.name ?? buffers.name ?? 'shape'\n const parts: Record<string, THREE_NS.Group> = {}\n if (withParts) {\n for (const part of buffers.parts) {\n const g = new THREE.Group()\n g.name = `part:${part.id}`\n g.userData.part = part.id\n placePart(THREE, g, part)\n parts[part.id] = g\n }\n }\n const into = (part: string | null): THREE_NS.Object3D => (part !== null && parts[part]) || group\n for (const batch of level.batches) {\n const mesh = new THREE.Mesh(toGeometry(THREE, batch, { copy: options.copy !== false }), materialOf(batch.material, batch.part))\n mesh.geometry.computeBoundingSphere()\n mesh.geometry.computeBoundingBox()\n mesh.name = batch.part === null ? `static:${batch.material}` : `part:${batch.part}`\n if (batch.part !== null) mesh.userData.part = batch.part\n mesh.userData.material = batch.material\n if (batch.ranges.length) mesh.userData.ranges = batch.ranges\n mesh.castShadow = shadows\n mesh.receiveShadow = shadows\n into(batch.part).add(mesh)\n meshes.push(mesh)\n }\n for (const batch of level.instanced) {\n const mesh = new THREE.InstancedMesh(toGeometry(THREE, batch.geometry, { copy: options.copy !== false }), materialOf(batch.material, batch.part), batch.count)\n mesh.instanceMatrix.array.set(batch.matrices)\n mesh.instanceMatrix.needsUpdate = true\n if (batch.colors) mesh.instanceColor = new THREE.InstancedBufferAttribute(batch.colors.slice(), 3)\n mesh.name = `instanced:${batch.name ?? batch.material}`\n mesh.userData.material = batch.material\n if (batch.part !== null) mesh.userData.part = batch.part\n mesh.castShadow = shadows\n mesh.receiveShadow = shadows\n mesh.computeBoundingSphere()\n into(batch.part).add(mesh)\n instanced.push(mesh)\n }\n for (const part of Object.values(parts)) group.add(part)\n return { group, parts }\n }\n\n const levels = buffers.levels\n const first = build(levels[0] ?? { distance: 0, detail: 1, batches: [], instanced: [] }, true)\n let object: THREE_NS.Object3D = first.group\n if (levels.length > 1 || buffers.cullDistance !== undefined) {\n const lod = new THREE.LOD()\n lod.name = first.group.name\n lod.addLevel(first.group, 0)\n for (const level of levels.slice(1)) lod.addLevel(build(level, false).group, level.distance)\n if (buffers.cullDistance !== undefined) lod.addLevel(new THREE.Group(), buffers.cullDistance)\n object = lod\n }\n object.userData.points = buffers.points\n return { object, near: first.group, parts: first.parts, meshes, instanced, points: buffers.points, materials }\n}\n","import { mergeTransformed } from '@adatechnology/game-shapes'\nimport type { TransformedPiece } from '@adatechnology/game-shapes'\nimport type * as THREE_NS from 'three'\n\nimport type { Three } from './geometry'\n\nconst isVisible = (object: THREE_NS.Object3D): boolean => {\n for (let node: THREE_NS.Object3D | null = object; node; node = node.parent) if (!node.visible) return false\n return true\n}\n\n/** A plain, non-interleaved, not normalised Float32 attribute: what the core merge reads directly. */\nconst plain = (attribute: THREE_NS.BufferAttribute | THREE_NS.InterleavedBufferAttribute | undefined): attribute is THREE_NS.BufferAttribute =>\n attribute !== undefined && !(attribute as THREE_NS.InterleavedBufferAttribute).isInterleavedBufferAttribute && attribute.array instanceof Float32Array && !attribute.normalized\n\n/** Arrays of a geometry the core merge can take as they are; for anything else, the arrays three's own `toNonIndexed` makes (then not indexed). */\nfunction piece(geometry: THREE_NS.BufferGeometry, matrix: THREE_NS.Matrix4): TransformedPiece {\n const position = geometry.getAttribute('position')\n const normal = geometry.getAttribute('normal')\n const uv = geometry.getAttribute('uv')\n const ok = plain(position) && (normal === undefined || plain(normal)) && (uv === undefined || plain(uv)) && position.itemSize === 3 && (uv === undefined || uv.itemSize === 2)\n if (ok) {\n return { positions: position.array, ...(normal ? { normals: normal.array } : {}), ...(uv ? { uvs: uv.array } : {}), indices: geometry.index ? geometry.index.array : null, matrix: matrix.elements }\n }\n const flat = geometry.index ? geometry.toNonIndexed() : geometry\n const read = (name: string, size: number): Float32Array | undefined => {\n const attribute = flat.getAttribute(name)\n if (!attribute) return undefined\n const out = new Float32Array(attribute.count * size)\n for (let i = 0; i < attribute.count; i++) for (let c = 0; c < size; c++) out[i * size + c] = c === 0 ? attribute.getX(i) : c === 1 ? attribute.getY(i) : attribute.getZ(i)\n return out\n }\n const positions = read('position', 3) as Float32Array\n const normals = read('normal', 3)\n const uvs = read('uv', 2)\n if (flat !== geometry) flat.dispose()\n return { positions, ...(normals ? { normals } : {}), ...(uvs ? { uvs } : {}), indices: null, matrix: matrix.elements }\n}\n\n/**\n * Every visible mesh under `root` (whose world matrix must be up to date), baked into the space of `space` and joined by material: one non-indexed\n * mesh per material (position, normal, uv), no shadow cast. The bake is game-shapes' `mergeTransformed`, bit-identical to three's\n * `toNonIndexed` + `applyMatrix4` + join, so the result is the one `game-props3d`'s `mergeByMaterial` always gave.\n */\nexport function mergeByMaterial(THREE: Three, root: THREE_NS.Object3D, space: THREE_NS.Object3D): THREE_NS.Mesh[] {\n const toSpace = space.matrixWorld.clone().invert()\n const byMaterial = new Map<THREE_NS.Material, TransformedPiece[]>()\n root.traverse((object) => {\n const mesh = object as THREE_NS.Mesh\n if (!mesh.isMesh || Array.isArray(mesh.material) || !isVisible(mesh)) return\n const list = byMaterial.get(mesh.material) ?? []\n list.push(piece(mesh.geometry, new THREE.Matrix4().multiplyMatrices(toSpace, mesh.matrixWorld)))\n byMaterial.set(mesh.material, list)\n })\n return [...byMaterial].map(([material, pieces]) => {\n const merged = mergeTransformed(pieces)\n const geometry = new THREE.BufferGeometry()\n geometry.setAttribute('position', new THREE.BufferAttribute(merged.positions, 3))\n geometry.setAttribute('normal', new THREE.BufferAttribute(merged.normals, 3))\n geometry.setAttribute('uv', new THREE.BufferAttribute(merged.uvs, 2))\n const mesh = new THREE.Mesh(geometry, material)\n mesh.castShadow = false\n mesh.receiveShadow = true\n return mesh\n })\n}\n","import type * as ThreeNS from 'three'\n\nexport type Vec3 = [number, number, number]\ntype ThreeLib = typeof ThreeNS\n\n/**\n * Points of a hanging cord between `a` and `b` (n points including both ends, n >= 2). The deepest point sits `sag` meters below\n * the straight line between the ends, on a real catenary (y = a cosh(x/a)); when the ends differ in height the curve is\n * measured against the straight line between them.\n */\nexport function catenary(a: Vec3, b: Vec3, sag: number, n = 12): Vec3[] {\n const count = Math.max(2, Math.floor(n))\n const { span, c } = catenaryOf(a[0], a[1], a[2], b[0], b[1], b[2], sag)\n const out: Vec3[] = []\n for (let i = 0; i < count; i++) {\n const s = i / (count - 1)\n out.push([a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s + catenaryDrop(span, c, s), a[2] + (b[2] - a[2]) * s])\n }\n return out\n}\n\n/** The span of a cord between two points (its horizontal run, or its length when it hangs straight down) and the parameter `c` of its catenary (0 when it hangs straight). */\nconst catenaryOf = (ax: number, ay: number, az: number, bx: number, by: number, bz: number, sag: number): { span: number; c: number } => {\n const span = Math.hypot(bx - ax, bz - az) || Math.hypot(bx - ax, by - ay, bz - az)\n const depth = Math.max(0, sag)\n if (depth <= 1e-6 || span <= 1e-6) return { span, c: 0 }\n // Solve depth = c (cosh(span / 2c) - 1) for c by bisection (depth grows as c shrinks).\n let lo = 1e-4\n let hi = span * 1000\n for (let i = 0; i < 80; i++) {\n const c = (lo + hi) / 2\n const d = c * (Math.cosh(span / (2 * c)) - 1)\n if (d > depth) lo = c\n else hi = c\n }\n return { span, c: (lo + hi) / 2 }\n}\n\n/** How far below the straight line the cord hangs at `s` (0..1 along it). */\nconst catenaryDrop = (span: number, c: number, s: number): number => (c > 0 ? c * (Math.cosh(((s - 0.5) * span) / c) - Math.cosh(span / (2 * c))) : 0)\n\n/** A thin tube through `points` (Catmull-Rom smoothed) for wires, cords and conduits. */\nexport function createCord(THREE: ThreeLib, points: readonly Vec3[], radius: number, material: ThreeNS.Material, radialSegments = 5): ThreeNS.Mesh {\n if (points.length < 2) throw new Error('createCord needs at least two points')\n const curve = new THREE.CatmullRomCurve3(points.map((p) => new THREE.Vector3(p[0], p[1], p[2])), false, 'centripetal')\n const segments = Math.max(4, (points.length - 1) * 4)\n const mesh = new THREE.Mesh(new THREE.TubeGeometry(curve, segments, radius, radialSegments, false), material)\n mesh.name = 'cord'\n mesh.castShadow = true\n return mesh\n}\n\n/** A point as three.js and plain objects give it. */\nexport interface PointLike {\n readonly x: number\n readonly y: number\n readonly z: number\n}\n\n/** A cord that hangs again between two moving ends every frame (a hose from a pack to the hand): one geometry, rewritten in place. */\nexport interface HangingCord {\n readonly mesh: ThreeNS.Mesh\n /** Hangs the cord from `a` to `b` with `sag` (m) below the straight line, rewriting its geometry in place: no allocation. */\n hang(a: PointLike, b: PointLike, sag: number): void\n}\n\n/**\n * A tube of `segments` lengths around a catenary between two ends that move (`createCord` draws one that stays). The vertices and normals are written in place on every `hang`, the rings\n * carried along the cord by parallel transport, so nothing is made or freed per frame.\n */\nexport function createHangingCord(THREE: ThreeLib, options: { readonly segments: number; readonly radius: number; readonly material: ThreeNS.Material; readonly radialSegments?: number }): HangingCord {\n const segments = Math.max(1, Math.floor(options.segments))\n const radial = Math.max(3, Math.floor(options.radialSegments ?? 5))\n const ring = radial + 1\n const positions = new Float32Array((segments + 1) * ring * 3)\n const normals = new Float32Array((segments + 1) * ring * 3)\n const index: number[] = []\n for (let i = 0; i < segments; i++) {\n for (let j = 0; j < radial; j++) {\n const a = i * ring + j\n const b = (i + 1) * ring + j\n index.push(a, b, a + 1, b, b + 1, a + 1)\n }\n }\n const geometry = new THREE.BufferGeometry()\n const positionAttribute = new THREE.BufferAttribute(positions, 3)\n const normalAttribute = new THREE.BufferAttribute(normals, 3)\n geometry.setAttribute('position', positionAttribute)\n geometry.setAttribute('normal', normalAttribute)\n geometry.setIndex(index)\n const sphere = new THREE.Sphere()\n geometry.boundingSphere = sphere\n const mesh = new THREE.Mesh(geometry, options.material)\n mesh.name = 'cord'\n mesh.castShadow = true\n const centre = new Float64Array((segments + 1) * 3)\n const tangent = new THREE.Vector3()\n const normal = new THREE.Vector3()\n const binormal = new THREE.Vector3()\n const previous = new THREE.Vector3()\n const low = new THREE.Vector3()\n const high = new THREE.Vector3()\n const tangentAt = (i: number): void => {\n const from = Math.max(0, i - 1)\n const to = Math.min(segments, i + 1)\n tangent.set(centre[to * 3]! - centre[from * 3]!, centre[to * 3 + 1]! - centre[from * 3 + 1]!, centre[to * 3 + 2]! - centre[from * 3 + 2]!).normalize()\n }\n return {\n mesh,\n hang(a, b, sag) {\n const { span, c } = catenaryOf(a.x, a.y, a.z, b.x, b.y, b.z, sag)\n for (let i = 0; i <= segments; i++) {\n const s = i / segments\n centre[i * 3] = a.x + (b.x - a.x) * s\n centre[i * 3 + 1] = a.y + (b.y - a.y) * s + catenaryDrop(span, c, s)\n centre[i * 3 + 2] = a.z + (b.z - a.z) * s\n }\n low.set(Infinity, Infinity, Infinity)\n high.set(-Infinity, -Infinity, -Infinity)\n for (let i = 0; i <= segments; i++) {\n tangentAt(i)\n if (i === 0) {\n // a first normal across the tangent, from the axis it leans on least\n const ax = Math.abs(tangent.x)\n const ay = Math.abs(tangent.y)\n const az = Math.abs(tangent.z)\n normal.set(ax <= ay && ax <= az ? 1 : 0, ay < ax && ay <= az ? 1 : 0, az < ax && az < ay ? 1 : 0)\n normal.sub(binormal.copy(tangent).multiplyScalar(normal.dot(tangent))).normalize()\n } else {\n // parallel transport: the last normal, without its part along the new tangent\n normal.copy(previous).sub(binormal.copy(tangent).multiplyScalar(previous.dot(tangent))).normalize()\n }\n previous.copy(normal)\n binormal.crossVectors(tangent, normal)\n const px = centre[i * 3]!\n const py = centre[i * 3 + 1]!\n const pz = centre[i * 3 + 2]!\n for (let j = 0; j <= radial; j++) {\n const angle = (j / radial) * Math.PI * 2\n const cos = Math.cos(angle)\n const sin = -Math.sin(angle)\n const nx = cos * normal.x + sin * binormal.x\n const ny = cos * normal.y + sin * binormal.y\n const nz = cos * normal.z + sin * binormal.z\n const at = (i * ring + j) * 3\n normals[at] = nx\n normals[at + 1] = ny\n normals[at + 2] = nz\n positions[at] = px + options.radius * nx\n positions[at + 1] = py + options.radius * ny\n positions[at + 2] = pz + options.radius * nz\n }\n low.set(Math.min(low.x, px), Math.min(low.y, py), Math.min(low.z, pz))\n high.set(Math.max(high.x, px), Math.max(high.y, py), Math.max(high.z, pz))\n }\n positionAttribute.needsUpdate = true\n normalAttribute.needsUpdate = true\n sphere.center.addVectors(low, high).multiplyScalar(0.5)\n sphere.radius = sphere.center.distanceTo(high) + options.radius\n },\n }\n}\n","import type * as THREE_NS from 'three'\n\n/** What `releaseObject3D` freed. */\nexport interface ReleaseReport {\n geometries: number\n materials: number\n textures: number\n}\n\nexport interface ReleaseOptions {\n /**\n * Trees that stay drawn (usually the scene): a geometry, material or texture any of them still uses is kept, so a resource shared by a clone that is\n * still on screen (a catalogue model, a material of the kit's palette) is not freed under it.\n */\n keep?: THREE_NS.Object3D | readonly THREE_NS.Object3D[]\n}\n\ntype Disposable = { dispose(): void; userData?: Record<string, unknown> }\ntype Owner = {\n geometry?: Disposable\n material?: THREE_NS.Material | THREE_NS.Material[]\n skeleton?: { dispose(): void }\n traverse(fn: (o: THREE_NS.Object3D) => void): void\n}\n\nconst isTexture = (v: unknown): v is THREE_NS.Texture => !!v && typeof v === 'object' && (v as { isTexture?: boolean }).isTexture === true\n\nfunction texturesOf(material: THREE_NS.Material, out: Set<THREE_NS.Texture>): void {\n for (const value of Object.values(material)) if (isTexture(value)) out.add(value)\n const uniforms = (material as { uniforms?: Record<string, { value?: unknown }> }).uniforms\n if (uniforms) for (const u of Object.values(uniforms)) if (isTexture(u?.value)) out.add(u.value)\n}\n\nfunction collect(roots: readonly THREE_NS.Object3D[]): { geometries: Set<Disposable>; materials: Set<THREE_NS.Material>; textures: Set<THREE_NS.Texture>; skeletons: Set<{ dispose(): void }> } {\n const geometries = new Set<Disposable>()\n const materials = new Set<THREE_NS.Material>()\n const textures = new Set<THREE_NS.Texture>()\n const skeletons = new Set<{ dispose(): void }>()\n for (const root of roots) {\n root.traverse((object) => {\n const o = object as unknown as Owner\n if (o.geometry && typeof o.geometry.dispose === 'function') geometries.add(o.geometry)\n if (o.skeleton && typeof o.skeleton.dispose === 'function') skeletons.add(o.skeleton)\n const list = Array.isArray(o.material) ? o.material : o.material ? [o.material] : []\n for (const m of list) {\n if (!m || typeof m.dispose !== 'function') continue\n materials.add(m)\n texturesOf(m, textures)\n }\n })\n }\n return { geometries, materials, textures, skeletons }\n}\n\nconst marked = new WeakSet<object>()\n/**\n * Marks geometries, materials or textures as shared on purpose (a palette, a model kit, a catalog): `releaseObject3D` and `discardObject3D` never free\n * them. Same as `userData.shared = true`, without touching the resource (its bytes and userData stay as they were, for digests and goldens).\n */\nexport function markShared<T extends object>(...resources: T[]): T[] {\n for (const resource of resources) marked.add(resource)\n return resources\n}\nconst shared = (r: { userData?: Record<string, unknown> }): boolean => r.userData?.shared === true || marked.has(r)\n\n/**\n * Free the GPU side of trees taken out of the scene: their geometries, materials, textures (maps and shader uniforms) and skeletons. three.js keeps a removed\n * mesh's buffers, programs and textures on the GPU (and the JS objects in its caches) until `dispose()`, so every object a game removes without this stays\n * in memory for good. A resource marked `userData.shared = true`, or still used by a tree in `keep`, is left alone. Disposing a resource that is used again\n * later is safe: three.js uploads it again on the next draw.\n */\nexport function releaseObject3D(roots: THREE_NS.Object3D | readonly THREE_NS.Object3D[], options: ReleaseOptions = {}): ReleaseReport {\n const list = (Array.isArray(roots) ? roots : [roots]) as THREE_NS.Object3D[]\n const report: ReleaseReport = { geometries: 0, materials: 0, textures: 0 }\n if (list.length === 0) return report\n const found = collect(list)\n const keepRoots = options.keep === undefined ? [] : ((Array.isArray(options.keep) ? options.keep : [options.keep]) as THREE_NS.Object3D[])\n // a released tree still hanging under a kept one is not \"kept\": skip it while walking the kept trees\n const releasing = new Set<THREE_NS.Object3D>(list)\n for (const keep of keepRoots) {\n const walk = (o: THREE_NS.Object3D): void => {\n if (releasing.has(o)) return\n const owner = o as unknown as Owner\n if (owner.geometry) found.geometries.delete(owner.geometry)\n if (owner.skeleton) found.skeletons.delete(owner.skeleton)\n const mats = Array.isArray(owner.material) ? owner.material : owner.material ? [owner.material] : []\n for (const m of mats) {\n if (!m) continue\n found.materials.delete(m)\n const t = new Set<THREE_NS.Texture>()\n texturesOf(m, t)\n for (const x of t) found.textures.delete(x)\n }\n for (const c of o.children) walk(c)\n }\n walk(keep)\n }\n for (const g of found.geometries) {\n if (shared(g)) continue\n g.dispose()\n report.geometries++\n }\n for (const m of found.materials) {\n if (shared(m as unknown as Disposable)) continue\n m.dispose()\n report.materials++\n }\n for (const t of found.textures) {\n if (shared(t as unknown as Disposable)) continue\n t.dispose()\n report.textures++\n }\n for (const s of found.skeletons) s.dispose()\n return report\n}\n\n/**\n * Take `objects` out of their trees and free what only they used (`releaseObject3D`, keeping whatever the rest of those trees, usually the scene,\n * still draws). The one call for pieces, fragments, helpers or bodies that leave the game for good. A list costs one walk of each scene, so pass\n * the whole list instead of calling it once per object.\n */\nexport function discardObject3D(objects: THREE_NS.Object3D | readonly THREE_NS.Object3D[], options: ReleaseOptions = {}): ReleaseReport {\n const list = (Array.isArray(objects) ? objects : [objects]) as THREE_NS.Object3D[]\n const keep = options.keep === undefined ? [] : Array.isArray(options.keep) ? [...(options.keep as THREE_NS.Object3D[])] : [options.keep as THREE_NS.Object3D]\n for (const object of list) {\n let top = object\n while (top.parent) top = top.parent\n object.removeFromParent()\n if (top !== object && !keep.includes(top)) keep.push(top)\n }\n return releaseObject3D(list, { keep })\n}\n","import type * as THREE_NS from 'three'\n\n/** A mesh (or a subclass: skinned, instanced) found while walking a tree; three marks them with `isMesh`. */\nexport function isMesh(o: THREE_NS.Object3D | null | undefined): o is THREE_NS.Mesh {\n return !!o && (o as Partial<THREE_NS.Mesh>).isMesh === true\n}\n","import type * as THREE_NS from 'three'\n\n/** How many declared writes a position attribute keeps: a host that missed an older one measures every part of the mesh again. */\nconst KEPT = 256\n\n/** The vertex ranges each declared write covered, by the attribute's `version` right after it. */\nconst declared = new WeakMap<object, Map<number, Array<readonly [number, number]>>>()\n\n/**\n * Flags the mesh's positions for upload (`needsUpdate`) and declares that the write changed the vertices `[v0, v1)`: the write and its declaration share one `version`,\n * so call it once per range written instead of setting `needsUpdate` yourself. A drawing that shares a\n * merged mesh with another that measures its ranges (the house collapsing the range of a wall it draws with holes, under the destruction renderer that measures each\n * part's range as a collider) calls it, so only the parts drawn by that range are measured again, not the whole house (`rangesWrittenSince`). A write that sets `needsUpdate` and declares nothing still counts, for every part of the mesh (`CLAUDE.md` §12).\n */\nexport function markPositionsWritten(mesh: THREE_NS.Mesh, v0: number, v1: number): void {\n const position = mesh.geometry?.getAttribute('position') as THREE_NS.BufferAttribute | undefined\n if (!position) return\n position.needsUpdate = true\n if (v1 <= v0) return\n let log = declared.get(position)\n if (!log) {\n log = new Map()\n declared.set(position, log)\n }\n const ranges = log.get(position.version)\n if (ranges) ranges.push([v0, v1])\n else log.set(position.version, [[v0, v1]])\n if (log.size > KEPT) log.delete(log.keys().next().value as number)\n}\n\n/** The ranges written after `version` up to the attribute's version now, or null when one of those writes declared no range (or is forgotten). */\nexport function rangesWrittenSince(position: THREE_NS.BufferAttribute, version: number): Array<readonly [number, number]> | null {\n const log = declared.get(position)\n const out: Array<readonly [number, number]> = []\n for (let v = version + 1; v <= position.version; v++) {\n const ranges = log?.get(v)\n if (!ranges) return null\n out.push(...ranges)\n }\n return out\n}\n","import type * as THREE_NS from 'three'\nimport { coincidentFaces } from '@adatechnology/game-shapes'\nimport type { CoincidentBatch, CoincidentFaceHit, CoincidentFacesOptions } from '@adatechnology/game-shapes'\n\nexport { GAME_DEPTH_PRECISION, depthResolution, describeCoincidentFaces } from '@adatechnology/game-shapes'\nexport type { CoincidentFaceHit, DepthPrecision } from '@adatechnology/game-shapes'\n\nimport { isMesh } from './guards'\n\nexport interface CoincidentFacesOfOptions extends CoincidentFacesOptions {\n /** Also check meshes that are hidden now (a piece that only shows when the wall breaks). Default false: only what is drawn. */\n readonly includeHidden?: boolean\n}\n\ntype Material = THREE_NS.Material & { polygonOffset?: boolean; name?: string }\n\n/** A LOD draws one level at a time: only the nearest one is checked, the others never share a frame with it. */\nfunction isFartherLevel(o: THREE_NS.Object3D): boolean {\n const lod = o.parent as (THREE_NS.LOD & { isLOD?: boolean }) | null\n return !!lod?.isLOD && lod.levels.length > 0 && lod.levels[0]!.object !== o\n}\n\nfunction isDrawn(node: THREE_NS.Object3D, root: THREE_NS.Object3D): boolean {\n for (let o: THREE_NS.Object3D | null = node; o; o = o.parent) {\n if (!o.visible || isFartherLevel(o)) return false\n if (o === root) return true\n }\n return true\n}\n\n/** A decal pushed forward with polygonOffset lies on its surface by design: the GPU orders it, it does not flicker. */\nfunction isOffsetDecal(mesh: THREE_NS.Mesh): boolean {\n const materials = (Array.isArray(mesh.material) ? mesh.material : [mesh.material]) as Material[]\n return materials.length > 0 && materials.every((m) => m?.polygonOffset === true)\n}\n\nfunction labelOf(mesh: THREE_NS.Mesh, root: THREE_NS.Object3D): string {\n const names: string[] = []\n for (let o: THREE_NS.Object3D | null = mesh; o && o !== root; o = o.parent) {\n const part = (o.userData as { destructionPart?: unknown } | undefined)?.destructionPart\n const name = o.name || (typeof part === 'string' ? part : '')\n if (name) names.unshift(name)\n }\n const material = (Array.isArray(mesh.material) ? mesh.material[0] : mesh.material) as Material | undefined\n const path = names.join('/') || mesh.type\n return material?.name ? `${path} [${material.name}]` : path\n}\n\n/** World-space positions of one mesh (or of one instance of an InstancedMesh). */\nfunction worldPositions(position: THREE_NS.BufferAttribute | THREE_NS.InterleavedBufferAttribute, matrix: THREE_NS.Matrix4): Float64Array {\n const e = matrix.elements\n const out = new Float64Array(position.count * 3)\n for (let i = 0; i < position.count; i++) {\n const x = position.getX(i), y = position.getY(i), z = position.getZ(i)\n const w = e[3]! * x + e[7]! * y + e[11]! * z + e[15]! || 1\n out[i * 3] = (e[0]! * x + e[4]! * y + e[8]! * z + e[12]!) / w\n out[i * 3 + 1] = (e[1]! * x + e[5]! * y + e[9]! * z + e[13]!) / w\n out[i * 3 + 2] = (e[2]! * x + e[6]! * y + e[10]! * z + e[14]!) / w\n }\n return out\n}\n\n/** three's DoubleSide. */\nconst DOUBLE_SIDE = 2\n\nfunction isDoubleSided(mesh: THREE_NS.Mesh): boolean {\n const materials = (Array.isArray(mesh.material) ? mesh.material : [mesh.material]) as THREE_NS.Material[]\n return materials.some((m) => m?.side === DOUBLE_SIDE)\n}\n\ntype Shaded = THREE_NS.Material & { readonly vertexColors?: boolean; readonly map?: unknown; readonly normalMap?: unknown; readonly bumpMap?: unknown; readonly alphaMap?: unknown; readonly roughnessMap?: unknown }\n\nconst attributeValues = (attribute: THREE_NS.BufferAttribute | THREE_NS.InterleavedBufferAttribute, size: number): number[] => {\n const out = new Array<number>(attribute.count * size)\n const read = [(i: number): number => attribute.getX(i), (i: number): number => attribute.getY(i), (i: number): number => attribute.getZ(i)]\n for (let i = 0; i < attribute.count; i++) for (let k = 0; k < size; k++) out[i * size + k] = read[k]!(i)\n return out\n}\n\n/** How the mesh is shaded, for the near mode's test of faces that draw the same pixels: one material (its identity), its vertex colours and, when textured, its UVs. */\nfunction lookOf(mesh: THREE_NS.Mesh, geometry: THREE_NS.BufferGeometry): Pick<CoincidentBatch, 'look' | 'colors' | 'uvs'> {\n if (Array.isArray(mesh.material)) return {}\n const material = mesh.material as Shaded\n const color = material.vertexColors ? geometry.getAttribute('color') : undefined\n const textured = Boolean(material.map || material.normalMap || material.bumpMap || material.alphaMap || material.roughnessMap)\n const uv = textured ? geometry.getAttribute('uv') : undefined\n if (textured && !uv) return {}\n return { look: material.uuid, ...(color ? { colors: attributeValues(color, 3) } : {}), ...(uv ? { uvs: attributeValues(uv, 2) } : {}) }\n}\n\n// only what the GPU draws: a geometry that reuses bigger buffers keeps stale triangles past its draw range\nfunction drawnIndices(geometry: THREE_NS.BufferGeometry): ArrayLike<number> | undefined {\n const { start, count } = geometry.drawRange\n const index = geometry.index?.array\n const total = index ? index.length : geometry.getAttribute('position').count\n const end = Math.min(total, start + (Number.isFinite(count) ? count : total))\n if (index) return start === 0 && end === index.length ? index : Array.from(index).slice(start, end)\n if (start === 0 && end === total) return undefined\n return Array.from({ length: end - start }, (_, i) => start + i)\n}\n\nfunction batchesOfMesh(mesh: THREE_NS.Mesh, label: string): CoincidentBatch[] {\n const doubleSided = isDoubleSided(mesh)\n const geometry = mesh.geometry as THREE_NS.BufferGeometry | undefined\n const position = geometry?.getAttribute('position')\n if (!geometry || !position) return []\n const indices = drawnIndices(geometry)\n const instanced = mesh as THREE_NS.InstancedMesh\n const look = lookOf(mesh, geometry)\n if (!instanced.isInstancedMesh) return [{ positions: worldPositions(position, mesh.matrixWorld), ...(indices ? { indices } : {}), label, doubleSided, ...look }]\n const batches: CoincidentBatch[] = []\n const instance = mesh.matrixWorld.clone()\n // instances of one colour each are told apart by it: an instance colour joins the look\n const tint = instanced.instanceColor\n for (let i = 0; i < instanced.count; i++) {\n instanced.getMatrixAt(i, instance)\n instance.premultiply(mesh.matrixWorld)\n const instanceLook = tint && look.look !== undefined ? { ...look, look: `${look.look}:${tint.getX(i)},${tint.getY(i)},${tint.getZ(i)}` } : look\n batches.push({ positions: worldPositions(position, instance), ...(indices ? { indices } : {}), label: `${label} #${i}`, doubleSided, ...instanceLook })\n }\n return batches\n}\n\nexport interface MeshBatches {\n readonly batches: CoincidentBatch[]\n /** The mesh each batch came from, at the same index. */\n readonly meshes: THREE_NS.Mesh[]\n}\n\n/** The triangles of every drawn mesh under `root`, in world space, with the mesh of each batch. */\nexport function meshBatchesOf(root: THREE_NS.Object3D, options: Pick<CoincidentFacesOfOptions, 'includeHidden'> = {}): MeshBatches {\n root.updateMatrixWorld(true)\n const batches: CoincidentBatch[] = []\n const meshes: THREE_NS.Mesh[] = []\n root.traverse((node) => {\n if (!isMesh(node) || (node as THREE_NS.Object3D & { isSprite?: boolean }).isSprite) return\n if (!options.includeHidden && !isDrawn(node, root)) return\n if (isOffsetDecal(node)) return\n for (const batch of batchesOfMesh(node, labelOf(node, root))) {\n batches.push(batch)\n meshes.push(node)\n }\n })\n return { batches, meshes }\n}\n\n/** The triangles of every drawn mesh under `root`, in world space, ready for `coincidentFaces`. */\nexport function coincidentBatchesOf(root: THREE_NS.Object3D, options: Pick<CoincidentFacesOfOptions, 'includeHidden'> = {}): CoincidentBatch[] {\n return meshBatchesOf(root, options).batches\n}\n\n/**\n * Faces of `root` that z-fight: same plane, same facing, overlapping. Use it in the catalog test of every package that draws pieces, so a\n * piece that comes back with a lining flush to its body fails the test instead of flickering on screen.\n */\nexport function coincidentFacesOf(root: THREE_NS.Object3D, options: CoincidentFacesOfOptions = {}): CoincidentFaceHit[] {\n const { batches, meshes } = meshBatchesOf(root, options)\n return coincidentFaces(batches, options).filter((hit) => writesDepth(meshes[hit.batchA]!) || writesDepth(meshes[hit.batchB]!))\n}\n\n/** Two layers that both leave the depth buffer alone (smoke, glow, sparks) are blended in order: they never fight for a pixel. */\nfunction writesDepth(mesh: THREE_NS.Mesh): boolean {\n const materials = (Array.isArray(mesh.material) ? mesh.material : [mesh.material]) as THREE_NS.Material[]\n return materials.some((m) => m.depthWrite !== false && m.depthTest !== false)\n}\n","import type * as THREE_NS from 'three'\nimport { coincidentFaces } from '@adatechnology/game-shapes'\nimport type { CoincidentFaceHit } from '@adatechnology/game-shapes'\n\nimport { meshBatchesOf } from './coincident'\n\nexport interface StandOutOptions {\n /** How far a fighting face of the smaller piece moves out, in metres. Default 0.002 (CLAUDE.md §13). */\n readonly gap?: number\n /** Rounds of check-and-move; a moved face can meet a third piece. Default 3. */\n readonly rounds?: number\n}\n\nexport interface StandOutReport {\n /** Meshes that were moved out. */\n readonly grown: number\n /** Face pairs still fighting after the last round (0 when it worked). */\n readonly left: number\n}\n\n/** How each side of a mesh's own box moves, `[-x, +x, -y, +y, -z, +z]`: 1 out, -1 in, 0 stays. */\ntype Sides = [number, number, number, number, number, number]\n\nfunction localSize(mesh: THREE_NS.Mesh, out: THREE_NS.Vector3): THREE_NS.Vector3 {\n const geometry = mesh.geometry as THREE_NS.BufferGeometry\n if (!geometry.boundingBox) geometry.computeBoundingBox()\n return geometry.boundingBox!.getSize(out)\n}\n\n/** Volume of the mesh's box in the world: the smaller of a fighting pair is the detail that moves. */\nfunction volumeOf(mesh: THREE_NS.Mesh): number {\n const size = localSize(mesh, mesh.position.clone())\n const scale = mesh.getWorldScale(mesh.position.clone())\n return Math.max(Math.abs(size.x * scale.x), 1e-4) * Math.max(Math.abs(size.y * scale.y), 1e-4) * Math.max(Math.abs(size.z * scale.z), 1e-4)\n}\n\n/** Marks the side of the mesh's box that faces along the world normal of the hit, to go out (1) or in (-1). */\nfunction markSide(mesh: THREE_NS.Mesh, hit: CoincidentFaceHit, sides: Sides, way: 1 | -1): void {\n const inverse = mesh.getWorldQuaternion(mesh.quaternion.clone()).invert()\n const n = mesh.position.clone().set(hit.normal[0], hit.normal[1], hit.normal[2]).applyQuaternion(inverse)\n const scale = mesh.getWorldScale(mesh.position.clone())\n const local = [n.x * Math.sign(scale.x || 1), n.y * Math.sign(scale.y || 1), n.z * Math.sign(scale.z || 1)]\n const axis = local.reduce((best, v, i) => (Math.abs(v) > Math.abs(local[best]!) ? i : best), 0)\n sides[axis * 2 + (local[axis]! > 0 ? 1 : 0)] = way\n}\n\n/** Moves the marked sides of the mesh's box `gap` metres out or in (in the world), keeping the other sides where they are. */\nfunction pushSides(mesh: THREE_NS.Mesh, sides: Sides, gap: number): void {\n const size = localSize(mesh, mesh.position.clone())\n const world = mesh.getWorldScale(mesh.position.clone())\n const shift = mesh.position.clone().set(0, 0, 0)\n const scale = [mesh.scale.x, mesh.scale.y, mesh.scale.z]\n const extent = [size.x, size.y, size.z]\n const worldScale = [Math.abs(world.x), Math.abs(world.y), Math.abs(world.z)]\n const centre = mesh.geometry.boundingBox!.getCenter(mesh.position.clone())\n const centres = [centre.x, centre.y, centre.z]\n for (let axis = 0; axis < 3; axis++) {\n const minus = sides[axis * 2]! * gap, plus = sides[axis * 2 + 1]! * gap\n const s = extent[axis]! * worldScale[axis]!\n if ((!minus && !plus) || s < 1e-6 || s + minus + plus < s / 2) continue\n const oldScale = scale[axis]!\n scale[axis] = (oldScale * (s + minus + plus)) / s\n // in the parent's frame the centre moves by half the difference of the two sides, so a side that is not marked stays where it was\n const parentPerWorld = oldScale / worldScale[axis]!\n const outward = ((plus - minus) / 2) * parentPerWorld\n const recentre = centres[axis]! * (oldScale - scale[axis]!)\n shift.setComponent(axis, outward + recentre)\n }\n mesh.scale.set(scale[0]!, scale[1]!, scale[2]!)\n mesh.position.add(shift.applyQuaternion(mesh.quaternion))\n mesh.updateMatrixWorld(true)\n}\n\n/**\n * Makes the faces of `root` stop fighting: of each pair of meshes with coincident faces, the face of the smaller one (the label, band, rim\n * or lining) moves `gap` out of the bigger one, the rule of `CLAUDE.md` §13 (\"a detail stands out at least 2 mm\"). Only the sides that\n * fight move. For pieces ported as they were drawn, where the detail sits flush on its body; a builder of the kit draws the gap itself.\n * Instanced meshes are left alone.\n */\nexport function standOutCoincident(root: THREE_NS.Object3D, options: StandOutOptions = {}): StandOutReport {\n const gap = options.gap ?? 0.002\n const grown = new Set<THREE_NS.Mesh>()\n const volumes = new Map<THREE_NS.Mesh, number>()\n const volume = (mesh: THREE_NS.Mesh): number => volumes.get(mesh) ?? volumes.set(mesh, volumeOf(mesh)).get(mesh)!\n let left = 0\n for (let round = 0; round < (options.rounds ?? 3); round++) {\n const { batches, meshes } = meshBatchesOf(root)\n const hits = coincidentFaces(batches, { maxHits: Number.POSITIVE_INFINITY })\n left = hits.length\n if (!left) break\n const toPush = new Map<THREE_NS.Mesh, Sides>()\n for (const hit of hits) {\n const a = meshes[hit.batchA]!, b = meshes[hit.batchB]!\n const [smaller, bigger] = volume(a) <= volume(b) ? [a, b] : [b, a]\n // a piece moves once: when the detail already stood out, the piece it now meets moves instead (a piece never grows twice)\n const mesh = grown.has(smaller) ? bigger : smaller\n if (grown.has(mesh) || (mesh as THREE_NS.InstancedMesh).isInstancedMesh) continue\n const sides = toPush.get(mesh) ?? [0, 0, 0, 0, 0, 0]\n markSide(mesh, hit, sides, 1)\n toPush.set(mesh, sides)\n }\n for (const [mesh, sides] of toPush) {\n pushSides(mesh, sides, gap)\n grown.add(mesh)\n }\n }\n return { grown: grown.size, left }\n}\n"],"mappings":";AAWA,IAAM,mBAAmB,oBAAI,IAAI,CAAC,iBAAiB,iBAAiB,CAAC;AAErE,IAAM,cAAc,oBAAI,IAAI,CAAC,eAAe,oBAAoB,gBAAgB,kBAAkB,iBAAiB,kBAAkB,gBAAgB,iBAAiB,eAAe,CAAC;AAEtL,IAAM,cAAc,CAAC,UAAoE,OAAQ,MAA2B,SAAS;AAGrI,SAAS,gBAAgB,OAAc,GAA8C;AACnF,MAAI,EAAE,SAAS,iB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6 @@
1
1
  {
2
2
  "name": "@adatechnology/game-shapes-three",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "license": "MIT",
5
5
  "description": "three.js drawing of @adatechnology/game-shapes buffers: BufferGeometry with three's own type and prototype, meshes per batch, part groups, InstancedMesh and LOD; a geometry namespace whose constructors are made by game-shapes (for ported code that reads new T.BoxGeometry); and mergeByMaterial on the core merge.",
6
6
  "keywords": [
@@ -38,7 +38,7 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "@adatechnology/game-shapes": "^0.5.0"
41
+ "@adatechnology/game-shapes": "^0.5.5"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "three": "^0.160.0"