@xeokit/xeokit-sdk 2.6.58 → 2.6.59

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": "@xeokit/xeokit-sdk",
3
- "version": "2.6.58",
3
+ "version": "2.6.59",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -14,6 +14,7 @@ const tmpVec4a = math.vec4();
14
14
  const tmpVec4b = math.vec4();
15
15
  const tmpVec4c = math.vec4();
16
16
  const tmpVec4d = math.vec4();
17
+ const tmpMat4 = math.mat4();
17
18
 
18
19
  const nop = () => { };
19
20
 
@@ -25,6 +26,15 @@ export function transformToNode(from, to, vec) {
25
26
  };
26
27
 
27
28
  const toClipSpace = (camera, worldPos, p) => {
29
+ // The reason the projMatrix is explicitely fetched as below is a complex callback chain
30
+ // leading from a boundary update to a viewMatrix and projMatrix updates, which change their values
31
+ // in the mid of the toClipSpace, leading to incorrect values.
32
+ // The fetch ensures that matrix values are stabilized before used to transform worldPos to p.
33
+ // Better solution would be to ensure that no mutually-triggered callbacks
34
+ // (like boundary => view/projMatrix in this situation) ever happen, so user code can rely
35
+ // on a callback running in a stable context.
36
+ tmpMat4.set(camera.viewMatrix);
37
+ tmpMat4.set(camera.projMatrix);
28
38
  // to homogeneous coords
29
39
  p.set(worldPos);
30
40
  p[3] = 1;
@@ -227,7 +227,7 @@ class MetaModel {
227
227
  this.metaScene.metaObjects[id] = metaObject;
228
228
  metaObject.metaModels = [];
229
229
  }
230
- this.metaObjects[id] =metaObject;
230
+ this.metaObjects[id] = metaObject;
231
231
  if (!metaObjectData.parent) {
232
232
  this.rootMetaObjects.push(metaObject);
233
233
  metaScene.rootMetaObjects[id] = metaObject;
@@ -185,13 +185,12 @@ class MetaScene {
185
185
  // Remove MetaObjects
186
186
 
187
187
  if (metaModel.metaObjects) {
188
- for (let i = 0, len = metaModel.metaObjects.length; i < len; i++) {
189
- const metaObject = metaModel.metaObjects[i];
190
- const id = metaObject.id;
188
+ for (let objectId in metaModel.metaObjects) {
189
+ const metaObject = metaModel.metaObjects[objectId];
191
190
  if (metaObject.metaModels.length === 1 && metaObject.metaModels[0].id === metaModelId) { // MetaObject owned only by this model, delete
192
- delete this.metaObjects[id];
191
+ delete this.metaObjects[objectId];
193
192
  if (!metaObject.parent) {
194
- delete this.rootMetaObjects[id];
193
+ delete this.rootMetaObjects[objectId];
195
194
  }
196
195
  } else {
197
196
  metaObject.metaModels = metaObject.metaModels.filter(metaModel => metaModel.id !== metaModelId);