kitchen-simulator 11.4.0 → 11.6.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.
@@ -1,9 +1,12 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
1
3
  import { Box3, BufferAttribute, BufferGeometry, LoaderUtils, LoadingManager, Vector3 } from 'three';
2
4
  import { MTLLoader } from 'three/examples/jsm/loaders/MTLLoader.js';
3
5
  import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader.js';
4
6
  import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
5
7
  import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
6
8
  import { OBJTYPE_MESH } from "../../constants";
9
+ import { sanitizeAssetUrl } from "../../shared/domain/asset/sanitize-asset-url";
7
10
  export function loadObjWithMaterial(mtlFile, objFile, imgPath) {
8
11
  var manager = new LoadingManager();
9
12
  var mtlLoader = new MTLLoader(manager);
@@ -20,48 +23,74 @@ export function loadObjWithMaterial(mtlFile, objFile, imgPath) {
20
23
  });
21
24
  });
22
25
  }
23
- export function loadGLTF(url) {
24
- if (url == undefined) {
25
- return Promise.reject('No url is passed');
26
- }
27
- var baseURL = LoaderUtils.extractUrlBase(url);
28
- var manager = new LoadingManager();
29
-
30
- // Intercept and override relative URLs.
31
- manager.setURLModifier(function (url, path) {
32
- // URIs in a glTF file may be escaped, or not. Assume that assetMap is
33
- // from an un-escaped source, and decode all URIs before lookups.
34
- // See: https://github.com/donmccurdy/three-gltf-viewer/issues/146
35
- var normalizedURL = decodeURI(url).replace(baseURL, '').replace(/^(\.?\/)/, '');
36
-
37
- // if (assetMap.has(normalizedURL)) {
38
- // const blob = assetMap.get(normalizedURL);
39
- // const blobURL = URL.createObjectURL(blob);
40
- // blobURLs.push(blobURL);
41
- // return blobURL;
42
- // }
43
- return (path || '') + url;
44
- });
45
- var loader = new GLTFLoader(manager);
46
- loader.setCrossOrigin('anonymous');
47
- var dracoLoader = new DRACOLoader();
48
- dracoLoader.setDecoderPath('/assets/draco/');
49
- loader.setDRACOLoader(dracoLoader);
26
+ function loadGLTFInternal(url, manager) {
50
27
  return new Promise(function (resolve, reject) {
28
+ var loader = new GLTFLoader(manager);
29
+ loader.setCrossOrigin('anonymous');
30
+ var dracoLoader = new DRACOLoader();
31
+ dracoLoader.setDecoderPath('/assets/draco/');
32
+ loader.setDRACOLoader(dracoLoader);
51
33
  loader.load(url, function (gltf) {
52
- resolve(gltf.scene);
53
- }, function (xhr) {
54
- // console.log("xhr", xhr);
55
- // called while loading is progressing
56
- // console.log( `${( xhr.loaded / xhr.total * 100 )}% loaded` );
57
- }, function (error) {
58
- // console.log("error", error);
59
- // called when loading has errors
60
- // console.error( '2= An error happened', error );
61
- reject(error);
34
+ return resolve(gltf.scene);
35
+ }, undefined, function (error) {
36
+ return reject(error);
62
37
  });
63
38
  });
64
39
  }
40
+ export function loadGLTF(_x) {
41
+ return _loadGLTF.apply(this, arguments);
42
+ }
43
+ function _loadGLTF() {
44
+ _loadGLTF = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
45
+ var baseURL, manager, sanitized, _t, _t2;
46
+ return _regeneratorRuntime.wrap(function (_context) {
47
+ while (1) switch (_context.prev = _context.next) {
48
+ case 0:
49
+ if (url) {
50
+ _context.next = 1;
51
+ break;
52
+ }
53
+ throw new Error('No url is passed');
54
+ case 1:
55
+ baseURL = LoaderUtils.extractUrlBase(url);
56
+ manager = new LoadingManager();
57
+ manager.setURLModifier(function (resourceUrl, path) {
58
+ var normalizedURL = decodeURI(resourceUrl).replace(baseURL, '').replace(/^(\.?\/)/, '');
59
+ return (path || '') + resourceUrl;
60
+ });
61
+ sanitized = sanitizeAssetUrl(url); // ---- First attempt ----
62
+ _context.prev = 2;
63
+ _context.next = 3;
64
+ return loadGLTFInternal(url, manager);
65
+ case 3:
66
+ return _context.abrupt("return", _context.sent);
67
+ case 4:
68
+ _context.prev = 4;
69
+ _t = _context["catch"](2);
70
+ console.warn('[GLTF] load failed, trying sanitized URL:', sanitized);
71
+
72
+ // Avoid useless retry
73
+ // if (!sanitized || sanitized === url) {
74
+ // throw err;
75
+ // }
76
+ _context.prev = 5;
77
+ _context.next = 6;
78
+ return loadGLTFInternal(sanitized, manager);
79
+ case 6:
80
+ return _context.abrupt("return", _context.sent);
81
+ case 7:
82
+ _context.prev = 7;
83
+ _t2 = _context["catch"](5);
84
+ console.error('[GLTF] failed after fallback:', sanitized);
85
+ throw _t2;
86
+ case 8:
87
+ case "end":
88
+ return _context.stop();
89
+ }
90
+ }, _callee, null, [[2, 4], [5, 7]]);
91
+ }));
92
+ return _loadGLTF.apply(this, arguments);
93
+ }
65
94
  export function scaleObject(object, defaultSizeArray, scaleSizeArray) {
66
95
  var boundingBox = new Box3().setFromObject(object);
67
96
  var initialSizeArray = boundingBox.getSize(new Vector3()).toArray();
@@ -17,6 +17,7 @@ import { GeometryUtils, MathUtils } from "../../utils/export";
17
17
  import { returnReplaceableDeepSearchType } from "../../components/viewer2d/utils";
18
18
  import { SVGLoader } from 'three/addons/loaders/SVGLoader';
19
19
  import { calcDistancesFromHoleToNearestOneOrWall } from "../../utils/geometry";
20
+ import { loadJSONWithFallback } from "../../shared/domain/asset/load-asset-json";
20
21
  var PRECISION = 2;
21
22
 
22
23
  // ---- compatibility: supports old + optimized props shapes ----
@@ -34,59 +35,18 @@ export function getPlannerStateFromProps(props) {
34
35
  }
35
36
 
36
37
  // ---- caches: avoid re-fetch/re-parse costs (no behavior change) ----
37
- var __jsonCache = new Map(); // url -> Promise<any>
38
38
  var __svgCache = new Map(); // url -> Promise<svgData|null>
39
- function loadJSON(_x) {
40
- return _loadJSON.apply(this, arguments);
41
- }
39
+
42
40
  /********Parse TempPlaceholder from cabinetPayloadData **************/
43
- function _loadJSON() {
44
- _loadJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(path) {
45
- var p;
46
- return _regeneratorRuntime.wrap(function (_context3) {
47
- while (1) switch (_context3.prev = _context3.next) {
48
- case 0:
49
- if (path) {
50
- _context3.next = 1;
51
- break;
52
- }
53
- return _context3.abrupt("return", null);
54
- case 1:
55
- if (!__jsonCache.has(path)) {
56
- _context3.next = 2;
57
- break;
58
- }
59
- return _context3.abrupt("return", __jsonCache.get(path));
60
- case 2:
61
- p = new Promise(function (resolve, reject) {
62
- var xhr = new XMLHttpRequest();
63
- xhr.onreadystatechange = function () {
64
- if (xhr.readyState === XMLHttpRequest.DONE) {
65
- if (xhr.status === 200) resolve(JSON.parse(xhr.responseText));else reject(xhr);
66
- }
67
- };
68
- xhr.open('GET', path, true);
69
- xhr.send();
70
- });
71
- __jsonCache.set(path, p);
72
- return _context3.abrupt("return", p);
73
- case 3:
74
- case "end":
75
- return _context3.stop();
76
- }
77
- }, _callee3);
78
- }));
79
- return _loadJSON.apply(this, arguments);
80
- }
81
- function parseTempPlaceholdersFromCabinetPayload(_x2) {
41
+ function parseTempPlaceholdersFromCabinetPayload(_x) {
82
42
  return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
83
43
  }
84
44
  /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
85
45
  function _parseTempPlaceholdersFromCabinetPayload() {
86
- _parseTempPlaceholdersFromCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(cabinetPayload) {
46
+ _parseTempPlaceholdersFromCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(cabinetPayload) {
87
47
  var link, keys, temp, i, _cabinetPayload$struc, _cabinetPayload$struc2, tempPlaceholdersData, k, _cabinetPayload$struc3, el, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, _t2, _t3, _t4;
88
- return _regeneratorRuntime.wrap(function (_context4) {
89
- while (1) switch (_context4.prev = _context4.next) {
48
+ return _regeneratorRuntime.wrap(function (_context3) {
49
+ while (1) switch (_context3.prev = _context3.next) {
90
50
  case 0:
91
51
  link = '';
92
52
  keys = Object.keys(cabinetPayload.structure_json);
@@ -94,27 +54,27 @@ function _parseTempPlaceholdersFromCabinetPayload() {
94
54
  i = 0;
95
55
  case 1:
96
56
  if (!(i < keys.length)) {
97
- _context4.next = 4;
57
+ _context3.next = 4;
98
58
  break;
99
59
  }
100
60
  if (!((_cabinetPayload$struc = cabinetPayload.structure_json[keys[i]]) !== null && _cabinetPayload$struc !== void 0 && (_cabinetPayload$struc = _cabinetPayload$struc.toString()) !== null && _cabinetPayload$struc !== void 0 && _cabinetPayload$struc.includes('.gltf') && (_cabinetPayload$struc2 = cabinetPayload.structure_json[keys[i]]) !== null && _cabinetPayload$struc2 !== void 0 && (_cabinetPayload$struc2 = _cabinetPayload$struc2.toString()) !== null && _cabinetPayload$struc2 !== void 0 && _cabinetPayload$struc2.startsWith('http'))) {
101
- _context4.next = 3;
61
+ _context3.next = 3;
102
62
  break;
103
63
  }
104
64
  link = cabinetPayload.structure_json[keys[i]];
105
65
  _t2 = temp;
106
66
  _t3 = keys[i];
107
- _context4.next = 2;
108
- return loadJSON(link);
67
+ _context3.next = 2;
68
+ return loadJSONWithFallback(link);
109
69
  case 2:
110
- _t4 = _context4.sent;
70
+ _t4 = _context3.sent;
111
71
  _t2.push.call(_t2, {
112
72
  name: _t3,
113
73
  data: _t4
114
74
  });
115
75
  case 3:
116
76
  i++;
117
- _context4.next = 1;
77
+ _context3.next = 1;
118
78
  break;
119
79
  case 4:
120
80
  tempPlaceholdersData = [];
@@ -423,29 +383,29 @@ function _parseTempPlaceholdersFromCabinetPayload() {
423
383
  structure: cabinetPayload.structure_json.tempPlaceholders[k].structure
424
384
  });
425
385
  }
426
- return _context4.abrupt("return", tempPlaceholdersData);
386
+ return _context3.abrupt("return", tempPlaceholdersData);
427
387
  case 5:
428
388
  case "end":
429
- return _context4.stop();
389
+ return _context3.stop();
430
390
  }
431
- }, _callee4);
391
+ }, _callee3);
432
392
  }));
433
393
  return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
434
394
  }
