kitchen-simulator 4.0.0-queuedEvents → 4.0.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.
Files changed (111) hide show
  1. package/es/LiteKitchenConfigurator.js +141 -288
  2. package/es/LiteRenderer.js +159 -398
  3. package/es/actions/items-actions.js +10 -6
  4. package/es/actions/lines-actions.js +3 -1
  5. package/es/actions/project-actions.js +15 -5
  6. package/es/assets/img/svg/bottombar/elevation.svg +12 -5
  7. package/es/catalog/areas/area/planner-element.js +10 -5
  8. package/es/catalog/catalog.js +1 -4
  9. package/es/catalog/factories/area-factory-3d.js +2 -1
  10. package/es/catalog/factories/wall-factory-3d.js +2 -2
  11. package/es/catalog/factories/wall-factory.js +8 -8
  12. package/es/catalog/lines/wall/planner-element.js +18 -9
  13. package/es/catalog/utils/exporter.js +7 -3
  14. package/es/catalog/utils/item-loader.js +24 -14
  15. package/es/catalog/utils/mtl-loader.js +2 -2
  16. package/es/catalog/utils/obj-loader.js +2 -2
  17. package/es/class/hole.js +0 -2
  18. package/es/class/item.js +183 -184
  19. package/es/class/line.js +11 -3
  20. package/es/class/project.js +165 -48
  21. package/es/components/content.js +19 -6
  22. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  23. package/es/components/viewer2d/item.js +84 -51
  24. package/es/components/viewer2d/line.js +315 -243
  25. package/es/components/viewer2d/ruler.js +20 -38
  26. package/es/components/viewer2d/rulerDist.js +48 -78
  27. package/es/components/viewer2d/utils.js +6 -0
  28. package/es/components/viewer2d/viewer2d.js +298 -220
  29. package/es/components/viewer3d/front3D.js +3 -2
  30. package/es/components/viewer3d/libs/mtl-loader.js +2 -2
  31. package/es/components/viewer3d/libs/obj-loader.js +2 -2
  32. package/es/components/viewer3d/libs/orbit-controls.js +3 -4
  33. package/es/components/viewer3d/libs/pointer-lock-controls.js +6 -7
  34. package/es/components/viewer3d/scene-creator.js +51 -15
  35. package/es/components/viewer3d/viewer3d.js +121 -82
  36. package/es/constants.js +111 -3
  37. package/es/devLiteRenderer.js +688 -31
  38. package/es/index.js +567 -87
  39. package/es/models.js +9 -5
  40. package/es/plugins/SVGLoader.js +7 -5
  41. package/es/plugins/console-debugger.js +0 -2
  42. package/es/plugins/keyboard.js +15 -6
  43. package/es/reducers/items-reducer.js +5 -5
  44. package/es/reducers/lines-reducer.js +1 -1
  45. package/es/reducers/project-reducer.js +5 -3
  46. package/es/shared-style.js +4 -4
  47. package/es/utils/geometry.js +163 -2
  48. package/es/utils/get-edges-of-subgraphs.js +1 -1
  49. package/es/utils/graph-cycles.js +1 -1
  50. package/es/utils/graph.js +1 -1
  51. package/es/utils/helper.js +105 -3
  52. package/es/utils/isolate-event-handler.js +1542 -164
  53. package/es/utils/molding.js +461 -11
  54. package/lib/LiteKitchenConfigurator.js +141 -289
  55. package/lib/LiteRenderer.js +159 -399
  56. package/lib/actions/items-actions.js +10 -6
  57. package/lib/actions/lines-actions.js +3 -1
  58. package/lib/actions/project-actions.js +15 -4
  59. package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
  60. package/lib/catalog/areas/area/planner-element.js +11 -5
  61. package/lib/catalog/catalog.js +1 -4
  62. package/lib/catalog/factories/area-factory-3d.js +2 -1
  63. package/lib/catalog/factories/wall-factory-3d.js +2 -2
  64. package/lib/catalog/factories/wall-factory.js +8 -8
  65. package/lib/catalog/lines/wall/planner-element.js +19 -9
  66. package/lib/catalog/utils/exporter.js +7 -3
  67. package/lib/catalog/utils/item-loader.js +24 -14
  68. package/lib/catalog/utils/mtl-loader.js +9 -2
  69. package/lib/catalog/utils/obj-loader.js +10 -2
  70. package/lib/class/hole.js +0 -2
  71. package/lib/class/item.js +180 -181
  72. package/lib/class/line.js +9 -1
  73. package/lib/class/project.js +164 -47
  74. package/lib/components/content.js +19 -6
  75. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  76. package/lib/components/viewer2d/item.js +83 -50
  77. package/lib/components/viewer2d/line.js +315 -242
  78. package/lib/components/viewer2d/ruler.js +19 -37
  79. package/lib/components/viewer2d/rulerDist.js +48 -78
  80. package/lib/components/viewer2d/utils.js +7 -0
  81. package/lib/components/viewer2d/viewer2d.js +296 -219
  82. package/lib/components/viewer3d/front3D.js +3 -2
  83. package/lib/components/viewer3d/libs/mtl-loader.js +9 -2
  84. package/lib/components/viewer3d/libs/obj-loader.js +9 -2
  85. package/lib/components/viewer3d/libs/orbit-controls.js +11 -5
  86. package/lib/components/viewer3d/libs/pointer-lock-controls.js +13 -7
  87. package/lib/components/viewer3d/scene-creator.js +49 -13
  88. package/lib/components/viewer3d/viewer3d.js +119 -80
  89. package/lib/constants.js +116 -7
  90. package/lib/devLiteRenderer.js +687 -30
  91. package/lib/index.js +567 -87
  92. package/lib/models.js +9 -5
  93. package/lib/plugins/SVGLoader.js +7 -5
  94. package/lib/plugins/console-debugger.js +0 -2
  95. package/lib/plugins/keyboard.js +15 -6
  96. package/lib/reducers/items-reducer.js +5 -5
  97. package/lib/reducers/lines-reducer.js +1 -1
  98. package/lib/reducers/project-reducer.js +4 -2
  99. package/lib/shared-style.js +4 -4
  100. package/lib/utils/geometry.js +164 -2
  101. package/lib/utils/get-edges-of-subgraphs.js +6 -1
  102. package/lib/utils/graph-cycles.js +7 -8
  103. package/lib/utils/graph.js +6 -1
  104. package/lib/utils/helper.js +108 -2
  105. package/lib/utils/isolate-event-handler.js +1538 -159
  106. package/lib/utils/molding.js +463 -9
  107. package/package.json +1 -1
  108. package/es/assets/Window.hdr +0 -2100
  109. package/es/assets/img/1.jpg +0 -0
  110. package/lib/assets/Window.hdr +0 -2100
  111. package/lib/assets/img/1.jpg +0 -0
