@crystaldesign/real-time-viewer 25.15.0-beta.2 → 25.15.0-beta.20

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.
@@ -3261,7 +3261,7 @@ function _findAssets() {
3261
3261
  case 0:
3262
3262
  _importGeo = function _importGeo3() {
3263
3263
  _importGeo = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(geo, path) {
3264
- var geoCached, size, result, mesh, _sceneStore$onMissing;
3264
+ var geoCached, cachedGeos, unusedGeos, geoCountToDelete, nextToDelete, size, result, mesh, _sceneStore$onMissing;
3265
3265
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
3266
3266
  while (1) switch (_context2.prev = _context2.next) {
3267
3267
  case 0:
@@ -3270,16 +3270,39 @@ function _findAssets() {
3270
3270
  return g.name == geo.name;
3271
3271
  });
3272
3272
  if (!geoCached) {
3273
- _context2.next = 3;
3273
+ _context2.next = 4;
3274
3274
  break;
3275
3275
  }
3276
+ geoCached.metadata = {
3277
+ lastUsed: Date.now()
3278
+ };
3276
3279
  return _context2.abrupt("return", geoCached);
3277
- case 3:
3280
+ case 4:
3281
+ // cache max size otherwise some devices crash (ram to high)
3282
+ cachedGeos = cacheGroup.getChildren(undefined, true);
3283
+ if (cachedGeos.length > 10) {
3284
+ // find unused geos
3285
+ unusedGeos = cachedGeos.filter(function (g) {
3286
+ return !cache.find(function (c) {
3287
+ var _c$geo;
3288
+ return ((_c$geo = c.geo) === null || _c$geo === void 0 ? void 0 : _c$geo.geometry.uniqueId) == g.uniqueId;
3289
+ });
3290
+ });
3291
+ geoCountToDelete = cachedGeos.length - 10;
3292
+ while (geoCountToDelete > 0 && unusedGeos.length > 0) {
3293
+ nextToDelete = unusedGeos.reduce(function (oIdx, cur, curIdx, ar) {
3294
+ return cur.metadata.lastUsed < ar[oIdx].metadata.lastUsed ? curIdx : oIdx;
3295
+ }, 0);
3296
+ unusedGeos[nextToDelete].dispose();
3297
+ unusedGeos.splice(nextToDelete, 1);
3298
+ geoCountToDelete--;
3299
+ }
3300
+ }
3278
3301
  size = 0;
3279
- _context2.prev = 4;
3280
- _context2.next = 7;
3302
+ _context2.prev = 7;
3303
+ _context2.next = 10;
3281
3304
  return loadAssetContainerAsync(path + geo.name + '.glb', sceneStore.scene);
3282
- case 7:
3305
+ case 10:
3283
3306
  result = _context2.sent;
3284
3307
  utilStore.setAnalyzeDataRow({
3285
3308
  name: geo.name,
@@ -3297,10 +3320,13 @@ function _findAssets() {
3297
3320
  result.meshes[0].dispose();
3298
3321
  mesh.name = geo.name;
3299
3322
  mesh.parent = cacheGroup;
3323
+ mesh.metadata = {
3324
+ lastUsed: Date.now()
3325
+ };
3300
3326
  return _context2.abrupt("return", mesh);
3301
- case 20:
3302
- _context2.prev = 20;
3303
- _context2.t0 = _context2["catch"](4);
3327
+ case 24:
3328
+ _context2.prev = 24;
3329
+ _context2.t0 = _context2["catch"](7);
3304
3330
  (_sceneStore$onMissing = sceneStore.onMissingGeo) === null || _sceneStore$onMissing === void 0 || _sceneStore$onMissing.call(sceneStore);
3305
3331
  utilStore.setAnalyzeDataRow({
3306
3332
  name: geo.name,
@@ -3311,11 +3337,11 @@ function _findAssets() {
3311
3337
  found: false
3312
3338
  });
3313
3339
  return _context2.abrupt("return", undefined);
3314
- case 25:
3340
+ case 29:
3315
3341
  case "end":
3316
3342
  return _context2.stop();
3317
3343
  }
3318
- }, _callee2, null, [[4, 20]]);
3344
+ }, _callee2, null, [[7, 24]]);
3319
3345
  }));
3320
3346
  return _importGeo.apply(this, arguments);
3321
3347
  };
@@ -3732,7 +3758,7 @@ var buildScene = function buildScene(_ref) {
3732
3758
  var geo = mesh.clone('geo_' + mesh.name, parentNode);
3733
3759
  geo.position = new Vector3(curGeo.pos.x / 100, curGeo.pos.y / 100, curGeo.pos.z / 100);
3734
3760
  geo.rotation = utilStore.degreesToRadians({
3735
- x: hqsGeo.isIDM3D ? 90 - curGeo.rot.x : -curGeo.rot.x,
3761
+ x: hqsGeo.isIDM3D && curGeo.rot.x != 0 ? 90 - curGeo.rot.x : -curGeo.rot.x,
3736
3762
  y: 360 - curGeo.rot.y,
3737
3763
  z: 360 - curGeo.rot.z
3738
3764
  });
@@ -3871,16 +3897,41 @@ function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symb
3871
3897
  function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
3872
3898
  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; }
