kitchen-simulator 3.10.0 → 3.11.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
@@ -9,10 +9,10 @@ import { Group, Hole, Layer } from "./export";
9
9
  import { GeometryUtils, IDBroker, MoldingUtils, NameGenerator } from "../utils/export";
10
10
  import { fromJS, Map } from 'immutable';
11
11
  import { INSTALLATION_SUFFIX_TYPE, INTERNAL_EVENT_DRAW_ELEMENT, MODE_DRAGGING_ITEM, MODE_DRAGGING_ITEM_3D, MODE_DRAWING_ITEM, MODE_DRAWING_ITEM_3D, MODE_IDLE, MODE_IDLE_3D, MODE_ROTATING_ITEM, MODE_ROTATING_ITEM_3D, MOLDING_LOCATIONS } from "../constants";
12
- import { debugUtil } from "../utils/helper";
12
+ import { debugUtil, updatePayloadOfInternalEvent } from "../utils/helper";
13
13
  import { isUndefined } from 'util';
14
14
  import { hasMoldingLayout } from "../utils/molding";
15
- import { getInstallationSuffix, isWarningItem } from "../components/viewer2d/utils";
15
+ import { getInstallationSuffix } from "../components/viewer2d/utils";
16
16
  import { historyPush } from "../utils/history";
17
17
  var allItemRect;
18
18
  var allItemSnap;
@@ -465,8 +465,9 @@ var Item = /*#__PURE__*/function () {
465
465
  break;
466
466
  }
