ldr 0.5.0 → 0.5.1

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-qIdKSv/src/cli.ts
3
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/cli.ts
4
4
  import fs4 from "node:fs";
5
5
  import zlib from "node:zlib";
6
6
 
7
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/build-pack.ts
7
+ // ../../../../../../../tmp/ldr-build-pIke9r/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-qIdKSv/src/node/resolver.ts
11
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/resolver.ts
12
12
  import fs from "node:fs";
13
13
  import path from "node:path";
14
14
 
15
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/spec.ts
15
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/spec.ts
16
16
  var norm = (s) => s.trim().toLowerCase().replace(/\\/g, "/").replace(/\/+/g, "/");
17
17
  function parseColor(tok) {
18
18
  if (/^0x/i.test(tok))
@@ -662,7 +662,7 @@ function fileStepViews(f) {
662
662
  return out;
663
663
  }
664
664
 
665
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/model.ts
665
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/model.ts
666
666
  function flatten(doc, opts = {}) {
667
667
  const out = [];
668
668
  const maxDepth = opts.maxDepth ?? 64;
@@ -784,7 +784,7 @@ function parseLDConfig(text) {
784
784
  return out;
785
785
  }
786
786
 
787
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/resolver.ts
787
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/resolver.ts
788
788
  var TOP_STUD_RE = /^(stud|studa|stud2|stud2a|stud6|stud6a|stud10|stud15|stud2s|stud2s2|stud-logo\d*|stud2-logo\d*)\.dat$/i;
789
789
  var UNDER_STUD_RE = /^(stud3|stud3a|stud4.*|stud12|stud16.*|stud18a)\.dat$/i;
790
790
  var norm2 = (ref) => ref.trim().replace(/\\/g, "/").toLowerCase();
@@ -1054,11 +1054,11 @@ function collectDeps(lib, refs) {
1054
1054
  return out;
1055
1055
  }
1056
1056
 
1057
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/compile.ts
1057
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/compile.ts
1058
1058
  import fs2 from "node:fs";
1059
1059
  import path2 from "node:path";
1060
1060
 
1061
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/lod.ts
1061
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/lod.ts
1062
1062
  import { MeshoptSimplifier, MeshoptEncoder } from "meshoptimizer";
1063
1063
  await Promise.all([MeshoptSimplifier.ready, MeshoptEncoder.ready]);
1064
1064
  function reorderMesh(P, N, C, I) {
@@ -1165,7 +1165,7 @@ function lodChain(P, C, I) {
1165
1165
  return out;
1166
1166
  }
1167
1167
 
1168
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/compile.ts
1168
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/compile.ts
1169
1169
  function loadColors(root) {
1170
1170
  const map = new Map;
1171
1171
  for (const l of fs2.readFileSync(path2.join(root, "LDConfig.ldr"), "latin1").split(/\r?\n/)) {
@@ -1748,7 +1748,7 @@ function encodePack(parts, studKinds, weld, extra, options = {}) {
1748
1748
  return Buffer.concat([head, ...chunks.map((c) => new Uint8Array(c.buffer, c.byteOffset, c.byteLength))]);
1749
1749
  }
1750
1750
 
1751
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/build-pack.ts
1751
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/build-pack.ts
1752
1752
  function buildPack(o) {
1753
1753
  const lib = new Library(o.ldrawRoot);
1754
1754
  const refs = new Map;
@@ -1811,7 +1811,7 @@ function buildPack(o) {
1811
1811
  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 } : {} };
1812
1812
  }
1813
1813
 
1814
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/cli.ts
1814
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/cli.ts
1815
1815
  var HELP = `ldr pack — build a parts pack for the ldr three.js renderer
1816
1816
 
1817
1817
  Usage:
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/spec.ts
1
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/spec.ts
2
2
  var norm = (s) => s.trim().toLowerCase().replace(/\\/g, "/").replace(/\/+/g, "/");
3
3
  function parseColor(tok) {
4
4
  if (/^0x/i.test(tok))
@@ -647,7 +647,7 @@ function fileStepViews(f) {
647
647
  viewMemo.set(f, out);
648
648
  return out;
649
649
  }
650
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/model.ts
650
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/model.ts
651
651
  function flatten(doc, opts = {}) {
652
652
  const out = [];
653
653
  const maxDepth = opts.maxDepth ?? 64;
@@ -768,7 +768,7 @@ function parseLDConfig(text) {
768
768
  }
769
769
  return out;
770
770
  }
771
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/render.ts
771
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/render.ts
772
772
  import * as THREE from "three";
773
773
  async function loadPack(url) {
774
774
  const res = await fetch(url);
@@ -856,10 +856,11 @@ function makeMaterial(side) {
856
856
  const m = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.45, side });
857
857
  m.onBeforeCompile = (s) => {
858
858
  s.vertexShader = `attribute vec4 ldrColor;
859
- ` + s.vertexShader.replace("#include <color_vertex>", `#ifdef USE_INSTANCING_COLOR
860
- vColor = vec4(ldrColor.a > 0.5 ? pow(ldrColor.rgb, vec3(2.2)) : instanceColor.rgb, 1.0); // baked LDConfig colours are sRGB
859
+ ` + s.vertexShader.replace("#include <color_vertex>", `#include <color_vertex>
860
+ #ifdef USE_INSTANCING_COLOR
861
+ vColor.rgb = ldrColor.a > 0.5 ? pow(ldrColor.rgb, vec3(2.2)) : instanceColor.rgb; // baked LDConfig colours are sRGB
861
862
  #else
862
- vColor = vec4(pow(ldrColor.rgb, vec3(2.2)), 1.0);
863
+ vColor.rgb = pow(ldrColor.rgb, vec3(2.2));
863
864
  #endif`);
864
865
  };
865
866
  m.customProgramCacheKey = () => "ldrColor";
@@ -1947,7 +1948,7 @@ function buildLdrScene(insts, pack, P, color, mark) {
1947
1948
  byPart.clear();
1948
1949
  return { root, stats, setCull, setSide, setEdges, setCond, swapStuds, setLod, setStep, box, texturesReady };
1949
1950
  }
1950
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/scene.ts
1951
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/scene.ts
1951
1952
  import * as THREE2 from "three";
1952
1953
  function colorFn(src, pack, fallback) {
1953
1954
  const table = new Map;
@@ -2107,7 +2108,7 @@ function createLdrObject(instances, pack, options = {}) {
2107
2108
  dispose: disposeCur
2108
2109
  });
2109
2110
  }
2110
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/pack-io.ts
2111
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/pack-io.ts
2111
2112
  import { decompress } from "fzstd";
2112
2113
  async function decompressPack(data) {
2113
2114
  const u = data instanceof Uint8Array ? data : new Uint8Array(data);
@@ -2118,7 +2119,7 @@ async function decompressPack(data) {
2118
2119
  return new Response(new Blob([u]).stream().pipeThrough(new DecompressionStream("gzip"))).arrayBuffer();
2119
2120
  return own(u);
2120
2121
  }
2121
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/cdn.ts
2122
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/cdn.ts
2122
2123
  import { decompress as decompress2 } from "fzstd";
2123
2124
  var DEFAULT_PARTS_CDN = "https://ldr-demo.vercel.app/cdn/v1/";
2124
2125
  var indexCache = new Map;
@@ -1,4 +1,4 @@
1
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/spec.ts
1
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/spec.ts
2
2
  var norm = (s) => s.trim().toLowerCase().replace(/\\/g, "/").replace(/\/+/g, "/");
3
3
  function parseColor(tok) {
4
4
  if (/^0x/i.test(tok))
@@ -647,7 +647,7 @@ function fileStepViews(f) {
647
647
  viewMemo.set(f, out);
648
648
  return out;
649
649
  }
650
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/model.ts
650
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/model.ts
651
651
  function flatten(doc, opts = {}) {
652
652
  const out = [];
653
653
  const maxDepth = opts.maxDepth ?? 64;
@@ -768,7 +768,7 @@ function parseLDConfig(text) {
768
768
  }
769
769
  return out;
770
770
  }
771
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/render.ts
771
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/render.ts
772
772
  import * as THREE from "three";
773
773
  async function loadPack(url) {
774
774
  const res = await fetch(url);
@@ -856,10 +856,11 @@ function makeMaterial(side) {
856
856
  const m = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.45, side });
857
857
  m.onBeforeCompile = (s) => {
858
858
  s.vertexShader = `attribute vec4 ldrColor;
859
- ` + s.vertexShader.replace("#include <color_vertex>", `#ifdef USE_INSTANCING_COLOR
860
- vColor = vec4(ldrColor.a > 0.5 ? pow(ldrColor.rgb, vec3(2.2)) : instanceColor.rgb, 1.0); // baked LDConfig colours are sRGB
859
+ ` + s.vertexShader.replace("#include <color_vertex>", `#include <color_vertex>
860
+ #ifdef USE_INSTANCING_COLOR
861
+ vColor.rgb = ldrColor.a > 0.5 ? pow(ldrColor.rgb, vec3(2.2)) : instanceColor.rgb; // baked LDConfig colours are sRGB
861
862
  #else
862
- vColor = vec4(pow(ldrColor.rgb, vec3(2.2)), 1.0);
863
+ vColor.rgb = pow(ldrColor.rgb, vec3(2.2));
863
864
  #endif`);
864
865
  };
865
866
  m.customProgramCacheKey = () => "ldrColor";
@@ -1947,7 +1948,7 @@ function buildLdrScene(insts, pack, P, color, mark) {
1947
1948
  byPart.clear();
1948
1949
  return { root, stats, setCull, setSide, setEdges, setCond, swapStuds, setLod, setStep, box, texturesReady };
1949
1950
  }
1950
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/scene.ts
1951
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/scene.ts
1951
1952
  import * as THREE2 from "three";
1952
1953
  function colorFn(src, pack, fallback) {
1953
1954
  const table = new Map;
@@ -2107,7 +2108,7 @@ function createLdrObject(instances, pack, options = {}) {
2107
2108
  dispose: disposeCur
2108
2109
  });
2109
2110
  }
2110
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/pack-io.ts
2111
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/pack-io.ts
2111
2112
  import { decompress } from "fzstd";
2112
2113
  async function decompressPack(data) {
2113
2114
  const u = data instanceof Uint8Array ? data : new Uint8Array(data);
@@ -2118,7 +2119,7 @@ async function decompressPack(data) {
2118
2119
  return new Response(new Blob([u]).stream().pipeThrough(new DecompressionStream("gzip"))).arrayBuffer();
2119
2120
  return own(u);
2120
2121
  }
2121
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/cdn.ts
2122
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/cdn.ts
2122
2123
  import { decompress as decompress2 } from "fzstd";
2123
2124
  var DEFAULT_PARTS_CDN = "https://ldr-demo.vercel.app/cdn/v1/";
2124
2125
  var indexCache = new Map;
@@ -2258,7 +2259,7 @@ async function loadModel(source, o = {}) {
2258
2259
  const t4 = performance.now();
2259
2260
  return Object.assign(obj, { pack, instances: insts, requests, bytes, timings: { fetchModel: t1 - t0, parse: t2 - t1, parts: t3 - t2, build: t4 - t3, total: t4 - t0 } });
2260
2261
  }
2261
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/library.ts
2262
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/library.ts
2262
2263
  import { existsSync, readFileSync } from "fs";
2263
2264
  import { join } from "path";
2264
2265
  var xf = (m, x, y, z) => [m[3] * x + m[4] * y + m[5] * z + m[0], m[6] * x + m[7] * y + m[8] * z + m[1], m[9] * x + m[10] * y + m[11] * z + m[2]];
@@ -2510,11 +2511,11 @@ class Library {
2510
2511
  return insts;
2511
2512
  }
2512
2513
  }
2513
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/build-pack.ts
2514
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/build-pack.ts
2514
2515
  import fs3 from "node:fs";
2515
2516
  import path3 from "node:path";
2516
2517
 
2517
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/resolver.ts
2518
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/resolver.ts
2518
2519
  import fs from "node:fs";
2519
2520
  import path from "node:path";
2520
2521
  var TOP_STUD_RE = /^(stud|studa|stud2|stud2a|stud6|stud6a|stud10|stud15|stud2s|stud2s2|stud-logo\d*|stud2-logo\d*)\.dat$/i;
@@ -2786,11 +2787,11 @@ function collectDeps(lib, refs) {
2786
2787
  return out;
2787
2788
  }
2788
2789
 
2789
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/compile.ts
2790
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/compile.ts
2790
2791
  import fs2 from "node:fs";
2791
2792
  import path2 from "node:path";
2792
2793
 
2793
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/lod.ts
2794
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/lod.ts
2794
2795
  import { MeshoptSimplifier, MeshoptEncoder } from "meshoptimizer";
2795
2796
  await Promise.all([MeshoptSimplifier.ready, MeshoptEncoder.ready]);
2796
2797
  function reorderMesh(P, N, C, I) {
@@ -2897,7 +2898,7 @@ function lodChain(P, C, I) {
2897
2898
  return out;
2898
2899
  }
2899
2900
 
2900
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/compile.ts
2901
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/compile.ts
2901
2902
  function loadColors(root) {
2902
2903
  const map = new Map;
2903
2904
  for (const l of fs2.readFileSync(path2.join(root, "LDConfig.ldr"), "latin1").split(/\r?\n/)) {
@@ -3480,7 +3481,7 @@ function encodePack(parts, studKinds, weld, extra, options = {}) {
3480
3481
  return Buffer.concat([head, ...chunks.map((c) => new Uint8Array(c.buffer, c.byteOffset, c.byteLength))]);
3481
3482
  }
3482
3483
 
3483
- // ../../../../../../../tmp/ldr-build-qIdKSv/src/node/build-pack.ts
3484
+ // ../../../../../../../tmp/ldr-build-pIke9r/src/node/build-pack.ts
3484
3485
  function buildPack(o) {
3485
3486
  const lib = new Library2(o.ldrawRoot);
3486
3487
  const refs = new Map;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ldr",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "High-performance LEGO (LDraw) rendering for three.js: instanced parts packs, hidden stud/tube culling, low-detail studs, indexed edges, build steps.",
5
5
  "license": "MIT",
6
6
  "author": "Evan Bacon",
@@ -41,7 +41,7 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "bin": {
44
- "ldr": "./dist/cli.js"
44
+ "ldr": "dist/cli.js"
45
45
  },
46
46
  "files": [
47
47
  "dist",
@@ -58,7 +58,7 @@
58
58
  "meshoptimizer": "1.2.0"
59
59
  },
60
60
  "peerDependencies": {
61
- "three": ">=0.160.0"
61
+ "three": ">=0.151.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/bun": "latest",