kitchen-simulator 10.3.0 → 10.4.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.
@@ -13,7 +13,7 @@ import { Item } from "../../models";
13
13
  import * as GeomUtils from "./geom-utils";
14
14
  import { loadGLTF } from "./load-obj";
15
15
  import { animateDoor, getSkuAliasFromCatalogElement, isEmpty, translateDrawer } from "../../utils/helper";
16
- import { isWarningItem } from "../../components/viewer2d/utils";
16
+ import { isWarningCabinet } from "../../shared/domain/cabinet-warning";
17
17
  import { orderCabinetAssemblyKeys } from "../cabinet/cabinet-assembly-order";
18
18
  var INITIAL_NORMAL_MAP = '';
19
19
 
@@ -293,7 +293,7 @@ export function render2DItem(element, layer, scene, sizeinfo, layoutpos, is_corn
293
293
  }), /*#__PURE__*/React.createElement("g", {
294
294
  transform: "translate(".concat(padding_width, ",").concat(padding_depth, ")")
295
295
  }, txtContent)), element.category === 'cabinet' && /*#__PURE__*/React.createElement("g", {
296
- visibility: isWarningItem(element) ? 'visible' : 'hidden'
296
+ visibility: isWarningCabinet(element) ? 'visible' : 'hidden'
297
297
  }, warning_buttons)));
