@crystaldesign/real-time-viewer 26.2.0-rc.9 → 26.2.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.
@@ -3274,7 +3274,7 @@ function _findAssets() {
3274
3274
  case 0:
3275
3275
  _importGeo = function _importGeo3() {
3276
3276
  _importGeo = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(geo, path) {
3277
- var geoCached, size, result, mesh, _sceneStore$onMissing;
3277
+ var geoCached, cachedGeos, unusedGeos, geoCountToDelete, nextToDelete, size, result, mesh, _sceneStore$onMissing;
3278
3278
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
3279
3279
  while (1) switch (_context2.prev = _context2.next) {
3280
3280
  case 0:
@@ -3291,11 +3291,31 @@ function _findAssets() {
3291
3291
  };
3292
3292
  return _context2.abrupt("return", geoCached);
3293
3293
  case 4:
3294
+ // cache max size otherwise some devices crash (ram to high)
3295
+ cachedGeos = cacheGroup.getChildren(undefined, true);
3296
+ if (cachedGeos.length > 10) {
3297
+ // find unused geos
3298
+ unusedGeos = cachedGeos.filter(function (g) {
3299
+ return !cache.find(function (c) {
3300
+ var _c$geo;
3301
+ return ((_c$geo = c.geo) === null || _c$geo === void 0 ? void 0 : _c$geo.geometry.uniqueId) == g.uniqueId;
3302
+ });
3303
+ });
3304
+ geoCountToDelete = cachedGeos.length - 10;
3305
+ while (geoCountToDelete > 0 && unusedGeos.length > 0) {
3306
+ nextToDelete = unusedGeos.reduce(function (oIdx, cur, curIdx, ar) {
3307
+ return cur.metadata.lastUsed < ar[oIdx].metadata.lastUsed ? curIdx : oIdx;
3308
+ }, 0);
3309
+ unusedGeos[nextToDelete].dispose();
3310
+ unusedGeos.splice(nextToDelete, 1);
3311
+ geoCountToDelete--;
3312
+ }
3313
+ }
3294
3314
  size = 0;
3295
- _context2.prev = 5;
3296
- _context2.next = 8;
3315
+ _context2.prev = 7;
3316
+ _context2.next = 10;
3297
3317
  return loadAssetContainerAsync(path + geo.name + '.glb', sceneStore.scene);
3298
- case 8:
3318
+ case 10:
3299
3319
  result = _context2.sent;
3300
3320
  utilStore.setAnalyzeDataRow({
3301
3321
  name: geo.name,
@@ -3317,9 +3337,9 @@ function _findAssets() {
3317
3337
  lastUsed: Date.now()
3318
3338
  };
3319
3339
  return _context2.abrupt("return", mesh);
3320
- case 22:
3321
- _context2.prev = 22;
3322
- _context2.t0 = _context2["catch"](5);
3340
+ case 24:
3341
+ _context2.prev = 24;
3342
+ _context2.t0 = _context2["catch"](7);
3323
3343
  (_sceneStore$onMissing = sceneStore.onMissingGeo) === null || _sceneStore$onMissing === void 0 || _sceneStore$onMissing.call(sceneStore);
3324
3344
  utilStore.setAnalyzeDataRow({
3325
3345
  name: geo.name,
@@ -3330,11 +3350,11 @@ function _findAssets() {
3330
3350
  found: false
3331
3351
  });
3332
3352
  return _context2.abrupt("return", undefined);
3333
- case 27:
3353
+ case 29:
3334
3354
  case "end":
3335
3355
  return _context2.stop();
3336
3356
  }
3337
- }, _callee2, null, [[5, 22]]);
3357
+ }, _callee2, null, [[7, 24]]);
3338
3358
  }));
3339
3359
  return _importGeo.apply(this, arguments);
3340
3360
  };
@@ -3801,19 +3821,17 @@ var buildScene = function buildScene(_ref) {
3801
3821
  return assets.id == curMat.id;
3802
3822
  });
3803
3823
  if (!(cachedElement !== null && cachedElement !== void 0 && cachedElement.material)) return;
3824
+ cachedElement.material.onElements.push(curElement);
3804
3825
  utilStore.setAnalyzeDataRowStatus(cachedElement.material.name, true);
