@crystaldesign/real-time-viewer 25.15.0-beta.1 → 25.15.0-beta.3

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.slice(nextToDelete);
3297
+ unusedGeos[nextToDelete].dispose();
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
  };
@@ -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"}