ldr 0.34.12 → 0.34.14

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/cli.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // ../../../../../../../tmp/ldr-build-vpoU1w/src/cli.ts
3
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/src/cli.ts
4
4
  import fs4 from "node:fs";
5
5
  import zlib from "node:zlib";
6
6
 
7
- // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/build-pack.ts
7
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/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-vpoU1w/src/node/resolver.ts
11
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/src/node/resolver.ts
12
12
  import fs from "node:fs";
13
13
  import path from "node:path";
14
14
 
15
- // ../../../../../../../tmp/ldr-build-vpoU1w/src/spec.ts
15
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/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-vpoU1w/src/model.ts
851
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/src/model.ts
852
852
  class ModelLimitError extends Error {
853
853
  limit;
854
854
  code = "ldr-model-limit";
@@ -898,6 +898,15 @@ function flatten(doc, opts = {}) {
898
898
  const loose = opts.looseGeometry !== false, tx = !!opts.textures, co = !!opts.callouts;
899
899
  const src = new Map;
900
900
  let subs = 0;
901
+ const stepSingles = [];
902
+ const stepPathOf = (path, s) => {
903
+ if (path.length)
904
+ return [...path, s];
905
+ let a = stepSingles[s];
906
+ if (!a)
907
+ stepSingles[s] = a = [s];
908
+ return a;
909
+ };
901
910
  const open = new Set;
902
911
  const maxN = opts.maxInstances ?? 2000000;
903
912
  let work = 0;
@@ -977,7 +986,7 @@ function flatten(doc, opts = {}) {
977
986
  const flushLoose = (upTo) => {
978
987
  while (li < ls.length && ls[li] <= upTo) {
979
988
  const k = ls[li++];
980
- emit(loosePartName(f.name, k), color, m, [...stepPath, k], k, false, null, colour, scope0).source = lazy(f, k);
989
+ emit(loosePartName(f.name, k), color, m, stepPathOf(stepPath, k), k, false, null, colour, scope0).source = lazy(f, k);
981
990
  }
982
991
  };
983
992
  for (const c0 of f.cmds) {
@@ -1008,10 +1017,10 @@ function flatten(doc, opts = {}) {
1008
1017
  continue;
1009
1018
  if (tx && c.fallback)
1010
1019
  continue;
1011
- const mm = mul(m, c.m);
1020
+ const mm = m === I ? c.m : mul(m, c.m);
1012
1021
  if (!inRange12(mm))
1013
1022
  continue;
1014
- const col = c.color === 16 ? color : c.color, cd = c.color === 16 ? colour : scope?.get(c.color), sp = [...stepPath, s];
1023
+ const col = c.color === 16 ? color : c.color, cd = c.color === 16 ? colour : scope?.get(c.color), sp = stepPathOf(stepPath, s);
1015
1024
  const tex = tx ? c.tex ?? texIn : null;
1016
1025
  const local = tex ? invert(c.m) : null;
1017
1026
  const lt = tex && local ? transformTexMap(tex, local) : null;
@@ -1290,7 +1299,7 @@ function blendedColourHex(code) {
1290
1299
  return "#" + [0, 1, 2].map((k) => (a[k] + b[k] >> 1).toString(16).padStart(2, "0")).join("").toUpperCase();
1291
1300
  }
1292
1301
 
1293
- // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/resolver.ts
1302
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/src/node/resolver.ts
1294
1303
  var TOP_STUD_RE = /^(stud|studa|stud2|stud2a|stud6|stud6a|stud10|stud15|stud2s|stud2s2|stud-logo\d*|stud2-logo\d*)\.dat$/i;
1295
1304
  var UNDER_STUD_RE = /^(stud3|stud3a|stud4.*|stud12|stud16.*|stud18a)\.dat$/i;
1296
1305
  var norm2 = (ref) => ref.trim().replace(/\\/g, "/").toLowerCase();
@@ -1617,11 +1626,11 @@ function collectDeps(lib, refs) {
1617
1626
  return out;
1618
1627
  }
1619
1628
 
1620
- // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/compile.ts
1629
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/src/node/compile.ts
1621
1630
  import fs2 from "node:fs";
1622
1631
  import path2 from "node:path";
1623
1632
 
1624
- // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/lod.ts
1633
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/src/node/lod.ts
1625
1634
  import { MeshoptSimplifier, MeshoptEncoder } from "meshoptimizer";
1626
1635
  await Promise.all([MeshoptSimplifier.ready, MeshoptEncoder.ready]);
1627
1636
  function reorderMesh(P, N, C, I) {
@@ -1927,7 +1936,7 @@ function levelLines(P, I, E, err, always, tol = 0.01) {
1927
1936
  return out;
1928
1937
  }
1929
1938
 
1930
- // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/compile.ts
1939
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/src/node/compile.ts
1931
1940
  class BfcState {
1932
1941
  accum;
1933
1942
  ccw = true;
@@ -2888,7 +2897,7 @@ function encodePack(parts, studKinds, weld, extra, options = {}) {
2888
2897
  return Buffer.concat([head, ...chunks.map((c) => new Uint8Array(c.buffer, c.byteOffset, c.byteLength))]);
2889
2898
  }
2890
2899
 
2891
- // ../../../../../../../tmp/ldr-build-vpoU1w/src/node/build-pack.ts
2900
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/src/node/build-pack.ts
2892
2901
  function packCompilerOpts(o) {
2893
2902
  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 } : {} };
2894
2903
  }
@@ -2961,7 +2970,7 @@ function buildPack(o) {
2961
2970
  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 } : {} };
2962
2971
  }
2963
2972
 
2964
- // ../../../../../../../tmp/ldr-build-vpoU1w/src/cli.ts
2973
+ // ../../../../../../../tmp/ldr-build-zkQ2hC/src/cli.ts
2965
2974
  var HELP = `ldr pack — build a parts pack for the ldr three.js renderer
2966
2975
 
2967
2976
  Usage:
package/dist/cull.d.ts CHANGED
@@ -14,7 +14,8 @@ export type PrepPart = {
14
14
  mask: Uint8Array | null;
15
15
  nx: number;
16
16
  nz: number; /** every mask cell enclosed */
17
- full: boolean;
17
+ full: boolean; /** the pack header's part entry (`H.parts[part]`) */
18
+ src: any;
18
19
  };
19
20
  export declare function prepPart(H: any, part: string): PrepPart | null;
20
21
  /** w = a * b for LDraw 12-number matrices (x y z a b c d e f g h i); same arithmetic as the instance flattener. */
@@ -82,7 +83,8 @@ export declare const STEP_NEVER = 2147483647;
82
83
  export declare function forEachStud(insts: Inst[], H: any, fn: (j: number, inst: number, w: Float64Array, kind: string, color: string, stud: number) => void): void;
83
84
  /** `steps` (optional, per instance): also compute when each stud / underside becomes hidden as the model is built step by step.
84
85
  * Transparent instances hide nothing (studs inside their hollow stay visible through them) and keep their own undersides. */
85
- export declare function cullCore(insts: Inst[], H: any, steps?: ArrayLike<number>): CullResult;
86
+ /** `pps`: each instance's `prepPart` when the caller already has them (the scene builder looks them up once for all its passes). */
87
+ export declare function cullCore(insts: Inst[], H: any, steps?: ArrayLike<number>, pps?: (PrepPart | null)[]): CullResult;
86
88
  /** Scene instances and per-instance step ranks as `createLdrObject` builds them (shared with the load worker). */
87
89
  export declare function sceneInstances(instances: PartInstance[], H: any, useTex: boolean): {
88
90
  all: {