kitchen-simulator 3.1.14 → 4.0.0-alpha.12

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 (105) hide show
  1. package/es/LiteKitchenConfigurator.js +204 -24
  2. package/es/LiteRenderer.js +277 -12
  3. package/es/actions/items-actions.js +6 -10
  4. package/es/actions/lines-actions.js +1 -3
  5. package/es/actions/project-actions.js +5 -15
  6. package/es/assets/Window.hdr +2100 -0
  7. package/es/assets/gltf/door_sliding.bin +0 -0
  8. package/es/assets/img/1.jpg +0 -0
  9. package/es/catalog/areas/area/planner-element.js +5 -10
  10. package/es/catalog/catalog.js +4 -1
  11. package/es/catalog/factories/area-factory-3d.js +17 -18
  12. package/es/catalog/factories/wall-factory-3d.js +2 -2
  13. package/es/catalog/factories/wall-factory.js +8 -8
  14. package/es/catalog/lines/wall/planner-element.js +9 -18
  15. package/es/catalog/utils/exporter.js +3 -6
  16. package/es/catalog/utils/item-loader.js +197 -202
  17. package/es/catalog/utils/mtl-loader.js +2 -2
  18. package/es/catalog/utils/obj-loader.js +2 -2
  19. package/es/class/item.js +127 -107
  20. package/es/class/line.js +2 -14
  21. package/es/class/project.js +44 -150
  22. package/es/components/content.js +6 -19
  23. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  24. package/es/components/viewer2d/item.js +51 -84
  25. package/es/components/viewer2d/line.js +243 -315
  26. package/es/components/viewer2d/ruler.js +36 -16
  27. package/es/components/viewer2d/rulerDist.js +75 -44
  28. package/es/components/viewer2d/utils.js +0 -6
  29. package/es/components/viewer2d/viewer2d.js +205 -301
  30. package/es/components/viewer3d/front3D.js +2 -3
  31. package/es/components/viewer3d/libs/mtl-loader.js +2 -2
  32. package/es/components/viewer3d/libs/obj-loader.js +2 -2
  33. package/es/components/viewer3d/libs/orbit-controls.js +4 -3
  34. package/es/components/viewer3d/libs/pointer-lock-controls.js +7 -6
  35. package/es/components/viewer3d/viewer3d.js +80 -127
  36. package/es/constants.js +3 -110
  37. package/es/devLiteRenderer.js +38 -597
  38. package/es/index.js +86 -16
  39. package/es/models.js +5 -8
  40. package/es/plugins/SVGLoader.js +5 -7
  41. package/es/plugins/keyboard.js +6 -15
  42. package/es/reducers/items-reducer.js +5 -5
  43. package/es/reducers/lines-reducer.js +1 -1
  44. package/es/reducers/project-reducer.js +3 -5
  45. package/es/shared-style.js +4 -4
  46. package/es/utils/geometry.js +0 -161
  47. package/es/utils/get-edges-of-subgraphs.js +1 -1
  48. package/es/utils/graph-cycles.js +1 -1
  49. package/es/utils/graph.js +1 -1
  50. package/es/utils/helper.js +2 -67
  51. package/es/utils/isolate-event-handler.js +124 -1367
  52. package/es/utils/molding.js +2 -238
  53. package/lib/LiteKitchenConfigurator.js +205 -25
  54. package/lib/LiteRenderer.js +278 -13
  55. package/lib/actions/items-actions.js +6 -10
  56. package/lib/actions/lines-actions.js +1 -3
  57. package/lib/actions/project-actions.js +4 -15
  58. package/lib/assets/Window.hdr +2100 -0
  59. package/lib/assets/gltf/door_sliding.bin +0 -0
  60. package/lib/assets/img/1.jpg +0 -0
  61. package/lib/catalog/areas/area/planner-element.js +5 -11
  62. package/lib/catalog/catalog.js +4 -1
  63. package/lib/catalog/factories/area-factory-3d.js +14 -15
  64. package/lib/catalog/factories/wall-factory-3d.js +2 -2
  65. package/lib/catalog/factories/wall-factory.js +8 -8
  66. package/lib/catalog/lines/wall/planner-element.js +9 -19
  67. package/lib/catalog/utils/exporter.js +3 -6
  68. package/lib/catalog/utils/item-loader.js +194 -199
  69. package/lib/catalog/utils/mtl-loader.js +2 -9
  70. package/lib/catalog/utils/obj-loader.js +2 -10
  71. package/lib/class/item.js +125 -105
  72. package/lib/class/line.js +1 -13
  73. package/lib/class/project.js +43 -149
  74. package/lib/components/content.js +6 -19
  75. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  76. package/lib/components/viewer2d/item.js +50 -83
  77. package/lib/components/viewer2d/line.js +242 -315
  78. package/lib/components/viewer2d/ruler.js +35 -15
  79. package/lib/components/viewer2d/rulerDist.js +75 -44
  80. package/lib/components/viewer2d/utils.js +0 -7
  81. package/lib/components/viewer2d/viewer2d.js +205 -299
  82. package/lib/components/viewer3d/front3D.js +2 -3
  83. package/lib/components/viewer3d/libs/mtl-loader.js +2 -9
  84. package/lib/components/viewer3d/libs/obj-loader.js +2 -9
  85. package/lib/components/viewer3d/libs/orbit-controls.js +5 -11
  86. package/lib/components/viewer3d/libs/pointer-lock-controls.js +7 -13
  87. package/lib/components/viewer3d/viewer3d.js +79 -125
  88. package/lib/constants.js +7 -115
  89. package/lib/devLiteRenderer.js +33 -592
  90. package/lib/index.js +86 -16
  91. package/lib/models.js +5 -8
  92. package/lib/plugins/SVGLoader.js +5 -7
  93. package/lib/plugins/keyboard.js +6 -15
  94. package/lib/reducers/items-reducer.js +5 -5
  95. package/lib/reducers/lines-reducer.js +1 -1
  96. package/lib/reducers/project-reducer.js +2 -4
  97. package/lib/shared-style.js +4 -4
  98. package/lib/utils/geometry.js +0 -162
  99. package/lib/utils/get-edges-of-subgraphs.js +1 -6
  100. package/lib/utils/graph-cycles.js +8 -7
  101. package/lib/utils/graph.js +1 -6
  102. package/lib/utils/helper.js +3 -70
  103. package/lib/utils/isolate-event-handler.js +121 -1364
  104. package/lib/utils/molding.js +0 -238
  105. package/package.json +1 -1