3805
3826
  if (cachedElement.material.onNodes) {
3806
- if (!cachedElement.material.parents.find(function (p) {
3807
- return p.uniqueId == parentNode.uniqueId;
3808
- }) || !cachedElement.material.onNodes.includes(curMat.onNode) || !cachedElement.material.onElements.includes(curElement)) {
3809
- var _cachedElement$materi;
3810
- (_cachedElement$materi = cachedElement.material.parents) === null || _cachedElement$materi === void 0 || _cachedElement$materi.push(parentNode);
3811
- cachedElement.material.onElements.push(curElement);
3812
- cachedElement.material.onNodes.push(curMat.onNode);
3813
- }
3827
+ cachedElement.material.onNodes.push(curMat.onNode);
3814
3828
  } else {
3815
- cachedElement.material.onElements.push(curElement);
3816
3829
  cachedElement.material.onNodes = [curMat.onNode];
3830
+ }
3831
+ if (cachedElement.material.parents) {
3832
+ var _cachedElement$materi;
3833
+ (_cachedElement$materi = cachedElement.material.parents) === null || _cachedElement$materi === void 0 || _cachedElement$materi.push(parentNode);
3834
+ } else {
3817
3835
  cachedElement.material.parents = [parentNode];
3818
3836
  }
3819
3837
  }
@@ -3883,29 +3901,7 @@ var buildScene = function buildScene(_ref) {
3883
3901
  }
3884
3902
  }
3885
3903
  }
3886
-
3887
- // cache max size otherwise some devices crash (ram to high)
3888
- var cachedGeos = cache.getChildren(undefined, true);
3889
- if (cachedGeos.length > 10) {
3890
- // find unused geos
3891
- var unusedGeos = cachedGeos.filter(function (g) {
3892
- return !cachedAssets.find(function (c) {
3893
- var _c$geo;
3894
- return ((_c$geo = c.geo) === null || _c$geo === void 0 ? void 0 : _c$geo.geometry.uniqueId) == g.uniqueId;
3895
- });
3896
- });
3897
- var geoCountToDelete = cachedGeos.length - 10;
3898
- while (geoCountToDelete > 0 && unusedGeos.length > 0) {
3899
- var nextToDelete = unusedGeos.reduce(function (oIdx, cur, curIdx, ar) {
3900
- return cur.metadata.lastUsed < ar[oIdx].metadata.lastUsed ? curIdx : oIdx;
3901
- }, 0);
3902
- unusedGeos[nextToDelete].dispose();
3903
- unusedGeos.splice(nextToDelete, 1);
3904
- geoCountToDelete--;
3905
- }
3906
- }
3907
3904
  recursiveIteration(startNode, parentNode);
3908
- console.log(" cache -> ", cachedAssets);
3909
3905
  sceneStore.cache = cachedAssets;
3910
3906
  };
3911
3907
 
@@ -3914,41 +3910,20 @@ function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r
3914
3910
  function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
