bimatter-viewer-react 0.3.0 → 0.4.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 +158 -0
- package/lib/Loaders/BmtConverter.d.ts +95 -0
- package/lib/Loaders/BmtLoader.d.ts +4 -0
- package/lib/Loaders/IFCLoader/IFCLoader.d.ts +4 -1
- package/lib/SelectableMesh.d.ts +2 -1
- package/lib/Selector/FilteredElementsCollector.d.ts +38 -0
- package/lib/api/ViewerApi.d.ts +17 -0
- package/lib/api/ViewerPropertiesApi.d.ts +4 -0
- package/lib/api/loader.d.ts +7 -1
- package/lib/index.d.ts +11 -4
- package/lib/index.js +14985 -13542
- package/lib/store/ViewerStore.d.ts +3 -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/utils/ExportUtils/ExportUtils.d.ts +13 -0
- package/lib/utils/ExportUtils/index.d.ts +2 -0
- package/lib/utils/GeometryUtils/useGeometryIndex.d.ts +2 -0
- package/lib/utils/GeometryUtils/useGeometryUtils.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,6 +109,16 @@ You can also load mixed model lists:
|
|
|
109
109
|
/>
|
|
110
110
|
```
|
|
111
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
|
+
|
|
112
122
|
## Loader API
|
|
113
123
|
|
|
114
124
|
You can load models yourself and pass parsed data to the viewer:
|
|
@@ -137,6 +147,7 @@ function App() {
|
|
|
137
147
|
```ts
|
|
138
148
|
await loader.loadModel(["/models/model.bmt"]);
|
|
139
149
|
await loader.loadModel(["/models/model.ifc"]);
|
|
150
|
+
await loader.loadModel(["/models/model.ifc"], { useIfcSpace: true });
|
|
140
151
|
await loader.loadModel(["/models/model.bmt", "/models/model.ifc"]);
|
|
141
152
|
await loader.loadModel(files);
|
|
142
153
|
```
|
|
@@ -199,6 +210,10 @@ function App() {
|
|
|
199
210
|
|
|
200
211
|
`P` - Create clipping plane by model intersection
|
|
201
212
|
|
|
213
|
+
### Dimensions
|
|
214
|
+
|
|
215
|
+
`M` - Toggle dimension drawing mode
|
|
216
|
+
|
|
202
217
|
## Viewer API
|
|
203
218
|
|
|
204
219
|
```ts
|
|
@@ -214,12 +229,16 @@ viewerRef.current?.geometryUtils.isolateByIds([1, 2, 3]);
|
|
|
214
229
|
viewerRef.current?.geometryUtils.isolateSelected();
|
|
215
230
|
viewerRef.current?.geometryUtils.resetIsolation();
|
|
216
231
|
viewerRef.current?.geometryUtils.getAllIds();
|
|
232
|
+
viewerRef.current?.geometryUtils.setIfcSpacesVisibility(false);
|
|
233
|
+
viewerRef.current?.geometryUtils.getIfcSpacesVisibility();
|
|
234
|
+
viewerRef.current?.geometryUtils.toggleIIfcSpacesVisibility();
|
|
217
235
|
|
|
218
236
|
viewerRef.current?.selector.setSelected(0, [10, 20], true);
|
|
219
237
|
viewerRef.current?.selector.addSelected(0, [30]);
|
|
220
238
|
viewerRef.current?.selector.removeSelected(0, [10]);
|
|
221
239
|
viewerRef.current?.selector.resetSelection();
|
|
222
240
|
viewerRef.current?.selector.getSelected();
|
|
241
|
+
viewerRef.current?.selector.collector().ofType("IfcWall").toElements();
|
|
223
242
|
viewerRef.current?.selector.setSelectionColor("#1194bd");
|
|
224
243
|
viewerRef.current?.selector.getSelectionColor();
|
|
225
244
|
viewerRef.current?.selector.setPreselectionColor("#68c6e3");
|
|
@@ -230,6 +249,17 @@ viewerRef.current?.colors.clearColor(0, [10]);
|
|
|
230
249
|
viewerRef.current?.colors.clearModelColors(0);
|
|
231
250
|
viewerRef.current?.colors.clearAllColors();
|
|
232
251
|
|
|
252
|
+
viewerRef.current?.converter.convertToBmt({
|
|
253
|
+
activeView: true,
|
|
254
|
+
useMinVersion: true,
|
|
255
|
+
});
|
|
256
|
+
viewerRef.current?.converter.convertIfcFileToBmt(files, {
|
|
257
|
+
useIfcColors: true,
|
|
258
|
+
useIfcElementAssembly: true,
|
|
259
|
+
useIfcSpace: true,
|
|
260
|
+
useMinVersion: true,
|
|
261
|
+
});
|
|
262
|
+
|
|
233
263
|
viewerRef.current?.clipping.createPlane();
|
|
234
264
|
viewerRef.current?.clipping.createClippingRectangle();
|
|
235
265
|
viewerRef.current?.clipping.toggle();
|
|
@@ -238,8 +268,23 @@ viewerRef.current?.clipping.setEdgesActive(true);
|
|
|
238
268
|
viewerRef.current?.clipping.setHelpersActive(true);
|
|
239
269
|
viewerRef.current?.clipping.deleteAllPlanes();
|
|
240
270
|
|
|
271
|
+
viewerRef.current?.dimensions.setActive(true);
|
|
272
|
+
viewerRef.current?.dimensions.toggle();
|
|
273
|
+
viewerRef.current?.dimensions.cancelDrawing();
|
|
274
|
+
viewerRef.current?.dimensions.changeAxes();
|
|
275
|
+
viewerRef.current?.dimensions.delete();
|
|
276
|
+
viewerRef.current?.dimensions.deleteAll();
|
|
277
|
+
viewerRef.current?.dimensions.setUnit("mm");
|
|
278
|
+
viewerRef.current?.dimensions.setColor("#111827");
|
|
279
|
+
viewerRef.current?.dimensions.setWidth(1);
|
|
280
|
+
viewerRef.current?.dimensions.setSnapDistance(1);
|
|
281
|
+
viewerRef.current?.dimensions.setEndpointScaleFactor(0.015);
|
|
282
|
+
viewerRef.current?.dimensions.getDimensions();
|
|
283
|
+
|
|
241
284
|
viewerRef.current?.properties.getModelProps();
|
|
242
285
|
viewerRef.current?.properties.getModelStructure();
|
|
286
|
+
viewerRef.current?.properties.exportExcel(0);
|
|
287
|
+
viewerRef.current?.properties.exportAllExcel();
|
|
243
288
|
viewerRef.current?.utils.getUserDevice();
|
|
244
289
|
viewerRef.current?.utils.getDefaultHotkeysEnabled();
|
|
245
290
|
viewerRef.current?.utils.setDefaultHotkeysEnabled(false);
|
|
@@ -295,6 +340,8 @@ function App() {
|
|
|
295
340
|
}
|
|
296
341
|
```
|
|
297
342
|
|
|
343
|
+
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.
|
|
344
|
+
|
|
298
345
|
## Colorize Elements
|
|
299
346
|
|
|
300
347
|
Use `viewerRef.current.colors` to apply temporary color overrides to model elements. The color is applied by `modelID` and element ids:
|
|
@@ -343,6 +390,89 @@ function App() {
|
|
|
343
390
|
}
|
|
344
391
|
```
|
|
345
392
|
|
|
393
|
+
## Convert To BMT
|
|
394
|
+
|
|
395
|
+
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.
|
|
396
|
+
|
|
397
|
+
```tsx
|
|
398
|
+
import { useRef } from "react";
|
|
399
|
+
import { Viewer, type ViewerApi } from "bimatter-viewer-react";
|
|
400
|
+
|
|
401
|
+
function downloadFiles(files: { blob: Blob; name: string }[]) {
|
|
402
|
+
files.forEach((file) => {
|
|
403
|
+
const url = URL.createObjectURL(file.blob);
|
|
404
|
+
const link = document.createElement("a");
|
|
405
|
+
|
|
406
|
+
link.href = url;
|
|
407
|
+
link.download = file.name;
|
|
408
|
+
link.click();
|
|
409
|
+
URL.revokeObjectURL(url);
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function App() {
|
|
414
|
+
const viewerRef = useRef<ViewerApi>(null);
|
|
415
|
+
|
|
416
|
+
function convertToBmt() {
|
|
417
|
+
const result = viewerRef.current?.converter.convertToBmt({
|
|
418
|
+
activeView: true,
|
|
419
|
+
fileName: "model",
|
|
420
|
+
useMinVersion: true,
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
if (result) {
|
|
424
|
+
downloadFiles(result.files);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return (
|
|
429
|
+
<>
|
|
430
|
+
<button onClick={convertToBmt}>Export BMT</button>
|
|
431
|
+
<Viewer ref={viewerRef} modelUrls={["/models/model.ifc"]} />
|
|
432
|
+
</>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Converter options:
|
|
438
|
+
|
|
439
|
+
```ts
|
|
440
|
+
viewerRef.current?.converter.convertToBmt({
|
|
441
|
+
activeView: true,
|
|
442
|
+
fileName: "model",
|
|
443
|
+
fileNames: {
|
|
444
|
+
0: "architecture",
|
|
445
|
+
1: "structure",
|
|
446
|
+
},
|
|
447
|
+
filterElement: ({ modelID, elementID }) => {
|
|
448
|
+
return modelID === 0 && elementID !== 10;
|
|
449
|
+
},
|
|
450
|
+
useMinVersion: true,
|
|
451
|
+
});
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
`activeView` exports only currently visible elements. This includes hide/isolate state because the viewer passes the current scene state to the converter.
|
|
455
|
+
|
|
456
|
+
`useMinVersion` exports `name.min.bmt` plus `name_props.json`. Without it, props and structure are written into one `.bmt` file.
|
|
457
|
+
|
|
458
|
+
`fileName` sets a base name for exported files. `fileNames` sets names per `modelID`.
|
|
459
|
+
|
|
460
|
+
`filterElement` is an optional custom element filter. Return `true` to keep an element in the exported BMT.
|
|
461
|
+
|
|
462
|
+
IFC file conversion is also available through the same API:
|
|
463
|
+
|
|
464
|
+
```ts
|
|
465
|
+
await viewerRef.current?.converter.convertIfcFileToBmt(files, {
|
|
466
|
+
fileName: "converted_ifc",
|
|
467
|
+
useIfcColors: true,
|
|
468
|
+
useIfcElementAssembly: true,
|
|
469
|
+
useIfcSpace: true,
|
|
470
|
+
useMinVersion: true,
|
|
471
|
+
});
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
`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.
|
|
475
|
+
|
|
346
476
|
## Controlled Selection
|
|
347
477
|
|
|
348
478
|
Selection can be controlled by your app state, including Zustand, Redux, or local React state.
|
|
@@ -364,6 +494,34 @@ function App() {
|
|
|
364
494
|
}
|
|
365
495
|
```
|
|
366
496
|
|
|
497
|
+
## Filtered Elements Collector
|
|
498
|
+
|
|
499
|
+
Use `selector.collector()` to query element properties from loaded models:
|
|
500
|
+
|
|
501
|
+
```tsx
|
|
502
|
+
import type { IfcClass } from "bimatter-viewer-react";
|
|
503
|
+
|
|
504
|
+
const wallType: IfcClass = "IfcWall";
|
|
505
|
+
|
|
506
|
+
const walls = viewerRef.current?.selector
|
|
507
|
+
.collector()
|
|
508
|
+
.ofType(wallType)
|
|
509
|
+
.toElements();
|
|
510
|
+
|
|
511
|
+
const basicWallIds = viewerRef.current?.selector
|
|
512
|
+
.collector()
|
|
513
|
+
.ofModel(0)
|
|
514
|
+
.ofType("IfcWall")
|
|
515
|
+
.Where((element) => element.props.Name.startsWith("basic wall"))
|
|
516
|
+
.toElementsIds();
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
Without `ofModel()`, `toElements()` returns `{ [modelID]: { elementID, props }[] }` and `toElementsIds()` returns `{ [modelID]: number[] }`.
|
|
520
|
+
|
|
521
|
+
With `ofModel(0)`, `toElements()` returns `{ elementID, props }[]` and `toElementsIds()` returns `number[]`.
|
|
522
|
+
|
|
523
|
+
`ofType()` accepts `IfcClass | string`, so TypeScript suggests IFC classes like `"IfcWall"` while still allowing custom type strings.
|
|
524
|
+
|
|
367
525
|
## Stats And Profiling
|
|
368
526
|
|
|
369
527
|
Enable FPS stats and console timing logs:
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -54,6 +55,7 @@ export interface BmtModelData {
|
|
|
54
55
|
coordinationMatrix?: string;
|
|
55
56
|
data: BmtModelGeometryData;
|
|
56
57
|
grids?: ModelGridsData;
|
|
58
|
+
name?: string;
|
|
57
59
|
props: BmtModelProps;
|
|
58
60
|
structure: BmtModelStructure;
|
|
59
61
|
}
|
|
@@ -85,10 +87,12 @@ export declare class BMTLoader {
|
|
|
85
87
|
STRUCTURE: number;
|
|
86
88
|
GRIDS: number;
|
|
87
89
|
MATRIX: number;
|
|
90
|
+
MESHSPACE: number;
|
|
88
91
|
};
|
|
89
92
|
parseMesh(data: Uint8Array): BmtMeshData;
|
|
90
93
|
private getExternalMetadataPath;
|
|
91
94
|
private loadExternalMetadata;
|
|
95
|
+
private getModelNameFromPath;
|
|
92
96
|
loadModel(path: string): Promise<BmtModelData>;
|
|
93
97
|
parseBinaryFile(data: ArrayBuffer): BmtModelData;
|
|
94
98
|
}
|
|
@@ -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 {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type * as WebIfc from "web-ifc";
|
|
2
|
+
import type { BmtElementProps, BmtModelData, BmtModelProps } from "../Loaders/BmtLoader";
|
|
3
|
+
type IfcClassConstructor = abstract new (...args: never[]) => unknown;
|
|
4
|
+
type IfcNamespaceClassNames<TNamespace> = Extract<{
|
|
5
|
+
[Key in keyof TNamespace]: TNamespace[Key] extends IfcClassConstructor ? Key : never;
|
|
6
|
+
}[keyof TNamespace], `Ifc${string}`>;
|
|
7
|
+
export type IfcClass = IfcNamespaceClassNames<typeof WebIfc.IFC2X3> | IfcNamespaceClassNames<typeof WebIfc.IFC4> | IfcNamespaceClassNames<typeof WebIfc.IFC4X3>;
|
|
8
|
+
export type IfcClassName = IfcClass | (string & {});
|
|
9
|
+
export type FilteredElement = {
|
|
10
|
+
elementID: number;
|
|
11
|
+
props: BmtElementProps;
|
|
12
|
+
};
|
|
13
|
+
export type FilteredElementWithModel = FilteredElement & {
|
|
14
|
+
modelID: number;
|
|
15
|
+
};
|
|
16
|
+
export type FilteredElementId = number;
|
|
17
|
+
export type FilteredElementsResult = Record<number, FilteredElement[]>;
|
|
18
|
+
export type FilteredElementIdsResult = Record<number, number[]>;
|
|
19
|
+
export type FilteredElementPredicate = (element: FilteredElementWithModel) => unknown;
|
|
20
|
+
export type FilteredElementsSource = BmtModelData | BmtModelProps | Record<number, BmtModelData> | Record<number, BmtModelProps> | null | undefined;
|
|
21
|
+
export declare class FilteredElementsCollector<TSingleModel extends boolean = false> {
|
|
22
|
+
private elements;
|
|
23
|
+
private filters;
|
|
24
|
+
private selectedModelIDs;
|
|
25
|
+
constructor(source?: FilteredElementsSource);
|
|
26
|
+
from(source: FilteredElementsSource): this;
|
|
27
|
+
ofType(type: IfcClassName | readonly IfcClassName[]): this;
|
|
28
|
+
ofModel(modelID: number): FilteredElementsCollector<true>;
|
|
29
|
+
ofModel(modelID: number[]): FilteredElementsCollector<false>;
|
|
30
|
+
Where(predicate: FilteredElementPredicate): this;
|
|
31
|
+
where(predicate: FilteredElementPredicate): this;
|
|
32
|
+
private getFilteredElements;
|
|
33
|
+
private hasSingleSelectedModel;
|
|
34
|
+
toElements(): TSingleModel extends true ? FilteredElement[] : FilteredElementsResult;
|
|
35
|
+
toElementsIds(): TSingleModel extends true ? number[] : FilteredElementIdsResult;
|
|
36
|
+
toElementIds(): TSingleModel extends true ? number[] : FilteredElementIdsResult;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
package/lib/api/ViewerApi.d.ts
CHANGED
|
@@ -2,22 +2,30 @@ 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
4
|
import type { ViewerClippingApi } from "../utils/ClippingUtils";
|
|
5
|
+
import type { ViewerDimensionsApi } from "../utils/DimentionsUtils";
|
|
5
6
|
import type { ViewerCameraGetIntersection } from "../Camera/useCameraUtils";
|
|
7
|
+
import type { BmtConversionResult, BmtConverterOptions, BmtConverterSource } from "../Loaders/BmtConverter";
|
|
8
|
+
import { FilteredElementsCollector } from "../Selector/FilteredElementsCollector";
|
|
6
9
|
export type { ViewerClippingApi } from "../utils/ClippingUtils";
|
|
10
|
+
export type { ViewerDimensionsApi } from "../utils/DimentionsUtils";
|
|
7
11
|
export type { ViewerCameraGetIntersection } from "../Camera/useCameraUtils";
|
|
8
12
|
export type ViewerSelection = Record<number, number[]>;
|
|
9
13
|
export type ViewerGeometryUtilsApi = {
|
|
10
14
|
getAllIds: () => number[];
|
|
15
|
+
getIfcSpacesVisibility: () => boolean;
|
|
11
16
|
hideByIds: (ids: number[]) => void;
|
|
12
17
|
hideSelected: () => void;
|
|
13
18
|
isolateByIds: (ids: number[]) => void;
|
|
14
19
|
isolateSelected: () => void;
|
|
15
20
|
resetIsolation: () => void;
|
|
21
|
+
setIfcSpacesVisibility: (visible: boolean) => void;
|
|
16
22
|
showAll: () => void;
|
|
17
23
|
showByIds: (ids: number[]) => void;
|
|
24
|
+
toggleIIfcSpacesVisibility: () => void;
|
|
18
25
|
};
|
|
19
26
|
export type ViewerSelectorApi = {
|
|
20
27
|
addSelected: (modelID: number, ids: number[]) => void;
|
|
28
|
+
collector: () => FilteredElementsCollector;
|
|
21
29
|
getPreselectionColor: () => ColorRepresentation;
|
|
22
30
|
getSelectionColor: () => ColorRepresentation;
|
|
23
31
|
getSelected: () => ViewerSelection;
|
|
@@ -54,10 +62,17 @@ export type ViewerCameraApi = {
|
|
|
54
62
|
fitCamera: () => void;
|
|
55
63
|
getIntersection: ViewerCameraGetIntersection;
|
|
56
64
|
};
|
|
65
|
+
export type ViewerBmtConverterOptions = Pick<BmtConverterOptions, "activeView" | "fileName" | "fileNames" | "filterElement" | "useIfcColors" | "useIfcElementAssembly" | "useIfcSpace" | "useMinVersion">;
|
|
66
|
+
export type ViewerConverterApi = {
|
|
67
|
+
convertIfcFileToBmt: (sources: BmtConverterSource, options?: ViewerBmtConverterOptions) => Promise<BmtConversionResult>;
|
|
68
|
+
convertToBmt: (options?: ViewerBmtConverterOptions) => BmtConversionResult;
|
|
69
|
+
};
|
|
57
70
|
export type ViewerApi = {
|
|
58
71
|
camera: ViewerCameraApi;
|
|
59
72
|
clipping: ViewerClippingApi;
|
|
60
73
|
colors: ViewerColorsApi;
|
|
74
|
+
converter: ViewerConverterApi;
|
|
75
|
+
dimensions: ViewerDimensionsApi;
|
|
61
76
|
geometryUtils: ViewerGeometryUtilsApi;
|
|
62
77
|
properties: ViewerPropertiesApi;
|
|
63
78
|
selector: ViewerSelectorApi;
|
|
@@ -67,6 +82,8 @@ export type ViewerSceneApi = {
|
|
|
67
82
|
camera: ViewerCameraApi;
|
|
68
83
|
clipping: ViewerClippingApi;
|
|
69
84
|
colors: ViewerColorsApi;
|
|
85
|
+
converter: ViewerConverterApi;
|
|
86
|
+
dimensions: ViewerDimensionsApi;
|
|
70
87
|
geometryUtils: ViewerGeometryUtilsApi;
|
|
71
88
|
};
|
|
72
89
|
export declare function serializeSelected(selected: SelectedStore): ViewerSelection;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { ViewerModelPropsStore, ViewerModelStructureStore, ViewerStoreApi } from "../store/ViewerStore";
|
|
2
|
+
import { type ExportedExcelFile, type ModelPropertiesExcelOptions } from "../utils/ExportUtils";
|
|
3
|
+
export type ViewerPropertiesExcelOptions = ModelPropertiesExcelOptions;
|
|
2
4
|
export type ViewerPropertiesApi = {
|
|
5
|
+
exportAllExcel: (options?: ViewerPropertiesExcelOptions) => ExportedExcelFile[];
|
|
6
|
+
exportExcel: (modelID: number, options?: ViewerPropertiesExcelOptions) => ExportedExcelFile | null;
|
|
3
7
|
getModelProps: () => ViewerModelPropsStore;
|
|
4
8
|
getModelStructure: () => ViewerModelStructureStore;
|
|
5
9
|
};
|
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,17 +1,24 @@
|
|
|
1
1
|
export { default as Viewer } from "./Viewer";
|
|
2
2
|
export type { ViewerModelsData, ViewerProps } from "./Viewer";
|
|
3
|
-
export type { ViewerApi, ViewerCameraApi, ViewerCameraGetIntersection, ViewerClippingApi, ViewerColorsApi, ViewerGeometryUtilsApi, ViewerSelection, ViewerSelectorApi, ViewerUtilsApi, } from "./api/ViewerApi";
|
|
4
|
-
export type { ViewerPropertiesApi } from "./api/ViewerPropertiesApi";
|
|
3
|
+
export type { ViewerApi, ViewerCameraApi, ViewerCameraGetIntersection, ViewerClippingApi, ViewerColorsApi, ViewerBmtConverterOptions, ViewerConverterApi, ViewerDimensionsApi, ViewerGeometryUtilsApi, ViewerSelection, ViewerSelectorApi, ViewerUtilsApi, } from "./api/ViewerApi";
|
|
4
|
+
export type { ViewerPropertiesApi, ViewerPropertiesExcelOptions, } 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 { BmtConverter, ConvertIfcFileToBmt, ConvertToBmt, bmtConverter, } from "./Loaders/BmtConverter";
|
|
10
|
+
export type { BmtActiveViewFilter, BmtActiveViewFilterParams, BmtConvertibleModels, BmtConversionResult, BmtConvertedFile, BmtConvertedFileType, BmtConverterOptions, BmtConverterSource, BmtVisibleIdsByModel, } from "./Loaders/BmtConverter";
|
|
9
11
|
export { ModelGrids } from "./utils/ModelGrids";
|
|
10
12
|
export type { ModelGridAxis, ModelGridData, ModelGridPoint, ModelGridsProps, ModelGridsData, } from "./utils/ModelGrids";
|
|
13
|
+
export { exportExcel, exportModelPropertiesToExcel, } from "./utils/ExportUtils";
|
|
14
|
+
export type { ExportedExcelFile, ExportModelSource, ModelPropertiesExcelOptions, } from "./utils/ExportUtils";
|
|
11
15
|
export { loader } from "./api/loader";
|
|
12
|
-
export type { ViewerLoadedModels, ViewerModelSource } from "./api/loader";
|
|
16
|
+
export type { ViewerLoadedModels, ViewerLoadModelOptions, ViewerModelSource, } from "./api/loader";
|
|
17
|
+
export { FilteredElementsCollector } from "./Selector/FilteredElementsCollector";
|
|
18
|
+
export type { FilteredElement, FilteredElementId, FilteredElementIdsResult, FilteredElementPredicate, FilteredElementsResult, FilteredElementsSource, FilteredElementWithModel, IfcClass, IfcClassName, } from "./Selector/FilteredElementsCollector";
|
|
13
19
|
export { NavigationCube } from "./utils/NavigationCube";
|
|
20
|
+
export { DimensionLine, DimensionsUtils, useDimensionsUtils, type DimensionUnit, } from "./utils/DimentionsUtils";
|
|
14
21
|
export { createViewerStore } from "./store/ViewerStore";
|
|
15
22
|
export { ViewerStoreProvider } from "./store/ViewerStoreProvider";
|
|
16
23
|
export { useViewerStore, useViewerStoreApi } from "./store/useViewerStore";
|
|
17
|
-
export type { SelectedStore, UserDevice, ViewerGridAxesVisibility, ViewerGridAxisSide, ViewerModelPropsStore, ViewerModelStructureStore, ViewerStore, ViewerStoreApi, } from "./store/ViewerStore";
|
|
24
|
+
export type { SelectedStore, UserDevice, ViewerGridAxesVisibility, ViewerGridAxisSide, ViewerModelNamesStore, ViewerModelPropsStore, ViewerModelStructureStore, ViewerStore, ViewerStoreApi, } from "./store/ViewerStore";
|