kitchen-simulator 11.36.0 → 11.38.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.
@@ -40,7 +40,7 @@ var _threeMemoryCleaner = require("./three-memory-cleaner");
40
40
  var _constants = require("../../constants");
41
41
  var _export = require("../../utils/export");
42
42
  var _convertUnitsLite = require("../../utils/convert-units-lite");
43
- var _geometry2 = require("../../utils/geometry");
43
+ var _geometry3 = require("../../utils/geometry");
44
44
  var GeomUtils = _interopRequireWildcard(require("../../catalog/utils/geom-utils"));
45
45
  var _itemLoader = require("../../catalog/utils/item-loader");
46
46
  var _cabinetWarning = require("../../shared/domain/cabinet-warning");
@@ -923,7 +923,7 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
923
923
  }
924
924
  function getDistances(layer, curItem, isCalcWall) {
925
925
  // matching fvLine distance with OP
926
- var pointArray = (0, _geometry2.calcDistancesFromItemToWalls)(curItem, layer).PointArray;
926
+ var pointArray = (0, _geometry3.calcDistancesFromItemToWalls)(curItem, layer).PointArray;
927
927
  if ((pointArray === null || pointArray === void 0 ? void 0 : pointArray.length) > 0) {
928
928
  var _loop2 = function _loop2() {
929
929
  var direction = i === 0 ? 90 : i === 1 ? -90 : i === 2 ? 180 : 0;
@@ -2758,6 +2758,12 @@ function isSingleQuadrilateral(groupCount, pointGroup) {
2758
2758
  * @param model - molding info that appear in real 3D
2759
2759
  */
2760
2760
  function moldingVertices(mPointGroup, mdGeo, MDV, model, svg_width, svg_height, groupCount) {
2761
+ // Guard against bad SVG metadata (missing/zero dimensions) which would produce NaN/Infinity vertices.
2762
+ if (!Number.isFinite(svg_width) || !Number.isFinite(svg_height) || svg_width <= 0 || svg_height <= 0) {
2763
+ mdGeo.setAttribute('position', new Three.BufferAttribute(new Float32Array(), 3));
2764
+ mdGeo.needsUpdate = true;
2765
+ return mdGeo;
2766
+ }
2761
2767
  var pointGroup = mPointGroup;
2762
2768
  var length = pointGroup.length;
2763
2769
  var isSnap = true;
@@ -2835,15 +2841,19 @@ function moldingVertices(mPointGroup, mdGeo, MDV, model, svg_width, svg_height,
2835
2841
  }
2836
2842
  vecNorm.rotateAround(o, Math.PI / 2 - alpha);
2837
2843
  vecNorm.normalize();
2838
- vecNorm.multiplyScalar(1 / Math.sin(alpha));
2844
+ var sinAlpha = Math.sin(alpha);
2845
+ if (Math.abs(sinAlpha) > 1e-6) {
2846
+ vecNorm.multiplyScalar(1 / sinAlpha);
2847
+ }
2839
2848
 
2840
2849
  // Make 3D Points
2841
2850
  MDV.forEach(function (p) {
2842
2851
  var x = cur.x - vecNorm.x * ((p.x / svg_width - 0.5) * model.length);
2843
2852
  var y = (0.5 - p.y / svg_height) * model.width;
2844
2853
  var z = -cur.y + vecNorm.y * ((p.x / svg_width - 0.5) * model.length);
2845
- if (mdGeo.attributes.hasOwnProperty('position')) verticesArray = mdGeo.attributes.position.array;
2846
- verticesArray.push(x, y, z);
2854
+ if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z)) {
2855
+ verticesArray.push(x, y, z);
2856
+ }
2847
2857
  });
2848
2858
  });
2849
2859
  var mdGeo1 = mdGeo.setAttribute('position', new Three.BufferAttribute(new Float32Array(verticesArray), 3));
@@ -2976,7 +2986,7 @@ function sameSign(pos1, pos2, pos3) {
2976
2986
  function getTotalDistance(pos, rect) {
2977
2987
  var sum = 0;
2978
2988
  for (var i = 0; i < rect.length; i++) {
2979
- sum += (0, _geometry2.verticesDistance)(pos, rect[i]);
2989
+ sum += (0, _geometry3.verticesDistance)(pos, rect[i]);
2980
2990
  }
2981
2991
  return sum;
2982
2992
  }
@@ -3031,7 +3041,7 @@ function createBacksplash(item, layer, planData, scene) {
3031
3041
  }
3032
3042
 
3033
3043
  // Get current wall line that item is snapped
3034
- var wLines = (_getSnappedWallLines = (0, _geometry2.getSnappedWallLines)(item.itemInfo, layer, planData.catalog)) === null || _getSnappedWallLines === void 0 ? void 0 : _getSnappedWallLines.filter(function (sLine) {
3044
+ var wLines = (_getSnappedWallLines = (0, _geometry3.getSnappedWallLines)(item.itemInfo, layer, planData.catalog)) === null || _getSnappedWallLines === void 0 ? void 0 : _getSnappedWallLines.filter(function (sLine) {
3035
3045
  return sLine.snapSide === 'front';
3036
3046
  });
3037
3047
  var curLine = wLines.length > 0 ? wLines[0] : null;
@@ -3068,7 +3078,7 @@ function createBacksplash(item, layer, planData, scene) {
3068
3078
  var altitudeUnit = ((_wallItem$itemInfo2 = wallItem.itemInfo) === null || _wallItem$itemInfo2 === void 0 || (_wallItem$itemInfo2 = _wallItem$itemInfo2.properties) === null || _wallItem$itemInfo2 === void 0 ? void 0 : _wallItem$itemInfo2.get('altitude').get('_unit')) || 'cm';
3069
3079
  if (!(0, _helper.isEmpty)(altitude) && !(0, _helper.isEmpty)(altitudeUnit)) {
3070
3080
  altitude = (0, _convertUnitsLite.convert)(altitude).from(altitudeUnit).to('cm');
3071
- var altPoints = (0, _geometry2.getLineSnapPointsOfItem)(layer, curLine, wallItem);
3081
+ var altPoints = (0, _geometry3.getLineSnapPointsOfItem)(layer, curLine, wallItem);
3072
3082
  if (altPoints.length > 1) {
3073
3083
  D0 = altPoints[0];
3074
3084
  D1 = altPoints[1];
@@ -3091,7 +3101,7 @@ function createBacksplash(item, layer, planData, scene) {
3091
3101
  var v0 = (_layer$vertices = layer.vertices) === null || _layer$vertices === void 0 ? void 0 : _layer$vertices.get(line === null || line === void 0 || (_line$vertices = line.vertices) === null || _line$vertices === void 0 ? void 0 : _line$vertices.get(0));
3092
3102
  var v1 = (_layer$vertices2 = layer.vertices) === null || _layer$vertices2 === void 0 ? void 0 : _layer$vertices2.get(line === null || line === void 0 || (_line$vertices2 = line.vertices) === null || _line$vertices2 === void 0 ? void 0 : _line$vertices2.get(1));
3093
3103
  if (!(0, _helper.isEmpty)(v0) || !(0, _helper.isEmpty)(v1)) {
3094
- var lineLength = (0, _geometry2.pointsDistance)(v0.x, v0.y, v1.x, v1.y);
3104
+ var lineLength = (0, _geometry3.pointsDistance)(v0.x, v0.y, v1.x, v1.y);
3095
3105
  var disD0 = lineLength * hole.offset - width / 2;
3096
3106
  var disD1 = lineLength * hole.offset + width / 2;
3097
3107
  D0 = {
@@ -3116,7 +3126,7 @@ function createBacksplash(item, layer, planData, scene) {
3116
3126
  if (altItems.length > 0) {
3117
3127
  depth = altItems[0].altitude;
3118
3128
  altItems.map(function (altItem) {
3119
- if ((0, _geometry2.isOverlappedTwoItemsOnOneLine)(layer, curLine, item, altItem)) {
3129
+ if ((0, _geometry3.isOverlappedTwoItemsOnOneLine)(layer, curLine, item, altItem)) {
3120
3130
  if (depth >= altItem.altitude) {
3121
3131
  depth = altItem.altitude;
3122
3132
  flag = true;
@@ -3284,7 +3294,7 @@ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag)
3284
3294
  // let layoutType = molding.items[0].layoutpos;
3285
3295
  // let visible = molding.items[0];
3286
3296
  molding.pointGroups.forEach(function (pointGroup) {
3287
- var _child$width_unit, _child$height_unit, _child$length_unit;
3297
+ var _child$width_unit, _child$height_unit, _child$length_unit, _geometry2;
3288
3298
  var geometry = new Three.BufferGeometry();
3289
3299
  var length = data.length; //point array
3290
3300
  var widthUnit = child.width_unit === 'inch' ? 'in' : (_child$width_unit = child.width_unit) !== null && _child$width_unit !== void 0 ? _child$width_unit : 'in';
@@ -3298,6 +3308,10 @@ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag)
3298
3308
  child.length_unit = 'cm';
3299
3309
  geometry.needsUpdate = true;
3300
3310
  geometry = moldingVertices(pointGroup, geometry, data, child, svg_width, svg_height, molding.pointGroups.length);
3311
+ // If we failed to generate positions (bad SVG/model data), skip this molding group.
3312
+ if (!((_geometry2 = geometry) !== null && _geometry2 !== void 0 && (_geometry2 = _geometry2.attributes) !== null && _geometry2 !== void 0 && _geometry2.position) || geometry.attributes.position.count < 3) {
3313
+ return;
3314
+ }
3301
3315
  var total = geometry.attributes.position.count;
3302
3316
  var len = geometry.attributes.position.count / length;
3303
3317
  if (!_export.GeometryUtils.samePoints(pointGroup[0], pointGroup[pointGroup.length - 1])) {
@@ -3341,7 +3355,7 @@ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag)
3341
3355
  x: data[_i2 + 1].x,
3342
3356
  y: data[_i2 + 1].y
3343
3357
  };
3344
- var posDistance = (0, _geometry2.verticesDistance)(v1, v2);
3358
+ var posDistance = (0, _geometry3.verticesDistance)(v1, v2);
3345
3359
  sumDistance += posDistance;
3346
3360
  if (_i2 === data.length - 2) finalDistance = sumDistance;
3347
3361
  sumDistanceArray.push(sumDistance);
@@ -3678,7 +3692,7 @@ function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
3678
3692
  }).toJS()[0] : (_mg$items$4 = mg.items[0]) === null || _mg$items$4 === void 0 || (_mg$items$4 = _mg$items$4.molding) === null || _mg$items$4 === void 0 ? void 0 : _mg$items$4.filter(function (mol) {
3679
3693
  return (mol === null || mol === void 0 ? void 0 : mol.location_type) === mg.location_type;
3680
3694
  })[0];
3681
- if (mg.molding === null || mg.molding.itemID !== mol.itemID || mg.lines === null || mg.points === null) {
3695
+ if (mg.molding === null || mg.molding.itemID !== molding.itemID || mg.lines === null || mg.points === null) {
3682
3696
  var _mg$molding;
3683
3697
  if (mg.molding !== null && ((_mg$molding = mg.molding) === null || _mg$molding === void 0 ? void 0 : _mg$molding.itemID) !== molding.itemID) {
3684
3698
  deleteMGMesh(mg, planData, mode);
@@ -9,6 +9,7 @@ exports.getElement = getElement;
9
9
  exports.getPlannerStateFromProps = getPlannerStateFromProps;
10
10
  exports.loadMoldingSvg = loadMoldingSvg;
11
11
  exports.mergeSameElements = mergeSameElements;
12
+ exports.prepareMoldingCCDFList = prepareMoldingCCDFList;
12
13
  exports.updateAttributeOfSelectedElement = updateAttributeOfSelectedElement;
13
14
  exports.updatePropertyOfSelectedElement = updatePropertyOfSelectedElement;
14
15
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
@@ -408,7 +409,7 @@ function _parseTempPlaceholdersFromCabinetPayload() {
408
409
  }
409
410
  });
410
411
  tempPlaceholdersData.push({
411
- id: parseInt(el, 10),
412
+ id: el,
412
413
  placeholders: tempData,
413
414
  structure: cabinetPayload.structure_json.tempPlaceholders[k].structure
414
415
  });
@@ -1038,11 +1039,19 @@ function _loadMoldingSvg() {
1038
1039
  }
1039
1040
  var loader = new _SVGLoader.SVGLoader();
1040
1041
  loader.load(url, function (data) {
1041
- var _data$xml$viewBox$ani, _data$xml, _data$xml$viewBox$ani2, _data$xml2;
1042
+ var _data$xml$viewBox$ani, _data$xml, _data$xml2, _data$xml$viewBox$ani2, _data$xml3, _data$xml4, _data$xml$width$animV, _data$xml5, _data$xml6, _data$xml$height$anim, _data$xml7, _data$xml8, _ref6, _ref7;
1043
+ // Some SVGs omit a viewBox; fall back to width/height to avoid 0 dimensions.
1044
+ // 0/invalid svg_width/svg_height later causes NaN/Infinity vertex positions in 3D molding meshes.
1045
+ var viewBoxWidth = (_data$xml$viewBox$ani = (_data$xml = data.xml) === null || _data$xml === void 0 || (_data$xml = _data$xml.viewBox) === null || _data$xml === void 0 || (_data$xml = _data$xml.animVal) === null || _data$xml === void 0 ? void 0 : _data$xml.width) !== null && _data$xml$viewBox$ani !== void 0 ? _data$xml$viewBox$ani : (_data$xml2 = data.xml) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.viewBox) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.baseVal) === null || _data$xml2 === void 0 ? void 0 : _data$xml2.width;
1046
+ var viewBoxHeight = (_data$xml$viewBox$ani2 = (_data$xml3 = data.xml) === null || _data$xml3 === void 0 || (_data$xml3 = _data$xml3.viewBox) === null || _data$xml3 === void 0 || (_data$xml3 = _data$xml3.animVal) === null || _data$xml3 === void 0 ? void 0 : _data$xml3.height) !== null && _data$xml$viewBox$ani2 !== void 0 ? _data$xml$viewBox$ani2 : (_data$xml4 = data.xml) === null || _data$xml4 === void 0 || (_data$xml4 = _data$xml4.viewBox) === null || _data$xml4 === void 0 || (_data$xml4 = _data$xml4.baseVal) === null || _data$xml4 === void 0 ? void 0 : _data$xml4.height;
1047
+ var attrWidth = (_data$xml$width$animV = (_data$xml5 = data.xml) === null || _data$xml5 === void 0 || (_data$xml5 = _data$xml5.width) === null || _data$xml5 === void 0 || (_data$xml5 = _data$xml5.animVal) === null || _data$xml5 === void 0 ? void 0 : _data$xml5.value) !== null && _data$xml$width$animV !== void 0 ? _data$xml$width$animV : (_data$xml6 = data.xml) === null || _data$xml6 === void 0 || (_data$xml6 = _data$xml6.width) === null || _data$xml6 === void 0 || (_data$xml6 = _data$xml6.baseVal) === null || _data$xml6 === void 0 ? void 0 : _data$xml6.value;
1048
+ var attrHeight = (_data$xml$height$anim = (_data$xml7 = data.xml) === null || _data$xml7 === void 0 || (_data$xml7 = _data$xml7.height) === null || _data$xml7 === void 0 || (_data$xml7 = _data$xml7.animVal) === null || _data$xml7 === void 0 ? void 0 : _data$xml7.value) !== null && _data$xml$height$anim !== void 0 ? _data$xml$height$anim : (_data$xml8 = data.xml) === null || _data$xml8 === void 0 || (_data$xml8 = _data$xml8.height) === null || _data$xml8 === void 0 || (_data$xml8 = _data$xml8.baseVal) === null || _data$xml8 === void 0 ? void 0 : _data$xml8.value;
1049
+ var svg_width = Number((_ref6 = viewBoxWidth !== null && viewBoxWidth !== void 0 ? viewBoxWidth : attrWidth) !== null && _ref6 !== void 0 ? _ref6 : 0);
1050
+ var svg_height = Number((_ref7 = viewBoxHeight !== null && viewBoxHeight !== void 0 ? viewBoxHeight : attrHeight) !== null && _ref7 !== void 0 ? _ref7 : 0);
1042
1051
  molding.data = {
1043
1052
  paths: data.paths,
1044
- svg_width: (_data$xml$viewBox$ani = (_data$xml = data.xml) === null || _data$xml === void 0 || (_data$xml = _data$xml.viewBox) === null || _data$xml === void 0 || (_data$xml = _data$xml.animVal) === null || _data$xml === void 0 ? void 0 : _data$xml.width) !== null && _data$xml$viewBox$ani !== void 0 ? _data$xml$viewBox$ani : 0,
1045
- svg_height: (_data$xml$viewBox$ani2 = (_data$xml2 = data.xml) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.viewBox) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.animVal) === null || _data$xml2 === void 0 ? void 0 : _data$xml2.height) !== null && _data$xml$viewBox$ani2 !== void 0 ? _data$xml$viewBox$ani2 : 0
1053
+ svg_width: Number.isFinite(svg_width) ? svg_width : 0,
1054
+ svg_height: Number.isFinite(svg_height) ? svg_height : 0
1046
1055
  };
1047
1056
  resolve();
1048
1057
  }, null, function (error) {
@@ -1082,4 +1091,21 @@ function mergeSameElements(projectItemsCatalog) {
1082
1091
  _loop(i);
1083
1092
  }
1084
1093
  return result;
1094
+ }
1095
+ function prepareMoldingCCDFList(doorStyle, moldingData) {
1096
+ var moldingCCDFs = [];
1097
+ for (var i = 0; i < moldingData.length; i++) {
1098
+ var _molding$ccdf$catalog, _molding$ccdf, _molding$ccdf$cabinet, _molding$ccdf2, _doorStyle$id, _molding$long_name;
1099
+ var molding = moldingData[i];
1100
+ moldingCCDFs.push({
1101
+ sizeinfo: molding.sizeinfo,
1102
+ catalog_cabinet_sku: (_molding$ccdf$catalog = molding === null || molding === void 0 || (_molding$ccdf = molding.ccdf) === null || _molding$ccdf === void 0 ? void 0 : _molding$ccdf.catalog_cabinet_sku) !== null && _molding$ccdf$catalog !== void 0 ? _molding$ccdf$catalog : molding.sku_number,
1103
+ cabinet_id: (_molding$ccdf$cabinet = molding === null || molding === void 0 || (_molding$ccdf2 = molding.ccdf) === null || _molding$ccdf2 === void 0 ? void 0 : _molding$ccdf2.cabinet_id) !== null && _molding$ccdf$cabinet !== void 0 ? _molding$ccdf$cabinet : molding.itemID,
1104
+ ccdf: molding.ccdf,
1105
+ target_door_finish_id: (_doorStyle$id = doorStyle === null || doorStyle === void 0 ? void 0 : doorStyle.id) !== null && _doorStyle$id !== void 0 ? _doorStyle$id : null,
1106
+ long_name: (_molding$long_name = molding === null || molding === void 0 ? void 0 : molding.long_name) !== null && _molding$long_name !== void 0 ? _molding$long_name : null,
1107
+ id: molding.itemID
1108
+ });
1109
+ }
1110
+ return moldingCCDFs;
1085
1111
  }
@@ -8,23 +8,7 @@ exports.handleChangeDoorStyleEvent = handleChangeDoorStyleEvent;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
10
  var _asyncPool = require("../../shared/concurrency/async-pool");
11
- function prepareMoldingCCDFList(doorStyle, moldingData) {
12
- var moldingCCDFs = [];
13
- for (var i = 0; i < moldingData.length; i++) {
14
- var _molding$ccdf$catalog, _molding$ccdf, _molding$ccdf$cabinet, _molding$ccdf2, _doorStyle$id, _molding$long_name;
15
- var molding = moldingData[i];
16
- moldingCCDFs.push({
17
- sizeinfo: molding.sizeinfo,
18
- catalog_cabinet_sku: (_molding$ccdf$catalog = molding === null || molding === void 0 || (_molding$ccdf = molding.ccdf) === null || _molding$ccdf === void 0 ? void 0 : _molding$ccdf.catalog_cabinet_sku) !== null && _molding$ccdf$catalog !== void 0 ? _molding$ccdf$catalog : molding.sku_number,
19
- cabinet_id: (_molding$ccdf$cabinet = molding === null || molding === void 0 || (_molding$ccdf2 = molding.ccdf) === null || _molding$ccdf2 === void 0 ? void 0 : _molding$ccdf2.cabinet_id) !== null && _molding$ccdf$cabinet !== void 0 ? _molding$ccdf$cabinet : molding.itemID,
20
- ccdf: molding.ccdf,
21
- target_door_finish_id: (_doorStyle$id = doorStyle === null || doorStyle === void 0 ? void 0 : doorStyle.id) !== null && _doorStyle$id !== void 0 ? _doorStyle$id : null,
22
- long_name: (_molding$long_name = molding === null || molding === void 0 ? void 0 : molding.long_name) !== null && _molding$long_name !== void 0 ? _molding$long_name : null,
23
- id: molding.itemID
24
- });
25
- }
26
- return moldingCCDFs;
27
- }
11
+ var _handleExternalEvent = require("./handleExternalEvent.util");
28
12
  function handleChangeDoorStyleEvent(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x0, _x1, _x10) {
29
13
  return _handleChangeDoorStyleEvent.apply(this, arguments);
30
14
  }
@@ -66,7 +50,7 @@ function _handleChangeDoorStyleEvent() {
66
50
  case 4:
67
51
  ccdf_list = [];
68
52
  _loop = /*#__PURE__*/_regenerator["default"].mark(function _loop() {
69
- var item, _item$ccdf$catalog_ca, _item$ccdf, _item$ccdf$cabinet_id, _item$ccdf2, _doorStyle$id3, _item$long_name;
53
+ var item, _item$ccdf$catalog_ca, _item$ccdf, _item$ccdf$cabinet_id, _item$ccdf2, _doorStyle$id2, _item$long_name;
70
54
  return _regenerator["default"].wrap(function (_context2) {
71
55
  while (1) switch (_context2.prev = _context2.next) {
72
56
  case 0:
@@ -80,7 +64,7 @@ function _handleChangeDoorStyleEvent() {
80
64
  catalog_cabinet_sku: (_item$ccdf$catalog_ca = item === null || item === void 0 || (_item$ccdf = item.ccdf) === null || _item$ccdf === void 0 ? void 0 : _item$ccdf.catalog_cabinet_sku) !== null && _item$ccdf$catalog_ca !== void 0 ? _item$ccdf$catalog_ca : item.sku_number,
81
65
  cabinet_id: (_item$ccdf$cabinet_id = item === null || item === void 0 || (_item$ccdf2 = item.ccdf) === null || _item$ccdf2 === void 0 ? void 0 : _item$ccdf2.cabinet_id) !== null && _item$ccdf$cabinet_id !== void 0 ? _item$ccdf$cabinet_id : null,
82
66
  ccdf: item.ccdf,
83
- target_door_finish_id: (_doorStyle$id3 = doorStyle === null || doorStyle === void 0 ? void 0 : doorStyle.id) !== null && _doorStyle$id3 !== void 0 ? _doorStyle$id3 : null,
67
+ target_door_finish_id: (_doorStyle$id2 = doorStyle === null || doorStyle === void 0 ? void 0 : doorStyle.id) !== null && _doorStyle$id2 !== void 0 ? _doorStyle$id2 : null,
84
68
  long_name: (_item$long_name = item === null || item === void 0 ? void 0 : item.long_name) !== null && _item$long_name !== void 0 ? _item$long_name : null,
85
69
  scene_cabinet_id: item.id
86
70
  });
@@ -103,7 +87,7 @@ function _handleChangeDoorStyleEvent() {
103
87
  _context3.next = 5;
104
88
  break;
105
89
  case 7:
106
- moldingCCDFList = prepareMoldingCCDFList(doorStyle, moldingData);
90
+ moldingCCDFList = (0, _handleExternalEvent.prepareMoldingCCDFList)(doorStyle, moldingData);
107
91
  if (ccdf_list.length > 0) {
108
92
  (_props$onInternalEven = props.onInternalEvent) === null || _props$onInternalEven === void 0 || _props$onInternalEven.call(props, {
109
93
  type: INTERNAL_EVENT_ITEMS_CATALOG,
@@ -117,7 +101,7 @@ function _handleChangeDoorStyleEvent() {
117
101
  // result is ccdf_list
118
102
  function () {
119
103
  var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(result) {
120
- var _result$ccdf_list, _doorStyle$id2, _result$molding_ccdf_;
104
+ var _result$ccdf_list, _doorStyle$id, _result$molding_ccdf_;
121
105
  var mappedCabinetDefinitionList, rt;
122
106
  return _regenerator["default"].wrap(function (_context) {
123
107
  while (1) switch (_context.prev = _context.next) {
@@ -135,7 +119,7 @@ function _handleChangeDoorStyleEvent() {
135
119
  // Persist ccdf on affected instances so SYNC includes the latest ccdf.id for each item.
136
120
  // IMPORTANT: host response `ccdf_list[]` may not include `door_finish_id`.
137
121
  // Use request door_finish_id (doorStyle.id) as the source of truth for door_finish_id.
138
- props.itemsActions.setItemsCCDF((_result$ccdf_list = result === null || result === void 0 ? void 0 : result.ccdf_list) !== null && _result$ccdf_list !== void 0 ? _result$ccdf_list : [], applyScope, itemIds, (_doorStyle$id2 = doorStyle === null || doorStyle === void 0 ? void 0 : doorStyle.id) !== null && _doorStyle$id2 !== void 0 ? _doorStyle$id2 : null);
122
+ props.itemsActions.setItemsCCDF((_result$ccdf_list = result === null || result === void 0 ? void 0 : result.ccdf_list) !== null && _result$ccdf_list !== void 0 ? _result$ccdf_list : [], applyScope, itemIds, (_doorStyle$id = doorStyle === null || doorStyle === void 0 ? void 0 : doorStyle.id) !== null && _doorStyle$id !== void 0 ? _doorStyle$id : null);
139
123
  props.itemsActions.setMoldingsCCDF((_result$molding_ccdf_ = result === null || result === void 0 ? void 0 : result.molding_ccdf_list) !== null && _result$molding_ccdf_ !== void 0 ? _result$molding_ccdf_ : [], applyScope);
140
124
  props.itemsActions.setDoorStyle(doorStyle, itemCDS, applyScope, itemIds);
141
125
  case 2:
@@ -7,11 +7,14 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.handleLoadProjectEvent = handleLoadProjectEvent;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
12
  var _convertUnitsLite = require("../../utils/convert-units-lite");
12
13
  var _constants = require("../../constants");
13
14
  var _models = require("../../models");
14
15
  var _asyncPool = require("../../shared/concurrency/async-pool");
16
+ var _handleExternalEvent = require("./handleExternalEvent.util");
17
+ var _utils = require("../../components/viewer2d/utils");
15
18
  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; }
16
19
  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; }
17
20
  function handleLoadProjectEvent(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
@@ -19,14 +22,14 @@ function handleLoadProjectEvent(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
19
22
  }
20
23
  function _handleLoadProjectEvent() {
21
24
  _handleLoadProjectEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(props, state, evt, mapFromCCDFToCDS, updateProjectWithCDSList, ccdfMapper, mergeSameElements, addItemToCatalog) {
22
- var layerName, _evt$payload$layers$l, _evt$payload, _state$catalog, ccdf_list, items, newScene, tempState, _props$onInternalEven;
25
+ var layerName, _evt$payload$layers$l, _evt$payload, _state$catalog, ccdf_list, molding_ccdf_list, items, newScene, tempState, _props$onInternalEven;
23
26
  return _regenerator["default"].wrap(function (_context2) {
24
27
  while (1) switch (_context2.prev = _context2.next) {
25
28
  case 0:
26
29
  layerName = 'layer-1';
27
30
  if (evt !== null && evt !== void 0 && evt.payload) {
28
31
  // prepare item data request
29
- ccdf_list = [];
32
+ ccdf_list = [], molding_ccdf_list = [];
30
33
  items = (_evt$payload$layers$l = evt === null || evt === void 0 || (_evt$payload = evt.payload) === null || _evt$payload === void 0 || (_evt$payload = _evt$payload.layers[layerName]) === null || _evt$payload === void 0 ? void 0 : _evt$payload.items) !== null && _evt$payload$layers$l !== void 0 ? _evt$payload$layers$l : {};
31
34
  Object.keys(items).forEach(function (k) {
32
35
  var _it$properties, _it$properties2, _it$properties3;
@@ -50,6 +53,7 @@ function _handleLoadProjectEvent() {
50
53
  long_name: (_it$long_name = it === null || it === void 0 ? void 0 : it.long_name) !== null && _it$long_name !== void 0 ? _it$long_name : null,
51
54
  scene_cabinet_id: it.id
52
55
  });
56
+ if (!(0, _utils.isEmpty)(it.doorStyle) && !(0, _utils.isEmpty)(it.molding)) molding_ccdf_list.push.apply(molding_ccdf_list, (0, _toConsumableArray2["default"])((0, _handleExternalEvent.prepareMoldingCCDFList)(it.doorStyle, it.molding)));
53
57
  }
54
58
  });
55
59
  newScene = new _models.Scene(evt === null || evt === void 0 ? void 0 : evt.payload);
@@ -62,7 +66,8 @@ function _handleLoadProjectEvent() {
62
66
  type: _constants.INTERNAL_EVENT_ITEMS_CATALOG,
63
67
  value: {
64
68
  event_type: 'load_project',
65
- ccdf_list: ccdf_list
69
+ ccdf_list: ccdf_list,
70
+ molding_ccdf_list: molding_ccdf_list
66
71
  }
67
72
  }, /*#__PURE__*/function () {
68
73
  var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(result) {
@@ -106,6 +111,7 @@ function _handleLoadProjectEvent() {
106
111
  });
107
112
  case 1:
108
113
  props.projectActions.loadProject(evt.payload);
114
+ props.itemsActions.setMoldingsCCDF(result === null || result === void 0 ? void 0 : result.molding_ccdf_list, 'all');
109
115
  case 2:
110
116
  case "end":
111
117
  return _context.stop();
@@ -20,7 +20,7 @@ function _handleSetMolding() {
20
20
  _context.next = 1;
21
21
  return loadMoldingSvg(moldingInfo);
22
22
  case 1:
23
- props.itemsActions.setMolding(moldingInfo, isGlobal);
23
+ props.itemsActions.setMolding(moldingInfo, isGlobal, props.onInternalEvent);
24
24
  case 2:
25
25
  case "end":
26
26
  return _context.stop();
@@ -112,7 +112,7 @@ function _default(state, action) {
112
112
  state = stateHistoryPush(state).updatedState;
113
113
  return _export.Item.setCounterTop(state, action.counterTop).updatedState;
114
114
  case _constants.SET_MOLDING:
115
- return _export.Item.setMolding(state, action.molding, action.isAll).updatedState;
115
+ return _export.Item.setMolding(state, action.molding, action.isAll, action.onInternalEvent).updatedState;
116
116
  case _constants.UPDATE_MOLDING:
117
117
  return _export.Item.updateMolding(state).updatedState;
118
118
  case _constants.SET_WALL_COLOR:
@@ -9,7 +9,6 @@ exports.createMonldingGroup = createMonldingGroup;
9
9
  exports.getAllMoldingGroups = getAllMoldingGroups;
10
10
  exports.getItemGroupFromMolding = getItemGroupFromMolding;
11
11
  exports.getItemRect = getItemRect;
12
- exports.getLinesFromItems = getLinesFromItems;
13
12
  exports.getLinesFromItems2 = getLinesFromItems2;
14
13
  exports.getLinesOfItem = getLinesOfItem;
15
14
  exports.getLinesOfItem2 = getLinesOfItem2;
@@ -727,97 +726,6 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
727
726
  return [];
728
727
  }
729
728
  }
730
- function getLinesFromItems(moldingGroup, layer, catalog) {
731
- var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
732
- var items = (0, _toConsumableArray2["default"])(moldingGroup.items);
733
- var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
734
- items = sortItemsByDistance(items, items[0]);
735
- var _loop7 = function _loop7() {
736
- var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
737
- var temp_MGLines = [];
738
- MGlines.forEach(function (line) {
739
- var idx = itemLines.findIndex(function (itemLine) {
740
- return isLinesOverlapped(line, itemLine);
741
- });
742
- var curItemLine = itemLines[idx];
743
- if (idx > -1) {
744
- if (!(_export.GeometryUtils.samePoints(line[0], curItemLine[0]) && _export.GeometryUtils.samePoints(line[1], curItemLine[1]) || _export.GeometryUtils.samePoints(line[0], curItemLine[1]) && _export.GeometryUtils.samePoints(line[1], curItemLine[0]))) {
745
- var MGLine = mergeOverlappedLines(line, curItemLine);
746
- temp_MGLines.push(MGLine);
747
- }
748
- itemLines.splice(idx, 1);
749
- } else {
750
- temp_MGLines.push(line);
751
- }
752
- });
753
- itemLines.forEach(function (itemLine) {
754
- return temp_MGLines.push(itemLine);
755
- });
756
- MGlines = [].concat(temp_MGLines);
757
- };
758
- for (var i = 1; i < items.length; i++) {
759
- _loop7();
760
- }
761
- // return MGlines;
762
- var snapped_other_items = layer.items.toArray().filter(function (item) {
763
- if (items.some(function (it) {
764
- return item.id === it.id;
765
- })) return false;
766
- return isItemSnappedGroup(item, items);
767
- });
768
- snapped_other_items.forEach(function (item) {
769
- var itemAltitude = item.properties.get('altitude').get('_length');
770
- var itemAltitudeUnit = item.properties.get('altitude').get('_unit');
771
- itemAltitude = (0, _convertUnitsLite.convert)(itemAltitude).from(itemAltitudeUnit).to('cm');
772
- var itemHeight = item.properties.get('height').get('_length');
773
- var itemHeightUnit = item.properties.get('height').get('_unit');
774
- itemHeight = (0, _convertUnitsLite.convert)(itemHeight).from(itemHeightUnit).to('cm');
775
- var mgroupAltitude = items[0].properties.get('altitude').get('_length');
776
- var mgroupAltitudeUnit = items[0].properties.get('altitude').get('_unit');
777
- mgroupAltitude = (0, _convertUnitsLite.convert)(mgroupAltitude).from(mgroupAltitudeUnit).to('cm');
778
- var mgroupHeight = items[0].properties.get('height').get('_length');
779
- var mgroupHeightUnit = items[0].properties.get('height').get('_unit');
780
- mgroupHeight = (0, _convertUnitsLite.convert)(mgroupHeight).from(mgroupHeightUnit).to('cm');
781
- var flag = false;
782
- switch (moldingGroup.location_type) {
783
- case _constants.TOP_MOLDING_LOCATION:
784
- flag = itemAltitude + itemHeight > mgroupAltitude + mgroupHeight;
785
- break;
786
- case _constants.MIDDLE_MOLDING_LOCATION:
787
- flag = true;
788
- break;
789
- case _constants.BOTTOM_MOLDING_LOCATION:
790
- flag = itemAltitude < mgroupAltitude;
791
- break;
792
- }
793
- if (item.category !== 'cabinet' || ![_constants.BASE_CABINET_LAYOUTPOS, _constants.WALL_CABINET_LAYOUTPOS, _constants.TALL_CABINET_LAYOUTPOS].includes(item.layoutpos)) flag = true;
794
- if (flag) {
795
- var itemLines = getLinesOfItem(item, allLineRects, catalog);
796
- var temp_MGLines = [];
797
- MGlines.forEach(function (mgl) {
798
- var idx = itemLines.findIndex(function (itl) {
799
- return isLinesOverlapped(mgl, itl);
800
- });
801
- var curITL = itemLines[idx];
802
- if (idx > -1) {
803
- if (getDelta(mgl[0], mgl[1], curITL[1], curITL[0]) < _constants.EPSILON || getDelta(mgl[0], mgl[1], curITL[0], curITL[1]) < _constants.EPSILON) {
804
- if (_export.GeometryUtils.verticesDistance(mgl[0], mgl[1]) > _export.GeometryUtils.verticesDistance(curITL[0], curITL[1])) {
805
- var MGLine = mergeOverlappedLines(mgl, curITL);
806
- temp_MGLines.push(MGLine);
807
- }
808
- itemLines.splice(idx, 1);
809
- } else {
810
- temp_MGLines.push(mgl);
811
- }
812
- } else {
813
- temp_MGLines.push(mgl);
814
- }
815
- });
816
- MGlines = [].concat(temp_MGLines);
817
- }
818
- });
819
- return MGlines;
820
- }
821
729
  function getMDPoints(newMD) {
822
730
  if (newMD.lines.length < 1) return _objectSpread(_objectSpread({}, newMD), {}, {
823
731
  pointGroups: []
@@ -867,7 +775,7 @@ function getMDPoints(newMD) {
867
775
  var pointGroups = [[]];
868
776
  var flag = 1;
869
777
  var i = 0;
870
- var _loop8 = function _loop8() {
778
+ var _loop7 = function _loop7() {
871
779
  if (pointGroups[i].length === 0) {
872
780
  pointGroups[i].push(new Three.Vector2(MDlines[0][0].x - cPos.x, MDlines[0][0].y - cPos.y), new Three.Vector2(MDlines[0][1].x - cPos.x, MDlines[0][1].y - cPos.y));
873
781
  MDlines.splice(0, 1);
@@ -932,7 +840,7 @@ function getMDPoints(newMD) {
932
840
  }
933
841
  };
934
842
  while (MDlines.length !== 0) {
935
- _loop8();
843
+ _loop7();
936
844
  }
937
845
  var z = newMD.items[0].properties.get('altitude').get('_length');
938
846
  var zUnit = newMD.items[0].properties.get('altitude').get('_unit') || 'cm';
@@ -1042,14 +950,14 @@ function getMoldingDataOfScene2(layer, catalog, doorStyle, moldingPieceLength) {
1042
950
  // filter the real molding line segments
1043
951
  var removeLineIds = []; // remove the line that fully overlapped to other line
1044
952
  var newLines = []; // new countour line segment that except the overlapped part
1045
- var _loop9 = function _loop9(i) {
953
+ var _loop8 = function _loop8(i) {
1046
954
  var srcLine = {
1047
955
  x1: moldingLines[i].line[0].x,
1048
956
  y1: moldingLines[i].line[0].y,
1049
957
  x2: moldingLines[i].line[1].x,
1050
958
  y2: moldingLines[i].line[1].y
1051
959
  };
1052
- var _loop1 = function _loop1(_j) {
960
+ var _loop0 = function _loop0(_j) {
1053
961
  if (i === _j) return 0; // continue
1054
962
  if (Math.abs(moldingLines[i].z - moldingLines[_j].z) > _constants.EPSILON) return 0; // continue
1055
963
  var destLine = {
@@ -1084,13 +992,13 @@ function getMoldingDataOfScene2(layer, catalog, doorStyle, moldingPieceLength) {
1084
992
  },
1085
993
  _ret4;
1086
994
  for (var _j = 0; _j < moldingLines.length; _j++) {
1087
- _ret4 = _loop1(_j);
995
+ _ret4 = _loop0(_j);
1088
996
  if (_ret4 === 0) continue;
1089
997
  if (_ret4 === 1) break;
1090
998
  }
1091
999
  };
1092
1000
  for (var i = 0; i < moldingLines.length; i++) {
1093
- _loop9(i);
1001
+ _loop8(i);
1094
1002
  }
1095
1003
  moldingLines = moldingLines.filter(function (line, idx) {
1096
1004
  return !removeLineIds.some(function (id) {
@@ -1121,7 +1029,7 @@ function getMoldingDataOfScene2(layer, catalog, doorStyle, moldingPieceLength) {
1121
1029
  // console.log('moldingLines: ', moldingLines);
1122
1030
 
1123
1031
  // make molding data with grouping molding & doorStyle
1124
- var _loop0 = function _loop0() {
1032
+ var _loop9 = function _loop9() {
1125
1033
  var ml = moldingLines[k];
1126
1034
  var mlLength = ml.molding.name === _constants.TOE_KICK_MOLDING ? ml.inchWidth : (0, _convertUnitsLite.convert)(_export.GeometryUtils.verticesDistance(ml.line[0], ml.line[1])).from('cm').to('in');
1127
1035
  var idx = moldingData.findIndex(function (v) {
@@ -1138,7 +1046,7 @@ function getMoldingDataOfScene2(layer, catalog, doorStyle, moldingPieceLength) {
1138
1046
  }
1139
1047
  };
1140
1048
  for (var k = 0; k < moldingLines.length; k++) {
1141
- _loop0();
1049
+ _loop9();
1142
1050
  }
1143
1051
  // console.log('moldingData: ', moldingData);
1144
1052
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "11.36.0",
3
+ "version": "11.38.0",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",