package/es/index.js CHANGED
@@ -4,52 +4,122 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
7
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
+ 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; }
9
+ 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; }
7
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
11
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
12
  import React from 'react';
10
- import ReactDOM from 'react-dom';
13
+ import { createRoot } from 'react-dom/client';
11
14
  import LiteRenderer from "./LiteRenderer";
15
+ var ROOT_KEY = '__kitchenSimulatorRoot__';
12
16
  export function renderKitchenSimulator(container) {
13
17
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14
- var setExternalEventFn = null;
15
-
16
- // Internal wrapper that exposes a state setter
18
+ var apiRef = null;
19
+ var idSeq = 0;
17
20
  var Wrapper = /*#__PURE__*/function (_React$Component) {
18
21
  function Wrapper(p) {
19
22
  var _this;
20
23
  _classCallCheck(this, Wrapper);
21
24
  _this = _callSuper(this, Wrapper, [p]);
25
+ _defineProperty(_this, "onExternalEventProcessed", function (eventId) {
26
+ // only resolve the current one
27
+ if (eventId === _this._currentId) {
28
+ var _this$_currentResolve, _this2;
29
+ (_this$_currentResolve = (_this2 = _this)._currentResolve) === null || _this$_currentResolve === void 0 || _this$_currentResolve.call(_this2);
30
+ _this._currentResolve = null;
31
+ _this._currentId = null;
32
+ _this.processing = false;
33
+ _this.processNext();
34
+ }
35
+ });
22
36
  _this.state = {
23
- externalEvent: p.externalEvent || null
37
+ externalEvent: null
38
+ };
39
+ _this.queue = [];
40
+ _this.processing = false;
41
+ apiRef = {
42
+ enqueueExternalEvent: function enqueueExternalEvent(ev) {
43
+ return _this.enqueue(ev);
44
+ }
24
45
  };
25
- setExternalEventFn = _this.setExternalEvent.bind(_this);
26
46
  return _this;
27
47
  }
28
48
  _inherits(Wrapper, _React$Component);
29
49
  return _createClass(Wrapper, [{
30
- key: "setExternalEvent",
31
- value: function setExternalEvent(newEvent) {
50
+ key: "enqueue",
51
+ value: function enqueue(ev) {
52
+ if (!ev) return Promise.resolve();
53
+ var id = ++idSeq;
54
+ var resolve;
55
+ var promise = new Promise(function (res) {
56
+ return resolve = res;
57
+ });
58
+ this.queue.push({
59
+ id: id,
60
+ ev: ev,
61
+ resolve: resolve
62
+ });
63
+ if (!this.processing) this.processNext();
64
+ return promise;
65
+ }
66
+ }, {
67
+ key: "processNext",
68
+ value: function processNext() {
69
+ var _this3 = this;
70
+ var next = this.queue.shift();
71
+ if (!next) {
72
+ this.processing = false;
73
+ return;
74
+ }
75
+ this.processing = true;
76
+
77
+ // IMPORTANT: set an ID so LiteRenderer can ack it
78
+ var payload = _objectSpread(_objectSpread({}, next.ev), {}, {
79
+ __eventId: next.id
80
+ });
81
+
82
+ // Clear then set (edge trigger), but no timers needed.
32
83
  this.setState({
33
- externalEvent: newEvent
84
+ externalEvent: null
85
+ }, function () {
86
+ _this3._currentResolve = next.resolve;
87
+ _this3._currentId = next.id;
88
+ _this3.setState({
89
+ externalEvent: payload
90
+ });
34
91
  });
35
92
  }
36
93
  }, {
37
94
  key: "render",
38
95
  value: function render() {
39
96
  return /*#__PURE__*/React.createElement(LiteRenderer, _extends({}, this.props, {
40
- externalEvent: this.state.externalEvent
97
+ externalEvent: this.state.externalEvent,
98
+ onExternalEventProcessed: this.onExternalEventProcessed
41
99
  }));
42
100
  }
43
101
  }]);
44
- }(React.Component); // Mount once
45
- ReactDOM.render(/*#__PURE__*/React.createElement(Wrapper, props), container);
102
+ }(React.Component);
103
+ var root = container[ROOT_KEY];
104
+ if (!root) {
105
+ root = createRoot(container);
106
+ container[ROOT_KEY] = root;
107
+ }
108
+ root.render(/*#__PURE__*/React.createElement(Wrapper, props));
46
109
  return {
47
- updateExternalEvent: function updateExternalEvent(newExternalEvent) {
48
- var _setExternalEventFn;
49
- (_setExternalEventFn = setExternalEventFn) === null || _setExternalEventFn === void 0 || _setExternalEventFn(newExternalEvent);
110
+ enqueueExternalEvent: function enqueueExternalEvent(ev) {
111
+ var _apiRef$enqueueExtern, _apiRef, _apiRef$enqueueExtern2;
112
+ return (_apiRef$enqueueExtern = (_apiRef = apiRef) === null || _apiRef === void 0 || (_apiRef$enqueueExtern2 = _apiRef.enqueueExternalEvent) === null || _apiRef$enqueueExtern2 === void 0 ? void 0 : _apiRef$enqueueExtern2.call(_apiRef, ev)) !== null && _apiRef$enqueueExtern !== void 0 ? _apiRef$enqueueExtern : Promise.resolve();
113
+ },
114
+ updateExternalEvent: function updateExternalEvent(ev) {
115
+ var _apiRef2, _apiRef2$enqueueExter;
116
+ (_apiRef2 = apiRef) === null || _apiRef2 === void 0 || (_apiRef2$enqueueExter = _apiRef2.enqueueExternalEvent) === null || _apiRef2$enqueueExter === void 0 || _apiRef2$enqueueExter.call(_apiRef2, ev);
50
117
  },
51
118
  unmount: function unmount() {
52
- ReactDOM.unmountComponentAtNode(container);
119
+ var _container$ROOT_KEY, _container$ROOT_KEY$u;
120
+ (_container$ROOT_KEY = container[ROOT_KEY]) === null || _container$ROOT_KEY === void 0 || (_container$ROOT_KEY$u = _container$ROOT_KEY.unmount) === null || _container$ROOT_KEY$u === void 0 || _container$ROOT_KEY$u.call(_container$ROOT_KEY);
121
+ container[ROOT_KEY] = null;
122
+ apiRef = null;
53
123
  }
54
124
  };
55
125
  }
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,
42
- colors: ['rgb(115, 125, 153)']
41
+ step: 30.48,
42
+ colors: ['#bbb', '#bbb', '#bbb', '#bbb', '#bbb'] // dot's color
43
43
  }