435
- function updateCabinetPayload(_x3) {
395
+ function updateCabinetPayload(_x2) {
436
396
  return _updateCabinetPayload.apply(this, arguments);
437
397
  }
438
398
  function _updateCabinetPayload() {
439
- _updateCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(cabinetPayload) {
399
+ _updateCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(cabinetPayload) {
440
400
  var tempPlaceholders, cabinetPayloadKeys, i;
441
- return _regeneratorRuntime.wrap(function (_context5) {
442
- while (1) switch (_context5.prev = _context5.next) {
401
+ return _regeneratorRuntime.wrap(function (_context4) {
402
+ while (1) switch (_context4.prev = _context4.next) {
443
403
  case 0:
444
404
  tempPlaceholders = [];
445
- _context5.next = 1;
405
+ _context4.next = 1;
446
406
  return parseTempPlaceholdersFromCabinetPayload(cabinetPayload);
447
407
  case 1:
448
- tempPlaceholders = _context5.sent;
408
+ tempPlaceholders = _context4.sent;
449
409
  cabinetPayloadKeys = Object.keys(cabinetPayload);
450
410
  for (i = 0; i < cabinetPayloadKeys.length; i++) {
451
411
  if (cabinetPayloadKeys[i] === 'structure_json') {
@@ -457,12 +417,12 @@ function _updateCabinetPayload() {
457
417
  cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] = tempPlaceholders;
458
418
  }
459
419
  }
460
- return _context5.abrupt("return", cabinetPayload);
420
+ return _context4.abrupt("return", cabinetPayload);
461
421
  case 2:
462
422
  case "end":
463
- return _context5.stop();
423
+ return _context4.stop();
464
424
  }
465
- }, _callee5);
425
+ }, _callee4);
466
426
  }));
467
427
  return _updateCabinetPayload.apply(this, arguments);
468
428
  }
@@ -534,7 +494,7 @@ var loadSVGsByItem = /*#__PURE__*/function () {
534
494
  }
535
495
  }, _callee2);
536
496
  }));
537
- return function loadSVGsByItem(_x4) {
497
+ return function loadSVGsByItem(_x3) {
538
498
  return _ref.apply(this, arguments);
539
499
  };
540
500
  }();
@@ -557,31 +517,31 @@ function populateCCDFList(param) {
557
517
  }
558
518
  return definition;
559
519
  }
