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.
Files changed (41) hide show
  1. package/es/LiteKitchenConfigurator.js +52 -29
  2. package/es/LiteRenderer.js +5 -8
  3. package/es/actions/lines-actions.js +3 -1
  4. package/es/assets/img/png/helper/video_preview_start.png +0 -0
  5. package/es/catalog/factories/area-factory-3d.js +17 -17
  6. package/es/catalog/holes/window-clear/planner-element.js +2 -2
  7. package/es/catalog/utils/item-loader.js +198 -197
  8. package/es/class/item.js +8 -0
  9. package/es/class/line.js +14 -2
  10. package/es/components/viewer2d/item.js +36 -12
  11. package/es/components/viewer2d/utils.js +2 -2
  12. package/es/components/viewer2d/viewer2d.js +12 -10
  13. package/es/components/viewer3d/viewer3d.js +66 -74
  14. package/es/constants.js +6 -2
  15. package/es/devLiteRenderer.js +192 -98
  16. package/es/index.js +104 -14
  17. package/es/reducers/lines-reducer.js +1 -1
  18. package/es/utils/geometry.js +161 -0
  19. package/es/utils/isolate-event-handler.js +268 -114
  20. package/es/utils/molding.js +234 -2
  21. package/lib/LiteKitchenConfigurator.js +52 -29
  22. package/lib/LiteRenderer.js +5 -8
  23. package/lib/actions/lines-actions.js +3 -1
  24. package/lib/assets/img/png/helper/video_preview_start.png +0 -0
  25. package/lib/catalog/factories/area-factory-3d.js +14 -14
  26. package/lib/catalog/holes/window-clear/planner-element.js +2 -2
  27. package/lib/catalog/utils/item-loader.js +195 -194
  28. package/lib/class/item.js +8 -0
  29. package/lib/class/line.js +13 -1
  30. package/lib/components/viewer2d/item.js +36 -12
  31. package/lib/components/viewer2d/utils.js +2 -2
  32. package/lib/components/viewer2d/viewer2d.js +12 -10
  33. package/lib/components/viewer3d/viewer3d.js +66 -74
  34. package/lib/constants.js +11 -7
  35. package/lib/devLiteRenderer.js +186 -92
  36. package/lib/index.js +104 -14
  37. package/lib/reducers/lines-reducer.js +1 -1
  38. package/lib/utils/geometry.js +162 -0
  39. package/lib/utils/isolate-event-handler.js +267 -113
  40. package/lib/utils/molding.js +233 -0
  41. package/package.json +1 -1
@@ -14,6 +14,7 @@ exports.angleBetweenTwoPoints = angleBetweenTwoPoints;
14
14
  exports.angleBetweenTwoPointsAndOrigin = angleBetweenTwoPointsAndOrigin;
15
15
  exports.buildRectFromLines = buildRectFromLines;
16
16
  exports.calcCreateSnap = calcCreateSnap;
17
+ exports.calcDistancesFromItemToWalls = calcDistancesFromItemToWalls;
17
18
  exports.calcSnap = calcSnap;
18
19
  exports.calcSnap1 = calcSnap1;
19
20
  exports.calcSnap2 = calcSnap2;
