@inweb/client 25.2.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.
- package/LICENSE +20 -0
- package/README.md +70 -0
- package/dist/client.js +21126 -0
- package/dist/client.js.map +1 -0
- package/dist/client.min.js +1 -0
- package/dist/client.module.js +7151 -0
- package/dist/client.module.js.map +1 -0
- package/lib/Api/Assembly.d.ts +339 -0
- package/lib/Api/ClashTest.d.ts +176 -0
- package/lib/Api/Client.d.ts +452 -0
- package/lib/Api/ClientEvents.d.ts +29 -0
- package/lib/Api/File.d.ts +568 -0
- package/lib/Api/HttpClient.d.ts +13 -0
- package/lib/Api/IAssembly.d.ts +14 -0
- package/lib/Api/IFile.d.ts +46 -0
- package/lib/Api/IHttpClient.d.ts +11 -0
- package/lib/Api/IUser.d.ts +11 -0
- package/lib/Api/Job.d.ts +142 -0
- package/lib/Api/Member.d.ts +85 -0
- package/lib/Api/Model.d.ts +147 -0
- package/lib/Api/Permission.d.ts +93 -0
- package/lib/Api/Project.d.ts +247 -0
- package/lib/Api/Role.d.ts +82 -0
- package/lib/Api/User.d.ts +197 -0
- package/lib/Api/impl/FetchError.d.ts +18 -0
- package/lib/Api/impl/Utils.d.ts +33 -0
- package/lib/Api/impl/http.d.ts +67 -0
- package/lib/ConvetMath.d.ts +29 -0
- package/lib/Viewer/CanvasEvents.d.ts +2 -0
- package/lib/Viewer/Commands/ApplyModelTransform.d.ts +2 -0
- package/lib/Viewer/Commands/ClearMarkup.d.ts +2 -0
- package/lib/Viewer/Commands/ClearSlices.d.ts +2 -0
- package/lib/Viewer/Commands/CreatePreview.d.ts +2 -0
- package/lib/Viewer/Commands/Explode.d.ts +2 -0
- package/lib/Viewer/Commands/GetDefaultViewPositions.d.ts +2 -0
- package/lib/Viewer/Commands/GetModels.d.ts +2 -0
- package/lib/Viewer/Commands/GetSelected.d.ts +2 -0
- package/lib/Viewer/Commands/HideSelected.d.ts +2 -0
- package/lib/Viewer/Commands/IsolateSelected.d.ts +2 -0
- package/lib/Viewer/Commands/RegenerateAll.d.ts +2 -0
- package/lib/Viewer/Commands/ResetView.d.ts +2 -0
- package/lib/Viewer/Commands/SelectModel.d.ts +2 -0
- package/lib/Viewer/Commands/SetActiveDragger.d.ts +2 -0
- package/lib/Viewer/Commands/SetDefaultViewPosition.d.ts +2 -0
- package/lib/Viewer/Commands/SetMarkupColor.d.ts +2 -0
- package/lib/Viewer/Commands/SetSelected.d.ts +2 -0
- package/lib/Viewer/Commands/ShowAll.d.ts +2 -0
- package/lib/Viewer/Commands/Unselect.d.ts +2 -0
- package/lib/Viewer/Commands/ZoomToExtents.d.ts +2 -0
- package/lib/Viewer/Commands/ZoomToObjects.d.ts +2 -0
- package/lib/Viewer/Commands/ZoomToSelected.d.ts +2 -0
- package/lib/Viewer/Commands.d.ts +3 -0
- package/lib/Viewer/Draggers/Actions/OrbitAction.d.ts +22 -0
- package/lib/Viewer/Draggers/Actions/PanAction.d.ts +18 -0
- package/lib/Viewer/Draggers/Actions/ZoomAction.d.ts +8 -0
- package/lib/Viewer/Draggers/Common/Geometry.d.ts +115 -0
- package/lib/Viewer/Draggers/Common/GestureManager.d.ts +41 -0
- package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +54 -0
- package/lib/Viewer/Draggers/Common/OdaGeAction.d.ts +30 -0
- package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +31 -0
- package/lib/Viewer/Draggers/MeasureLineDragger/MeasureUtils.d.ts +20 -0
- package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +24 -0
- package/lib/Viewer/Draggers/OdBaseCuttingPlaneDragger.d.ts +27 -0
- package/lib/Viewer/Draggers/OdCuttingPlaneXAxisDragger.d.ts +8 -0
- package/lib/Viewer/Draggers/OdCuttingPlaneYAxisDragger.d.ts +8 -0
- package/lib/Viewer/Draggers/OdCuttingPlaneZAxisDragger.d.ts +8 -0
- package/lib/Viewer/Draggers/OdOrbitDragger.d.ts +15 -0
- package/lib/Viewer/Draggers/OdPanDragger.d.ts +12 -0
- package/lib/Viewer/Draggers/OdZoomDragger.d.ts +12 -0
- package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +11 -0
- package/lib/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.d.ts +19 -0
- package/lib/Viewer/Draggers/OdZoomWindowDragger/index.d.ts +14 -0
- package/lib/Viewer/Draggers/OdaLineDragger.d.ts +15 -0
- package/lib/Viewer/Draggers/OdaTextDragger.d.ts +16 -0
- package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +30 -0
- package/lib/Viewer/Draggers/OrbitAroundBuildingDragger.d.ts +19 -0
- package/lib/Viewer/EventEmitter2.d.ts +54 -0
- package/lib/Viewer/ICommands.d.ts +25 -0
- package/lib/Viewer/IEventEmitter2.d.ts +13 -0
- package/lib/Viewer/IViewer.d.ts +27 -0
- package/lib/Viewer/Loaders/BaseLoader.d.ts +11 -0
- package/lib/Viewer/Loaders/LoaderFactory.d.ts +10 -0
- package/lib/Viewer/Loaders/TCSLoader.d.ts +5 -0
- package/lib/Viewer/Loaders/UpdaterController.d.ts +15 -0
- package/lib/Viewer/Loaders/VsfXLoader.d.ts +5 -0
- package/lib/Viewer/Loaders/VsfXPartialLoader.d.ts +5 -0
- package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +12 -0
- package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +5 -0
- package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +15 -0
- package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +15 -0
- package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +11 -0
- package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +12 -0
- package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +15 -0
- package/lib/Viewer/Markup/Api/IMarkupText.d.ts +13 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +32 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +40 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +36 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +32 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +38 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +37 -0
- package/lib/Viewer/Markup/IMarkup.d.ts +38 -0
- package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +63 -0
- package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +19 -0
- package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +33 -0
- package/lib/Viewer/Markup/MarkupFactory.d.ts +7 -0
- package/lib/Viewer/Options.d.ts +228 -0
- package/lib/Viewer/OptionsEvents.d.ts +26 -0
- package/lib/Viewer/Viewer.d.ts +353 -0
- package/lib/Viewer/ViewerCommands.d.ts +23 -0
- package/lib/Viewer/ViewerEvents.d.ts +601 -0
- package/lib/Viewer/utils.d.ts +4 -0
- package/lib/index.d.ts +24 -0
- package/package.json +32 -0
- package/src/Api/Assembly.ts +678 -0
- package/src/Api/ClashTest.ts +290 -0
- package/src/Api/Client.ts +816 -0
- package/src/Api/ClientEvents.ts +31 -0
- package/src/Api/File.ts +962 -0
- package/src/Api/HttpClient.ts +73 -0
- package/src/Api/IAssembly.ts +37 -0
- package/src/Api/IFile.ts +74 -0
- package/src/Api/IHttpClient.ts +50 -0
- package/src/Api/IUser.ts +33 -0
- package/src/Api/Job.ts +253 -0
- package/src/Api/Member.ts +161 -0
- package/src/Api/Model.ts +259 -0
- package/src/Api/Permission.ts +173 -0
- package/src/Api/Project.ts +479 -0
- package/src/Api/Role.ts +158 -0
- package/src/Api/User.ts +357 -0
- package/src/Api/impl/FetchError.ts +48 -0
- package/src/Api/impl/Utils.ts +367 -0
- package/src/Api/impl/http.ts +92 -0
- package/src/ConvetMath.ts +372 -0
- package/src/Viewer/CanvasEvents.ts +41 -0
- package/src/Viewer/Commands/ApplyModelTransform.ts +70 -0
- package/src/Viewer/Commands/ClearMarkup.ts +28 -0
- package/src/Viewer/Commands/ClearSlices.ts +27 -0
- package/src/Viewer/Commands/CreatePreview.ts +33 -0
- package/src/Viewer/Commands/Explode.ts +38 -0
- package/src/Viewer/Commands/GetDefaultViewPositions.ts +36 -0
- package/src/Viewer/Commands/GetModels.ts +43 -0
- package/src/Viewer/Commands/GetSelected.ts +58 -0
- package/src/Viewer/Commands/HideSelected.ts +37 -0
- package/src/Viewer/Commands/IsolateSelected.ts +37 -0
- package/src/Viewer/Commands/RegenerateAll.ts +37 -0
- package/src/Viewer/Commands/ResetView.ts +43 -0
- package/src/Viewer/Commands/SelectModel.ts +52 -0
- package/src/Viewer/Commands/SetActiveDragger.ts +29 -0
- package/src/Viewer/Commands/SetDefaultViewPosition.ts +50 -0
- package/src/Viewer/Commands/SetMarkupColor.ts +29 -0
- package/src/Viewer/Commands/SetSelected.ts +47 -0
- package/src/Viewer/Commands/ShowAll.ts +37 -0
- package/src/Viewer/Commands/Unselect.ts +37 -0
- package/src/Viewer/Commands/ZoomToExtents.ts +43 -0
- package/src/Viewer/Commands/ZoomToObjects.ts +47 -0
- package/src/Viewer/Commands/ZoomToSelected.ts +39 -0
- package/src/Viewer/Commands.ts +81 -0
- package/src/Viewer/Draggers/Actions/OrbitAction.ts +250 -0
- package/src/Viewer/Draggers/Actions/PanAction.ts +102 -0
- package/src/Viewer/Draggers/Actions/ZoomAction.ts +45 -0
- package/src/Viewer/Draggers/Common/Geometry.ts +152 -0
- package/src/Viewer/Draggers/Common/GestureManager.ts +263 -0
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +270 -0
- package/src/Viewer/Draggers/Common/OdaGeAction.ts +146 -0
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +248 -0
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +182 -0
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +166 -0
- package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +182 -0
- package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +53 -0
- package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +53 -0
- package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +53 -0
- package/src/Viewer/Draggers/OdOrbitDragger.ts +70 -0
- package/src/Viewer/Draggers/OdPanDragger.ts +62 -0
- package/src/Viewer/Draggers/OdZoomDragger.ts +59 -0
- package/src/Viewer/Draggers/OdZoomWheelDragger.ts +103 -0
- package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +123 -0
- package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +75 -0
- package/src/Viewer/Draggers/OdaLineDragger.ts +80 -0
- package/src/Viewer/Draggers/OdaTextDragger.ts +118 -0
- package/src/Viewer/Draggers/OdaWalkDragger.ts +278 -0
- package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +184 -0
- package/src/Viewer/EventEmitter2.ts +116 -0
- package/src/Viewer/ICommands.ts +53 -0
- package/src/Viewer/IEventEmitter2.ts +36 -0
- package/src/Viewer/IViewer.ts +55 -0
- package/src/Viewer/Loaders/BaseLoader.ts +40 -0
- package/src/Viewer/Loaders/LoaderFactory.ts +44 -0
- package/src/Viewer/Loaders/TCSLoader.ts +82 -0
- package/src/Viewer/Loaders/UpdaterController.ts +36 -0
- package/src/Viewer/Loaders/VsfXLoader.ts +87 -0
- package/src/Viewer/Loaders/VsfXPartialLoader.ts +208 -0
- package/src/Viewer/Markup/Api/IMarkupArrow.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupColorable.ts +4 -0
- package/src/Viewer/Markup/Api/IMarkupEllipse.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupImage.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupLine.ts +10 -0
- package/src/Viewer/Markup/Api/IMarkupObject.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupRectangle.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupText.ts +12 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +119 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +113 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +121 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +99 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +113 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +104 -0
- package/src/Viewer/Markup/IMarkup.ts +39 -0
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +872 -0
- package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +39 -0
- package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +273 -0
- package/src/Viewer/Markup/MarkupFactory.ts +32 -0
- package/src/Viewer/Options.ts +502 -0
- package/src/Viewer/OptionsEvents.ts +28 -0
- package/src/Viewer/Viewer.ts +1109 -0
- package/src/Viewer/ViewerCommands.ts +45 -0
- package/src/Viewer/ViewerEvents.ts +700 -0
- package/src/Viewer/utils.ts +74 -0
- package/src/index.ts +48 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert world coordinates to screen normalized (-1, 1)
|
|
3
|
+
*
|
|
4
|
+
* @param viewMatrix Camera world matrix
|
|
5
|
+
* @param projectionMatrix Camera projection matrix
|
|
6
|
+
* @param worldPoint World point
|
|
7
|
+
*/
|
|
8
|
+
export function worldToScreenNormalized(
|
|
9
|
+
viewMatrix: Array<number>,
|
|
10
|
+
projectionMatrix: Array<number>,
|
|
11
|
+
worldPoint: [x: number, y: number, z: number]
|
|
12
|
+
): [x: number, y: number, z: number] {
|
|
13
|
+
function applyMatrixToPoint3(matrix, point: [x: number, y: number, z: number]): [x: number, y: number, z: number] {
|
|
14
|
+
const [x, y, z] = point;
|
|
15
|
+
const e = matrix;
|
|
16
|
+
const w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
|
|
17
|
+
|
|
18
|
+
return [
|
|
19
|
+
(e[0] * x + e[4] * y + e[8] * z + e[12]) * w,
|
|
20
|
+
(e[1] * x + e[5] * y + e[9] * z + e[13]) * w,
|
|
21
|
+
(e[2] * x + e[6] * y + e[10] * z + e[14]) * w,
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const [x, y, z] = applyMatrixToPoint3(projectionMatrix, applyMatrixToPoint3(invertMatrix(viewMatrix), worldPoint));
|
|
26
|
+
|
|
27
|
+
return [x, y, z];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function multiplyMatrices(a: Array<number>, b: Array<number>): Array<number> {
|
|
31
|
+
const ae = a;
|
|
32
|
+
const be = b;
|
|
33
|
+
const te = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
34
|
+
|
|
35
|
+
const a11 = ae[0],
|
|
36
|
+
a12 = ae[4],
|
|
37
|
+
a13 = ae[8],
|
|
38
|
+
a14 = ae[12];
|
|
39
|
+
const a21 = ae[1],
|
|
40
|
+
a22 = ae[5],
|
|
41
|
+
a23 = ae[9],
|
|
42
|
+
a24 = ae[13];
|
|
43
|
+
const a31 = ae[2],
|
|
44
|
+
a32 = ae[6],
|
|
45
|
+
a33 = ae[10],
|
|
46
|
+
a34 = ae[14];
|
|
47
|
+
const a41 = ae[3],
|
|
48
|
+
a42 = ae[7],
|
|
49
|
+
a43 = ae[11],
|
|
50
|
+
a44 = ae[15];
|
|
51
|
+
|
|
52
|
+
const b11 = be[0],
|
|
53
|
+
b12 = be[4],
|
|
54
|
+
b13 = be[8],
|
|
55
|
+
b14 = be[12];
|
|
56
|
+
const b21 = be[1],
|
|
57
|
+
b22 = be[5],
|
|
58
|
+
b23 = be[9],
|
|
59
|
+
b24 = be[13];
|
|
60
|
+
const b31 = be[2],
|
|
61
|
+
b32 = be[6],
|
|
62
|
+
b33 = be[10],
|
|
63
|
+
b34 = be[14];
|
|
64
|
+
const b41 = be[3],
|
|
65
|
+
b42 = be[7],
|
|
66
|
+
b43 = be[11],
|
|
67
|
+
b44 = be[15];
|
|
68
|
+
|
|
69
|
+
te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
|
|
70
|
+
te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
|
|
71
|
+
te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
|
|
72
|
+
te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
|
|
73
|
+
|
|
74
|
+
te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
|
|
75
|
+
te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
|
|
76
|
+
te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
|
|
77
|
+
te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
|
|
78
|
+
|
|
79
|
+
te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
|
|
80
|
+
te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
|
|
81
|
+
te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
|
|
82
|
+
te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
|
|
83
|
+
|
|
84
|
+
te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
|
|
85
|
+
te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
|
|
86
|
+
te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
|
|
87
|
+
te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
|
|
88
|
+
|
|
89
|
+
return te;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param matrix
|
|
94
|
+
* @returns Matrix
|
|
95
|
+
*/
|
|
96
|
+
export function invertMatrix(matrix: Array<number>): Array<number> {
|
|
97
|
+
const te = matrix,
|
|
98
|
+
n11 = te[0],
|
|
99
|
+
n21 = te[1],
|
|
100
|
+
n31 = te[2],
|
|
101
|
+
n41 = te[3],
|
|
102
|
+
n12 = te[4],
|
|
103
|
+
n22 = te[5],
|
|
104
|
+
n32 = te[6],
|
|
105
|
+
n42 = te[7],
|
|
106
|
+
n13 = te[8],
|
|
107
|
+
n23 = te[9],
|
|
108
|
+
n33 = te[10],
|
|
109
|
+
n43 = te[11],
|
|
110
|
+
n14 = te[12],
|
|
111
|
+
n24 = te[13],
|
|
112
|
+
n34 = te[14],
|
|
113
|
+
n44 = te[15],
|
|
114
|
+
t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
|
|
115
|
+
t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
|
|
116
|
+
t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
|
|
117
|
+
t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
|
|
118
|
+
|
|
119
|
+
const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
|
|
120
|
+
|
|
121
|
+
if (det === 0) return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
122
|
+
|
|
123
|
+
const detInv = 1 / det;
|
|
124
|
+
|
|
125
|
+
return [
|
|
126
|
+
t11 * detInv,
|
|
127
|
+
(n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) *
|
|
128
|
+
detInv,
|
|
129
|
+
(n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) *
|
|
130
|
+
detInv,
|
|
131
|
+
(n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) *
|
|
132
|
+
detInv,
|
|
133
|
+
|
|
134
|
+
t12 * detInv,
|
|
135
|
+
(n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) *
|
|
136
|
+
detInv,
|
|
137
|
+
(n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) *
|
|
138
|
+
detInv,
|
|
139
|
+
(n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) *
|
|
140
|
+
detInv,
|
|
141
|
+
|
|
142
|
+
t13 * detInv,
|
|
143
|
+
(n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) *
|
|
144
|
+
detInv,
|
|
145
|
+
(n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) *
|
|
146
|
+
detInv,
|
|
147
|
+
(n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) *
|
|
148
|
+
detInv,
|
|
149
|
+
|
|
150
|
+
t14 * detInv,
|
|
151
|
+
(n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) *
|
|
152
|
+
detInv,
|
|
153
|
+
(n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) *
|
|
154
|
+
detInv,
|
|
155
|
+
(n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) *
|
|
156
|
+
detInv,
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Convert world coordinates to screen (screenWidth, screenHeight)
|
|
162
|
+
*
|
|
163
|
+
* @param viewMatrix Camera world matrix
|
|
164
|
+
* @param projectionMatrix Camera projection matrix
|
|
165
|
+
* @param worldPoint World point
|
|
166
|
+
* @param screenWidth Screen width
|
|
167
|
+
* @param screenHeight Screen height
|
|
168
|
+
*/
|
|
169
|
+
export function worldToScreen(
|
|
170
|
+
viewMatrix: Array<number>,
|
|
171
|
+
projectionMatrix: Array<number>,
|
|
172
|
+
worldPoint: [x: number, y: number, z: number],
|
|
173
|
+
screenWidth: number,
|
|
174
|
+
screenHeight: number
|
|
175
|
+
) {
|
|
176
|
+
const widthHalf = screenWidth / 2;
|
|
177
|
+
const heightHalf = screenHeight / 2;
|
|
178
|
+
|
|
179
|
+
const [x, y] = worldToScreenNormalized(viewMatrix, projectionMatrix, worldPoint);
|
|
180
|
+
const p = [x * widthHalf + widthHalf, -(y * heightHalf) + heightHalf];
|
|
181
|
+
return p;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @param a
|
|
186
|
+
* @returns
|
|
187
|
+
*/
|
|
188
|
+
function lengthVector(a: { x: number; y: number; z: number }): number {
|
|
189
|
+
return Math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
|
|
190
|
+
}
|
|
191
|
+
function normalizeVector(a: { x: number; y: number; z: number }): { x: number; y: number; z: number } {
|
|
192
|
+
const len = lengthVector(a);
|
|
193
|
+
if (len === 0) return a;
|
|
194
|
+
return {
|
|
195
|
+
x: a.x / len,
|
|
196
|
+
y: a.y / len,
|
|
197
|
+
z: a.z / len,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function crossVectors(a, b) {
|
|
202
|
+
const ax = a.x,
|
|
203
|
+
ay = a.y,
|
|
204
|
+
az = a.z;
|
|
205
|
+
const bx = b.x,
|
|
206
|
+
by = b.y,
|
|
207
|
+
bz = b.z;
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
x: ay * bz - az * by,
|
|
211
|
+
y: az * bx - ax * bz,
|
|
212
|
+
z: ax * by - ay * bx,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function normalizedProjection(
|
|
217
|
+
width,
|
|
218
|
+
height,
|
|
219
|
+
nearClipPlaneDist,
|
|
220
|
+
farClipPlaneDist,
|
|
221
|
+
normalizedCenter,
|
|
222
|
+
normalizedWidth,
|
|
223
|
+
normalizedHeight,
|
|
224
|
+
normalizedDepth
|
|
225
|
+
) {
|
|
226
|
+
const mtx = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
227
|
+
|
|
228
|
+
mtx[0] = -normalizedWidth / width;
|
|
229
|
+
mtx[1] = 0;
|
|
230
|
+
mtx[2] = 0.0;
|
|
231
|
+
mtx[3] = normalizedCenter.x;
|
|
232
|
+
|
|
233
|
+
mtx[4] = 0.0;
|
|
234
|
+
mtx[5] = -normalizedHeight / height;
|
|
235
|
+
mtx[6] = 0.0;
|
|
236
|
+
mtx[7] = normalizedCenter.y;
|
|
237
|
+
|
|
238
|
+
mtx[8] = 0;
|
|
239
|
+
mtx[9] = 0.0;
|
|
240
|
+
mtx[10] = normalizedDepth / (farClipPlaneDist - nearClipPlaneDist);
|
|
241
|
+
mtx[11] = -mtx[10] * nearClipPlaneDist;
|
|
242
|
+
|
|
243
|
+
mtx[12] = mtx[13] = mtx[14] = 0.0;
|
|
244
|
+
mtx[15] = 1.0;
|
|
245
|
+
|
|
246
|
+
return mtx;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function createOrthoProjectionMatrix(camera, width, height) {
|
|
250
|
+
const nearClipPlaneDist = 0.1;
|
|
251
|
+
const farClipPlaneDist = 1000;
|
|
252
|
+
const fieldWidth = camera.field_width;
|
|
253
|
+
const fieldHeight = camera.field_height;
|
|
254
|
+
let viewportNormalizedWidth = 2;
|
|
255
|
+
let viewportNormalizedHeight = 2;
|
|
256
|
+
|
|
257
|
+
if (width > height) {
|
|
258
|
+
const aspect = height / width;
|
|
259
|
+
const aspectFiled = fieldHeight / fieldWidth;
|
|
260
|
+
viewportNormalizedWidth = (2 / aspectFiled) * aspect;
|
|
261
|
+
viewportNormalizedHeight = 2;
|
|
262
|
+
} else {
|
|
263
|
+
const aspect = width / height;
|
|
264
|
+
const aspectFiled = fieldWidth / fieldHeight;
|
|
265
|
+
viewportNormalizedWidth = 2;
|
|
266
|
+
viewportNormalizedHeight = (2 / aspectFiled) * aspect;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const viewportNormalizedCenter = {
|
|
270
|
+
x: 0,
|
|
271
|
+
y: 0,
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const projectionMatrix = normalizedProjection(
|
|
275
|
+
fieldWidth,
|
|
276
|
+
fieldHeight,
|
|
277
|
+
nearClipPlaneDist,
|
|
278
|
+
farClipPlaneDist,
|
|
279
|
+
viewportNormalizedCenter,
|
|
280
|
+
viewportNormalizedWidth,
|
|
281
|
+
viewportNormalizedHeight,
|
|
282
|
+
1.0
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
return projectionMatrix;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function createViewMatrix(camera) {
|
|
289
|
+
const position = camera.view_point;
|
|
290
|
+
|
|
291
|
+
const viewMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, position.x, position.y, position.z, 1];
|
|
292
|
+
|
|
293
|
+
const target = addVectors(camera.direction, position);
|
|
294
|
+
|
|
295
|
+
matrixLookAt(viewMatrix, position, target, camera.up_vector);
|
|
296
|
+
|
|
297
|
+
return viewMatrix;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function bcfWorldToScreenFromCamera(
|
|
301
|
+
camera,
|
|
302
|
+
canvas: HTMLCanvasElement,
|
|
303
|
+
point: [x: number, y: number, z: number]
|
|
304
|
+
) {
|
|
305
|
+
const { width, height } = canvas;
|
|
306
|
+
|
|
307
|
+
if (lengthVector(camera.direction) >= 1.0001) {
|
|
308
|
+
camera = {
|
|
309
|
+
...camera,
|
|
310
|
+
direction: normalizeVector(subVectors(camera.direction, camera.view_point)),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const projectionMatrix = createOrthoProjectionMatrix(camera, width, height);
|
|
315
|
+
const viewMatrix = createViewMatrix(camera);
|
|
316
|
+
|
|
317
|
+
return worldToScreen(viewMatrix, projectionMatrix, point, width, height);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function subVectors(
|
|
321
|
+
a: { x: number; y: number; z: number },
|
|
322
|
+
b: { x: number; y: number; z: number }
|
|
323
|
+
): { x: number; y: number; z: number } {
|
|
324
|
+
return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function addVectors(
|
|
328
|
+
a: { x: number; y: number; z: number },
|
|
329
|
+
b: { x: number; y: number; z: number }
|
|
330
|
+
): { x: number; y: number; z: number } {
|
|
331
|
+
return { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function matrixLookAt(matrix, eye, target, up) {
|
|
335
|
+
let z = subVectors(eye, target);
|
|
336
|
+
|
|
337
|
+
if (lengthVector(z) === 0) {
|
|
338
|
+
z.z = 1;
|
|
339
|
+
}
|
|
340
|
+
z = normalizeVector(z);
|
|
341
|
+
|
|
342
|
+
let x = crossVectors(z, up);
|
|
343
|
+
if (lengthVector(x) === 0) {
|
|
344
|
+
if (Math.abs(up.z) === 1) {
|
|
345
|
+
z.x += 0.0001;
|
|
346
|
+
} else {
|
|
347
|
+
z.z += 0.0001;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
z = normalizeVector(z);
|
|
351
|
+
|
|
352
|
+
x = crossVectors(up, z);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
x = normalizeVector(x);
|
|
356
|
+
|
|
357
|
+
const y = crossVectors(z, x);
|
|
358
|
+
|
|
359
|
+
const m = matrix;
|
|
360
|
+
|
|
361
|
+
m[0] = x.x;
|
|
362
|
+
m[4] = y.x;
|
|
363
|
+
m[8] = z.x;
|
|
364
|
+
m[1] = x.y;
|
|
365
|
+
m[5] = y.y;
|
|
366
|
+
m[9] = z.y;
|
|
367
|
+
m[2] = x.z;
|
|
368
|
+
m[6] = y.z;
|
|
369
|
+
m[10] = z.z;
|
|
370
|
+
|
|
371
|
+
return m;
|
|
372
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
export const CANVAS_EVENTS = [
|
|
25
|
+
"click",
|
|
26
|
+
"dblclick",
|
|
27
|
+
"mousedown",
|
|
28
|
+
"mousemove",
|
|
29
|
+
"mouseup",
|
|
30
|
+
"mouseleave",
|
|
31
|
+
"pointerdown",
|
|
32
|
+
"pointermove",
|
|
33
|
+
"pointerup",
|
|
34
|
+
"pointerleave",
|
|
35
|
+
"pointercancel",
|
|
36
|
+
"wheel",
|
|
37
|
+
"touchstart",
|
|
38
|
+
"touchmove",
|
|
39
|
+
"touchend",
|
|
40
|
+
"touchcancel",
|
|
41
|
+
];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { Viewer } from "../Viewer";
|
|
25
|
+
import { commands } from "../Commands";
|
|
26
|
+
import { Model } from "../../Api/Model";
|
|
27
|
+
import { Assembly } from "../../Api/Assembly";
|
|
28
|
+
|
|
29
|
+
export const composeMatrixFromTransform = (translate, rotate, scale, modelCenter, matrix) => {
|
|
30
|
+
const translateMatrix = matrix.setTranslation([translate.x, translate.y, translate.z]);
|
|
31
|
+
const rotateMatrix = matrix.setToRotation(rotate.angle, [rotate.x, rotate.y, rotate.z], modelCenter);
|
|
32
|
+
const scaleMatrix = matrix.setToScaling(scale, modelCenter);
|
|
33
|
+
return translateMatrix.postMultBy(rotateMatrix).postMultBy(scaleMatrix);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function applyModelTransform(viewer: Viewer, model: Model | File | Assembly) {
|
|
37
|
+
if (!viewer.visualizeJs) return;
|
|
38
|
+
|
|
39
|
+
const assembly = model instanceof Model ? model.assembly : model;
|
|
40
|
+
if (!(assembly instanceof Assembly)) return;
|
|
41
|
+
|
|
42
|
+
const visLib = viewer.visLib();
|
|
43
|
+
const visViewer = visLib.getViewer();
|
|
44
|
+
|
|
45
|
+
const modelItr = visViewer.getModelIterator();
|
|
46
|
+
for (; !modelItr.done(); modelItr.step()) {
|
|
47
|
+
const modelPtr = modelItr.getModel();
|
|
48
|
+
|
|
49
|
+
const transform = assembly.getModelTransformMatrix(modelPtr.getDatabaseHandle());
|
|
50
|
+
if (transform) {
|
|
51
|
+
const extents = modelPtr.getExtents();
|
|
52
|
+
const matrix = composeMatrixFromTransform(
|
|
53
|
+
transform.translate,
|
|
54
|
+
transform.rotation,
|
|
55
|
+
transform.scale,
|
|
56
|
+
extents.center(),
|
|
57
|
+
new visLib.Matrix3d()
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
modelPtr.setModelingMatrix(matrix, true);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
modelItr.delete();
|
|
64
|
+
|
|
65
|
+
visViewer.clearViewExtentsCache?.();
|
|
66
|
+
|
|
67
|
+
viewer.update();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
commands("VisualizeJS").registerCommand("applyModelTransform", applyModelTransform);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { Viewer } from "../Viewer";
|
|
25
|
+
import { commands } from "../Commands";
|
|
26
|
+
|
|
27
|
+
commands("VisualizeJS").registerCommand("clearMarkup", (viewer: Viewer) => viewer.clearOverlay());
|
|
28
|
+
commands("VisualizeJS").registerCommandAlias("clearMarkup", "clearOverlay");
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { Viewer } from "../Viewer";
|
|
25
|
+
import { commands } from "../Commands";
|
|
26
|
+
|
|
27
|
+
commands("VisualizeJS").registerCommand("clearSlices", (viewer: Viewer) => viewer.clearSlices());
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { Viewer } from "../Viewer";
|
|
25
|
+
import { commands } from "../Commands";
|
|
26
|
+
|
|
27
|
+
function createPreview(viewer: Viewer, type = "image/jpeg", encoderOptions = 0.25): string {
|
|
28
|
+
if (!viewer.visualizeJs) return "";
|
|
29
|
+
|
|
30
|
+
return viewer.canvas?.toDataURL(type, encoderOptions) || "";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
commands("VisualizeJS").registerCommand("createPreview", createPreview);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { Viewer } from "../Viewer";
|
|
25
|
+
import { commands } from "../Commands";
|
|
26
|
+
|
|
27
|
+
function explode(viewer: Viewer, index = 0): void {
|
|
28
|
+
if (!viewer.visualizeJs) return;
|
|
29
|
+
|
|
30
|
+
const visViewer = viewer.visViewer();
|
|
31
|
+
visViewer.explode(index);
|
|
32
|
+
|
|
33
|
+
viewer.update();
|
|
34
|
+
viewer.emit({ type: "explode", data: index });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
commands("VisualizeJS").registerCommand("explode", explode);
|
|
38
|
+
commands("VisualizeJS").registerCommand("collect", (viewer: any) => explode(viewer, 0));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { Viewer } from "../Viewer";
|
|
25
|
+
import { commands } from "../Commands";
|
|
26
|
+
|
|
27
|
+
function getDefaultViewPositions(viewer: Viewer): string[] {
|
|
28
|
+
if (!viewer.visualizeJs) return [];
|
|
29
|
+
|
|
30
|
+
const visLib = viewer.visLib();
|
|
31
|
+
|
|
32
|
+
const defViewPos = visLib.DefaultViewPosition;
|
|
33
|
+
return Object.keys(defViewPos).filter((x) => x !== "values");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
commands("VisualizeJS").registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|