bimatter-viewer-react 0.6.3 → 0.6.5
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 +2 -0
- package/lib/Selector/useSelector.d.ts +7 -2
- package/lib/Viewer.d.ts +1 -0
- package/lib/index.js +1757 -1253
- package/lib/utils/ClippingUtils/ClippingCaps.d.ts +60 -0
- package/lib/utils/ClippingUtils/ClippingUtils.d.ts +28 -1
- package/lib/utils/ClippingUtils/PlaneHelper.d.ts +8 -0
- package/lib/utils/DimentionsUtils/DimentionsUtils.d.ts +5 -3
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BufferGeometry, Mesh, Plane } from "three";
|
|
2
|
+
import type { ClippingUtils } from "./ClippingUtils";
|
|
3
|
+
type CapPreselection = {
|
|
4
|
+
elementID: number;
|
|
5
|
+
modelID: number;
|
|
6
|
+
} | null;
|
|
7
|
+
export declare class ClippingCaps {
|
|
8
|
+
active: boolean;
|
|
9
|
+
readonly plane: Plane;
|
|
10
|
+
private readonly capMaterial;
|
|
11
|
+
private readonly capMesh;
|
|
12
|
+
private readonly capTexture;
|
|
13
|
+
private readonly context;
|
|
14
|
+
private readonly root;
|
|
15
|
+
private readonly box;
|
|
16
|
+
private readonly meshBox;
|
|
17
|
+
private readonly inverseMatrix;
|
|
18
|
+
private readonly localPlane;
|
|
19
|
+
private readonly tempLine;
|
|
20
|
+
private readonly tempVector;
|
|
21
|
+
private readonly tempVector1;
|
|
22
|
+
private readonly tempAxisX;
|
|
23
|
+
private readonly tempAxisY;
|
|
24
|
+
private readonly tempAxisZ;
|
|
25
|
+
private readonly worldPoint;
|
|
26
|
+
private capClippingPlanesKey;
|
|
27
|
+
private capShader;
|
|
28
|
+
private closeGapTolerance;
|
|
29
|
+
private preselection;
|
|
30
|
+
private tolerance;
|
|
31
|
+
constructor(context: ClippingUtils, plane: Plane);
|
|
32
|
+
dispose(): void;
|
|
33
|
+
setVisible(visible: boolean): void;
|
|
34
|
+
syncMeshes(): void;
|
|
35
|
+
getSelectableObject(): Mesh<BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, import("three").Material<import("three").MaterialEventMap> | import("three").Material<import("three").MaterialEventMap>[], import("three").Object3DEventMap>;
|
|
36
|
+
setPreselection(preselection: CapPreselection): void;
|
|
37
|
+
updateVisualState(): void;
|
|
38
|
+
update(): void;
|
|
39
|
+
private setupCapMaterialShader;
|
|
40
|
+
private updateColorUniform;
|
|
41
|
+
private updateColorUniforms;
|
|
42
|
+
private updatePreselectionUniforms;
|
|
43
|
+
private updateCapMaterial;
|
|
44
|
+
private createCapGeometry;
|
|
45
|
+
private getCapSegments;
|
|
46
|
+
private getTriangleElementID;
|
|
47
|
+
private getTriangleIntersections;
|
|
48
|
+
private getPlanePoint;
|
|
49
|
+
private getClosedContours;
|
|
50
|
+
private getElementClosedContours;
|
|
51
|
+
private walkContour;
|
|
52
|
+
private getNextContourKey;
|
|
53
|
+
private cleanContour;
|
|
54
|
+
private triangulateContours;
|
|
55
|
+
private pushContourVertex;
|
|
56
|
+
private getHatchSpacing;
|
|
57
|
+
private getModelHatchReferenceDirection;
|
|
58
|
+
private getModelWorldBox;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Camera, Material, Mesh, Plane, Raycaster, Scene, Vector3, WebGLRenderer } from "three";
|
|
1
|
+
import { Camera, 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";
|
|
5
|
+
import { ClippingCaps } from "./ClippingCaps";
|
|
5
6
|
import { ClippingEdges } from "./ClippingEdges";
|
|
6
7
|
import { PlaneHelper } from "./PlaneHelper";
|
|
7
8
|
type ClippingContext = {
|
|
@@ -15,15 +16,21 @@ type ClippingContext = {
|
|
|
15
16
|
scene: Scene;
|
|
16
17
|
viewerStore: ViewerStoreApi;
|
|
17
18
|
};
|
|
19
|
+
type ClippingPreselection = {
|
|
20
|
+
elementID: number;
|
|
21
|
+
modelID: number;
|
|
22
|
+
} | null;
|
|
18
23
|
export type ViewerClippingApi = {
|
|
19
24
|
createClippingRectangle: (selected?: boolean) => Plane[];
|
|
20
25
|
createPlane: (event?: MouseEvent | PointerEvent) => Plane | null;
|
|
21
26
|
deleteAllPlanes: () => void;
|
|
27
|
+
getCapsActive: () => boolean;
|
|
22
28
|
getEdgesActive: () => boolean;
|
|
23
29
|
getHelpersActive: () => boolean;
|
|
24
30
|
getPlanes: () => Plane[];
|
|
25
31
|
getActive: () => boolean;
|
|
26
32
|
setActive: (active: boolean) => void;
|
|
33
|
+
setCapsActive: (active: boolean) => void;
|
|
27
34
|
setEdgesActive: (active: boolean) => void;
|
|
28
35
|
setHelpersActive: (active: boolean) => void;
|
|
29
36
|
toggle: () => void;
|
|
@@ -32,20 +39,25 @@ export type ViewerClippingApi = {
|
|
|
32
39
|
};
|
|
33
40
|
export declare class ClippingUtils {
|
|
34
41
|
planes: Plane[];
|
|
42
|
+
caps: ClippingCaps[];
|
|
35
43
|
edges: ClippingEdges[];
|
|
36
44
|
helpers: PlaneHelper[];
|
|
37
45
|
private active;
|
|
46
|
+
private capsActive;
|
|
38
47
|
private context;
|
|
39
48
|
private edgesActive;
|
|
40
49
|
private helperDragActive;
|
|
41
50
|
private helpersActive;
|
|
42
51
|
private helperHoverMoveState;
|
|
52
|
+
private capsDragActive;
|
|
53
|
+
private capsDragIdleTimeout;
|
|
43
54
|
private updateEdgesFrame;
|
|
44
55
|
private updateHelpersFrame;
|
|
45
56
|
constructor(context: ClippingContext);
|
|
46
57
|
setContext(context: ClippingContext): void;
|
|
47
58
|
getActive(): boolean;
|
|
48
59
|
getEdgesActive(): boolean;
|
|
60
|
+
getCapsActive(): boolean;
|
|
49
61
|
getHelpersActive(): boolean;
|
|
50
62
|
getPlanes(): Plane[];
|
|
51
63
|
getScene(): Scene<import("three").Object3DEventMap>;
|
|
@@ -53,11 +65,21 @@ export declare class ClippingUtils {
|
|
|
53
65
|
getCameraUtils(): CameraUtilsApi;
|
|
54
66
|
getDomElement(): HTMLCanvasElement;
|
|
55
67
|
getRaycaster(): Raycaster;
|
|
68
|
+
getMaxTextureAnisotropy(): number;
|
|
56
69
|
getControlRef(): ViewerControlsRef;
|
|
57
70
|
getMeshes(): Mesh<import("three").BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, Material<import("three").MaterialEventMap> | Material<import("three").MaterialEventMap>[], import("three").Object3DEventMap>[];
|
|
71
|
+
getSelectableObjects(): Mesh<import("three").BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, Material<import("three").MaterialEventMap> | Material<import("three").MaterialEventMap>[], import("three").Object3DEventMap>[];
|
|
72
|
+
getSelected(): import("../..").SelectedStore;
|
|
73
|
+
getPreselectionColor(): import("three").ColorRepresentation;
|
|
74
|
+
getSelectionColor(): import("three").ColorRepresentation;
|
|
75
|
+
setCapsPreselection(preselection: ClippingPreselection): void;
|
|
76
|
+
updateCapsVisualState(): void;
|
|
58
77
|
getHelperHoverIsMoving(): boolean;
|
|
59
78
|
getHelperDragActive(): boolean;
|
|
60
79
|
setHelperDragActive(active: boolean): void;
|
|
80
|
+
setCapsDragActive(active: boolean): void;
|
|
81
|
+
requestCapsDragIdleUpdate(): void;
|
|
82
|
+
private clearCapsDragIdleTimeout;
|
|
61
83
|
clearHelpersHover(except?: PlaneHelper): void;
|
|
62
84
|
setHelperHoverMoveStart: () => void;
|
|
63
85
|
setHelperHoverMoveEnd: () => void;
|
|
@@ -74,8 +96,11 @@ export declare class ClippingUtils {
|
|
|
74
96
|
addPlane(plane: Plane, location: Vector3, normal: Vector3): void;
|
|
75
97
|
deleteAllPlanes(): void;
|
|
76
98
|
setHelpersActive(active: boolean): void;
|
|
99
|
+
setCapsActive(active: boolean): void;
|
|
77
100
|
setEdgesActive(active: boolean): void;
|
|
78
101
|
updateEdges(): void;
|
|
102
|
+
flushEdgesUpdate(): void;
|
|
103
|
+
updateCaps(): void;
|
|
79
104
|
updateHelpers(): void;
|
|
80
105
|
requestEdgesUpdate(): void;
|
|
81
106
|
requestHelpersUpdate(): void;
|
|
@@ -83,6 +108,8 @@ export declare class ClippingUtils {
|
|
|
83
108
|
dispose(): void;
|
|
84
109
|
}
|
|
85
110
|
export declare function useClippingUtils(modelRef: ViewerModelRef, controlRef: ViewerControlsRef, cameraUtils: CameraUtilsApi): ViewerClippingApi & {
|
|
111
|
+
getSelectableObjects: () => Object3D[];
|
|
112
|
+
setCapsPreselection: (preselection: ClippingPreselection) => void;
|
|
86
113
|
syncWithModel: () => void;
|
|
87
114
|
};
|
|
88
115
|
export {};
|
|
@@ -10,10 +10,12 @@ export declare class PlaneHelper extends Object3D {
|
|
|
10
10
|
private readonly border;
|
|
11
11
|
private readonly context;
|
|
12
12
|
private readonly location;
|
|
13
|
+
private readonly localHitPoint;
|
|
13
14
|
private readonly normal;
|
|
14
15
|
private readonly planeMesh;
|
|
15
16
|
private readonly pointer;
|
|
16
17
|
private layout;
|
|
18
|
+
private polygon;
|
|
17
19
|
private dragState;
|
|
18
20
|
private hovered;
|
|
19
21
|
private listenersActive;
|
|
@@ -28,9 +30,15 @@ export declare class PlaneHelper extends Object3D {
|
|
|
28
30
|
private updateBorderDash;
|
|
29
31
|
private addEventListeners;
|
|
30
32
|
private removeEventListeners;
|
|
33
|
+
private hasHelperPriority;
|
|
34
|
+
private stopHelperPriorityEvent;
|
|
31
35
|
private getPointerIntersection;
|
|
32
36
|
private getNearestHelperIntersection;
|
|
33
37
|
private hasModelIntersection;
|
|
38
|
+
private isPointerHitNearEdge;
|
|
39
|
+
private getEdgeInteractionWidth;
|
|
40
|
+
private getDragDistanceEpsilon;
|
|
41
|
+
private getPointToSegmentDistanceSquared;
|
|
34
42
|
private getPointerPointOnPlane;
|
|
35
43
|
private onPointerDown;
|
|
36
44
|
private onPointerMove;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Color, ConeGeometry, SphereGeometry, type Camera, type Scene } from "three";
|
|
2
|
-
import type
|
|
1
|
+
import { Color, ConeGeometry, Object3D, SphereGeometry, type Camera, type Scene } from "three";
|
|
2
|
+
import { type CameraUtilsApi } from "../../Camera/useCameraUtils";
|
|
3
3
|
import type { ViewerStoreApi } from "../../store/ViewerStore";
|
|
4
4
|
import type { ViewerControlsRef, ViewerModelRef } from "../../types";
|
|
5
5
|
import { DimensionLine, type DimensionUnit } from "./DimentionLine";
|
|
@@ -8,6 +8,7 @@ type DimensionsContext = {
|
|
|
8
8
|
cameraUtils: CameraUtilsApi;
|
|
9
9
|
controlRef: ViewerControlsRef;
|
|
10
10
|
domElement: HTMLCanvasElement;
|
|
11
|
+
getExtraSnapObjects?: () => Object3D[];
|
|
11
12
|
modelRef: ViewerModelRef;
|
|
12
13
|
scene: Scene;
|
|
13
14
|
viewerStore: ViewerStoreApi;
|
|
@@ -74,6 +75,7 @@ export declare class DimensionsUtils {
|
|
|
74
75
|
private drawPreview;
|
|
75
76
|
private drawEnd;
|
|
76
77
|
private createDimension;
|
|
78
|
+
private getSnapObjects;
|
|
77
79
|
private getModelHit;
|
|
78
80
|
private getBoundingBoxes;
|
|
79
81
|
private getClosestVertex;
|
|
@@ -91,7 +93,7 @@ export declare class DimensionsUtils {
|
|
|
91
93
|
static createEndpointGeometry(height?: number, radius?: number): ConeGeometry;
|
|
92
94
|
static createPreviewGeometry(): SphereGeometry;
|
|
93
95
|
}
|
|
94
|
-
export declare function useDimensionsUtils(modelRef: ViewerModelRef, controlRef: ViewerControlsRef, cameraUtils: CameraUtilsApi): ViewerDimensionsApi & {
|
|
96
|
+
export declare function useDimensionsUtils(modelRef: ViewerModelRef, controlRef: ViewerControlsRef, cameraUtils: CameraUtilsApi, getExtraSnapObjects?: () => Object3D[]): ViewerDimensionsApi & {
|
|
95
97
|
syncWithModel: () => void;
|
|
96
98
|
};
|
|
97
99
|
export {};
|