kitchen-simulator 11.35.0 → 11.37.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.
package/es/class/item.js CHANGED
@@ -17,6 +17,7 @@ import { historyPush } from "../utils/history";
17
17
  import { toJSIfNeeded } from "../shared/objects/immutable";
18
18
  import { canMirrorCabinet } from "../shared/domain/cabinet-mirror";
19
19
  import { isWarningCabinet } from "../shared/domain/cabinet-warning";
20
+ import { mapFromCCDFToCDS } from "../mappings/external-events/mappers/ccdfToCDSMapper";
20
21
  var allItemRect;
21
22
  var allItemSnap;
22
23
  var allLines;
@@ -126,22 +127,17 @@ var Item = /*#__PURE__*/function () {
126
127
  var refAlt = refItem === null || refItem === void 0 || (_refItem$properties = refItem.properties) === null || _refItem$properties === void 0 || (_refItem$properties$g = _refItem$properties.get) === null || _refItem$properties$g === void 0 ? void 0 : _refItem$properties$g.call(_refItem$properties, 'altitude');
127
128
  if (refAlt) item = item.setIn(['properties', 'altitude'], refAlt);
128
129
  } else {
129
- var _layer$doorStyle, _temp, _ref, _temp$doorStyles$cds$, _temp2, _temp3, _state5;
130
+ var _layer$doorStyle, _temp;
130
131
  var layer = state.getIn(['scene', 'layers', layerID]);
131
132
  var temp = (_layer$doorStyle = layer === null || layer === void 0 ? void 0 : layer.doorStyle) !== null && _layer$doorStyle !== void 0 ? _layer$doorStyle : state.doorStyle;
132
133
  if (!isEmpty(temp) && Map.isMap(temp)) temp = (_temp = temp) === null || _temp === void 0 ? void 0 : _temp.toJS();
133
- var cds = (_ref = (_temp$doorStyles$cds$ = (_temp2 = temp) === null || _temp2 === void 0 || (_temp2 = _temp2.doorStyles) === null || _temp2 === void 0 || (_temp2 = _temp2.cds) === null || _temp2 === void 0 ? void 0 : _temp2.find(function (elem) {
134
- var _state3;
135
- return elem.itemID === ((_state3 = state) === null || _state3 === void 0 || (_state3 = _state3.catalog) === null || _state3 === void 0 ? void 0 : _state3.getIn(['elements', type, 'itemID']));
136
- })) !== null && _temp$doorStyles$cds$ !== void 0 ? _temp$doorStyles$cds$ : (_temp3 = temp) === null || _temp3 === void 0 || (_temp3 = _temp3.cds) === null || _temp3 === void 0 ? void 0 : _temp3.find(function (elem) {
137
- var _state4;
138
- return elem.itemID === ((_state4 = state) === null || _state4 === void 0 || (_state4 = _state4.catalog) === null || _state4 === void 0 ? void 0 : _state4.getIn(['elements', type, 'itemID']));
139
- })) !== null && _ref !== void 0 ? _ref : (_state5 = state) === null || _state5 === void 0 || (_state5 = _state5.catalog) === null || _state5 === void 0 ? void 0 : _state5.getIn(['elements', type, 'cds']);
134
+ var cds = mapFromCCDFToCDS([toJSIfNeeded(item.ccdf)], [toJSIfNeeded(item)]);
135
+ temp.cds = cds;
140
136
  if (cds) {
141
- var _temp4;
142
- var updatedDoorStyles = _objectSpread(_objectSpread({}, (_temp4 = temp) === null || _temp4 === void 0 ? void 0 : _temp4.doorStyles), {}, {
143
- cds: [cds],
144
- cabinet_door_style_id: cds.cabinet_door_style_id
137
+ var _temp2;
138
+ var updatedDoorStyles = _objectSpread(_objectSpread({}, (_temp2 = temp) === null || _temp2 === void 0 ? void 0 : _temp2.doorStyles), {}, {
139
+ cds: cds,
140
+ cabinet_door_style_id: cds[0].cabinet_door_style_id
145
141
  });
146
142
  item = item.merge({
147
143
  doorStyle: fromJS(_objectSpread(_objectSpread({}, temp), {}, {
@@ -854,8 +850,8 @@ var Item = /*#__PURE__*/function () {
854
850
  }, {
855
851
  key: "updateDraggingItemChanged",
856
852
  value: function updateDraggingItemChanged(state, x, y, layerID, itemID) {
857
- var _state6 = state,
858
- scene = _state6.scene;
853
+ var _state3 = state,
854
+ scene = _state3.scene;
859
855
  // let originalX = draggingSupport.get('originalX');
860
856
  // let originalY = draggingSupport.get('originalY');
861
857
 
@@ -947,9 +943,9 @@ var Item = /*#__PURE__*/function () {
947
943
  }, {
948
944
  key: "updateDraggingItem",
949
945
  value: function updateDraggingItem(state, x, y) {
950
- var _state7 = state,
951
- draggingSupport = _state7.draggingSupport,
952
- scene = _state7.scene;
946
+ var _state4 = state,
947
+ draggingSupport = _state4.draggingSupport,
948
+ scene = _state4.scene;
953
949
  var layerID = draggingSupport.get('layerID');
954
950
  var itemID = draggingSupport.get('itemID');
955
951
  var startPointX = draggingSupport.get('startPointX');
@@ -981,9 +977,9 @@ var Item = /*#__PURE__*/function () {
981
977
  }, {
982
978
  key: "updateDraggingItem3DX",
983
979
  value: function updateDraggingItem3DX(state, x) {
984
- var _state8 = state,
985
- draggingSupport = _state8.draggingSupport,
986
- scene = _state8.scene;
980
+ var _state5 = state,
981
+ draggingSupport = _state5.draggingSupport,
982
+ scene = _state5.scene;
987
983
  var layerID = draggingSupport.get('layerID');
988
984
  var itemID = draggingSupport.get('itemID');
989
985
  var startPointX = draggingSupport.get('startPointX');
@@ -1003,9 +999,9 @@ var Item = /*#__PURE__*/function () {
1003
999
  }, {
1004
1000
  key: "updateDraggingItem3DY",
1005
1001
  value: function updateDraggingItem3DY(state, y) {
1006
- var _state9 = state,
1007
- draggingSupport = _state9.draggingSupport,
1008
- scene = _state9.scene;
1002
+ var _state6 = state,
1003
+ draggingSupport = _state6.draggingSupport,
1004
+ scene = _state6.scene;
1009
1005
  var layerID = draggingSupport.get('layerID');
1010
1006
  var itemID = draggingSupport.get('itemID');
1011
1007
  var startPointY = draggingSupport.get('startPointY');
@@ -1086,9 +1082,9 @@ var Item = /*#__PURE__*/function () {
1086
1082
  }, {
1087
1083
  key: "updateRotatingItem",
1088
1084
  value: function updateRotatingItem(state, x, y) {
1089
- var _state0 = state,
1090
- rotatingSupport = _state0.rotatingSupport,
1091
- scene = _state0.scene;
1085
+ var _state7 = state,
1086
+ rotatingSupport = _state7.rotatingSupport,
1087
+ scene = _state7.scene;
1092
1088
  var layerID = rotatingSupport.get('layerID');
1093
1089
  var itemID = rotatingSupport.get('itemID');
1094
1090
  var item = state.getIn(['scene', 'layers', layerID, 'items', itemID]);
@@ -1171,9 +1167,9 @@ var Item = /*#__PURE__*/function () {
1171
1167
  }, {
1172
1168
  key: "replaceSubmodule",
1173
1169
  value: function replaceSubmodule(state, url) {
1174
- var _state1 = state,
1175
- replacingSupport = _state1.replacingSupport,
1176
- scene = _state1.scene;
1170
+ var _state8 = state,
1171
+ replacingSupport = _state8.replacingSupport,
1172
+ scene = _state8.scene;
1177
1173
  url = 'catalog/texture.png';
1178
1174
  var urlData = url.split('/');
1179
1175
  var newURL = '';
@@ -1274,9 +1270,9 @@ var Item = /*#__PURE__*/function () {
1274
1270
  }, {
1275
1271
  key: "animateObject",
1276
1272
  value: function animateObject(state, value) {
1277
- var _state10 = state,
1278
- replacingSupport = _state10.replacingSupport,
1279
- scene = _state10.scene;
1273
+ var _state9 = state,
1274
+ replacingSupport = _state9.replacingSupport,
1275
+ scene = _state9.scene;
1280
1276
  var layerID = replacingSupport.get('layerID');
1281
1277
  var itemID = replacingSupport.get('itemID');
1282
1278
  var item = state.getIn(['scene', 'layers', layerID, 'items', itemID]);
@@ -1313,8 +1309,8 @@ var Item = /*#__PURE__*/function () {
1313
1309
  state = state.merge({
1314
1310
  doorStyle: doorStyle
1315
1311
  });
1316
- var _state11 = state,
1317
- scene = _state11.scene;
1312
+ var _state0 = state,
1313
+ scene = _state0.scene;
1318
1314
  var layerID = scene.get('selectedLayer');
1319
1315
  var layers = scene.layers.get(layerID);
1320
1316
  var items = layers.items;
@@ -1523,8 +1519,8 @@ var Item = /*#__PURE__*/function () {
1523
1519
  }, {
1524
1520
  key: "setCounterTop",
1525
1521
  value: function setCounterTop(state, counterTop) {
1526
- var _state12 = state,
1527
- scene = _state12.scene;
1522
+ var _state1 = state,
1523
+ scene = _state1.scene;
1528
1524
  var layerID = scene.get('selectedLayer');
1529
1525
  var layers = scene.layers.get(layerID);
1530
1526
  layers = layers.mergeIn(['counterTop'], counterTop);
@@ -1568,8 +1564,8 @@ var Item = /*#__PURE__*/function () {
1568
1564
  }, {
1569
1565
  key: "setDoorHandle",
1570
1566
  value: function setDoorHandle(state, doorHandle) {
1571
- var _state13 = state,
1572
- scene = _state13.scene;
1567
+ var _state10 = state,
1568
+ scene = _state10.scene;
1573
1569
  var layerID = scene.get('selectedLayer');
1574
1570
  var layer = scene.layers.get(layerID);
1575
1571
  layer = layer.mergeIn(['doorHandle'], doorHandle);
@@ -1593,8 +1589,8 @@ var Item = /*#__PURE__*/function () {
1593
1589
  }, {
1594
1590
  key: "setHandleMaterial",
1595
1591
  value: function setHandleMaterial(state, material) {
1596
- var _state14 = state,
1597
- scene = _state14.scene;
1592
+ var _state11 = state,
1593
+ scene = _state11.scene;
1598
1594
  var layerID = scene.get('selectedLayer');
1599
1595
  var layers = scene.layers.get(layerID);
1600
1596
  var items = layers.items;
@@ -1619,8 +1615,8 @@ var Item = /*#__PURE__*/function () {
1619
1615
  }, {
1620
1616
  key: "setWallColor",
1621
1617
  value: function setWallColor(state, wallColor) {
1622
- var _state15 = state,
1623
- scene = _state15.scene;
1618
+ var _state12 = state,
1619
+ scene = _state12.scene;
1624
1620
  var layerID = scene.get('selectedLayer');
1625
1621
  var layer = scene.layers.get(layerID);
1626
1622
  layer = layer.merge({
@@ -1646,8 +1642,8 @@ var Item = /*#__PURE__*/function () {
1646
1642
  }, {
1647
1643
  key: "setBacksplash",
1648
1644
  value: function setBacksplash(state, backsplash) {
1649
- var _state16 = state,
1650
- scene = _state16.scene;
1645
+ var _state13 = state,
1646
+ scene = _state13.scene;
1651
1647
  var layerID = scene.get('selectedLayer');
1652
1648
  var layer = scene.layers.get(layerID);
1653
1649
  var dataJSON = layer.toJS();
@@ -1675,8 +1671,8 @@ var Item = /*#__PURE__*/function () {
1675
1671
  }, {
1676
1672
  key: "setMolding",
1677
1673
  value: function setMolding(state, molding, isAll) {
1678
- var _state17 = state,
1679
- scene = _state17.scene;
1674
+ var _state14 = state,
1675
+ scene = _state14.scene;
1680
1676
  var layerID = scene.get('selectedLayer');
1681
1677
  var layer = scene.layers.get(layerID);
1682
1678
  if (isAll) {
@@ -1768,8 +1764,8 @@ var Item = /*#__PURE__*/function () {
1768
1764
  }, {
1769
1765
  key: "updateMolding",
1770
1766
  value: function updateMolding(state) {
1771
- var _state18 = state,
1772
- scene = _state18.scene;
1767
+ var _state15 = state,
1768
+ scene = _state15.scene;
1773
1769
  var layerID = scene.get('selectedLayer');
1774
1770
  var layer = scene.layers.get(layerID);
1775
1771
  var selectedItem = layer.getIn(['items', layer.selected.toJS().items[0]]);
@@ -1893,8 +1889,8 @@ var Item = /*#__PURE__*/function () {
1893
1889
  }, {
1894
1890
  key: "setBacksplashVisible",
1895
1891
  value: function setBacksplashVisible(state, itemID, backsplashVisible) {
1896
- var _state19 = state,
1897
- scene = _state19.scene;
1892
+ var _state16 = state,
1893
+ scene = _state16.scene;
1898
1894
  var layerID = scene.get('selectedLayer');
1899
1895
  var layer = scene.layers.get(layerID);
1900
1896
  layer = layer.mergeIn(['items', itemID, 'backsplashVisible'], backsplashVisible);
@@ -1914,8 +1910,8 @@ var Item = /*#__PURE__*/function () {
1914
1910
  }, {
1915
1911
  key: "setApplianceMaterial",
1916
1912
  value: function setApplianceMaterial(state, material) {
1917
- var _state20 = state,
1918
- scene = _state20.scene;
1913
+ var _state17 = state,
1914
+ scene = _state17.scene;
1919
1915
  var layerID = scene.get('selectedLayer');
1920
1916
  var layers = scene.layers.get(layerID);
1921
1917
  var items = layers.items;
@@ -1939,8 +1935,8 @@ var Item = /*#__PURE__*/function () {
1939
1935
  }, {
1940
1936
  key: "setModelling",
1941
1937
  value: function setModelling(state, molding) {
1942
- var _state21 = state,
1943
- scene = _state21.scene;
1938
+ var _state18 = state,
1939
+ scene = _state18.scene;
1944
1940
  var layerID = scene.get('selectedLayer');
1945
1941
  var layers = scene.layers.get(layerID);
1946
1942
  var items = layers.items;
@@ -2050,8 +2046,8 @@ var Item = /*#__PURE__*/function () {
2050
2046
  }, {
2051
2047
  key: "toggleLoadingCabinet",
2052
2048
  value: function toggleLoadingCabinet(state) {
2053
- var _state22 = state,
2054
- scene = _state22.scene;
2049
+ var _state19 = state,
2050
+ scene = _state19.scene;
2055
2051
  console.log('scene.isLoadingCabinet: ', !scene.isLoadingCabinet);
2056
2052
  // scene = scene.set('isLoadingCabinet', !scene.isLoadingCabinet);
2057
2053
  // state = state.set('scene', scene);
@@ -2063,8 +2059,8 @@ var Item = /*#__PURE__*/function () {
2063
2059
  }, {
2064
2060
  key: "endLoading",
2065
2061
  value: function endLoading(state) {
2066
- var _state23 = state,
2067
- scene = _state23.scene;
2062
+ var _state20 = state,
2063
+ scene = _state20.scene;
2068
2064
  state = state.setIn(['scene', 'loadFlag'], true);
2069
2065
  return {
2070
2066
  updatedState: state
@@ -2724,6 +2724,12 @@ function isSingleQuadrilateral(groupCount, pointGroup) {
2724
2724
  * @param model - molding info that appear in real 3D
2725
2725
  */
2726
2726
  function moldingVertices(mPointGroup, mdGeo, MDV, model, svg_width, svg_height, groupCount) {
2727
+ // Guard against bad SVG metadata (missing/zero dimensions) which would produce NaN/Infinity vertices.
2728
+ if (!Number.isFinite(svg_width) || !Number.isFinite(svg_height) || svg_width <= 0 || svg_height <= 0) {
2729
+ mdGeo.setAttribute('position', new Three.BufferAttribute(new Float32Array(), 3));
2730
+ mdGeo.needsUpdate = true;
2731
+ return mdGeo;
2732
+ }
2727
2733
  var pointGroup = mPointGroup;
2728
2734
  var length = pointGroup.length;
2729
2735
  var isSnap = true;
@@ -2801,15 +2807,19 @@ function moldingVertices(mPointGroup, mdGeo, MDV, model, svg_width, svg_height,
2801
2807
  }
2802
2808
  vecNorm.rotateAround(o, Math.PI / 2 - alpha);
2803
2809
  vecNorm.normalize();
2804
- vecNorm.multiplyScalar(1 / Math.sin(alpha));
2810
+ var sinAlpha = Math.sin(alpha);
2811
+ if (Math.abs(sinAlpha) > 1e-6) {
2812
+ vecNorm.multiplyScalar(1 / sinAlpha);
2813
+ }
2805
2814
 
2806
2815
  // Make 3D Points
2807
2816
  MDV.forEach(function (p) {
2808
2817
  var x = cur.x - vecNorm.x * ((p.x / svg_width - 0.5) * model.length);
2809
2818
  var y = (0.5 - p.y / svg_height) * model.width;
2810
2819
  var z = -cur.y + vecNorm.y * ((p.x / svg_width - 0.5) * model.length);
2811
- if (mdGeo.attributes.hasOwnProperty('position')) verticesArray = mdGeo.attributes.position.array;
2812
- verticesArray.push(x, y, z);
2820
+ if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z)) {
2821
+ verticesArray.push(x, y, z);
2822
+ }
2813
2823
  });
2814
2824
  });
2815
2825
  var mdGeo1 = mdGeo.setAttribute('position', new Three.BufferAttribute(new Float32Array(verticesArray), 3));
@@ -2972,6 +2982,7 @@ var applyTexture = function applyTexture(material, texture, length, height) {
2972
2982
  * @param {Scene} scene
2973
2983
  */
2974
2984
  export function createBacksplash(item, layer, planData, scene) {
2985
+ var _getSnappedWallLines;
2975
2986
  var sceneGraph = planData.sceneGraph;
2976
2987
  var selectedLayer = planData.sceneData.selectedLayer;
2977
2988
  /**
@@ -2996,7 +3007,9 @@ export function createBacksplash(item, layer, planData, scene) {
2996
3007
  }
2997
3008
 
2998
3009
  // Get current wall line that item is snapped
2999
- var wLines = getSnappedWallLines(item.itemInfo, layer, planData.catalog);
3010
+ var wLines = (_getSnappedWallLines = getSnappedWallLines(item.itemInfo, layer, planData.catalog)) === null || _getSnappedWallLines === void 0 ? void 0 : _getSnappedWallLines.filter(function (sLine) {
3011
+ return sLine.snapSide === 'front';
3012
+ });
3000
3013
  var curLine = wLines.length > 0 ? wLines[0] : null;
3001
3014
 
3002
3015
  // Get wall items which snapped to the curLine
@@ -3075,6 +3088,7 @@ export function createBacksplash(item, layer, planData, scene) {
3075
3088
  altitude: altitude
3076
3089
  });
3077
3090
  });
3091
+ var DEFAULT_BACKSPLASH_HEIGHT = 52 * 2.54;
3078
3092
  if (altItems.length > 0) {
3079
3093
  depth = altItems[0].altitude;
3080
3094
  altItems.map(function (altItem) {
@@ -3083,11 +3097,9 @@ export function createBacksplash(item, layer, planData, scene) {
3083
3097
  depth = altItem.altitude;
3084
3098
  flag = true;
3085
3099
  }
3086
- }
3100
+ } else if (!flag || depth > DEFAULT_BACKSPLASH_HEIGHT) depth = DEFAULT_BACKSPLASH_HEIGHT;
3087
3101
  });
3088
3102
  }
3089
- var DEFAULT_BACKSPLASH_HEIGHT = 52 * 2.54;
3090
- if (!flag || depth > DEFAULT_BACKSPLASH_HEIGHT) depth = DEFAULT_BACKSPLASH_HEIGHT;
3091
3103
 
3092
3104
  // Get backsplash info
3093
3105
 
@@ -3248,7 +3260,7 @@ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag)
3248
3260
  // let layoutType = molding.items[0].layoutpos;
3249
3261
  // let visible = molding.items[0];
3250
3262
  molding.pointGroups.forEach(function (pointGroup) {
3251
- var _child$width_unit, _child$height_unit, _child$length_unit;
3263
+ var _child$width_unit, _child$height_unit, _child$length_unit, _geometry2;
3252
3264
  var geometry = new Three.BufferGeometry();
3253
3265
  var length = data.length; //point array
3254
3266
  var widthUnit = child.width_unit === 'inch' ? 'in' : (_child$width_unit = child.width_unit) !== null && _child$width_unit !== void 0 ? _child$width_unit : 'in';
@@ -3262,6 +3274,10 @@ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag)
3262
3274
  child.length_unit = 'cm';
3263
3275
  geometry.needsUpdate = true;
3264
3276
  geometry = moldingVertices(pointGroup, geometry, data, child, svg_width, svg_height, molding.pointGroups.length);
3277
+ // If we failed to generate positions (bad SVG/model data), skip this molding group.
3278
+ if (!((_geometry2 = geometry) !== null && _geometry2 !== void 0 && (_geometry2 = _geometry2.attributes) !== null && _geometry2 !== void 0 && _geometry2.position) || geometry.attributes.position.count < 3) {
3279
+ return;
3280
+ }
3265
3281
  var total = geometry.attributes.position.count;
3266
3282
  var len = geometry.attributes.position.count / length;
3267
3283
  if (!GeometryUtils.samePoints(pointGroup[0], pointGroup[pointGroup.length - 1])) {
@@ -3642,7 +3658,7 @@ export function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
3642
3658
  }).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) {
3643
3659
  return (mol === null || mol === void 0 ? void 0 : mol.location_type) === mg.location_type;
3644
3660
  })[0];
3645
- if (mg.molding === null || mg.molding.itemID !== mol.itemID || mg.lines === null || mg.points === null) {
3661
+ if (mg.molding === null || mg.molding.itemID !== molding.itemID || mg.lines === null || mg.points === null) {
3646
3662
  var _mg$molding;
3647
3663
  if (mg.molding !== null && ((_mg$molding = mg.molding) === null || _mg$molding === void 0 ? void 0 : _mg$molding.itemID) !== molding.itemID) {
3648
3664
  deleteMGMesh(mg, planData, mode);
@@ -395,7 +395,7 @@ function _parseTempPlaceholdersFromCabinetPayload() {
395
395
  }
396
396
  });
397
397
  tempPlaceholdersData.push({
398
- id: parseInt(el, 10),
398
+ id: el,
399
399
  placeholders: tempData,
400
400
  structure: cabinetPayload.structure_json.tempPlaceholders[k].structure
401
401
  });
@@ -1027,11 +1027,19 @@ function _loadMoldingSvg() {
1027
1027
  }
1028
1028
  var loader = new SVGLoader();
1029
1029
  loader.load(url, function (data) {
1030
- var _data$xml$viewBox$ani, _data$xml, _data$xml$viewBox$ani2, _data$xml2;
1030
+ 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;
1031
+ // Some SVGs omit a viewBox; fall back to width/height to avoid 0 dimensions.
1032
+ // 0/invalid svg_width/svg_height later causes NaN/Infinity vertex positions in 3D molding meshes.
1033
+ 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;
1034
+ 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;
1035
+ 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;
1036
+ 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;
1037
+ var svg_width = Number((_ref6 = viewBoxWidth !== null && viewBoxWidth !== void 0 ? viewBoxWidth : attrWidth) !== null && _ref6 !== void 0 ? _ref6 : 0);
1038
+ var svg_height = Number((_ref7 = viewBoxHeight !== null && viewBoxHeight !== void 0 ? viewBoxHeight : attrHeight) !== null && _ref7 !== void 0 ? _ref7 : 0);
1031
1039
  molding.data = {
1032
1040
  paths: data.paths,
1033
- 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,
1034
- 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
1041
+ svg_width: Number.isFinite(svg_width) ? svg_width : 0,
1042
+ svg_height: Number.isFinite(svg_height) ? svg_height : 0
1035
1043
  };
1036
1044
  resolve();
1037
1045
  }, null, function (error) {
package/lib/class/item.js CHANGED
@@ -22,6 +22,7 @@ var _history = require("../utils/history");
22
22
  var _immutable2 = require("../shared/objects/immutable");
23
23
  var _cabinetMirror = require("../shared/domain/cabinet-mirror");
24
24
  var _cabinetWarning = require("../shared/domain/cabinet-warning");
25
+ var _ccdfToCDSMapper = require("../mappings/external-events/mappers/ccdfToCDSMapper");
25
26
  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; }
26
27
  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; }
27
28
  var allItemRect;
@@ -133,22 +134,17 @@ var Item = exports["default"] = /*#__PURE__*/function () {
133
134
  var refAlt = refItem === null || refItem === void 0 || (_refItem$properties = refItem.properties) === null || _refItem$properties === void 0 || (_refItem$properties$g = _refItem$properties.get) === null || _refItem$properties$g === void 0 ? void 0 : _refItem$properties$g.call(_refItem$properties, 'altitude');
134
135
  if (refAlt) item = item.setIn(['properties', 'altitude'], refAlt);
135
136
  } else {
136
- var _layer$doorStyle, _temp, _ref, _temp$doorStyles$cds$, _temp2, _temp3, _state5;
137
+ var _layer$doorStyle, _temp;
137
138
  var layer = state.getIn(['scene', 'layers', layerID]);
138
139
  var temp = (_layer$doorStyle = layer === null || layer === void 0 ? void 0 : layer.doorStyle) !== null && _layer$doorStyle !== void 0 ? _layer$doorStyle : state.doorStyle;
139
140
  if (!(0, _utils.isEmpty)(temp) && _immutable.Map.isMap(temp)) temp = (_temp = temp) === null || _temp === void 0 ? void 0 : _temp.toJS();
140
- var cds = (_ref = (_temp$doorStyles$cds$ = (_temp2 = temp) === null || _temp2 === void 0 || (_temp2 = _temp2.doorStyles) === null || _temp2 === void 0 || (_temp2 = _temp2.cds) === null || _temp2 === void 0 ? void 0 : _temp2.find(function (elem) {
141
- var _state3;
142
- return elem.itemID === ((_state3 = state) === null || _state3 === void 0 || (_state3 = _state3.catalog) === null || _state3 === void 0 ? void 0 : _state3.getIn(['elements', type, 'itemID']));
143
- })) !== null && _temp$doorStyles$cds$ !== void 0 ? _temp$doorStyles$cds$ : (_temp3 = temp) === null || _temp3 === void 0 || (_temp3 = _temp3.cds) === null || _temp3 === void 0 ? void 0 : _temp3.find(function (elem) {
144
- var _state4;
145
- return elem.itemID === ((_state4 = state) === null || _state4 === void 0 || (_state4 = _state4.catalog) === null || _state4 === void 0 ? void 0 : _state4.getIn(['elements', type, 'itemID']));
146
- })) !== null && _ref !== void 0 ? _ref : (_state5 = state) === null || _state5 === void 0 || (_state5 = _state5.catalog) === null || _state5 === void 0 ? void 0 : _state5.getIn(['elements', type, 'cds']);
141
+ var cds = (0, _ccdfToCDSMapper.mapFromCCDFToCDS)([(0, _immutable2.toJSIfNeeded)(item.ccdf)], [(0, _immutable2.toJSIfNeeded)(item)]);
142
+ temp.cds = cds;
147
143
  if (cds) {
148
- var _temp4;
149
- var updatedDoorStyles = _objectSpread(_objectSpread({}, (_temp4 = temp) === null || _temp4 === void 0 ? void 0 : _temp4.doorStyles), {}, {
150
- cds: [cds],
151
- cabinet_door_style_id: cds.cabinet_door_style_id
144
+ var _temp2;
145
+ var updatedDoorStyles = _objectSpread(_objectSpread({}, (_temp2 = temp) === null || _temp2 === void 0 ? void 0 : _temp2.doorStyles), {}, {
146
+ cds: cds,
147
+ cabinet_door_style_id: cds[0].cabinet_door_style_id
152
148
  });
153
149
  item = item.merge({
154
150
  doorStyle: (0, _immutable.fromJS)(_objectSpread(_objectSpread({}, temp), {}, {
@@ -861,8 +857,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
861
857
  }, {
862
858
  key: "updateDraggingItemChanged",
863
859
  value: function updateDraggingItemChanged(state, x, y, layerID, itemID) {
864
- var _state6 = state,
865
- scene = _state6.scene;
860
+ var _state3 = state,
861
+ scene = _state3.scene;
866
862
  // let originalX = draggingSupport.get('originalX');
867
863
  // let originalY = draggingSupport.get('originalY');
868
864
 
@@ -954,9 +950,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
954
950
  }, {
955
951
  key: "updateDraggingItem",
956
952
  value: function updateDraggingItem(state, x, y) {
957
- var _state7 = state,
958
- draggingSupport = _state7.draggingSupport,
959
- scene = _state7.scene;
953
+ var _state4 = state,
954
+ draggingSupport = _state4.draggingSupport,
955
+ scene = _state4.scene;
960
956
  var layerID = draggingSupport.get('layerID');
961
957
  var itemID = draggingSupport.get('itemID');
962
958
  var startPointX = draggingSupport.get('startPointX');
@@ -988,9 +984,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
988
984
  }, {
989
985
  key: "updateDraggingItem3DX",
990
986
  value: function updateDraggingItem3DX(state, x) {
991
- var _state8 = state,
992
- draggingSupport = _state8.draggingSupport,
993
- scene = _state8.scene;
987
+ var _state5 = state,
988
+ draggingSupport = _state5.draggingSupport,
989
+ scene = _state5.scene;
994
990
  var layerID = draggingSupport.get('layerID');
995
991
  var itemID = draggingSupport.get('itemID');
996
992
  var startPointX = draggingSupport.get('startPointX');
@@ -1010,9 +1006,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1010
1006
  }, {
1011
1007
  key: "updateDraggingItem3DY",
1012
1008
  value: function updateDraggingItem3DY(state, y) {
1013
- var _state9 = state,
1014
- draggingSupport = _state9.draggingSupport,
1015
- scene = _state9.scene;
1009
+ var _state6 = state,
1010
+ draggingSupport = _state6.draggingSupport,
1011
+ scene = _state6.scene;
1016
1012
  var layerID = draggingSupport.get('layerID');
1017
1013
  var itemID = draggingSupport.get('itemID');
1018
1014
  var startPointY = draggingSupport.get('startPointY');
@@ -1093,9 +1089,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1093
1089
  }, {
1094
1090
  key: "updateRotatingItem",
1095
1091
  value: function updateRotatingItem(state, x, y) {
1096
- var _state0 = state,
1097
- rotatingSupport = _state0.rotatingSupport,
1098
- scene = _state0.scene;
1092
+ var _state7 = state,
1093
+ rotatingSupport = _state7.rotatingSupport,
1094
+ scene = _state7.scene;
1099
1095
  var layerID = rotatingSupport.get('layerID');
1100
1096
  var itemID = rotatingSupport.get('itemID');
1101
1097
  var item = state.getIn(['scene', 'layers', layerID, 'items', itemID]);
@@ -1178,9 +1174,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1178
1174
  }, {
1179
1175
  key: "replaceSubmodule",
1180
1176
  value: function replaceSubmodule(state, url) {
1181
- var _state1 = state,
1182
- replacingSupport = _state1.replacingSupport,
1183
- scene = _state1.scene;
1177
+ var _state8 = state,
1178
+ replacingSupport = _state8.replacingSupport,
1179
+ scene = _state8.scene;
1184
1180
  url = 'catalog/texture.png';
1185
1181
  var urlData = url.split('/');
1186
1182
  var newURL = '';
@@ -1281,9 +1277,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1281
1277
  }, {
1282
1278
  key: "animateObject",
1283
1279
  value: function animateObject(state, value) {
1284
- var _state10 = state,
1285
- replacingSupport = _state10.replacingSupport,
1286
- scene = _state10.scene;
1280
+ var _state9 = state,
1281
+ replacingSupport = _state9.replacingSupport,
1282
+ scene = _state9.scene;
1287
1283
  var layerID = replacingSupport.get('layerID');
1288
1284
  var itemID = replacingSupport.get('itemID');
1289
1285
  var item = state.getIn(['scene', 'layers', layerID, 'items', itemID]);
@@ -1320,8 +1316,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1320
1316
  state = state.merge({
1321
1317
  doorStyle: doorStyle
1322
1318
  });
1323
- var _state11 = state,
1324
- scene = _state11.scene;
1319
+ var _state0 = state,
1320
+ scene = _state0.scene;
1325
1321
  var layerID = scene.get('selectedLayer');
1326
1322
  var layers = scene.layers.get(layerID);
1327
1323
  var items = layers.items;
@@ -1530,8 +1526,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1530
1526
  }, {
1531
1527
  key: "setCounterTop",
1532
1528
  value: function setCounterTop(state, counterTop) {
1533
- var _state12 = state,
1534
- scene = _state12.scene;
1529
+ var _state1 = state,
1530
+ scene = _state1.scene;
1535
1531
  var layerID = scene.get('selectedLayer');
1536
1532
  var layers = scene.layers.get(layerID);
1537
1533
  layers = layers.mergeIn(['counterTop'], counterTop);
@@ -1575,8 +1571,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1575
1571
  }, {
1576
1572
  key: "setDoorHandle",
1577
1573
  value: function setDoorHandle(state, doorHandle) {
1578
- var _state13 = state,
1579
- scene = _state13.scene;
1574
+ var _state10 = state,
1575
+ scene = _state10.scene;
1580
1576
  var layerID = scene.get('selectedLayer');
1581
1577
  var layer = scene.layers.get(layerID);
1582
1578
  layer = layer.mergeIn(['doorHandle'], doorHandle);
@@ -1600,8 +1596,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1600
1596
  }, {
1601
1597
  key: "setHandleMaterial",
1602
1598
  value: function setHandleMaterial(state, material) {
1603
- var _state14 = state,
1604
- scene = _state14.scene;
1599
+ var _state11 = state,
1600
+ scene = _state11.scene;
1605
1601
  var layerID = scene.get('selectedLayer');
1606
1602
  var layers = scene.layers.get(layerID);
1607
1603
  var items = layers.items;
@@ -1626,8 +1622,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1626
1622
  }, {
1627
1623
  key: "setWallColor",
1628
1624
  value: function setWallColor(state, wallColor) {
1629
- var _state15 = state,
1630
- scene = _state15.scene;
1625
+ var _state12 = state,
1626
+ scene = _state12.scene;
1631
1627
  var layerID = scene.get('selectedLayer');
1632
1628
  var layer = scene.layers.get(layerID);
1633
1629
  layer = layer.merge({
@@ -1653,8 +1649,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1653
1649
  }, {
1654
1650
  key: "setBacksplash",
1655
1651
  value: function setBacksplash(state, backsplash) {
1656
- var _state16 = state,
1657
- scene = _state16.scene;
1652
+ var _state13 = state,
1653
+ scene = _state13.scene;
1658
1654
  var layerID = scene.get('selectedLayer');
1659
1655
  var layer = scene.layers.get(layerID);
1660
1656
  var dataJSON = layer.toJS();
@@ -1682,8 +1678,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1682
1678
  }, {
1683
1679
  key: "setMolding",
1684
1680
  value: function setMolding(state, molding, isAll) {
1685
- var _state17 = state,
1686
- scene = _state17.scene;
1681
+ var _state14 = state,
1682
+ scene = _state14.scene;
1687
1683
  var layerID = scene.get('selectedLayer');
1688
1684
  var layer = scene.layers.get(layerID);
1689
1685
  if (isAll) {
@@ -1775,8 +1771,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1775
1771
  }, {
1776
1772
  key: "updateMolding",
1777
1773
  value: function updateMolding(state) {
1778
- var _state18 = state,
1779
- scene = _state18.scene;
1774
+ var _state15 = state,
1775
+ scene = _state15.scene;
1780
1776
  var layerID = scene.get('selectedLayer');
1781
1777
  var layer = scene.layers.get(layerID);
1782
1778
  var selectedItem = layer.getIn(['items', layer.selected.toJS().items[0]]);
@@ -1900,8 +1896,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1900
1896
  }, {
1901
1897
  key: "setBacksplashVisible",
1902
1898
  value: function setBacksplashVisible(state, itemID, backsplashVisible) {
1903
- var _state19 = state,
1904
- scene = _state19.scene;
1899
+ var _state16 = state,
1900
+ scene = _state16.scene;
1905
1901
  var layerID = scene.get('selectedLayer');
1906
1902
  var layer = scene.layers.get(layerID);
1907
1903
  layer = layer.mergeIn(['items', itemID, 'backsplashVisible'], backsplashVisible);
@@ -1921,8 +1917,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1921
1917
  }, {
1922
1918
  key: "setApplianceMaterial",
1923
1919
  value: function setApplianceMaterial(state, material) {
1924
- var _state20 = state,
1925
- scene = _state20.scene;
1920
+ var _state17 = state,
1921
+ scene = _state17.scene;
1926
1922
  var layerID = scene.get('selectedLayer');
1927
1923
  var layers = scene.layers.get(layerID);
1928
1924
  var items = layers.items;
@@ -1946,8 +1942,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1946
1942
  }, {
1947
1943
  key: "setModelling",
1948
1944
  value: function setModelling(state, molding) {
1949
- var _state21 = state,
1950
- scene = _state21.scene;
1945
+ var _state18 = state,
1946
+ scene = _state18.scene;
1951
1947
  var layerID = scene.get('selectedLayer');
1952
1948
  var layers = scene.layers.get(layerID);
1953
1949
  var items = layers.items;
@@ -2057,8 +2053,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
2057
2053
  }, {
2058
2054
  key: "toggleLoadingCabinet",
2059
2055
  value: function toggleLoadingCabinet(state) {
2060
- var _state22 = state,
2061
- scene = _state22.scene;
2056
+ var _state19 = state,
2057
+ scene = _state19.scene;
2062
2058
  console.log('scene.isLoadingCabinet: ', !scene.isLoadingCabinet);
2063
2059
  // scene = scene.set('isLoadingCabinet', !scene.isLoadingCabinet);
2064
2060
  // state = state.set('scene', scene);
@@ -2070,8 +2066,8 @@ var Item = exports["default"] = /*#__PURE__*/function () {
2070
2066
  }, {
2071
2067
  key: "endLoading",
2072
2068
  value: function endLoading(state) {
2073
- var _state23 = state,
2074
- scene = _state23.scene;
2069
+ var _state20 = state,
2070
+ scene = _state20.scene;
2075
2071
  state = state.setIn(['scene', 'loadFlag'], true);
2076
2072
  return {
2077
2073
  updatedState: state
@@ -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
  }
@@ -3006,6 +3016,7 @@ var applyTexture = function applyTexture(material, texture, length, height) {
3006
3016
  * @param {Scene} scene
3007
3017
  */
3008
3018
  function createBacksplash(item, layer, planData, scene) {
3019
+ var _getSnappedWallLines;
3009
3020
  var sceneGraph = planData.sceneGraph;
3010
3021
  var selectedLayer = planData.sceneData.selectedLayer;
3011
3022
  /**
@@ -3030,7 +3041,9 @@ function createBacksplash(item, layer, planData, scene) {
3030
3041
  }
3031
3042
 
3032
3043
  // Get current wall line that item is snapped
3033
- var wLines = (0, _geometry2.getSnappedWallLines)(item.itemInfo, layer, planData.catalog);
3044
+ var wLines = (_getSnappedWallLines = (0, _geometry3.getSnappedWallLines)(item.itemInfo, layer, planData.catalog)) === null || _getSnappedWallLines === void 0 ? void 0 : _getSnappedWallLines.filter(function (sLine) {
3045
+ return sLine.snapSide === 'front';
3046
+ });
3034
3047
  var curLine = wLines.length > 0 ? wLines[0] : null;
3035
3048
 
3036
3049
  // Get wall items which snapped to the curLine
@@ -3065,7 +3078,7 @@ function createBacksplash(item, layer, planData, scene) {
3065
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';
3066
3079
  if (!(0, _helper.isEmpty)(altitude) && !(0, _helper.isEmpty)(altitudeUnit)) {
3067
3080
  altitude = (0, _convertUnitsLite.convert)(altitude).from(altitudeUnit).to('cm');
3068
- var altPoints = (0, _geometry2.getLineSnapPointsOfItem)(layer, curLine, wallItem);
3081
+ var altPoints = (0, _geometry3.getLineSnapPointsOfItem)(layer, curLine, wallItem);
3069
3082
  if (altPoints.length > 1) {
3070
3083
  D0 = altPoints[0];
3071
3084
  D1 = altPoints[1];
@@ -3088,7 +3101,7 @@ function createBacksplash(item, layer, planData, scene) {
3088
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));
3089
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));
3090
3103
  if (!(0, _helper.isEmpty)(v0) || !(0, _helper.isEmpty)(v1)) {
3091
- 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);
3092
3105
  var disD0 = lineLength * hole.offset - width / 2;
3093
3106
  var disD1 = lineLength * hole.offset + width / 2;
3094
3107
  D0 = {
@@ -3109,19 +3122,18 @@ function createBacksplash(item, layer, planData, scene) {
3109
3122
  altitude: altitude
3110
3123
  });
3111
3124
  });
3125
+ var DEFAULT_BACKSPLASH_HEIGHT = 52 * 2.54;
3112
3126
  if (altItems.length > 0) {
3113
3127
  depth = altItems[0].altitude;
3114
3128
  altItems.map(function (altItem) {
3115
- if ((0, _geometry2.isOverlappedTwoItemsOnOneLine)(layer, curLine, item, altItem)) {
3129
+ if ((0, _geometry3.isOverlappedTwoItemsOnOneLine)(layer, curLine, item, altItem)) {
3116
3130
  if (depth >= altItem.altitude) {
3117
3131
  depth = altItem.altitude;
3118
3132
  flag = true;
3119
3133
  }
3120
- }
3134
+ } else if (!flag || depth > DEFAULT_BACKSPLASH_HEIGHT) depth = DEFAULT_BACKSPLASH_HEIGHT;
3121
3135
  });
3122
3136
  }
3123
- var DEFAULT_BACKSPLASH_HEIGHT = 52 * 2.54;
3124
- if (!flag || depth > DEFAULT_BACKSPLASH_HEIGHT) depth = DEFAULT_BACKSPLASH_HEIGHT;
3125
3137
 
3126
3138
  // Get backsplash info
3127
3139
 
@@ -3282,7 +3294,7 @@ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag)
3282
3294
  // let layoutType = molding.items[0].layoutpos;
3283
3295
  // let visible = molding.items[0];
3284
3296
  molding.pointGroups.forEach(function (pointGroup) {
3285
- var _child$width_unit, _child$height_unit, _child$length_unit;
3297
+ var _child$width_unit, _child$height_unit, _child$length_unit, _geometry2;
3286
3298
  var geometry = new Three.BufferGeometry();
3287
3299
  var length = data.length; //point array
3288
3300
  var widthUnit = child.width_unit === 'inch' ? 'in' : (_child$width_unit = child.width_unit) !== null && _child$width_unit !== void 0 ? _child$width_unit : 'in';
@@ -3296,6 +3308,10 @@ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag)
3296
3308
  child.length_unit = 'cm';
3297
3309
  geometry.needsUpdate = true;
3298
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
+ }
3299
3315
  var total = geometry.attributes.position.count;
3300
3316
  var len = geometry.attributes.position.count / length;
3301
3317
  if (!_export.GeometryUtils.samePoints(pointGroup[0], pointGroup[pointGroup.length - 1])) {
@@ -3339,7 +3355,7 @@ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag)
3339
3355
  x: data[_i2 + 1].x,
3340
3356
  y: data[_i2 + 1].y
3341
3357
  };
3342
- var posDistance = (0, _geometry2.verticesDistance)(v1, v2);
3358
+ var posDistance = (0, _geometry3.verticesDistance)(v1, v2);
3343
3359
  sumDistance += posDistance;
3344
3360
  if (_i2 === data.length - 2) finalDistance = sumDistance;
3345
3361
  sumDistanceArray.push(sumDistance);
@@ -3676,7 +3692,7 @@ function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
3676
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) {
3677
3693
  return (mol === null || mol === void 0 ? void 0 : mol.location_type) === mg.location_type;
3678
3694
  })[0];
3679
- 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) {
3680
3696
  var _mg$molding;
3681
3697
  if (mg.molding !== null && ((_mg$molding = mg.molding) === null || _mg$molding === void 0 ? void 0 : _mg$molding.itemID) !== molding.itemID) {
3682
3698
  deleteMGMesh(mg, planData, mode);
@@ -408,7 +408,7 @@ function _parseTempPlaceholdersFromCabinetPayload() {
408
408
  }
409
409
  });
410
410
  tempPlaceholdersData.push({
411
- id: parseInt(el, 10),
411
+ id: el,
412
412
  placeholders: tempData,
413
413
  structure: cabinetPayload.structure_json.tempPlaceholders[k].structure
414
414
  });
@@ -1038,11 +1038,19 @@ function _loadMoldingSvg() {
1038
1038
  }
1039
1039
  var loader = new _SVGLoader.SVGLoader();
1040
1040
  loader.load(url, function (data) {
1041
- var _data$xml$viewBox$ani, _data$xml, _data$xml$viewBox$ani2, _data$xml2;
1041
+ 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;
1042
+ // Some SVGs omit a viewBox; fall back to width/height to avoid 0 dimensions.
1043
+ // 0/invalid svg_width/svg_height later causes NaN/Infinity vertex positions in 3D molding meshes.
1044
+ 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;
1045
+ 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;
1046
+ 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;
1047
+ 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;
1048
+ var svg_width = Number((_ref6 = viewBoxWidth !== null && viewBoxWidth !== void 0 ? viewBoxWidth : attrWidth) !== null && _ref6 !== void 0 ? _ref6 : 0);
1049
+ var svg_height = Number((_ref7 = viewBoxHeight !== null && viewBoxHeight !== void 0 ? viewBoxHeight : attrHeight) !== null && _ref7 !== void 0 ? _ref7 : 0);
1042
1050
  molding.data = {
1043
1051
  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
1052
+ svg_width: Number.isFinite(svg_width) ? svg_width : 0,
1053
+ svg_height: Number.isFinite(svg_height) ? svg_height : 0
1046
1054
  };
1047
1055
  resolve();
1048
1056
  }, null, function (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "11.35.0",
3
+ "version": "11.37.0",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",