298
298
  } else {
299
299
  rendered = /*#__PURE__*/React.createElement("g", {
@@ -3,9 +3,8 @@ import React, { useState } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import RulerDist from "./rulerDist";
5
5
  import { convert } from "../../utils/convert-units-lite";
6
- import { GeometryUtils } from "../../utils/export";
7
6
  import { MODE_ROTATING_ITEM, WALL_CABINET_LAYOUTPOS } from "../../constants";
8
- import { isEmpty, isWarningItem, returnReplaceableDeepSearchType } from "./utils";
7
+ import { isWarningCabinet } from "../../shared/domain/cabinet-warning";
9
8
  import { calcDistancesFromItemToWalls, findCatalogElement } from "../../utils/geometry";
10
9
  var STYLE_LINE = {
11
10
  fill: '#0096fd',
@@ -170,7 +169,7 @@ export default function Item(_ref, _ref2) {
170
169
  y: "-19",
171
170
  height: "16",
172
171
  width: "16",
173
- style: isWarningItem(item) ? {
172
+ style: isWarningCabinet(item) ? {
174
173
  transform: 'rotateX(180deg)',
175
174
  opacity: 0.5
176
175
  } : {
@@ -184,10 +184,4 @@ export var areaPolygon = function areaPolygon(points) {
184
184
  }
185
185
  var area = det / 2;
186
186
  return signed ? area : Math.abs(area);
187
- };
188
- export var isWarningItem = function isWarningItem(item) {
189
- var _item$toJS$doorStyle;
190
- if (item.category === 'cabinet') return !(item !== null && item !== void 0 && (_item$toJS$doorStyle = item.toJS().doorStyle) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.doorStyles) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.cds) !== null && _item$toJS$doorStyle !== void 0 && _item$toJS$doorStyle.filter(function (cd) {
191
- return cd.itemID == (item === null || item === void 0 ? void 0 : item.getIn(['itemID']));
192
- }).length) > 0;else return false;
193
187
  };
@@ -16,7 +16,7 @@ import { convert } from "../../utils/convert-units-lite";
16
16
  import { Map } from 'immutable';
17
17
  import { formatNumber } from "../../utils/math";
18
18
  import { isEmpty, updatePayloadOfInternalEvent } from "../../utils/helper"; // variables
19
- import { isWarningItem } from "./utils";
19
+ import { isWarningCabinet } from "../../shared/domain/cabinet-warning";
20
20
  // variables
21
21
  var pinFlag = false;
22
22
  var sFlag = false; //for all object move
@@ -953,7 +953,7 @@ export default function Viewer2D(_ref, _ref2) {
953
953
  case 'items':
954
954
  if (elementData.part === 'duplicate') {
955
955
  var currentObject = state.getIn(['scene', 'layers', layerID, 'items', elementData.id]);
956
- if (!isWarningItem(currentObject)) itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
956
+ if (!isWarningCabinet(currentObject)) itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
957
957
  break;
958
958
  } else if (elementData.part === 'remove') {
959
959
  projectActions.remove();
@@ -6,15 +6,17 @@ import * as Three from 'three';
6
6
  import { Color, Group } from 'three';
7
7
  import createGrid from "./grid-creator";
8
8
  import { disposeObject } from "./three-memory-cleaner";
9
- import { ANIMATE_STEP_MAX, ANIMATE_STEP_MIN, ARRAY_3D_MODES, ARROW_TEXT_BACKCOLOR, ARROW_TEXT_FONTFACE, ARROW_TEXT_FORECOLOR, BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, DECIMAL_PLACES_2, DIFFERENT_VALUES_PATH_LENGTH, DISTANCE_EPSILON, EPSILON, MIDDLE_MOLDING_LOCATION, MODE_DRAGGING_ITEM_3D, MODE_DRAWING_ITEM_3D, MODE_IDLE, MODE_IDLE_3D, MODE_ROTATING_ITEM_3D, OBJTYPE_MESH, SHADE_DARK_PURPLE_COLOR, TOP_MOLDING_LOCATION, UNIT_CENTIMETER, UNIT_FOOT, UNIT_INCH, UNIT_METER, WALL_CABINET_LAYOUTPOS } from "../../constants";
9
+ import { ANIMATE_STEP_MAX, ANIMATE_STEP_MIN, ARRAY_3D_MODES, ARROW_TEXT_BACKCOLOR, ARROW_TEXT_FONTFACE, ARROW_TEXT_FORECOLOR, BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, DECIMAL_PLACES_2, DIFFERENT_VALUES_PATH_LENGTH, DISTANCE_EPSILON, EPSILON, ITEM_TYPE, MIDDLE_MOLDING_LOCATION, MODE_DRAGGING_ITEM_3D, MODE_DRAWING_ITEM_3D, MODE_IDLE, MODE_IDLE_3D, MODE_ROTATING_ITEM_3D, OBJTYPE_MESH, SHADE_DARK_PURPLE_COLOR, TOP_MOLDING_LOCATION, UNIT_CENTIMETER, UNIT_FOOT, UNIT_INCH, UNIT_METER, WALL_CABINET_LAYOUTPOS } from "../../constants";
10
10
  import { GeometryUtils, IDBroker, MoldingUtils } from "../../utils/export";
11
11
  import { convert } from "../../utils/convert-units-lite";
12
12
  import { calcDistancesFromItemToWalls, getLineSnapPointsOfItem, getSnappedWallLines, isOverlappedTwoItemsOnOneLine, pointsDistance, verticesDistance } from "../../utils/geometry";
13
13
  import * as GeomUtils from "../../catalog/utils/geom-utils";
14
14
  import { loadTexture } from "../../catalog/utils/item-loader";
15
+ import { isWarningCabinet } from "../../shared/domain/cabinet-warning";
15
16
  import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
16
17
  import { animateDoor, isElevationView, isEmpty, isImmutable, replaceMeshesWithLineSegments, translateDrawer } from "../../utils/helper";
17
18
  import { formatNumber } from "../../utils/math";
19
+ import { toJSIfNeeded } from "../../shared/objects/immutable";
18
20
  export var fVLine = [];
19
21
  var scene_mode = null;
20
22
  export function parseData(sceneData, actions, catalog, camera, renderer, mode) {
@@ -502,16 +504,14 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
502
504
  }
503
505
  var mBoxColor = 0x99c3fb;
504
506
  var _item = item.toJS();
505
- if (_item.doorStyle.doorStyles !== undefined && _item.doorStyle.doorStyles.cds) {
506
- if (showYelloBox(_item)) {
507
- mBoxColor = 'rgba(232,187,47,1)';
508
- var mBox = GeomUtils.makeMBoxfromObject(item3D, mBoxColor);
509
- var warningObj = createWarningObject();
510
- warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
511
- if (mBox) {
512
- mBox.add(warningObj);
513
- item3D.add(mBox);
514
- }
507
+ if (isWarningCabinet(_item)) {
508
+ mBoxColor = 'rgba(232,187,47,1)';
509
+ var mBox = GeomUtils.makeMBoxfromObject(item3D, mBoxColor);
510
+ var warningObj = createWarningObject();
511
+ warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
512
+ if (mBox) {
513
+ mBox.add(warningObj);
514
+ item3D.add(mBox);
515
515
  }
516
516
  }
517
517
  }
@@ -692,16 +692,14 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
692
692
  if (item3D) {
693
693
  var _mBoxColor = 0x99c3fb;
694
694
  var _item2 = item.toJS();
695
- if (_item2.doorStyle.doorStyles !== undefined && _item2.doorStyle.doorStyles.cds) {
696
- if (showYelloBox(_item2)) {
697
- _mBoxColor = 'rgba(232,187,47,1)';
698
- var _mBox2 = GeomUtils.makeMBoxfromObject(item3D, _mBoxColor);
699
- var _warningObj = createWarningObject();
700
- _warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
701
- if (_mBox2) {
702
- _mBox2.add(_warningObj);
703
- item3D.add(_mBox2);
704
- }
695
+ if (isWarningCabinet(_item2)) {
696
+ _mBoxColor = 'rgba(232,187,47,1)';
697
+ var _mBox2 = GeomUtils.makeMBoxfromObject(item3D, _mBoxColor);
698
+ var _warningObj = createWarningObject();
699
+ _warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
700
+ if (_mBox2) {
701
+ _mBox2.add(_warningObj);
702
+ item3D.add(_mBox2);
705
703
  }
706
704
  }
707
705
  }
@@ -824,10 +822,8 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
824
822
  }
825
823
  var _mBoxColor2 = 0x99c3fb;
826
824
  var _item3 = item.toJS();
827
- if (_item3.doorStyle.doorStyles !== undefined && _item3.doorStyle.doorStyles.cds) {
828
- if (showYelloBox(_item3)) {
829
- _mBoxColor2 = 'rgba(232,187,47,1)';
830
- }
825
+ if (isWarningCabinet(_item3)) {
826
+ _mBoxColor2 = 'rgba(232,187,47,1)';
831
827
  }
832
828
  rItem.children[0].children.forEach(function (rItemElement) {
833
829
  rItemElement.visible = false;
@@ -2047,21 +2043,19 @@ function addItem(sceneData, planData, layer, itemID, catalog, itemsActions) {
2047
2043
  if (pivot) {
2048
2044
  var mBoxColor = 0x99c3fb;
2049
2045
  var _item = item.toJS();
2050
- if (_item.doorStyle.doorStyles !== undefined && _item.doorStyle.doorStyles.cds) {
2051
- if (showYelloBox(_item)) {
2052
- mBoxColor = 'rgba(232,187,47,1)';
2053
- } else {
2054
- pivot.children[0].children.forEach(function (pivotElement) {
2055
- pivotElement.visible = false;
2056
- });
2057
- }
2058
- var mBox = GeomUtils.makeMBoxfromObject(pivot, mBoxColor);
2059
- var warningObj = createWarningObject();
2060
- warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
2061
- if (mBox) {
2062
- mBox.add(warningObj);
2063
- pivot.add(mBox);
2064
- }
2046
+ if (isWarningCabinet(_item)) {
2047
+ mBoxColor = 'rgba(232,187,47,1)';
2048
+ } else {
2049
+ pivot.children[0].children.forEach(function (pivotElement) {
2050
+ pivotElement.visible = false;
2051
+ });
2052
+ }
2053
+ var mBox = GeomUtils.makeMBoxfromObject(pivot, mBoxColor);
2054
+ var warningObj = createWarningObject();
2055
+ warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
2056
+ if (mBox) {
2057
+ mBox.add(warningObj);
2058
+ pivot.add(mBox);
2065
2059
  }
2066
2060
  }
2067
2061
 
@@ -2187,13 +2181,9 @@ function addItem(sceneData, planData, layer, itemID, catalog, itemsActions) {
2187
2181
  });
2188
2182
  if (pivot.children.length > 1) {
2189
2183
  var _item4 = item.toJS();
2190
- if (_item4.doorStyle.doorStyles !== undefined) {
2191
- if (_item4.category === 'cabinet') {
2192
- if (_item4.doorStyle.doorStyles.cds.some(function (element) {
2193
- return element.itemID === item.itemID;
2194
- })) {
2195
- pivot.children.pop();
2196
- }
2184
+ if (_item4.category === ITEM_TYPE.CABINET) {
2185
+ if (!isWarningCabinet(item)) {
2186
+ pivot.children.pop();
2197
2187
  } else {
2198
2188
  pivot.children.pop();
2199
2189
  }
@@ -2910,31 +2900,6 @@ export function threedfabs(a) {
2910
2900
  export function getDistanceBetweenLineSegment(pos1, pos2, pos3, pos4) {
2911
2901
  if (pos1.x == pos2.x && pos3.x == pos4.x) return pos3.x - pos1.x;else if (pos1.y == pos2.y && pos3.y == pos4.y) return pos3.y - pos1.y;else return -1;
2912
2902
  }
2913
-
2914
- /**
2915
- * check to see if an item is suitable for the given doorStyle.
2916
- * @param _item
2917
- * @returns true if it's not suitable.
2918
- */
2919
- export function showYelloBox(_item) {
2920
- var _doorStyle;
2921
- var doorStyle = _item === null || _item === void 0 ? void 0 : _item.doorStyle;
2922
-
2923
- // If doorStyle is an Immutable Map, convert to plain JS
2924
- if (doorStyle && typeof doorStyle.toJS === 'function') {
2925
- doorStyle = doorStyle.toJS();
2926
- }
2927
- var isItemCabinet = (_item === null || _item === void 0 ? void 0 : _item.category) === 'cabinet';
2928
- var cds = (_doorStyle = doorStyle) === null || _doorStyle === void 0 || (_doorStyle = _doorStyle.doorStyles) === null || _doorStyle === void 0 ? void 0 : _doorStyle.cds;
2929
-
2930
- // hasItemCDS: item is suitable if its itemID exists in cds
2931
- var hasItemCDS = isItemCabinet && Array.isArray(cds) ? cds.some(function (element) {
2932
- return element.itemID === _item.itemID;
2933
- }) : false;
2934
-
2935
- // return true if it's a cabinet but not suitable for the current doorStyle
2936
- return isItemCabinet && !hasItemCDS;
2937
- }
2938
2903
  function isSimilar(a, b) {
2939
2904
  if (threedfabs(a - b) <= 0.01) return 1;
2940
2905
  return 0;
@@ -3473,7 +3438,7 @@ export function addMolding(MGArray, addItem, planData, layer, itemActions, mode)
3473
3438
  if (addItem.selected && [MODE_DRAGGING_ITEM_3D, MODE_ROTATING_ITEM_3D].includes(mode)) return false;
3474
3439
 
3475
3440
  // If the item is not available for current doorStyle
3476
- if (showYelloBox(addItem))
3441
+ if (isWarningCabinet(addItem))
3477
3442
  // Do not add molding to that item
3478
3443
  return MGArray;
3479
3444
 
@@ -4,8 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import React, { useState, useEffect } from 'react';
5
5
  import { Map } from 'immutable';
6
6
  import ContainerDimensions from 'react-container-dimensions';
7
- import ccdfPayload1 from "./mocks/get_ccdf_of_b12_brilliant.json";
8
- import ccdfPayload2 from "./mocks/get_ccdf_of_b12_cambridge.json";
7
+ import ccdfPayload from "./mocks/getCCDFPayload.json";
9
8
  import configData from "./mocks/configData.json";
10
9
  import projectJson from "./mocks/project.json";
11
10
  import cabinetPaylod from "./mocks/cabinetPayload.json";
@@ -29,7 +28,6 @@ var options = {
29
28
  unit: 'in',
30
29
  enable3D: true
31
30
  };
32
- var test_num = 0;
33
31
  var onInternalEvent = /*#__PURE__*/function () {
34
32
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(evt, callback) {
35
33
  var _t;
@@ -41,9 +39,8 @@ var onInternalEvent = /*#__PURE__*/function () {
41
39
  _context.next = _t === INTERNAL_EVENT_ITEMS_CATALOG ? 1 : 3;
42
40
  break;
43
41
  case 1:
44
- console.log("Use ".concat(test_num % 2 === 1 ? 'Brilliant' : 'Cambridge'));
45
42
  _context.next = 2;
46
- return callback(test_num % 2 === 1 ? ccdfPayload1 : ccdfPayload2);
43
+ return callback(ccdfPayload);
47
44
  case 2:
48
45
  return _context.abrupt("continue", 3);
49
46
  case 3:
@@ -221,11 +218,6 @@ function WorkSpace(props) {
221
218
  setExternalEvent(evt);
222
219
  }
223
220
  }, "Add B12 Cabinet"), /*#__PURE__*/React.createElement(Button, {
224
- actionType: "danger",
225
- onClick: function onClick() {
226
- test_num = 1;
227
- }
228
- }, "Use Brilliant for ITEMS_CATALOG"), /*#__PURE__*/React.createElement(Button, {
229
221
  actionType: "danger",
230
222
  onClick: function onClick() {
231
223
  var evt = {
@@ -238,11 +230,6 @@ function WorkSpace(props) {
238
230
  setExternalEvent(evt);
239
231
  }
240
232
  }, "DoorStyle Change(Brilliant)"), /*#__PURE__*/React.createElement(Button, {
241
- actionType: "danger",
242
- onClick: function onClick() {
243
- test_num = 2;
244
- }
245
- }, "Use Cambridge for ITEMS_CATALOG"), /*#__PURE__*/React.createElement(Button, {
246
233
  actionType: "danger",
247
234
  onClick: function onClick() {
248
235
  var evt = {
@@ -0,0 +1,14 @@
1
+ // Centralized warning heuristic for cabinets across 2D/3D.
2
+ // Rule: a cabinet is "warning" when there are no assets for the current door style.
3
+
4
+ import { ITEM_TYPE } from "../../constants";
5
+ import { toJSIfNeeded } from "../objects/immutable";
6
+
7
+ // Implementation: return true if item.category === 'cabinet' and (no ccdf or empty ccdf.assets3d)
8
+ export function isWarningCabinet(item) {
9
+ var js = toJSIfNeeded(item);
10
+ var isCabinet = (js === null || js === void 0 ? void 0 : js.category) === ITEM_TYPE.CABINET;
11
+ var ccdf = js === null || js === void 0 ? void 0 : js.ccdf;
12
+ var hasCcdf = !!ccdf && !!(ccdf !== null && ccdf !== void 0 && ccdf.id);
13
+ return isCabinet && !hasCcdf;
14
+ }
@@ -5,7 +5,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  import { HDRCubeTextureLoader } from 'three/examples/jsm/loaders/HDRCubeTextureLoader.js';
6
6
  import { ANIMATE_OBJECT_OPEN_DOOR_ROTATION_UNIT, ANIMATE_STEP_MAX, DECIMAL_PLACES_2, HDR_URLS, MAX_ZOOM_IN_SCALE, MODE_ELEVATION_VIEW, UNIT_CENTIMETER, ZOOM_VARIABLE } from "../constants";
7
7
  import * as Three from 'three';
8
- import { isWarningItem, returnReplaceableDeepSearchType } from "./../components/viewer2d/utils";
8
+ import { returnReplaceableDeepSearchType } from "./../components/viewer2d/utils";
9
+ import { isWarningCabinet } from "../shared/domain/cabinet-warning";
9
10
  import { convert } from "./convert-units-lite";
10
11
  import { formatNumber } from "./math";
11
12
  import AWS from 'aws-sdk';
@@ -414,7 +415,7 @@ export function updatePayloadOfInternalEvent(currentObject, layer, catalog) {
414
415
  //////////////////////////////////////
415
416
  } else if ((currentObject === null || currentObject === void 0 ? void 0 : currentObject.prototype) === 'items') {
416
417
  // check this cabinet has warning box
417
- updatedPayload.isWarning = isWarningItem(currentObject);
418
+ updatedPayload.isWarning = isWarningCabinet(currentObject);
418
419
  // check this item is available molding
419
420
  updatedPayload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, currentObject);
420
421
  // check this item is snapped to wall
@@ -24,7 +24,7 @@ var _models = require("../../models");
24
24
  var GeomUtils = _interopRequireWildcard(require("./geom-utils"));
25
25
  var _loadObj = require("./load-obj");
26
26
  var _helper = require("../../utils/helper");
27
- var _utils = require("../../components/viewer2d/utils");
27
+ var _cabinetWarning = require("../../shared/domain/cabinet-warning");
28
28
  var _cabinetAssemblyOrder = require("../cabinet/cabinet-assembly-order");
29
29
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
30
30
  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; }
@@ -307,7 +307,7 @@ function render2DItem(element, layer, scene, sizeinfo, layoutpos, is_corner, sha
307
307
  }), /*#__PURE__*/_react["default"].createElement("g", {
308
308
  transform: "translate(".concat(padding_width, ",").concat(padding_depth, ")")
309
309
  }, txtContent)), element.category === 'cabinet' && /*#__PURE__*/_react["default"].createElement("g", {
310
- visibility: (0, _utils.isWarningItem)(element) ? 'visible' : 'hidden'
310
+ visibility: (0, _cabinetWarning.isWarningCabinet)(element) ? 'visible' : 'hidden'
311
311
  }, warning_buttons)));
312
312
  } else {
313
313
  rendered = /*#__PURE__*/_react["default"].createElement("g", {
@@ -11,9 +11,8 @@ var _react = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _rulerDist = _interopRequireDefault(require("./rulerDist"));
13
13
  var _convertUnitsLite = require("../../utils/convert-units-lite");
14
- var _export = require("../../utils/export");
15
14
  var _constants = require("../../constants");
16
- var _utils = require("./utils");
15
+ var _cabinetWarning = require("../../shared/domain/cabinet-warning");
17
16
  var _geometry = require("../../utils/geometry");
18
17
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
19
18
  var STYLE_LINE = {
@@ -179,7 +178,7 @@ function Item(_ref, _ref2) {
179
178
  y: "-19",
180
179
  height: "16",
181
180
  width: "16",
182
- style: (0, _utils.isWarningItem)(item) ? {
181
+ style: (0, _cabinetWarning.isWarningCabinet)(item) ? {
183
182
  transform: 'rotateX(180deg)',
184
183
  opacity: 0.5
185
184
  } : {
@@ -9,7 +9,6 @@ exports.getInstallationSuffix = getInstallationSuffix;
9
9
  exports.getToeKickSKU = void 0;
10
10
  exports.isEmpty = isEmpty;
11
11
  exports.isEqualInstallationType = isEqualInstallationType;
12
- exports.isWarningItem = void 0;
13
12
  exports.makeSKUForMagento = makeSKUForMagento;
14
13
  exports.searchForSkuValue = exports.returnReplaceableDeepSearchType = void 0;
15
14
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
@@ -198,10 +197,4 @@ var areaPolygon = exports.areaPolygon = function areaPolygon(points) {
198
197
  }
199
198
  var area = det / 2;
200
199
  return signed ? area : Math.abs(area);
201
- };
202
- var isWarningItem = exports.isWarningItem = function isWarningItem(item) {
203
- var _item$toJS$doorStyle;
204
- if (item.category === 'cabinet') return !(item !== null && item !== void 0 && (_item$toJS$doorStyle = item.toJS().doorStyle) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.doorStyles) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.cds) !== null && _item$toJS$doorStyle !== void 0 && _item$toJS$doorStyle.filter(function (cd) {
205
- return cd.itemID == (item === null || item === void 0 ? void 0 : item.getIn(['itemID']));
206
- }).length) > 0;else return false;
207
200
  };
@@ -22,7 +22,7 @@ var _convertUnitsLite = require("../../utils/convert-units-lite");
22
22
  var _immutable = require("immutable");
23
23
  var _math = require("../../utils/math");
24
24
  var _helper = require("../../utils/helper");
25
- var _utils = require("./utils");
25
+ var _cabinetWarning = require("../../shared/domain/cabinet-warning");
26
26
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
27
27
  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; }
28
28
  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; } // variables
@@ -962,7 +962,7 @@ function Viewer2D(_ref, _ref2) {
962
962
  case 'items':
963
963
  if (elementData.part === 'duplicate') {
964
964
  var currentObject = state.getIn(['scene', 'layers', layerID, 'items', elementData.id]);
965
- if (!(0, _utils.isWarningItem)(currentObject)) itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
965
+ if (!(0, _cabinetWarning.isWarningCabinet)(currentObject)) itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
966
966
  break;
967
967
  } else if (elementData.part === 'remove') {
968
968
  projectActions.remove();
@@ -25,7 +25,6 @@ exports.parseData = parseData;
25
25
  exports.removeItem = removeItem;
26
26
  exports.removeSelItemMesh = removeSelItemMesh;
27
27
  exports.sameSign = sameSign;
28
- exports.showYelloBox = showYelloBox;
29
28
  exports.threedfabs = threedfabs;
30
29
  exports.tryAdjacentMD = tryAdjacentMD;
31
30
  exports.updateDoorHandleMesh = updateDoorHandleMesh;
@@ -44,9 +43,11 @@ var _convertUnitsLite = require("../../utils/convert-units-lite");
44
43
  var _geometry2 = require("../../utils/geometry");
45
44
  var GeomUtils = _interopRequireWildcard(require("../../catalog/utils/geom-utils"));
46
45
  var _itemLoader = require("../../catalog/utils/item-loader");
46
+ var _cabinetWarning = require("../../shared/domain/cabinet-warning");
47
47
  var _utils = require("../viewer2d/utils");
48
48
  var _helper = require("../../utils/helper");
49
49
  var _math = require("../../utils/math");
50
+ var _immutable = require("../../shared/objects/immutable");
50
51
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
51
52
  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; }
52
53
  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; }
@@ -537,16 +538,14 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
537
538
  }
538
539
  var mBoxColor = 0x99c3fb;
539
540
  var _item = item.toJS();
540
- if (_item.doorStyle.doorStyles !== undefined && _item.doorStyle.doorStyles.cds) {
541
- if (showYelloBox(_item)) {
542
- mBoxColor = 'rgba(232,187,47,1)';
543
- var mBox = GeomUtils.makeMBoxfromObject(item3D, mBoxColor);
544
- var warningObj = createWarningObject();
545
- warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
546
- if (mBox) {
547
- mBox.add(warningObj);
548
- item3D.add(mBox);
549
- }
541
+ if ((0, _cabinetWarning.isWarningCabinet)(_item)) {
542
+ mBoxColor = 'rgba(232,187,47,1)';
543
+ var mBox = GeomUtils.makeMBoxfromObject(item3D, mBoxColor);
544
+ var warningObj = createWarningObject();
545
+ warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
546
+ if (mBox) {
547
+ mBox.add(warningObj);
548
+ item3D.add(mBox);
550
549
  }
551
550
  }
552
551
  }
@@ -727,16 +726,14 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
727
726
  if (item3D) {
728
727
  var _mBoxColor = 0x99c3fb;
729
728
  var _item2 = item.toJS();
730
- if (_item2.doorStyle.doorStyles !== undefined && _item2.doorStyle.doorStyles.cds) {
731
- if (showYelloBox(_item2)) {
732
- _mBoxColor = 'rgba(232,187,47,1)';
733
- var _mBox2 = GeomUtils.makeMBoxfromObject(item3D, _mBoxColor);
734
- var _warningObj = createWarningObject();
735
- _warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
736
- if (_mBox2) {
737
- _mBox2.add(_warningObj);
738
- item3D.add(_mBox2);
739
- }
729
+ if ((0, _cabinetWarning.isWarningCabinet)(_item2)) {
730
+ _mBoxColor = 'rgba(232,187,47,1)';
731
+ var _mBox2 = GeomUtils.makeMBoxfromObject(item3D, _mBoxColor);
732
+ var _warningObj = createWarningObject();
733
+ _warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
734
+ if (_mBox2) {
735
+ _mBox2.add(_warningObj);
736
+ item3D.add(_mBox2);
740
737
  }
741
738
  }
742
739
  }
@@ -859,10 +856,8 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
859
856
  }
860
857
  var _mBoxColor2 = 0x99c3fb;
861
858
  var _item3 = item.toJS();
862
- if (_item3.doorStyle.doorStyles !== undefined && _item3.doorStyle.doorStyles.cds) {
863
- if (showYelloBox(_item3)) {
864
- _mBoxColor2 = 'rgba(232,187,47,1)';
865
- }
859
+ if ((0, _cabinetWarning.isWarningCabinet)(_item3)) {
860
+ _mBoxColor2 = 'rgba(232,187,47,1)';
866
861
  }
867
862
  rItem.children[0].children.forEach(function (rItemElement) {
868
863
  rItemElement.visible = false;
@@ -2082,21 +2077,19 @@ function addItem(sceneData, planData, layer, itemID, catalog, itemsActions) {
2082
2077
  if (pivot) {
2083
2078
  var mBoxColor = 0x99c3fb;
2084
2079
  var _item = item.toJS();
2085
- if (_item.doorStyle.doorStyles !== undefined && _item.doorStyle.doorStyles.cds) {
2086
- if (showYelloBox(_item)) {
2087
- mBoxColor = 'rgba(232,187,47,1)';
2088
- } else {
2089
- pivot.children[0].children.forEach(function (pivotElement) {
2090
- pivotElement.visible = false;
2091
- });
2092
- }
2093
- var mBox = GeomUtils.makeMBoxfromObject(pivot, mBoxColor);
2094
- var warningObj = createWarningObject();
2095
- warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
2096
- if (mBox) {
2097
- mBox.add(warningObj);
2098
- pivot.add(mBox);
2099
- }
2080
+ if ((0, _cabinetWarning.isWarningCabinet)(_item)) {
2081
+ mBoxColor = 'rgba(232,187,47,1)';
2082
+ } else {
2083
+ pivot.children[0].children.forEach(function (pivotElement) {
2084
+ pivotElement.visible = false;
2085
+ });
2086
+ }
2087
+ var mBox = GeomUtils.makeMBoxfromObject(pivot, mBoxColor);
2088
+ var warningObj = createWarningObject();
2089
+ warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
2090
+ if (mBox) {
2091
+ mBox.add(warningObj);
2092
+ pivot.add(mBox);
2100
2093
  }
2101
2094
  }
2102
2095
 
@@ -2222,13 +2215,9 @@ function addItem(sceneData, planData, layer, itemID, catalog, itemsActions) {
2222
2215
  });
2223
2216
  if (pivot.children.length > 1) {
2224
2217
  var _item4 = item.toJS();
2225
- if (_item4.doorStyle.doorStyles !== undefined) {
2226
- if (_item4.category === 'cabinet') {
2227
- if (_item4.doorStyle.doorStyles.cds.some(function (element) {
2228
- return element.itemID === item.itemID;
2229
- })) {
2230
- pivot.children.pop();
2231
- }
2218
+ if (_item4.category === _constants.ITEM_TYPE.CABINET) {
2219
+ if (!(0, _cabinetWarning.isWarningCabinet)(item)) {
2220
+ pivot.children.pop();
2232
2221
  } else {
2233
2222
  pivot.children.pop();
2234
2223
  }
@@ -2945,31 +2934,6 @@ function threedfabs(a) {
2945
2934
  function getDistanceBetweenLineSegment(pos1, pos2, pos3, pos4) {
2946
2935
  if (pos1.x == pos2.x && pos3.x == pos4.x) return pos3.x - pos1.x;else if (pos1.y == pos2.y && pos3.y == pos4.y) return pos3.y - pos1.y;else return -1;
2947
2936
  }
2948
-
2949
- /**
2950
- * check to see if an item is suitable for the given doorStyle.
2951
- * @param _item
2952
- * @returns true if it's not suitable.
2953
- */
2954
- function showYelloBox(_item) {
2955
- var _doorStyle;
2956
- var doorStyle = _item === null || _item === void 0 ? void 0 : _item.doorStyle;
2957
-
2958
- // If doorStyle is an Immutable Map, convert to plain JS
2959
- if (doorStyle && typeof doorStyle.toJS === 'function') {
2960
- doorStyle = doorStyle.toJS();
2961
- }
2962
- var isItemCabinet = (_item === null || _item === void 0 ? void 0 : _item.category) === 'cabinet';
2963
- var cds = (_doorStyle = doorStyle) === null || _doorStyle === void 0 || (_doorStyle = _doorStyle.doorStyles) === null || _doorStyle === void 0 ? void 0 : _doorStyle.cds;
2964
-
2965
- // hasItemCDS: item is suitable if its itemID exists in cds
2966
- var hasItemCDS = isItemCabinet && Array.isArray(cds) ? cds.some(function (element) {
2967
- return element.itemID === _item.itemID;
2968
- }) : false;
2969
-
2970
- // return true if it's a cabinet but not suitable for the current doorStyle
2971
- return isItemCabinet && !hasItemCDS;
2972
- }
2973
2937
  function isSimilar(a, b) {
2974
2938
  if (threedfabs(a - b) <= 0.01) return 1;
2975
2939
  return 0;
@@ -3508,7 +3472,7 @@ function addMolding(MGArray, addItem, planData, layer, itemActions, mode) {
3508
3472
  if (addItem.selected && [_constants.MODE_DRAGGING_ITEM_3D, _constants.MODE_ROTATING_ITEM_3D].includes(mode)) return false;
3509
3473
 
3510
3474
  // If the item is not available for current doorStyle
3511
- if (showYelloBox(addItem))
3475
+ if ((0, _cabinetWarning.isWarningCabinet)(addItem))
3512
3476
  // Do not add molding to that item
3513
3477
  return MGArray;
3514
3478
 
@@ -8,8 +8,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _immutable = require("immutable");
10
10
  var _reactContainerDimensions = _interopRequireDefault(require("react-container-dimensions"));
11
- var _get_ccdf_of_b12_brilliant = _interopRequireDefault(require("./mocks/get_ccdf_of_b12_brilliant.json"));
12
- var _get_ccdf_of_b12_cambridge = _interopRequireDefault(require("./mocks/get_ccdf_of_b12_cambridge.json"));
11
+ var _getCCDFPayload = _interopRequireDefault(require("./mocks/getCCDFPayload.json"));
13
12
  var _configData = _interopRequireDefault(require("./mocks/configData.json"));
14
13
  var _project = _interopRequireDefault(require("./mocks/project.json"));
15
14
  var _cabinetPayload = _interopRequireDefault(require("./mocks/cabinetPayload.json"));
@@ -33,7 +32,6 @@ var options = {
33
32
  unit: 'in',
34
33
  enable3D: true
35
34
  };
36
- var test_num = 0;
37
35
  var onInternalEvent = /*#__PURE__*/function () {
38
36
  var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(evt, callback) {
39
37
  var _t;
@@ -45,9 +43,8 @@ var onInternalEvent = /*#__PURE__*/function () {
45
43
  _context.next = _t === _constants.INTERNAL_EVENT_ITEMS_CATALOG ? 1 : 3;
46
44
  break;
47
45
  case 1:
48
- console.log("Use ".concat(test_num % 2 === 1 ? 'Brilliant' : 'Cambridge'));
49
46
  _context.next = 2;
50
- return callback(test_num % 2 === 1 ? _get_ccdf_of_b12_brilliant["default"] : _get_ccdf_of_b12_cambridge["default"]);
47
+ return callback(_getCCDFPayload["default"]);
51
48
  case 2:
52
49
  return _context.abrupt("continue", 3);
53
50
  case 3:
@@ -225,11 +222,6 @@ function WorkSpace(props) {
225
222
  setExternalEvent(evt);
226
223
  }
227
224
  }, "Add B12 Cabinet"), /*#__PURE__*/_react["default"].createElement(_antd.Button, {
228
- actionType: "danger",
229
- onClick: function onClick() {
230
- test_num = 1;
231
- }
232
- }, "Use Brilliant for ITEMS_CATALOG"), /*#__PURE__*/_react["default"].createElement(_antd.Button, {
233
225
  actionType: "danger",
234
226
  onClick: function onClick() {
235
227
  var evt = {
@@ -242,11 +234,6 @@ function WorkSpace(props) {
242
234
  setExternalEvent(evt);
243
235
  }
244
236
  }, "DoorStyle Change(Brilliant)"), /*#__PURE__*/_react["default"].createElement(_antd.Button, {
245
- actionType: "danger",
246
- onClick: function onClick() {
247
- test_num = 2;
248
- }
249
- }, "Use Cambridge for ITEMS_CATALOG"), /*#__PURE__*/_react["default"].createElement(_antd.Button, {
250
237
  actionType: "danger",
251
238
  onClick: function onClick() {
252
239
  var evt = {
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isWarningCabinet = isWarningCabinet;
7
+ var _constants = require("../../constants");
8
+ var _immutable = require("../objects/immutable");
9
+ // Centralized warning heuristic for cabinets across 2D/3D.
10
+ // Rule: a cabinet is "warning" when there are no assets for the current door style.
11
+
12
+ // Implementation: return true if item.category === 'cabinet' and (no ccdf or empty ccdf.assets3d)
13
+ function isWarningCabinet(item) {
14
+ var js = (0, _immutable.toJSIfNeeded)(item);
15
+ var isCabinet = (js === null || js === void 0 ? void 0 : js.category) === _constants.ITEM_TYPE.CABINET;
16
+ var ccdf = js === null || js === void 0 ? void 0 : js.ccdf;
17
+ var hasCcdf = !!ccdf && !!(ccdf !== null && ccdf !== void 0 && ccdf.id);
18
+ return isCabinet && !hasCcdf;
19
+ }
@@ -33,6 +33,7 @@ var _HDRCubeTextureLoader = require("three/examples/jsm/loaders/HDRCubeTextureLo
33
33
  var _constants = require("../constants");
34
34
  var Three = _interopRequireWildcard(require("three"));
35
35
  var _utils = require("./../components/viewer2d/utils");
36
+ var _cabinetWarning = require("../shared/domain/cabinet-warning");
36
37
  var _convertUnitsLite = require("./convert-units-lite");
37
38
  var _math = require("./math");
38
39
  var _awsSdk = _interopRequireDefault(require("aws-sdk"));
@@ -444,7 +445,7 @@ function updatePayloadOfInternalEvent(currentObject, layer, catalog) {
444
445
  //////////////////////////////////////
445
446
  } else if ((currentObject === null || currentObject === void 0 ? void 0 : currentObject.prototype) === 'items') {
446
447
  // check this cabinet has warning box
447
- updatedPayload.isWarning = (0, _utils.isWarningItem)(currentObject);
448
+ updatedPayload.isWarning = (0, _cabinetWarning.isWarningCabinet)(currentObject);
448
449
  // check this item is available molding
449
450
  updatedPayload.isMoldingAvailable = _export.MoldingUtils.isEnableItemForMolding(layer, currentObject);
450
451
  // check this item is snapped to wall
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "10.3.0",
3
+ "version": "10.4.0",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",