3873
3899
  function findMaterials(cache) {
3900
+ var matsOnMeshes = {};
3874
3901
  //! parent = the parent from which on every child should receive the Material
3875
3902
  //! id = the id which points to the material that should be assigned
3876
3903
  var setMaterials = function setMaterials(onNode, mat) {
3877
- if (onNode !== null && onNode !== void 0 && onNode._isMesh) onNode.material = mat;
3904
+ if (onNode !== null && onNode !== void 0 && onNode._isMesh) {
3905
+ matsOnMeshes[onNode.uniqueId] = {
3906
+ mat: mat,
3907
+ onNode: onNode
3908
+ };
3909
+ onNode.material = mat;
3910
+ }
3878
3911
  var _iterator = _createForOfIteratorHelper$1(onNode.getChildMeshes()),
3879
3912
  _step;
3880
3913
  try {
3914
+ var _loop = function _loop() {
3915
+ var mesh = _step.value;
3916
+ var existing = Object.keys(matsOnMeshes).find(function (key) {
3917
+ return key == mesh.uniqueId.toString();
3918
+ });
3919
+ if (existing) {
3920
+ if (onNode.uniqueId.toString() == existing) return 0; // continue
3921
+ if (onNode.getChildren().find(function (node) {
3922
+ return node.uniqueId.toString() == existing;
3923
+ })) return 0; // continue
3924
+ }
3925
+ matsOnMeshes[mesh.uniqueId] = {
3926
+ mat: mat,
3927
+ onNode: onNode
3928
+ };
3929
+ mesh.material = mat;
3930
+ },
3931
+ _ret;
3881
3932
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
3882
- var mesh = _step.value;
3883
- mesh.material = mat;
3933
+ _ret = _loop();
3934
+ if (_ret === 0) continue;
3884
3935
  }
3885
3936
  } catch (err) {
3886
3937
  _iterator.e(err);
@@ -3890,7 +3941,7 @@ function findMaterials(cache) {
3890
3941
  };
3891
3942
 
3892
3943
  //! find On Node from json to scene and then call setMaterials to apply it to all Children
3893
- var findOnNode = function findOnNode(mat, parent) {
3944
+ var findOnNode = function findOnNode(mat, parent, onNode) {
3894
3945
  if (!mat.onNodes) return;
3895
3946
  var children = parent.getChildTransformNodes(false);
3896
3947
  var _iterator2 = _createForOfIteratorHelper$1(children),
@@ -3898,20 +3949,10 @@ function findMaterials(cache) {
3898
3949
  try {
3899
3950
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3900
3951
  var child = _step2.value;
3901
- var _iterator3 = _createForOfIteratorHelper$1(mat.onNodes),
3902
- _step3;
3903
- try {
3904
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
3905
- var onNode = _step3.value;
3906
- if (onNode == "" || onNode == "ALL") setMaterials(child, mat.mat);
3907
- if (child.name.startsWith(onNode) || child.name.startsWith('geo_') && child.name.includes(onNode)) {
3908
- setMaterials(child, mat.mat);
3909
- }
3910
- }
3911
- } catch (err) {
3912
- _iterator3.e(err);
3913
- } finally {
3914
- _iterator3.f();
3952
+ if (onNode == "" || onNode == "ALL") setMaterials(child, mat.mat);
3953
+ if (child.name.startsWith(onNode) || child.name.startsWith('geo_') && child.name.includes(onNode)) {
3954
+ if (child.getChildren(undefined, true)) {}
3955
+ setMaterials(child, mat.mat);
3915
3956
  }
3916
3957
  }
3917
3958
  } catch (err) {
@@ -3920,29 +3961,22 @@ function findMaterials(cache) {
3920
3961
  _iterator2.f();
3921
3962
  }
3922
3963
  };
3923
- var _iterator4 = _createForOfIteratorHelper$1(cache),
3924
- _step4;
3964
+ var _iterator3 = _createForOfIteratorHelper$1(cache),
3965
+ _step3;
3925
3966
  try {
3926
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3927
- var element = _step4.value;
3967
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
3968
+ var element = _step3.value;
3928
3969
  if (!element.material || !element.material.parents) continue;
3929
- var _iterator5 = _createForOfIteratorHelper$1(element.material.parents),
3930
- _step5;
3931
- try {
3932
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3933
- var parent = _step5.value;
3934
- findOnNode(element.material, parent);
3935
- }
3936
- } catch (err) {
3937
- _iterator5.e(err);
3938
- } finally {
3939
- _iterator5.f();
3970
+ for (var idx = 0; idx < element.material.parents.length; idx++) {
3971
+ var parent = element.material.parents[idx];
3972
+ var onNode = element.material.onNodes[idx];
3973
+ findOnNode(element.material, parent, onNode);
3940
3974
  }
3941
3975
  }
3942
3976
  } catch (err) {
3943
- _iterator4.e(err);
3977
+ _iterator3.e(err);
3944
3978
  } finally {
3945
- _iterator4.f();
3979
+ _iterator3.f();
3946
3980
  }
3947
3981
  return findMaterials;
3948
3982
  }
@@ -4202,50 +4236,49 @@ function useRealTimeRenderData (_ref) {
4202
4236
  return _context2.abrupt("return");
4203
4237
  case 2:
4204
4238
  sceneStore.isInitializing = true;
4205
- if (!overlayImage && !disableToggleLoading) actions.toggleLoading('buildScene', false, true);
4206
4239
  if (sceneStore.hasRendered) {
4207
- _context2.next = 10;
4240
+ _context2.next = 9;
4208
4241
  break;
4209
4242
  }
4210
4243
  if (inBackground) sceneStore.scene.getEngine().setHardwareScalingLevel(5);
4211
4244
  sceneStore.init(apiConfig.diva3darchive + '/', gameCanvas.current, viewpoint, resolution);
4212
4245
  uiStore.resize();
4213
- _context2.next = 15;
4246
+ _context2.next = 13;
4214
4247
  break;
4215
- case 10:
4248
+ case 9:
4216
4249
  sceneStore.hqRenderScript = JSON.parse(renderjob);
4217
4250
  if (checkCachedData()) {
4218
- _context2.next = 15;
4251
+ _context2.next = 13;
4219
4252
  break;
4220
4253
  }
4221
- if (!overlayImage && !disableToggleLoading) actions.toggleLoading('buildScene', false, false);
4222
4254
  sceneStore.isInitializing = false;
4223
4255
  return _context2.abrupt("return");
4224
- case 15:
4256
+ case 13:
4257
+ if (!overlayImage && !disableToggleLoading) actions.toggleLoading('buildScene', false, true);
4225
4258
  LOG.startTransaction({
4226
4259
  event: 'buildScene',
4227
4260
  message: 'Start Building Realtime Scene',
4228
4261
  eventId: 'BUILD_SCENE'
4229
4262
  });
4230
- _context2.prev = 16;
4263
+ _context2.prev = 15;
4231
4264
  uiStore.deactivateHighlightLayer();
4232
- _context2.next = 20;
4265
+ _context2.next = 19;
4233
4266
  return parser();
4234
- case 20:
4267
+ case 19:
4235
4268
  uiStore.initGui(callbacks.onElementSelected, sceneStore.elements);
4236
4269
  if ((uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.plannerMode) != 'BoxPlanner' && (freePlacesOnGrids || plannedPlacesOnGrids)) gridStore.getGrids('ShelfPlanner', undefined, freePlacesOnGrids, plannedPlacesOnGrids);else if (viewHandler !== null && viewHandler !== void 0 && viewHandler.settingsState.generalPlanningState) gridStore.getGrids('BoxPlanner', viewHandler.settingsState.generalPlanningState);
4237
- _context2.next = 29;
4270
+ _context2.next = 28;
4238
4271
  break;
4239
- case 24:
4240
- _context2.prev = 24;
4241
- _context2.t0 = _context2["catch"](16);
4272
+ case 23:
4273
+ _context2.prev = 23;
4274
+ _context2.t0 = _context2["catch"](15);
4242
4275
  LOG.errorTransaction('BUILD_SCENE', 'RTS_0001', _context2.t0.message);
4243
4276
  LOG.error(new DivaError('Error building scene', {
4244
4277
  cause: _context2.t0,
4245
4278
  code: 'RTS_0001'
4246
4279
  }));
4247
4280
  sceneStore.isInitializing = false;
4248
- case 29:
4281
+ case 28:
4249
4282
  if (callbacks.setGlb) {
4250
4283
  sceneStore.exportScene(callbacks.setGlb);
4251
4284
  } else {
@@ -4257,11 +4290,11 @@ function useRealTimeRenderData (_ref) {
4257
4290
  sceneStore.runRenderLoopForTime(5000);
4258
4291
  sceneStore.scene.onAfterRenderObservable.add(onFirstFrame);
4259
4292
  LOG.successTransaction('BUILD_SCENE');
4260
- case 34:
4293
+ case 33:
4261
4294
  case "end":
4262
4295
  return _context2.stop();
4263
4296
  }
4264
- }, _callee2, null, [[16, 24]]);
4297
+ }, _callee2, null, [[15, 23]]);
4265
4298
  }));
4266
4299
  return _onSceneReady.apply(this, arguments);
4267
4300
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,cAAc,gBAAgB,CAAC;AAO/B,QAAA,MAAM,gBAAgB,oCACZ,KAAK,uBA4Bd,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,cAAc,gBAAgB,CAAC;AAO/B,QAAA,MAAM,gBAAgB,oCACZ,KAAK,uBA+Bd,CAAC;AAEF,eAAe,gBAAgB,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;;;GAiJ1E"}
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;;;GAoK1E"}
@@ -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,wBAgCnD"}
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;AAUtC,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;;EA2PP"}
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;AAUtC,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;;EA0PP"}