@inweb/viewer-visualize 26.9.10 → 26.10.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/viewer-visualize",
3
- "version": "26.9.10",
3
+ "version": "26.10.1",
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.9.10",
33
- "@inweb/eventemitter2": "~26.9.10",
34
- "@inweb/markup": "~26.9.10",
35
- "@inweb/viewer-core": "~26.9.10"
32
+ "@inweb/client": "~26.10.1",
33
+ "@inweb/eventemitter2": "~26.10.1",
34
+ "@inweb/markup": "~26.10.1",
35
+ "@inweb/viewer-core": "~26.10.1"
36
36
  },
37
- "visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/26.9/Visualize.js"
37
+ "visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js"
38
38
  }
@@ -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, pCenter, pUp, vUp, crossProduct, crossProductNormal]);
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();