kitchen-simulator 3.0.3 → 3.1.0-alpha.13
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 +52 -29
- package/es/LiteRenderer.js +5 -8
- package/es/actions/lines-actions.js +3 -1
- package/es/assets/img/png/helper/video_preview_start.png +0 -0
- package/es/catalog/factories/area-factory-3d.js +17 -17
- package/es/catalog/holes/window-clear/planner-element.js +2 -2
- package/es/catalog/utils/item-loader.js +198 -197
- package/es/class/item.js +8 -0
- package/es/class/line.js +14 -2
- package/es/components/viewer2d/item.js +36 -12
- package/es/components/viewer2d/utils.js +2 -2
- package/es/components/viewer2d/viewer2d.js +12 -10
- package/es/components/viewer3d/viewer3d.js +66 -74
- package/es/constants.js +6 -2
- package/es/devLiteRenderer.js +192 -98
- package/es/index.js +104 -14
- package/es/reducers/lines-reducer.js +1 -1
- package/es/utils/geometry.js +161 -0
- package/es/utils/isolate-event-handler.js +268 -114
- package/es/utils/molding.js +234 -2
- package/lib/LiteKitchenConfigurator.js +52 -29
- package/lib/LiteRenderer.js +5 -8
- package/lib/actions/lines-actions.js +3 -1
- package/lib/assets/img/png/helper/video_preview_start.png +0 -0
- package/lib/catalog/factories/area-factory-3d.js +14 -14
- package/lib/catalog/holes/window-clear/planner-element.js +2 -2
- package/lib/catalog/utils/item-loader.js +195 -194
- package/lib/class/item.js +8 -0
- package/lib/class/line.js +13 -1
- package/lib/components/viewer2d/item.js +36 -12
- package/lib/components/viewer2d/utils.js +2 -2
- package/lib/components/viewer2d/viewer2d.js +12 -10
- package/lib/components/viewer3d/viewer3d.js +66 -74
- package/lib/constants.js +11 -7
- package/lib/devLiteRenderer.js +186 -92
- package/lib/index.js +104 -14
- package/lib/reducers/lines-reducer.js +1 -1
- package/lib/utils/geometry.js +162 -0
- package/lib/utils/isolate-event-handler.js +267 -113
- package/lib/utils/molding.js +233 -0
- package/package.json +1 -1
package/es/utils/geometry.js
CHANGED
|
@@ -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
|
}
|