ldr 0.34.11 → 0.34.12

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/README.md CHANGED
@@ -147,7 +147,7 @@ MPD-embedded parts, such as Studio/OMR unofficial parts or stickers, become part
147
147
  | `lodEdgeCap` | `0.75` | LOD: a part draws at most `lodEdgeCap` × d² of its edge segments (its longest), d = its size on screen in pixels. `0` = no cap. |
148
148
  | `lodUnder` | `true` | LOD: skip undersides that can't be seen (camera behind every bottom face of a cluster's parts, or the body drawn as its closed bounding box). Lossless in the fidelity checks. |
149
149
 
150
- `LdrObject`: `object`, `stats` (`instances`, `drawn`, `missing[]`, `studsHidden/Total`, `undersHidden/Total`, `buildMs`, `condBatches`, `texBatches`, `textures`, `glossmaps`, `clusters`), `stepCount`, `stepViews`, `texturesReady`, `setStep(n | null)`, `setEdges(on)`, `setConditionalLines(on)`, `setCulling(studs, undersides)`, `setSide(side)`, `setLod(on)`, `setGhost(on, { opacity, color, whiten }?)`, `getBox(target?)`, `dispose()`.
150
+ `LdrObject`: `object`, `stats` (`instances`, `drawn`, `missing[]`, `studsHidden/Total`, `undersHidden/Total`, `buildMs`, `condBatches`, `texBatches`, `textures`, `glossmaps`, `clusters`), `stepCount`, `stepViews`, `texturesReady`, `setStep(n | null, mask?, ghostAfter?)` (`ghostAfter`: the ghost shows only the steps after it, e.g. `setStep(s - 1, mask, s)` while step s's parts animate in, so none is drawn as a ghost and a solid at once), `setEdges(on)`, `setConditionalLines(on)`, `setCulling(studs, undersides)`, `setSide(side)`, `setLod(on)`, `setGhost(on, { opacity, color, whiten }?)`, `getBox(target?)`, `dispose()`.
151
151
 
152
152
  `setStep` doesn't rebuild anything: it compacts instance buffers, and culling is step-aware (a stud covered only by a later step's part stays visible). `stats` reflect the shown step.
153
153
 
package/dist/cli.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/cli.ts
3
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/cli.ts
4
4
  import fs4 from "node:fs";
5
5
  import zlib from "node:zlib";
6
6
 
7
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/node/build-pack.ts
7
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/build-pack.ts
8
8
  import fs3 from "node:fs";
9
9
  import path3 from "node:path";
10
10
 
11
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/node/resolver.ts
11
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/resolver.ts
12
12
  import fs from "node:fs";
13
13
  import path from "node:path";
14
14
 
15
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/spec.ts
15
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/spec.ts
16
16
  var norm = (s) => s.trim().toLowerCase().replace(/\\/g, "/").replace(/\/+/g, "/");
17
17
  var COLOUR_ID_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
18
18
  var namedCodes = new Map;
@@ -848,7 +848,7 @@ function fileStepViews(f) {
848
848
  return out;
849
849
  }
850
850
 
