kitchen-simulator 4.0.6 → 4.0.7-measurement-unit-payload
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/actions/project-actions.js +2 -1
- package/es/catalog/factories/wall-factory.js +1 -1
- package/es/catalog/utils/exporter.js +23 -11
- package/es/catalog/utils/item-loader.js +4 -9
- package/es/class/item.js +3 -0
- package/es/class/layer.js +1 -1
- package/es/class/project.js +9 -7
- package/es/components/viewer2d/line.js +5 -5
- package/es/components/viewer2d/ruler.js +16 -13
- package/es/components/viewer2d/rulerDist.js +38 -52
- package/es/components/viewer2d/viewer2d.js +10 -5
- package/es/components/viewer3d/scene-creator.js +213 -53
- package/es/components/viewer3d/viewer3d.js +21 -14
- package/es/constants.js +1 -0
- package/es/index.js +26 -5
- package/es/models.js +10 -6
- package/es/reducers/project-reducer.js +1 -1
- package/es/reducers/viewer2d-reducer.js +3 -1
- package/es/reducers/viewer3d-reducer.js +3 -1
- package/es/utils/geometry.js +7 -7
- package/es/utils/isolate-event-handler.js +8 -8
- package/es/utils/molding.js +4 -2
- package/es/utils/ruler.js +58 -0
- package/lib/actions/project-actions.js +2 -1
- package/lib/catalog/factories/wall-factory.js +1 -1
- package/lib/catalog/utils/exporter.js +23 -11
- package/lib/catalog/utils/item-loader.js +4 -9
- package/lib/class/item.js +3 -0
- package/lib/class/layer.js +1 -1
- package/lib/class/project.js +9 -7
- package/lib/components/viewer2d/line.js +5 -5
- package/lib/components/viewer2d/ruler.js +15 -12
- package/lib/components/viewer2d/rulerDist.js +38 -52
- package/lib/components/viewer2d/viewer2d.js +10 -5
- package/lib/components/viewer3d/scene-creator.js +212 -52
- package/lib/components/viewer3d/viewer3d.js +21 -14
- package/lib/constants.js +5 -4
- package/lib/index.js +28 -5
- package/lib/models.js +10 -6
- package/lib/reducers/project-reducer.js +1 -1
- package/lib/reducers/viewer2d-reducer.js +3 -1
- package/lib/reducers/viewer3d-reducer.js +3 -1
- package/lib/utils/geometry.js +7 -7
- package/lib/utils/isolate-event-handler.js +8 -8
- package/lib/utils/molding.js +4 -2
- package/lib/utils/ruler.js +63 -0
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ import { disposeObject } from "./three-memory-cleaner";
|
|
|
12
12
|
import { ANIMATE_STEP_MAX, ANIMATE_STEP_MIN, ARRAY_3D_MODES, ARROW_TEXT_BACKCOLOR, ARROW_TEXT_FONTFACE, ARROW_TEXT_FORECOLOR, BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, DECIMAL_PLACES_2, DIFFERENT_VALUES_PATH_LENGTH, DISTANCE_EPSILON, EPSILON, MIDDLE_MOLDING_LOCATION, MODE_DRAGGING_ITEM_3D, MODE_DRAWING_ITEM_3D, MODE_IDLE, MODE_IDLE_3D, MODE_ROTATING_ITEM_3D, OBJTYPE_MESH, SHADE_DARK_PURPLE_COLOR, TOP_MOLDING_LOCATION, UNIT_CENTIMETER, UNIT_FOOT, UNIT_INCH, UNIT_METER, WALL_CABINET_LAYOUTPOS } from "../../constants";
|
|
13
13
|
import { GeometryUtils, IDBroker, MoldingUtils } from "../../utils/export";
|
|
14
14
|
import { convert } from "../../utils/convert-units-lite";
|
|
15
|
-
import { verticesDistance } from "../../utils/geometry";
|
|
15
|
+
import { calcDistancesFromItemToWalls, verticesDistance } from "../../utils/geometry";
|
|
16
16
|
import * as GeomUtils from "../../catalog/utils/geom-utils";
|
|
17
17
|
import { loadTexture } from "../../catalog/utils/item-loader";
|
|
18
18
|
import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
|
|
@@ -479,19 +479,19 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
|
|
|
479
479
|
if (modifiedPath[keyIndex] == 'rotation') {
|
|
480
480
|
item3D.rotation.set(0, value * Math.PI / 180 + Math.PI, 0);
|
|
481
481
|
setTimeout(function () {
|
|
482
|
-
getDistances(layer);
|
|
482
|
+
getDistances(layer, item);
|
|
483
483
|
}, 50);
|
|
484
484
|
removeSelItemMesh(tmpMoldings, item, planData, mode);
|
|
485
485
|
} else if (modifiedPath[keyIndex] == 'x') {
|
|
486
486
|
item3D.position.x = value;
|
|
487
487
|
setTimeout(function () {
|
|
488
|
-
getDistances(layer);
|
|
488
|
+
getDistances(layer, item);
|
|
489
489
|
}, 50);
|
|
490
490
|
removeSelItemMesh(tmpMoldings, item, planData, mode);
|
|
491
491
|
} else if (modifiedPath[keyIndex] == 'y') {
|
|
492
492
|
item3D.position.z = -value;
|
|
493
493
|
setTimeout(function () {
|
|
494
|
-
getDistances(layer);
|
|
494
|
+
getDistances(layer, item);
|
|
495
495
|
}, 50);
|
|
496
496
|
removeSelItemMesh(tmpMoldings, item, planData, mode);
|
|
497
497
|
} else if (modifiedPath[keyIndex] == 'selected') {
|
|
@@ -717,7 +717,7 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
|
|
|
717
717
|
return actions.itemsActions.selectItem(layer.id, modifiedPath[4]);
|
|
718
718
|
});
|
|
719
719
|
setTimeout(function () {
|
|
720
|
-
getDistances(layer);
|
|
720
|
+
getDistances(layer, item);
|
|
721
721
|
}, 100);
|
|
722
722
|
}
|
|
723
723
|
} else if (modifiedPath[keyIndex] == 'length') {
|
|
@@ -845,7 +845,7 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
|
|
|
845
845
|
removeItemWithoutItem(planData, layer.id, modifiedPath[4]);
|
|
846
846
|
promises.push(addItem(sceneData, planData, layer, modifiedPath[4], catalog, actions.itemsActions, mode, null, rItem));
|
|
847
847
|
setTimeout(function () {
|
|
848
|
-
getDistances(layer);
|
|
848
|
+
getDistances(layer, item);
|
|
849
849
|
}, 100);
|
|
850
850
|
}
|
|
851
851
|
break;
|
|
@@ -891,10 +891,169 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
|
|
|
891
891
|
promise: p1
|
|
892
892
|
};
|
|
893
893
|
}
|
|
894
|
-
export function getDistances(layer, isCalcWall) {
|
|
894
|
+
export function getDistances(layer, curItem, isCalcWall) {
|
|
895
|
+
// matching fvLine distance with OP
|
|
896
|
+
var pointArray = calcDistancesFromItemToWalls(curItem, layer).PointArray;
|
|
897
|
+
if ((pointArray === null || pointArray === void 0 ? void 0 : pointArray.length) > 0) {
|
|
898
|
+
var _loop2 = function _loop2() {
|
|
899
|
+
var direction = i === 0 ? 90 : i === 1 ? -90 : i === 2 ? 180 : 0;
|
|
900
|
+
if (fVLine[i].userData) {
|
|
901
|
+
var _pointArray$filter$;
|
|
902
|
+
var opDist = (_pointArray$filter$ = pointArray.filter(function (v) {
|
|
903
|
+
return v[1] === direction;
|
|
904
|
+
})[0]) !== null && _pointArray$filter$ !== void 0 ? _pointArray$filter$ : fVLine[i].userData.distance;
|
|
905
|
+
fVLine[i].userData.opDist = opDist[0];
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
for (var i = 0; i < ((_fVLine = fVLine) === null || _fVLine === void 0 ? void 0 : _fVLine.length); i++) {
|
|
909
|
+
var _fVLine;
|
|
910
|
+
_loop2();
|
|
911
|
+
}
|
|
912
|
+
}
|
|
895
913
|
fVLine.forEach(function (line, index) {
|
|
896
|
-
|
|
914
|
+
getLineDistance2(line, layer, isEmpty(isCalcWall) ? false : isCalcWall, index);
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
function getLineDistance2(obj, layer, isCalcWall, index) {
|
|
918
|
+
var _obj$userData$opDist, _obj$userData, _obj$userData2, _obj$userData$opDist2, _obj$userData3, _obj$userData4;
|
|
919
|
+
if (obj === undefined) return;
|
|
920
|
+
var positionAttribute = obj.geometry.attributes.position;
|
|
921
|
+
if (positionAttribute === undefined) return;
|
|
922
|
+
var wPoint0 = new Three.Vector3().fromBufferAttribute(positionAttribute, 0).applyMatrix4(obj.matrixWorld);
|
|
923
|
+
var wPoint1 = new Three.Vector3().fromBufferAttribute(positionAttribute, 1).applyMatrix4(obj.matrixWorld);
|
|
924
|
+
var raycaster = new Three.Raycaster(wPoint0, new Three.Vector3(wPoint1.x - wPoint0.x, wPoint1.y - wPoint0.y, wPoint1.z - wPoint0.z));
|
|
925
|
+
var rayDirection = raycaster.ray.direction;
|
|
926
|
+
raycaster.camera = new Three.Camera();
|
|
927
|
+
rayDirection.normalize();
|
|
928
|
+
var meshes = [];
|
|
929
|
+
planData.plan.traverse(function (child) {
|
|
930
|
+
if (child.isMesh && child.geometry) {
|
|
931
|
+
meshes.push(child);
|
|
932
|
+
}
|
|
897
933
|
});
|
|
934
|
+
var dx = wPoint0.x - wPoint1.x;
|
|
935
|
+
var dy = wPoint0.y - wPoint1.y;
|
|
936
|
+
var dz = wPoint0.z - wPoint1.z;
|
|
937
|
+
var length = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
938
|
+
var scale = 1;
|
|
939
|
+
var extrudeSettings = {
|
|
940
|
+
steps: 2,
|
|
941
|
+
depth: 0.01,
|
|
942
|
+
bevelEnabled: false
|
|
943
|
+
};
|
|
944
|
+
var w = 0.2;
|
|
945
|
+
var h = w * (Math.sqrt(3) / 2);
|
|
946
|
+
var shape = new Three.Shape();
|
|
947
|
+
shape.moveTo(0, 0);
|
|
948
|
+
shape.lineTo(-w / 4, h / 2);
|
|
949
|
+
shape.lineTo(w / 4, h / 2);
|
|
950
|
+
var geom = new Three.ExtrudeGeometry(shape, extrudeSettings);
|
|
951
|
+
geom.center();
|
|
952
|
+
var opDist = (_obj$userData$opDist = (_obj$userData = obj.userData) === null || _obj$userData === void 0 ? void 0 : _obj$userData.opDist) !== null && _obj$userData$opDist !== void 0 ? _obj$userData$opDist : (_obj$userData2 = obj.userData) === null || _obj$userData2 === void 0 ? void 0 : _obj$userData2.distance;
|
|
953
|
+
scale = opDist / length;
|
|
954
|
+
if (opDist <= 0.1) {
|
|
955
|
+
scale = 0.1 / length;
|
|
956
|
+
}
|
|
957
|
+
obj.userData.distance = (_obj$userData$opDist2 = (_obj$userData3 = obj.userData) === null || _obj$userData3 === void 0 ? void 0 : _obj$userData3.opDist) !== null && _obj$userData$opDist2 !== void 0 ? _obj$userData$opDist2 : (_obj$userData4 = obj.userData) === null || _obj$userData4 === void 0 ? void 0 : _obj$userData4.distance;
|
|
958
|
+
// obj.userData.target = intersects[i].object;
|
|
959
|
+
var originPoint = obj.geometry.attributes.position.array.slice(0, 3);
|
|
960
|
+
var lx = obj.geometry.attributes.position.array[3] - obj.geometry.attributes.position.array[0];
|
|
961
|
+
var ly = obj.geometry.attributes.position.array[4] - obj.geometry.attributes.position.array[1];
|
|
962
|
+
var lz = obj.geometry.attributes.position.array[5] - obj.geometry.attributes.position.array[2];
|
|
963
|
+
var newVec = new Three.Vector3(originPoint[0] + lx * scale, originPoint[1] + ly * scale, originPoint[2] + lz * scale);
|
|
964
|
+
obj.geometry.attributes.position.array[3] = newVec.x;
|
|
965
|
+
obj.geometry.attributes.position.array[4] = newVec.y;
|
|
966
|
+
obj.geometry.attributes.position.array[5] = newVec.z;
|
|
967
|
+
obj.geometry.attributes.position.needsUpdate = true;
|
|
968
|
+
obj.geometry.computeBoundingSphere();
|
|
969
|
+
obj.geometry.computeBoundingBox();
|
|
970
|
+
var dist = convert(opDist).from('cm').to('in');
|
|
971
|
+
if (dist > 3) {
|
|
972
|
+
var _canvas = getDistanceCanvas(dist, layer);
|
|
973
|
+
var wid = _canvas.width / window.innerWidth * 30;
|
|
974
|
+
var hei = _canvas.height / window.innerHeight * 30;
|
|
975
|
+
var texture = new Three.Texture(_canvas);
|
|
976
|
+
texture.minFilter = Three.LinearFilter;
|
|
977
|
+
texture.needsUpdate = true;
|
|
978
|
+
var geometry = new Three.PlaneGeometry(wid / 5, hei / 5);
|
|
979
|
+
geometry.computeBoundingBox();
|
|
980
|
+
var material = new Three.MeshBasicMaterial({
|
|
981
|
+
map: texture,
|
|
982
|
+
side: Three.DoubleSide
|
|
983
|
+
});
|
|
984
|
+
var textMesh = new Three.Mesh(geometry, material);
|
|
985
|
+
for (; obj.children.length != 0;) {
|
|
986
|
+
var temp = obj.children.pop();
|
|
987
|
+
disposeObject(temp);
|
|
988
|
+
}
|
|
989
|
+
textMesh.rotation.set(Math.PI / 2, Math.PI, 0);
|
|
990
|
+
// obj.add(textMesh);
|
|
991
|
+
textMesh.position.set((obj.geometry.attributes.position.array[0] + obj.geometry.attributes.position.array[3]) / 2, 0.01, (obj.geometry.attributes.position.array[2] + obj.geometry.attributes.position.array[5]) / 2);
|
|
992
|
+
textMesh.name = 'lineText';
|
|
993
|
+
textMesh.renderOrder = 2;
|
|
994
|
+
textMesh.material.depthTest = false;
|
|
995
|
+
textMesh.material.transparent = true;
|
|
996
|
+
var sprite1 = new Three.Sprite(new Three.SpriteMaterial({
|
|
997
|
+
map: texture
|
|
998
|
+
}));
|
|
999
|
+
sprite1.position.set((obj.geometry.attributes.position.array[0] + obj.geometry.attributes.position.array[3]) / 2, 0.01, (obj.geometry.attributes.position.array[2] + obj.geometry.attributes.position.array[5]) / 2);
|
|
1000
|
+
sprite1.name = 'lineText';
|
|
1001
|
+
sprite1.renderOrder = 2;
|
|
1002
|
+
sprite1.scale.set(0.2, 0.1, 0.2);
|
|
1003
|
+
sprite1.layers.set(1);
|
|
1004
|
+
sprite1.material.depthTest = false;
|
|
1005
|
+
obj.add(sprite1);
|
|
1006
|
+
if (obj.parent != null) {
|
|
1007
|
+
// is not lighting
|
|
1008
|
+
var item3D = obj.parent.parent.parent;
|
|
1009
|
+
var max = item3D.children[0].userData.max;
|
|
1010
|
+
var min = item3D.children[0].userData.min;
|
|
1011
|
+
var objW = (max.x - min.x) / 100,
|
|
1012
|
+
objL = (max.z - min.z) / 100;
|
|
1013
|
+
var triangle = new Three.Mesh(geom, new Three.MeshBasicMaterial({
|
|
1014
|
+
color: SHADE_DARK_PURPLE_COLOR
|
|
1015
|
+
}));
|
|
1016
|
+
var triangle1 = new Three.Mesh(geom, new Three.MeshBasicMaterial({
|
|
1017
|
+
color: SHADE_DARK_PURPLE_COLOR
|
|
1018
|
+
}));
|
|
1019
|
+
triangle.position.set((index < 2 ? 0 : Math.sin((index === 2 ? 1 : -1) * Math.PI / 2)) * (obj.geometry.attributes.position.array[0] + h / 4 + (index % 2 === 0 ? 0 : objW)), newVec.y, (index < 2 ? Math.cos(index * Math.PI) : 0) * (obj.geometry.attributes.position.array[2] + h / 4 + (index % 2 === 0 ? 0 : objL)));
|
|
1020
|
+
triangle1.position.set(newVec.x - (index < 2 ? 0 : Math.sin((index === 2 ? 1 : -1) * Math.PI / 2)) * h / 4, newVec.y, newVec.z - (index < 2 ? Math.cos(index * Math.PI) : 0) * h / 4);
|
|
1021
|
+
if (index < 2) {
|
|
1022
|
+
triangle.rotation.x = Math.cos(index * Math.PI) * Math.PI / 2;
|
|
1023
|
+
triangle1.rotation.x = -Math.cos(index * Math.PI) * Math.PI / 2;
|
|
1024
|
+
} else {
|
|
1025
|
+
triangle.rotation.x = -Math.PI / 2;
|
|
1026
|
+
triangle.rotation.z = -(index === 2 ? 1 : -1) * Math.PI / 2;
|
|
1027
|
+
triangle1.rotation.x = Math.PI / 2;
|
|
1028
|
+
triangle1.rotation.z = (index === 2 ? 1 : -1) * Math.PI / 2;
|
|
1029
|
+
}
|
|
1030
|
+
triangle.name = 'lineText';
|
|
1031
|
+
triangle1.name = 'lineText';
|
|
1032
|
+
triangle.renderOrder = 2;
|
|
1033
|
+
triangle1.renderOrder = 2;
|
|
1034
|
+
triangle.material.transparent = true;
|
|
1035
|
+
triangle1.material.transparent = true;
|
|
1036
|
+
triangle.material.depthTest = false;
|
|
1037
|
+
triangle1.material.depthTest = false;
|
|
1038
|
+
obj.add(triangle);
|
|
1039
|
+
obj.add(triangle1);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// if (obj.userData.distance <= 50 && obj.userData.distance >= 0.5) {
|
|
1044
|
+
var real_target = obj.userData.target;
|
|
1045
|
+
for (; ((_real_target = real_target) === null || _real_target === void 0 ? void 0 : _real_target.name) != 'pivot';) {
|
|
1046
|
+
var _real_target, _real_target2, _real_target3;
|
|
1047
|
+
if (((_real_target2 = real_target) === null || _real_target2 === void 0 ? void 0 : _real_target2.parent) == null) break;
|
|
1048
|
+
real_target = (_real_target3 = real_target) === null || _real_target3 === void 0 ? void 0 : _real_target3.parent;
|
|
1049
|
+
}
|
|
1050
|
+
// let item3D = obj.parent.parent.parent;
|
|
1051
|
+
// let origin = obj.geometry.vertices[0].clone().applyMatrix4(obj.matrixWorld);
|
|
1052
|
+
// let target = obj.geometry.vertices[1].clone().applyMatrix4(obj.matrixWorld);
|
|
1053
|
+
// let uVec = new Three.Vector3(target.x - origin.x - 0.2, target.y - origin.y - 0.2, target.z - origin.z - 0.2);
|
|
1054
|
+
obj.visible = true;
|
|
1055
|
+
if (dist < 3) obj.visible = false;
|
|
1056
|
+
return obj;
|
|
898
1057
|
}
|
|
899
1058
|
function getLineDistance(obj, layer, isCalcWall, index) {
|
|
900
1059
|
if (obj === undefined) return;
|
|
@@ -953,10 +1112,10 @@ function getLineDistance(obj, layer, isCalcWall, index) {
|
|
|
953
1112
|
obj.geometry.computeBoundingBox();
|
|
954
1113
|
var dist = convert(intersects[i].distance).from('cm').to('in');
|
|
955
1114
|
if (dist > 3) {
|
|
956
|
-
var
|
|
957
|
-
var wid =
|
|
958
|
-
var hei =
|
|
959
|
-
var texture = new Three.Texture(
|
|
1115
|
+
var _canvas2 = getDistanceCanvas(dist, layer);
|
|
1116
|
+
var wid = _canvas2.width / window.innerWidth * 30;
|
|
1117
|
+
var hei = _canvas2.height / window.innerHeight * 30;
|
|
1118
|
+
var texture = new Three.Texture(_canvas2);
|
|
960
1119
|
texture.minFilter = Three.LinearFilter;
|
|
961
1120
|
texture.needsUpdate = true;
|
|
962
1121
|
var geometry = new Three.PlaneGeometry(wid / 5, hei / 5);
|
|
@@ -985,6 +1144,7 @@ function getLineDistance(obj, layer, isCalcWall, index) {
|
|
|
985
1144
|
sprite1.renderOrder = 2;
|
|
986
1145
|
sprite1.scale.set(0.2, 0.1, 0.2);
|
|
987
1146
|
sprite1.layers.set(1);
|
|
1147
|
+
sprite1.material.depthTest = false;
|
|
988
1148
|
obj.add(sprite1);
|
|
989
1149
|
if (obj.parent != null) {
|
|
990
1150
|
// is not lighting
|
|
@@ -1073,12 +1233,12 @@ function getLineDistance(obj, layer, isCalcWall, index) {
|
|
|
1073
1233
|
obj.geometry.attributes.position.array[4] = _newVec.y;
|
|
1074
1234
|
obj.geometry.attributes.position.array[5] = _newVec.z;
|
|
1075
1235
|
obj.geometry.attributes.position.needsUpdate = true;
|
|
1076
|
-
var _dist = formatNumber(distance, DECIMAL_PLACES_2);
|
|
1236
|
+
var _dist = convert(formatNumber(distance, DECIMAL_PLACES_2)).from('cm').to('in');
|
|
1077
1237
|
if (_dist > 3) {
|
|
1078
|
-
var
|
|
1079
|
-
var _wid =
|
|
1080
|
-
var _hei =
|
|
1081
|
-
var _texture = new Three.Texture(
|
|
1238
|
+
var _canvas3 = getDistanceCanvas(_dist, layer);
|
|
1239
|
+
var _wid = _canvas3.width / window.innerWidth * 30;
|
|
1240
|
+
var _hei = _canvas3.height / window.innerHeight * 30;
|
|
1241
|
+
var _texture = new Three.Texture(_canvas3);
|
|
1082
1242
|
_texture.needsUpdate = true;
|
|
1083
1243
|
var _geometry = new Three.PlaneGeometry(_wid / 2, _hei / 2);
|
|
1084
1244
|
_geometry.computeBoundingBox();
|
|
@@ -1808,7 +1968,7 @@ function addArea(sceneData, planData, layer, areaID, catalog, areaActions, mode)
|
|
|
1808
1968
|
layer.lines.forEach(function (data) {
|
|
1809
1969
|
lines.push(data);
|
|
1810
1970
|
});
|
|
1811
|
-
var
|
|
1971
|
+
var _loop3 = function _loop3() {
|
|
1812
1972
|
var data = lines[i];
|
|
1813
1973
|
var realVec = [];
|
|
1814
1974
|
data.vertices.forEach(function (vec) {
|
|
@@ -1821,7 +1981,7 @@ function addArea(sceneData, planData, layer, areaID, catalog, areaActions, mode)
|
|
|
1821
1981
|
}
|
|
1822
1982
|
};
|
|
1823
1983
|
for (var i = 0; i < lines.length; i++) {
|
|
1824
|
-
if (
|
|
1984
|
+
if (_loop3()) break;
|
|
1825
1985
|
}
|
|
1826
1986
|
ceil.translateZ(convert(layer.ceilHeight).from(layer.unit).to(UNIT_CENTIMETER));
|
|
1827
1987
|
pivot.name = 'pivot';
|
|
@@ -1876,6 +2036,7 @@ function addItem(sceneData, planData, layer, itemID, catalog, itemsActions) {
|
|
|
1876
2036
|
if (!catalogElement) catalogElement = catalog.getElement(returnReplaceableDeepSearchType(item.type));
|
|
1877
2037
|
if (!catalogElement) return false;
|
|
1878
2038
|
return catalogElement.render3D(item, layer, sceneData, mode).then(function (item3D) {
|
|
2039
|
+
var _item$properties$getI, _item$properties$getI2, _item$properties$getI3;
|
|
1879
2040
|
if (item3D instanceof Three.LOD) {
|
|
1880
2041
|
planData.sceneGraph.LODs[itemID] = item3D;
|
|
1881
2042
|
}
|
|
@@ -1932,7 +2093,7 @@ function addItem(sceneData, planData, layer, itemID, catalog, itemsActions) {
|
|
|
1932
2093
|
if (child.type === 'Line' && child.geometry.attributes !== undefined) fVLine.push(child);
|
|
1933
2094
|
});
|
|
1934
2095
|
setTimeout(function () {
|
|
1935
|
-
getDistances();
|
|
2096
|
+
getDistances(layer, item);
|
|
1936
2097
|
}, 50);
|
|
1937
2098
|
}
|
|
1938
2099
|
applyOpacity(pivot, opacity);
|
|
@@ -1991,9 +2152,9 @@ function addItem(sceneData, planData, layer, itemID, catalog, itemsActions) {
|
|
|
1991
2152
|
var catid = item.type;
|
|
1992
2153
|
var cat = catalog.elements[catid];
|
|
1993
2154
|
if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
1994
|
-
var width = convert(item.properties.getIn(['width', '_length'])).from('in').to(sceneData.unit);
|
|
1995
|
-
var height = convert(item.properties.getIn(['height', '_length'])).from('in').to(sceneData.unit);
|
|
1996
|
-
var depth = convert(item.properties.getIn(['depth', '_length'])).from('in').to(sceneData.unit);
|
|
2155
|
+
var width = convert(item.properties.getIn(['width', '_length'])).from((_item$properties$getI = item.properties.getIn(['width', '_unit'])) !== null && _item$properties$getI !== void 0 ? _item$properties$getI : 'in').to(sceneData.unit);
|
|
2156
|
+
var height = convert(item.properties.getIn(['height', '_length'])).from((_item$properties$getI2 = item.properties.getIn(['height', '_unit'])) !== null && _item$properties$getI2 !== void 0 ? _item$properties$getI2 : 'in').to(sceneData.unit);
|
|
2157
|
+
var depth = convert(item.properties.getIn(['depth', '_length'])).from((_item$properties$getI3 = item.properties.getIn(['depth', '_unit'])) !== null && _item$properties$getI3 !== void 0 ? _item$properties$getI3 : 'in').to(sceneData.unit);
|
|
1997
2158
|
val.size = {
|
|
1998
2159
|
width: width,
|
|
1999
2160
|
height: height,
|
|
@@ -2047,7 +2208,7 @@ function addItem(sceneData, planData, layer, itemID, catalog, itemsActions) {
|
|
|
2047
2208
|
return itemsActions.selectItem(layer.id, item.id);
|
|
2048
2209
|
});
|
|
2049
2210
|
setTimeout(function () {
|
|
2050
|
-
return getDistances(layer);
|
|
2211
|
+
return getDistances(layer, item);
|
|
2051
2212
|
}, 100);
|
|
2052
2213
|
if (!sceneData.loadFlag && scene_mode == MODE_DRAWING_ITEM_3D) {
|
|
2053
2214
|
itemsActions.endLoading();
|
|
@@ -2874,19 +3035,23 @@ export function createBacksplash(item, layer, planData, scene) {
|
|
|
2874
3035
|
var altItems = [],
|
|
2875
3036
|
flag = false;
|
|
2876
3037
|
wallItems.map(function (wallItem) {
|
|
2877
|
-
var
|
|
2878
|
-
var
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
3038
|
+
var _wallItem$itemInfo, _wallItem$itemInfo2;
|
|
3039
|
+
var altitude = (_wallItem$itemInfo = wallItem.itemInfo) === null || _wallItem$itemInfo === void 0 || (_wallItem$itemInfo = _wallItem$itemInfo.properties) === null || _wallItem$itemInfo === void 0 ? void 0 : _wallItem$itemInfo.get('altitude').get('_length');
|
|
3040
|
+
var altitudeUnit = ((_wallItem$itemInfo2 = wallItem.itemInfo) === null || _wallItem$itemInfo2 === void 0 || (_wallItem$itemInfo2 = _wallItem$itemInfo2.properties) === null || _wallItem$itemInfo2 === void 0 ? void 0 : _wallItem$itemInfo2.get('altitude').get('_unit')) || 'cm';
|
|
3041
|
+
if (!isEmpty(altitude) && !isEmpty(altitudeUnit)) {
|
|
3042
|
+
altitude = convert(altitude).from(altitudeUnit).to('cm');
|
|
3043
|
+
altItems.push({
|
|
3044
|
+
x: wallItem.pos.x,
|
|
3045
|
+
width: wallItem.size.width,
|
|
3046
|
+
altitude: altitude
|
|
3047
|
+
});
|
|
3048
|
+
}
|
|
2885
3049
|
});
|
|
2886
3050
|
layer.holes.map(function (hole) {
|
|
2887
|
-
var
|
|
2888
|
-
var
|
|
2889
|
-
|
|
3051
|
+
var _hole$properties, _hole$properties2;
|
|
3052
|
+
var width = (_hole$properties = hole.properties) === null || _hole$properties === void 0 ? void 0 : _hole$properties.getIn(['width', 'length']);
|
|
3053
|
+
var altitude = (_hole$properties2 = hole.properties) === null || _hole$properties2 === void 0 ? void 0 : _hole$properties2.getIn(['altitude', 'length']);
|
|
3054
|
+
if (!isEmpty(width) && !isEmpty(altitude)) altItems.push({
|
|
2890
3055
|
x: hole.x,
|
|
2891
3056
|
width: width,
|
|
2892
3057
|
altitude: altitude
|
|
@@ -3064,23 +3229,18 @@ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag)
|
|
|
3064
3229
|
// let layoutType = molding.items[0].layoutpos;
|
|
3065
3230
|
// let visible = molding.items[0];
|
|
3066
3231
|
molding.pointGroups.forEach(function (pointGroup) {
|
|
3232
|
+
var _child$width_unit, _child$height_unit, _child$length_unit;
|
|
3067
3233
|
var geometry = new Three.BufferGeometry();
|
|
3068
3234
|
var length = data.length; //point array
|
|
3069
|
-
var
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
}
|
|
3079
|
-
temp_unit = child.length_unit;
|
|
3080
|
-
if (temp_unit === 'inch') {
|
|
3081
|
-
child.length = convert(child.length).from('in').to('cm');
|
|
3082
|
-
child.length_unit = 'cm';
|
|
3083
|
-
}
|
|
3235
|
+
var widthUnit = child.width_unit === 'inch' ? 'in' : (_child$width_unit = child.width_unit) !== null && _child$width_unit !== void 0 ? _child$width_unit : 'in';
|
|
3236
|
+
var heightUnit = child.height_unit === 'inch' ? 'in' : (_child$height_unit = child.height_unit) !== null && _child$height_unit !== void 0 ? _child$height_unit : 'in';
|
|
3237
|
+
var lengthUnit = child.length_unit === 'inch' ? 'in' : (_child$length_unit = child.length_unit) !== null && _child$length_unit !== void 0 ? _child$length_unit : 'in';
|
|
3238
|
+
child.height = convert(child.height).from(heightUnit).to('cm');
|
|
3239
|
+
child.height_unit = 'cm';
|
|
3240
|
+
child.width = convert(child.width).from(widthUnit).to('cm');
|
|
3241
|
+
child.width_unit = 'cm';
|
|
3242
|
+
child.length = convert(child.length).from(lengthUnit).to('cm');
|
|
3243
|
+
child.length_unit = 'cm';
|
|
3084
3244
|
geometry.needsUpdate = true;
|
|
3085
3245
|
geometry = moldingVertices(pointGroup, geometry, data, child, svg_width, svg_height, molding.pointGroups.length);
|
|
3086
3246
|
var total = geometry.attributes.position.count;
|
|
@@ -3390,7 +3550,7 @@ export function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
|
|
|
3390
3550
|
if (isEmpty(filteredNewMGList)) {
|
|
3391
3551
|
return true;
|
|
3392
3552
|
}
|
|
3393
|
-
var
|
|
3553
|
+
var _loop4 = function _loop4() {
|
|
3394
3554
|
var newMG = filteredNewMGList[k];
|
|
3395
3555
|
if (oldMG.items.some(function (it) {
|
|
3396
3556
|
return it.id === selItem.id;
|
|
@@ -3443,7 +3603,7 @@ export function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
|
|
|
3443
3603
|
},
|
|
3444
3604
|
_ret;
|
|
3445
3605
|
for (var k = 0; k < filteredNewMGList.length; k++) {
|
|
3446
|
-
_ret =
|
|
3606
|
+
_ret = _loop4();
|
|
3447
3607
|
if (_ret) return _ret.v;
|
|
3448
3608
|
}
|
|
3449
3609
|
return true;
|
|
@@ -3612,7 +3772,7 @@ export function addWarningBox(itemId, altitude, planData) {
|
|
|
3612
3772
|
deleteSpecifiedMeshObjects('WarningBox' + itemId);
|
|
3613
3773
|
var item3D = planData.sceneGraph.layers[planData.sceneData.selectedLayer].items[itemId];
|
|
3614
3774
|
if (item3D == undefined) return;
|
|
3615
|
-
var altitudeLength =
|
|
3775
|
+
var altitudeLength = altitude;
|
|
3616
3776
|
var sBounding = item3D.children[0].userData;
|
|
3617
3777
|
var width = sBounding.max.x - sBounding.min.x;
|
|
3618
3778
|
var height = sBounding.max.y - sBounding.min.y;
|
|
@@ -816,17 +816,19 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
816
816
|
this.snap = function (obj, layer) {
|
|
817
817
|
// snap operation
|
|
818
818
|
var target = obj.userData.target;
|
|
819
|
+
if (isEmpty(target)) return;
|
|
819
820
|
for (; target.parent != null;) {
|
|
820
821
|
if (target.name == 'pivot') break;
|
|
821
822
|
target = target.parent;
|
|
822
823
|
}
|
|
823
824
|
var source = obj.parent.parent.parent;
|
|
824
825
|
if (target.userData.type == 'item') {
|
|
826
|
+
var _item$properties$getI;
|
|
825
827
|
var sRot = layer.getIn(['items', source.userData.itemId]).rotation;
|
|
826
828
|
var tRot = layer.getIn(['items', target.userData.itemId]) ? layer.getIn(['items', target.userData.itemId]).rotation : 0;
|
|
827
829
|
var item = layer.getIn(['items', source.userData.itemId]);
|
|
828
830
|
var layoutType = item.layoutpos;
|
|
829
|
-
var altitudeLength = convert(item.properties.getIn(['altitude', '_length'])).from('in').to('cm');
|
|
831
|
+
var altitudeLength = convert(item.properties.getIn(['altitude', '_length'])).from((_item$properties$getI = item.properties.getIn(['altitude', '_unit'])) !== null && _item$properties$getI !== void 0 ? _item$properties$getI : 'in').to('cm');
|
|
830
832
|
var sBounding = source.children[0].userData;
|
|
831
833
|
var tBounding = target.children[0].userData;
|
|
832
834
|
var tPos = target.position.clone();
|
|
@@ -926,8 +928,9 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
926
928
|
snapFlag = false;
|
|
927
929
|
return;
|
|
928
930
|
} else {
|
|
931
|
+
var _item3$properties$get;
|
|
929
932
|
var _layoutType = _item3.layoutpos;
|
|
930
|
-
var _altitudeLength = convert(_item3.properties.getIn(['altitude', '_length'])).from('in').to('cm');
|
|
933
|
+
var _altitudeLength = convert(_item3.properties.getIn(['altitude', '_length'])).from((_item3$properties$get = _item3.properties.getIn(['altitude', '_unit'])) !== null && _item3$properties$get !== void 0 ? _item3$properties$get : 'in').to('cm');
|
|
931
934
|
var _sBounding = source.children[0].userData;
|
|
932
935
|
var _width = _sBounding.max.x - _sBounding.min.x;
|
|
933
936
|
var _height = _sBounding.max.y - _sBounding.min.y;
|
|
@@ -1359,10 +1362,12 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1359
1362
|
}
|
|
1360
1363
|
};
|
|
1361
1364
|
this.mouseUpEvent = function (event) {
|
|
1365
|
+
var _selectedObject;
|
|
1362
1366
|
var internalType = ''; // internalEvent type - select/drag/draw
|
|
1363
1367
|
var selectedElement; // internalEvent data
|
|
1364
1368
|
firstMove = 0;
|
|
1365
1369
|
var altitude = 0;
|
|
1370
|
+
var curLayer = _this2.props.state.scene.getIn(['layers', (_selectedObject = selectedObject) === null || _selectedObject === void 0 ? void 0 : _selectedObject.layerID]);
|
|
1366
1371
|
if (allItemRect && allItemRect.cur && allItemRect.cur.itemInfo !== undefined) {
|
|
1367
1372
|
var properties = allItemRect.cur.itemInfo.properties;
|
|
1368
1373
|
altitude = properties.getIn(['altitude', '_length']);
|
|
@@ -1383,7 +1388,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1383
1388
|
actions.itemsActions.endDrawingItem(_this2.props.state.scene.selectedLayer, sPoint.x, sPoint.y);
|
|
1384
1389
|
} else {
|
|
1385
1390
|
removeSnapBox();
|
|
1386
|
-
var polygon = GeometryUtils.getPoylgonPoints(layer);
|
|
1391
|
+
var polygon = GeometryUtils.getPoylgonPoints(curLayer !== null && curLayer !== void 0 ? curLayer : layer);
|
|
1387
1392
|
// if cursor is outside of room
|
|
1388
1393
|
if (polygon.length > 0 && !GeometryUtils.ContainsPoint(polygon, Point.x, Point.y)) {
|
|
1389
1394
|
actions.itemsActions.endDrawingItem(_this2.props.state.scene.selectedLayer, sPoint.x, sPoint.y);
|
|
@@ -1477,8 +1482,8 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1477
1482
|
}
|
|
1478
1483
|
gridMatrix.copy(gridPlane.matrixWorld).invert();
|
|
1479
1484
|
var addItemToolObj = function addItemToolObj() {
|
|
1480
|
-
var _planData$sceneGraph,
|
|
1481
|
-
var selectedItem = (_planData$sceneGraph = planData.sceneGraph) === null || _planData$sceneGraph === void 0 || (_planData$sceneGraph = _planData$sceneGraph.layers[selectedObject.layerID]) === null || _planData$sceneGraph === void 0 ? void 0 : _planData$sceneGraph.items[(
|
|
1485
|
+
var _planData$sceneGraph, _selectedObject2, _intersects$_i;
|
|
1486
|
+
var selectedItem = (_planData$sceneGraph = planData.sceneGraph) === null || _planData$sceneGraph === void 0 || (_planData$sceneGraph = _planData$sceneGraph.layers[selectedObject.layerID]) === null || _planData$sceneGraph === void 0 ? void 0 : _planData$sceneGraph.items[(_selectedObject2 = selectedObject) === null || _selectedObject2 === void 0 ? void 0 : _selectedObject2.itemID];
|
|
1482
1487
|
if (isUndefined(selectedItem)) return;
|
|
1483
1488
|
selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
|
|
1484
1489
|
var itemPos = selectedItem.position.clone();
|
|
@@ -1511,8 +1516,9 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1511
1516
|
}
|
|
1512
1517
|
isSelected = true;
|
|
1513
1518
|
setTimeout(function () {
|
|
1514
|
-
|
|
1519
|
+
var _curLayer$id;
|
|
1515
1520
|
addItemToolObj();
|
|
1521
|
+
getDistances(curLayer !== null && curLayer !== void 0 ? curLayer : layer, selectedElement);
|
|
1516
1522
|
_this2.setState({
|
|
1517
1523
|
toolObj: toolObj
|
|
1518
1524
|
});
|
|
@@ -1522,8 +1528,8 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1522
1528
|
// pointArray.push([fVLine[1].userData.distance, -90]);
|
|
1523
1529
|
// pointArray.push([fVLine[2].userData.distance, 180]);
|
|
1524
1530
|
// pointArray.push([fVLine[3].userData.distance, 0]);
|
|
1525
|
-
pointArray = GeometryUtils.calcDistancesFromItemToWalls(selectedElement, layer).PointArray;
|
|
1526
|
-
actions.itemsActions.storeDistArray(layer.id, selectedObject.itemID, pointArray);
|
|
1531
|
+
pointArray = GeometryUtils.calcDistancesFromItemToWalls(selectedElement, curLayer !== null && curLayer !== void 0 ? curLayer : layer).PointArray;
|
|
1532
|
+
actions.itemsActions.storeDistArray((_curLayer$id = curLayer === null || curLayer === void 0 ? void 0 : curLayer.id) !== null && _curLayer$id !== void 0 ? _curLayer$id : layer.id, selectedObject.itemID, pointArray);
|
|
1527
1533
|
internalType = internalType ? internalType : INTERNAL_EVENT_SELECT_ELEMENT;
|
|
1528
1534
|
sendInternalEvent(internalType, selectedElement, pointArray);
|
|
1529
1535
|
});
|
|
@@ -1575,11 +1581,11 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1575
1581
|
bRotate = false;
|
|
1576
1582
|
bMoveUP = false;
|
|
1577
1583
|
if (isSelected) {
|
|
1578
|
-
prepareSnap(layer);
|
|
1584
|
+
prepareSnap(curLayer !== null && curLayer !== void 0 ? curLayer : layer);
|
|
1579
1585
|
selectedObj = allItemRect.cur;
|
|
1580
1586
|
}
|
|
1581
1587
|
} else {
|
|
1582
|
-
var _planData$sceneGraph2,
|
|
1588
|
+
var _planData$sceneGraph2, _selectedObject3, _selectedObject4;
|
|
1583
1589
|
visibleTransformBox(false);
|
|
1584
1590
|
var alti = 0;
|
|
1585
1591
|
if (allItemRect && allItemRect.cur && allItemRect.cur.itemInfo !== undefined) {
|
|
@@ -1589,7 +1595,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1589
1595
|
alti = convert(alti).from(_unit2).to(_this2.props.state.scene.unit);
|
|
1590
1596
|
}
|
|
1591
1597
|
getPoint(event, alti);
|
|
1592
|
-
var _selectedItem = planData === null || planData === void 0 || (_planData$sceneGraph2 = planData.sceneGraph) === null || _planData$sceneGraph2 === void 0 || (_planData$sceneGraph2 = _planData$sceneGraph2.layers[(
|
|
1598
|
+
var _selectedItem = planData === null || planData === void 0 || (_planData$sceneGraph2 = planData.sceneGraph) === null || _planData$sceneGraph2 === void 0 || (_planData$sceneGraph2 = _planData$sceneGraph2.layers[(_selectedObject3 = selectedObject) === null || _selectedObject3 === void 0 ? void 0 : _selectedObject3.layerID]) === null || _planData$sceneGraph2 === void 0 ? void 0 : _planData$sceneGraph2.items[(_selectedObject4 = selectedObject) === null || _selectedObject4 === void 0 ? void 0 : _selectedObject4.itemID];
|
|
1593
1599
|
if (isSelected && !isEmpty(_selectedItem)) addItemToolObj();
|
|
1594
1600
|
if (bRotate) {
|
|
1595
1601
|
_this2.setState({
|
|
@@ -1627,7 +1633,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1627
1633
|
removeSnapBox();
|
|
1628
1634
|
actions.sceneActions.updateMovingState(true);
|
|
1629
1635
|
if (isSelected === true) {
|
|
1630
|
-
prepareSnap(layer);
|
|
1636
|
+
prepareSnap(curLayer !== null && curLayer !== void 0 ? curLayer : layer);
|
|
1631
1637
|
selectedObj = allItemRect.cur;
|
|
1632
1638
|
}
|
|
1633
1639
|
}
|
|
@@ -2026,8 +2032,9 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
2026
2032
|
// handle snapBox, distArray, backsplash
|
|
2027
2033
|
this.handleAfterMovingItem = function () {
|
|
2028
2034
|
var layer = _this2.props.state.scene.getIn(['layers', selectedObject.layerID]);
|
|
2035
|
+
var item = layer.getIn(['items', selectedObject.itemID]);
|
|
2029
2036
|
var item3D = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
|
|
2030
|
-
getDistances(layer);
|
|
2037
|
+
getDistances(layer, item);
|
|
2031
2038
|
var pointArray = [],
|
|
2032
2039
|
cnt = 0;
|
|
2033
2040
|
pointArray.push([fVLine[0].userData.distance, 90]);
|
|
@@ -2066,7 +2073,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
2066
2073
|
if (minDis < snapDelta && !snapFlag) {
|
|
2067
2074
|
_this2.snap(snapObj, layer);
|
|
2068
2075
|
snapFlag = true;
|
|
2069
|
-
getDistances(layer);
|
|
2076
|
+
getDistances(layer, item);
|
|
2070
2077
|
var _i13 = 0;
|
|
2071
2078
|
for (_i13 = 0; _i13 < fVLine.length; _i13++) {
|
|
2072
2079
|
if (fVLine[_i13].userData.distance < snapDelta) {
|
package/es/constants.js
CHANGED
|
@@ -751,6 +751,7 @@ export var INTERNAL_EVENT_DRAW_ELEMENT = 'INTERNAL_EVENT_DRAW_ELEMENT';
|
|
|
751
751
|
export var INTERNAL_EVENT_ROTATE_ELEMENT = 'INTERNAL_EVENT_ROTATE_ELEMENT';
|
|
752
752
|
export var INTERNAL_EVENT_REPLACE_CABINET = 'INTERNAL_EVENT_REPLACE_CABINET';
|
|
753
753
|
export var INTERNAL_EVENT_START_DRAW_WALL = 'INTERNAL_EVENT_START_DRAW_WALL';
|
|
754
|
+
export var INTERNAL_EVENT_TOGGLE_TO_ELEVATION = 'INTERNAL_EVENT_TOGGLE_TO_ELEVATION';
|
|
754
755
|
|
|
755
756
|
// room shape type
|
|
756
757
|
export var ROOM_SHAPE_TYPE = {
|
package/es/index.js
CHANGED
|
@@ -12,6 +12,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
12
12
|
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; }
|
|
13
13
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
14
14
|
import React from 'react';
|
|
15
|
+
import * as Three from 'three';
|
|
15
16
|
import LiteRenderer from "./LiteRenderer";
|
|
16
17
|
import { createRoot } from 'react-dom/client';
|
|
17
18
|
var ROOT_KEY = '__kitchenSimulatorRoot__';
|
|
@@ -22,6 +23,18 @@ function nextFrame() {
|
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
// DIY-714 [Temp Fix] Rewrite API URLs
|
|
27
|
+
var API_HOST_REGEX = /(https?:\/\/)?(api\.diydesignspace\.com|api\.addovisuals\.com|127\.0\.0\.1:4002)/;
|
|
28
|
+
var API_HOST_REPLACEMENT = 'https://api-old.diydesignspace.com';
|
|
29
|
+
function rewriteApiUrl(url) {
|
|
30
|
+
return typeof url === 'string' ? url.replace(API_HOST_REGEX, API_HOST_REPLACEMENT) : url;
|
|
31
|
+
}
|
|
32
|
+
var originalTextureLoad = Three.TextureLoader.prototype.load;
|
|
33
|
+
Three.TextureLoader.prototype.load = function (url, onLoad, onProgress, onError) {
|
|
34
|
+
var newUrl = rewriteApiUrl(url);
|
|
35
|
+
return originalTextureLoad.call(this, newUrl, onLoad, onProgress, onError);
|
|
36
|
+
};
|
|
37
|
+
|
|
25
38
|
/**
|
|
26
39
|
* Track 3D asset network activity (gltf/glb/bin/textures/hdr/etc)
|
|
27
40
|
* Ref-counted global install so multiple instances don't clobber each other.
|
|
@@ -144,7 +157,9 @@ function installGltfTracker() {
|
|
|
144
157
|
var _len3,
|
|
145
158
|
args,
|
|
146
159
|
_key3,
|
|
147
|
-
|
|
160
|
+
input,
|
|
161
|
+
init,
|
|
162
|
+
newUrl,
|
|
148
163
|
track,
|
|
149
164
|
_args2 = arguments;
|
|
150
165
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
@@ -153,19 +168,25 @@ function installGltfTracker() {
|
|
|
153
168
|
for (_len3 = _args2.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
154
169
|
args[_key3] = _args2[_key3];
|
|
155
170
|
}
|
|
156
|
-
|
|
157
|
-
|
|
171
|
+
input = args[0], init = args[1]; // DIY-714 [Temp Fix] Rewrite API URLs
|
|
172
|
+
if (typeof input === 'string') {
|
|
173
|
+
input = rewriteApiUrl(input);
|
|
174
|
+
} else if (input instanceof Request) {
|
|
175
|
+
newUrl = rewriteApiUrl(input.url);
|
|
176
|
+
input = new Request(newUrl, input);
|
|
177
|
+
}
|
|
178
|
+
track = is3dAssetUrl(input);
|
|
158
179
|
if (track) {
|
|
159
180
|
_context2.next = 1;
|
|
160
181
|
break;
|
|
161
182
|
}
|
|
162
|
-
return _context2.abrupt("return", g.originalFetch.
|
|
183
|
+
return _context2.abrupt("return", g.originalFetch.call(this, input, init));
|
|
163
184
|
case 1:
|
|
164
185
|
g.inFlight += 1;
|
|
165
186
|
notify();
|
|
166
187
|
_context2.prev = 2;
|
|
167
188
|
_context2.next = 3;
|
|
168
|
-
return g.originalFetch.
|
|
189
|
+
return g.originalFetch.call(this, input, init);
|
|
169
190
|
case 3:
|
|
170
191
|
return _context2.abrupt("return", _context2.sent);
|
|
171
192
|
case 4:
|