kitchen-simulator 7.0.4-react-18 → 7.0.6-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/WorkSpaceHostMimic.js +45 -35
- package/es/class/project.js +1 -14
- package/es/utils/helper.js +23 -6
- package/es/utils/isolate-event-handler.js +4 -4
- package/package.json +1 -1
package/es/WorkSpaceHostMimic.js
CHANGED
|
@@ -6,7 +6,7 @@ import { useResizeDetector } from 'react-resize-detector';
|
|
|
6
6
|
import mockProps from "./mocks/mockProps.json";
|
|
7
7
|
import projectItemsCatalog from "./mocks/projectItemsCatalog.json";
|
|
8
8
|
import renderKitchenSimulator from "./index";
|
|
9
|
-
import { EXTERNAL_EVENT_CENTERING_2D, INTERNAL_EVENT_ITEMS_CATALOG } from "./constants";
|
|
9
|
+
import { EXTERNAL_EVENT_CENTERING_2D, EXTERNAL_EVENT_LOAD_PROJECT, INTERNAL_EVENT_ITEMS_CATALOG } from "./constants";
|
|
10
10
|
var options = {
|
|
11
11
|
unit: 'in',
|
|
12
12
|
enable3D: true
|
|
@@ -24,23 +24,31 @@ export default function WorkSpaceHostMimic() {
|
|
|
24
24
|
inFlight = _useState2[0],
|
|
25
25
|
setInFlight = _useState2[1];
|
|
26
26
|
var rafRef = useRef(0);
|
|
27
|
-
var onInternalEvent =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
var onInternalEvent = /*#__PURE__*/function () {
|
|
28
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(evt, callback) {
|
|
29
|
+
var _t;
|
|
30
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
31
|
+
while (1) switch (_context.prev = _context.next) {
|
|
32
|
+
case 0:
|
|
33
|
+
console.log('EVENT:', evt.type, evt.value);
|
|
34
|
+
_t = evt.type;
|
|
35
|
+
_context.next = _t === INTERNAL_EVENT_ITEMS_CATALOG ? 1 : 3;
|
|
36
|
+
break;
|
|
37
|
+
case 1:
|
|
38
|
+
_context.next = 2;
|
|
39
|
+
return callback(projectItemsCatalog);
|
|
40
|
+
case 2:
|
|
41
|
+
return _context.abrupt("continue", 3);
|
|
42
|
+
case 3:
|
|
43
|
+
case "end":
|
|
44
|
+
return _context.stop();
|
|
45
|
+
}
|
|
46
|
+
}, _callee);
|
|
47
|
+
}));
|
|
48
|
+
return function onInternalEvent(_x, _x2) {
|
|
49
|
+
return _ref.apply(this, arguments);
|
|
50
|
+
};
|
|
51
|
+
}();
|
|
44
52
|
useEffect(function () {
|
|
45
53
|
if (!mountRef.current) return;
|
|
46
54
|
if (apiRef.current) return;
|
|
@@ -61,44 +69,46 @@ export default function WorkSpaceHostMimic() {
|
|
|
61
69
|
var unsub = typeof api.subscribeGltfInFlight === 'function' ? api.subscribeGltfInFlight(function (count) {
|
|
62
70
|
return setInFlight(count);
|
|
63
71
|
}) : null;
|
|
64
|
-
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
72
|
+
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
65
73
|
var ok;
|
|
66
|
-
return _regeneratorRuntime.wrap(function (
|
|
67
|
-
while (1) switch (
|
|
74
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
75
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
68
76
|
case 0:
|
|
69
77
|
if (!sentOnceRef.current) {
|
|
70
|
-
|
|
78
|
+
_context2.next = 1;
|
|
71
79
|
break;
|
|
72
80
|
}
|
|
73
|
-
return
|
|
81
|
+
return _context2.abrupt("return");
|
|
74
82
|
case 1:
|
|
75
83
|
sentOnceRef.current = true;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
|
|
85
|
+
// await api.whenReady();
|
|
86
|
+
|
|
87
|
+
// ✅ send center with EMPTY payload
|
|
88
|
+
_context2.next = 2;
|
|
80
89
|
return api.sendExternalEvents([{
|
|
81
|
-
type:
|
|
82
|
-
|
|
90
|
+
type: EXTERNAL_EVENT_LOAD_PROJECT,
|
|
91
|
+
// send request for sync scene data to 3DTool
|
|
92
|
+
payload: JSON.parse(mockProps.projectElement[0].project_data),
|
|
83
93
|
framesPerEvent: 2,
|
|
84
94
|
waitForGltfIdleAfterEachEvent: false
|
|
85
95
|
}], {
|
|
86
96
|
timeoutMs: 15000
|
|
87
97
|
});
|
|
88
|
-
case
|
|
89
|
-
ok =
|
|
98
|
+
case 2:
|
|
99
|
+
ok = _context2.sent;
|
|
90
100
|
if (!ok) console.warn('Centering timed out (fail-open).');
|
|
91
|
-
case
|
|
101
|
+
case 3:
|
|
92
102
|
case "end":
|
|
93
|
-
return
|
|
103
|
+
return _context2.stop();
|
|
94
104
|
}
|
|
95
|
-
},
|
|
105
|
+
}, _callee2);
|
|
96
106
|
}))();
|
|
97
107
|
return function () {
|
|
98
108
|
var _apiRef$current, _apiRef$current$unmou;
|
|
99
109
|
try {
|
|
100
110
|
unsub === null || unsub === void 0 || unsub();
|
|
101
|
-
} catch (
|
|
111
|
+
} catch (_unused) {}
|
|
102
112
|
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 || (_apiRef$current$unmou = _apiRef$current.unmount) === null || _apiRef$current$unmou === void 0 || _apiRef$current$unmou.call(_apiRef$current);
|
|
103
113
|
apiRef.current = null;
|
|
104
114
|
sentOnceRef.current = false;
|
package/es/class/project.js
CHANGED
|
@@ -146,19 +146,7 @@ var Project = /*#__PURE__*/function () {
|
|
|
146
146
|
if (w != 0 && Math.abs(w) != Infinity && h != 0 && Math.abs(h) != Infinity) {
|
|
147
147
|
a = viewer.viewerHeight < h ? viewer.viewerHeight / h : (viewer.viewerHeight / h * 3 / 5 - 0.5) / constants.ZOOM_VARIABLE > 400 ? viewer.viewerHeight / h * 400 / ((viewer.viewerHeight / h - 0.5) / constants.ZOOM_VARIABLE) : viewer.viewerHeight / h * 3 / 5;
|
|
148
148
|
e = (viewer.viewerWidth - (bb.maxX + bb.minX) * a) / 2;
|
|
149
|
-
f = (viewer.viewerHeight - (
|
|
150
|
-
while (!(e <= 10)) {
|
|
151
|
-
e -= 0.1;
|
|
152
|
-
}
|
|
153
|
-
while (!(e + a * viewer.SVGWidth + 10 >= viewer.viewerWidth)) {
|
|
154
|
-
e += 0.1;
|
|
155
|
-
}
|
|
156
|
-
while (!(f <= 80)) {
|
|
157
|
-
f -= 0.1;
|
|
158
|
-
}
|
|
159
|
-
while (!(f + a * viewer.SVGHeight + 10 >= viewer.viewerHeight)) {
|
|
160
|
-
f += 0.1;
|
|
161
|
-
}
|
|
149
|
+
f = (viewer.viewerHeight - (bb.maxY + bb.minY) * a) / 2;
|
|
162
150
|
_viewer2D = _viewer2D.merge({
|
|
163
151
|
a: a,
|
|
164
152
|
d: a,
|
|
@@ -180,7 +168,6 @@ var Project = /*#__PURE__*/function () {
|
|
|
180
168
|
state = Item.setCounterTop(state, counterTop).updatedState;
|
|
181
169
|
state = Area.setFloorStyles(state, floorStyle).updatedState;
|
|
182
170
|
this.updateZoomScale(state, a);
|
|
183
|
-
viewer2DActions.updateCameraView(_viewer2D);
|
|
184
171
|
return {
|
|
185
172
|
updatedState: state
|
|
186
173
|
};
|
package/es/utils/helper.js
CHANGED
|
@@ -341,12 +341,29 @@ export var updateViwer2D = function updateViwer2D(value) {
|
|
|
341
341
|
var _zoomValue = parseInt((value.a - 0.5) / ZOOM_VARIABLE);
|
|
342
342
|
if (_zoomValue > MAX_ZOOM_IN_SCALE) return;
|
|
343
343
|
if (_zoomValue < 0 || Number.isNaN(_zoomValue)) return;
|
|
344
|
-
var
|
|
345
|
-
var
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
344
|
+
var scaledWidth = value.a * value.SVGWidth;
|
|
345
|
+
var scaledHeight = value.a * value.SVGHeight;
|
|
346
|
+
|
|
347
|
+
/* ---------- Horizontal ---------- */
|
|
348
|
+
if (scaledWidth <= value.viewerWidth) {
|
|
349
|
+
// scene smaller than viewport → force center
|
|
350
|
+
value.e = (value.viewerWidth - scaledWidth) / 2;
|
|
351
|
+
} else {
|
|
352
|
+
// scene larger → clamp normally
|
|
353
|
+
var maxE = 10;
|
|
354
|
+
var minE = value.viewerWidth - (scaledWidth + 10);
|
|
355
|
+
value.e = Math.min(maxE, Math.max(minE, value.e));
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/* ---------- Vertical ---------- */
|
|
359
|
+
if (scaledHeight <= value.viewerHeight) {
|
|
360
|
+
// scene smaller than viewport → force center
|
|
361
|
+
value.f = (value.viewerHeight - scaledHeight) / 2;
|
|
362
|
+
} else {
|
|
363
|
+
var maxF = 80;
|
|
364
|
+
var minF = value.viewerHeight - (scaledHeight + 10);
|
|
365
|
+
value.f = Math.min(maxF, Math.max(minF, value.f));
|
|
366
|
+
}
|
|
350
367
|
if (viewer2DActions && compareSVGRect(value)) viewer2DActions.updateCameraView(value);
|
|
351
368
|
};
|
|
352
369
|
export function centering2D(state) {
|
|
@@ -902,8 +902,8 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, ca
|
|
|
902
902
|
var xp = (lengthValue + halfWidthLength) * Math.cos(alpha) + x0;
|
|
903
903
|
var yp = (lengthValue + halfWidthLength) * Math.sin(alpha) + y0;
|
|
904
904
|
var offset = GeometryUtils.pointPositionOnLineSegment(x0, y0, x1, y1, xp, yp);
|
|
905
|
-
/*
|
|
906
|
-
if (x0 > x1) offset = 1 - offset;
|
|
905
|
+
/*
|
|
906
|
+
if (x0 > x1) offset = 1 - offset;
|
|
907
907
|
*/
|
|
908
908
|
var endAt = MathUtils.toFixedFloat(lineLength - lineLength * offset - halfWidthLength, PRECISION);
|
|
909
909
|
var offsetUnit = attributesFormData.getIn(['offsetB', '_unit']);
|
|
@@ -940,8 +940,8 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, ca
|
|
|
940
940
|
var _xp = _x0 - (_lengthValue + _halfWidthLength) * Math.cos(_alpha);
|
|
941
941
|
var _yp = _y2 - (_lengthValue + _halfWidthLength) * Math.sin(_alpha);
|
|
942
942
|
var _offset = GeometryUtils.pointPositionOnLineSegment(_x9, _y, _x0, _y2, _xp, _yp);
|
|
943
|
-
/*
|
|
944
|
-
if (x0 > x1) offset = 1 - offset;
|
|
943
|
+
/*
|
|
944
|
+
if (x0 > x1) offset = 1 - offset;
|
|
945
945
|
*/
|
|
946
946
|
var startAt = MathUtils.toFixedFloat(_lineLength * _offset - _halfWidthLength, PRECISION);
|
|
947
947
|
var _offsetUnit = attributesFormData.getIn(['offsetA', '_unit']);
|