560
- export function addItemToCatalog(_x5, _x6, _x7, _x8) {
520
+ export function addItemToCatalog(_x4, _x5, _x6, _x7) {
561
521
  return _addItemToCatalog.apply(this, arguments);
562
522
  }
563
523
 
564
524
  // Get attributs of current selected element
565
525
  function _addItemToCatalog() {
566
- _addItemToCatalog = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(element, state, catalogInstance, projectActions) {
526
+ _addItemToCatalog = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(element, state, catalogInstance, projectActions) {
567
527
  var _elementJs, _elementJs3;
568
528
  var elementJs, outlineSVGData, _state$getIn, _elementJs$structure_, _elementJs$structure_2, _elementJs$structure_3, cds, _cds$find, _elementJs2, currentCdsId, cdsIdx, ttph, updatedStructureJson, catalogElements, catalogElementKeys, catalogItem, k, _catalogElements$cata, tempPlaceholderArray, _catalogItem$structur, newTempPlaceholderArray, mergedTempPlaceholder;
569
- return _regeneratorRuntime.wrap(function (_context6) {
570
- while (1) switch (_context6.prev = _context6.next) {
529
+ return _regeneratorRuntime.wrap(function (_context5) {
530
+ while (1) switch (_context5.prev = _context5.next) {
571
531
  case 0:
572
532
  if (!isEmpty(element === null || element === void 0 ? void 0 : element.name)) {
573
- _context6.next = 1;
533
+ _context5.next = 1;
574
534
  break;
575
535
  }
576
- return _context6.abrupt("return");
536
+ return _context5.abrupt("return");
577
537
  case 1:
578
538
  elementJs = populateCCDFList(element); // if (isEmpty(catalog?.elements[element.name])) {
579
- _context6.next = 2;
539
+ _context5.next = 2;
580
540
  return loadSVGsByItem(elementJs);
581
541
  case 2:
582
- outlineSVGData = _context6.sent;
542
+ outlineSVGData = _context5.sent;
583
543
  if (!(((_elementJs = elementJs) === null || _elementJs === void 0 ? void 0 : _elementJs.type) === 'cabinet')) {
584
- _context6.next = 4;
544
+ _context5.next = 4;
585
545
  break;
586
546
  }
587
547
  // move the tempPlaceholder of current door style to first of tempPlaceholders array
@@ -609,13 +569,13 @@ function _addItemToCatalog() {
609
569
  }
610
570
  });
611
571
  if (isEmpty((_elementJs$structure_3 = elementJs.structure_json) === null || _elementJs$structure_3 === void 0 ? void 0 : _elementJs$structure_3.tempPlaceholders)) {
612
- _context6.next = 4;
572
+ _context5.next = 4;
613
573
  break;
614
574
  }
615
- _context6.next = 3;
575
+ _context5.next = 3;
616
576
  return updateCabinetPayload(elementJs);
617
577
  case 3:
618
- elementJs = _context6.sent;
578
+ elementJs = _context5.sent;
619
579
  case 4:
620
580
  elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
621
581
  outlineSVGData: outlineSVGData,
@@ -632,18 +592,18 @@ function _addItemToCatalog() {
632
592
  k = 0;
633
593
  case 5:
634
594
  if (!(k < catalogElementKeys.length)) {
635
- _context6.next = 7;
595
+ _context5.next = 7;
636
596
  break;
637
597
  }
638
598
  if (!(((_catalogElements$cata = catalogElements[catalogElementKeys[k]]) === null || _catalogElements$cata === void 0 ? void 0 : _catalogElements$cata.itemID) === elementJs.itemID)) {
639
- _context6.next = 6;
599
+ _context5.next = 6;
640
600
  break;
641
601
  }
642
602
  catalogItem = catalogElements[catalogElementKeys[k]];
643
- return _context6.abrupt("continue", 7);
603
+ return _context5.abrupt("continue", 7);
644
604
  case 6:
645
605
  k++;
646
- _context6.next = 5;
606
+ _context5.next = 5;
647
607
  break;
648
608
  case 7:
649
609
  // get old tempPlaceholder array from catalog item
@@ -674,9 +634,9 @@ function _addItemToCatalog() {
674
634
  }
675
635
  case 8:
676
636
  case "end":
677
- return _context6.stop();
637
+ return _context5.stop();
678
638
  }
679
- }, _callee6);
639
+ }, _callee5);
680
640
  }));
681
641
  return _addItemToCatalog.apply(this, arguments);
682
642
  }
@@ -1036,15 +996,15 @@ export function getElement(objProps, state) {
1036
996
  }
1037
997
  return curObject;
1038
998
  }
