ldr 0.14.0 → 0.16.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 +211 -93
- package/dist/node/index.js +218 -100
- package/dist/render.d.ts +22 -21
- package/dist/scene.d.ts +23 -0
- package/package.json +1 -1
package/dist/render.d.ts
CHANGED
|
@@ -70,29 +70,30 @@ 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
|
-
trimmed: {
|
|
90
|
-
studs: boolean;
|
|
91
|
-
under: boolean;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
73
|
/**
|
|
95
74
|
* Builds (and caches on the pack) the shared BufferGeometries `buildLdrScene` will use, in time slices of about `sliceMs` that yield
|
|
96
75
|
* to the event loop, until done or `stop()` returns true. Lets the main thread do this useful work while the load worker culls.
|
|
97
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 while mid-build paints are active (ms). Default 8. */
|
|
81
|
+
sliceMs?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Soft cap after mid-build paints stop (onSlice returned false, or no onSlice). Default max(sliceMs, 24).
|
|
84
|
+
* Larger slices cut yield/timer overhead on the remaining build without changing the sync path.
|
|
85
|
+
*/
|
|
86
|
+
postPaintSliceMs?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Called after each yield while paints are enabled; live root already holds finished batches (paint for TTFP).
|
|
89
|
+
* Return `false` to stop further onSlice calls (keeps yielding with postPaintSliceMs) — use after first frame.
|
|
90
|
+
*/
|
|
91
|
+
onSlice?: (root: THREE.Object3D) => void | boolean | Promise<void | boolean>;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Same scene as buildLdrScene, but yields to the event loop about every sliceMs so the main thread stays responsive
|
|
95
|
+
* and onSlice can render partial geometry for a fast time-to-first-pixel. Meshes are added to root as they are built.
|
|
96
|
+
* After onSlice returns false (TTFP done), slices coarsen to postPaintSliceMs and paints stop — cuts total loadMs.
|
|
97
|
+
*/
|
|
98
|
+
export declare function buildLdrSceneAsync(insts: Inst[], pack: Pack, P: LdrParams, color: (c: string) => THREE.Color, mark: (k: string) => void, opts?: BuildLdrSceneAsyncOptions): Promise<any>;
|
|
98
99
|
export declare function warmPackGeometry(pack: Pack, stop?: () => boolean, sliceMs?: number): Promise<void>;
|
package/dist/scene.d.ts
CHANGED
|
@@ -51,6 +51,15 @@ 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 while mid-build paints are active, ms. Default 8. */
|
|
55
|
+
sliceMs?: number;
|
|
56
|
+
/** Progressive build: soft cap after paints stop (onSlice returned false / no onSlice). Default max(sliceMs, 24). */
|
|
57
|
+
postPaintSliceMs?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Progressive build: called after each yield while paints are enabled; live object holds finished batches — render for TTFP.
|
|
60
|
+
* Return `false` to stop further onSlice calls (keeps yielding with postPaintSliceMs).
|
|
61
|
+
*/
|
|
62
|
+
onSlice?: () => void | boolean | Promise<void | boolean>;
|
|
54
63
|
}
|
|
55
64
|
export interface LdrStats {
|
|
56
65
|
instances: number;
|
|
@@ -61,6 +70,10 @@ export interface LdrStats {
|
|
|
61
70
|
undersTotal: number;
|
|
62
71
|
undersHidden: number;
|
|
63
72
|
buildMs: number;
|
|
73
|
+
/** Progressive build: longest contiguous main-thread slice (ms). */
|
|
74
|
+
longestSliceMs?: number;
|
|
75
|
+
/** Progressive build: number of yields during scene construction. */
|
|
76
|
+
buildYields?: number;
|
|
64
77
|
/** Conditional-line batches (draw calls) created; 0 for packs without conditional lines. */
|
|
65
78
|
condBatches?: number;
|
|
66
79
|
/** Textured batches (one per part x texture) and distinct textures; 0 for packs without textures. */
|
|
@@ -97,8 +110,18 @@ export interface LdrObject {
|
|
|
97
110
|
getBox(target?: THREE.Box3): THREE.Box3;
|
|
98
111
|
dispose(): void;
|
|
99
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Build a three.js object for a flattened model using a parts pack.
|
|
115
|
+
* Instances whose part is not in the pack are skipped and listed in `stats.missing`.
|
|
116
|
+
*/
|
|
100
117
|
/**
|
|
101
118
|
* Build a three.js object for a flattened model using a parts pack.
|
|
102
119
|
* Instances whose part is not in the pack are skipped and listed in `stats.missing`.
|
|
103
120
|
*/
|
|
104
121
|
export declare function createLdrObject(instances: PartInstance[], pack: Pack, options?: LdrObjectOptions): LdrObject;
|
|
122
|
+
/**
|
|
123
|
+
* Progressive/async variant of `createLdrObject`: yields about every `sliceMs` (default 8) so the main thread stays responsive.
|
|
124
|
+
* Meshes land on `object` as batches finish; pass `onSlice` to render for a fast time-to-first-pixel.
|
|
125
|
+
* Final visuals and stats match the sync path (same generator).
|
|
126
|
+
*/
|
|
127
|
+
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.16.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",
|