bimatter-viewer-react 0.7.0 → 0.7.2

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.
@@ -1,5 +1,6 @@
1
1
  import { type StoreApi } from "zustand/vanilla";
2
2
  import type { ColorRepresentation } from "three";
3
+ import type { ViewerPostproductionPassType } from "../types";
3
4
  import type { BmtModelProps, BmtModelStructure } from "../Loaders/BmtLoader";
4
5
  import type { ViewerApi } from "../api/ViewerApi";
5
6
  export type UserDevice = "pc" | "mobile";
@@ -13,16 +14,39 @@ export interface SelectedStore {
13
14
  export type ViewerModelPropsStore = Record<number, BmtModelProps>;
14
15
  export type ViewerModelStructureStore = Record<number, BmtModelStructure>;
15
16
  export type ViewerModelNamesStore = Record<number, string>;
17
+ export type ViewerLightSettings = {
18
+ color: ColorRepresentation;
19
+ intensity: number;
20
+ };
21
+ export type ViewerLightingSettings = {
22
+ ambient: ViewerLightSettings;
23
+ directional: ViewerLightSettings;
24
+ };
25
+ export type ViewerLightingSettingsUpdate = {
26
+ ambient?: Partial<ViewerLightSettings>;
27
+ directional?: Partial<ViewerLightSettings>;
28
+ };
29
+ export type ViewerPostproductionActivePassFilter = {
30
+ pass: unknown;
31
+ type: Exclude<ViewerPostproductionPassType, null>;
32
+ };
16
33
  export declare const DEFAULT_SELECTION_COLOR = "rgb(17, 148, 189)";
17
34
  export declare const DEFAULT_PRESELECTION_COLOR = "rgb(104, 198, 227)";
35
+ export declare const DEFAULT_AMBIENT_LIGHT_COLOR = "#ffffff";
36
+ export declare const DEFAULT_AMBIENT_LIGHT_INTENSITY = 1.5;
37
+ export declare const DEFAULT_DIRECTIONAL_LIGHT_COLOR = "#ffffff";
38
+ export declare const DEFAULT_DIRECTIONAL_LIGHT_INTENSITY = 1.5;
18
39
  export type ViewerStore = {
19
40
  api: ViewerApi | null;
20
41
  defaultHotkeysEnabled: boolean;
42
+ lighting: ViewerLightingSettings;
21
43
  modelNames: ViewerModelNamesStore;
22
44
  modelProps: ViewerModelPropsStore;
23
45
  modelStructure: ViewerModelStructureStore;
24
46
  gridAxesVisibility: ViewerGridAxesVisibility;
25
47
  preselectionColor: ColorRepresentation;
48
+ postproductionActivePassFilter: ViewerPostproductionActivePassFilter | null;
49
+ postproductionPassType: ViewerPostproductionPassType;
26
50
  selected: SelectedStore;
27
51
  selectionColor: ColorRepresentation;
28
52
  selectionInteractionDisabled: boolean;
@@ -33,11 +57,18 @@ export type ViewerStore = {
33
57
  setDefaultHotkeysEnabled: (enabled: boolean) => void;
34
58
  setGridAxesVisibility: (gridAxesVisibility: Partial<ViewerGridAxesVisibility>) => void;
35
59
  setGridAxisVisibility: (side: ViewerGridAxisSide, visible: boolean) => void;
60
+ setAmbientLightColor: (color: ColorRepresentation) => void;
61
+ setAmbientLightIntensity: (intensity: number) => void;
62
+ setDirectionalLightColor: (color: ColorRepresentation) => void;
63
+ setDirectionalLightIntensity: (intensity: number) => void;
36
64
  setShowGridAxes: (visible: boolean) => void;
65
+ setLighting: (lighting: ViewerLightingSettingsUpdate) => void;
37
66
  setModelNames: (modelNames: ViewerModelNamesStore) => void;
38
67
  setModelProps: (modelProps: ViewerModelPropsStore) => void;
39
68
  setModelStructure: (modelStructure: ViewerModelStructureStore) => void;
40
69
  setPreselectionColor: (color: ColorRepresentation) => void;
70
+ setPostproductionActivePassFilter: (filter: ViewerPostproductionActivePassFilter | null) => void;
71
+ setPostproductionPassType: (type: ViewerPostproductionPassType) => void;
41
72
  setSelectionColor: (color: ColorRepresentation) => void;
42
73
  setSelectionInteractionDisabled: (disabled: boolean) => void;
43
74
  setShowNavCube: (showNavCube: boolean) => void;
package/lib/types.d.ts CHANGED
@@ -9,4 +9,5 @@ export type ViewerCameraRef = RefObject<Camera | null>;
9
9
  export type ViewerControlsRef = RefObject<CameraControlsImpl | null>;
10
10
  export type ViewerLightRef = RefObject<DirectionalLight | null>;
11
11
  export type ViewerMaterialMode = "quality" | "performance";
12
+ export type ViewerPostproductionPassType = "N8AO" | "SSAO" | null;
12
13
  export type ViewerUploadMode = "smooth" | "balanced" | "fast";
@@ -1,4 +1,4 @@
1
- import { BufferGeometry, Mesh, Plane } from "three";
1
+ import { BufferGeometry, Mesh, Plane, Vector3 } from "three";
2
2
  import type { ClippingUtils } from "./ClippingUtils";
3
3
  type CapPreselection = {
4
4
  elementID: number;
@@ -9,7 +9,6 @@ export declare class ClippingCaps {
9
9
  readonly plane: Plane;
10
10
  private readonly capMaterial;
11
11
  private readonly capMesh;
12
- private readonly capTexture;
13
12
  private readonly context;
14
13
  private readonly root;
15
14
  private readonly box;
@@ -19,9 +18,6 @@ export declare class ClippingCaps {
19
18
  private readonly tempLine;
20
19
  private readonly tempVector;
21
20
  private readonly tempVector1;
22
- private readonly tempAxisX;
23
- private readonly tempAxisY;
24
- private readonly tempAxisZ;
25
21
  private readonly worldPoint;
26
22
  private capClippingPlanesKey;
27
23
  private capShader;
@@ -34,11 +30,14 @@ export declare class ClippingCaps {
34
30
  setVisible(visible: boolean): void;
35
31
  syncMeshes(): void;
36
32
  getSelectableObject(): Mesh<BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, import("three").Material<import("three").MaterialEventMap> | import("three").Material<import("three").MaterialEventMap>[], import("three").Object3DEventMap>;
33
+ getSnapPoints(point: Vector3, distance: number): Vector3[];
37
34
  setPreselection(preselection: CapPreselection): void;
35
+ updateColors(): void;
38
36
  updateVisualState(): void;
39
37
  update(): void;
40
38
  private setupWebGpuCapMaterial;
41
39
  private setupCapMaterialShader;
40
+ private updateBaseMaterialColor;
42
41
  private updateColorUniform;
43
42
  private updateColorUniforms;
44
43
  private updatePreselectionUniforms;
@@ -56,8 +55,6 @@ export declare class ClippingCaps {
56
55
  private cleanContour;
57
56
  private triangulateContours;
58
57
  private pushContourVertex;
59
- private getHatchSpacing;
60
- private getModelHatchReferenceDirection;
61
58
  private getModelWorldBox;
62
59
  }
63
60
  export {};
@@ -1,4 +1,4 @@
1
- import { Camera, Material, Mesh, Object3D, Plane, Raycaster, Scene, Vector3, WebGLRenderer } from "three";
1
+ import { Camera, type ColorRepresentation, Material, Mesh, Object3D, Plane, Raycaster, Scene, Vector3, WebGLRenderer } from "three";
2
2
  import type { CameraUtilsApi } from "../../Camera/useCameraUtils";
3
3
  import type { ViewerStoreApi } from "../../store/ViewerStore";
4
4
  import type { ViewerControlsRef, ViewerModelRef } from "../../types";
@@ -27,12 +27,14 @@ export type ViewerClippingApi = {
27
27
  createPlane: (event?: MouseEvent | PointerEvent) => Plane | null;
28
28
  deleteAllPlanes: () => void;
29
29
  getCapsActive: () => boolean;
30
+ getCapsColor: () => ColorRepresentation;
30
31
  getEdgesActive: () => boolean;
31
32
  getHelpersActive: () => boolean;
32
33
  getPlanes: () => Plane[];
33
34
  getActive: () => boolean;
34
35
  setActive: (active: boolean) => void;
35
36
  setCapsActive: (active: boolean) => void;
37
+ setCapsColor: (color: ColorRepresentation) => void;
36
38
  setEdgesActive: (active: boolean) => void;
37
39
  setHelpersActive: (active: boolean) => void;
38
40
  toggle: () => void;
@@ -46,6 +48,8 @@ export declare class ClippingUtils {
46
48
  helpers: PlaneHelper[];
47
49
  private active;
48
50
  private capsActive;
51
+ private capsCameraMotionActive;
52
+ private capsColor;
49
53
  private context;
50
54
  private edgesActive;
51
55
  private helperDragActive;
@@ -60,6 +64,7 @@ export declare class ClippingUtils {
60
64
  getActive(): boolean;
61
65
  getEdgesActive(): boolean;
62
66
  getCapsActive(): boolean;
67
+ getCapsColor(): ColorRepresentation;
63
68
  getHelpersActive(): boolean;
64
69
  getPlanes(): Plane[];
65
70
  getScene(): Scene<import("three").Object3DEventMap>;
@@ -68,20 +73,21 @@ export declare class ClippingUtils {
68
73
  getDomElement(): HTMLCanvasElement;
69
74
  getRaycaster(): Raycaster;
70
75
  getUseWebGPU(): boolean;
71
- getMaxTextureAnisotropy(): number;
72
76
  getControlRef(): ViewerControlsRef;
73
77
  getMeshes(): Mesh<import("three").BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, Material<import("three").MaterialEventMap> | Material<import("three").MaterialEventMap>[], import("three").Object3DEventMap>[];
74
78
  getObjectModelID(object: Object3D): number;
75
79
  getEdgeSegmentsForPlane(plane: Plane): readonly ClippingIntersectionSegment[] | null;
76
80
  getSelectableObjects(): Mesh<import("three").BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, Material<import("three").MaterialEventMap> | Material<import("three").MaterialEventMap>[], import("three").Object3DEventMap>[];
81
+ getSnapPoints(point: Vector3, distance: number): Vector3[];
77
82
  getSelected(): import("../..").SelectedStore;
78
- getPreselectionColor(): import("three").ColorRepresentation;
79
- getSelectionColor(): import("three").ColorRepresentation;
83
+ getPreselectionColor(): ColorRepresentation;
84
+ getSelectionColor(): ColorRepresentation;
80
85
  setCapsPreselection(preselection: ClippingPreselection): void;
81
86
  updateCapsVisualState(): void;
82
87
  getHelperHoverIsMoving(): boolean;
83
88
  getHelperDragActive(): boolean;
84
89
  setHelperDragActive(active: boolean): void;
90
+ setCapsCameraMotionActive(active: boolean): void;
85
91
  setCapsDragActive(active: boolean): void;
86
92
  requestCapsDragIdleUpdate(): void;
87
93
  private clearCapsDragIdleTimeout;
@@ -102,6 +108,7 @@ export declare class ClippingUtils {
102
108
  deleteAllPlanes(): void;
103
109
  setHelpersActive(active: boolean): void;
104
110
  setCapsActive(active: boolean): void;
111
+ setCapsColor(color: ColorRepresentation): void;
105
112
  setEdgesActive(active: boolean): void;
106
113
  updateEdges(): void;
107
114
  flushEdgesUpdate(): void;
@@ -114,6 +121,8 @@ export declare class ClippingUtils {
114
121
  }
115
122
  export declare function useClippingUtils(modelRef: ViewerModelRef, controlRef: ViewerControlsRef, cameraUtils: CameraUtilsApi, useWebGPU?: boolean): ViewerClippingApi & {
116
123
  getSelectableObjects: () => Object3D[];
124
+ getSnapPoints: (point: Vector3, distance: number) => Vector3[];
125
+ setCapsCameraMotionActive: (active: boolean) => void;
117
126
  setCapsPreselection: (preselection: ClippingPreselection) => void;
118
127
  syncWithModel: () => void;
119
128
  };
@@ -1,4 +1,4 @@
1
- import { Color, ConeGeometry, Object3D, SphereGeometry, type Camera, type Scene } from "three";
1
+ import { Color, ConeGeometry, Object3D, SphereGeometry, Vector3, type Camera, type Scene } from "three";
2
2
  import { type CameraUtilsApi } from "../../Camera/useCameraUtils";
3
3
  import type { ViewerStoreApi } from "../../store/ViewerStore";
4
4
  import type { ViewerControlsRef, ViewerModelRef } from "../../types";
@@ -9,6 +9,7 @@ type DimensionsContext = {
9
9
  controlRef: ViewerControlsRef;
10
10
  domElement: HTMLCanvasElement;
11
11
  getExtraSnapObjects?: () => Object3D[];
12
+ getExtraSnapPoints?: (point: Vector3, distance: number) => Vector3[];
12
13
  modelRef: ViewerModelRef;
13
14
  scene: Scene;
14
15
  viewerStore: ViewerStoreApi;
@@ -78,6 +79,8 @@ export declare class DimensionsUtils {
78
79
  private getSnapObjects;
79
80
  private getModelHit;
80
81
  private getBoundingBoxes;
82
+ private getExtraSnapPoints;
83
+ private getClosestPoint;
81
84
  private getClosestVertex;
82
85
  private getPreviewEndPoint;
83
86
  private getNextAxis;
@@ -93,7 +96,7 @@ export declare class DimensionsUtils {
93
96
  static createEndpointGeometry(height?: number, radius?: number): ConeGeometry;
94
97
  static createPreviewGeometry(): SphereGeometry;
95
98
  }
96
- export declare function useDimensionsUtils(modelRef: ViewerModelRef, controlRef: ViewerControlsRef, cameraUtils: CameraUtilsApi, getExtraSnapObjects?: () => Object3D[]): ViewerDimensionsApi & {
99
+ export declare function useDimensionsUtils(modelRef: ViewerModelRef, controlRef: ViewerControlsRef, cameraUtils: CameraUtilsApi, getExtraSnapObjects?: () => Object3D[], getExtraSnapPoints?: (point: Vector3, distance: number) => Vector3[]): ViewerDimensionsApi & {
97
100
  syncWithModel: () => void;
98
101
  };
99
102
  export {};
package/package.json CHANGED
@@ -1,68 +1,68 @@
1
1
  {
2
- "name": "bimatter-viewer-react",
3
- "version": "0.7.0",
4
- "license": "PolyForm-Noncommercial-1.0.0",
5
- "type": "module",
6
- "main": "./lib/index.js",
7
- "module": "./lib/index.js",
8
- "types": "./lib/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./lib/index.d.ts",
12
- "import": "./lib/index.js"
2
+ "name": "bimatter-viewer-react",
3
+ "version": "0.7.2",
4
+ "license": "PolyForm-Noncommercial-1.0.0",
5
+ "type": "module",
6
+ "main": "./lib/index.js",
7
+ "module": "./lib/index.js",
8
+ "types": "./lib/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "import": "./lib/index.js"
13
+ },
14
+ "./ifc-parser.wasm": "./public/ifc-parser.wasm"
13
15
  },
14
- "./ifc-parser.wasm": "./public/ifc-parser.wasm"
15
- },
16
- "files": [
17
- "README.md",
18
- "LICENSE.md",
19
- "lib",
20
- "public/ifc-parser.wasm"
21
- ],
22
- "scripts": {
23
- "dev": "vite",
24
- "build": "tsc -b && vite build",
25
- "build:lib": "vite build -c vite.lib.config.ts && tsc -p tsconfig.lib.json",
26
- "lint": "eslint .",
27
- "prepublishOnly": "npm run build:lib",
28
- "preview": "vite preview"
29
- },
30
- "dependencies": {
31
- "@react-three/drei": "^10.7.7",
32
- "@react-three/fiber": "^9.6.1",
33
- "pako": "^2.1.0",
34
- "three": "^0.184.0",
35
- "three-mesh-bvh": "^0.9.9",
36
- "web-ifc": "^0.0.77",
37
- "zustand": "^5.0.13"
38
- },
39
- "peerDependencies": {
40
- "react": "^19.2.5",
41
- "react-dom": "^19.2.5"
42
- },
43
- "devDependencies": {
44
- "@eslint/js": "^10.0.1",
45
- "@loaders.gl/core": "^4.4.2",
46
- "@loaders.gl/las": "^4.4.2",
47
- "@math.gl/types": "^4.1.0",
48
- "@react-three/drei": "^10.7.7",
49
- "@react-three/fiber": "^9.6.1",
50
- "@types/node": "^24.12.2",
51
- "@types/pako": "^2.0.4",
52
- "@types/react": "^19.2.14",
53
- "@types/react-dom": "^19.2.3",
54
- "@vitejs/plugin-react": "^6.0.1",
55
- "eslint": "^10.2.1",
56
- "eslint-plugin-react-hooks": "^7.1.1",
57
- "eslint-plugin-react-refresh": "^0.5.2",
58
- "globals": "^17.5.0",
59
- "lil-gui": "^0.21.0",
60
- "react": "^19.2.5",
61
- "react-dom": "^19.2.5",
62
- "three": "^0.184.0",
63
- "three-mesh-bvh": "^0.9.9",
64
- "typescript": "~6.0.2",
65
- "typescript-eslint": "^8.58.2",
66
- "vite": "^8.0.10"
67
- }
16
+ "files": [
17
+ "README.md",
18
+ "LICENSE.md",
19
+ "lib",
20
+ "public/ifc-parser.wasm"
21
+ ],
22
+ "scripts": {
23
+ "dev": "vite",
24
+ "build": "tsc -b && vite build",
25
+ "build:lib": "vite build -c vite.lib.config.ts && tsc -p tsconfig.lib.json",
26
+ "lint": "eslint .",
27
+ "prepublishOnly": "npm run build:lib",
28
+ "preview": "vite preview"
29
+ },
30
+ "dependencies": {
31
+ "@react-three/drei": "^10.7.7",
32
+ "@react-three/fiber": "^9.6.1",
33
+ "@react-three/postprocessing": "^3.0.4",
34
+ "pako": "^2.1.0",
35
+ "postprocessing": "^6.39.1",
36
+ "three": "^0.184.0",
37
+ "three-mesh-bvh": "^0.9.9",
38
+ "web-ifc": "^0.0.77",
39
+ "zustand": "^5.0.13"
40
+ },
41
+ "peerDependencies": {
42
+ "react": "^19.2.5",
43
+ "react-dom": "^19.2.5"
44
+ },
45
+ "devDependencies": {
46
+ "@eslint/js": "^10.0.1",
47
+ "@loaders.gl/core": "^4.4.2",
48
+ "@loaders.gl/las": "^4.4.2",
49
+ "@math.gl/types": "^4.1.0",
50
+ "@react-three/drei": "^10.7.7",
51
+ "@react-three/fiber": "^9.6.1",
52
+ "@types/node": "^24.12.2",
53
+ "@types/pako": "^2.0.4",
54
+ "@types/react": "^19.2.14",
55
+ "@types/react-dom": "^19.2.3",
56
+ "@vitejs/plugin-react": "^6.0.1",
57
+ "eslint": "^10.2.1",
58
+ "eslint-plugin-react-hooks": "^7.1.1",
59
+ "eslint-plugin-react-refresh": "^0.5.2",
60
+ "globals": "^17.5.0",
61
+ "lil-gui": "^0.21.0",
62
+ "react": "^19.2.5",
63
+ "react-dom": "^19.2.5",
64
+ "typescript": "~6.0.2",
65
+ "typescript-eslint": "^8.58.2",
66
+ "vite": "^8.0.10"
67
+ }
68
68
  }