ldr 0.13.0 → 0.15.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/cli.js +11 -11
- package/dist/index.d.ts +3 -3
- package/dist/index.js +213 -131
- package/dist/node/index.js +220 -138
- package/dist/render.d.ts +13 -17
- package/dist/scene.d.ts +20 -0
- package/package.json +1 -1
package/dist/render.d.ts
CHANGED
|
@@ -70,25 +70,21 @@ export declare function computeCulling(insts: Inst[], H: any): {
|
|
|
70
70
|
}[];
|
|
71
71
|
underHidden: boolean[];
|
|
72
72
|
};
|
|
73
|
-
export declare function buildLdrScene(insts: Inst[], pack: Pack, P: LdrParams, color: (c: string) => THREE.Color, mark: (k: string) => void): {
|
|
74
|
-
root: THREE.Group;
|
|
75
|
-
stats: any;
|
|
76
|
-
setCull: (studs: boolean, under: boolean) => void;
|
|
77
|
-
setSide: (front: boolean) => void;
|
|
78
|
-
setEdges: (v: boolean) => void;
|
|
79
|
-
setCond: (v: boolean) => void;
|
|
80
|
-
setLod: (on: boolean) => void;
|
|
81
|
-
setStep: (s: number | null, mask?: ArrayLike<number | boolean> | null) => {
|
|
82
|
-
studsTotal: number;
|
|
83
|
-
studsHidden: number;
|
|
84
|
-
undersTotal: number;
|
|
85
|
-
undersHidden: number;
|
|
86
|
-
};
|
|
87
|
-
box: THREE.Box3;
|
|
88
|
-
texturesReady: Promise<void>;
|
|
89
|
-
};
|
|
90
73
|
/**
|
|
91
74
|
* Builds (and caches on the pack) the shared BufferGeometries `buildLdrScene` will use, in time slices of about `sliceMs` that yield
|
|
92
75
|
* to the event loop, until done or `stop()` returns true. Lets the main thread do this useful work while the load worker culls.
|
|
93
76
|
*/
|
|
77
|
+
/** Drive buildLdrSceneGen to completion without yielding (same as pre-Round-33 sync build). */
|
|
78
|
+
export declare function buildLdrScene(insts: Inst[], pack: Pack, P: LdrParams, color: (c: string) => THREE.Color, mark: (k: string) => void): any;
|
|
79
|
+
export type BuildLdrSceneAsyncOptions = {
|
|
80
|
+
/** Soft cap on contiguous main-thread work between yields (ms). Default 8. */
|
|
81
|
+
sliceMs?: number;
|
|
82
|
+
/** Called after each yield while the live root already holds finished batches (paint for TTFP). */
|
|
83
|
+
onSlice?: (root: THREE.Object3D) => void | Promise<void>;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Same scene as buildLdrScene, but yields to the event loop about every sliceMs so the main thread stays responsive
|
|
87
|
+
* and onSlice can render partial geometry for a fast time-to-first-pixel. Meshes are added to root as they are built.
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildLdrSceneAsync(insts: Inst[], pack: Pack, P: LdrParams, color: (c: string) => THREE.Color, mark: (k: string) => void, opts?: BuildLdrSceneAsyncOptions): Promise<any>;
|
|
94
90
|
export declare function warmPackGeometry(pack: Pack, stop?: () => boolean, sliceMs?: number): Promise<void>;
|
package/dist/scene.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export interface LdrObjectOptions {
|
|
|
51
51
|
/** LOD: skip undersides that can't be seen: while the camera is behind every bottom face of a cluster's (same-orientation) parts and
|
|
52
52
|
* studs are under 4 px, or where the body is drawn as its closed bounding box. Default true. */
|
|
53
53
|
lodUnder?: boolean;
|
|
54
|
+
/** Progressive build (createLdrObjectAsync / loadModel): soft cap on contiguous main-thread work between yields, ms. Default 8. */
|
|
55
|
+
sliceMs?: number;
|
|
56
|
+
/** Progressive build: called after each yield; the live object already holds finished batches — render for TTFP. */
|
|
57
|
+
onSlice?: () => void | Promise<void>;
|
|
54
58
|
}
|
|
55
59
|
export interface LdrStats {
|
|
56
60
|
instances: number;
|
|
@@ -61,6 +65,10 @@ export interface LdrStats {
|
|
|
61
65
|
undersTotal: number;
|
|
62
66
|
undersHidden: number;
|
|
63
67
|
buildMs: number;
|
|
68
|
+
/** Progressive build: longest contiguous main-thread slice (ms). */
|
|
69
|
+
longestSliceMs?: number;
|
|
70
|
+
/** Progressive build: number of yields during scene construction. */
|
|
71
|
+
buildYields?: number;
|
|
64
72
|
/** Conditional-line batches (draw calls) created; 0 for packs without conditional lines. */
|
|
65
73
|
condBatches?: number;
|
|
66
74
|
/** Textured batches (one per part x texture) and distinct textures; 0 for packs without textures. */
|
|
@@ -87,6 +95,8 @@ export interface LdrObject {
|
|
|
87
95
|
texturesReady: Promise<void>;
|
|
88
96
|
/** Toggle conditional lines (only visible while edges are on). */
|
|
89
97
|
setConditionalLines(on: boolean): void;
|
|
98
|
+
/** Without steps, an object built with culling on drops the hidden instances' buffers; turning that culling off rebuilds the object
|
|
99
|
+
* (like a fresh `createLdrObject`, ~build time) so they can be drawn. Turning it back on afterwards is instant. */
|
|
90
100
|
setCulling(studs: boolean, undersides: boolean): void;
|
|
91
101
|
setSide(side: "front" | "double"): void;
|
|
92
102
|
/** Turn distance LOD on/off (off = full detail and edges everywhere). Only has an effect if the object was built with `lod` (default). */
|
|
@@ -95,8 +105,18 @@ export interface LdrObject {
|
|
|
95
105
|
getBox(target?: THREE.Box3): THREE.Box3;
|
|
96
106
|
dispose(): void;
|
|
97
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Build a three.js object for a flattened model using a parts pack.
|
|
110
|
+
* Instances whose part is not in the pack are skipped and listed in `stats.missing`.
|
|
111
|
+
*/
|
|
98
112
|
/**
|
|
99
113
|
* Build a three.js object for a flattened model using a parts pack.
|
|
100
114
|
* Instances whose part is not in the pack are skipped and listed in `stats.missing`.
|
|
101
115
|
*/
|
|
102
116
|
export declare function createLdrObject(instances: PartInstance[], pack: Pack, options?: LdrObjectOptions): LdrObject;
|
|
117
|
+
/**
|
|
118
|
+
* Progressive/async variant of `createLdrObject`: yields about every `sliceMs` (default 8) so the main thread stays responsive.
|
|
119
|
+
* Meshes land on `object` as batches finish; pass `onSlice` to render for a fast time-to-first-pixel.
|
|
120
|
+
* Final visuals and stats match the sync path (same generator).
|
|
121
|
+
*/
|
|
122
|
+
export declare function createLdrObjectAsync(instances: PartInstance[], pack: Pack, options?: LdrObjectOptions): Promise<LdrObject>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ldr",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
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",
|