@@ -2542,4 +2543,165 @@ function validRect(itemRect, rects) {
2542
2543
  return rects.every(function (rect) {
2543
2544
  return !intersectRect(rect.rect, updatedItemRect.rect);
2544
2545
  });
2546
+ }
2547
+ function getCalcRectFromItem2(itemInfo) {
2548
+ var x = itemInfo.pos.x;
2549
+ var y = itemInfo.pos.y;
2550
+ var w = itemInfo.size.width / 2;
2551
+ var h = itemInfo.size.height / 2;
2552
+ var rotRad = itemInfo.rotRad;
2553
+ var mh = 3 * h / 4;
2554
+ var mx = x - w * Math.cos(rotRad) - mh * Math.sin(rotRad);
2555
+ var my = y - w * Math.sin(rotRad) + mh * Math.cos(rotRad);
2556
+ var m2x = x + w * Math.cos(rotRad) - mh * Math.sin(rotRad);
2557
+ var m2y = y + w * Math.sin(rotRad) + mh * Math.cos(rotRad);
2558
+ var m3x = x - h * Math.sin(rotRad);
2559
+ var m3y = y + h * Math.cos(rotRad);
2560
+ var m1x = x + h * Math.sin(rotRad);
2561
+ var m1y = y - h * Math.cos(rotRad);
2562
+ return {
2563
+ rectCenterPoint: [[point(mx, my), 180], [point(m1x, m1y), -90], [point(m2x, m2y), 0], [point(m3x, m3y), 90]]
2564
+ };
2565
+ }
2566
+ function getAllItems2(curItem, layer) {
2567
+ var rectarray = [];
2568
+ var tempHeight = curItem.get('properties').get('depth');
2569
+ layer.items.forEach(function (item) {
2570
+ var val = {
2571
+ pos: {
2572
+ x: item.x,
2573
+ y: item.y
2574
+ },
2575
+ rotRad: item.rotation / 180 * Math.PI
2576
+ };
2577
+ var width = (0, _convertUnitsLite.convert)(item.properties.getIn(['width', '_length'])).from('in').to('cm');
2578
+ var height = (0, _convertUnitsLite.convert)(item.properties.getIn(['depth', '_length'])).from('in').to('cm');
2579
+ val.size = {
2580
+ width: width,
2581
+ height: height
2582
+ };
2583
+ if (curItem.get('id') !== item.id) {
2584
+ 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']);
2585
+ if (detectObjectsAtSameAltitudeFlag) {
2586
+ var x = val.pos.x;
2587
+ var y = val.pos.y;
2588
+ var rotRad = val.rotRad;
2589
+ var w = val.size.width / 2;
2590
+ var h = val.size.height / 2;
2591
+ var mx = x - w * Math.cos(rotRad);
2592
+ var my = y - w * Math.sin(rotRad);
2593
+ var x0 = mx + h * Math.sin(rotRad);
2594
+ var y0 = my - h * Math.cos(rotRad);
2595
+ var x3 = mx * 2 - x0;
2596
+ var y3 = my * 2 - y0;
2597
+ var x1 = x * 2 - x3;
2598
+ var y1 = y * 2 - y3;
2599
+ var x2 = x * 2 - x0;
2600
+ var y2 = y * 2 - y0;
2601
+ rectarray.push({
2602
+ rect: [point(x0, y0), point(x1, y1), point(x0, y0), point(x1, y1)]
2603
+ });
2604
+ rectarray.push({
2605
+ rect: [point(x1, y1), point(x2, y2), point(x1, y1), point(x2, y2)]
2606
+ });
2607
+ rectarray.push({
2608
+ rect: [point(x2, y2), point(x3, y3), point(x2, y2), point(x3, y3)]
2609
+ });
2610
+ rectarray.push({
2611
+ rect: [point(x3, y3), point(x0, y0), point(x3, y3), point(x0, y0)]
2612
+ });
2613
+ }
2614
+ }
2615
+ });
2616
+ return {
2617
+ others: rectarray
2618
+ };
2619
+ }
2620
+ function calcDistancesFromItemToWalls(curItem, layer) {
2621
+ if ((0, _helper.isEmpty)(curItem)) return [];
2622
+ var x = curItem.get('x');
2623
+ var y = curItem.get('y');
2624
+ var rotRad = curItem.get('rotation') / 180 * Math.PI;
2625
+ var width, height;
2626
+ if (curItem.get('properties').get('width') || curItem.get('properties').get('depth')) {
2627
+ width = (0, _convertUnitsLite.convert)(curItem.get('properties').get('width').get('_length')).from(curItem.get('properties').get('width').get('_unit')).to('cm');
2628
+ height = (0, _convertUnitsLite.convert)(curItem.get('properties').get('depth').get('_length')).from(curItem.get('properties').get('depth').get('_unit')).to('cm');
2629
+ } else {
2630
+ width = (0, _convertUnitsLite.convert)(curItem.info.sizeinfo.width).from('in').to('cm');
2631
+ height = (0, _convertUnitsLite.convert)(curItem.info.sizeinfo.depth).from('in').to('cm');
2632
+ }
2633
+ var center_h = 3 * height / 8;
2634
+ var center_x = x; // middle of front line of cabinet rect
2635
+ var center_y = y;
2636
+ var center_x1 = x - center_h * Math.sin(rotRad); // center point of cabinet rect
2637
+ var center_y1 = y + center_h * Math.cos(rotRad);
2638
+ var PointArray = [];
2639
+ var itemInfo = {
2640
+ pos: {
2641
+ x: x,
2642
+ y: y
2643
+ },
2644
+ rotRad: rotRad
2645
+ };
2646
+ itemInfo.size = {
2647
+ width: width,
2648
+ height: height
2649
+ };
2650
+ var curiteminfo = getCalcRectFromItem2(itemInfo);
2651
+ var allItemRect = getAllItems2(curItem, layer);
2652
+ var allLines = getAllLines(layer);
2653
+ var allLineRects = buildRectFromLines(layer, allLines);
2654
+ var allRect = allLineRects.concat(allItemRect.others);
2655
+ var _loop = function _loop(i) {
2656
+ // [rectCenterPoint] has four middle points of cabinet rect edges
2657
+ var centerpoint = curiteminfo.rectCenterPoint[i];
2658
+ var comparelength = []; // distance array from rectCenterPoint[i] to other lines(walls, other cabinet rect edges)
2659
+ var a;
2660
+ var RectLineFuction; // normal line of cabinet rect edge
2661
+ 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);
2662
+ allRect.forEach(function (linerect) {
2663
+ // calc distance to all other lines
2664
+ var p0 = clone_point(linerect.rect[2]);
2665
+ var p1 = clone_point(linerect.rect[3]);
2666
+ var lineFunction = {}; // other line function
2667
+ if (p0.x !== p1.x || p0.y !== p1.y) lineFunction = linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
2668
+ // intersection between normal line and other line
2669
+ var coordinatePoint = twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
2670
+ if (coordinatePoint !== undefined) {
2671
+ if (
2672
+ // intersection point is on the other line
2673
+ 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)) {
2674
+ // check the intersection point is outside direction of edge
2675
+ var isOutside = true;
2676
+ for (var j = 0; j < curiteminfo.rectCenterPoint.length; j++) {
2677
+ if (j === i) continue;
2678
+ var otherCenterPoint = curiteminfo.rectCenterPoint[j];
2679
+ if (isPointOnLineSegment(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y, otherCenterPoint[0].x, otherCenterPoint[0].y)) isOutside = false;
2680
+ }
2681
+ if (isOutside && pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
2682
+ comparelength.push(pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
2683
+ a = Math.min.apply(null, comparelength);
2684
+ }
2685
+ }
2686
+ }
2687
+ });
2688
+ PointArray.push([a, centerpoint[1]]);
2689
+ };
2690
+ for (var i = 0; i < curiteminfo.rectCenterPoint.length; i++) {
2691
+ _loop(i);
2692
+ }
2693
+ PointArray.forEach(function (pointElement, index) {
2694
+ if (pointElement[0] == undefined) PointArray[index][0] = 0;
2695
+ });
2696
+ var cnt = 0;
2697
+ PointArray.forEach(function (pointElement) {
2698
+ if (pointElement[0] == 0) cnt++;
2699
+ });
2700
+ if (cnt == 4 || cnt == 3) {
2701
+ PointArray[0][0] = 100;
2702
+ PointArray[1][0] = 100;
2703
+ }
2704
+ return {
2705
+ PointArray: PointArray
2706
+ };
2545
2707
  }