44
44
  }),
45
45
  v1: new Grid({
46
46
  id: 'v1',
47
47
  type: 'vertical-streak',
48
48
  properties: {
49
- step: 30,
50
- colors: ['rgb(229, 233, 245)']
49
+ step: 30.48,
50
+ colors: ['#bbb', '#bbb', '#bbb', '#bbb', '#bbb'] // dot's color
51
51
  }
52
52
  })
53
53
  });
@@ -199,8 +199,6 @@ 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?
204
202
  backsplashVisible: false,
205
203
  applianceMaterial: {
206
204
  roughness: 0.4,
@@ -340,8 +338,7 @@ export var CatalogElement = /*#__PURE__*/function (_Record1) {
340
338
  info: new Map(),
341
339
  properties: new Map(),
342
340
  obj: new Map(),
343
- type: '',
344
- cds: new Map()
341
+ type: ''
345
342
  }, 'CatalogElement'));
346
343
  export var Catalog = /*#__PURE__*/function (_Record10) {
347
344
  function Catalog() {
@@ -79,13 +79,11 @@ 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
- 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
- }
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);
89
87
  }
90
88
  break;
91
89
  default:
@@ -6,21 +6,12 @@ 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
- // 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
- // }
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
+ }
24
15
  case KEYBOARD_BUTTON_CODE.ESC:
25
16
  {
26
17
  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, action.onInternalEvent).updatedState;
20
+ return Item.duplicateSelected(state, action.currentObject).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).updatedState;
31
+ return Item.selectToolDrawingItem(state, action.sceneComponentType, action.oStyle).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, action.isInitialPos).updatedState;
35
+ return Item.updateDrawingItem(state, action.layerID, action.x, action.y).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.itemCDS, action.isAll).updatedState;
108
+ return Item.setDoorStyle(state, action.doorStyle, 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).updatedState;
133
+ return Item.setInitialDoorStyle(state, action.doorStyle, action.oStyle).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, action.onInternalEvent).updatedState;
16
+ return Line.beginDrawingLine(state, action.layerID, action.x, action.y).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, CREATE_ROOM_WITH_SHAPE } 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 } 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).updatedState;
9
+ return Project.loadProject(state, action.sceneJSON, action.categoryData).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, action.delObject).updatedState;
46
+ return Project.remove(state).updatedState;
47
47
  case UNDO:
48
48
  return Project.undo(state).updatedState;
49
49
  case REDO:
@@ -125,8 +125,6 @@ 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;
130
128
  default:
131
129
  return state;
132
130
  }
@@ -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
- selected: '#6E1EA8',
58
- unselected: ' #455A64'
57
+ unselected: ' #0a0a10',
58
+ selected: '#4C12A1'
59
59
  };
60
60
  export var LINE_MESH_COLOR = {
61
- selected: '#6E1EA8',
61
+ selected: '#4C12A1',
62
62
  unselected: 'rgb(135,145,171)'
63
63
  };
64
64
  export var LINE_MESH = {
65
- selected: '#6E1EA8'
65
+ selected: '#4C12A1'
66
66
  };
@@ -2443,165 +2443,4 @@ 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
- };
2607
2446
  }
@@ -23,4 +23,4 @@ function getVerticesFromBiconnectedComponent(component) {
23
23
  });
24
24
  return vertices;
25
25
  }
26
- export default getEdgesOfSubgraphs;
26
+ module.exports = getEdgesOfSubgraphs;
@@ -202,7 +202,7 @@ function find_inner_cycles(V, EV) {
202
202
  }
203
203
 
204
204
  // export default find_inner_cycles;