package/es/models.js CHANGED
@@ -38,16 +38,16 @@ export var DefaultGrids = new Map({
38
38
  id: 'h1',
39
39
  type: 'horizontal-streak',
40
40
  properties: {
41
- step: 30.48,
42
- colors: ['#bbb', '#bbb', '#bbb', '#bbb', '#bbb'] // dot's color
41
+ step: 30,
42
+ colors: ['rgb(115, 125, 153)']
43
43
  }
44
44
  }),
45
45
  v1: new Grid({
46
46
  id: 'v1',
47
47
  type: 'vertical-streak',
48
48
  properties: {
49
- step: 30.48,
50
- colors: ['#bbb', '#bbb', '#bbb', '#bbb', '#bbb'] // dot's color
49
+ step: 30,
50
+ colors: ['rgb(229, 233, 245)']
51
51
  }
52
52
  })
53
53
  });
@@ -199,6 +199,8 @@ export var Item = /*#__PURE__*/function (_Record7) {
199
199
  uri: ''
200
200
  },
201
201
  molding: [],
202
+ isInitialPos: false,
203
+ //current {x,y} is the initial position from host?
202
204
  backsplashVisible: false,
203
205
  applianceMaterial: {
204
206
  roughness: 0.4,
@@ -338,7 +340,9 @@ export var CatalogElement = /*#__PURE__*/function (_Record1) {
338
340
  info: new Map(),
339
341
  properties: new Map(),
340
342
  obj: new Map(),
341
- type: ''
343
+ type: '',
344
+ cds: new Map(),
345
+ structure_json: {}
342
346
  }, 'CatalogElement'));