1039
- export function loadMoldingSvg(_x9) {
999
+ export function loadMoldingSvg(_x8) {
1040
1000
  return _loadMoldingSvg.apply(this, arguments);
1041
1001
  }
1042
1002
  function _loadMoldingSvg() {
1043
- _loadMoldingSvg = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(molding) {
1044
- return _regeneratorRuntime.wrap(function (_context7) {
1045
- while (1) switch (_context7.prev = _context7.next) {
1003
+ _loadMoldingSvg = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(molding) {
1004
+ return _regeneratorRuntime.wrap(function (_context6) {
1005
+ while (1) switch (_context6.prev = _context6.next) {
1046
1006
  case 0:
1047
- return _context7.abrupt("return", new Promise(function (resolve, reject) {
1007
+ return _context6.abrupt("return", new Promise(function (resolve, reject) {
1048
1008
  var url = molding === null || molding === void 0 ? void 0 : molding.shape_svg;
1049
1009
  if (!url) {
1050
1010
  // Skip if no SVG URL available
@@ -1066,9 +1026,9 @@ function _loadMoldingSvg() {
1066
1026
  }));
1067
1027
  case 1:
1068
1028
  case "end":
1069
- return _context7.stop();
1029
+ return _context6.stop();
1070
1030
  }
1071
- }, _callee7);
1031
+ }, _callee6);
1072
1032
  }));
1073
1033
  return _loadMoldingSvg.apply(this, arguments);
1074
1034
  }
@@ -0,0 +1,53 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { loadJSON } from "../../network/load-json";
4
+ import { sanitizeAssetUrl } from "./sanitize-asset-url";
5
+ export function loadJSONWithFallback(_x) {
6
+ return _loadJSONWithFallback.apply(this, arguments);
7
+ }
8
+ function _loadJSONWithFallback() {
9
+ _loadJSONWithFallback = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(path) {
10
+ var sanitized, _t, _t2;
11
+ return _regeneratorRuntime.wrap(function (_context) {
12
+ while (1) switch (_context.prev = _context.next) {
13
+ case 0:
14
+ if (path) {
15
+ _context.next = 1;
16
+ break;
17
+ }
18
+ return _context.abrupt("return", null);
19
+ case 1:
20
+ sanitized = sanitizeAssetUrl(path);
21
+ _context.prev = 2;
22
+ _context.next = 3;
23
+ return loadJSON(path);
24
+ case 3:
25
+ return _context.abrupt("return", _context.sent);
26
+ case 4:
27
+ _context.prev = 4;
28
+ _t = _context["catch"](2);
29
+ console.warn('[GLTF load failed, retrying with sanitized URL]', sanitized);
30
+ _context.prev = 5;
31
+ if (!(!sanitized || sanitized === path)) {
32
+ _context.next = 6;
33
+ break;
34
+ }
35
+ throw _t;
36
+ case 6:
37
+ _context.next = 7;
38
+ return loadJSON(sanitized);
39
+ case 7:
40
+ return _context.abrupt("return", _context.sent);
41
+ case 8:
42
+ _context.prev = 8;
43
+ _t2 = _context["catch"](5);
44
+ console.error('[GLTF load failed after retry]');
45
+ return _context.abrupt("return", null);
46
+ case 9:
47
+ case "end":
48
+ return _context.stop();
49
+ }
50
+ }, _callee, null, [[2, 4], [5, 8]]);
51
+ }));
52
+ return _loadJSONWithFallback.apply(this, arguments);
53
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Strip stray dots from the **path portion** of a GLTF/BIN URL.
3
+ * e.g. `…/B36_36x34.5x24.gltf` → `…/B36_36x345x24.gltf`
4
+ *
5
+ * Leaves the protocol/domain and the final file extension untouched.
6
+ */
7
+ export var sanitizeAssetUrl = function sanitizeAssetUrl(url) {
8
+ if (!url) return url;
9
+ var parsed = new URL(url);
10
+
11
+ // If the URL starts with the S3 base, only sanitize the path after it.
12
+ var base = parsed.origin; // https://industry-media.addovisuals.com
13
+ var hasBase = base && url.startsWith(base);
14
+ var prefix = hasBase ? base : '';
15
+ var rest = hasBase ? url.substring(base.length) : url;
16
+
17
+ // Find the last dot in the remaining part — that's the file extension.
18
+ var lastDotIdx = rest.lastIndexOf('.');
19
+ if (lastDotIdx === -1) return url;
20
+ var pathPart = rest.substring(0, lastDotIdx);
21
+ var extension = rest.substring(lastDotIdx); // e.g. ".gltf"
22
+
23
+ // Remove all dots in the path portion (they're dimension separators like 34.5).
24
+ return prefix + pathPart.replace(/\./g, '') + extension;
25
+ };
@@ -0,0 +1,45 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ var __jsonCache = new Map(); // url -> Promise<any>
4
+
5
+ export function loadJSON(_x) {
6
+ return _loadJSON.apply(this, arguments);
7
+ }
8
+ function _loadJSON() {
9
+ _loadJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(path) {
10
+ var p;
11
+ return _regeneratorRuntime.wrap(function (_context) {
12
+ while (1) switch (_context.prev = _context.next) {
13
+ case 0:
14
+ if (path) {
15
+ _context.next = 1;
16
+ break;
17
+ }
18
+ return _context.abrupt("return", null);
19
+ case 1:
20
+ if (!__jsonCache.has(path)) {
21
+ _context.next = 2;
22
+ break;
23
+ }
24
+ return _context.abrupt("return", __jsonCache.get(path));
25
+ case 2:
26
+ p = new Promise(function (resolve, reject) {
27
+ var xhr = new XMLHttpRequest();
28
+ xhr.onreadystatechange = function () {
29
+ if (xhr.readyState === XMLHttpRequest.DONE) {
30
+ if (xhr.status === 200) resolve(JSON.parse(xhr.responseText));else reject(xhr);
31
+ }
32
+ };
33
+ xhr.open('GET', path, true);
34
+ xhr.send();
35
+ });
36
+ __jsonCache.set(path, p);
37
+ return _context.abrupt("return", p);
38
+ case 3:
39
+ case "end":
40
+ return _context.stop();
41
+ }
42
+ }, _callee);
43
+ }));
44
+ return _loadJSON.apply(this, arguments);
45
+ }
@@ -199,9 +199,12 @@ function filterFacesBlockedByFaces(sourceFaces, blockingFaces) {
199
199
  var verticallyOverlappedBottomPart = jFace.zTop < iFace.zTop && jFace.zTop > iFace.zBottom && Math.abs(jFace.zTop - iFace.zTop) > EPSILON && Math.abs(jFace.zTop - iFace.zBottom) > EPSILON;
200
200
  var relationship = relationshipOfTwoOverlappedLines(iFace.sectionLine, jFace.sectionLine);
201
201
  if (overlapList.includes(relationship.result)) {
202
- if (verticallyIncluded) removeIdxs.push(i);else if (verticallyOverlappedTopPart) {
202
+ if (verticallyIncluded) {
203
203
  removeIdxs.push(i);
204
- newFaces.push({
204
+ break;
205
+ } else if (verticallyOverlappedTopPart) {
206
+ removeIdxs.push(i);
207
+ var newFace = {
205
208
  sectionLine: iFace.sectionLine,
206
209
  // cm unit
207
210
  zBottom: iFace.zBottom,
@@ -215,10 +218,15 @@ function filterFacesBlockedByFaces(sourceFaces, blockingFaces) {
215
218
  isBackFace: iFace.isBackFace,
216
219
  skinPanelSKU: iFace.skinPanelSKU,
217
220
  itemInfo: iFace.itemInfo
218
- });
221
+ };
222
+ var contourFaces = filterFacesBlockedByFaces([newFace], sourceFaces === blockingFaces ? blockingFaces.filter(function (v, idx) {
223
+ return idx !== i;
224
+ }) : blockingFaces, 0);
225
+ if (contourFaces.length > 0) newFaces = [].concat(_toConsumableArray(newFaces), _toConsumableArray(contourFaces));
226
+ break;
219
227
  } else if (verticallyOverlappedBottomPart) {
220
228
  removeIdxs.push(i);
221
- newFaces.push({
229
+ var _newFace = {
222
230
  sectionLine: iFace.sectionLine,
223
231
  // cm unit
224
232
  zBottom: jFace.zTop,
@@ -232,9 +240,13 @@ function filterFacesBlockedByFaces(sourceFaces, blockingFaces) {
232
240
  isBackFace: iFace.isBackFace,
233
241
  skinPanelSKU: iFace.skinPanelSKU,
234
242
  itemInfo: iFace.itemInfo
235
- });
243
+ };
244
+ var _contourFaces = filterFacesBlockedByFaces([_newFace], sourceFaces === blockingFaces ? blockingFaces.filter(function (v, idx) {
245
+ return idx !== i;
246
+ }) : blockingFaces, 0);
247
+ if (_contourFaces.length > 0) newFaces = [].concat(_toConsumableArray(newFaces), _toConsumableArray(_contourFaces));
248
+ break;
236
249
  }
237
- break;
238
250
  } else if (relationship.result === OVERLAP_SOME && ((_relationship$trimmed = relationship.trimmedSegs) === null || _relationship$trimmed === void 0 ? void 0 : _relationship$trimmed.length) > 0 && verticallyIncluded) {
239
251
  removeIdxs.push(i);
240
252
  var tFaceSegs = getTrimmedFaceSegs([iFace], sourceFaces === blockingFaces ? blockingFaces.filter(function (v, idx) {
@@ -1,17 +1,21 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.loadGLTF = loadGLTF;
7
8
  exports.loadObjWithMaterial = loadObjWithMaterial;
8
9
  exports.scaleObject = scaleObject;
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
12
  var _three = require("three");
10
13
  var _MTLLoader = require("three/examples/jsm/loaders/MTLLoader.js");
11
14
  var _OBJLoader = require("three/examples/jsm/loaders/OBJLoader.js");
12
15
  var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader.js");
13
16
  var _DRACOLoader = require("three/examples/jsm/loaders/DRACOLoader.js");
14
17
  var _constants = require("../../constants");
18
+ var _sanitizeAssetUrl = require("../../shared/domain/asset/sanitize-asset-url");
15
19
  function loadObjWithMaterial(mtlFile, objFile, imgPath) {
16
20
  var manager = new _three.LoadingManager();
17
21
  var mtlLoader = new _MTLLoader.MTLLoader(manager);
@@ -28,48 +32,74 @@ function loadObjWithMaterial(mtlFile, objFile, imgPath) {
28
32
  });
29
33
  });
30
34
  }
31
- function loadGLTF(url) {
32
- if (url == undefined) {
33
- return Promise.reject('No url is passed');
34
- }
35
- var baseURL = _three.LoaderUtils.extractUrlBase(url);
36
- var manager = new _three.LoadingManager();
37
-
38
- // Intercept and override relative URLs.
39
- manager.setURLModifier(function (url, path) {
40
- // URIs in a glTF file may be escaped, or not. Assume that assetMap is
41
- // from an un-escaped source, and decode all URIs before lookups.
42
- // See: https://github.com/donmccurdy/three-gltf-viewer/issues/146
43
- var normalizedURL = decodeURI(url).replace(baseURL, '').replace(/^(\.?\/)/, '');
44
-
45
- // if (assetMap.has(normalizedURL)) {
46
- // const blob = assetMap.get(normalizedURL);
47
- // const blobURL = URL.createObjectURL(blob);
48
- // blobURLs.push(blobURL);
49
- // return blobURL;
50
- // }
51
- return (path || '') + url;
52
- });
53
- var loader = new _GLTFLoader.GLTFLoader(manager);
54
- loader.setCrossOrigin('anonymous');
55
- var dracoLoader = new _DRACOLoader.DRACOLoader();
56
- dracoLoader.setDecoderPath('/assets/draco/');
57
- loader.setDRACOLoader(dracoLoader);
35
+ function loadGLTFInternal(url, manager) {
58
36
  return new Promise(function (resolve, reject) {
37
+ var loader = new _GLTFLoader.GLTFLoader(manager);
38
+ loader.setCrossOrigin('anonymous');
39
+ var dracoLoader = new _DRACOLoader.DRACOLoader();
40
+ dracoLoader.setDecoderPath('/assets/draco/');
41
+ loader.setDRACOLoader(dracoLoader);
59
42
  loader.load(url, function (gltf) {
60
- resolve(gltf.scene);
61
- }, function (xhr) {
62
- // console.log("xhr", xhr);
63
- // called while loading is progressing
64
- // console.log( `${( xhr.loaded / xhr.total * 100 )}% loaded` );
65
- }, function (error) {
66
- // console.log("error", error);
67
- // called when loading has errors
68
- // console.error( '2= An error happened', error );
69
- reject(error);
43
+ return resolve(gltf.scene);
44
+ }, undefined, function (error) {
45
+ return reject(error);
70
46
  });
71
47
  });
72
48
  }
49
+ function loadGLTF(_x) {
50
+ return _loadGLTF.apply(this, arguments);
51
+ }
52
+ function _loadGLTF() {
53
+ _loadGLTF = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(url) {
54
+ var baseURL, manager, sanitized, _t, _t2;
55
+ return _regenerator["default"].wrap(function (_context) {
56
+ while (1) switch (_context.prev = _context.next) {
57
+ case 0:
58
+ if (url) {
59
+ _context.next = 1;
60
+ break;
61
+ }
62
+ throw new Error('No url is passed');
63
+ case 1:
64
+ baseURL = _three.LoaderUtils.extractUrlBase(url);
65
+ manager = new _three.LoadingManager();
66
+ manager.setURLModifier(function (resourceUrl, path) {
67
+ var normalizedURL = decodeURI(resourceUrl).replace(baseURL, '').replace(/^(\.?\/)/, '');
68
+ return (path || '') + resourceUrl;
69
+ });
70
+ sanitized = (0, _sanitizeAssetUrl.sanitizeAssetUrl)(url); // ---- First attempt ----
71
+ _context.prev = 2;
72
+ _context.next = 3;
73
+ return loadGLTFInternal(url, manager);
74
+ case 3:
75
+ return _context.abrupt("return", _context.sent);
76
+ case 4:
77
+ _context.prev = 4;
78
+ _t = _context["catch"](2);
79
+ console.warn('[GLTF] load failed, trying sanitized URL:', sanitized);
80
+
81
+ // Avoid useless retry
82
+ // if (!sanitized || sanitized === url) {
83
+ // throw err;
84
+ // }
85
+ _context.prev = 5;
86
+ _context.next = 6;
87
+ return loadGLTFInternal(sanitized, manager);
88
+ case 6:
89
+ return _context.abrupt("return", _context.sent);
90
+ case 7:
91
+ _context.prev = 7;
92
+ _t2 = _context["catch"](5);
93
+ console.error('[GLTF] failed after fallback:', sanitized);
94
+ throw _t2;
95
+ case 8:
96
+ case "end":
97
+ return _context.stop();
98
+ }
99
+ }, _callee, null, [[2, 4], [5, 7]]);
100
+ }));
101
+ return _loadGLTF.apply(this, arguments);
102
+ }
73
103
  function scaleObject(object, defaultSizeArray, scaleSizeArray) {
74
104
  var boundingBox = new _three.Box3().setFromObject(object);
75
105
  var initialSizeArray = boundingBox.getSize(new _three.Vector3()).toArray();
@@ -27,6 +27,7 @@ var _export = require("../../utils/export");
27
27
  var _utils = require("../../components/viewer2d/utils");
28
28
  var _SVGLoader = require("three/addons/loaders/SVGLoader");
29
29
  var _geometry = require("../../utils/geometry");
30
+ var _loadAssetJson = require("../../shared/domain/asset/load-asset-json");
30
31
  var _excluded = ["ccdf"];
31
32
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
32
33
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -47,59 +48,18 @@ function getPlannerStateFromProps(props) {
47
48
  }
48
49
 
49
50
  // ---- caches: avoid re-fetch/re-parse costs (no behavior change) ----
50
- var __jsonCache = new _immutable.Map(); // url -> Promise<any>
51
51
  var __svgCache = new _immutable.Map(); // url -> Promise<svgData|null>
52
- function loadJSON(_x) {
53
- return _loadJSON.apply(this, arguments);
54
- }
52
+
55
53
  /********Parse TempPlaceholder from cabinetPayloadData **************/
56
- function _loadJSON() {
57
- _loadJSON = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(path) {
58
- var p;
59
- return _regenerator["default"].wrap(function (_context3) {
60
- while (1) switch (_context3.prev = _context3.next) {
61
- case 0:
62
- if (path) {
63
- _context3.next = 1;
64
- break;
65
- }
66
- return _context3.abrupt("return", null);
67
- case 1:
68
- if (!__jsonCache.has(path)) {
69
- _context3.next = 2;
70
- break;
71
- }
72
- return _context3.abrupt("return", __jsonCache.get(path));
73
- case 2:
74
- p = new Promise(function (resolve, reject) {
75
- var xhr = new XMLHttpRequest();
76
- xhr.onreadystatechange = function () {
77
- if (xhr.readyState === XMLHttpRequest.DONE) {
78
- if (xhr.status === 200) resolve(JSON.parse(xhr.responseText));else reject(xhr);
79
- }
80
- };
81
- xhr.open('GET', path, true);
82
- xhr.send();
83
- });
84
- __jsonCache.set(path, p);
85
- return _context3.abrupt("return", p);
86
- case 3:
87
- case "end":
88
- return _context3.stop();
89
- }
90
- }, _callee3);
91
- }));
92
- return _loadJSON.apply(this, arguments);
93
- }
94
- function parseTempPlaceholdersFromCabinetPayload(_x2) {
54
+ function parseTempPlaceholdersFromCabinetPayload(_x) {
95
55
  return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
96
56
  }
97
57
  /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
98
58
  function _parseTempPlaceholdersFromCabinetPayload() {
99
- _parseTempPlaceholdersFromCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(cabinetPayload) {
59
+ _parseTempPlaceholdersFromCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(cabinetPayload) {
100
60
  var link, keys, temp, i, _cabinetPayload$struc, _cabinetPayload$struc2, tempPlaceholdersData, k, _cabinetPayload$struc3, el, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, _t2, _t3, _t4;
101
- return _regenerator["default"].wrap(function (_context4) {
102
- while (1) switch (_context4.prev = _context4.next) {
61
+ return _regenerator["default"].wrap(function (_context3) {
62
+ while (1) switch (_context3.prev = _context3.next) {
103
63
  case 0:
104
64
  link = '';
105
65
  keys = Object.keys(cabinetPayload.structure_json);
@@ -107,27 +67,27 @@ function _parseTempPlaceholdersFromCabinetPayload() {
107
67
  i = 0;
108
68
  case 1:
109
69
  if (!(i < keys.length)) {
110
- _context4.next = 4;
70
+ _context3.next = 4;
111
71
  break;
112
72
  }
113
73
  if (!((_cabinetPayload$struc = cabinetPayload.structure_json[keys[i]]) !== null && _cabinetPayload$struc !== void 0 && (_cabinetPayload$struc = _cabinetPayload$struc.toString()) !== null && _cabinetPayload$struc !== void 0 && _cabinetPayload$struc.includes('.gltf') && (_cabinetPayload$struc2 = cabinetPayload.structure_json[keys[i]]) !== null && _cabinetPayload$struc2 !== void 0 && (_cabinetPayload$struc2 = _cabinetPayload$struc2.toString()) !== null && _cabinetPayload$struc2 !== void 0 && _cabinetPayload$struc2.startsWith('http'))) {
114
- _context4.next = 3;
74
+ _context3.next = 3;
115
75
  break;
116
76
  }
117
77
  link = cabinetPayload.structure_json[keys[i]];
118
78
  _t2 = temp;
119
79
  _t3 = keys[i];
120
- _context4.next = 2;
121
- return loadJSON(link);
80
+ _context3.next = 2;
81
+ return (0, _loadAssetJson.loadJSONWithFallback)(link);
122
82
  case 2:
123
- _t4 = _context4.sent;
83
+ _t4 = _context3.sent;
124
84
  _t2.push.call(_t2, {
125
85
  name: _t3,
126
86
  data: _t4
127
87
  });
128
88
  case 3:
129
89
  i++;
130
- _context4.next = 1;
90
+ _context3.next = 1;
131
91
  break;
132
92
  case 4:
133
93
  tempPlaceholdersData = [];
@@ -436,29 +396,29 @@ function _parseTempPlaceholdersFromCabinetPayload() {
436
396
  structure: cabinetPayload.structure_json.tempPlaceholders[k].structure
437
397
  });
438
398
  }
439
- return _context4.abrupt("return", tempPlaceholdersData);
399
+ return _context3.abrupt("return", tempPlaceholdersData);
440
400
  case 5:
441
401
  case "end":
442
- return _context4.stop();
402
+ return _context3.stop();
443
403
  }
444
- }, _callee4);
404
+ }, _callee3);
445
405
  }));
446
406
  return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
447
407
  }
448
- function updateCabinetPayload(_x3) {
408
+ function updateCabinetPayload(_x2) {
449
409
  return _updateCabinetPayload.apply(this, arguments);
450
410
  }
451
411
  function _updateCabinetPayload() {
452
- _updateCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(cabinetPayload) {
412
+ _updateCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(cabinetPayload) {
453
413
  var tempPlaceholders, cabinetPayloadKeys, i;
454
- return _regenerator["default"].wrap(function (_context5) {
455
- while (1) switch (_context5.prev = _context5.next) {
414
+ return _regenerator["default"].wrap(function (_context4) {
415
+ while (1) switch (_context4.prev = _context4.next) {
456
416
  case 0:
457
417
  tempPlaceholders = [];
458
- _context5.next = 1;
418
+ _context4.next = 1;
459
419
  return parseTempPlaceholdersFromCabinetPayload(cabinetPayload);
460
420
  case 1:
461
- tempPlaceholders = _context5.sent;
421
+ tempPlaceholders = _context4.sent;
462
422
  cabinetPayloadKeys = Object.keys(cabinetPayload);
463
423
  for (i = 0; i < cabinetPayloadKeys.length; i++) {
464
424
  if (cabinetPayloadKeys[i] === 'structure_json') {
@@ -470,12 +430,12 @@ function _updateCabinetPayload() {
470
430
  cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] = tempPlaceholders;
471
431
  }
472
432
  }
473
- return _context5.abrupt("return", cabinetPayload);
433
+ return _context4.abrupt("return", cabinetPayload);
474
434
  case 2:
475
435
  case "end":
476
- return _context5.stop();
436
+ return _context4.stop();
477
437
  }
478
- }, _callee5);
438
+ }, _callee4);
479
439
  }));
480
440
  return _updateCabinetPayload.apply(this, arguments);
481
441
  }
@@ -547,7 +507,7 @@ var loadSVGsByItem = /*#__PURE__*/function () {
547
507
  }
548
508
  }, _callee2);
549
509
  }));
550
- return function loadSVGsByItem(_x4) {
510
+ return function loadSVGsByItem(_x3) {
551
511
  return _ref.apply(this, arguments);
552
512
  };
553
513
  }();
@@ -570,29 +530,29 @@ function populateCCDFList(param) {
570
530
  }
571
531
  return definition;
572
532
  }
573
- function addItemToCatalog(_x5, _x6, _x7, _x8) {
533
+ function addItemToCatalog(_x4, _x5, _x6, _x7) {
574
534
  return _addItemToCatalog.apply(this, arguments);
575
535
  } // Get attributs of current selected element
576
536
  function _addItemToCatalog() {
577
- _addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(element, state, catalogInstance, projectActions) {
537
+ _addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(element, state, catalogInstance, projectActions) {
578
538
  var _elementJs, _elementJs3;
579
539
  var elementJs, outlineSVGData, _state$getIn, _elementJs$structure_, _elementJs$structure_2, _elementJs$structure_3, cds, _cds$find, _elementJs2, currentCdsId, cdsIdx, ttph, updatedStructureJson, catalogElements, catalogElementKeys, catalogItem, k, _catalogElements$cata, tempPlaceholderArray, _catalogItem$structur, newTempPlaceholderArray, mergedTempPlaceholder;
580
- return _regenerator["default"].wrap(function (_context6) {
581
- while (1) switch (_context6.prev = _context6.next) {
540
+ return _regenerator["default"].wrap(function (_context5) {
541
+ while (1) switch (_context5.prev = _context5.next) {
582
542
  case 0:
583
543
  if (!(0, _helper.isEmpty)(element === null || element === void 0 ? void 0 : element.name)) {
584
- _context6.next = 1;
544
+ _context5.next = 1;
585
545
  break;
586
546
  }
587
- return _context6.abrupt("return");
547
+ return _context5.abrupt("return");
588
548
  case 1:
589
549
  elementJs = populateCCDFList(element); // if (isEmpty(catalog?.elements[element.name])) {
590
- _context6.next = 2;
550
+ _context5.next = 2;
591
551
  return loadSVGsByItem(elementJs);
592
552
  case 2:
593
- outlineSVGData = _context6.sent;
553
+ outlineSVGData = _context5.sent;
594
554
  if (!(((_elementJs = elementJs) === null || _elementJs === void 0 ? void 0 : _elementJs.type) === 'cabinet')) {
595
- _context6.next = 4;
555
+ _context5.next = 4;
596
556
  break;
597
557
  }
598
558
  // move the tempPlaceholder of current door style to first of tempPlaceholders array
@@ -620,13 +580,13 @@ function _addItemToCatalog() {
620
580
  }
621
581
  });
622
582
  if ((0, _helper.isEmpty)((_elementJs$structure_3 = elementJs.structure_json) === null || _elementJs$structure_3 === void 0 ? void 0 : _elementJs$structure_3.tempPlaceholders)) {
623
- _context6.next = 4;
583
+ _context5.next = 4;
624
584
  break;
625
585
  }
626
- _context6.next = 3;
586
+ _context5.next = 3;
627
587
  return updateCabinetPayload(elementJs);
628
588
  case 3:
629
- elementJs = _context6.sent;
589
+ elementJs = _context5.sent;
630
590
  case 4:
631
591
  elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
632
592
  outlineSVGData: outlineSVGData,
@@ -643,18 +603,18 @@ function _addItemToCatalog() {
643
603
  k = 0;
644
604
  case 5:
645
605
  if (!(k < catalogElementKeys.length)) {
646
- _context6.next = 7;
606
+ _context5.next = 7;
647
607
  break;
648
608
  }
649
609
  if (!(((_catalogElements$cata = catalogElements[catalogElementKeys[k]]) === null || _catalogElements$cata === void 0 ? void 0 : _catalogElements$cata.itemID) === elementJs.itemID)) {
650
- _context6.next = 6;
610
+ _context5.next = 6;
651
611
  break;
652
612
  }
653
613
  catalogItem = catalogElements[catalogElementKeys[k]];
654
- return _context6.abrupt("continue", 7);
614
+ return _context5.abrupt("continue", 7);
655
615
  case 6:
656
616
  k++;
657
- _context6.next = 5;
617
+ _context5.next = 5;
658
618
  break;
659
619
  case 7:
660
620
  // get old tempPlaceholder array from catalog item
@@ -685,9 +645,9 @@ function _addItemToCatalog() {
685
645
  }
686
646
  case 8:
687
647
  case "end":
688
- return _context6.stop();
648
+ return _context5.stop();
689
649
  }
690
- }, _callee6);
650
+ }, _callee5);
691
651
  }));
692
652
  return _addItemToCatalog.apply(this, arguments);
693
653
  }
@@ -1047,15 +1007,15 @@ function getElement(objProps, state) {
1047
1007
  }
1048
1008
  return curObject;
1049
1009
  }