205
- export default find_inner_cycles;
205
+ module.exports = 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
- export default Graph;
145
+ module.exports = Graph;
@@ -3,12 +3,12 @@ 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, MAX_ZOOM_IN_SCALE, MODE_ELEVATION_VIEW, ZOOM_VARIABLE } from "../constants";
6
+ import { ANIMATE_OBJECT_OPEN_DOOR_ROTATION_UNIT, ANIMATE_STEP_MAX, DECIMAL_PLACES_2, HDR_URLS, MODE_ELEVATION_VIEW } from "../constants";
7
7
  import * as Three from 'three';
8
8
  import { returnReplaceableDeepSearchType } from "./../components/viewer2d/utils";
9
9
  import { convert } from "./convert-units-lite";
10
10
  import { formatNumber } from "./math";
11
- import AWS from 'aws-sdk';
11
+ var AWS = require('aws-sdk');
12
12
  var s3 = new AWS.S3({
13
13
  accessKeyId: process.env.REACT_APP_AWS_ID,
14
14
  secretAccessKey: process.env.REACT_APP_AWS_SECRET
@@ -331,69 +331,4 @@ export function isImmutable(maybeImmutable) {
331
331
  }
332
332
  export function debugUtil() {
333
333
  return new Date();
334
- }
335
- export var compareSVGRect = function compareSVGRect(value) {
336
- 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;
337
- };
338
- export var updateViwer2D = function updateViwer2D(value) {
339
- var viewer2DActions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
340
- var _zoomValue = parseInt((value.a - 0.5) / ZOOM_VARIABLE);
341
- if (_zoomValue > MAX_ZOOM_IN_SCALE) return;
342
- if (_zoomValue < 0 || Number.isNaN(_zoomValue)) return;
343
-
344
- // modify e, f to fit to SVG
345
- while (!(value.e <= 10)) {
346
- value.e -= 0.1;
347
- }
348
- while (!(value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth)) {
349
- value.e += 0.1;
350
- }
351
- while (!(value.f <= 80)) {
352
- value.f -= 0.1;
353
- }
354
- while (!(value.f + value.a * value.SVGHeight + 10 >= value.viewerHeight)) {
355
- value.f += 0.1;
356
- }
357
- if (viewer2DActions && compareSVGRect(value)) viewer2DActions.updateCameraView(value);
358
- };
359
- export function centering2D(state) {
360
- var viewer2DActions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
361
- // calculate the bounding box of all elements in plan
362
- var layer = state.scene.getIn(['layers', state.scene.selectedLayer]);
363
- var bb = {
364
- minX: Infinity,
365
- maxX: -Infinity,
366
- minY: Infinity,
367
- maxY: -Infinity
368
- };
369
- bb = layer.vertices.reduce(function (pre, cur) {
370
- pre.minX = Math.min(pre.minX, cur.x);
371
- pre.maxX = Math.max(pre.maxX, cur.x);
372
- pre.minY = Math.min(pre.minY, cur.y);
373
- pre.maxY = Math.max(pre.maxY, cur.y);
374
- return pre;
375
- }, bb);
376
- var w = bb.maxX - bb.minX;
377
- var h = bb.maxY - bb.minY;
378
-
379
- // calc scale and offset to fit view
380
- var viewer = state.getIn(['viewer2D']).toJS();
381
- if (w != 0 && Math.abs(w) != Infinity && h != 0 && Math.abs(h) != Infinity) {
382
- // elements are exist && bounding box size > 0
383
- 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;
384
- viewer.d = viewer.a;
385
- viewer.e = (viewer.viewerWidth - (bb.maxX + bb.minX) * viewer.a) / 2;
386
- viewer.f = (viewer.viewerHeight - (bb.maxY + bb.minY) * viewer.a) / 2;
387
- } else {
388
- // there is no any element && bounding box size == 0
389
- viewer.e = viewer.viewerWidth / 2 - viewer.SVGWidth / 2;
390
- viewer.f = viewer.viewerHeight / 2 - viewer.SVGHeight / 2;
391
- viewer.a = 0.99;
392
- viewer.d = 0.99;
393
- }
394
- state = state.merge({
395
- viewer2D: viewer
396
- });
397
- if (viewer2DActions) updateViwer2D(viewer, viewer2DActions);
398
- return state;
399
334
  }