343
347
  export var Catalog = /*#__PURE__*/function (_Record10) {
344
348
  function Catalog() {
@@ -79,11 +79,13 @@ SVGLoader.prototype = Object.assign(Object.create(Loader.prototype), {
79
79
  case 'use':
80
80
  style = parseStyle(node, style);
81
81
  var usedNodeId = node.href.baseVal.substring(1);
82
- var usedNode = node.viewportElement.getElementById(usedNodeId);
83
- if (usedNode) {
84
- parseNode(usedNode, style);
85
- } else {
86
- console.warn("SVGLoader: 'use node' references non-existent node id: " + usedNodeId);
82
+ if (node.viewportElement.getElementById(usedNodeId)) {
83
+ var usedNode = node.viewportElement.getElementById(usedNodeId);
84
+ if (usedNode) {
85
+ parseNode(usedNode, style);
86
+ } else {
87
+ console.warn("SVGLoader: 'use node' references non-existent node id: " + usedNodeId);
88
+ }
87
89
  }
88
90
  break;
89
91
  default:
@@ -27,8 +27,6 @@ export default function consoleDebugger() {
27
27
  });
28
28
  console.groupCollapsed('KitchenConfigurator');
29
29
  console.info('KitchenConfigurator is ready');
30
- console.info('console.log(KitchenConfigurator)');
31
- console.log(window.KitchenConfigurator);
32
30
  console.groupEnd();
33
31
  };
34
32
  }
@@ -6,12 +6,21 @@ export default function keyboard() {
6
6
  var state = stateExtractor(store.getState());
7
7
  var mode = state.get('mode');
8
8
  switch (event.keyCode) {
9
- case KEYBOARD_BUTTON_CODE.BACKSPACE:
10
- case KEYBOARD_BUTTON_CODE.DELETE:
11
- {
12
- if ([MODE_IDLE, MODE_3D_FIRST_PERSON, MODE_3D_VIEW, MODE_IDLE_3D, MODE_ROTATING_ITEM_3D, MODE_DRAGGING_ITEM_3D].includes(mode)) store.dispatch(remove());
13
- break;
14
- }
9
+ // case KEYBOARD_BUTTON_CODE.BACKSPACE:
10
+ // case KEYBOARD_BUTTON_CODE.DELETE: {
11
+ // if (
12
+ // [
13
+ // MODE_IDLE,
14
+ // MODE_3D_FIRST_PERSON,
15
+ // MODE_3D_VIEW,
16
+ // MODE_IDLE_3D,
17
+ // MODE_ROTATING_ITEM_3D,
18
+ // MODE_DRAGGING_ITEM_3D
19
+ // ].includes(mode)
20
+ // )
21
+ // store.dispatch(remove());
22
+ // break;
23
+ // }
15
24
  case KEYBOARD_BUTTON_CODE.ESC:
16
25
  {
17
26
  store.dispatch(rollback());
@@ -17,7 +17,7 @@ export default function (state, action) {
17
17
  case EDIT_WIDTH:
18
18
  return Item.editWidth(state, action.newWidth, action.layerID, action.itemID).updatedState;
19
19
  case DUPLICATE_SELECTED:
20
- return Item.duplicateSelected(state, action.currentObject).updatedState;
20
+ return Item.duplicateSelected(state, action.currentObject, action.onInternalEvent).updatedState;
21
21
  case END_CREATING_CABINET:
22
22
  return Item.endCreatingCabinet(state).updatedState;
23
23
  case UPDATE_POPUP_OPEN:
@@ -28,11 +28,11 @@ export default function (state, action) {
28
28
  state = state.merge({
29
29
  sceneHistory: history.historyPush(state.sceneHistory, state.scene)
30
30
  });
31
- return Item.selectToolDrawingItem(state, action.sceneComponentType, action.oStyle).updatedState;
31
+ return Item.selectToolDrawingItem(state, action.sceneComponentType).updatedState;
32
32
  case REPLACE_ITEM:
33
33
  return Item.replaceItem(state, action.selectedPos, action.currentObject, action.selectedObject).updatedState;
34
34
  case UPDATE_DRAWING_ITEM:
35
- return Item.updateDrawingItem(state, action.layerID, action.x, action.y).updatedState;
35
+ return Item.updateDrawingItem(state, action.layerID, action.x, action.y, action.isInitialPos).updatedState;
36
36
  case END_DRAWING_ITEM:
37
37
  state = state.merge({
38
38
  sceneHistory: history.historyPush(state.sceneHistory, state.scene)
@@ -105,7 +105,7 @@ export default function (state, action) {
105
105
  case SELECT_TOOL_DRAWING_ITEM_3D:
106
106
  return Item.selectToolDrawingItem3D(state, action.sceneComponentType).updatedState;
107
107
  case SET_DOOR_STYLE:
108
- return Item.setDoorStyle(state, action.doorStyle, action.isAll).updatedState;
108
+ return Item.setDoorStyle(state, action.doorStyle, action.itemCDS, action.isAll).updatedState;
109
109
  case SET_HANDLE_MATERIAL:
110
110
  return Item.setHandleMaterial(state, action.material).updatedState;
111
111
  case SET_DOOR_HANDLE:
@@ -130,7 +130,7 @@ export default function (state, action) {
130
130
  case SET_APPLIANCE_MATERIAL:
131
131
  return Item.setApplianceMaterial(state, action.material).updatedState;
132
132
  case SET_INITIAL_DOOR_STYLE:
133
- return Item.setInitialDoorStyle(state, action.doorStyle, action.oStyle).updatedState;
133
+ return Item.setInitialDoorStyle(state, action.doorStyle).updatedState;
134
134
  case UPDATE_ITEM_POSITION:
135
135
  return Item.updateItemPosition(state, action.layerID, action.itemID, action.pos).updatedState;
136
136
  // case SET_MOVE_STATUS:
@@ -13,7 +13,7 @@ export default function (state, action) {
13
13
  state = state.merge({
14
14
  sceneHistory: history.historyPush(state.sceneHistory, state.scene)
15
15
  });
16
- return Line.beginDrawingLine(state, action.layerID, action.x, action.y).updatedState;
16
+ return Line.beginDrawingLine(state, action.layerID, action.x, action.y, action.onInternalEvent).updatedState;
17
17
  case UPDATE_DRAWING_LINE:
18
18
  return Line.updateDrawingLine(state, action.x, action.y, action.relatedLines).updatedState;
19
19
  case STOP_DRAWING_LINE:
@@ -1,12 +1,12 @@
1
1
  import { history } from "../utils/export";
2
- import { LOAD_PROJECT, NEW_PROJECT, OPEN_CATALOG, SELECT_TOOL_EDIT, MODE_IDLE, UNSELECT_ALL, SELECT_ALL, SET_PROPERTIES, SET_ITEMS_ATTRIBUTES, SET_LINES_ATTRIBUTES, SET_HOLES_ATTRIBUTES, REMOVE, INVERT, UNDO, REDO, RECREATE, UNCREATE, PROJECT_RE_NAME, ROLLBACK, SET_PROJECT_PROPERTIES, SET_PROJECT_ID, OPEN_PROJECT_CONFIGURATOR, INIT_CATALOG, UPDATE_MOUSE_COORDS, UPDATE_ZOOM_SCALE, TOGGLE_SNAP, CHANGE_CATALOG_PAGE, GO_BACK_TO_CATALOG_PAGE, THROW_ERROR, THROW_WARNING, COPY_PROPERTIES, PASTE_PROPERTIES, PUSH_LAST_SELECTED_CATALOG_ELEMENT_TO_HISTORY, ALTERATE_STATE, SET_MODE, ADD_HORIZONTAL_GUIDE, ADD_VERTICAL_GUIDE, ADD_CIRCULAR_GUIDE, REMOVE_HORIZONTAL_GUIDE, REMOVE_VERTICAL_GUIDE, REMOVE_CIRCULAR_GUIDE, REMOVE_DRAWING_SUPPORT, SET_STATE_PROPERTIES, SHIFT2DON, SHIFT2DOFF, MODE_DRAWING_LINE, SET_IS_HELP, SET_IS_CABINET_DRAWING, ADD_ELEMENT_TO_CATALOG } from "../constants";
2
+ import { LOAD_PROJECT, NEW_PROJECT, OPEN_CATALOG, SELECT_TOOL_EDIT, MODE_IDLE, UNSELECT_ALL, SELECT_ALL, SET_PROPERTIES, SET_ITEMS_ATTRIBUTES, SET_LINES_ATTRIBUTES, SET_HOLES_ATTRIBUTES, REMOVE, INVERT, UNDO, REDO, RECREATE, UNCREATE, PROJECT_RE_NAME, ROLLBACK, SET_PROJECT_PROPERTIES, SET_PROJECT_ID, OPEN_PROJECT_CONFIGURATOR, INIT_CATALOG, UPDATE_MOUSE_COORDS, UPDATE_ZOOM_SCALE, TOGGLE_SNAP, CHANGE_CATALOG_PAGE, GO_BACK_TO_CATALOG_PAGE, THROW_ERROR, THROW_WARNING, COPY_PROPERTIES, PASTE_PROPERTIES, PUSH_LAST_SELECTED_CATALOG_ELEMENT_TO_HISTORY, ALTERATE_STATE, SET_MODE, ADD_HORIZONTAL_GUIDE, ADD_VERTICAL_GUIDE, ADD_CIRCULAR_GUIDE, REMOVE_HORIZONTAL_GUIDE, REMOVE_VERTICAL_GUIDE, REMOVE_CIRCULAR_GUIDE, REMOVE_DRAWING_SUPPORT, SET_STATE_PROPERTIES, SHIFT2DON, SHIFT2DOFF, MODE_DRAWING_LINE, SET_IS_HELP, SET_IS_CABINET_DRAWING, ADD_ELEMENT_TO_CATALOG, CREATE_ROOM_WITH_SHAPE } from "../constants";
3
3
  import { Project } from "../class/export";
4
4
  export default function (state, action) {
5
5
  switch (action.type) {
6
6
  case NEW_PROJECT:
7
7
  return Project.newProject(state).updatedState;
8
8
  case LOAD_PROJECT:
9
- return Project.loadProject(state, action.sceneJSON, action.categoryData).updatedState;
9
+ return Project.loadProject(state, action.sceneJSON).updatedState;
10
10
  case OPEN_CATALOG:
11
11
  return Project.openCatalog(state).updatedState;
12
12
  case CHANGE_CATALOG_PAGE:
@@ -43,7 +43,7 @@ export default function (state, action) {
43
43
  state = state.merge({
44
44
  sceneHistory: history.historyPush(state.sceneHistory, state.scene)
45
45
  });
46
- return Project.remove(state).updatedState;
46
+ return Project.remove(state, action.delObject).updatedState;
47
47
  case UNDO:
48
48
  return Project.undo(state).updatedState;
49
49
  case REDO:
@@ -125,6 +125,8 @@ export default function (state, action) {
125
125
  return Project.setIsHelp(state, action.isHelp).updatedState;
126
126
  case SET_IS_CABINET_DRAWING:
127
127
  return Project.setIsCabinetDrawing(state, action.isCabinetDrawing).updatedState;
128
+ case CREATE_ROOM_WITH_SHAPE:
129
+ return Project.createRoomWithShape(state, action.roomShapeType, action.width, action.height, action.doorStyle).updatedState;
128
130
  default:
129
131
  return state;
130
132
  }
@@ -54,13 +54,13 @@ export var AREA_MESH_COLOR = {
54
54
  unselected: 'rgb(221,221,255)'
55
55
  };
56
56
  export var INTERIOR_LINE = {
57
- unselected: ' #0a0a10',
58
- selected: '#4C12A1'
57
+ selected: '#6E1EA8',
58
+ unselected: ' #455A64'
59
59
  };
60
60
  export var LINE_MESH_COLOR = {
61
- selected: '#4C12A1',
61
+ selected: '#6E1EA8',
62
62
  unselected: 'rgb(135,145,171)'
63
63
  };
64
64
  export var LINE_MESH = {
65
- selected: '#4C12A1'
65
+ selected: '#6E1EA8'
66
66
  };
@@ -1873,7 +1873,7 @@ export function getAllHoleRect(scene, val) {
1873
1873
  layer.lines.forEach(function (line) {
1874
1874
  line.holes.forEach(function (holeID) {
1875
1875
  var hole = layer.holes.get(holeID);
1876
- holes.push(hole);
1876
+ if (hole) holes.push(hole);
1877
1877
  });
1878
1878
  });
1879
1879
  var i = 0;
@@ -2105,7 +2105,7 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2105
2105
  lineSX = _sort4[0],
2106
2106
  lineDX = _sort4[1];
2107
2107
  var isReversedSrcLineIdx = false;
2108
- if (lineSX[0].x === line1[0].x && lineSX[0].y === line1[0].y) isReversedSrcLineIdx = true;
2108
+ if (lineSX[0].x === line0[0].x && lineSX[0].y === line0[0].y) isReversedSrcLineIdx = false;else if (lineSX[0].x === line1[0].x && lineSX[0].y === line1[0].y) isReversedSrcLineIdx = true;
2109
2109
  var compare0 = comparator(lineSX[0], lineDX[0]);
2110
2110
  var compare1 = comparator(lineSX[1], lineDX[0]);
2111
2111
  var compare2 = comparator(lineSX[1], lineDX[1]);
@@ -2443,4 +2443,165 @@ export function validRect(itemRect, rects) {
2443
2443
  return rects.every(function (rect) {
2444
2444
  return !intersectRect(rect.rect, updatedItemRect.rect);
2445
2445
  });
2446
+ }
2447
+ function getCalcRectFromItem2(itemInfo) {
2448
+ var x = itemInfo.pos.x;
2449
+ var y = itemInfo.pos.y;
2450
+ var w = itemInfo.size.width / 2;
2451
+ var h = itemInfo.size.height / 2;
2452
+ var rotRad = itemInfo.rotRad;
2453
+ var mh = 3 * h / 4;
2454
+ var mx = x - w * Math.cos(rotRad) - mh * Math.sin(rotRad);
2455
+ var my = y - w * Math.sin(rotRad) + mh * Math.cos(rotRad);
2456
+ var m2x = x + w * Math.cos(rotRad) - mh * Math.sin(rotRad);
2457
+ var m2y = y + w * Math.sin(rotRad) + mh * Math.cos(rotRad);
2458
+ var m3x = x - h * Math.sin(rotRad);
2459
+ var m3y = y + h * Math.cos(rotRad);
2460
+ var m1x = x + h * Math.sin(rotRad);
2461
+ var m1y = y - h * Math.cos(rotRad);
2462
+ return {
2463
+ rectCenterPoint: [[point(mx, my), 180], [point(m1x, m1y), -90], [point(m2x, m2y), 0], [point(m3x, m3y), 90]]
2464
+ };
2465
+ }
2466
+ function getAllItems2(curItem, layer) {
2467
+ var rectarray = [];
2468
+ var tempHeight = curItem.get('properties').get('depth');
2469
+ layer.items.forEach(function (item) {
2470
+ var val = {
2471
+ pos: {
2472
+ x: item.x,
2473
+ y: item.y
2474
+ },
2475
+ rotRad: item.rotation / 180 * Math.PI
2476
+ };
2477
+ var width = convert(item.properties.getIn(['width', '_length'])).from('in').to('cm');
2478
+ var height = convert(item.properties.getIn(['depth', '_length'])).from('in').to('cm');
2479
+ val.size = {
2480
+ width: width,
2481
+ height: height
2482
+ };
2483
+ if (curItem.get('id') !== item.id) {
2484
+ var detectObjectsAtSameAltitudeFlag = curItem.get('layoutpos') === 'Base' ? item.properties.getIn(['altitude', '_length']) <= curItem.get('properties').getIn(['altitude', '_length']) + tempHeight.get('_length') : item.properties.getIn(['altitude', '_length']) + item.properties.getIn(['height', '_length']) >= curItem.get('properties').getIn(['altitude', '_length']);
2485
+ if (detectObjectsAtSameAltitudeFlag) {
2486
+ var x = val.pos.x;
2487
+ var y = val.pos.y;
2488
+ var rotRad = val.rotRad;
2489
+ var w = val.size.width / 2;
2490
+ var h = val.size.height / 2;
2491
+ var mx = x - w * Math.cos(rotRad);
2492
+ var my = y - w * Math.sin(rotRad);
2493
+ var x0 = mx + h * Math.sin(rotRad);
2494
+ var y0 = my - h * Math.cos(rotRad);
2495
+ var x3 = mx * 2 - x0;
2496
+ var y3 = my * 2 - y0;
2497
+ var x1 = x * 2 - x3;
2498
+ var y1 = y * 2 - y3;
2499
+ var x2 = x * 2 - x0;
2500
+ var y2 = y * 2 - y0;
2501
+ rectarray.push({
2502
+ rect: [point(x0, y0), point(x1, y1), point(x0, y0), point(x1, y1)]
2503
+ });
2504
+ rectarray.push({
2505
+ rect: [point(x1, y1), point(x2, y2), point(x1, y1), point(x2, y2)]
2506
+ });
2507
+ rectarray.push({
2508
+ rect: [point(x2, y2), point(x3, y3), point(x2, y2), point(x3, y3)]
2509
+ });
2510
+ rectarray.push({
2511
+ rect: [point(x3, y3), point(x0, y0), point(x3, y3), point(x0, y0)]
2512
+ });
2513
+ }
2514
+ }
2515
+ });
2516
+ return {
2517
+ others: rectarray
2518
+ };
2519
+ }
2520
+ export function calcDistancesFromItemToWalls(curItem, layer) {
2521
+ if (isEmpty(curItem)) return [];
2522
+ var x = curItem.get('x');
2523
+ var y = curItem.get('y');
2524
+ var rotRad = curItem.get('rotation') / 180 * Math.PI;
2525
+ var width, height;
2526
+ if (curItem.get('properties').get('width') || curItem.get('properties').get('depth')) {
2527
+ width = convert(curItem.get('properties').get('width').get('_length')).from(curItem.get('properties').get('width').get('_unit')).to('cm');
2528
+ height = convert(curItem.get('properties').get('depth').get('_length')).from(curItem.get('properties').get('depth').get('_unit')).to('cm');
2529
+ } else {
2530
+ width = convert(curItem.info.sizeinfo.width).from('in').to('cm');
2531
+ height = convert(curItem.info.sizeinfo.depth).from('in').to('cm');
2532
+ }
2533
+ var center_h = 3 * height / 8;
2534
+ var center_x = x; // middle of front line of cabinet rect
2535
+ var center_y = y;
2536
+ var center_x1 = x - center_h * Math.sin(rotRad); // center point of cabinet rect
2537
+ var center_y1 = y + center_h * Math.cos(rotRad);
2538
+ var PointArray = [];
2539
+ var itemInfo = {
2540
+ pos: {
2541
+ x: x,
2542
+ y: y
2543
+ },
2544
+ rotRad: rotRad
2545
+ };
2546
+ itemInfo.size = {
2547
+ width: width,
2548
+ height: height
2549
+ };
2550
+ var curiteminfo = getCalcRectFromItem2(itemInfo);
2551
+ var allItemRect = getAllItems2(curItem, layer);
2552
+ var allLines = getAllLines(layer);
2553
+ var allLineRects = buildRectFromLines(layer, allLines);
2554
+ var allRect = allLineRects.concat(allItemRect.others);
2555
+ var _loop = function _loop(i) {
2556
+ // [rectCenterPoint] has four middle points of cabinet rect edges
2557
+ var centerpoint = curiteminfo.rectCenterPoint[i];
2558
+ var comparelength = []; // distance array from rectCenterPoint[i] to other lines(walls, other cabinet rect edges)
2559
+ var a;
2560
+ var RectLineFuction; // normal line of cabinet rect edge
2561
+ if (centerpoint[1] === 180 || centerpoint[1] === 0) RectLineFuction = linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x1, center_y1);else RectLineFuction = linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x, center_y);
2562
+ allRect.forEach(function (linerect) {
2563
+ // calc distance to all other lines
2564
+ var p0 = clone_point(linerect.rect[2]);
2565
+ var p1 = clone_point(linerect.rect[3]);
2566
+ var lineFunction = {}; // other line function
2567
+ if (p0.x !== p1.x || p0.y !== p1.y) lineFunction = linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
2568
+ // intersection between normal line and other line
2569
+ var coordinatePoint = twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
2570
+ if (coordinatePoint !== undefined) {
2571
+ if (
2572
+ // intersection point is on the other line
2573
+ pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
2574
+ // check the intersection point is outside direction of edge
2575
+ var isOutside = true;
2576
+ for (var j = 0; j < curiteminfo.rectCenterPoint.length; j++) {
2577
+ if (j === i) continue;
2578
+ var otherCenterPoint = curiteminfo.rectCenterPoint[j];
2579
+ if (isPointOnLineSegment(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y, otherCenterPoint[0].x, otherCenterPoint[0].y)) isOutside = false;
2580
+ }
2581
+ if (isOutside && pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
2582
+ comparelength.push(pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
2583
+ a = Math.min.apply(null, comparelength);
2584
+ }
2585
+ }
2586
+ }
2587
+ });
2588
+ PointArray.push([a, centerpoint[1]]);
2589
+ };
2590
+ for (var i = 0; i < curiteminfo.rectCenterPoint.length; i++) {
2591
+ _loop(i);
2592
+ }
2593
+ PointArray.forEach(function (pointElement, index) {
2594
+ if (pointElement[0] == undefined) PointArray[index][0] = 0;
2595
+ });
2596
+ var cnt = 0;
2597
+ PointArray.forEach(function (pointElement) {
2598
+ if (pointElement[0] == 0) cnt++;
2599
+ });
2600
+ if (cnt == 4 || cnt == 3) {
2601
+ PointArray[0][0] = 100;
2602
+ PointArray[1][0] = 100;
2603
+ }
2604
+ return {
2605
+ PointArray: PointArray
2606
+ };
2446
2607
  }
@@ -23,4 +23,4 @@ function getVerticesFromBiconnectedComponent(component) {
23
23
  });
24
24
  return vertices;
25
25
  }
26
- module.exports = getEdgesOfSubgraphs;
26
+ export default getEdgesOfSubgraphs;
@@ -202,7 +202,7 @@ function find_inner_cycles(V, EV) {
202
202
  }
203
203
 
204
204
  // export default find_inner_cycles;
205
- module.exports = find_inner_cycles;
205
+ export default find_inner_cycles;
206
206
 
207
207
  /**
208
208
  * DATA
package/es/utils/graph.js CHANGED
@@ -142,4 +142,4 @@ var Graph = /*#__PURE__*/function () {
142
142
  }
143
143
  }]);
144
144
  }();
145
- module.exports = Graph;
145
+ export default Graph;
@@ -3,12 +3,13 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  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; }
4
4
  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) { _defineProperty(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; }
5
5
  import { HDRCubeTextureLoader } from 'three/examples/jsm/loaders/HDRCubeTextureLoader.js';
6
- import { ANIMATE_OBJECT_OPEN_DOOR_ROTATION_UNIT, ANIMATE_STEP_MAX, DECIMAL_PLACES_2, HDR_URLS, MODE_ELEVATION_VIEW } from "../constants";
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
- var AWS = require('aws-sdk');
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
@@ -331,4 +332,105 @@ export function isImmutable(maybeImmutable) {
331
332
  }
332
333
  export function debugUtil() {
333
334
  return new Date();
335
+ }
336
+ export var compareSVGRect = function compareSVGRect(value) {
337
+ return value.e <= 10 && value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth && value.f <= 80 && value.f + value.d * value.SVGHeight + 10 >= value.viewerHeight ? true : false;
338
+ };
339
+ export var updateViwer2D = function updateViwer2D(value) {
340
+ var viewer2DActions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
341
+ var _zoomValue = parseInt((value.a - 0.5) / ZOOM_VARIABLE);
342
+ if (_zoomValue > MAX_ZOOM_IN_SCALE) return;
343
+ if (_zoomValue < 0 || Number.isNaN(_zoomValue)) return;
344
+
345
+ // modify e, f to fit to SVG
346
+ while (!(value.e <= 10)) {
347
+ value.e -= 0.1;
348
+ }
349
+ while (!(value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth)) {
350
+ value.e += 0.1;
351
+ }
352
+ while (!(value.f <= 80)) {
353
+ value.f -= 0.1;
354
+ }
355
+ while (!(value.f + value.a * value.SVGHeight + 10 >= value.viewerHeight)) {
356
+ value.f += 0.1;
357
+ }
358
+ if (viewer2DActions && compareSVGRect(value)) viewer2DActions.updateCameraView(value);
359
+ };
360
+ export function centering2D(state) {
361
+ var viewer2DActions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
362
+ // calculate the bounding box of all elements in plan
363
+ var layer = state.scene.getIn(['layers', state.scene.selectedLayer]);
364
+ var bb = {
365
+ minX: Infinity,
366
+ maxX: -Infinity,
367
+ minY: Infinity,
368
+ maxY: -Infinity
369
+ };
370
+ bb = layer.vertices.reduce(function (pre, cur) {
371
+ pre.minX = Math.min(pre.minX, cur.x);
372
+ pre.maxX = Math.max(pre.maxX, cur.x);
373
+ pre.minY = Math.min(pre.minY, cur.y);
374
+ pre.maxY = Math.max(pre.maxY, cur.y);
375
+ return pre;
376
+ }, bb);
377
+ var w = bb.maxX - bb.minX;
378
+ var h = bb.maxY - bb.minY;
379
+
380
+ // calc scale and offset to fit view
381
+ var viewer = state.getIn(['viewer2D']).toJS();
382
+ if (w != 0 && Math.abs(w) != Infinity && h != 0 && Math.abs(h) != Infinity) {
383
+ // elements are exist && bounding box size > 0
384
+ viewer.a = viewer.viewerHeight < h ? viewer.viewerHeight / h : viewer.viewerHeight / h * 3 / 5 / ZOOM_VARIABLE > MAX_ZOOM_IN_SCALE ? viewer.viewerHeight / h * MAX_ZOOM_IN_SCALE / (viewer.viewerHeight / h / ZOOM_VARIABLE) : viewer.viewerHeight / h * 3 / 5;
385
+ viewer.d = viewer.a;
386
+ viewer.e = (viewer.viewerWidth - (bb.maxX + bb.minX) * viewer.a) / 2;
387
+ viewer.f = (viewer.viewerHeight - (bb.maxY + bb.minY) * viewer.a) / 2;
388
+ } else {
389
+ // there is no any element && bounding box size == 0
390
+ viewer.e = viewer.viewerWidth / 2 - viewer.SVGWidth / 2;
391
+ viewer.f = viewer.viewerHeight / 2 - viewer.SVGHeight / 2;
392
+ viewer.a = 0.99;
393
+ viewer.d = 0.99;
394
+ }
395
+ state = state.merge({
396
+ viewer2D: viewer
397
+ });
398
+ if (viewer2DActions) updateViwer2D(viewer, viewer2DActions);
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;
334
436
  }