bimatter-viewer-react 0.11.12 → 1.0.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/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 +5 -4
- package/lib/SelectableMesh.d.ts +7 -2
- package/lib/ViewerComponents/ViewerScene.d.ts +2 -2
- package/lib/WebGpuSelectableMesh.d.ts +1 -1
- 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 +3061 -2534
- package/lib/sharedMeshMaterials.d.ts +24 -0
- package/lib/utils/ClippingUtils/ClippingUtils.d.ts +6 -0
- 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/WorkerErrors.d.ts +6 -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,24 @@
|
|
|
1
|
+
import type { DataTexture, Material, Plane } from "three";
|
|
2
|
+
import type { BmtMaterialData } from "./Loaders/BmtLoader";
|
|
3
|
+
import type { ViewerMaterialMode } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Materials shared by the meshes of one model that look the same. The cache
|
|
6
|
+
* must stay per model: preselection writes the element id into the material
|
|
7
|
+
* uniforms of every mesh of the preselected model, so a material shared
|
|
8
|
+
* between models would highlight the same id in all of them.
|
|
9
|
+
*
|
|
10
|
+
* Keys include everything a material is built from, so a cache can outlive
|
|
11
|
+
* palette or renderer changes without handing out a mismatched material.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SharedMeshMaterials {
|
|
14
|
+
private readonly materials;
|
|
15
|
+
get<T extends Material>(key: string, create: () => T): T;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare function getSharedMeshMaterialKey(renderer: "webgl" | "webgpu", colorPaletteTexture: DataTexture, material: BmtMaterialData, materialMode: ViewerMaterialMode, useDoubleSideMaterial: boolean): string;
|
|
19
|
+
/**
|
|
20
|
+
* Gives a model material the current section planes before it is rendered,
|
|
21
|
+
* so a mesh added while clipping is active never shows up unclipped for a
|
|
22
|
+
* frame. It also compiles the shader with the planes right away.
|
|
23
|
+
*/
|
|
24
|
+
export declare function applyMaterialClippingPlanes(material: Material, planes: Plane[] | undefined): void;
|
|
@@ -112,6 +112,11 @@ export declare class ClippingUtils {
|
|
|
112
112
|
private getSelectedWorldBox;
|
|
113
113
|
setControlsEnabled(enabled: boolean): void;
|
|
114
114
|
setSelectionInteractionDisabled(disabled: boolean): void;
|
|
115
|
+
/**
|
|
116
|
+
* The plane array model materials reference: the live planes while
|
|
117
|
+
* clipping is active, so dragging a plane needs no material update.
|
|
118
|
+
*/
|
|
119
|
+
getMaterialPlanes(): Plane[];
|
|
115
120
|
updateMaterials(): void;
|
|
116
121
|
setActive(active: boolean): void;
|
|
117
122
|
toggle(): void;
|
|
@@ -140,6 +145,7 @@ export declare function useClippingUtils(modelRef: ViewerModelRef, controlRef: V
|
|
|
140
145
|
getPlanVisualObjects: () => Object3D[];
|
|
141
146
|
setCapsCameraMotionActive: (active: boolean) => void;
|
|
142
147
|
setEdgesCameraMotionActive: (active: boolean) => void;
|
|
148
|
+
getMaterialPlanes: () => Plane[];
|
|
143
149
|
setCapsPreselection: (preselection: ClippingPreselection) => void;
|
|
144
150
|
syncWithModel: () => void;
|
|
145
151
|
};
|
|
@@ -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,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns a worker "error" event into an Error with whatever the browser told
|
|
3
|
+
* us. Errors thrown inside a running task come back as messages instead, so
|
|
4
|
+
* an event without a message usually means the worker script never started.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createWorkerEventError(workerName: string, event: ErrorEvent): Error;
|
|
@@ -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;
|