851
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/model.ts
851
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/model.ts
852
852
  class ModelLimitError extends Error {
853
853
  limit;
854
854
  code = "ldr-model-limit";
@@ -1290,7 +1290,7 @@ function blendedColourHex(code) {
1290
1290
  return "#" + [0, 1, 2].map((k) => (a[k] + b[k] >> 1).toString(16).padStart(2, "0")).join("").toUpperCase();
1291
1291
  }
1292
1292
 
1293
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/node/resolver.ts
1293
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/resolver.ts
1294
1294
  var TOP_STUD_RE = /^(stud|studa|stud2|stud2a|stud6|stud6a|stud10|stud15|stud2s|stud2s2|stud-logo\d*|stud2-logo\d*)\.dat$/i;
1295
1295
  var UNDER_STUD_RE = /^(stud3|stud3a|stud4.*|stud12|stud16.*|stud18a)\.dat$/i;
1296
1296
  var norm2 = (ref) => ref.trim().replace(/\\/g, "/").toLowerCase();
@@ -1617,11 +1617,11 @@ function collectDeps(lib, refs) {
1617
1617
  return out;
1618
1618
  }
1619
1619
 
1620
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/node/compile.ts
1620
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/compile.ts
1621
1621
  import fs2 from "node:fs";
1622
1622
  import path2 from "node:path";
1623
1623
 
1624
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/node/lod.ts
1624
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/lod.ts
1625
1625
  import { MeshoptSimplifier, MeshoptEncoder } from "meshoptimizer";
1626
1626
  await Promise.all([MeshoptSimplifier.ready, MeshoptEncoder.ready]);
1627
1627
  function reorderMesh(P, N, C, I) {
@@ -1927,7 +1927,7 @@ function levelLines(P, I, E, err, always, tol = 0.01) {
1927
1927
  return out;
1928
1928
  }
1929
1929
 
1930
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/node/compile.ts
1930
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/compile.ts
1931
1931
  class BfcState {
1932
1932
  accum;
1933
1933
  ccw = true;
@@ -2230,6 +2230,22 @@ class Compiler {
2230
2230
  seatStuds(out, fullKind, (k) => this.compile(k, false).bbox);
2231
2231
  if (this.opts.tex && this.hasTex(key))
2232
2232
  this.texPass(key, out, separateStuds, colorOf);
2233
+ const cap = OPEN_BOTTOM[key.replace(/^.*[\\/]/, "").toLowerCase()];
2234
+ if (cap && isFinite(out.bbox[0])) {
2235
+ const [cx0, cz0, cx1, cz1] = cap, y = out.bbox[4], b = out.body, per = b.col.length / (b.pos.length / 3);
2236
+ let v = -1;
2237
+ for (let i = 1;i < b.pos.length; i += 3)
2238
+ if (Math.abs(b.pos[i] - y) < 0.01) {
2239
+ v = (i - 1) / 3;
2240
+ break;
2241
+ }
2242
+ if (v >= 0) {
2243
+ const rgba = b.col.slice(v * per, v * per + per);
2244
+ b.pos.push(cx0, y, cz0, cx0, y, cz1, cx1, y, cz1, cx0, y, cz0, cx1, y, cz1, cx1, y, cz0);
2245
+ for (let k = 0;k < 6; k++)
2246
+ b.col.push(...rgba);
2247
+ }
2248
+ }
2233
2249
  const [x0, y0, z0, x1, y1, z1] = out.bbox;
2234
2250
  let ax0 = Infinity, ax1 = -Infinity, az0 = Infinity, az1 = -Infinity;
2235
2251
  for (const b of [out.body, out.under])
@@ -2455,6 +2471,7 @@ class Compiler {
2455
2471
  }
2456
2472
  }
2457
2473
  }
2474
+ var OPEN_BOTTOM = { "11477.dat": [-10, -20, 10, 20] };
2458
2475
  function underEnclosed(c) {
2459
2476
  const u = c.under.pos;
2460
2477
  let uy0 = Infinity, uy1 = -Infinity, ux0 = Infinity, ux1 = -Infinity, uz0 = Infinity, uz1 = -Infinity;
@@ -2871,7 +2888,7 @@ function encodePack(parts, studKinds, weld, extra, options = {}) {
2871
2888
  return Buffer.concat([head, ...chunks.map((c) => new Uint8Array(c.buffer, c.byteOffset, c.byteLength))]);
2872
2889
  }
2873
2890
 
2874
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/node/build-pack.ts
2891
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/build-pack.ts
2875
2892
  function packCompilerOpts(o) {
2876
2893
  return { studs: o.studs ?? "low", prims: o.primitives ?? "full", weld: o.weld ?? true, separateStuds: true, cond: !!o.cond, tex: !!o.textures, ...o.partWorkLimit ? { workLimit: o.partWorkLimit } : {} };
2877
2894
  }
@@ -2944,7 +2961,7 @@ function buildPack(o) {
2944
2961
  return { data: encodePack(parts, kinds, comp.opts.weld, extra, { texture, lod: o.lod !== false, reorder: !!o.reorder }), parts: parts.size, studKinds: kinds.size, missing: [...missing], ...warnings.length ? { warnings } : {} };
2945
2962
  }
2946
2963
 
2947
- // ../../../../../../../tmp/ldr-build-cBWp5F/src/cli.ts
2964
+ // ../../../../../../../tmp/ldr-build-vpoU1w/src/cli.ts
2948
2965
  var HELP = `ldr pack — build a parts pack for the ldr three.js renderer
2949
2966
 
2950
2967
  Usage:
package/dist/index.d.ts CHANGED
@@ -6,8 +6,9 @@ export type { StepCameraView, StepCameraOptions, Vec3 } from "./instructions.js"
6
6
  export type { PartInstance, FlattenOptions, LDrawColor, LDrawFinish, LDrawFinishType, LDrawMaterialGrain, ColourSurface } from "./model.js";
7
7
  export { loadPack, decodePack, buildLdrScene, buildLdrSceneAsync, makeMaterial, makeFinishMaterial, createInstancedEdges, computeCulling, cullCore, forEachStud, conditionalLines, createInstancedConditionalEdges, conditionalLineVisible, warmPackGeometry, makeTexturedMaterial, packTexture, pngHasAlpha } from "./render.js";
8
8
  export { precomputeCull, sceneInstances } from "./cull.js";
9
- export type { Pack, LdrParams, Inst, CullResult, BuildLdrSceneAsyncOptions, GlossMap } from "./render.js";
9
+ export type { StudMask, Pack, LdrParams, Inst, CullResult, BuildLdrSceneAsyncOptions, GlossMap } from "./render.js";
10
10
  export { createLdrObject, createLdrObjectAsync } from "./scene.js";
11
+ export { studDecalUniforms, type StudDecalUniforms } from "./stud-decal.js";
11
12
  export type { LdrObject, LdrObjectOptions, LdrStats, ColorSource, GhostOptions } from "./scene.js";
12
13
  export { decompressPack, decodeModelText, modelFileName } from "./pack-io.js";
13
14
  export { loadModel, loadParts, loadPartsIndex, mergePacks, prepareModel, bodyTriangles, estimateBudgetFromIndex, BudgetError, DEFAULT_PARTS_CDN } from "./cdn.js";