bimatter-viewer-react 0.5.13 → 0.6.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/README.md +26 -6
- package/lib/{IFCLoader-RIJas-B5.js → IFCLoader-Cjkb3xMA.js} +1 -1
- package/lib/Loaders/BmtLoader.d.ts +6 -0
- package/lib/Model.d.ts +3 -1
- package/lib/SelectableMesh.d.ts +4 -1
- package/lib/Viewer.d.ts +3 -0
- package/lib/api/loader.d.ts +4 -0
- package/lib/assets/{BmtConverterWorker-S83_KT6j.js → BmtConverterWorker-BHhPlty_.js} +1 -1
- package/lib/assets/{IFCWorker-GKoow6yV.js → IFCWorker-DipGoUKy.js} +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1081 -1050
- package/lib/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,13 +111,13 @@ You can also load mixed model lists:
|
|
|
111
111
|
/>
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
IFC spaces are
|
|
114
|
+
IFC spaces are loaded by default when the IFC contains room geometry, but they are hidden in the viewer by default. Disable loading them when room volumes are not needed:
|
|
115
115
|
|
|
116
116
|
```ts
|
|
117
117
|
import { loader } from "bimatter-viewer-react";
|
|
118
118
|
|
|
119
119
|
await loader.loadModel(["/models/architecture.ifc"], {
|
|
120
|
-
useIfcSpace:
|
|
120
|
+
useIfcSpace: false,
|
|
121
121
|
});
|
|
122
122
|
```
|
|
123
123
|
|
|
@@ -149,17 +149,22 @@ function App() {
|
|
|
149
149
|
```ts
|
|
150
150
|
await loader.loadModel(["/models/model.bmt"]);
|
|
151
151
|
await loader.loadModel(["/models/model.ifc"]);
|
|
152
|
-
await loader.loadModel(["/models/model.ifc"], { useIfcSpace:
|
|
152
|
+
await loader.loadModel(["/models/model.ifc"], { useIfcSpace: false });
|
|
153
|
+
await loader.loadModel(["/models/model.bmt"], { materialMode: "performance" });
|
|
154
|
+
await loader.loadModel(["/models/model.bmt"], { useDoubleSideMaterial: true });
|
|
153
155
|
await loader.loadModel(["/models/model.bmt", "/models/model.ifc"]);
|
|
154
156
|
await loader.loadModel(files);
|
|
155
157
|
```
|
|
156
158
|
|
|
159
|
+
`materialMode: "performance"` uses a cheaper unlit material. Use `"quality"` or omit it for the default lit material.
|
|
160
|
+
|
|
161
|
+
`useDoubleSideMaterial` is disabled by default for better FPS. Enable it only when the model needs back faces to be visible.
|
|
162
|
+
|
|
157
163
|
Use `useWorker` to parse BMT and IFC models outside the main thread:
|
|
158
164
|
|
|
159
165
|
```ts
|
|
160
166
|
const models = await loader.loadModel(["/models/model.ifc"], {
|
|
161
167
|
chunk: 200,
|
|
162
|
-
useIfcSpace: true,
|
|
163
168
|
useWorker: true,
|
|
164
169
|
onProgress: (event) => {
|
|
165
170
|
console.log(event.phase, Math.round(event.progress * 100));
|
|
@@ -412,12 +417,11 @@ await viewerRef.current?.converter.convertIfcFileToBmt(files, {
|
|
|
412
417
|
fileName: "converted_ifc",
|
|
413
418
|
useIfcColors: true,
|
|
414
419
|
useIfcElementAssembly: true,
|
|
415
|
-
useIfcSpace: true,
|
|
416
420
|
useMinVersion: true,
|
|
417
421
|
});
|
|
418
422
|
```
|
|
419
423
|
|
|
420
|
-
`useIfcColors`, `useIfcElementAssembly`, and `useIfcSpace` are used when converting IFC files directly. They do not change already loaded model data in `convertToBmt`. `useIfcSpace` loads IFCSPACE geometry as a separate almost-transparent gray mesh when the IFC contains room geometry.
|
|
424
|
+
`useIfcColors`, `useIfcElementAssembly`, and `useIfcSpace` are used when converting IFC files directly. They do not change already loaded model data in `convertToBmt`. `useIfcSpace` is enabled by default and loads IFCSPACE geometry as a separate almost-transparent gray mesh when the IFC contains room geometry.
|
|
421
425
|
|
|
422
426
|
## Controlled Selection
|
|
423
427
|
|
|
@@ -531,6 +535,22 @@ if (viewer && firstLevel) {
|
|
|
531
535
|
}
|
|
532
536
|
```
|
|
533
537
|
|
|
538
|
+
## Performance Mode
|
|
539
|
+
|
|
540
|
+
Use `performanceMode` for heavy models or weaker GPUs:
|
|
541
|
+
|
|
542
|
+
```tsx
|
|
543
|
+
<Viewer modelUrls={["/models/model.bmt"]} performanceMode />
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
It caps canvas DPR at `1`, disables antialiasing, asks the browser for a high-performance GPU, and uses `materialMode="performance"` unless another material mode is passed.
|
|
547
|
+
|
|
548
|
+
You can also switch only the model material:
|
|
549
|
+
|
|
550
|
+
```tsx
|
|
551
|
+
<Viewer modelUrls={["/models/model.bmt"]} materialMode="performance" />
|
|
552
|
+
```
|
|
553
|
+
|
|
534
554
|
## Stats And Profiling
|
|
535
555
|
|
|
536
556
|
Enable FPS stats and console timing logs:
|
|
@@ -191720,7 +191720,7 @@ var __ = class {
|
|
|
191720
191720
|
}, y_ = class {
|
|
191721
191721
|
useIfcElemetAssembly = !1;
|
|
191722
191722
|
useIfcColors = !1;
|
|
191723
|
-
useIfcSpace = !
|
|
191723
|
+
useIfcSpace = !0;
|
|
191724
191724
|
coordinationMatrix = null;
|
|
191725
191725
|
parser;
|
|
191726
191726
|
propertySerializer;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import pako from "pako";
|
|
2
2
|
import type { ModelGridsData } from "../utils/ModelGrids";
|
|
3
|
+
import type { ViewerMaterialMode } from "../types";
|
|
3
4
|
export type BmtIndexArray = Uint16Array | Uint32Array;
|
|
4
5
|
export interface BmtMaterialData {
|
|
5
6
|
r: number;
|
|
@@ -51,12 +52,17 @@ export type BmtModelStructureNode = {
|
|
|
51
52
|
};
|
|
52
53
|
export type BmtModelStructure = BmtModelStructureNode | BmtModelStructureNode[] | Record<string, BmtModelStructureNode>;
|
|
53
54
|
export type BmtModelGeometryData = Record<number, BmtGeomData>;
|
|
55
|
+
export type BmtModelRenderSettings = {
|
|
56
|
+
materialMode?: ViewerMaterialMode;
|
|
57
|
+
useDoubleSideMaterial?: boolean;
|
|
58
|
+
};
|
|
54
59
|
export interface BmtModelData {
|
|
55
60
|
coordinationMatrix?: string;
|
|
56
61
|
data: BmtModelGeometryData;
|
|
57
62
|
grids?: ModelGridsData;
|
|
58
63
|
name?: string;
|
|
59
64
|
props: BmtModelProps;
|
|
65
|
+
renderSettings?: BmtModelRenderSettings;
|
|
60
66
|
structure: BmtModelStructure;
|
|
61
67
|
}
|
|
62
68
|
export type BmtGeometryChunkData = {
|
package/lib/Model.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { BmtModelData } from "./Loaders/BmtLoader";
|
|
2
2
|
import { Matrix4, type DataTexture } from "three";
|
|
3
|
+
import type { ViewerMaterialMode } from "./types";
|
|
3
4
|
type ModelProps = {
|
|
4
5
|
colorPaletteTexture: DataTexture;
|
|
5
6
|
coordinationMatrix?: Matrix4 | null;
|
|
6
7
|
modelID: number;
|
|
7
8
|
data: BmtModelData;
|
|
9
|
+
materialMode?: ViewerMaterialMode;
|
|
8
10
|
};
|
|
9
11
|
export declare function parseModelMatrix(matrix?: string): Matrix4 | null;
|
|
10
12
|
export declare function getModelCoordinationMatrix(data: BmtModelData): Matrix4 | null;
|
|
11
13
|
export declare function getModelCoordinationMatrixSource(data: BmtModelData): string | undefined;
|
|
12
|
-
declare function Model({ colorPaletteTexture, coordinationMatrix, modelID, data, }: ModelProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function Model({ colorPaletteTexture, coordinationMatrix, modelID, data, materialMode: materialModeOverride, }: ModelProps): import("react/jsx-runtime").JSX.Element;
|
|
13
15
|
declare const _default: import("react").MemoExoticComponent<typeof Model>;
|
|
14
16
|
export default _default;
|
package/lib/SelectableMesh.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Matrix4, type DataTexture } from "three";
|
|
3
3
|
import type { BmtGeomData, BmtMaterialData } from "./Loaders/BmtLoader";
|
|
4
|
+
import type { ViewerMaterialMode } from "./types";
|
|
4
5
|
type SelectableMeshProps = {
|
|
5
6
|
colorPaletteTexture: DataTexture;
|
|
6
7
|
data: BmtGeomData;
|
|
7
8
|
isIfcSpace?: boolean;
|
|
8
9
|
material: BmtMaterialData;
|
|
10
|
+
materialMode?: ViewerMaterialMode;
|
|
9
11
|
meshMatrix: Matrix4;
|
|
12
|
+
useDoubleSideMaterial?: boolean;
|
|
10
13
|
};
|
|
11
|
-
export declare const SelectableMesh: React.MemoExoticComponent<({ colorPaletteTexture, material, data, isIfcSpace, meshMatrix, }: SelectableMeshProps) => import("react/jsx-runtime").JSX.Element>;
|
|
14
|
+
export declare const SelectableMesh: React.MemoExoticComponent<({ colorPaletteTexture, material, materialMode, data, isIfcSpace, meshMatrix, useDoubleSideMaterial, }: SelectableMeshProps) => import("react/jsx-runtime").JSX.Element>;
|
|
12
15
|
export {};
|
package/lib/Viewer.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ComponentProps } from "react";
|
|
2
2
|
import type { BmtModelData } from "./Loaders/BmtLoader";
|
|
3
3
|
import { Canvas } from "@react-three/fiber";
|
|
4
|
+
import type { ViewerMaterialMode } from "./types";
|
|
4
5
|
import { type ViewerApi, type ViewerSelection } from "./api/ViewerApi";
|
|
5
6
|
import { type ViewerModelSource } from "./api/loader";
|
|
6
7
|
type ModelsData = Record<number, BmtModelData>;
|
|
@@ -10,11 +11,13 @@ export type ViewerProps = {
|
|
|
10
11
|
camera?: ComponentProps<typeof Canvas>["camera"];
|
|
11
12
|
dpr?: ComponentProps<typeof Canvas>["dpr"];
|
|
12
13
|
defaultSelected?: ViewerSelection;
|
|
14
|
+
materialMode?: ViewerMaterialMode;
|
|
13
15
|
modelUrls?: string[];
|
|
14
16
|
modelSources?: ViewerModelSource[];
|
|
15
17
|
modelsData?: ModelsData;
|
|
16
18
|
onReady?: (api: ViewerApi) => void;
|
|
17
19
|
onSelectedChange?: (selected: ViewerSelection) => void;
|
|
20
|
+
performanceMode?: boolean;
|
|
18
21
|
selected?: ViewerSelection;
|
|
19
22
|
showNavCube?: boolean;
|
|
20
23
|
showStats?: boolean;
|
package/lib/api/loader.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type BmtModelData } from "../Loaders/BmtLoader";
|
|
2
2
|
import { type BmtWorkerGeometryChunk, type IfcWorkerGeometryChunk, type WorkerProgressEvent } from "../workers";
|
|
3
|
+
import type { ViewerMaterialMode } from "../types";
|
|
3
4
|
export type ViewerModelSource = string | File;
|
|
4
5
|
export type ViewerLoadedModels = Record<number, BmtModelData>;
|
|
5
6
|
export type ViewerLoaderWorkerChunk = (BmtWorkerGeometryChunk | IfcWorkerGeometryChunk) & {
|
|
@@ -8,10 +9,12 @@ export type ViewerLoaderWorkerChunk = (BmtWorkerGeometryChunk | IfcWorkerGeometr
|
|
|
8
9
|
export type ViewerLoadModelOptions = {
|
|
9
10
|
chunk?: number;
|
|
10
11
|
collectWorkerChunks?: boolean;
|
|
12
|
+
materialMode?: ViewerMaterialMode;
|
|
11
13
|
maxMeshBytes?: number;
|
|
12
14
|
onChunk?: (chunk: ViewerLoaderWorkerChunk) => void;
|
|
13
15
|
onProgress?: (progress: WorkerProgressEvent) => void;
|
|
14
16
|
streamGeometryChunks?: boolean;
|
|
17
|
+
useDoubleSideMaterial?: boolean;
|
|
15
18
|
useIfcSpace?: boolean;
|
|
16
19
|
useWorker?: boolean;
|
|
17
20
|
wasmPath?: string;
|
|
@@ -34,6 +37,7 @@ declare class ViewerLoaderApi {
|
|
|
34
37
|
private loadIfcModelInWorker;
|
|
35
38
|
private loadBmtModelInWorker;
|
|
36
39
|
private resetCoordinationMatrixState;
|
|
40
|
+
private applyRenderSettings;
|
|
37
41
|
resetCoordinationMatrix(): void;
|
|
38
42
|
loadModel(sources: ViewerModelSource | ViewerModelSource[], options?: ViewerLoadModelOptions): Promise<ViewerLoadedModels>;
|
|
39
43
|
}
|