@inweb/viewer-visualize 26.9.10 → 26.10.0
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/dist/viewer-visualize.js +29 -5
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +29 -5
- package/dist/viewer-visualize.module.js.map +1 -1
- package/package.json +6 -6
- package/src/Viewer/Commands/ResetView.ts +1 -5
- package/src/Viewer/Draggers/Actions/OrbitAction.ts +48 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-visualize",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.10.0",
|
|
4
4
|
"description": "JavaScript library for rendering CAD and BIM files in a browser using VisualizeJS",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"docs": "typedoc"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@inweb/client": "~26.
|
|
33
|
-
"@inweb/eventemitter2": "~26.
|
|
34
|
-
"@inweb/markup": "~26.
|
|
35
|
-
"@inweb/viewer-core": "~26.
|
|
32
|
+
"@inweb/client": "~26.10.0",
|
|
33
|
+
"@inweb/eventemitter2": "~26.10.0",
|
|
34
|
+
"@inweb/markup": "~26.10.0",
|
|
35
|
+
"@inweb/viewer-core": "~26.10.0"
|
|
36
36
|
},
|
|
37
|
-
"visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/
|
|
37
|
+
"visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js"
|
|
38
38
|
}
|
|
@@ -22,13 +22,10 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Viewer } from "../Viewer";
|
|
25
|
-
import type { ResetComponent } from "../Components/ResetComponent";
|
|
26
25
|
|
|
27
26
|
export function resetView(viewer: Viewer): void {
|
|
28
27
|
if (!viewer.visualizeJs) return;
|
|
29
28
|
|
|
30
|
-
const reset = viewer.getComponent("ResetComponent") as ResetComponent;
|
|
31
|
-
|
|
32
29
|
viewer.executeCommand("setActiveDragger");
|
|
33
30
|
viewer.executeCommand("clearSlices");
|
|
34
31
|
viewer.executeCommand("clearOverlay");
|
|
@@ -37,8 +34,7 @@ export function resetView(viewer: Viewer): void {
|
|
|
37
34
|
viewer.executeCommand("showAll");
|
|
38
35
|
viewer.executeCommand("explode", 0);
|
|
39
36
|
viewer.executeCommand("zoomToExtents", true);
|
|
40
|
-
|
|
41
|
-
reset.resetCameraPosition();
|
|
37
|
+
viewer.executeCommand("k3DViewSW");
|
|
42
38
|
|
|
43
39
|
viewer.emit({ type: "resetview" });
|
|
44
40
|
}
|
|
@@ -121,7 +121,24 @@ export class OrbitAction {
|
|
|
121
121
|
const direct = pTarget.sub(pPosition);
|
|
122
122
|
const vDirect = direct.asVector();
|
|
123
123
|
|
|
124
|
+
// Protect against zero or near-zero vector when pTarget and pPosition are the same
|
|
125
|
+
if (vDirect.length() < 1e-10) {
|
|
126
|
+
// Return a default side vector (X axis) when direction is degenerate
|
|
127
|
+
const defaultSide = this.toVector(this._m_module.Vector3d.kXAxis);
|
|
128
|
+
this.deleteAll([direct, pUpV, pTarget, pPosition, vDirect]);
|
|
129
|
+
return defaultSide;
|
|
130
|
+
}
|
|
131
|
+
|
|
124
132
|
const vCross = pUpV.crossProduct(vDirect);
|
|
133
|
+
|
|
134
|
+
// Also protect against zero cross product (parallel vectors)
|
|
135
|
+
if (vCross.length() < 1e-10) {
|
|
136
|
+
// Return a default side vector when up and direction are parallel
|
|
137
|
+
const defaultSide = this.toVector(this._m_module.Vector3d.kXAxis);
|
|
138
|
+
this.deleteAll([direct, pUpV, pTarget, pPosition, vDirect, vCross]);
|
|
139
|
+
return defaultSide;
|
|
140
|
+
}
|
|
141
|
+
|
|
125
142
|
const sideVector = vCross.normalize();
|
|
126
143
|
|
|
127
144
|
this.deleteAll([direct, pUpV, pTarget, pPosition, vDirect, vCross]);
|
|
@@ -153,17 +170,31 @@ export class OrbitAction {
|
|
|
153
170
|
{
|
|
154
171
|
const pPoint = this.toPoint(viewParams.position);
|
|
155
172
|
const pTarget = this.toPoint(viewParams.target);
|
|
156
|
-
const pCenter = this.toPoint(this.m_viewCenter);
|
|
157
173
|
|
|
158
174
|
const pUp = pTarget.sub(pPoint);
|
|
159
175
|
const vUp = pUp.asVector();
|
|
160
176
|
|
|
177
|
+
// Protect against zero or near-zero vector when pPoint and pTarget are the same
|
|
178
|
+
if (vUp.length() < 1e-10) {
|
|
179
|
+
// Skip up vector calculation if points are too close
|
|
180
|
+
this.deleteAll([pPoint, pTarget, pUp, vUp]);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
161
184
|
const crossProduct = vUp.crossProduct(sideVector);
|
|
185
|
+
|
|
186
|
+
// Protect against zero cross product (parallel vectors)
|
|
187
|
+
if (crossProduct.length() < 1e-10) {
|
|
188
|
+
// Keep current up vector if cross product is degenerate
|
|
189
|
+
this.deleteAll([pPoint, pTarget, pUp, vUp, crossProduct]);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
162
193
|
const crossProductNormal = crossProduct.normalize();
|
|
163
194
|
|
|
164
195
|
viewParams.upVector = crossProductNormal.toArray();
|
|
165
196
|
|
|
166
|
-
this.deleteAll([pPoint, pTarget,
|
|
197
|
+
this.deleteAll([pPoint, pTarget, pUp, vUp, crossProduct, crossProductNormal]);
|
|
167
198
|
}
|
|
168
199
|
}
|
|
169
200
|
|
|
@@ -202,7 +233,22 @@ export class OrbitAction {
|
|
|
202
233
|
const pUp = pTarget.sub(pPoint);
|
|
203
234
|
const vUp = pUp.asVector();
|
|
204
235
|
|
|
236
|
+
// Protect against zero or near-zero vector when pPoint and pTarget are the same
|
|
237
|
+
if (vUp.length() < 1e-10) {
|
|
238
|
+
// Skip up vector calculation if points are too close
|
|
239
|
+
this.deleteAll([zAxis, pTarget, pPoint, side, pUp, vUp]);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
205
243
|
const cross = vUp.crossProduct(side);
|
|
244
|
+
|
|
245
|
+
// Protect against zero cross product (parallel vectors)
|
|
246
|
+
if (cross.length() < 1e-10) {
|
|
247
|
+
// Keep current up vector if cross product is degenerate
|
|
248
|
+
this.deleteAll([zAxis, pTarget, pPoint, side, pUp, vUp, cross]);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
206
252
|
const crossNormal = cross.normalize();
|
|
207
253
|
|
|
208
254
|
viewParams.upVector = crossNormal.toArray();
|