3915
3911
  function findMaterials(cache) {
3916
3912
  var matsOnMeshes = {};
3917
- var getDepth = function getDepth(child, ancestor) {
3918
- var depth = 0;
3919
- var current = child;
3920
- while (current && current.uniqueId !== ancestor.uniqueId) {
3921
- depth++;
3922
- current = current.parent;
3923
- }
3924
- return depth;
3925
- };
3926
-
3927
3913
  //! parent = the parent from which on every child should receive the Material
3928
3914
  //! id = the id which points to the material that should be assigned
3929
- // the level defines how many parents above the material was set the lower the higher the prio
3930
- var setMaterials = function setMaterials(onNode, mat, parent) {
3915
+ var setMaterials = function setMaterials(onNode, mat) {
3931
3916
  if (onNode !== null && onNode !== void 0 && onNode._isMesh) {
3932
- var mesh = onNode;
3933
- if (mesh) {
3934
- var _mesh$metadata;
3935
- var depth = getDepth(mesh, parent);
3936
- if (mesh.material && ((_mesh$metadata = mesh.metadata) === null || _mesh$metadata === void 0 ? void 0 : _mesh$metadata["matLevel"]) < depth) return;
3937
- matsOnMeshes[onNode.uniqueId] = {
3938
- mat: mat,
3939
- onNode: onNode
3940
- };
3941
- mesh.material = mat;
3942
- if (!mesh.metadata) mesh.metadata = {
3943
- "matLevel": depth
3944
- };else mesh.metadata["matLevel"] = depth;
3945
- }
3917
+ matsOnMeshes[onNode.uniqueId] = {
3918
+ mat: mat,
3919
+ onNode: onNode
3920
+ };
3921
+ onNode.material = mat;
3946
3922
  }
3947
3923
  var _iterator = _createForOfIteratorHelper$1(onNode.getChildMeshes()),
3948
3924
  _step;
3949
3925
  try {
3950
3926
  var _loop = function _loop() {
3951
- var _mesh$metadata2;
3952
3927
  var mesh = _step.value;
3953
3928
  var existing = Object.keys(matsOnMeshes).find(function (key) {
3954
3929
  return key == mesh.uniqueId.toString();
@@ -3959,24 +3934,16 @@ function findMaterials(cache) {
3959
3934
  return node.uniqueId.toString() == existing;
3960
3935
  })) return 0; // continue
3961
3936
  }
3962
- var depth = getDepth(mesh, parent);
3963
- if (mesh.material && ((_mesh$metadata2 = mesh.metadata) === null || _mesh$metadata2 === void 0 ? void 0 : _mesh$metadata2["matLevel"]) < depth) return {
3964
- v: void 0
3965
- };
3966
3937
  matsOnMeshes[mesh.uniqueId] = {
3967
3938
  mat: mat,
3968
3939
  onNode: onNode
3969
3940
  };
3970
3941
  mesh.material = mat;
3971
- if (!mesh.metadata) mesh.metadata = {
3972
- "matLevel": depth
3973
- };else mesh.metadata["matLevel"] = depth;
3974
3942
  },
3975
3943
  _ret;
3976
3944
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
3977
3945
  _ret = _loop();
3978
3946
  if (_ret === 0) continue;
3979
- if (_ret) return _ret.v;
3980
3947
  }
3981
3948
  } catch (err) {
3982
3949
  _iterator.e(err);
@@ -3989,18 +3956,15 @@ function findMaterials(cache) {
3989
3956
  var findOnNode = function findOnNode(mat, parent, onNode) {
3990
3957
  if (!mat.onNodes) return;
3991
3958
  var children = parent.getChildTransformNodes(false);
3992
- var childMeshes = parent.getChildMeshes(true);
3993
- if (onNode == "" || onNode == "ALL") childMeshes.forEach(function (cm) {
3994
- return setMaterials(cm, mat.mat, parent);
3995
- });
3996
3959
  var _iterator2 = _createForOfIteratorHelper$1(children),
3997
3960
  _step2;
3998
3961
  try {
3999
3962
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4000
3963
  var child = _step2.value;
4001
- if (onNode == "" || onNode == "ALL") setMaterials(child, mat.mat, parent);
3964
+ if (onNode == "" || onNode == "ALL") setMaterials(child, mat.mat);
4002
3965
  if (child.name.startsWith(onNode) || child.name.startsWith('geo_') && child.name.includes(onNode)) {
4003
- setMaterials(child, mat.mat, parent);
3966
+ if (child.getChildren(undefined, true)) {}
3967
+ setMaterials(child, mat.mat);
4004
3968
  }
4005
3969
  }
4006
3970
  } catch (err) {
@@ -4363,6 +4327,7 @@ function useRealTimeRenderData (_ref) {
4363
4327
  }
4364
4328
  function onFirstFrame() {
4365
4329
  var _callbacks$onInitiali2;
4330
+ //sceneStore.scene?.debugLayer?.show();
4366
4331
  sceneStore.isInitializing = false;
4367
4332
  sceneStore.scene.onAfterRenderObservable.removeCallback(onFirstFrame);
4368
4333
  if (!overlayImage && !disableToggleLoading) actions.toggleLoading('buildScene', false, false);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/buildScene/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAkB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpD,QAAA,MAAM,UAAU,oDAKb;IACD,SAAS,EAAE,QAAQ,CAAC;IACpB,KAAK,EAAE,aAAa,CAAC;IACrB,YAAY,EAAE,KAAK,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B,SAmIA,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/buildScene/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAkB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpD,QAAA,MAAM,UAAU,oDAKb;IACD,SAAS,EAAE,QAAQ,CAAC;IACpB,KAAK,EAAE,aAAa,CAAC;IACrB,YAAY,EAAE,KAAK,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B,SAgHA,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/findAssets/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAW,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKpC,wBAA8B,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE;;;GAoJ1E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/findAssets/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAW,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKpC,wBAA8B,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE;;;GAmK1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/findMaterials/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAY,MAAM,aAAa,CAAC;AAG9C,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,wBA0EnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/parser/findMaterials/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAY,MAAM,aAAa,CAAC;AAG9C,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,wBA6CnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRealTimeRenderData.d.ts","sourceRoot":"","sources":["../../../../src/useRealTimeRenderData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMhC,OAAO,8BAA8B,CAAC;AAWtC,MAAM,CAAC,OAAO,WAAW,EACvB,GAAG,EACH,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,QAAQ,EACR,oBAAoB,GACrB,EAAE,KAAK;;;;EA2WP"}
1
+ {"version":3,"file":"useRealTimeRenderData.d.ts","sourceRoot":"","sources":["../../../../src/useRealTimeRenderData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMhC,OAAO,8BAA8B,CAAC;AAWtC,MAAM,CAAC,OAAO,WAAW,EACvB,GAAG,EACH,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,QAAQ,EACR,oBAAoB,GACrB,EAAE,KAAK;;;;EA4WP"}