@threekit-tools/treble 0.0.94-next-02 → 0.0.95-next-01
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.
|
@@ -264,6 +264,10 @@ function prepLengthForUser(value, unit) {
|
|
|
264
264
|
if (unit === types_1.IUnits.FEET) {
|
|
265
265
|
var feet = Math.floor(value);
|
|
266
266
|
var inches = 12 * (value % 1);
|
|
267
|
+
if (inches > 11.95) {
|
|
268
|
+
feet += 1;
|
|
269
|
+
inches = 0;
|
|
270
|
+
}
|
|
267
271
|
return "".concat(feet).concat(constants_1.UNIT_LABELS[types_1.IUnits.FEET], " ").concat(inches.toFixed(1)).concat(constants_1.UNIT_LABELS[types_1.IUnits.INCH]);
|
|
268
272
|
}
|
|
269
273
|
return "".concat(value.toFixed(2), " ").concat(constants_1.UNIT_LABELS[unit]);
|
|
@@ -60,6 +60,14 @@ var SpacesLayout_1 = __importDefault(require("./SpacesLayout"));
|
|
|
60
60
|
var store_1 = require("../../store");
|
|
61
61
|
var spaces_1 = require("../../store/spaces");
|
|
62
62
|
var useThreekitInitStatus_1 = __importDefault(require("../useThreekitInitStatus"));
|
|
63
|
+
var getLocalTouchPoint = function (touch, rect) {
|
|
64
|
+
if (touch.clientY < rect.top ||
|
|
65
|
+
rect.bottom < touch.clientY ||
|
|
66
|
+
touch.clientX < rect.left ||
|
|
67
|
+
rect.right < touch.clientX)
|
|
68
|
+
return undefined;
|
|
69
|
+
return [touch.clientX - rect.left, touch.clientY - rect.top];
|
|
70
|
+
};
|
|
63
71
|
var useSpaces = function (props) {
|
|
64
72
|
var _a, _b, _c, _d, _e;
|
|
65
73
|
var attributesState = (0, useConfigurator_1.default)()[0];
|
|
@@ -171,14 +179,22 @@ var useSpaces = function (props) {
|
|
|
171
179
|
return;
|
|
172
180
|
if (canvasRef.current) {
|
|
173
181
|
canvasRef.current.addEventListener('mousedown', handleDrawWallStart);
|
|
182
|
+
canvasRef.current.addEventListener('touchstart', handleDrawWallStart);
|
|
174
183
|
canvasRef.current.addEventListener('mousemove', handleDrawWallMouseMove);
|
|
184
|
+
canvasRef.current.addEventListener('touchmove', handleDrawWallMouseMove);
|
|
175
185
|
document.addEventListener('mouseup', handleDrawWallFinish);
|
|
186
|
+
document.addEventListener('touchend', handleDrawWallFinish);
|
|
176
187
|
canvasRef.current.addEventListener('mousemove', handleHover);
|
|
177
188
|
canvasRef.current.addEventListener('mousedown', handleSelectElement);
|
|
189
|
+
canvasRef.current.addEventListener('touchstart', handleSelectElement);
|
|
178
190
|
canvasRef.current.addEventListener('mousemove', handleMoveSelectedElement);
|
|
179
|
-
|
|
191
|
+
canvasRef.current.addEventListener('touchmove', handleMoveSelectedElement);
|
|
192
|
+
if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled)) {
|
|
180
193
|
canvasRef.current.addEventListener('mousemove', handleMoveCanvas);
|
|
194
|
+
canvasRef.current.addEventListener('touchmove', handleMoveCanvas);
|
|
195
|
+
}
|
|
181
196
|
document.addEventListener('mouseup', handleFinishMove);
|
|
197
|
+
document.addEventListener('touchend', handleFinishMove);
|
|
182
198
|
if (!((_b = props.config) === null || _b === void 0 ? void 0 : _b.zoomDisabled))
|
|
183
199
|
canvasRef.current.addEventListener('wheel', handleScrollToZoom);
|
|
184
200
|
}
|
|
@@ -186,14 +202,22 @@ var useSpaces = function (props) {
|
|
|
186
202
|
var _a, _b;
|
|
187
203
|
if (canvasRef.current) {
|
|
188
204
|
canvasRef.current.removeEventListener('mousedown', handleDrawWallStart);
|
|
205
|
+
canvasRef.current.removeEventListener('touchstart', handleDrawWallStart);
|
|
189
206
|
canvasRef.current.removeEventListener('mousemove', handleDrawWallMouseMove);
|
|
207
|
+
canvasRef.current.removeEventListener('touchmove', handleDrawWallMouseMove);
|
|
190
208
|
document.removeEventListener('mouseup', handleDrawWallFinish);
|
|
209
|
+
document.removeEventListener('touchend', handleDrawWallFinish);
|
|
191
210
|
canvasRef.current.removeEventListener('mousemove', handleHover);
|
|
192
211
|
canvasRef.current.removeEventListener('mousedown', handleSelectElement);
|
|
212
|
+
canvasRef.current.removeEventListener('touchstart', handleSelectElement);
|
|
193
213
|
canvasRef.current.removeEventListener('mousemove', handleMoveSelectedElement);
|
|
194
|
-
|
|
214
|
+
canvasRef.current.removeEventListener('touchmove', handleMoveSelectedElement);
|
|
215
|
+
if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled)) {
|
|
195
216
|
canvasRef.current.removeEventListener('mousemove', handleMoveCanvas);
|
|
217
|
+
canvasRef.current.removeEventListener('touchmove', handleMoveCanvas);
|
|
218
|
+
}
|
|
196
219
|
document.removeEventListener('mouseup', handleFinishMove);
|
|
220
|
+
document.removeEventListener('touchend', handleFinishMove);
|
|
197
221
|
if (!((_b = props.config) === null || _b === void 0 ? void 0 : _b.zoomDisabled))
|
|
198
222
|
canvasRef.current.removeEventListener('wheel', handleScrollToZoom);
|
|
199
223
|
}
|
|
@@ -243,7 +267,15 @@ var useSpaces = function (props) {
|
|
|
243
267
|
return;
|
|
244
268
|
if (modeValue !== types_2.IModes.SELECT)
|
|
245
269
|
return;
|
|
246
|
-
var cursorPoint
|
|
270
|
+
var cursorPoint;
|
|
271
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
272
|
+
cursorPoint = [e.offsetX, e.offsetY];
|
|
273
|
+
else {
|
|
274
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
275
|
+
if (!localTouchPoint)
|
|
276
|
+
return;
|
|
277
|
+
cursorPoint = localTouchPoint;
|
|
278
|
+
}
|
|
247
279
|
spacesRef.current.selectElementIfInProximity(canvasRef.current, cursorPoint);
|
|
248
280
|
var element = spacesRef.current.getElementUiAtPoint(cursorPoint);
|
|
249
281
|
if (!element) {
|
|
@@ -266,7 +298,15 @@ var useSpaces = function (props) {
|
|
|
266
298
|
return;
|
|
267
299
|
if (!canvasRef.current)
|
|
268
300
|
return;
|
|
269
|
-
var point
|
|
301
|
+
var point;
|
|
302
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
303
|
+
point = [e.offsetX, e.offsetY];
|
|
304
|
+
else {
|
|
305
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
306
|
+
if (!localTouchPoint)
|
|
307
|
+
return;
|
|
308
|
+
point = localTouchPoint;
|
|
309
|
+
}
|
|
270
310
|
spacesRef.current.moveActiveElement(canvasRef.current, point);
|
|
271
311
|
selectElementPending.current = null;
|
|
272
312
|
};
|
|
@@ -279,15 +319,24 @@ var useSpaces = function (props) {
|
|
|
279
319
|
return;
|
|
280
320
|
if (spacesRef.current.selectedElement || !translationAnchorRef.current)
|
|
281
321
|
return;
|
|
322
|
+
var point;
|
|
323
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
324
|
+
point = [e.offsetX, e.offsetY];
|
|
325
|
+
else {
|
|
326
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
327
|
+
if (!localTouchPoint)
|
|
328
|
+
return;
|
|
329
|
+
point = localTouchPoint;
|
|
330
|
+
}
|
|
282
331
|
spacesRef.current.translate = [
|
|
283
332
|
spacesRef.current.translate[0] +
|
|
284
|
-
|
|
333
|
+
point[0] -
|
|
285
334
|
translationAnchorRef.current[0],
|
|
286
335
|
spacesRef.current.translate[1] +
|
|
287
|
-
|
|
336
|
+
point[1] -
|
|
288
337
|
translationAnchorRef.current[1],
|
|
289
338
|
];
|
|
290
|
-
translationAnchorRef.current =
|
|
339
|
+
translationAnchorRef.current = point;
|
|
291
340
|
drawSpaces();
|
|
292
341
|
};
|
|
293
342
|
var handleFinishMove = function (e) {
|
|
@@ -321,19 +370,38 @@ var useSpaces = function (props) {
|
|
|
321
370
|
spacesRef.current.showGuideAtPoint(canvas, cursorPoint);
|
|
322
371
|
};
|
|
323
372
|
var handleDrawWallStart = function (e) {
|
|
324
|
-
if (!spacesRef.current)
|
|
373
|
+
if (!spacesRef.current || !canvasRef.current)
|
|
325
374
|
return;
|
|
326
375
|
if (modeValue !== types_2.IModes.DRAW)
|
|
327
376
|
return;
|
|
328
|
-
|
|
377
|
+
var startPoint;
|
|
378
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
379
|
+
startPoint = [e.offsetX, e.offsetY];
|
|
380
|
+
else {
|
|
381
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
382
|
+
if (!localTouchPoint)
|
|
383
|
+
return;
|
|
384
|
+
startPoint = localTouchPoint;
|
|
385
|
+
}
|
|
386
|
+
spacesRef.current.startDrawNewWall(startPoint);
|
|
329
387
|
};
|
|
330
388
|
var handleDrawWallMouseMove = function (e) {
|
|
331
389
|
if (!spacesRef.current || !canvasRef.current)
|
|
332
390
|
return;
|
|
333
391
|
if (modeValue !== types_2.IModes.DRAW)
|
|
334
392
|
return;
|
|
335
|
-
if (spacesRef.current.isDrawWallActive)
|
|
336
|
-
|
|
393
|
+
if (!spacesRef.current.isDrawWallActive)
|
|
394
|
+
return;
|
|
395
|
+
var point;
|
|
396
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
397
|
+
point = [e.offsetX, e.offsetY];
|
|
398
|
+
else {
|
|
399
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
400
|
+
if (!localTouchPoint)
|
|
401
|
+
return;
|
|
402
|
+
point = localTouchPoint;
|
|
403
|
+
}
|
|
404
|
+
spacesRef.current.drawNewWall(canvasRef.current, point);
|
|
337
405
|
};
|
|
338
406
|
var handleDrawWallFinish = function (e) {
|
|
339
407
|
var _a;
|