kitchen-simulator 3.12.0 → 3.14.0

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.
@@ -5,7 +5,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
6
6
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
7
7
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
8
- import { BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, EPSILON, MIDDLE_MOLDING_LOCATION, MOLDING_LOCATIONS, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_SAME, OVERLAP_SOME, TALL_CABINET_LAYOUTPOS, TOE_KICK_MOLDING, TOP_MOLDING_LOCATION, WALL_CABINET_LAYOUTPOS } from "../constants";
8
+ import { BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, EPSILON, ITEM_TYPE, MIDDLE_MOLDING_LOCATION, MOLDING_LOCATIONS, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_SAME, OVERLAP_SOME, TALL_CABINET_LAYOUTPOS, TOE_KICK_MOLDING, TOP_MOLDING_LOCATION, WALL_CABINET_LAYOUTPOS } from "../constants";
9
9
  import * as Three from 'three';
10
10
  import { convert } from "./convert-units-lite";
11
11
  import IDBroker from "./id-broker";
@@ -304,6 +304,74 @@ export function getLinesOfItem(item, allLineRects, catalog) {
304
304
  }
305
305
  return lines;
306
306
  }
307
+ export function getLinesOfItem2(item, allLineRects, catalog) {
308
+ var lines = [];
309
+ var outline = null;
310
+ var element = catalog.elements[item.get('type')];
311
+ if (!element) element = catalog.elements[returnReplaceableDeepSearchType(item.get('type'))];
312
+ // get edge lines
313
+ var newWidth = item.properties.get('width').get('_length');
314
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
315
+ newWidth = convert(newWidth).from(wUnit).to('cm');
316
+ var newDepth = item.properties.get('depth').get('_length');
317
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
318
+ newDepth = convert(newDepth).from(hUnit).to('cm');
319
+ if (item) {
320
+ // Get Outline Data of Selected Item
321
+ outline = element.info.outline;
322
+ if (outline) {
323
+ // Extract Points from `outline`
324
+ var outlinePaths = outline.paths;
325
+ var outlineWidth = outline.svgWidth;
326
+ var outlineHeight = outline.svgHeight;
327
+ var outlinePoints = []; // Hold Points Of SVG
328
+ var _iterator3 = _createForOfIteratorHelper(outlinePaths),
329
+ _step3;
330
+ try {
331
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
332
+ var path = _step3.value;
333
+ var _iterator4 = _createForOfIteratorHelper(path.subPaths),
334
+ _step4;
335
+ try {
336
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
337
+ var subPath = _step4.value;
338
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
339
+ }
340
+ } catch (err) {
341
+ _iterator4.e(err);
342
+ } finally {
343
+ _iterator4.f();
344
+ }
345
+ }
346
+ } catch (err) {
347
+ _iterator3.e(err);
348
+ } finally {
349
+ _iterator3.f();
350
+ }
351
+ outline.reverse && outlinePoints.reverse();
352
+ for (var i = 0; i < outlinePoints.length - 1; i++) {
353
+ lines.push([GeometryUtils.rotatePointAroundPoint((outlinePoints[i].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90), GeometryUtils.rotatePointAroundPoint((outlinePoints[i + 1].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i + 1].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90), IDBroker.acquireID()]);
354
+ }
355
+ } else {
356
+ var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
357
+ for (var _i2 = 0; _i2 < 4; _i2++) {
358
+ lines.push([GeometryUtils.rotatePointAroundPoint(pos[_i2][0] * newWidth / 2 + item.x, pos[_i2][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), GeometryUtils.rotatePointAroundPoint(pos[(_i2 + 1) % 4][0] * newWidth / 2 + item.x, pos[(_i2 + 1) % 4][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), IDBroker.acquireID()]);
359
+ }
360
+ }
361
+ }
362
+ lines = lines.filter(function (line) {
363
+ return !GeometryUtils.isSnappedLine({
364
+ rect: [{
365
+ x: 0,
366
+ y: 0
367
+ }, {
368
+ x: 0,
369
+ y: 0
370
+ }, line[0], line[1]]
371
+ }, allLineRects);
372
+ });
373
+ return lines;
374
+ }
307
375
  function isParallelLines(line1, line2) {
308
376
  var isParallel = false;
309
377
  if (Math.abs(line1[0].y - line1[1].y) <= EPSILON && Math.abs(line2[0].y - line2[1].y) <= EPSILON) isParallel = true;
@@ -485,20 +553,20 @@ export function getLinesFromItems2(moldingGroup, layer, catalog) {
485
553
  // merge the collinear linked lines to one line
486
554
  var newMGlines = [];
487
555
  var filteredMGlines = MGlines;
488
- var _loop3 = function _loop3(_i2) {
556
+ var _loop3 = function _loop3(_i3) {
489
557
  if (filteredMGlines.length < 1) return 0; // break
490
558
  if (!filteredMGlines.some(function (v) {
491
- return v[2] === MGlines[_i2][2];
559
+ return v[2] === MGlines[_i3][2];
492
560
  })) return 1; // continue
493
- var mergedResult = getMergedLine(MGlines[_i2], filteredMGlines, 0);
561
+ var mergedResult = getMergedLine(MGlines[_i3], filteredMGlines, 0);
494
562
  if (mergedResult) {
495
563
  newMGlines.push(mergedResult.mergedLine);
496
564
  filteredMGlines = mergedResult.filteredMGlines;
497
565
  }
498
566
  },
499
567
  _ret;
500
- for (var _i2 = 0; _i2 < MGlines.length; _i2++) {
501
- _ret = _loop3(_i2);
568
+ for (var _i3 = 0; _i3 < MGlines.length; _i3++) {
569
+ _ret = _loop3(_i3);
502
570
  if (_ret === 0) break;
503
571
  if (_ret === 1) continue;
504
572
  }
@@ -587,11 +655,12 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
587
655
  };
588
656
  var bContourSeg = true;
589
657
  var _loop6 = function _loop6(j) {
658
+ var _otherLines$j$0$x, _otherLines$j$, _otherLines$j$line$, _otherLines$j$0$y, _otherLines$j$2, _otherLines$j$line$2, _otherLines$j$1$x, _otherLines$j$3, _otherLines$j$line$3, _otherLines$j$1$y, _otherLines$j$4, _otherLines$j$line$4;
590
659
  var destLine = {
591
- x1: otherLines[j][0].x,
592
- y1: otherLines[j][0].y,
593
- x2: otherLines[j][1].x,
594
- y2: otherLines[j][1].y
660
+ x1: (_otherLines$j$0$x = (_otherLines$j$ = otherLines[j][0]) === null || _otherLines$j$ === void 0 ? void 0 : _otherLines$j$.x) !== null && _otherLines$j$0$x !== void 0 ? _otherLines$j$0$x : (_otherLines$j$line$ = otherLines[j].line[0]) === null || _otherLines$j$line$ === void 0 ? void 0 : _otherLines$j$line$.x,
661
+ y1: (_otherLines$j$0$y = (_otherLines$j$2 = otherLines[j][0]) === null || _otherLines$j$2 === void 0 ? void 0 : _otherLines$j$2.y) !== null && _otherLines$j$0$y !== void 0 ? _otherLines$j$0$y : (_otherLines$j$line$2 = otherLines[j].line[0]) === null || _otherLines$j$line$2 === void 0 ? void 0 : _otherLines$j$line$2.y,
662
+ x2: (_otherLines$j$1$x = (_otherLines$j$3 = otherLines[j][1]) === null || _otherLines$j$3 === void 0 ? void 0 : _otherLines$j$3.x) !== null && _otherLines$j$1$x !== void 0 ? _otherLines$j$1$x : (_otherLines$j$line$3 = otherLines[j].line[1]) === null || _otherLines$j$line$3 === void 0 ? void 0 : _otherLines$j$line$3.x,
663
+ y2: (_otherLines$j$1$y = (_otherLines$j$4 = otherLines[j][1]) === null || _otherLines$j$4 === void 0 ? void 0 : _otherLines$j$4.y) !== null && _otherLines$j$1$y !== void 0 ? _otherLines$j$1$y : (_otherLines$j$line$4 = otherLines[j].line[1]) === null || _otherLines$j$line$4 === void 0 ? void 0 : _otherLines$j$line$4.y
595
664
  };
596
665
  var rst = GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
597
666
  if (rst.result == OVERLAP_SAME || rst.result == OVERLAP_INCLUDED) {
@@ -867,6 +936,151 @@ export function createMonldingGroup(oldMG, layer, molding, catalog) {
867
936
  newMG = getMDPoints(newMG);
868
937
  return newMG;
869
938
  }
939
+ export function getMoldingDataOfScene2(layer, catalog, doorStyle) {
940
+ var moldingData = [];
941
+ var items = layer.items.toArray();
942
+ var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
943
+
944
+ // get all molding line segments
945
+ var moldingLines = [];
946
+ items.forEach(function (item) {
947
+ if (item.category === ITEM_TYPE.CABINET) {
948
+ var _item$molding;
949
+ var MGlines = getLinesOfItem2(item, allLineRects, catalog); // exclude overlayed to wall
950
+ // z position of molding line
951
+ var z = item.properties.get('altitude').get('_length');
952
+ var zUnit = item.properties.get('altitude').get('_unit') || 'cm';
953
+ z = convert(z).from(zUnit).to('cm');
954
+ var h = item.properties.get('height').get('_length');
955
+ var hUnit = item.properties.get('height').get('_unit') || 'cm';
956
+ h = convert(h).from(hUnit).to('cm');
957
+ if (!isEmpty(item.molding) && isEnableItemForMolding(layer, item)) {
958
+ // calc normal molding line
959
+ item === null || item === void 0 || item.molding.forEach(function (molding) {
960
+ var lineZ = z;
961
+ switch (molding.location_type) {
962
+ case TOP_MOLDING_LOCATION:
963
+ lineZ = z + h;
964
+ break;
965
+ case MIDDLE_MOLDING_LOCATION:
966
+ lineZ = z + h / 2;
967
+ break;
968
+ }
969
+ MGlines === null || MGlines === void 0 || MGlines.forEach(function (line) {
970
+ return moldingLines.push({
971
+ molding: _objectSpread({}, molding),
972
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : !isEmpty(item.doorStyle) && item.doorStyle.toJS(),
973
+ line: line,
974
+ z: lineZ
975
+ });
976
+ });
977
+ });
978
+ } else if (
979
+ // calc toe kick molding line
980
+ item.layoutpos === BASE_CABINET_LAYOUTPOS && (isEmpty(item.molding) || ((_item$molding = item.molding) === null || _item$molding === void 0 ? void 0 : _item$molding.length) < 1 || !isEnableItemForMolding(layer, item))) {
981
+ var skuName = getToeKickSKU(item.doorStyle, catalog);
982
+ var thumbnail = skuName ? skuName : '';
983
+ MGlines === null || MGlines === void 0 || MGlines.forEach(function (line) {
984
+ return moldingLines.push({
985
+ molding: {
986
+ name: TOE_KICK_MOLDING,
987
+ sku: getToeKickSKU(item.doorStyle, catalog),
988
+ thumbnail: thumbnail,
989
+ category: 'molding',
990
+ type: 'cabinet'
991
+ },
992
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : !isEmpty(item.doorStyle) && item.doorStyle.toJS(),
993
+ line: line,
994
+ z: z
995
+ });
996
+ });
997
+ }
998
+ }
999
+ });
1000
+
1001
+ // filter the real molding line segments
1002
+ var removeLineIds = []; // remove the line that fully overlapped to other line
1003
+ var newLines = []; // new countour line segment that except the overlapped part
1004
+ var _loop9 = function _loop9(i) {
1005
+ var srcLine = {
1006
+ x1: moldingLines[i].line[0].x,
1007
+ y1: moldingLines[i].line[0].y,
1008
+ x2: moldingLines[i].line[1].x,
1009
+ y2: moldingLines[i].line[1].y
1010
+ };
1011
+ var _loop1 = function _loop1(j) {
1012
+ if (i === j) return 0; // continue
1013
+ if (Math.abs(moldingLines[i].z - moldingLines[j].z) > EPSILON) return 0; // continue
1014
+ var destLine = {
1015
+ x1: moldingLines[j].line[0].x,
1016
+ y1: moldingLines[j].line[0].y,
1017
+ x2: moldingLines[j].line[1].x,
1018
+ y2: moldingLines[j].line[1].y
1019
+ };
1020
+ var rst = GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
1021
+ if (rst.result === OVERLAP_SAME || rst.result === OVERLAP_INCLUDED) {
1022
+ removeLineIds.push(i);
1023
+ return 1; // break
1024
+ } else if (rst.result === OVERLAP_SOME) {
1025
+ removeLineIds.push(i);
1026
+ var lineSegs = getTrimmedContourLineSegs(rst.trimmedSegs, moldingLines.filter(function (v, idx) {
1027
+ return idx !== i && idx !== j && Math.abs(v.z - moldingLines[i].z) < EPSILON;
1028
+ }), 0);
1029
+ if (lineSegs.length > 0) {
1030
+ lineSegs.forEach(function (ls) {
1031
+ return newLines.push({
1032
+ molding: _objectSpread({}, moldingLines[i].molding),
1033
+ doorStyle: moldingLines[i].doorStyle,
1034
+ line: _toConsumableArray(ls),
1035
+ z: moldingLines[i].z
1036
+ });
1037
+ });
1038
+ }
1039
+ return 1; // break
1040
+ }
1041
+ },
1042
+ _ret4;
1043
+ for (var j = 0; j < moldingLines.length; j++) {
1044
+ _ret4 = _loop1(j);
1045
+ if (_ret4 === 0) continue;
1046
+ if (_ret4 === 1) break;
1047
+ }
1048
+ };
1049
+ for (var i = 0; i < moldingLines.length; i++) {
1050
+ _loop9(i);
1051
+ }
1052
+ moldingLines = moldingLines.filter(function (line, idx) {
1053
+ return !removeLineIds.some(function (id) {
1054
+ return idx === id;
1055
+ });
1056
+ });
1057
+ if (newLines.length > 0) moldingLines = [].concat(_toConsumableArray(moldingLines), newLines);
1058
+ // console.log('moldingLines: ', moldingLines);
1059
+
1060
+ // make molding data with sorting molding & doorStyle
1061
+ var _loop0 = function _loop0() {
1062
+ var ml = moldingLines[k];
1063
+ var mlLength = convert(GeometryUtils.verticesDistance(ml.line[0], ml.line[1])).from('cm').to('in');
1064
+ var idx = moldingData.findIndex(function (v) {
1065
+ var _ml$molding, _v$doorStyle, _ml$doorStyle;
1066
+ return (v === null || v === void 0 ? void 0 : v.name) === ((_ml$molding = ml.molding) === null || _ml$molding === void 0 ? void 0 : _ml$molding.name) && ((_v$doorStyle = v.doorStyle) === null || _v$doorStyle === void 0 ? void 0 : _v$doorStyle.id) === ((_ml$doorStyle = ml.doorStyle) === null || _ml$doorStyle === void 0 ? void 0 : _ml$doorStyle.id);
1067
+ });
1068
+ if (idx < 0) moldingData.push(_objectSpread(_objectSpread({}, ml.molding), {}, {
1069
+ doorStyle: ml.doorStyle,
1070
+ totalLength: mlLength,
1071
+ count: Math.ceil(mlLength * 1.1 / 96)
1072
+ }));else {
1073
+ moldingData[idx].totalLength += mlLength;
1074
+ moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 / 96);
1075
+ }
1076
+ };
1077
+ for (var k = 0; k < moldingLines.length; k++) {
1078
+ _loop0();
1079
+ }
1080
+ // console.log('moldingData: ', moldingData);
1081
+
1082
+ return moldingData;
1083
+ }
870
1084
  export function getMoldingDataOfScene(layer, catalog, doorStyle) {
871
1085
  var moldingData = [];
872
1086
  var items = layer.items.toArray();
@@ -895,7 +1109,7 @@ export function getMoldingDataOfScene(layer, catalog, doorStyle) {
895
1109
  if (temp_items.length) {
896
1110
  while (temp_items.length > 0) {
897
1111
  var itemGroup = [temp_items[0]];
898
- var _loop9 = function _loop9(_idx) {
1112
+ var _loop10 = function _loop10(_idx) {
899
1113
  if (!itemGroup.some(function (it) {
900
1114
  return it.id === temp_items[_idx].id;
901
1115
  }) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
@@ -905,7 +1119,7 @@ export function getMoldingDataOfScene(layer, catalog, doorStyle) {
905
1119
  idx = _idx;
906
1120
  };
907
1121
  for (var idx = 0; idx < temp_items.length; idx++) {
908
- _loop9(idx);
1122
+ _loop10(idx);
909
1123
  }
910
1124
  itemGroup.forEach(function (item) {
911
1125
  var index = temp_items.findIndex(function (it) {
@@ -923,7 +1137,7 @@ export function getMoldingDataOfScene(layer, catalog, doorStyle) {
923
1137
  var items = _toConsumableArray(itemgroup);
924
1138
  var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
925
1139
  items = sortItemsByDistance(items, items[0]);
926
- var _loop0 = function _loop0() {
1140
+ var _loop11 = function _loop11() {
927
1141
  var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
928
1142
  var temp_MGLines = [];
929
1143
  MGlines.forEach(function (line) {
@@ -947,7 +1161,7 @@ export function getMoldingDataOfScene(layer, catalog, doorStyle) {
947
1161
  MGlines = [].concat(temp_MGLines);
948
1162
  };
949
1163
  for (var i = 1; i < items.length; i++) {
950
- _loop0();
1164
+ _loop11();
951
1165
  }
952
1166
  MGlines.forEach(function (line) {
953
1167
  molding_totalLength += GeometryUtils.verticesDistance(line[0], line[1]);
@@ -971,8 +1185,8 @@ export function getMoldingDataOfScene(layer, catalog, doorStyle) {
971
1185
  var tmpMoldingData = [];
972
1186
  var toedoorStyles = [];
973
1187
  tmp.map(function (item) {
974
- var _item$molding;
975
- if (item.layoutpos === BASE_CABINET_LAYOUTPOS && (isEmpty(item.molding) || ((_item$molding = item.molding) === null || _item$molding === void 0 ? void 0 : _item$molding.length) < 1 || !isEnableItemForMolding(layer, item))) {
1188
+ var _item$molding2;
1189
+ if (item.layoutpos === BASE_CABINET_LAYOUTPOS && (isEmpty(item.molding) || ((_item$molding2 = item.molding) === null || _item$molding2 === void 0 ? void 0 : _item$molding2.length) < 1 || !isEnableItemForMolding(layer, item))) {
976
1190
  var w = item.properties.get('width').get('_length');
977
1191
  var wUnit = item.properties.get('width').get('_unit') || 'cm';
978
1192
  w = convert(w / 2).from(wUnit).to('cm');
@@ -990,28 +1204,28 @@ export function getMoldingDataOfScene(layer, catalog, doorStyle) {
990
1204
  var outlineWidth = outline.svgWidth;
991
1205
  var outlineHeight = outline.svgHeight;
992
1206
  var outlinePoints = []; // Hold Points Of SVG
993
- var _iterator3 = _createForOfIteratorHelper(outlinePaths),
994
- _step3;
1207
+ var _iterator5 = _createForOfIteratorHelper(outlinePaths),
1208
+ _step5;
995
1209
  try {
996
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
997
- var path = _step3.value;
998
- var _iterator4 = _createForOfIteratorHelper(path.subPaths),
999
- _step4;
1210
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1211
+ var path = _step5.value;
1212
+ var _iterator6 = _createForOfIteratorHelper(path.subPaths),
1213
+ _step6;
1000
1214
  try {
1001
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1002
- var subPath = _step4.value;
1215
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1216
+ var subPath = _step6.value;
1003
1217
  outlinePoints = outlinePoints.concat(subPath.getPoints());
1004
1218
  }
1005
1219
  } catch (err) {
1006
- _iterator4.e(err);
1220
+ _iterator6.e(err);
1007
1221
  } finally {
1008
- _iterator4.f();
1222
+ _iterator6.f();
1009
1223
  }
1010
1224
  }
1011
1225
  } catch (err) {
1012
- _iterator3.e(err);
1226
+ _iterator5.e(err);
1013
1227
  } finally {
1014
- _iterator3.f();
1228
+ _iterator5.f();
1015
1229
  }
1016
1230
  var maxX = outlinePoints[0].x,
1017
1231
  minX = outlinePoints[0].x;
@@ -12,7 +12,7 @@ var SharedStyle = _interopRequireWildcard(require("../../shared-style"));
12
12
  var _RGBELoader = require("three/examples/jsm/loaders/RGBELoader");
13
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
14
14
  var params = {
15
- envMap: "HDR",
15
+ envMap: 'HDR',
16
16
  roughness: 0.9,
17
17
  metalness: 0.8,
18
18
  exposure: 1.0
@@ -67,7 +67,7 @@ var assignUVs = function assignUVs(geometry) {
67
67
  var y3 = position.getY(i + 2);
68
68
  uvArray.push((x1 + offset.x) / range.x, (y1 + offset.y) / range.y, (x2 + offset.x) / range.x, (y2 + offset.y) / range.y, (x3 + offset.x) / range.x, (y3 + offset.y) / range.y);
69
69
  }
70
- geometry.setAttribute("uv", new Three.BufferAttribute(new Float32Array(uvArray), 2));
70
+ geometry.setAttribute('uv', new Three.BufferAttribute(new Float32Array(uvArray), 2));
71
71
  geometry.needsUpdate = true;
72
72
  };
73
73
  function createArea(element, layer, scene, textures) {
@@ -78,15 +78,15 @@ function createArea(element, layer, scene, textures) {
78
78
  var texture = element.texture;
79
79
  texture.lengthRepeatScale = 0.01;
80
80
  texture.heightRepeatScale = 0.01;
81
- var color = element.properties.get("patternColor");
81
+ var color = element.properties.get('patternColor');
82
82
  if (element.selected) {
83
83
  color = SharedStyle.AREA_MESH_COLOR.selected;
84
84
  } else {
85
85
  color = SharedStyle.AREA_MESH_COLOR.unselected;
86
86
  }
87
- if (texture.uri === undefined || texture.uri == "") {
87
+ if (texture.uri === undefined || texture.uri == '') {
88
88
  // @todo THIS IS A TEMPORARY FIX TO HAVE A DEFAULT FLOOR TEXTURE
89
- texture.uri = layer.floorStyle.uri || "https://media.test.diydesignspace.com/uploads/CountTop/202203162950_2/texture/oak-barcelona-s.jpg";
89
+ texture.uri = layer.floorStyle.uri || 'https://media.test.diydesignspace.com/uploads/CountTop/202203162950_2/texture/oak-barcelona-s.jpg';
90
90
  }
91
91
  var shape = new _three.Shape();
92
92
  shape.moveTo(vertices[0].x, vertices[0].y);
@@ -94,7 +94,7 @@ function createArea(element, layer, scene, textures) {
94
94
  shape.lineTo(vertices[i].x, vertices[i].y);
95
95
  }
96
96
  function loadFloorENV() {
97
- return new _RGBELoader.RGBELoader().load("/assets/Window.hdr", function (texture) {
97
+ return new _RGBELoader.RGBELoader().load('/assets/Window.hdr', function (texture) {
98
98
  texture.mapping = Three.EquirectangularReflectionMapping;
99
99
  return texture;
100
100
  });
@@ -114,8 +114,8 @@ function createArea(element, layer, scene, textures) {
114
114
  /* Create holes for the area */
115
115
  element.holes.forEach(function (holeID) {
116
116
  var holeCoords = [];
117
- layer.getIn(["areas", holeID, "vertices"]).forEach(function (vertexID) {
118
- var _layer$getIn = layer.getIn(["vertices", vertexID]),
117
+ layer.getIn(['areas', holeID, 'vertices']).forEach(function (vertexID) {
118
+ var _layer$getIn = layer.getIn(['vertices', vertexID]),
119
119
  x = _layer$getIn.x,
120
120
  y = _layer$getIn.y;
121
121
  holeCoords.push([x, y]);
@@ -142,7 +142,7 @@ function createArea(element, layer, scene, textures) {
142
142
  var area = new _three.Mesh(shapeGeometry, areaMaterial);
143
143
  area.rotation.x -= Math.PI / 2;
144
144
  area.receiveShadow = true;
145
- area.name = "floor";
145
+ area.name = 'floor';
146
146
  // This mesh is use for creating ceiling mesh
147
147
 
148
148
  var shapeGeometry2 = new Three.ShapeGeometry(shape);
@@ -153,7 +153,7 @@ function createArea(element, layer, scene, textures) {
153
153
  area2.castShadow = true;
154
154
  area2.rotation.x -= Math.PI / 2;
155
155
  area2.receiveShadow = true;
156
- area2.name = "floorSupport";
156
+ area2.name = 'floorSupport';
157
157
  var floorSupport = area2.clone();
158
158
  area.userData.floorSupport = floorSupport;
159
159
  return Promise.resolve(area);
@@ -163,13 +163,13 @@ function updatedArea(element, layer, scene, textures, mesh, oldElement, differen
163
163
  selfDestroy();
164
164
  return selfBuild();
165
165
  };
166
- var floor = mesh.getObjectByName("floor");
166
+ var floor = mesh.getObjectByName('floor');
167
167
  floor.receiveShadow = true;
168
- if (differences[0] == "selected") {
168
+ if (differences[0] == 'selected') {
169
169
  var color = element.selected ? SharedStyle.AREA_MESH_COLOR.selected : SharedStyle.AREA_MESH_COLOR.unselected;
170
170
  floor.material.color.set(color);
171
- } else if (differences[0] == "properties") {
172
- if (differences[1] === "texture") {
171
+ } else if (differences[0] == 'properties') {
172
+ if (differences[1] === 'texture') {
173
173
  return noPerf();
174
174
  }
175
175
  } else return noPerf();
@@ -1011,7 +1011,7 @@ function render3DItem(element, layer, scene, sizeinfo, structure_json, is_corner
1011
1011
  counterTop = counterTop.toJS();
1012
1012
  } catch (error) {
1013
1013
  //@todo THIS IS A TEMPORARY FIX FOR COUNTERTOP TEXTURE UNDEFINED ISSUE
1014
- counterTop.uri = 'http://kc.server.com:4002/uploads/CountTop/202105074107_5/texture/Unique_Calcatta_texture.jpg';
1014
+ counterTop.uri = 'https://media.test.diydesignspace.com/uploads/CountTop/202105074107_5/texture/Unique_Calcatta_texture.jpg';
1015
1015
  console.log(error);
1016
1016
  }
1017
1017
  }
package/lib/class/hole.js CHANGED
@@ -783,11 +783,9 @@ var Hole = exports["default"] = /*#__PURE__*/function () {
783
783
  scene: scene.mergeIn(['layers', layerID, 'holes', holeID], hole)
784
784
  });
785
785
  state = state.updateIn(['scene', 'layers', layerID, 'lines', hole.line, 'holes'], function (holes) {
786
- console.log(holes, 'holes');
787
786
  var index = holes.findIndex(function (ID) {
788
787
  return holeID === ID;
789
788
  });
790
- console.log(index, 'index');
791
789
  return index === -1 ? holes.push(holeID) : holes;
792
790
  });
793
791
  return {
package/lib/class/item.js CHANGED
@@ -36,9 +36,11 @@ var Item = exports["default"] = /*#__PURE__*/function () {
36
36
  return (0, _createClass2["default"])(Item, null, [{
37
37
  key: "create",
38
38
  value: function create(state, layerID, type, x, y, width, height, rotation, isDuplication) {
39
+ var _item;
39
40
  var molding = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : [];
40
41
  var isInitialPos = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
41
42
  var refItem = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : null;
43
+ var counterTopURI = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : null;
42
44
  var itemID = _export2.IDBroker.acquireID();
43
45
  var item = state.catalog.factoryElement(type, {
44
46
  id: itemID,
@@ -167,6 +169,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
167
169
  }
168
170
  };
169
171
  item.category === 'cabinet' && setSizeOfItemByDoorStyle();
172
+ if (counterTopURI || (_item = item) !== null && _item !== void 0 && _item.counterTop) {
173
+ item.counterTop.uri = counterTopURI;
174
+ }
170
175
  item = this.updateDoorHandle(item, state.getIn(['scene', 'layers', layerID]));
171
176
  state = state.setIn(['scene', 'layers', layerID, 'items', itemID], item);
172
177
  if (item.type.includes('Light')) {
@@ -338,17 +343,17 @@ var Item = exports["default"] = /*#__PURE__*/function () {
338
343
  if (isRect) {
339
344
  var _this$create2 = this.create(state, layerID, sceneComponentType, x - width * Math.cos(rotRad), y - width * Math.sin(rotRad), 200, 100, rotRad * 180 / Math.PI, true, myObject.molding, false, myObject),
340
345
  _stateI = _this$create2.updatedState,
341
- _item = _this$create2.item;
342
- duplicatedElement = _item;
343
- if (_item === null) {
346
+ _item2 = _this$create2.item;
347
+ duplicatedElement = _item2;
348
+ if (_item2 === null) {
344
349
  alert('There are no Door Colors in this cabinet.');
345
350
  state = state.merge({
346
351
  mode: _constants.MODE_IDLE,
347
352
  drawingSupport: new _immutable.Map()
348
353
  });
349
354
  } else {
350
- state = Item.select(_stateI, layerID, _item.id).updatedState;
351
- state = state.setIn(['drawingSupport', 'currentID'], _item.id);
355
+ state = Item.select(_stateI, layerID, _item2.id).updatedState;
356
+ state = state.setIn(['drawingSupport', 'currentID'], _item2.id);
352
357
  }
353
358
  } else {
354
359
  var _val2 = {
@@ -365,17 +370,17 @@ var Item = exports["default"] = /*#__PURE__*/function () {
365
370
  if (isRectDown) {
366
371
  var _this$create3 = this.create(state, layerID, sceneComponentType, x - depth * Math.sin(rotRad), y - depth * Math.cos(rotRad), 200, 100, rotRad * 180 / Math.PI, true, myObject.molding, false, myObject),
367
372
  _stateI2 = _this$create3.updatedState,
368
- _item2 = _this$create3.item;
369
- duplicatedElement = _item2;
370
- if (_item2 === null) {
373
+ _item3 = _this$create3.item;
374
+ duplicatedElement = _item3;
375
+ if (_item3 === null) {
371
376
  alert('There are no Door Colors in this cabinet.');
372
377
  state = state.merge({
373
378
  mode: _constants.MODE_IDLE,
374
379
  drawingSupport: new _immutable.Map()
375
380
  });
376
381
  } else {
377
- state = Item.select(_stateI2, layerID, _item2.id).updatedState;
378
- state = state.setIn(['drawingSupport', 'currentID'], _item2.id);
382
+ state = Item.select(_stateI2, layerID, _item3.id).updatedState;
383
+ state = state.setIn(['drawingSupport', 'currentID'], _item3.id);
379
384
  }
380
385
  } else {
381
386
  var _val3 = {
@@ -392,17 +397,17 @@ var Item = exports["default"] = /*#__PURE__*/function () {
392
397
  if (isRectUp) {
393
398
  var _this$create4 = this.create(state, layerID, sceneComponentType, x + depth * Math.sin(rotRad), y + depth * Math.cos(rotRad), 200, 100, rotRad * 180 / Math.PI, true, myObject.molding, false, myObject),
394
399
  _stateI3 = _this$create4.updatedState,
395
- _item3 = _this$create4.item;
396
- duplicatedElement = _item3;
397
- if (_item3 === null) {
400
+ _item4 = _this$create4.item;
401
+ duplicatedElement = _item4;
402
+ if (_item4 === null) {
398
403
  alert('There are no Door Colors in this cabinet.');
399
404
  state = state.merge({
400
405
  mode: _constants.MODE_IDLE,
401
406
  drawingSupport: new _immutable.Map()
402
407
  });
403
408
  } else {
404
- state = Item.select(_stateI3, layerID, _item3.id).updatedState;
405
- state = state.setIn(['drawingSupport', 'currentID'], _item3.id);
409
+ state = Item.select(_stateI3, layerID, _item4.id).updatedState;
410
+ state = state.setIn(['drawingSupport', 'currentID'], _item4.id);
406
411
  }
407
412
  } else {
408
413
  console.log('there is no space');
@@ -539,8 +544,14 @@ var Item = exports["default"] = /*#__PURE__*/function () {
539
544
  }, {
540
545
  key: "replaceItem",
541
546
  value: function replaceItem(state, selectedPos, currentObject, selectedObject) {
547
+ var _currentObject$counte;
548
+ var counterTopURI = '';
549
+ if (!(0, _utils.isEmpty)(currentObject === null || currentObject === void 0 || (_currentObject$counte = currentObject.counterTop) === null || _currentObject$counte === void 0 ? void 0 : _currentObject$counte.uri)) {
550
+ var _currentObject$counte2;
551
+ counterTopURI = currentObject === null || currentObject === void 0 || (_currentObject$counte2 = currentObject.counterTop) === null || _currentObject$counte2 === void 0 ? void 0 : _currentObject$counte2.uri;
552
+ } else if (!(0, _utils.isEmpty)(state.getIn(['scene', 'layers', 'layer-1', 'counterTop']))) counterTopURI = state.getIn(['scene', 'layers', 'layer-1', 'counterTop']).uri;else counterTopURI = 'https://media.test.diydesignspace.com/uploads/CountTop/202105074107_5/texture/Unique_Calcatta_texture.jpg';
542
553
  state = this.remove(state, state.scene.selectedLayer, selectedPos.selectedItemId).updatedState;
543
- state = this.create(state, state.scene.selectedLayer, selectedObject.name, selectedPos.x, selectedPos.y, selectedObject.info.width, selectedObject.info.height, selectedPos.rotation, false).updatedState;
554
+ state = this.create(state, state.scene.selectedLayer, selectedObject.name, selectedPos.x, selectedPos.y, selectedObject.info.width, selectedObject.info.height, selectedPos.rotation, false, [], false, null, counterTopURI).updatedState;
544
555
  // state = this.select(state, state.scene.selectedLayer, selectedPos.selectedItemId).updatedState;
545
556
  return {
546
557
  updatedState: state
@@ -43,7 +43,8 @@ var Project = exports["default"] = /*#__PURE__*/function () {
43
43
  }, {
44
44
  key: "newProject",
45
45
  value: function newProject(state) {
46
- var doorStyle = state.toJS().doorStyle === null ? null : state.toJS().doorStyle;
46
+ var _state$toJS$doorStyle, _state;
47
+ var doorStyle = (_state$toJS$doorStyle = (_state = state) === null || _state === void 0 || (_state = _state.toJS()) === null || _state === void 0 ? void 0 : _state.doorStyle) !== null && _state$toJS$doorStyle !== void 0 ? _state$toJS$doorStyle : null;
47
48
  // let counterTop = state.getIn(['scene', 'layers', layerID, 'counterTop']);
48
49
  // let floorStyle = state.getIn(['scene', 'layers', layerID, 'floorStyle']);
49
50
  var _viewer2D = state.viewer2D;
@@ -83,9 +84,9 @@ var Project = exports["default"] = /*#__PURE__*/function () {
83
84
  a: 0.99,
84
85
  d: 0.99
85
86
  });
86
- var _state = state,
87
- oldScene = _state.scene,
88
- oldSceneHistory = _state.sceneHistory;
87
+ var _state2 = state,
88
+ oldScene = _state2.scene,
89
+ oldSceneHistory = _state2.sceneHistory;
89
90
  var json_items = sceneJSON.layers[sceneJSON.selectedLayer].items;
90
91
  var elements = state.catalog.get('elements').toArray();
91
92
  var _loop = function _loop(x) {
@@ -838,14 +839,18 @@ var Project = exports["default"] = /*#__PURE__*/function () {
838
839
  key: "createRoomWithShape",
839
840
  value: function createRoomWithShape(state, roomShapeType, width, height, doorStyle) {
840
841
  var catalog = state.catalog;
842
+ // keep measurement unit
843
+ var curLayerID = state.scene.selectedLayer;
844
+ var layerUnit = state.getIn(['scene', 'layers', curLayerID, 'unit']);
845
+ var ceilHeight = state.getIn(['scene', 'layers', curLayerID, 'ceilHeight']);
841
846
  state = this.newProject(state).updatedState;
842
847
  state = state.merge({
843
848
  catalog: catalog
844
849
  });
845
850
  var _viewer2D = state.viewer2D;
846
851
  var viewer = _viewer2D.toJS();
847
- width = (0, _convertUnitsLite.convert)(width).from('in').to('cm');
848
- height = (0, _convertUnitsLite.convert)(height).from('in').to('cm');
852
+ width = (0, _convertUnitsLite.convert)(width).from(state.getIn(['scene', 'layers', 'layer-1', 'unit'])).to('cm');
853
+ height = (0, _convertUnitsLite.convert)(height).from(state.getIn(['scene', 'layers', 'layer-1', 'unit'])).to('cm');
849
854
  var layerID = state.scene.selectedLayer;
850
855
  state = _export2.Item.setInitialDoorStyle(state, doorStyle).updatedState;
851
856
  if ((0, _helper.isEmpty)(viewer)) return {
@@ -921,6 +926,9 @@ var Project = exports["default"] = /*#__PURE__*/function () {
921
926
  }
922
927
  state = _export2.Layer.detectAndUpdateAreas(state, layerID, drawingInfo).updatedState;
923
928
  }
929
+ // copy keeped measurement unit
930
+ state = state.setIn(['scene', 'layers', layerID, 'unit'], layerUnit);
931
+ state = state.setIn(['scene', 'layers', layerID, 'ceilHeight'], ceilHeight);
924
932
  state = (0, _helper.centering2D)(state);
925
933
  return {
926
934
  updatedState: state