bimatter-viewer-react 0.11.12 → 1.0.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/lib/{IFCLoader-5oUOfYbb.js → IFCLoader-CIjIkMG4.js} +59 -34
- package/lib/Loaders/BmtLoader.d.ts +40 -0
- package/lib/Loaders/IFCLoader/IFCLoader.d.ts +3 -0
- package/lib/Model.d.ts +2 -2
- package/lib/ViewerComponents/ViewerScene.d.ts +2 -2
- package/lib/assets/BMTWorker-B5pcLJyM.js +1 -0
- package/lib/assets/{BmtConverterWorker-DpSn1XL3.js → BmtConverterWorker-D1SGs9qm.js} +1 -1
- package/lib/assets/BvhWorker-BIP1xLJx.js +1 -0
- package/lib/assets/IFCWorker-DeYf8nwm.js +6 -0
- package/lib/index.js +2681 -2226
- package/lib/utils/GeometryUtils/meshBoundsTree.d.ts +23 -0
- package/lib/workers/BMTWorker.d.ts +2 -0
- package/lib/workers/BvhWorker.d.ts +12 -0
- package/lib/workers/BvhWorkerPool.d.ts +16 -0
- package/lib/workers/IFCWorker.d.ts +2 -0
- package/lib/workers/ProgressUtils.d.ts +4 -0
- package/lib/workers/WorkerGeometrySplit.d.ts +23 -0
- package/lib/workers/WorkerMeshBvh.d.ts +2 -2
- package/package.json +1 -1
- package/lib/assets/BMTWorker-B6cln5F6.js +0 -1
- package/lib/assets/IFCWorker-CzO3G2wD.js +0 -6
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BufferGeometry } from "three";
|
|
2
|
+
import { MeshBVH } from "three-mesh-bvh";
|
|
3
|
+
import type { BmtGeomData } from "../../Loaders/BmtLoader";
|
|
4
|
+
/**
|
|
5
|
+
* Geometry streamed in chunks from a loader worker is revealed with the
|
|
6
|
+
* progressive draw range, the same as before the BVH moved to the pool.
|
|
7
|
+
*/
|
|
8
|
+
export declare function shouldUseProgressiveDrawRange(data: BmtGeomData): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* BVH built for the geometry's original index, or null when it is not ready
|
|
11
|
+
* yet or was built for another index (e.g. after removeByIds).
|
|
12
|
+
*
|
|
13
|
+
* Indexes are compared by length: visibility tools only ever shorten them,
|
|
14
|
+
* while the WebGPU backend may replace an odd-length Uint16 index with an
|
|
15
|
+
* equal Uint32 copy.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getMeshOriginalBoundsTree(geometry: BufferGeometry, index: ArrayLike<number>): MeshBVH | null;
|
|
18
|
+
/**
|
|
19
|
+
* Attaches a MeshBVH to the mesh geometry without blocking the main thread:
|
|
20
|
+
* a worker-built tree is deserialized, otherwise the build runs in the BVH
|
|
21
|
+
* worker pool. Returns a cancel function for unmounts.
|
|
22
|
+
*/
|
|
23
|
+
export declare function attachMeshBoundsTree(data: BmtGeomData, geometry: BufferGeometry, onAttached: () => void): () => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type BmtGeomData, type BmtModelData } from "../Loaders/BmtLoader";
|
|
2
2
|
import { type WorkerProgressEvent } from "./ProgressUtils";
|
|
3
|
+
import { type WorkerBoundsTreeSource } from "./WorkerGeometrySplit";
|
|
3
4
|
export type BmtWorkerSource = {
|
|
4
5
|
buffer: ArrayBuffer;
|
|
5
6
|
kind: "buffer";
|
|
@@ -40,6 +41,7 @@ export type BmtWorkerResponse = {
|
|
|
40
41
|
taskId: string;
|
|
41
42
|
type: "error";
|
|
42
43
|
} | {
|
|
44
|
+
bvhSource?: WorkerBoundsTreeSource;
|
|
43
45
|
chunk: BmtWorkerGeometryChunk;
|
|
44
46
|
taskId: string;
|
|
45
47
|
type: "chunk";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BmtIndexArray, BmtSerializedMeshBVH } from "../Loaders/BmtLoader";
|
|
2
|
+
export type BvhWorkerRequest = {
|
|
3
|
+
id: number;
|
|
4
|
+
ind: BmtIndexArray;
|
|
5
|
+
pos: Float32Array;
|
|
6
|
+
type: "build-bvh";
|
|
7
|
+
};
|
|
8
|
+
export type BvhWorkerResponse = {
|
|
9
|
+
boundsTree: BmtSerializedMeshBVH | null;
|
|
10
|
+
id: number;
|
|
11
|
+
type: "bvh";
|
|
12
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BmtGeomData, BmtIndexArray, BmtSerializedMeshBVH } from "../Loaders/BmtLoader";
|
|
2
|
+
/**
|
|
3
|
+
* Builds a serialized indirect MeshBVH in a background worker. The passed
|
|
4
|
+
* arrays are transferred, so callers must hand over copies they do not need.
|
|
5
|
+
* Resolves with null when workers are unavailable or the build failed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function requestWorkerBoundsTree(pos: Float32Array, ind: BmtIndexArray): Promise<BmtSerializedMeshBVH | null>;
|
|
8
|
+
export declare function setPendingBoundsTree(geometry: BmtGeomData, boundsTree: Promise<BmtSerializedMeshBVH | null>): Promise<BmtSerializedMeshBVH | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Registers geometry streamed from a loader worker together with its BVH
|
|
11
|
+
* build. The serialized tree is stored on the geometry like the worker used
|
|
12
|
+
* to send it, so collected models keep it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerWorkerGeometryBoundsTree(geometry: BmtGeomData, boundsTree: Promise<BmtSerializedMeshBVH | null>): Promise<BmtSerializedMeshBVH | null>;
|
|
15
|
+
export declare function isWorkerStreamedGeometry(geometry: BmtGeomData): boolean;
|
|
16
|
+
export declare function getPendingBoundsTree(geometry: BmtGeomData): Promise<BmtSerializedMeshBVH | null> | null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BmtGeomData, BmtModelData } from "../Loaders/BmtLoader";
|
|
2
2
|
import { type IfcCoordinationMatrixSource } from "../Loaders/IFCLoader/IFCLoader";
|
|
3
3
|
import { type WorkerProgressEvent } from "./ProgressUtils";
|
|
4
|
+
import { type WorkerBoundsTreeSource } from "./WorkerGeometrySplit";
|
|
4
5
|
export type IfcWorkerSource = {
|
|
5
6
|
kind: "buffer";
|
|
6
7
|
buffer: ArrayBuffer;
|
|
@@ -54,6 +55,7 @@ export type IfcWorkerResponse = {
|
|
|
54
55
|
taskId: string;
|
|
55
56
|
type: "complete";
|
|
56
57
|
} | {
|
|
58
|
+
bvhSource?: WorkerBoundsTreeSource;
|
|
57
59
|
chunk: IfcWorkerGeometryChunk;
|
|
58
60
|
taskId: string;
|
|
59
61
|
type: "chunk";
|
|
@@ -20,6 +20,10 @@ export declare class WorkerProgressUtils {
|
|
|
20
20
|
private readonly emit;
|
|
21
21
|
private readonly taskId;
|
|
22
22
|
private readonly totalModels;
|
|
23
|
+
private lastEmitTime;
|
|
24
|
+
private lastMessage;
|
|
25
|
+
private lastModelIndex;
|
|
26
|
+
private lastPhase;
|
|
23
27
|
constructor(options: WorkerProgressOptions);
|
|
24
28
|
emitModelProgress(modelIndex: number, modelName: string | undefined, phase: WorkerProgressPhase, modelProgress: number, data?: Pick<WorkerProgressEvent, "loaded" | "message" | "total">): void;
|
|
25
29
|
emitError(message: string): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BmtGeomData, BmtIndexArray } from "../Loaders/BmtLoader";
|
|
2
|
+
export declare const WORKER_CHUNK_MAX_VERTICES = 262144;
|
|
3
|
+
export type WorkerBoundsTreeSource = {
|
|
4
|
+
ind: BmtIndexArray;
|
|
5
|
+
pos: Float32Array;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Splits a large mesh into parts of about maxVertices at element boundaries.
|
|
9
|
+
* Requires elements to be stored as contiguous vertex runs (as the BMT and
|
|
10
|
+
* IFC builders write them); otherwise the geometry is returned as is.
|
|
11
|
+
*/
|
|
12
|
+
export declare function splitGeometryByElements(geometry: BmtGeomData, maxVertices?: number): BmtGeomData[];
|
|
13
|
+
/**
|
|
14
|
+
* Keeps geometry IDs unique within a model. Split parts and duplicated IDs get
|
|
15
|
+
* new IDs from the top of the uint32 range, which BMT export writes as is.
|
|
16
|
+
*/
|
|
17
|
+
export declare class WorkerGeometryIDs {
|
|
18
|
+
private nextGeometryID;
|
|
19
|
+
private readonly usedGeometryIDs;
|
|
20
|
+
allocate(preferredGeometryID?: number): number;
|
|
21
|
+
}
|
|
22
|
+
export declare function createBoundsTreeSource(geometry: BmtGeomData): WorkerBoundsTreeSource;
|
|
23
|
+
export declare function collectGeometryTransferables(geometry: BmtGeomData, buffers: Set<ArrayBuffer>): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
1
|
+
import type { BmtIndexArray, BmtSerializedMeshBVH } from "../Loaders/BmtLoader";
|
|
2
|
+
export declare function buildSerializedBoundsTree(positions: Float32Array, indices: BmtIndexArray): BmtSerializedMeshBVH | null;
|
|
3
3
|
export declare function collectBoundsTreeTransferables(boundsTree: BmtSerializedMeshBVH | undefined, buffers: Set<ArrayBuffer>): void;
|