467
467
  if (onInternalEvent && duplicatedElement) {
468
- var jsElement = duplicatedElement.toJS();
469
- if (jsElement.prototype === 'items') jsElement.isWarning = isWarningItem(duplicatedElement);
468
+ var _state$get;
469
+ var catalog = (_state$get = state.get('catalog')) === null || _state$get === void 0 ? void 0 : _state$get.toJS();
470
+ var jsElement = updatePayloadOfInternalEvent(duplicatedElement, layer, catalog);
470
471
  onInternalEvent({
471
472
  type: INTERNAL_EVENT_DRAW_ELEMENT,
472
473
  value: jsElement
package/es/class/line.js CHANGED
@@ -6,8 +6,7 @@ import { Group, Hole, Layer, Vertex } from "./export";
6
6
  import { GeometryUtils, history, IDBroker, NameGenerator, SnapSceneUtils, SnapUtils } from "../utils/export";
7
7
  import * as Three from 'three';
8
8
  import { END_DRAGGING_LINE, END_DRAGGING_VERTEX, END_DRAWING_LINE, EPSILON, INTERNAL_EVENT_START_DRAW_WALL, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_DRAGGING_LINE, MODE_DRAWING_LINE, MODE_IDLE, MODE_WAITING_DRAWING_LINE, UNIT_ANGLE } from "../constants";
9
- import { isEmpty } from "../utils/helper";
10
- import { convert } from "../utils/convert-units-lite";
9
+ import { isEmpty, updatePayloadOfInternalEvent } from "../utils/helper";
11
10
  var timeGlobal = 0;
12
11
  var TimeRecorder = /*#__PURE__*/function () {
13
12
  function TimeRecorder(name) {
@@ -428,6 +427,7 @@ var Line = /*#__PURE__*/function () {
428
427
  }, {
429
428
  key: "beginDrawingLine",
430
429
  value: function beginDrawingLine(state, layerID, x, y, onInternalEvent) {
430
+ var _state$get;
431
431
  // if end drawing by created area
432
432
  if (state.mode == MODE_IDLE) {
433
433
  return {
@@ -481,12 +481,8 @@ var Line = /*#__PURE__*/function () {
481
481
  drawingSupport: drawingSupport
482
482
  });
483
483
  var layer = state.getIn(['scene', 'layers', layerID]);
484
- var payload = line.toJS();
485
- var v_a = layer.vertices.get(line.vertices.get(0));
486
- var v_b = layer.vertices.get(line.vertices.get(1));
487
- var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
488
- var _length = convert(distance).from('cm').to(layer.unit);
489
- payload.length = _length;
484
+ var catalog = (_state$get = state.get('catalog')) === null || _state$get === void 0 ? void 0 : _state$get.toJS();
485
+ var payload = updatePayloadOfInternalEvent(line, layer, catalog);
490
486
  if (onInternalEvent) onInternalEvent({
491
487
  type: INTERNAL_EVENT_START_DRAW_WALL,
492
488
  value: payload
@@ -15,9 +15,8 @@ import FormNumberInput from "../style/form-number-input";
15
15
  import { convert } from "../../utils/convert-units-lite";
16
16
  import { Map } from 'immutable';
17
17
  import { formatNumber } from "../../utils/math";
18
- import { isEmpty } from "../../utils/helper"; // variables
18
+ import { isEmpty, updatePayloadOfInternalEvent } from "../../utils/helper"; // variables
19
19
  import { isWarningItem } from "./utils";
20
- import { MoldingUtils } from "../../utils/export";
21
20
  // variables
22
21
  var pinFlag = false;
23
22
  var sFlag = false; //for all object move
@@ -1251,24 +1250,7 @@ export default function Viewer2D(_ref, _ref2) {
1251
1250
  _currentObject = state.getIn(['scene', 'layers', layerID, elementPrototype, elementID]);
1252
1251
  }
1253
1252
  if (_currentObject) {
1254
- var _currentObject3, _currentObject4, _currentObject5;
1255
- var payload = (_currentObject3 = _currentObject) === null || _currentObject3 === void 0 ? void 0 : _currentObject3.toJS();
1256
- if (((_currentObject4 = _currentObject) === null || _currentObject4 === void 0 ? void 0 : _currentObject4.prototype) === 'lines') {
1257
- // caculating length of selected line//
1258
- var v_a = layer.vertices.get(_currentObject.vertices.get(0));
1259
- var v_b = layer.vertices.get(_currentObject.vertices.get(1));
1260
- var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1261
- var _length3 = convert(distance).from('cm').to(layer.unit);
1262
- payload.length = _length3;
1263
- //////////////////////////////////////
1264
- } else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
1265
- // check this cabinet has warning box
1266
- payload.isWarning = isWarningItem(_currentObject);
1267
- // check this item is available molding
1268
- payload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, _currentObject);
1269
- // check this item is snapped to wall
1270
- payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, _currentObject);
1271
- }
1253
+ var payload = updatePayloadOfInternalEvent(_currentObject, layer, catalog);
1272
1254
 
1273
1255
  // send selection event befor replace event
1274
1256
  if (internalType === constants.INTERNAL_EVENT_REPLACE_CABINET) {
@@ -642,10 +642,10 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
642
642
  vLine3.material.depthTest = false;
643
643
  var uVec = new Three.Vector3(-posVec.x / scalevec.x, -posVec.y / scalevec.y, -posVec.z / scalevec.z);
644
644
  var blLighting = item.type.includes('Light');
645
- vLine.translateY(blLighting ? 1.6 : 0.1);
646
- vLine1.translateY(blLighting ? 1.6 : 0.1);
647
- vLine2.translateY(blLighting ? 1.6 : 0.1);
648
- vLine3.translateY(blLighting ? 1.6 : 0.1);
645
+ vLine.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
646
+ vLine1.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
647
+ vLine2.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
648
+ vLine3.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
649
649
  upObj.translateOnAxis(uVec, 1);
650
650
  upObj.translateY(max.y - min.y);
651
651
  _mBox.name = 'TransformBox';
@@ -24,12 +24,11 @@ import { isUndefined } from 'util';
24
24
  import { verticesDistance } from "../../utils/geometry";
25
25
  import { convert } from "../../utils/convert-units-lite";
26
26
  import { GeometryUtils } from "../../utils/export";
27
- import { handleCamRect, isElevationView, isEmpty } from "../../utils/helper";
27
+ import { handleCamRect, isElevationView, isEmpty, updatePayloadOfInternalEvent } from "../../utils/helper";
28
28
  import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader';
29
29
  import CameraControls from 'camera-controls';
30
30
  import { getAllMeshes, vectorIntersectWithMesh } from "../../utils/objects-utils";
31
- import { isWarningItem, returnReplaceableDeepSearchType } from "../viewer2d/utils";
32
- import { MoldingUtils } from "../../utils/export";
31
+ import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
33
32
  CameraControls.install({
34
33
  THREE: Three
35
34
  });
@@ -1187,25 +1186,9 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1187
1186
  var sendInternalEvent = function sendInternalEvent(evtType, evtElement) {
1188
1187
  var pointArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1189
1188
  if (!isEmpty(evtType) && !isEmpty(evtElement)) {
1190
- var _this2$props$onIntern, _this2$props;
1191
- var payload = evtElement === null || evtElement === void 0 ? void 0 : evtElement.toJS();
1192
- if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'lines') {
1193
- // caculating length of selected line//
1194
- var v_a = layer.vertices.get(evtElement.vertices.get(0));
1195
- var v_b = layer.vertices.get(evtElement.vertices.get(1));
1196
- var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1197
- var _length = convert(distance).from('cm').to(layer.unit);
1198
- payload.length = _length;
1199
- //////////////////////////////////////
1200
- } else if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'items') {
1201
- // check this cabinet has warning box
1202
- payload.isWarning = isWarningItem(evtElement);
1203
- // check this item is available molding
1204
- payload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, evtElement); // check this item is snapped to wall
1205
- payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, evtElement);
1206
- // update distArray
1207
- if (pointArray) payload.distArray = pointArray;
1208
- }
1189
+ var _state$get, _this2$props$onIntern, _this2$props;
1190
+ var catalog = (_state$get = state.get('catalog')) === null || _state$get === void 0 ? void 0 : _state$get.toJS();
1191
+ var payload = updatePayloadOfInternalEvent(evtElement, layer, catalog, pointArray);
1209
1192
  (_this2$props$onIntern = (_this2$props = _this2.props).onInternalEvent) === null || _this2$props$onIntern === void 0 || _this2$props$onIntern.call(_this2$props, {
1210
1193
  type: evtType,
1211
1194
  value: payload
@@ -5,10 +5,11 @@ 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, ZOOM_VARIABLE } from "../constants";
7
7
  import * as Three from 'three';
8
- import { returnReplaceableDeepSearchType } from "./../components/viewer2d/utils";
8
+ import { isWarningItem, returnReplaceableDeepSearchType } from "./../components/viewer2d/utils";
9
9
  import { convert } from "./convert-units-lite";
10
10
  import { formatNumber } from "./math";
11
11
  import AWS from 'aws-sdk';
12
+ import { GeometryUtils, MoldingUtils } from "./export";
12
13
  var s3 = new AWS.S3({
13
14
  accessKeyId: process.env.REACT_APP_AWS_ID,
14
15
  secretAccessKey: process.env.REACT_APP_AWS_SECRET
@@ -396,4 +397,40 @@ export function centering2D(state) {
396
397
  });
397
398
  if (viewer2DActions) updateViwer2D(viewer, viewer2DActions);
398
399
  return state;
400
+ }
401
+ export function updatePayloadOfInternalEvent(currentObject, layer, catalog) {
402
+ var pointArray = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
403
+ if (isEmpty(currentObject)) return null;
404
+ var updatedPayload = currentObject.toJS();
405
+ if (isEmpty(layer) || isEmpty(catalog)) return updatedPayload;
406
+ if ((currentObject === null || currentObject === void 0 ? void 0 : currentObject.prototype) === 'lines') {
407
+ // caculating length of selected line//
408
+ var v_a = layer.vertices.get(currentObject.vertices.get(0));
409
+ var v_b = layer.vertices.get(currentObject.vertices.get(1));
410
+ var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
411
+ var _length = convert(distance).from('cm').to(layer.unit);
412
+ updatedPayload.length = _length;
413
+ //////////////////////////////////////
414
+ } else if ((currentObject === null || currentObject === void 0 ? void 0 : currentObject.prototype) === 'items') {
415
+ var _catalog$elements$cur;
416
+ // check this cabinet has warning box
417
+ updatedPayload.isWarning = isWarningItem(currentObject);
418
+ // check this item is available molding
419
+ updatedPayload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, currentObject);
420
+ // check this item is snapped to wall
421
+ updatedPayload.isAttachedWall = MoldingUtils.isAttachedWall(layer, currentObject);
422
+ // update distArray
423
+ if (pointArray) updatedPayload.distArray = pointArray;
424
+
425
+ // update sku_number using sku_array
426
+ var currentDoorColorId = currentObject.getIn(['doorStyle', 'id']);
427
+ var skuArray = catalog === null || catalog === void 0 || (_catalog$elements$cur = catalog.elements[currentObject.get('name')]) === null || _catalog$elements$cur === void 0 || (_catalog$elements$cur = _catalog$elements$cur.obj) === null || _catalog$elements$cur === void 0 ? void 0 : _catalog$elements$cur.skuArray;
428
+ var correctSKU = skuArray === null || skuArray === void 0 ? void 0 : skuArray.find(function (sku) {
429
+ return sku.door_color_id === currentDoorColorId;
430
+ });
431
+ if (correctSKU) {
432
+ updatedPayload.sku_number = correctSKU.sku;
433
+ }
434
+ }
435
+ return updatedPayload;
399
436
  }