bimatter-viewer-react 0.2.0 → 0.4.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 +151 -1
- package/lib/Camera/useCameraUtils.d.ts +28 -0
- package/lib/Loaders/BmtConverter.d.ts +95 -0
- package/lib/Loaders/BmtLoader.d.ts +3 -1
- package/lib/Loaders/IFCLoader/IFCLoader.d.ts +4 -1
- package/lib/Loaders/IFCLoader/IfcGrid.d.ts +1 -1
- package/lib/SelectableMesh.d.ts +2 -1
- package/lib/Selector/SelectionBox.d.ts +3 -2
- package/lib/Selector/useSelector.d.ts +2 -2
- package/lib/api/ViewerApi.d.ts +29 -0
- package/lib/api/loader.d.ts +7 -1
- package/lib/index.d.ts +8 -5
- package/lib/index.js +17205 -15349
- package/lib/store/ViewerStore.d.ts +14 -0
- package/lib/utils/ClippingUtils/ClippingEdges.d.ts +23 -0
- package/lib/utils/ClippingUtils/ClippingUtils.d.ts +87 -0
- package/lib/utils/ClippingUtils/PlaneHelper.d.ts +54 -0
- package/lib/utils/ClippingUtils/index.d.ts +2 -0
- package/lib/{Colors → utils/ColorsUtils}/useElementColors.d.ts +1 -0
- package/lib/utils/DimentionsUtils/DimentionLine.d.ts +59 -0
- package/lib/utils/DimentionsUtils/DimentionsUtils.d.ts +97 -0
- package/lib/utils/DimentionsUtils/index.d.ts +2 -0
- package/lib/{GeometryUtils → utils/GeometryUtils}/useGeometryIndex.d.ts +3 -1
- package/lib/{GeometryUtils → utils/GeometryUtils}/useGeometryUtils.d.ts +3 -0
- package/lib/utils/Hotkeys/useHotkeysUtils.d.ts +1 -0
- package/lib/{NavigationCube → utils/NavigationCube}/NavigationCube.d.ts +1 -1
- package/package.json +2 -1
- package/lib/Hotkeys/useHotkeysUtils.d.ts +0 -2
- package/lib/ModelGrids copy/ModelGrids.d.ts +0 -61
- /package/lib/{ModelGrids → utils/ModelGrids}/ModelGrids.d.ts +0 -0
- /package/lib/{ModelGrids → utils/ModelGrids}/index.d.ts +0 -0
- /package/lib/{ModelGrids → utils/ModelGrids}/types.d.ts +0 -0
- /package/lib/{NavigationCube → utils/NavigationCube}/index.d.ts +0 -0
package/README.md
CHANGED
|
@@ -4,10 +4,12 @@ React viewer for Bimatter `.bmt` models and `.ifc` models.
|
|
|
4
4
|
|
|
5
5
|
All about us you can see on our website [Bimatter](https://bimatter.ru/)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[Demo viewer](https://rkaeplive.github.io/bimatter-viewer-react/)
|
|
8
8
|
|
|
9
9
|
[GitHub](https://github.com/rkaeplive/bimatter-viewer-react)
|
|
10
10
|
|
|
11
|
+
Vanila js viewer core: [bimatter-viewer](https://www.npmjs.com/package/bimatter-viewer?activeTab=code)
|
|
12
|
+
|
|
11
13
|
Write your issuse here: [GitHub](https://github.com/rkaeplive/bimatter-viewer-react/issues)
|
|
12
14
|
|
|
13
15
|
## License
|
|
@@ -107,6 +109,16 @@ You can also load mixed model lists:
|
|
|
107
109
|
/>
|
|
108
110
|
```
|
|
109
111
|
|
|
112
|
+
IFC spaces are disabled by default. Enable them per load when room volumes should be loaded as an almost-transparent gray mesh:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { loader } from "bimatter-viewer-react";
|
|
116
|
+
|
|
117
|
+
await loader.loadModel(["/models/architecture.ifc"], {
|
|
118
|
+
useIfcSpace: true,
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
110
122
|
## Loader API
|
|
111
123
|
|
|
112
124
|
You can load models yourself and pass parsed data to the viewer:
|
|
@@ -135,6 +147,7 @@ function App() {
|
|
|
135
147
|
```ts
|
|
136
148
|
await loader.loadModel(["/models/model.bmt"]);
|
|
137
149
|
await loader.loadModel(["/models/model.ifc"]);
|
|
150
|
+
await loader.loadModel(["/models/model.ifc"], { useIfcSpace: true });
|
|
138
151
|
await loader.loadModel(["/models/model.bmt", "/models/model.ifc"]);
|
|
139
152
|
await loader.loadModel(files);
|
|
140
153
|
```
|
|
@@ -193,10 +206,20 @@ function App() {
|
|
|
193
206
|
|
|
194
207
|
`I` - Isolate selected elements
|
|
195
208
|
|
|
209
|
+
### Clipping
|
|
210
|
+
|
|
211
|
+
`P` - Create clipping plane by model intersection
|
|
212
|
+
|
|
213
|
+
### Dimensions
|
|
214
|
+
|
|
215
|
+
`M` - Toggle dimension drawing mode
|
|
216
|
+
|
|
196
217
|
## Viewer API
|
|
197
218
|
|
|
198
219
|
```ts
|
|
199
220
|
viewerRef.current?.camera.fitCamera();
|
|
221
|
+
viewerRef.current?.camera.getIntersection();
|
|
222
|
+
viewerRef.current?.camera.getIntersection(true);
|
|
200
223
|
|
|
201
224
|
viewerRef.current?.geometryUtils.showAll();
|
|
202
225
|
viewerRef.current?.geometryUtils.showByIds([1, 2, 3]);
|
|
@@ -206,21 +229,63 @@ viewerRef.current?.geometryUtils.isolateByIds([1, 2, 3]);
|
|
|
206
229
|
viewerRef.current?.geometryUtils.isolateSelected();
|
|
207
230
|
viewerRef.current?.geometryUtils.resetIsolation();
|
|
208
231
|
viewerRef.current?.geometryUtils.getAllIds();
|
|
232
|
+
viewerRef.current?.geometryUtils.setIfcSpacesVisibility(false);
|
|
233
|
+
viewerRef.current?.geometryUtils.getIfcSpacesVisibility();
|
|
234
|
+
viewerRef.current?.geometryUtils.toggleIIfcSpacesVisibility();
|
|
209
235
|
|
|
210
236
|
viewerRef.current?.selector.setSelected(0, [10, 20], true);
|
|
211
237
|
viewerRef.current?.selector.addSelected(0, [30]);
|
|
212
238
|
viewerRef.current?.selector.removeSelected(0, [10]);
|
|
213
239
|
viewerRef.current?.selector.resetSelection();
|
|
214
240
|
viewerRef.current?.selector.getSelected();
|
|
241
|
+
viewerRef.current?.selector.setSelectionColor("#1194bd");
|
|
242
|
+
viewerRef.current?.selector.getSelectionColor();
|
|
243
|
+
viewerRef.current?.selector.setPreselectionColor("#68c6e3");
|
|
244
|
+
viewerRef.current?.selector.getPreselectionColor();
|
|
215
245
|
|
|
216
246
|
viewerRef.current?.colors.setColor(0, [10, 20], "#ff3355");
|
|
217
247
|
viewerRef.current?.colors.clearColor(0, [10]);
|
|
218
248
|
viewerRef.current?.colors.clearModelColors(0);
|
|
219
249
|
viewerRef.current?.colors.clearAllColors();
|
|
220
250
|
|
|
251
|
+
viewerRef.current?.converter.convertToBmt({
|
|
252
|
+
activeView: true,
|
|
253
|
+
useMinVersion: true,
|
|
254
|
+
});
|
|
255
|
+
viewerRef.current?.converter.convertIfcFileToBmt(files, {
|
|
256
|
+
useIfcColors: true,
|
|
257
|
+
useIfcElementAssembly: true,
|
|
258
|
+
useIfcSpace: true,
|
|
259
|
+
useMinVersion: true,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
viewerRef.current?.clipping.createPlane();
|
|
263
|
+
viewerRef.current?.clipping.createClippingRectangle();
|
|
264
|
+
viewerRef.current?.clipping.toggle();
|
|
265
|
+
viewerRef.current?.clipping.setActive(true);
|
|
266
|
+
viewerRef.current?.clipping.setEdgesActive(true);
|
|
267
|
+
viewerRef.current?.clipping.setHelpersActive(true);
|
|
268
|
+
viewerRef.current?.clipping.deleteAllPlanes();
|
|
269
|
+
|
|
270
|
+
viewerRef.current?.dimensions.setActive(true);
|
|
271
|
+
viewerRef.current?.dimensions.toggle();
|
|
272
|
+
viewerRef.current?.dimensions.cancelDrawing();
|
|
273
|
+
viewerRef.current?.dimensions.changeAxes();
|
|
274
|
+
viewerRef.current?.dimensions.delete();
|
|
275
|
+
viewerRef.current?.dimensions.deleteAll();
|
|
276
|
+
viewerRef.current?.dimensions.setUnit("mm");
|
|
277
|
+
viewerRef.current?.dimensions.setColor("#111827");
|
|
278
|
+
viewerRef.current?.dimensions.setWidth(1);
|
|
279
|
+
viewerRef.current?.dimensions.setSnapDistance(1);
|
|
280
|
+
viewerRef.current?.dimensions.setEndpointScaleFactor(0.015);
|
|
281
|
+
viewerRef.current?.dimensions.getDimensions();
|
|
282
|
+
|
|
221
283
|
viewerRef.current?.properties.getModelProps();
|
|
222
284
|
viewerRef.current?.properties.getModelStructure();
|
|
223
285
|
viewerRef.current?.utils.getUserDevice();
|
|
286
|
+
viewerRef.current?.utils.getDefaultHotkeysEnabled();
|
|
287
|
+
viewerRef.current?.utils.setDefaultHotkeysEnabled(false);
|
|
288
|
+
viewerRef.current?.utils.toggleDefaultHotkeys();
|
|
224
289
|
viewerRef.current?.utils.getShowStats();
|
|
225
290
|
viewerRef.current?.utils.setShowStats(true);
|
|
226
291
|
viewerRef.current?.utils.getShowNavCube();
|
|
@@ -272,6 +337,8 @@ function App() {
|
|
|
272
337
|
}
|
|
273
338
|
```
|
|
274
339
|
|
|
340
|
+
IFC space visibility is a separate mesh-level layer. When spaces are disabled through `setIfcSpacesVisibility(false)`, `showAll()` does not show them again; use `setIfcSpacesVisibility(true)` or `toggleIIfcSpacesVisibility()` for that.
|
|
341
|
+
|
|
275
342
|
## Colorize Elements
|
|
276
343
|
|
|
277
344
|
Use `viewerRef.current.colors` to apply temporary color overrides to model elements. The color is applied by `modelID` and element ids:
|
|
@@ -320,6 +387,89 @@ function App() {
|
|
|
320
387
|
}
|
|
321
388
|
```
|
|
322
389
|
|
|
390
|
+
## Convert To BMT
|
|
391
|
+
|
|
392
|
+
Use `viewerRef.current.converter` to export loaded models to the BMT format. With `activeView: true`, the converter uses the current viewer state and exports only visible elements.
|
|
393
|
+
|
|
394
|
+
```tsx
|
|
395
|
+
import { useRef } from "react";
|
|
396
|
+
import { Viewer, type ViewerApi } from "bimatter-viewer-react";
|
|
397
|
+
|
|
398
|
+
function downloadFiles(files: { blob: Blob; name: string }[]) {
|
|
399
|
+
files.forEach((file) => {
|
|
400
|
+
const url = URL.createObjectURL(file.blob);
|
|
401
|
+
const link = document.createElement("a");
|
|
402
|
+
|
|
403
|
+
link.href = url;
|
|
404
|
+
link.download = file.name;
|
|
405
|
+
link.click();
|
|
406
|
+
URL.revokeObjectURL(url);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function App() {
|
|
411
|
+
const viewerRef = useRef<ViewerApi>(null);
|
|
412
|
+
|
|
413
|
+
function convertToBmt() {
|
|
414
|
+
const result = viewerRef.current?.converter.convertToBmt({
|
|
415
|
+
activeView: true,
|
|
416
|
+
fileName: "model",
|
|
417
|
+
useMinVersion: true,
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
if (result) {
|
|
421
|
+
downloadFiles(result.files);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return (
|
|
426
|
+
<>
|
|
427
|
+
<button onClick={convertToBmt}>Export BMT</button>
|
|
428
|
+
<Viewer ref={viewerRef} modelUrls={["/models/model.ifc"]} />
|
|
429
|
+
</>
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Converter options:
|
|
435
|
+
|
|
436
|
+
```ts
|
|
437
|
+
viewerRef.current?.converter.convertToBmt({
|
|
438
|
+
activeView: true,
|
|
439
|
+
fileName: "model",
|
|
440
|
+
fileNames: {
|
|
441
|
+
0: "architecture",
|
|
442
|
+
1: "structure",
|
|
443
|
+
},
|
|
444
|
+
filterElement: ({ modelID, elementID }) => {
|
|
445
|
+
return modelID === 0 && elementID !== 10;
|
|
446
|
+
},
|
|
447
|
+
useMinVersion: true,
|
|
448
|
+
});
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
`activeView` exports only currently visible elements. This includes hide/isolate state because the viewer passes the current scene state to the converter.
|
|
452
|
+
|
|
453
|
+
`useMinVersion` exports `name.min.bmt` plus `name_props.json`. Without it, props and structure are written into one `.bmt` file.
|
|
454
|
+
|
|
455
|
+
`fileName` sets a base name for exported files. `fileNames` sets names per `modelID`.
|
|
456
|
+
|
|
457
|
+
`filterElement` is an optional custom element filter. Return `true` to keep an element in the exported BMT.
|
|
458
|
+
|
|
459
|
+
IFC file conversion is also available through the same API:
|
|
460
|
+
|
|
461
|
+
```ts
|
|
462
|
+
await viewerRef.current?.converter.convertIfcFileToBmt(files, {
|
|
463
|
+
fileName: "converted_ifc",
|
|
464
|
+
useIfcColors: true,
|
|
465
|
+
useIfcElementAssembly: true,
|
|
466
|
+
useIfcSpace: true,
|
|
467
|
+
useMinVersion: true,
|
|
468
|
+
});
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
`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.
|
|
472
|
+
|
|
323
473
|
## Controlled Selection
|
|
324
474
|
|
|
325
475
|
Selection can be controlled by your app state, including Zustand, Redux, or local React state.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Intersection, type Object3D, type Plane, type Vector3 } from "three";
|
|
2
|
+
import type { ViewerModelRef } from "../types";
|
|
3
|
+
export declare const CLIPPING_PLANE_EPSILON = 0.000001;
|
|
4
|
+
export type CameraClippingSource = {
|
|
5
|
+
getActive: () => boolean;
|
|
6
|
+
getPlanes: () => Plane[];
|
|
7
|
+
};
|
|
8
|
+
export type CameraIntersectionOptions = {
|
|
9
|
+
event?: MouseEvent | PointerEvent;
|
|
10
|
+
filter?: (intersection: Intersection<Object3D>) => boolean;
|
|
11
|
+
object?: Object3D | Object3D[] | null;
|
|
12
|
+
recursive?: boolean;
|
|
13
|
+
respectClipping?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type ViewerCameraGetIntersection = {
|
|
16
|
+
(first: true): Intersection<Object3D> | null;
|
|
17
|
+
(first?: false): Intersection<Object3D>[];
|
|
18
|
+
};
|
|
19
|
+
export type CameraUtilsApi = {
|
|
20
|
+
getActiveClippingPlanes: () => Plane[];
|
|
21
|
+
getIntersection: {
|
|
22
|
+
(first: true, options?: CameraIntersectionOptions): Intersection<Object3D> | null;
|
|
23
|
+
(first?: false, options?: CameraIntersectionOptions): Intersection<Object3D>[];
|
|
24
|
+
};
|
|
25
|
+
setClippingSource: (source: CameraClippingSource | null) => void;
|
|
26
|
+
};
|
|
27
|
+
export declare function isPointVisibleByClippingPlanes(point: Vector3, planes: Plane[]): boolean;
|
|
28
|
+
export default function useCameraUtils(modelRef: ViewerModelRef): CameraUtilsApi;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type Object3D } from "three";
|
|
2
|
+
import type { BmtGeomData, BmtModelData } from "./BmtLoader";
|
|
3
|
+
import { type IfcCoordinationMatrixSource, type IfcModelSource } from "./IFCLoader/IFCLoader";
|
|
4
|
+
export type BmtConverterSource = IfcModelSource | IfcModelSource[];
|
|
5
|
+
export type BmtConvertibleModels = BmtModelData | BmtModelData[] | Record<number, BmtModelData>;
|
|
6
|
+
export type BmtVisibleIdsByModel = Record<string | number, Iterable<number>>;
|
|
7
|
+
export type BmtActiveViewFilterParams = {
|
|
8
|
+
elementID: number;
|
|
9
|
+
geometry: BmtGeomData;
|
|
10
|
+
geometryKey: number;
|
|
11
|
+
modelID: number;
|
|
12
|
+
};
|
|
13
|
+
export type BmtActiveViewFilter = (params: BmtActiveViewFilterParams) => boolean;
|
|
14
|
+
export type BmtConverterOptions = {
|
|
15
|
+
activeView?: boolean;
|
|
16
|
+
activeViewRoot?: Object3D | Object3D[] | null;
|
|
17
|
+
chunk?: number;
|
|
18
|
+
coordinationMatrix?: IfcCoordinationMatrixSource;
|
|
19
|
+
fileName?: string;
|
|
20
|
+
fileNames?: Record<string | number, string>;
|
|
21
|
+
filterElement?: BmtActiveViewFilter;
|
|
22
|
+
maxMeshBytes?: number;
|
|
23
|
+
useIfcColors?: boolean;
|
|
24
|
+
useIfcElementAssembly?: boolean;
|
|
25
|
+
useIfcSpace?: boolean;
|
|
26
|
+
useMinVersion?: boolean;
|
|
27
|
+
visibleIdsByModel?: BmtVisibleIdsByModel;
|
|
28
|
+
wasmPath?: string;
|
|
29
|
+
};
|
|
30
|
+
export type BmtConvertedFileType = "bmt" | "json";
|
|
31
|
+
export type BmtConvertedFile = {
|
|
32
|
+
blob: Blob;
|
|
33
|
+
bytes: Uint8Array;
|
|
34
|
+
name: string;
|
|
35
|
+
type: BmtConvertedFileType;
|
|
36
|
+
};
|
|
37
|
+
export type BmtConversionResult = {
|
|
38
|
+
files: BmtConvertedFile[];
|
|
39
|
+
models: Record<number, BmtModelData>;
|
|
40
|
+
};
|
|
41
|
+
export declare class BmtConverter {
|
|
42
|
+
private readonly textEncoder;
|
|
43
|
+
private readonly ifcLoader;
|
|
44
|
+
ConvertIfcFileToBmt(sources: BmtConverterSource, options?: BmtConverterOptions): Promise<BmtConversionResult>;
|
|
45
|
+
convertIfcFileToBmt(sources: BmtConverterSource, options?: BmtConverterOptions): Promise<BmtConversionResult>;
|
|
46
|
+
ConvertToBmt(models: BmtConvertibleModels, options?: BmtConverterOptions): BmtConversionResult;
|
|
47
|
+
convertToBmt(models: BmtConvertibleModels, options?: BmtConverterOptions): BmtConversionResult;
|
|
48
|
+
private configureIfcLoader;
|
|
49
|
+
private normalizeModels;
|
|
50
|
+
private isBmtModelData;
|
|
51
|
+
private getFileNamesFromSources;
|
|
52
|
+
private getModelFileBaseName;
|
|
53
|
+
private normalizeBaseName;
|
|
54
|
+
private createModelFiles;
|
|
55
|
+
private createBmtBytes;
|
|
56
|
+
private writeProps;
|
|
57
|
+
private writeMeshes;
|
|
58
|
+
private createMeshPayload;
|
|
59
|
+
private writeJsonChunk;
|
|
60
|
+
private writeTextChunk;
|
|
61
|
+
private writeChunk;
|
|
62
|
+
private createSerializableModel;
|
|
63
|
+
private markIfcSpaceGeometries;
|
|
64
|
+
private markIfcSpaceGeometry;
|
|
65
|
+
private geometryHasOnlyIds;
|
|
66
|
+
private getHiddenElementIds;
|
|
67
|
+
private addGeometryElementIds;
|
|
68
|
+
private getElementFilter;
|
|
69
|
+
private filterGeometry;
|
|
70
|
+
private isValidVertexIndex;
|
|
71
|
+
private createIndexArray;
|
|
72
|
+
private filterProps;
|
|
73
|
+
private filterStructure;
|
|
74
|
+
private filterStructureNode;
|
|
75
|
+
private getStructureNodeElementID;
|
|
76
|
+
private isStructureNode;
|
|
77
|
+
private getVisibleIdsByModel;
|
|
78
|
+
private getIfcSpaceIdsByModel;
|
|
79
|
+
private addVisibleIdsFromObject3D;
|
|
80
|
+
private isReadableAttribute;
|
|
81
|
+
private isObjectVisible;
|
|
82
|
+
private isIfcSpaceObject;
|
|
83
|
+
private getObjectModelID;
|
|
84
|
+
private hasMeshMatrices;
|
|
85
|
+
private getIndexType;
|
|
86
|
+
private colorToByte;
|
|
87
|
+
private deflateTypedArray;
|
|
88
|
+
private deflateBytes;
|
|
89
|
+
private encodeText;
|
|
90
|
+
private encodePrettyJson;
|
|
91
|
+
private isRecord;
|
|
92
|
+
}
|
|
93
|
+
export declare const bmtConverter: BmtConverter;
|
|
94
|
+
export declare function ConvertIfcFileToBmt(sources: BmtConverterSource, options?: BmtConverterOptions): Promise<BmtConversionResult>;
|
|
95
|
+
export declare function ConvertToBmt(models: BmtConvertibleModels, options?: BmtConverterOptions): BmtConversionResult;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pako from "pako";
|
|
2
|
-
import type { ModelGridsData } from "../ModelGrids";
|
|
2
|
+
import type { ModelGridsData } from "../utils/ModelGrids";
|
|
3
3
|
export type BmtIndexArray = Uint16Array | Uint32Array;
|
|
4
4
|
export interface BmtMaterialData {
|
|
5
5
|
r: number;
|
|
@@ -12,6 +12,7 @@ export interface BmtGeomData {
|
|
|
12
12
|
pos: Float32Array;
|
|
13
13
|
norm?: Float32Array;
|
|
14
14
|
ind: BmtIndexArray;
|
|
15
|
+
isIfcSpace?: boolean;
|
|
15
16
|
ids: Uint32Array;
|
|
16
17
|
matrix?: string;
|
|
17
18
|
mat: BmtMaterialData;
|
|
@@ -85,6 +86,7 @@ export declare class BMTLoader {
|
|
|
85
86
|
STRUCTURE: number;
|
|
86
87
|
GRIDS: number;
|
|
87
88
|
MATRIX: number;
|
|
89
|
+
MESHSPACE: number;
|
|
88
90
|
};
|
|
89
91
|
parseMesh(data: Uint8Array): BmtMeshData;
|
|
90
92
|
private getExternalMetadataPath;
|
|
@@ -21,6 +21,7 @@ export type IfcCoordinationMatrixSource = Matrix4 | number[] | string | null | u
|
|
|
21
21
|
export declare class IFCLoader {
|
|
22
22
|
useIfcElemetAssembly: boolean;
|
|
23
23
|
useIfcColors: boolean;
|
|
24
|
+
useIfcSpace: boolean;
|
|
24
25
|
private coordinationMatrix;
|
|
25
26
|
private parser;
|
|
26
27
|
private propertySerializer;
|
|
@@ -58,9 +59,11 @@ export declare class IfcParser {
|
|
|
58
59
|
private readonly meshMatrix;
|
|
59
60
|
private readonly normalMatrix;
|
|
60
61
|
constructor(parser: IfcAPI, ifcModelID: number, options: IfcParserOptions);
|
|
61
|
-
parseData(allIds: Set<number>, elementsAssembly: IfcElementsAssembly | null): BmtModelData;
|
|
62
|
+
parseData(allIds: Set<number>, elementsAssembly: IfcElementsAssembly | null, includeSpaces?: boolean): BmtModelData;
|
|
63
|
+
private streamGeometryChunks;
|
|
62
64
|
private applyGeometryTransformation;
|
|
63
65
|
private planGeometryChunks;
|
|
66
|
+
private streamMeshes;
|
|
64
67
|
private getMaterialChunkPlan;
|
|
65
68
|
private deleteFlatMesh;
|
|
66
69
|
private canFitInChunk;
|
package/lib/SelectableMesh.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import type { BmtGeomData, BmtMaterialData } from "./Loaders/BmtLoader";
|
|
|
4
4
|
type SelectableMeshProps = {
|
|
5
5
|
colorPaletteTexture: DataTexture;
|
|
6
6
|
data: BmtGeomData;
|
|
7
|
+
isIfcSpace?: boolean;
|
|
7
8
|
material: BmtMaterialData;
|
|
8
9
|
meshMatrix: Matrix4;
|
|
9
10
|
};
|
|
10
|
-
export declare const SelectableMesh: React.MemoExoticComponent<({ colorPaletteTexture, material, data, meshMatrix, }: SelectableMeshProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
|
+
export declare const SelectableMesh: React.MemoExoticComponent<({ colorPaletteTexture, material, data, isIfcSpace, meshMatrix, }: SelectableMeshProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
12
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MutableRefObject } from "react";
|
|
2
|
-
import { Camera, Object3D, Vector2 } from "three";
|
|
2
|
+
import { Camera, Object3D, Vector2, type Plane } from "three";
|
|
3
3
|
export type ClientRectSelection = {
|
|
4
4
|
minX: number;
|
|
5
5
|
minY: number;
|
|
@@ -34,9 +34,10 @@ export type SelectionBoxProfile = {
|
|
|
34
34
|
export declare const MIN_BOX_SIZE = 6;
|
|
35
35
|
export declare function getClientSelectionRect(start: Vector2, end: Vector2): ClientRectSelection;
|
|
36
36
|
export declare function getSelectionBoxMode(start: Vector2, end: Vector2): SelectionBoxMode;
|
|
37
|
-
export declare function getBoxSelectedIds({ model, camera, domElement, rect, mode, profile, }: {
|
|
37
|
+
export declare function getBoxSelectedIds({ model, camera, clippingPlanes, domElement, rect, mode, profile, }: {
|
|
38
38
|
model: Object3D | null;
|
|
39
39
|
camera: Camera;
|
|
40
|
+
clippingPlanes?: Plane[];
|
|
40
41
|
domElement: HTMLElement;
|
|
41
42
|
rect: ClientRectSelection;
|
|
42
43
|
mode: SelectionBoxMode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CameraUtilsApi } from "../Camera/useCameraUtils";
|
|
2
2
|
import type { ViewerControlsRef, ViewerModelRef } from "../types";
|
|
3
|
-
export default function useSelector(modelRef: ViewerModelRef, controlRef: ViewerControlsRef,
|
|
3
|
+
export default function useSelector(modelRef: ViewerModelRef, controlRef: ViewerControlsRef, cameraUtils: CameraUtilsApi): void;
|
package/lib/api/ViewerApi.d.ts
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
import type { ColorRepresentation } from "three";
|
|
2
2
|
import type { SelectedStore, UserDevice, ViewerGridAxesVisibility, ViewerGridAxisSide, ViewerStoreApi } from "../store/ViewerStore";
|
|
3
3
|
import { type ViewerPropertiesApi } from "./ViewerPropertiesApi";
|
|
4
|
+
import type { ViewerClippingApi } from "../utils/ClippingUtils";
|
|
5
|
+
import type { ViewerDimensionsApi } from "../utils/DimentionsUtils";
|
|
6
|
+
import type { ViewerCameraGetIntersection } from "../Camera/useCameraUtils";
|
|
7
|
+
import type { BmtConversionResult, BmtConverterOptions, BmtConverterSource } from "../Loaders/BmtConverter";
|
|
8
|
+
export type { ViewerClippingApi } from "../utils/ClippingUtils";
|
|
9
|
+
export type { ViewerDimensionsApi } from "../utils/DimentionsUtils";
|
|
10
|
+
export type { ViewerCameraGetIntersection } from "../Camera/useCameraUtils";
|
|
4
11
|
export type ViewerSelection = Record<number, number[]>;
|
|
5
12
|
export type ViewerGeometryUtilsApi = {
|
|
6
13
|
getAllIds: () => number[];
|
|
14
|
+
getIfcSpacesVisibility: () => boolean;
|
|
7
15
|
hideByIds: (ids: number[]) => void;
|
|
8
16
|
hideSelected: () => void;
|
|
9
17
|
isolateByIds: (ids: number[]) => void;
|
|
10
18
|
isolateSelected: () => void;
|
|
11
19
|
resetIsolation: () => void;
|
|
20
|
+
setIfcSpacesVisibility: (visible: boolean) => void;
|
|
12
21
|
showAll: () => void;
|
|
13
22
|
showByIds: (ids: number[]) => void;
|
|
23
|
+
toggleIIfcSpacesVisibility: () => void;
|
|
14
24
|
};
|
|
15
25
|
export type ViewerSelectorApi = {
|
|
16
26
|
addSelected: (modelID: number, ids: number[]) => void;
|
|
27
|
+
getPreselectionColor: () => ColorRepresentation;
|
|
28
|
+
getSelectionColor: () => ColorRepresentation;
|
|
17
29
|
getSelected: () => ViewerSelection;
|
|
18
30
|
removeSelected: (modelID: number, ids: number[]) => void;
|
|
19
31
|
resetSelection: (modelID?: number) => void;
|
|
32
|
+
setPreselectionColor: (color: ColorRepresentation) => void;
|
|
33
|
+
setSelectionColor: (color: ColorRepresentation) => void;
|
|
20
34
|
setSelected: (modelID: number, ids: number[], reset?: boolean) => void;
|
|
21
35
|
};
|
|
22
36
|
export type ViewerColorsApi = {
|
|
@@ -26,13 +40,16 @@ export type ViewerColorsApi = {
|
|
|
26
40
|
setColor: (modelID: number, ids: number[], color: ColorRepresentation) => void;
|
|
27
41
|
};
|
|
28
42
|
export type ViewerUtilsApi = {
|
|
43
|
+
getDefaultHotkeysEnabled: () => boolean;
|
|
29
44
|
getGridAxesVisibility: () => ViewerGridAxesVisibility;
|
|
30
45
|
getShowNavCube: () => boolean;
|
|
31
46
|
getShowGridAxes: () => boolean;
|
|
32
47
|
getShowStats: () => boolean;
|
|
33
48
|
getUserDevice: () => UserDevice;
|
|
34
49
|
setGridAxesVisibility: (gridAxesVisibility: Partial<ViewerGridAxesVisibility>) => void;
|
|
50
|
+
setDefaultHotkeysEnabled: (enabled: boolean) => void;
|
|
35
51
|
setGridAxisVisibility: (side: ViewerGridAxisSide, visible: boolean) => void;
|
|
52
|
+
toggleDefaultHotkeys: () => void;
|
|
36
53
|
setShowNavCube: (showNavCube: boolean) => void;
|
|
37
54
|
setShowGridAxes: (showGridAxes: boolean) => void;
|
|
38
55
|
setShowStats: (showStats: boolean) => void;
|
|
@@ -41,10 +58,19 @@ export type ViewerUtilsApi = {
|
|
|
41
58
|
};
|
|
42
59
|
export type ViewerCameraApi = {
|
|
43
60
|
fitCamera: () => void;
|
|
61
|
+
getIntersection: ViewerCameraGetIntersection;
|
|
62
|
+
};
|
|
63
|
+
export type ViewerBmtConverterOptions = Pick<BmtConverterOptions, "activeView" | "fileName" | "fileNames" | "filterElement" | "useIfcColors" | "useIfcElementAssembly" | "useIfcSpace" | "useMinVersion">;
|
|
64
|
+
export type ViewerConverterApi = {
|
|
65
|
+
convertIfcFileToBmt: (sources: BmtConverterSource, options?: ViewerBmtConverterOptions) => Promise<BmtConversionResult>;
|
|
66
|
+
convertToBmt: (options?: ViewerBmtConverterOptions) => BmtConversionResult;
|
|
44
67
|
};
|
|
45
68
|
export type ViewerApi = {
|
|
46
69
|
camera: ViewerCameraApi;
|
|
70
|
+
clipping: ViewerClippingApi;
|
|
47
71
|
colors: ViewerColorsApi;
|
|
72
|
+
converter: ViewerConverterApi;
|
|
73
|
+
dimensions: ViewerDimensionsApi;
|
|
48
74
|
geometryUtils: ViewerGeometryUtilsApi;
|
|
49
75
|
properties: ViewerPropertiesApi;
|
|
50
76
|
selector: ViewerSelectorApi;
|
|
@@ -52,7 +78,10 @@ export type ViewerApi = {
|
|
|
52
78
|
};
|
|
53
79
|
export type ViewerSceneApi = {
|
|
54
80
|
camera: ViewerCameraApi;
|
|
81
|
+
clipping: ViewerClippingApi;
|
|
55
82
|
colors: ViewerColorsApi;
|
|
83
|
+
converter: ViewerConverterApi;
|
|
84
|
+
dimensions: ViewerDimensionsApi;
|
|
56
85
|
geometryUtils: ViewerGeometryUtilsApi;
|
|
57
86
|
};
|
|
58
87
|
export declare function serializeSelected(selected: SelectedStore): ViewerSelection;
|
package/lib/api/loader.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { type BmtModelData } from "../Loaders/BmtLoader";
|
|
2
2
|
export type ViewerModelSource = string | File;
|
|
3
3
|
export type ViewerLoadedModels = Record<number, BmtModelData>;
|
|
4
|
+
export type ViewerLoadModelOptions = {
|
|
5
|
+
useIfcSpace?: boolean;
|
|
6
|
+
};
|
|
4
7
|
declare class ViewerLoaderApi {
|
|
5
8
|
coordinationMatrix: string | undefined;
|
|
9
|
+
useIfcSpace: boolean;
|
|
6
10
|
private bmtLoader;
|
|
7
11
|
private ifcLoader;
|
|
8
12
|
private loadedModelCount;
|
|
@@ -10,10 +14,12 @@ declare class ViewerLoaderApi {
|
|
|
10
14
|
private initLoaders;
|
|
11
15
|
private getBmtLoader;
|
|
12
16
|
private getIfcLoader;
|
|
17
|
+
private getFileSourceMap;
|
|
18
|
+
private applyBmtMetadata;
|
|
13
19
|
private loadBmtModel;
|
|
14
20
|
private resetCoordinationMatrixState;
|
|
15
21
|
resetCoordinationMatrix(): void;
|
|
16
|
-
loadModel(sources: ViewerModelSource | ViewerModelSource[]): Promise<ViewerLoadedModels>;
|
|
22
|
+
loadModel(sources: ViewerModelSource | ViewerModelSource[], options?: ViewerLoadModelOptions): Promise<ViewerLoadedModels>;
|
|
17
23
|
}
|
|
18
24
|
export declare const loader: ViewerLoaderApi;
|
|
19
25
|
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
export { default as Viewer } from "./Viewer";
|
|
2
2
|
export type { ViewerModelsData, ViewerProps } from "./Viewer";
|
|
3
|
-
export type { ViewerApi, ViewerCameraApi, ViewerColorsApi, ViewerGeometryUtilsApi, ViewerSelection, ViewerSelectorApi, ViewerUtilsApi, } from "./api/ViewerApi";
|
|
3
|
+
export type { ViewerApi, ViewerCameraApi, ViewerCameraGetIntersection, ViewerClippingApi, ViewerColorsApi, ViewerBmtConverterOptions, ViewerConverterApi, ViewerDimensionsApi, ViewerGeometryUtilsApi, ViewerSelection, ViewerSelectorApi, ViewerUtilsApi, } from "./api/ViewerApi";
|
|
4
4
|
export type { ViewerPropertiesApi } from "./api/ViewerPropertiesApi";
|
|
5
5
|
export { BMTLoader } from "./Loaders/BmtLoader";
|
|
6
6
|
export type { BmtModelGeometryData, BmtGeomData, BmtIndexArray, BmtMaterialData, BmtElementProps, BmtModelData, BmtModelProps, BmtModelStructure, BmtModelStructureNode, BmtPropertyRecord, BmtPropertySet, BmtPropertyValue, } from "./Loaders/BmtLoader";
|
|
7
7
|
export { IFCLoader } from "./Loaders/IFCLoader/IFCLoader";
|
|
8
8
|
export type { IfcLoadedModels, IfcModelSource, } from "./Loaders/IFCLoader/IFCLoader";
|
|
9
|
-
export {
|
|
10
|
-
export type {
|
|
9
|
+
export { BmtConverter, ConvertIfcFileToBmt, ConvertToBmt, bmtConverter, } from "./Loaders/BmtConverter";
|
|
10
|
+
export type { BmtActiveViewFilter, BmtActiveViewFilterParams, BmtConvertibleModels, BmtConversionResult, BmtConvertedFile, BmtConvertedFileType, BmtConverterOptions, BmtConverterSource, BmtVisibleIdsByModel, } from "./Loaders/BmtConverter";
|
|
11
|
+
export { ModelGrids } from "./utils/ModelGrids";
|
|
12
|
+
export type { ModelGridAxis, ModelGridData, ModelGridPoint, ModelGridsProps, ModelGridsData, } from "./utils/ModelGrids";
|
|
11
13
|
export { loader } from "./api/loader";
|
|
12
|
-
export type { ViewerLoadedModels, ViewerModelSource } from "./api/loader";
|
|
13
|
-
export { NavigationCube } from "./NavigationCube";
|
|
14
|
+
export type { ViewerLoadedModels, ViewerLoadModelOptions, ViewerModelSource, } from "./api/loader";
|
|
15
|
+
export { NavigationCube } from "./utils/NavigationCube";
|
|
16
|
+
export { DimensionLine, DimensionsUtils, useDimensionsUtils, type DimensionUnit, } from "./utils/DimentionsUtils";
|
|
14
17
|
export { createViewerStore } from "./store/ViewerStore";
|
|
15
18
|
export { ViewerStoreProvider } from "./store/ViewerStoreProvider";
|
|
16
19
|
export { useViewerStore, useViewerStoreApi } from "./store/useViewerStore";
|