1050
- function loadMoldingSvg(_x9) {
1010
+ function loadMoldingSvg(_x8) {
1051
1011
  return _loadMoldingSvg.apply(this, arguments);
1052
1012
  }
1053
1013
  function _loadMoldingSvg() {
1054
- _loadMoldingSvg = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(molding) {
1055
- return _regenerator["default"].wrap(function (_context7) {
1056
- while (1) switch (_context7.prev = _context7.next) {
1014
+ _loadMoldingSvg = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(molding) {
1015
+ return _regenerator["default"].wrap(function (_context6) {
1016
+ while (1) switch (_context6.prev = _context6.next) {
1057
1017
  case 0:
1058
- return _context7.abrupt("return", new Promise(function (resolve, reject) {
1018
+ return _context6.abrupt("return", new Promise(function (resolve, reject) {
1059
1019
  var url = molding === null || molding === void 0 ? void 0 : molding.shape_svg;
1060
1020
  if (!url) {
1061
1021
  // Skip if no SVG URL available
@@ -1077,9 +1037,9 @@ function _loadMoldingSvg() {
1077
1037
  }));
1078
1038
  case 1:
1079
1039
  case "end":
1080
- return _context7.stop();
1040
+ return _context6.stop();
1081
1041
  }
1082
- }, _callee7);
1042
+ }, _callee6);
1083
1043
  }));
1084
1044
  return _loadMoldingSvg.apply(this, arguments);
1085
1045
  }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.loadJSONWithFallback = loadJSONWithFallback;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _loadJson = require("../../network/load-json");
11
+ var _sanitizeAssetUrl = require("./sanitize-asset-url");
12
+ function loadJSONWithFallback(_x) {
13
+ return _loadJSONWithFallback.apply(this, arguments);
14
+ }
15
+ function _loadJSONWithFallback() {
16
+ _loadJSONWithFallback = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(path) {
17
+ var sanitized, _t, _t2;
18
+ return _regenerator["default"].wrap(function (_context) {
19
+ while (1) switch (_context.prev = _context.next) {
20
+ case 0:
21
+ if (path) {
22
+ _context.next = 1;
23
+ break;
24
+ }
25
+ return _context.abrupt("return", null);
26
+ case 1:
27
+ sanitized = (0, _sanitizeAssetUrl.sanitizeAssetUrl)(path);
28
+ _context.prev = 2;
29
+ _context.next = 3;
30
+ return (0, _loadJson.loadJSON)(path);
31
+ case 3:
32
+ return _context.abrupt("return", _context.sent);
33
+ case 4:
34
+ _context.prev = 4;
35
+ _t = _context["catch"](2);
36
+ console.warn('[GLTF load failed, retrying with sanitized URL]', sanitized);
37
+ _context.prev = 5;
38
+ if (!(!sanitized || sanitized === path)) {
39
+ _context.next = 6;
40
+ break;
41
+ }
42
+ throw _t;
43
+ case 6:
44
+ _context.next = 7;
45
+ return (0, _loadJson.loadJSON)(sanitized);
46
+ case 7:
47
+ return _context.abrupt("return", _context.sent);
48
+ case 8:
49
+ _context.prev = 8;
50
+ _t2 = _context["catch"](5);
51
+ console.error('[GLTF load failed after retry]');
52
+ return _context.abrupt("return", null);
53
+ case 9:
54
+ case "end":
55
+ return _context.stop();
56
+ }
57
+ }, _callee, null, [[2, 4], [5, 8]]);
58
+ }));
59
+ return _loadJSONWithFallback.apply(this, arguments);
60
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sanitizeAssetUrl = void 0;
7
+ /**
8
+ * Strip stray dots from the **path portion** of a GLTF/BIN URL.
9
+ * e.g. `…/B36_36x34.5x24.gltf` → `…/B36_36x345x24.gltf`
10
+ *
11
+ * Leaves the protocol/domain and the final file extension untouched.
12
+ */
13
+ var sanitizeAssetUrl = exports.sanitizeAssetUrl = function sanitizeAssetUrl(url) {
14
+ if (!url) return url;
15
+ var parsed = new URL(url);
16
+
17
+ // If the URL starts with the S3 base, only sanitize the path after it.
18
+ var base = parsed.origin; // https://industry-media.addovisuals.com
19
+ var hasBase = base && url.startsWith(base);
20
+ var prefix = hasBase ? base : '';
21
+ var rest = hasBase ? url.substring(base.length) : url;
22
+
23
+ // Find the last dot in the remaining part — that's the file extension.
24
+ var lastDotIdx = rest.lastIndexOf('.');
25
+ if (lastDotIdx === -1) return url;
26
+ var pathPart = rest.substring(0, lastDotIdx);
27
+ var extension = rest.substring(lastDotIdx); // e.g. ".gltf"
28
+
29
+ // Remove all dots in the path portion (they're dimension separators like 34.5).
30
+ return prefix + pathPart.replace(/\./g, '') + extension;
31
+ };
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.loadJSON = loadJSON;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var __jsonCache = new Map(); // url -> Promise<any>
11
+ function loadJSON(_x) {
12
+ return _loadJSON.apply(this, arguments);
13
+ }
14
+ function _loadJSON() {
15
+ _loadJSON = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(path) {
16
+ var p;
17
+ return _regenerator["default"].wrap(function (_context) {
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ if (path) {
21
+ _context.next = 1;
22
+ break;
23
+ }
24
+ return _context.abrupt("return", null);
25
+ case 1:
26
+ if (!__jsonCache.has(path)) {
27
+ _context.next = 2;
28
+ break;
29
+ }
30
+ return _context.abrupt("return", __jsonCache.get(path));
31
+ case 2:
32
+ p = new Promise(function (resolve, reject) {
33
+ var xhr = new XMLHttpRequest();
34
+ xhr.onreadystatechange = function () {
35
+ if (xhr.readyState === XMLHttpRequest.DONE) {
36
+ if (xhr.status === 200) resolve(JSON.parse(xhr.responseText));else reject(xhr);
37
+ }
38
+ };
39
+ xhr.open('GET', path, true);
40
+ xhr.send();
41
+ });
42
+ __jsonCache.set(path, p);
43
+ return _context.abrupt("return", p);
44
+ case 3:
45
+ case "end":
46
+ return _context.stop();
47
+ }
48
+ }, _callee);
49
+ }));
50
+ return _loadJSON.apply(this, arguments);
51
+ }
@@ -207,9 +207,12 @@ function filterFacesBlockedByFaces(sourceFaces, blockingFaces) {
207
207
  var verticallyOverlappedBottomPart = jFace.zTop < iFace.zTop && jFace.zTop > iFace.zBottom && Math.abs(jFace.zTop - iFace.zTop) > _constants.EPSILON && Math.abs(jFace.zTop - iFace.zBottom) > _constants.EPSILON;
208
208
  var relationship = (0, _geometry.relationshipOfTwoOverlappedLines)(iFace.sectionLine, jFace.sectionLine);
209
209
  if (overlapList.includes(relationship.result)) {
210
- if (verticallyIncluded) removeIdxs.push(i);else if (verticallyOverlappedTopPart) {
210
+ if (verticallyIncluded) {
211
211
  removeIdxs.push(i);
212
- newFaces.push({
212
+ break;
213
+ } else if (verticallyOverlappedTopPart) {
214
+ removeIdxs.push(i);
215
+ var newFace = {
213
216
  sectionLine: iFace.sectionLine,
214
217
  // cm unit
215
218
  zBottom: iFace.zBottom,
@@ -223,10 +226,15 @@ function filterFacesBlockedByFaces(sourceFaces, blockingFaces) {
223
226
  isBackFace: iFace.isBackFace,
224
227
  skinPanelSKU: iFace.skinPanelSKU,
225
228
  itemInfo: iFace.itemInfo
226
- });
229
+ };
230
+ var contourFaces = filterFacesBlockedByFaces([newFace], sourceFaces === blockingFaces ? blockingFaces.filter(function (v, idx) {
231
+ return idx !== i;
232
+ }) : blockingFaces, 0);
233
+ if (contourFaces.length > 0) newFaces = [].concat((0, _toConsumableArray2["default"])(newFaces), (0, _toConsumableArray2["default"])(contourFaces));
234
+ break;
227
235
  } else if (verticallyOverlappedBottomPart) {
228
236
  removeIdxs.push(i);
229
- newFaces.push({
237
+ var _newFace = {
230
238
  sectionLine: iFace.sectionLine,
231
239
  // cm unit
232
240
  zBottom: jFace.zTop,
@@ -240,9 +248,13 @@ function filterFacesBlockedByFaces(sourceFaces, blockingFaces) {
240
248
  isBackFace: iFace.isBackFace,
241
249
  skinPanelSKU: iFace.skinPanelSKU,
242
250
  itemInfo: iFace.itemInfo
243
- });
251
+ };
252
+ var _contourFaces = filterFacesBlockedByFaces([_newFace], sourceFaces === blockingFaces ? blockingFaces.filter(function (v, idx) {
253
+ return idx !== i;
254
+ }) : blockingFaces, 0);
255
+ if (_contourFaces.length > 0) newFaces = [].concat((0, _toConsumableArray2["default"])(newFaces), (0, _toConsumableArray2["default"])(_contourFaces));
256
+ break;
244
257
  }
245
- break;
246
258
  } else if (relationship.result === _constants.OVERLAP_SOME && ((_relationship$trimmed = relationship.trimmedSegs) === null || _relationship$trimmed === void 0 ? void 0 : _relationship$trimmed.length) > 0 && verticallyIncluded) {
247
259
  removeIdxs.push(i);
248
260
  var tFaceSegs = getTrimmedFaceSegs([iFace], sourceFaces === blockingFaces ? blockingFaces.filter(function (v, idx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "11.4.0",
3
+ "version": "11.6.0",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",