bimatter-viewer-react 0.5.11 → 0.5.12
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 +76 -0
- package/lib/api/ViewerApi.d.ts +4 -0
- package/lib/api/ViewerPropertiesApi.d.ts +4 -1
- package/lib/index.js +855 -740
- package/lib/utils/ColorsUtils/useElementColors.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -268,6 +268,32 @@ Use `viewerRef.current.colors` to apply temporary color overrides to model eleme
|
|
|
268
268
|
|
|
269
269
|
```tsx
|
|
270
270
|
viewerRef.current?.colors.setColor(0, [10, 20, 30], "#ff3355");
|
|
271
|
+
viewerRef.current?.colors.rebuildByColors({
|
|
272
|
+
0: {
|
|
273
|
+
"#ff3355": [10, 20, 30],
|
|
274
|
+
"#3b82f6": [40, 50],
|
|
275
|
+
},
|
|
276
|
+
1: {
|
|
277
|
+
"#22c55e": [10, 20],
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
viewerRef.current?.colors.rebuildByColors(
|
|
281
|
+
{
|
|
282
|
+
0: {
|
|
283
|
+
"#ff3355": [10, 20, 30],
|
|
284
|
+
"#3b82f6": [40, 50],
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
"#d1d5db",
|
|
288
|
+
);
|
|
289
|
+
viewerRef.current?.colors.rebuildModelByColors(
|
|
290
|
+
0,
|
|
291
|
+
{
|
|
292
|
+
"#ff3355": [10, 20, 30],
|
|
293
|
+
"#3b82f6": [40, 50],
|
|
294
|
+
},
|
|
295
|
+
"#d1d5db",
|
|
296
|
+
);
|
|
271
297
|
viewerRef.current?.colors.clearColor(0, [10, 20]);
|
|
272
298
|
viewerRef.current?.colors.clearModelColors(0);
|
|
273
299
|
viewerRef.current?.colors.clearAllColors();
|
|
@@ -455,6 +481,56 @@ With `ofLevel(level)`, `toElements()` returns `{ elementID, props }[]` and `toEl
|
|
|
455
481
|
|
|
456
482
|
`ofType()` accepts `IfcClass | string`, so TypeScript suggests IFC classes like `"IfcWall"` while still allowing custom type strings.
|
|
457
483
|
|
|
484
|
+
## Using Colorize With Collectors
|
|
485
|
+
|
|
486
|
+
Collectors can be used directly as color inputs. This is useful when you want to highlight elements by IFC type, level, or property value:
|
|
487
|
+
|
|
488
|
+
```tsx
|
|
489
|
+
const viewer = viewerRef.current;
|
|
490
|
+
|
|
491
|
+
viewer?.colors.rebuildModelByColors(
|
|
492
|
+
0,
|
|
493
|
+
{
|
|
494
|
+
"#ff3355":
|
|
495
|
+
viewer.selector
|
|
496
|
+
.collector()
|
|
497
|
+
.ofModel(0)
|
|
498
|
+
.Where((element) => {
|
|
499
|
+
return (
|
|
500
|
+
viewer.properties.getParamValueByName(
|
|
501
|
+
element.props,
|
|
502
|
+
"System Name",
|
|
503
|
+
"Mechanical",
|
|
504
|
+
) === "Mechanical Supply Air 2"
|
|
505
|
+
);
|
|
506
|
+
})
|
|
507
|
+
.toElementsIds() ?? [],
|
|
508
|
+
},
|
|
509
|
+
"#d1d5db",
|
|
510
|
+
);
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
You can also combine level filters with type filters:
|
|
514
|
+
|
|
515
|
+
```tsx
|
|
516
|
+
const viewer = viewerRef.current;
|
|
517
|
+
const firstLevel = viewer?.properties.getAllModelLevels(0, true)[0];
|
|
518
|
+
|
|
519
|
+
if (viewer && firstLevel) {
|
|
520
|
+
viewer.colors.rebuildModelByColors(
|
|
521
|
+
0,
|
|
522
|
+
{
|
|
523
|
+
"#3b82f6": viewer.selector
|
|
524
|
+
.collector()
|
|
525
|
+
.ofLevel(firstLevel)
|
|
526
|
+
.ofType("IfcWall")
|
|
527
|
+
.toElementsIds(),
|
|
528
|
+
},
|
|
529
|
+
"#d1d5db",
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
458
534
|
## Stats And Profiling
|
|
459
535
|
|
|
460
536
|
Enable FPS stats and console timing logs:
|
package/lib/api/ViewerApi.d.ts
CHANGED
|
@@ -2,11 +2,13 @@ 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 { ViewerColorConfigByModel, ViewerModelColorConfig } from "../utils/ColorsUtils/useElementColors";
|
|
5
6
|
import type { ViewerDimensionsApi } from "../utils/DimentionsUtils";
|
|
6
7
|
import type { ViewerCameraGetIntersection } from "../Camera/useCameraUtils";
|
|
7
8
|
import type { BmtConversionResult, BmtConverterOptions, BmtConverterSource } from "../Loaders/BmtConverter";
|
|
8
9
|
import { FilteredElementsCollector } from "../Selector/FilteredElementsCollector";
|
|
9
10
|
export type { ViewerClippingApi } from "../utils/ClippingUtils";
|
|
11
|
+
export type { ViewerColorConfigByModel, ViewerModelColorConfig, } from "../utils/ColorsUtils/useElementColors";
|
|
10
12
|
export type { ViewerDimensionsApi } from "../utils/DimentionsUtils";
|
|
11
13
|
export type { ViewerCameraGetIntersection } from "../Camera/useCameraUtils";
|
|
12
14
|
export type ViewerSelection = Record<number, number[]>;
|
|
@@ -42,6 +44,8 @@ export type ViewerColorsApi = {
|
|
|
42
44
|
clearAllColors: () => void;
|
|
43
45
|
clearColor: (modelID: number, ids: number[]) => void;
|
|
44
46
|
clearModelColors: (modelID: number) => void;
|
|
47
|
+
rebuildByColors: (colorsByModel: ViewerColorConfigByModel, defaultColor?: ColorRepresentation) => void;
|
|
48
|
+
rebuildModelByColors: (modelID: number, colorsByIds: ViewerModelColorConfig, defaultColor?: ColorRepresentation) => void;
|
|
45
49
|
setColor: (modelID: number, ids: number[], color: ColorRepresentation) => void;
|
|
46
50
|
};
|
|
47
51
|
export type ViewerUtilsApi = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ViewerModelPropsStore, ViewerModelStructureStore, ViewerStoreApi } from "../store/ViewerStore";
|
|
2
2
|
import { type ExportedExcelFile, type ModelPropertiesExcelOptions } from "../utils/ExportUtils";
|
|
3
|
-
import type { BmtModelStructureNode, BmtPropertyRecord, BmtPropertySet, BmtPropertyValue } from "../Loaders/BmtLoader";
|
|
3
|
+
import type { BmtElementProps, BmtModelStructureNode, BmtPropertyRecord, BmtPropertySet, BmtPropertyValue } from "../Loaders/BmtLoader";
|
|
4
4
|
export type ViewerPropertiesExcelOptions = ModelPropertiesExcelOptions;
|
|
5
5
|
type ViewerModelLevelValue = BmtModelStructureNode[] | BmtPropertyRecord | BmtPropertySet[] | BmtPropertyValue;
|
|
6
6
|
export type ViewerModelLevel = Record<string, ViewerModelLevelValue | undefined> & {
|
|
@@ -15,6 +15,9 @@ export type ViewerPropertiesApi = {
|
|
|
15
15
|
getAllModelLevels: (modelID: number, recursive?: boolean) => ViewerModelLevel[];
|
|
16
16
|
getModelProps: () => ViewerModelPropsStore;
|
|
17
17
|
getModelStructure: () => ViewerModelStructureStore;
|
|
18
|
+
getParamsByElement: (modelID: number, elementID: number) => BmtElementProps | undefined;
|
|
19
|
+
getParamValueByName: (elementParams: BmtElementProps | null | undefined, paramName: string, setName?: string) => BmtPropertyValue | undefined;
|
|
20
|
+
getParamValueByElement: (modelID: number, elementID: number, paramName: string, setName?: string) => BmtPropertyValue | undefined;
|
|
18
21
|
};
|
|
19
22
|
export declare function createViewerPropertiesApi(viewerStore: ViewerStoreApi): ViewerPropertiesApi;
|
|
20
23
|
export {};
|