bimatter-viewer-react 0.5.13 → 0.6.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/README.md +22 -0
- 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/index.d.ts +1 -0
- package/lib/index.js +1064 -1033
- package/lib/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,10 +150,16 @@ function App() {
|
|
|
150
150
|
await loader.loadModel(["/models/model.bmt"]);
|
|
151
151
|
await loader.loadModel(["/models/model.ifc"]);
|
|
152
152
|
await loader.loadModel(["/models/model.ifc"], { useIfcSpace: true });
|
|
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
|
|
@@ -531,6 +537,22 @@ if (viewer && firstLevel) {
|
|
|
531
537
|
}
|
|
532
538
|
```
|
|
533
539
|
|
|
540
|
+
## Performance Mode
|
|
541
|
+
|
|
542
|
+
Use `performanceMode` for heavy models or weaker GPUs:
|
|
543
|
+
|
|
544
|
+
```tsx
|
|
545
|
+
<Viewer modelUrls={["/models/model.bmt"]} performanceMode />
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
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.
|
|
549
|
+
|
|
550
|
+
You can also switch only the model material:
|
|
551
|
+
|
|
552
|
+
```tsx
|
|
553
|
+
<Viewer modelUrls={["/models/model.bmt"]} materialMode="performance" />
|
|
554
|
+
```
|
|
555
|
+
|
|
534
556
|
## Stats And Profiling
|
|
535
557
|
|
|
536
558
|
Enable FPS stats and console timing logs:
|
|
@@ -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
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Viewer } from "./Viewer";
|
|
2
2
|
export type { ViewerModelsData, ViewerProps } from "./Viewer";
|
|
3
|
+
export type { ViewerMaterialMode } from "./types";
|
|
3
4
|
export type { ViewerApi, ViewerCameraApi, ViewerCameraGetIntersection, ViewerClippingApi, ViewerColorsApi, ViewerBmtConverterOptions, ViewerConverterApi, ViewerDimensionsApi, ViewerGeometryUtilsApi, ViewerSelection, ViewerSelectorApi, ViewerUtilsApi, } from "./api/ViewerApi";
|
|
4
5
|
export type { ViewerModelLevel, ViewerModelLevelsByModel, ViewerPropertiesApi, ViewerPropertiesExcelOptions, } from "./api/ViewerPropertiesApi";
|
|
5
6
|
export { BMTLoader } from "./Loaders/BmtLoader";
|