ldr 0.7.0 → 0.9.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/README.md +1 -1
- package/dist/cdn.d.ts +2 -1
- package/dist/cli.js +11 -11
- package/dist/embedded.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +434 -98
- package/dist/load-worker.gen.d.ts +1 -1
- package/dist/node/index.js +440 -104
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ Light the scene (or set `scene.environment`) as you would for any `MeshStandardM
|
|
|
102
102
|
| `resolveModel(name)` | – | Resolves an external reference to a `Doc`, such as a model loaded separately. Return `null` to treat it as a part. |
|
|
103
103
|
| `maxDepth` | `64` | Submodel nesting limit (cycle guard). |
|
|
104
104
|
|
|
105
|
-
MPD-embedded parts, such as Studio/OMR unofficial parts or stickers, become part instances (`embedded: true`) and override library parts of the same name.
|
|
105
|
+
MPD-embedded parts, such as Studio/OMR unofficial parts or stickers, become part instances (`embedded: true`) and override library parts of the same name. `loadModel` asks the parts CDN for them by a hash of their definition (`embeddedKeys`), so a CDN built with `--embedded <model dir>` serves the embedded parts of those models (the demo CDN carries the ones in its 1,773 catalog models).
|
|
106
106
|
|
|
107
107
|
**Packs and rendering**
|
|
108
108
|
|
package/dist/cdn.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface LoadedModel extends LdrObject {
|
|
|
24
24
|
/**
|
|
25
25
|
* One call from an `.ldr` / `.mpd` URL (or text) to a three.js object: fetches the model, fetches just the parts it uses from the
|
|
26
26
|
* parts CDN and builds an instanced `LdrObject`. No LDraw library or parts pack needed.
|
|
27
|
-
*
|
|
27
|
+
* MPD-embedded parts are fetched by content key (`emb/<hash>.dat`, see embedded.ts): a CDN built with `--embedded` serves the ones in
|
|
28
|
+
* known models. Embedded parts the CDN lacks, and loose geometry in model files, are skipped (listed in `stats.missing`).
|
|
28
29
|
*/
|
|
29
30
|
export declare function loadModel(source: string, o?: LoadModelOptions): Promise<LoadedModel>;
|
package/dist/cli.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// ../../../../../../../tmp/ldr-build-
|
|
3
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/src/cli.ts
|
|
4
4
|
import fs4 from "node:fs";
|
|
5
5
|
import zlib from "node:zlib";
|
|
6
6
|
|
|
7
|
-
// ../../../../../../../tmp/ldr-build-
|
|
7
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/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-
|
|
11
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/src/node/resolver.ts
|
|
12
12
|
import fs from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
|
|
15
|
-
// ../../../../../../../tmp/ldr-build-
|
|
15
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/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))
|
|
@@ -705,7 +705,7 @@ function fileStepViews(f) {
|
|
|
705
705
|
return out;
|
|
706
706
|
}
|
|
707
707
|
|
|
708
|
-
// ../../../../../../../tmp/ldr-build-
|
|
708
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/src/model.ts
|
|
709
709
|
var CALLOUT_END = 999999;
|
|
710
710
|
var stepKey = (steps) => steps.map((x) => String(x).padStart(6, "0")).join(".") + "~";
|
|
711
711
|
function flatten(doc, opts = {}) {
|
|
@@ -864,7 +864,7 @@ function parseLDConfig(text) {
|
|
|
864
864
|
return out;
|
|
865
865
|
}
|
|
866
866
|
|
|
867
|
-
// ../../../../../../../tmp/ldr-build-
|
|
867
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/src/node/resolver.ts
|
|
868
868
|
var TOP_STUD_RE = /^(stud|studa|stud2|stud2a|stud6|stud6a|stud10|stud15|stud2s|stud2s2|stud-logo\d*|stud2-logo\d*)\.dat$/i;
|
|
869
869
|
var UNDER_STUD_RE = /^(stud3|stud3a|stud4.*|stud12|stud16.*|stud18a)\.dat$/i;
|
|
870
870
|
var norm2 = (ref) => ref.trim().replace(/\\/g, "/").toLowerCase();
|
|
@@ -1134,11 +1134,11 @@ function collectDeps(lib, refs) {
|
|
|
1134
1134
|
return out;
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
1137
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1137
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/src/node/compile.ts
|
|
1138
1138
|
import fs2 from "node:fs";
|
|
1139
1139
|
import path2 from "node:path";
|
|
1140
1140
|
|
|
1141
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1141
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/src/node/lod.ts
|
|
1142
1142
|
import { MeshoptSimplifier, MeshoptEncoder } from "meshoptimizer";
|
|
1143
1143
|
await Promise.all([MeshoptSimplifier.ready, MeshoptEncoder.ready]);
|
|
1144
1144
|
function reorderMesh(P, N, C, I) {
|
|
@@ -1330,7 +1330,7 @@ function lodChain(P, C, I) {
|
|
|
1330
1330
|
return out;
|
|
1331
1331
|
}
|
|
1332
1332
|
|
|
1333
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1333
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/src/node/compile.ts
|
|
1334
1334
|
function loadColors(root) {
|
|
1335
1335
|
const map = new Map;
|
|
1336
1336
|
for (const l of fs2.readFileSync(path2.join(root, "LDConfig.ldr"), "latin1").split(/\r?\n/)) {
|
|
@@ -1913,7 +1913,7 @@ function encodePack(parts, studKinds, weld, extra, options = {}) {
|
|
|
1913
1913
|
return Buffer.concat([head, ...chunks.map((c) => new Uint8Array(c.buffer, c.byteOffset, c.byteLength))]);
|
|
1914
1914
|
}
|
|
1915
1915
|
|
|
1916
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1916
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/src/node/build-pack.ts
|
|
1917
1917
|
function buildPack(o) {
|
|
1918
1918
|
const lib = new Library(o.ldrawRoot);
|
|
1919
1919
|
const refs = new Map;
|
|
@@ -1976,7 +1976,7 @@ function buildPack(o) {
|
|
|
1976
1976
|
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 } : {} };
|
|
1977
1977
|
}
|
|
1978
1978
|
|
|
1979
|
-
// ../../../../../../../tmp/ldr-build-
|
|
1979
|
+
// ../../../../../../../tmp/ldr-build-E7gTbS/src/cli.ts
|
|
1980
1980
|
var HELP = `ldr pack — build a parts pack for the ldr three.js renderer
|
|
1981
1981
|
|
|
1982
1982
|
Usage:
|
package/dist/index.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export type { LdrObject, LdrObjectOptions, LdrStats, ColorSource } from "./scene
|
|
|
12
12
|
export { decompressPack } from "./pack-io.js";
|
|
13
13
|
export { loadModel, loadParts, loadPartsIndex, mergePacks, prepareModel, DEFAULT_PARTS_CDN } from "./cdn.js";
|
|
14
14
|
export type { LoadModelOptions, LoadedModel, LoadPartsOptions, PartsCdnIndex, PrepareOptions, PreparedModel } from "./cdn.js";
|
|
15
|
+
export { embeddedKeys } from "./embedded.js";
|