kitchen-simulator 4.1.5-react-18 → 4.1.7-react-18
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/LiteKitchenConfigurator.js +0 -9
- package/es/components/content.js +0 -5
- package/es/components/viewer2d/viewer2d.js +0 -5
- package/es/components/viewer3d/front3D.js +0 -11
- package/es/components/viewer3d/viewer3d-first-person.js +3 -2
- package/es/components/viewer3d/viewer3d.js +3 -6
- package/es/index.js +12 -11
- package/lib/LiteKitchenConfigurator.js +0 -9
- package/lib/components/content.js +0 -5
- package/lib/components/viewer2d/viewer2d.js +0 -5
- package/lib/components/viewer3d/front3D.js +0 -11
- package/lib/components/viewer3d/viewer3d-first-person.js +3 -2
- package/lib/components/viewer3d/viewer3d.js +3 -6
- package/lib/index.js +12 -11
- package/package.json +1 -1
|
@@ -108,7 +108,6 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
108
108
|
_this.closeCabinetTB = _this.closeCabinetTB.bind(_this);
|
|
109
109
|
_this.closeFinishingTB = _this.closeFinishingTB.bind(_this);
|
|
110
110
|
_this.closeApplianceTB = _this.closeApplianceTB.bind(_this);
|
|
111
|
-
_this.setToolbar = _this.setToolbar.bind(_this);
|
|
112
111
|
_this.replaceCabinet = _this.replaceCabinet.bind(_this);
|
|
113
112
|
_this.setSubmitToSave = _this.setSubmitToSave.bind(_this);
|
|
114
113
|
_this.setSignOpen = _this.setSignOpen.bind(_this);
|
|
@@ -123,13 +122,6 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
123
122
|
// Toolbar control functions
|
|
124
123
|
_inherits(LiteKitchenConfigurator, _Component);
|
|
125
124
|
return _createClass(LiteKitchenConfigurator, [{
|
|
126
|
-
key: "setToolbar",
|
|
127
|
-
value: function setToolbar(toolBarKey) {
|
|
128
|
-
this.setState({
|
|
129
|
-
toolbar: toolBarKey
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}, {
|
|
133
125
|
key: "setShowProperty",
|
|
134
126
|
value: function setShowProperty(value) {
|
|
135
127
|
this.setState({
|
|
@@ -412,7 +404,6 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
412
404
|
catalog: this.props.catalog,
|
|
413
405
|
state: extractedState,
|
|
414
406
|
toolBar: this.state.toolbar,
|
|
415
|
-
setToolbar: this.setToolbar,
|
|
416
407
|
replaceCabinet: this.replaceCabinet,
|
|
417
408
|
keyDownEnable: !savePopupVisible && !quotePopupVisible && !assistPopupVisible
|
|
418
409
|
}, props, {
|
package/es/components/content.js
CHANGED
|
@@ -14,7 +14,6 @@ export default function Content(_ref) {
|
|
|
14
14
|
state = _ref.state,
|
|
15
15
|
customContents = _ref.customContents,
|
|
16
16
|
match = _ref.match,
|
|
17
|
-
setToolbar = _ref.setToolbar,
|
|
18
17
|
replaceCabinet = _ref.replaceCabinet,
|
|
19
18
|
keyDownEnable = _ref.keyDownEnable,
|
|
20
19
|
catalog = _ref.catalog,
|
|
@@ -126,7 +125,6 @@ export default function Content(_ref) {
|
|
|
126
125
|
state: state,
|
|
127
126
|
width: width,
|
|
128
127
|
height: height,
|
|
129
|
-
setToolbar: setToolbar,
|
|
130
128
|
replaceCabinet: replaceCabinet,
|
|
131
129
|
keyDownEnable: keyDownEnable,
|
|
132
130
|
catalog: catalog
|
|
@@ -137,7 +135,6 @@ export default function Content(_ref) {
|
|
|
137
135
|
state: state,
|
|
138
136
|
width: width,
|
|
139
137
|
height: height,
|
|
140
|
-
setToolbar: setToolbar,
|
|
141
138
|
replaceCabinet: replaceCabinet,
|
|
142
139
|
keyDownEnable: keyDownEnable,
|
|
143
140
|
downloadFlag: false,
|
|
@@ -178,7 +175,6 @@ export default function Content(_ref) {
|
|
|
178
175
|
state: state,
|
|
179
176
|
width: width,
|
|
180
177
|
height: height,
|
|
181
|
-
setToolbar: setToolbar,
|
|
182
178
|
replaceCabinet: replaceCabinet,
|
|
183
179
|
onInternalEvent: onInternalEvent
|
|
184
180
|
});
|
|
@@ -193,7 +189,6 @@ export default function Content(_ref) {
|
|
|
193
189
|
state: state,
|
|
194
190
|
width: width,
|
|
195
191
|
height: height,
|
|
196
|
-
setToolbar: setToolbar,
|
|
197
192
|
replaceCabinet: replaceCabinet,
|
|
198
193
|
keyDownEnable: keyDownEnable,
|
|
199
194
|
downloadFlag: false,
|
|
@@ -127,7 +127,6 @@ export default function Viewer2D(_ref) {
|
|
|
127
127
|
var state = _ref.state,
|
|
128
128
|
width = _ref.width,
|
|
129
129
|
height = _ref.height,
|
|
130
|
-
setToolbar = _ref.setToolbar,
|
|
131
130
|
replaceCabinet = _ref.replaceCabinet,
|
|
132
131
|
onInternalEvent = _ref.onInternalEvent;
|
|
133
132
|
var _useAppContext = useAppContext(),
|
|
@@ -834,7 +833,6 @@ export default function Viewer2D(_ref) {
|
|
|
834
833
|
verticesActions.beginDraggingVertex(elementData.layer, elementData.id, x, y, state.snapMask);
|
|
835
834
|
break;
|
|
836
835
|
case 'items':
|
|
837
|
-
setToolbar('');
|
|
838
836
|
current_sel_obj_id = elementData.id;
|
|
839
837
|
if (elementData.part === 'rotation-anchor') itemsActions.beginRotatingItem(elementData.layer, elementData.id, x, y);else if (elementData.part === 'remove') break;else if (elementData.part === 'duplicate') break;else if (elementData.part === 'warning_edit') break;else {
|
|
840
838
|
// closes the setting dialog
|
|
@@ -869,9 +867,6 @@ export default function Viewer2D(_ref) {
|
|
|
869
867
|
// setRulerEdit(null);
|
|
870
868
|
var event = viewerEvent.originalEvent;
|
|
871
869
|
var bbox = event.target.getBoundingClientRect();
|
|
872
|
-
if (!mode.includes('ING')) {
|
|
873
|
-
setToolbar('');
|
|
874
|
-
}
|
|
875
870
|
// bbox.width = event.target.getBBox().width;
|
|
876
871
|
// bbox.height = event.target.getBBox().height;
|
|
877
872
|
if (event.target.tagName === 'rect') {
|
|
@@ -8,7 +8,6 @@ export default function Front3D(_ref) {
|
|
|
8
8
|
var width = _ref.width,
|
|
9
9
|
height = _ref.height,
|
|
10
10
|
state = _ref.state,
|
|
11
|
-
setToolbar = _ref.setToolbar,
|
|
12
11
|
replaceCabinet = _ref.replaceCabinet,
|
|
13
12
|
keyDownEnable = _ref.keyDownEnable,
|
|
14
13
|
catalog = _ref.catalog;
|
|
@@ -22,15 +21,6 @@ export default function Front3D(_ref) {
|
|
|
22
21
|
k++;
|
|
23
22
|
setMode(state.get('mode'));
|
|
24
23
|
}
|
|
25
|
-
var mouseUpEvent = function mouseUpEvent(event) {
|
|
26
|
-
setToolbar('');
|
|
27
|
-
};
|
|
28
|
-
useEffect(function () {
|
|
29
|
-
if (!isEmpty(document.getElementById('front'))) document.getElementById('front').addEventListener('mouseup', mouseUpEvent);
|
|
30
|
-
return function () {
|
|
31
|
-
if (!isEmpty(document.getElementById('front'))) document.getElementById('front').removeEventListener('mouseup', mouseUpEvent);
|
|
32
|
-
};
|
|
33
|
-
}, []);
|
|
34
24
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("svg", {
|
|
35
25
|
width: sceneWidth,
|
|
36
26
|
height: sceneHeight,
|
|
@@ -53,7 +43,6 @@ export default function Front3D(_ref) {
|
|
|
53
43
|
state: state,
|
|
54
44
|
width: width,
|
|
55
45
|
height: height,
|
|
56
|
-
setToolbar: setToolbar,
|
|
57
46
|
replaceCabinet: replaceCabinet,
|
|
58
47
|
keyDownEnable: keyDownEnable,
|
|
59
48
|
downloadFlag: false
|
|
@@ -24,6 +24,7 @@ var Viewer3DFirstPerson = /*#__PURE__*/function (_React$Component) {
|
|
|
24
24
|
var _this;
|
|
25
25
|
_classCallCheck(this, Viewer3DFirstPerson);
|
|
26
26
|
_this = _callSuper(this, Viewer3DFirstPerson, [props]);
|
|
27
|
+
_this.canvasWrapperRef = /*#__PURE__*/React.createRef();
|
|
27
28
|
_this.width = props.width;
|
|
28
29
|
_this.height = props.height;
|
|
29
30
|
_this.stopRendering = false;
|
|
@@ -57,7 +58,7 @@ var Viewer3DFirstPerson = /*#__PURE__*/function (_React$Component) {
|
|
|
57
58
|
};
|
|
58
59
|
var state = this.props.state;
|
|
59
60
|
var data = state.scene;
|
|
60
|
-
var canvasWrapper =
|
|
61
|
+
var canvasWrapper = this.canvasWrapperRef.current;
|
|
61
62
|
var scene3D = new Three.Scene();
|
|
62
63
|
|
|
63
64
|
// As I need to show the pointer above all scene objects, I use this workaround http://stackoverflow.com/a/13309722
|
|
@@ -300,7 +301,7 @@ var Viewer3DFirstPerson = /*#__PURE__*/function (_React$Component) {
|
|
|
300
301
|
key: "render",
|
|
301
302
|
value: function render() {
|
|
302
303
|
return /*#__PURE__*/React.createElement('div', {
|
|
303
|
-
ref:
|
|
304
|
+
ref: this.canvasWrapperRef
|
|
304
305
|
});
|
|
305
306
|
}
|
|
306
307
|
}]);
|
|
@@ -52,6 +52,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
52
52
|
_this.width = props.width;
|
|
53
53
|
_this.height = props.height;
|
|
54
54
|
_this.renderingID = 0;
|
|
55
|
+
_this.canvasWrapperRef = /*#__PURE__*/React.createRef();
|
|
55
56
|
var mode = props.state.mode;
|
|
56
57
|
if (!window.__elevationRendererDownload) {
|
|
57
58
|
window.__elevationRendererDownload = {};
|
|
@@ -1288,7 +1289,6 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1288
1289
|
}
|
|
1289
1290
|
if (_this2.props.state.mode == MODE_DRAWING_ITEM_3D) return;
|
|
1290
1291
|
if (isSelected) {
|
|
1291
|
-
!_this2.props.downloadFlag && _this2.props.setToolbar('');
|
|
1292
1292
|
if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
|
|
1293
1293
|
var _i1;
|
|
1294
1294
|
for (_i1 = 0; _i1 < intersects.length; _i1++) {
|
|
@@ -1393,9 +1393,6 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1393
1393
|
}
|
|
1394
1394
|
scene3D.remove(angleObj);
|
|
1395
1395
|
scene3D.remove(toolObj);
|
|
1396
|
-
if (!_this2.props.downloadFlag && !_this2.props.state.mode.includes('ING')) {
|
|
1397
|
-
_this2.props.setToolbar('');
|
|
1398
|
-
}
|
|
1399
1396
|
if (_this2.props.state.mode == MODE_DRAWING_ITEM_3D) {
|
|
1400
1397
|
if (Point.x > _this2.props.state.scene.width) Point.x = _this2.props.state.width;
|
|
1401
1398
|
if (Point.y > _this2.props.state.scene.height) Point.y = _this2.props.state.height;
|
|
@@ -2193,7 +2190,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
2193
2190
|
}
|
|
2194
2191
|
|
|
2195
2192
|
// Add the output of the renderer to the html element
|
|
2196
|
-
var canvasWrapper =
|
|
2193
|
+
var canvasWrapper = this.canvasWrapperRef.current;
|
|
2197
2194
|
canvasWrapper && canvasWrapper.appendChild(this.renderer.domElement);
|
|
2198
2195
|
|
|
2199
2196
|
//
|
|
@@ -2674,7 +2671,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
2674
2671
|
this.renderer.domElement.style.opacity = '1';
|
|
2675
2672
|
!this.props.downloadFlag && document.getElementById('front') && (document.getElementById('front').style.display = 'block');
|
|
2676
2673
|
return /*#__PURE__*/React.createElement('div', {
|
|
2677
|
-
ref:
|
|
2674
|
+
ref: this.canvasWrapperRef
|
|
2678
2675
|
});
|
|
2679
2676
|
}
|
|
2680
2677
|
}
|
package/es/index.js
CHANGED
|
@@ -9,6 +9,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { createRoot } from 'react-dom/client';
|
|
11
11
|
import LiteRenderer from "./LiteRenderer";
|
|
12
|
+
var ROOT_KEY = '__kitchenSimulatorRoot__';
|
|
12
13
|
export function renderKitchenSimulator(container) {
|
|
13
14
|
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14
15
|
var apiRef = null;
|
|
@@ -25,8 +26,7 @@ export function renderKitchenSimulator(container) {
|
|
|
25
26
|
apiRef = {
|
|
26
27
|
enqueueExternalEvent: function enqueueExternalEvent(ev) {
|
|
27
28
|
return _this.enqueue(ev);
|
|
28
|
-
}
|
|
29
|
-
unmount: function unmount() {}
|
|
29
|
+
}
|
|
30
30
|
};
|
|
31
31
|
return _this;
|
|
32
32
|
}
|
|
@@ -48,11 +48,7 @@ export function renderKitchenSimulator(container) {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
this.processing = true;
|
|
51
|
-
|
|
52
|
-
// Separate task => prevents React 18 batching from collapsing updates
|
|
53
51
|
setTimeout(function () {
|
|
54
|
-
// setting null first ensures `prevProps.externalEvent !== externalEvent`
|
|
55
|
-
// even if two events are referentially equal or key logic is weird
|
|
56
52
|
_this2.setState({
|
|
57
53
|
externalEvent: null
|
|
58
54
|
}, function () {
|
|
@@ -66,9 +62,7 @@ export function renderKitchenSimulator(container) {
|
|
|
66
62
|
key: "componentDidUpdate",
|
|
67
63
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
68
64
|
var _this3 = this;
|
|
69
|
-
// When the event was delivered, schedule the next one
|
|
70
65
|
if (prevState.externalEvent !== this.state.externalEvent) {
|
|
71
|
-
// Give LiteKitchenConfigurator a chance to react in its componentDidUpdate
|
|
72
66
|
setTimeout(function () {
|
|
73
67
|
return _this3.processNext();
|
|
74
68
|
}, 0);
|
|
@@ -82,8 +76,12 @@ export function renderKitchenSimulator(container) {
|
|
|
82
76
|
}));
|
|
83
77
|
}
|
|
84
78
|
}]);
|
|
85
|
-
}(React.Component);
|
|
86
|
-
var root =
|
|
79
|
+
}(React.Component); // ✅ reuse existing root if present
|
|
80
|
+
var root = container[ROOT_KEY];
|
|
81
|
+
if (!root) {
|
|
82
|
+
root = createRoot(container);
|
|
83
|
+
container[ROOT_KEY] = root;
|
|
84
|
+
}
|
|
87
85
|
root.render(/*#__PURE__*/React.createElement(Wrapper, props));
|
|
88
86
|
return {
|
|
89
87
|
updateExternalEvent: function updateExternalEvent(newExternalEvent) {
|
|
@@ -91,7 +89,10 @@ export function renderKitchenSimulator(container) {
|
|
|
91
89
|
(_apiRef = apiRef) === null || _apiRef === void 0 || (_apiRef$enqueueExtern = _apiRef.enqueueExternalEvent) === null || _apiRef$enqueueExtern === void 0 || _apiRef$enqueueExtern.call(_apiRef, newExternalEvent);
|
|
92
90
|
},
|
|
93
91
|
unmount: function unmount() {
|
|
94
|
-
|
|
92
|
+
var _container$ROOT_KEY, _container$ROOT_KEY$u;
|
|
93
|
+
// ✅ unmount and clear the stored root
|
|
94
|
+
(_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);
|
|
95
|
+
container[ROOT_KEY] = null;
|
|
95
96
|
apiRef = null;
|
|
96
97
|
}
|
|
97
98
|
};
|
|
@@ -117,7 +117,6 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
117
117
|
_this.closeCabinetTB = _this.closeCabinetTB.bind(_this);
|
|
118
118
|
_this.closeFinishingTB = _this.closeFinishingTB.bind(_this);
|
|
119
119
|
_this.closeApplianceTB = _this.closeApplianceTB.bind(_this);
|
|
120
|
-
_this.setToolbar = _this.setToolbar.bind(_this);
|
|
121
120
|
_this.replaceCabinet = _this.replaceCabinet.bind(_this);
|
|
122
121
|
_this.setSubmitToSave = _this.setSubmitToSave.bind(_this);
|
|
123
122
|
_this.setSignOpen = _this.setSignOpen.bind(_this);
|
|
@@ -132,13 +131,6 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
132
131
|
// Toolbar control functions
|
|
133
132
|
(0, _inherits2["default"])(LiteKitchenConfigurator, _Component);
|
|
134
133
|
return (0, _createClass2["default"])(LiteKitchenConfigurator, [{
|
|
135
|
-
key: "setToolbar",
|
|
136
|
-
value: function setToolbar(toolBarKey) {
|
|
137
|
-
this.setState({
|
|
138
|
-
toolbar: toolBarKey
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}, {
|
|
142
134
|
key: "setShowProperty",
|
|
143
135
|
value: function setShowProperty(value) {
|
|
144
136
|
this.setState({
|
|
@@ -421,7 +413,6 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
421
413
|
catalog: this.props.catalog,
|
|
422
414
|
state: extractedState,
|
|
423
415
|
toolBar: this.state.toolbar,
|
|
424
|
-
setToolbar: this.setToolbar,
|
|
425
416
|
replaceCabinet: this.replaceCabinet,
|
|
426
417
|
keyDownEnable: !savePopupVisible && !quotePopupVisible && !assistPopupVisible
|
|
427
418
|
}, props, {
|
|
@@ -24,7 +24,6 @@ function Content(_ref) {
|
|
|
24
24
|
state = _ref.state,
|
|
25
25
|
customContents = _ref.customContents,
|
|
26
26
|
match = _ref.match,
|
|
27
|
-
setToolbar = _ref.setToolbar,
|
|
28
27
|
replaceCabinet = _ref.replaceCabinet,
|
|
29
28
|
keyDownEnable = _ref.keyDownEnable,
|
|
30
29
|
catalog = _ref.catalog,
|
|
@@ -136,7 +135,6 @@ function Content(_ref) {
|
|
|
136
135
|
state: state,
|
|
137
136
|
width: width,
|
|
138
137
|
height: height,
|
|
139
|
-
setToolbar: setToolbar,
|
|
140
138
|
replaceCabinet: replaceCabinet,
|
|
141
139
|
keyDownEnable: keyDownEnable,
|
|
142
140
|
catalog: catalog
|
|
@@ -147,7 +145,6 @@ function Content(_ref) {
|
|
|
147
145
|
state: state,
|
|
148
146
|
width: width,
|
|
149
147
|
height: height,
|
|
150
|
-
setToolbar: setToolbar,
|
|
151
148
|
replaceCabinet: replaceCabinet,
|
|
152
149
|
keyDownEnable: keyDownEnable,
|
|
153
150
|
downloadFlag: false,
|
|
@@ -188,7 +185,6 @@ function Content(_ref) {
|
|
|
188
185
|
state: state,
|
|
189
186
|
width: width,
|
|
190
187
|
height: height,
|
|
191
|
-
setToolbar: setToolbar,
|
|
192
188
|
replaceCabinet: replaceCabinet,
|
|
193
189
|
onInternalEvent: onInternalEvent
|
|
194
190
|
});
|
|
@@ -203,7 +199,6 @@ function Content(_ref) {
|
|
|
203
199
|
state: state,
|
|
204
200
|
width: width,
|
|
205
201
|
height: height,
|
|
206
|
-
setToolbar: setToolbar,
|
|
207
202
|
replaceCabinet: replaceCabinet,
|
|
208
203
|
keyDownEnable: keyDownEnable,
|
|
209
204
|
downloadFlag: false,
|
|
@@ -135,7 +135,6 @@ function Viewer2D(_ref) {
|
|
|
135
135
|
var state = _ref.state,
|
|
136
136
|
width = _ref.width,
|
|
137
137
|
height = _ref.height,
|
|
138
|
-
setToolbar = _ref.setToolbar,
|
|
139
138
|
replaceCabinet = _ref.replaceCabinet,
|
|
140
139
|
onInternalEvent = _ref.onInternalEvent;
|
|
141
140
|
var _useAppContext = (0, _useAppContext2.useAppContext)(),
|
|
@@ -842,7 +841,6 @@ function Viewer2D(_ref) {
|
|
|
842
841
|
verticesActions.beginDraggingVertex(elementData.layer, elementData.id, x, y, state.snapMask);
|
|
843
842
|
break;
|
|
844
843
|
case 'items':
|
|
845
|
-
setToolbar('');
|
|
846
844
|
current_sel_obj_id = elementData.id;
|
|
847
845
|
if (elementData.part === 'rotation-anchor') itemsActions.beginRotatingItem(elementData.layer, elementData.id, x, y);else if (elementData.part === 'remove') break;else if (elementData.part === 'duplicate') break;else if (elementData.part === 'warning_edit') break;else {
|
|
848
846
|
// closes the setting dialog
|
|
@@ -877,9 +875,6 @@ function Viewer2D(_ref) {
|
|
|
877
875
|
// setRulerEdit(null);
|
|
878
876
|
var event = viewerEvent.originalEvent;
|
|
879
877
|
var bbox = event.target.getBoundingClientRect();
|
|
880
|
-
if (!mode.includes('ING')) {
|
|
881
|
-
setToolbar('');
|
|
882
|
-
}
|
|
883
878
|
// bbox.width = event.target.getBBox().width;
|
|
884
879
|
// bbox.height = event.target.getBBox().height;
|
|
885
880
|
if (event.target.tagName === 'rect') {
|
|
@@ -17,7 +17,6 @@ function Front3D(_ref) {
|
|
|
17
17
|
var width = _ref.width,
|
|
18
18
|
height = _ref.height,
|
|
19
19
|
state = _ref.state,
|
|
20
|
-
setToolbar = _ref.setToolbar,
|
|
21
20
|
replaceCabinet = _ref.replaceCabinet,
|
|
22
21
|
keyDownEnable = _ref.keyDownEnable,
|
|
23
22
|
catalog = _ref.catalog;
|
|
@@ -31,15 +30,6 @@ function Front3D(_ref) {
|
|
|
31
30
|
k++;
|
|
32
31
|
setMode(state.get('mode'));
|
|
33
32
|
}
|
|
34
|
-
var mouseUpEvent = function mouseUpEvent(event) {
|
|
35
|
-
setToolbar('');
|
|
36
|
-
};
|
|
37
|
-
(0, _react.useEffect)(function () {
|
|
38
|
-
if (!(0, _utils.isEmpty)(document.getElementById('front'))) document.getElementById('front').addEventListener('mouseup', mouseUpEvent);
|
|
39
|
-
return function () {
|
|
40
|
-
if (!(0, _utils.isEmpty)(document.getElementById('front'))) document.getElementById('front').removeEventListener('mouseup', mouseUpEvent);
|
|
41
|
-
};
|
|
42
|
-
}, []);
|
|
43
33
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("svg", {
|
|
44
34
|
width: sceneWidth,
|
|
45
35
|
height: sceneHeight,
|
|
@@ -62,7 +52,6 @@ function Front3D(_ref) {
|
|
|
62
52
|
state: state,
|
|
63
53
|
width: width,
|
|
64
54
|
height: height,
|
|
65
|
-
setToolbar: setToolbar,
|
|
66
55
|
replaceCabinet: replaceCabinet,
|
|
67
56
|
keyDownEnable: keyDownEnable,
|
|
68
57
|
downloadFlag: false
|
|
@@ -31,6 +31,7 @@ var Viewer3DFirstPerson = exports["default"] = /*#__PURE__*/function (_React$Com
|
|
|
31
31
|
var _this;
|
|
32
32
|
(0, _classCallCheck2["default"])(this, Viewer3DFirstPerson);
|
|
33
33
|
_this = _callSuper(this, Viewer3DFirstPerson, [props]);
|
|
34
|
+
_this.canvasWrapperRef = /*#__PURE__*/_react["default"].createRef();
|
|
34
35
|
_this.width = props.width;
|
|
35
36
|
_this.height = props.height;
|
|
36
37
|
_this.stopRendering = false;
|
|
@@ -64,7 +65,7 @@ var Viewer3DFirstPerson = exports["default"] = /*#__PURE__*/function (_React$Com
|
|
|
64
65
|
};
|
|
65
66
|
var state = this.props.state;
|
|
66
67
|
var data = state.scene;
|
|
67
|
-
var canvasWrapper =
|
|
68
|
+
var canvasWrapper = this.canvasWrapperRef.current;
|
|
68
69
|
var scene3D = new Three.Scene();
|
|
69
70
|
|
|
70
71
|
// As I need to show the pointer above all scene objects, I use this workaround http://stackoverflow.com/a/13309722
|
|
@@ -307,7 +308,7 @@ var Viewer3DFirstPerson = exports["default"] = /*#__PURE__*/function (_React$Com
|
|
|
307
308
|
key: "render",
|
|
308
309
|
value: function render() {
|
|
309
310
|
return /*#__PURE__*/_react["default"].createElement('div', {
|
|
310
|
-
ref:
|
|
311
|
+
ref: this.canvasWrapperRef
|
|
311
312
|
});
|
|
312
313
|
}
|
|
313
314
|
}]);
|
|
@@ -58,6 +58,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
|
|
|
58
58
|
_this.width = props.width;
|
|
59
59
|
_this.height = props.height;
|
|
60
60
|
_this.renderingID = 0;
|
|
61
|
+
_this.canvasWrapperRef = /*#__PURE__*/_react["default"].createRef();
|
|
61
62
|
var mode = props.state.mode;
|
|
62
63
|
if (!window.__elevationRendererDownload) {
|
|
63
64
|
window.__elevationRendererDownload = {};
|
|
@@ -1294,7 +1295,6 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
|
|
|
1294
1295
|
}
|
|
1295
1296
|
if (_this2.props.state.mode == _constants.MODE_DRAWING_ITEM_3D) return;
|
|
1296
1297
|
if (isSelected) {
|
|
1297
|
-
!_this2.props.downloadFlag && _this2.props.setToolbar('');
|
|
1298
1298
|
if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
|
|
1299
1299
|
var _i1;
|
|
1300
1300
|
for (_i1 = 0; _i1 < intersects.length; _i1++) {
|
|
@@ -1399,9 +1399,6 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
|
|
|
1399
1399
|
}
|
|
1400
1400
|
scene3D.remove(angleObj);
|
|
1401
1401
|
scene3D.remove(toolObj);
|
|
1402
|
-
if (!_this2.props.downloadFlag && !_this2.props.state.mode.includes('ING')) {
|
|
1403
|
-
_this2.props.setToolbar('');
|
|
1404
|
-
}
|
|
1405
1402
|
if (_this2.props.state.mode == _constants.MODE_DRAWING_ITEM_3D) {
|
|
1406
1403
|
if (Point.x > _this2.props.state.scene.width) Point.x = _this2.props.state.width;
|
|
1407
1404
|
if (Point.y > _this2.props.state.scene.height) Point.y = _this2.props.state.height;
|
|
@@ -2199,7 +2196,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
|
|
|
2199
2196
|
}
|
|
2200
2197
|
|
|
2201
2198
|
// Add the output of the renderer to the html element
|
|
2202
|
-
var canvasWrapper =
|
|
2199
|
+
var canvasWrapper = this.canvasWrapperRef.current;
|
|
2203
2200
|
canvasWrapper && canvasWrapper.appendChild(this.renderer.domElement);
|
|
2204
2201
|
|
|
2205
2202
|
//
|
|
@@ -2680,7 +2677,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
|
|
|
2680
2677
|
this.renderer.domElement.style.opacity = '1';
|
|
2681
2678
|
!this.props.downloadFlag && document.getElementById('front') && (document.getElementById('front').style.display = 'block');
|
|
2682
2679
|
return /*#__PURE__*/_react["default"].createElement('div', {
|
|
2683
|
-
ref:
|
|
2680
|
+
ref: this.canvasWrapperRef
|
|
2684
2681
|
});
|
|
2685
2682
|
}
|
|
2686
2683
|
}
|
package/lib/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var _client = require("react-dom/client");
|
|
|
17
17
|
var _LiteRenderer = _interopRequireDefault(require("./LiteRenderer"));
|
|
18
18
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
19
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
|
+
var ROOT_KEY = '__kitchenSimulatorRoot__';
|
|
20
21
|
function renderKitchenSimulator(container) {
|
|
21
22
|
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
22
23
|
var apiRef = null;
|
|
@@ -33,8 +34,7 @@ function renderKitchenSimulator(container) {
|
|
|
33
34
|
apiRef = {
|
|
34
35
|
enqueueExternalEvent: function enqueueExternalEvent(ev) {
|
|
35
36
|
return _this.enqueue(ev);
|
|
36
|
-
}
|
|
37
|
-
unmount: function unmount() {}
|
|
37
|
+
}
|
|
38
38
|
};
|
|
39
39
|
return _this;
|
|
40
40
|
}
|
|
@@ -56,11 +56,7 @@ function renderKitchenSimulator(container) {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
this.processing = true;
|
|
59
|
-
|
|
60
|
-
// Separate task => prevents React 18 batching from collapsing updates
|
|
61
59
|
setTimeout(function () {
|
|
62
|
-
// setting null first ensures `prevProps.externalEvent !== externalEvent`
|
|
63
|
-
// even if two events are referentially equal or key logic is weird
|
|
64
60
|
_this2.setState({
|
|
65
61
|
externalEvent: null
|
|
66
62
|
}, function () {
|
|
@@ -74,9 +70,7 @@ function renderKitchenSimulator(container) {
|
|
|
74
70
|
key: "componentDidUpdate",
|
|
75
71
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
76
72
|
var _this3 = this;
|
|
77
|
-
// When the event was delivered, schedule the next one
|
|
78
73
|
if (prevState.externalEvent !== this.state.externalEvent) {
|
|
79
|
-
// Give LiteKitchenConfigurator a chance to react in its componentDidUpdate
|
|
80
74
|
setTimeout(function () {
|
|
81
75
|
return _this3.processNext();
|
|
82
76
|
}, 0);
|
|
@@ -90,8 +84,12 @@ function renderKitchenSimulator(container) {
|
|
|
90
84
|
}));
|
|
91
85
|
}
|
|
92
86
|
}]);
|
|
93
|
-
}(_react["default"].Component);
|
|
94
|
-
var root =
|
|
87
|
+
}(_react["default"].Component); // ✅ reuse existing root if present
|
|
88
|
+
var root = container[ROOT_KEY];
|
|
89
|
+
if (!root) {
|
|
90
|
+
root = (0, _client.createRoot)(container);
|
|
91
|
+
container[ROOT_KEY] = root;
|
|
92
|
+
}
|
|
95
93
|
root.render(/*#__PURE__*/_react["default"].createElement(Wrapper, props));
|
|
96
94
|
return {
|
|
97
95
|
updateExternalEvent: function updateExternalEvent(newExternalEvent) {
|
|
@@ -99,7 +97,10 @@ function renderKitchenSimulator(container) {
|
|
|
99
97
|
(_apiRef = apiRef) === null || _apiRef === void 0 || (_apiRef$enqueueExtern = _apiRef.enqueueExternalEvent) === null || _apiRef$enqueueExtern === void 0 || _apiRef$enqueueExtern.call(_apiRef, newExternalEvent);
|
|
100
98
|
},
|
|
101
99
|
unmount: function unmount() {
|
|
102
|
-
|
|
100
|
+
var _container$ROOT_KEY, _container$ROOT_KEY$u;
|
|
101
|
+
// ✅ unmount and clear the stored root
|
|
102
|
+
(_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);
|
|
103
|
+
container[ROOT_KEY] = null;
|
|
103
104
|
apiRef = null;
|
|
104
105
|
}
|
|
105
106
|
};
|