door_models 5.5.4 → 5.5.6
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/dist/index.cjs.js +168 -242
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +168 -242
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -396,6 +396,7 @@ const ConfiguratorProvider = _ref => {
|
|
|
396
396
|
const [bodyType, setBodyType] = React.useState("40");
|
|
397
397
|
const [exteriorFanlightType, setExteriorFanlightType] = React.useState("WPFL");
|
|
398
398
|
const doorHeight = 0;
|
|
399
|
+
const [initialDoorHeight, setInitialDoorHeight] = React.useState(null);
|
|
399
400
|
const [newPivotPosition, setNewPivotPosition] = React.useState(0);
|
|
400
401
|
const [, setParseMessage] = React.useState({
|
|
401
402
|
type: "",
|
|
@@ -412,7 +413,7 @@ const ConfiguratorProvider = _ref => {
|
|
|
412
413
|
if (initialMaterials) {
|
|
413
414
|
setMaterials(initialMaterials);
|
|
414
415
|
}
|
|
415
|
-
}, [
|
|
416
|
+
}, []);
|
|
416
417
|
const handleParseCpid = React.useCallback(cpidToParse => {
|
|
417
418
|
const showMessage = function (text) {
|
|
418
419
|
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "error";
|
|
@@ -749,6 +750,8 @@ const ConfiguratorProvider = _ref => {
|
|
|
749
750
|
glassDepth,
|
|
750
751
|
setGlassDepth,
|
|
751
752
|
handleParseCpid,
|
|
753
|
+
initialDoorHeight,
|
|
754
|
+
setInitialDoorHeight,
|
|
752
755
|
newPivotPosition,
|
|
753
756
|
setNewPivotPosition,
|
|
754
757
|
doorHeight,
|
|
@@ -933,79 +936,11 @@ const useDoorMaterials = function () {
|
|
|
933
936
|
}, [materialsProp, textureMap, textureUrls]);
|
|
934
937
|
};
|
|
935
938
|
|
|
936
|
-
/******************************************************************************
|
|
937
|
-
Copyright (c) Microsoft Corporation.
|
|
938
|
-
|
|
939
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
940
|
-
purpose with or without fee is hereby granted.
|
|
941
|
-
|
|
942
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
943
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
944
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
945
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
946
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
947
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
948
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
949
|
-
***************************************************************************** */
|
|
950
|
-
|
|
951
|
-
var __assign = function() {
|
|
952
|
-
__assign = Object.assign || function __assign(t) {
|
|
953
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
954
|
-
s = arguments[i];
|
|
955
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
956
|
-
}
|
|
957
|
-
return t;
|
|
958
|
-
};
|
|
959
|
-
return __assign.apply(this, arguments);
|
|
960
|
-
};
|
|
961
|
-
|
|
962
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
963
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
964
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
965
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
966
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
967
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
968
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
969
|
-
});
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
function __generator(thisArg, body) {
|
|
973
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
974
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
975
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
976
|
-
function step(op) {
|
|
977
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
978
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
979
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
980
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
981
|
-
switch (op[0]) {
|
|
982
|
-
case 0: case 1: t = op; break;
|
|
983
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
984
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
985
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
986
|
-
default:
|
|
987
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
988
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
989
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
990
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
991
|
-
if (t[2]) _.ops.pop();
|
|
992
|
-
_.trys.pop(); continue;
|
|
993
|
-
}
|
|
994
|
-
op = body.call(thisArg, _);
|
|
995
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
996
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1001
|
-
var e = new Error(message);
|
|
1002
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1003
|
-
};
|
|
1004
|
-
|
|
1005
939
|
// Three.js Y-up -> IFC / CAD coords:
|
|
1006
940
|
// IFC X = x
|
|
1007
941
|
// IFC Y = z (depth)
|
|
1008
942
|
// IFC Z = y (height)
|
|
943
|
+
|
|
1009
944
|
/**
|
|
1010
945
|
* Convert a Three.js Vector3 (X, Y, Z) into IFC / CAD-style coordinates (X, Z, Y).
|
|
1011
946
|
*
|
|
@@ -1029,22 +964,23 @@ function threeToIfcCoords(vec3) {
|
|
|
1029
964
|
z: vec3.y
|
|
1030
965
|
};
|
|
1031
966
|
}
|
|
967
|
+
|
|
1032
968
|
/**
|
|
1033
969
|
* Trigger a file download in the browser from a Blob.
|
|
1034
970
|
*
|
|
1035
971
|
* @param {Blob} blob - File data as a Blob.
|
|
1036
972
|
* @param {string} name - File name shown to the user (e.g. "project_123.dxf").
|
|
1037
973
|
*/
|
|
974
|
+
|
|
1038
975
|
function downloadBlob(blob, name) {
|
|
1039
|
-
|
|
1040
|
-
|
|
976
|
+
const a = document.createElement("a");
|
|
977
|
+
const url = URL.createObjectURL(blob);
|
|
1041
978
|
a.href = url;
|
|
1042
979
|
a.download = name;
|
|
1043
980
|
a.click();
|
|
1044
|
-
setTimeout(
|
|
1045
|
-
return URL.revokeObjectURL(url);
|
|
1046
|
-
}, 100);
|
|
981
|
+
setTimeout(() => URL.revokeObjectURL(url), 100);
|
|
1047
982
|
}
|
|
983
|
+
|
|
1048
984
|
/**
|
|
1049
985
|
* useDxfExportPayload
|
|
1050
986
|
*
|
|
@@ -1102,19 +1038,17 @@ function downloadBlob(blob, name) {
|
|
|
1102
1038
|
* }) => Promise<void>
|
|
1103
1039
|
* }}
|
|
1104
1040
|
*/
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
rootGroupRef
|
|
1109
|
-
getPropsForMesh
|
|
1110
|
-
|
|
1111
|
-
projectNumber = _c === void 0 ? "1987348" : _c,
|
|
1112
|
-
// used for naming (DXF file, project label)
|
|
1113
|
-
_d = _b.version,
|
|
1041
|
+
|
|
1042
|
+
function useDxfExportPayload() {
|
|
1043
|
+
let {
|
|
1044
|
+
rootGroupRef,
|
|
1045
|
+
getPropsForMesh,
|
|
1046
|
+
projectNumber = "1987348",
|
|
1114
1047
|
// used for naming (DXF file, project label)
|
|
1115
|
-
version =
|
|
1116
|
-
|
|
1117
|
-
|
|
1048
|
+
version = "V1.0" // used for naming (DXF file version)
|
|
1049
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1050
|
+
const collectElementsFromGroup = React.useCallback(() => {
|
|
1051
|
+
const root = rootGroupRef === null || rootGroupRef === void 0 ? void 0 : rootGroupRef.current;
|
|
1118
1052
|
if (!root) {
|
|
1119
1053
|
console.warn("[DXF-PAYLOAD] rootGroupRef.current is null, nothing to export");
|
|
1120
1054
|
alert("DXF export aborted: no export group found in the scene.");
|
|
@@ -1129,28 +1063,30 @@ function useDxfExportPayload(_a) {
|
|
|
1129
1063
|
countsByType: {}
|
|
1130
1064
|
};
|
|
1131
1065
|
}
|
|
1066
|
+
|
|
1132
1067
|
// Make sure transforms are up to date for the whole subtree
|
|
1133
1068
|
root.updateWorldMatrix(true, true);
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
root.traverse(
|
|
1141
|
-
var
|
|
1142
|
-
|
|
1069
|
+
const elements = [];
|
|
1070
|
+
let meshCount = 0;
|
|
1071
|
+
let vertexCount = 0;
|
|
1072
|
+
let triangleCount = 0;
|
|
1073
|
+
const tmpLocal = new THREE__namespace.Vector3();
|
|
1074
|
+
const tmpWorld = new THREE__namespace.Vector3();
|
|
1075
|
+
root.traverse(obj => {
|
|
1076
|
+
var _mesh$userData4;
|
|
1077
|
+
const mesh = obj;
|
|
1143
1078
|
if (!mesh.isMesh) return;
|
|
1079
|
+
|
|
1144
1080
|
// Skip helper meshes (like invisible selection boxes)
|
|
1145
|
-
|
|
1081
|
+
const mat = mesh.material;
|
|
1146
1082
|
if (mat && mat.transparent && mat.opacity === 0) return;
|
|
1147
|
-
|
|
1083
|
+
const geometry = mesh.geometry;
|
|
1148
1084
|
if (!geometry || !geometry.attributes || !geometry.attributes.position) {
|
|
1149
1085
|
console.warn("[DXF-PAYLOAD] Mesh skipped: missing geometry or position attribute", mesh.name || mesh.uuid);
|
|
1150
1086
|
return;
|
|
1151
1087
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1088
|
+
const positionAttr = geometry.getAttribute("position");
|
|
1089
|
+
const vCount = positionAttr.count;
|
|
1154
1090
|
if (vCount < 3) {
|
|
1155
1091
|
console.warn("[DXF-PAYLOAD] Mesh skipped: fewer than 3 vertices", {
|
|
1156
1092
|
name: mesh.name,
|
|
@@ -1160,94 +1096,102 @@ function useDxfExportPayload(_a) {
|
|
|
1160
1096
|
}
|
|
1161
1097
|
meshCount += 1;
|
|
1162
1098
|
vertexCount += vCount;
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1099
|
+
const localPositions = new Array(vCount * 3);
|
|
1100
|
+
const worldPositions = new Array(vCount * 3);
|
|
1101
|
+
const worldMatrix = mesh.matrixWorld;
|
|
1102
|
+
|
|
1166
1103
|
// Build local + world positions (already in IFC axes)
|
|
1167
|
-
for (
|
|
1104
|
+
for (let i = 0; i < vCount; i++) {
|
|
1168
1105
|
tmpLocal.fromBufferAttribute(positionAttr, i);
|
|
1106
|
+
|
|
1169
1107
|
// Local IFC coords (no world matrix): x, z, y
|
|
1170
|
-
|
|
1108
|
+
const li = threeToIfcCoords(tmpLocal);
|
|
1171
1109
|
localPositions[3 * i + 0] = li.x;
|
|
1172
1110
|
localPositions[3 * i + 1] = li.y;
|
|
1173
1111
|
localPositions[3 * i + 2] = li.z;
|
|
1112
|
+
|
|
1174
1113
|
// World IFC coords
|
|
1175
1114
|
tmpWorld.copy(tmpLocal).applyMatrix4(worldMatrix);
|
|
1176
|
-
|
|
1115
|
+
const wi = threeToIfcCoords(tmpWorld);
|
|
1177
1116
|
worldPositions[3 * i + 0] = wi.x;
|
|
1178
1117
|
worldPositions[3 * i + 1] = wi.y;
|
|
1179
1118
|
worldPositions[3 * i + 2] = wi.z;
|
|
1180
1119
|
}
|
|
1120
|
+
|
|
1181
1121
|
// Indices (triangles)
|
|
1182
|
-
|
|
1122
|
+
let indices;
|
|
1183
1123
|
if (geometry.index) {
|
|
1184
1124
|
indices = Array.from(geometry.index.array);
|
|
1185
1125
|
} else {
|
|
1186
1126
|
// Assume non-indexed geometry is already triangulated (3 verrtices pe tri)
|
|
1187
|
-
|
|
1188
|
-
|
|
1127
|
+
const triCount = Math.floor(vCount / 3);
|
|
1128
|
+
const indexCount = triCount * 3;
|
|
1189
1129
|
indices = new Array(indexCount);
|
|
1190
|
-
for (
|
|
1130
|
+
for (let i = 0; i < indexCount; i++) {
|
|
1191
1131
|
indices[i] = i;
|
|
1192
1132
|
}
|
|
1193
1133
|
}
|
|
1134
|
+
|
|
1194
1135
|
// Optional flip: mimic current buildElementsForIfcAndDxf behaviour
|
|
1195
1136
|
try {
|
|
1196
1137
|
if (worldMatrix.determinant() >= 0) {
|
|
1197
|
-
for (
|
|
1198
|
-
|
|
1138
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
1139
|
+
const tmp = indices[i + 1];
|
|
1199
1140
|
indices[i + 1] = indices[i + 2];
|
|
1200
1141
|
indices[i + 2] = tmp;
|
|
1201
1142
|
}
|
|
1202
1143
|
}
|
|
1203
|
-
} catch (
|
|
1144
|
+
} catch (_unused) {
|
|
1204
1145
|
// ignore
|
|
1205
1146
|
}
|
|
1206
1147
|
triangleCount += indices.length / 3;
|
|
1148
|
+
|
|
1207
1149
|
// IFC type + props
|
|
1208
|
-
|
|
1209
|
-
|
|
1150
|
+
let ifcType = "IfcBuildingElementProxy";
|
|
1151
|
+
let props = {};
|
|
1210
1152
|
if (typeof getPropsForMesh === "function") {
|
|
1211
|
-
|
|
1153
|
+
const extra = getPropsForMesh(mesh) || {};
|
|
1212
1154
|
ifcType = extra.ifcType || ifcType;
|
|
1213
1155
|
props = extra.props || props;
|
|
1214
1156
|
} else {
|
|
1157
|
+
var _mesh$userData, _mesh$userData2, _mesh$userData3, _mesh$material;
|
|
1215
1158
|
// Fallback: derive from userData / type (not used in your current setup)
|
|
1216
|
-
ifcType = ((
|
|
1217
|
-
|
|
1218
|
-
props =
|
|
1219
|
-
materialName: (
|
|
1159
|
+
ifcType = ((_mesh$userData = mesh.userData) === null || _mesh$userData === void 0 ? void 0 : _mesh$userData.ifcType) || (((_mesh$userData2 = mesh.userData) === null || _mesh$userData2 === void 0 ? void 0 : _mesh$userData2.type) === "door" ? "IfcDoor" : ((_mesh$userData3 = mesh.userData) === null || _mesh$userData3 === void 0 ? void 0 : _mesh$userData3.type) === "wall" ? "IfcWall" : "IfcBuildingElementProxy");
|
|
1160
|
+
const color = mesh.material && mesh.material.color && typeof mesh.material.color.getHexString === "function" ? "#".concat(mesh.material.color.getHexString()) : undefined;
|
|
1161
|
+
props = _objectSpread2(_objectSpread2({}, mesh.userData), {}, {
|
|
1162
|
+
materialName: (_mesh$material = mesh.material) === null || _mesh$material === void 0 ? void 0 : _mesh$material.name,
|
|
1220
1163
|
colorHex: color
|
|
1221
1164
|
});
|
|
1222
1165
|
}
|
|
1223
|
-
|
|
1166
|
+
const element = {
|
|
1224
1167
|
uuid: mesh.uuid,
|
|
1225
|
-
name: mesh.name || ((
|
|
1226
|
-
ifcType
|
|
1227
|
-
props
|
|
1228
|
-
worldPositions
|
|
1229
|
-
localPositions
|
|
1168
|
+
name: mesh.name || ((_mesh$userData4 = mesh.userData) === null || _mesh$userData4 === void 0 ? void 0 : _mesh$userData4.name) || "",
|
|
1169
|
+
ifcType,
|
|
1170
|
+
props,
|
|
1171
|
+
worldPositions,
|
|
1172
|
+
localPositions,
|
|
1230
1173
|
matrixWorld: Array.from(worldMatrix.elements),
|
|
1231
|
-
indices
|
|
1174
|
+
indices
|
|
1232
1175
|
};
|
|
1233
1176
|
elements.push(element);
|
|
1234
1177
|
});
|
|
1235
|
-
|
|
1236
|
-
meshCount
|
|
1178
|
+
const stats = {
|
|
1179
|
+
meshCount,
|
|
1237
1180
|
elementCount: elements.length,
|
|
1238
|
-
vertexCount
|
|
1239
|
-
triangleCount
|
|
1181
|
+
vertexCount,
|
|
1182
|
+
triangleCount
|
|
1240
1183
|
};
|
|
1184
|
+
|
|
1241
1185
|
// Extra: count elements per IFC type (walls / doors / others)
|
|
1242
|
-
|
|
1243
|
-
|
|
1186
|
+
const countsByType = elements.reduce((acc, el) => {
|
|
1187
|
+
const key = el.ifcType || "UNKNOWN";
|
|
1244
1188
|
acc[key] = (acc[key] || 0) + 1;
|
|
1245
1189
|
return acc;
|
|
1246
1190
|
}, {});
|
|
1247
1191
|
console.log("[DXF-PAYLOAD] collectElementsFromGroup() summary:", stats);
|
|
1248
1192
|
console.log("[DXF-PAYLOAD] countsByType:", countsByType);
|
|
1249
1193
|
if (elements[0]) {
|
|
1250
|
-
|
|
1194
|
+
const e0 = elements[0];
|
|
1251
1195
|
console.log("[DXF-PAYLOAD] First element preview:", {
|
|
1252
1196
|
uuid: e0.uuid,
|
|
1253
1197
|
name: e0.name,
|
|
@@ -1257,11 +1201,12 @@ function useDxfExportPayload(_a) {
|
|
|
1257
1201
|
});
|
|
1258
1202
|
}
|
|
1259
1203
|
return {
|
|
1260
|
-
elements
|
|
1261
|
-
stats
|
|
1262
|
-
countsByType
|
|
1204
|
+
elements,
|
|
1205
|
+
stats,
|
|
1206
|
+
countsByType
|
|
1263
1207
|
};
|
|
1264
1208
|
}, [rootGroupRef, getPropsForMesh]);
|
|
1209
|
+
|
|
1265
1210
|
/**
|
|
1266
1211
|
* Call the `/api/ifc-dxf` endpoint using the current scene geometry and
|
|
1267
1212
|
* immediately download the resulting DXF.
|
|
@@ -1289,102 +1234,84 @@ function useDxfExportPayload(_a) {
|
|
|
1289
1234
|
*
|
|
1290
1235
|
* @returns {Promise<void>}
|
|
1291
1236
|
*/
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
projectName =
|
|
1296
|
-
// dynamic default using projectNumber
|
|
1297
|
-
_d = _b.schema,
|
|
1237
|
+
|
|
1238
|
+
const exportDxfFromServer = React.useCallback(async function () {
|
|
1239
|
+
let {
|
|
1240
|
+
projectName = "Roometry Project ".concat(projectNumber),
|
|
1298
1241
|
// dynamic default using projectNumber
|
|
1299
|
-
schema =
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
bakeWorld = _f === void 0 ? false : _f,
|
|
1304
|
-
_g = _b.compat,
|
|
1305
|
-
compat = _g === void 0 ? {
|
|
1242
|
+
schema = "IFC4",
|
|
1243
|
+
format = "tfs",
|
|
1244
|
+
bakeWorld = false,
|
|
1245
|
+
compat = {
|
|
1306
1246
|
useRootContextForBody: true
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
elements: elements
|
|
1346
|
-
})
|
|
1347
|
-
})];
|
|
1348
|
-
case 2:
|
|
1349
|
-
res = _k.sent();
|
|
1350
|
-
if (!!res.ok) return [3 /*break*/, 4];
|
|
1351
|
-
return [4 /*yield*/, res.text()];
|
|
1352
|
-
case 3:
|
|
1353
|
-
txt = _k.sent();
|
|
1354
|
-
console.error("[DXF] Server error:", txt);
|
|
1355
|
-
alert("DXF export failed: " + txt);
|
|
1356
|
-
return [2 /*return*/];
|
|
1357
|
-
case 4:
|
|
1358
|
-
return [4 /*yield*/, res.json()];
|
|
1359
|
-
case 5:
|
|
1360
|
-
payload = _k.sent();
|
|
1361
|
-
console.log("[DXF] Server stats:", payload.stats);
|
|
1362
|
-
dxfText = payload.dxf;
|
|
1363
|
-
if (typeof dxfText !== "string") {
|
|
1364
|
-
console.error("[DXF] Invalid DXF in response:", payload);
|
|
1365
|
-
alert("DXF export failed: invalid DXF payload from server");
|
|
1366
|
-
return [2 /*return*/];
|
|
1367
|
-
}
|
|
1368
|
-
dxfBlob = new Blob([dxfText], {
|
|
1369
|
-
type: "image/vnd.dxf"
|
|
1370
|
-
});
|
|
1371
|
-
downloadBlob(dxfBlob, fileName);
|
|
1372
|
-
return [3 /*break*/, 7];
|
|
1373
|
-
case 6:
|
|
1374
|
-
err_1 = _k.sent();
|
|
1375
|
-
msg = err_1 instanceof Error ? err_1.message : String(err_1);
|
|
1376
|
-
console.error("[DXF] Network error:", err_1);
|
|
1377
|
-
alert("DXF export failed (network): " + msg);
|
|
1378
|
-
return [3 /*break*/, 7];
|
|
1379
|
-
case 7:
|
|
1380
|
-
return [2 /*return*/];
|
|
1381
|
-
}
|
|
1247
|
+
},
|
|
1248
|
+
fileName = "".concat(projectNumber, "_v").concat(version, "_.dxf") // dynamic default: <projectNumber>_v<version>_.dxf
|
|
1249
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1250
|
+
const {
|
|
1251
|
+
elements,
|
|
1252
|
+
stats,
|
|
1253
|
+
countsByType
|
|
1254
|
+
} = collectElementsFromGroup();
|
|
1255
|
+
if (!elements.length) {
|
|
1256
|
+
console.warn("[DXF] No elements to export");
|
|
1257
|
+
alert("DXF export failed: no geometry to export");
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
console.log("[DXF] Payload for /api/ifc-dxf:", _objectSpread2(_objectSpread2({}, stats), {}, {
|
|
1261
|
+
countsByType,
|
|
1262
|
+
firstElement: elements[0] && {
|
|
1263
|
+
uuid: elements[0].uuid,
|
|
1264
|
+
name: elements[0].name,
|
|
1265
|
+
ifcType: elements[0].ifcType,
|
|
1266
|
+
worldPositionsLength: elements[0].worldPositions.length,
|
|
1267
|
+
indicesLength: elements[0].indices.length
|
|
1268
|
+
}
|
|
1269
|
+
}));
|
|
1270
|
+
try {
|
|
1271
|
+
const res = await fetch("http://192.168.30.92:3009/api/ifc-dxf", {
|
|
1272
|
+
method: "POST",
|
|
1273
|
+
headers: {
|
|
1274
|
+
"Content-Type": "application/json"
|
|
1275
|
+
},
|
|
1276
|
+
body: JSON.stringify({
|
|
1277
|
+
projectName,
|
|
1278
|
+
schema,
|
|
1279
|
+
format,
|
|
1280
|
+
// 'tfs'
|
|
1281
|
+
bakeWorld,
|
|
1282
|
+
compat,
|
|
1283
|
+
elements
|
|
1284
|
+
})
|
|
1382
1285
|
});
|
|
1383
|
-
|
|
1286
|
+
if (!res.ok) {
|
|
1287
|
+
const txt = await res.text();
|
|
1288
|
+
console.error("[DXF] Server error:", txt);
|
|
1289
|
+
alert("DXF export failed: " + txt);
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
const payload = await res.json();
|
|
1293
|
+
console.log("[DXF] Server stats:", payload.stats);
|
|
1294
|
+
// You can compare payload.stats.triangleCount with stats.triangleCount here if you want
|
|
1295
|
+
|
|
1296
|
+
const dxfText = payload.dxf;
|
|
1297
|
+
if (typeof dxfText !== "string") {
|
|
1298
|
+
console.error("[DXF] Invalid DXF in response:", payload);
|
|
1299
|
+
alert("DXF export failed: invalid DXF payload from server");
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
const dxfBlob = new Blob([dxfText], {
|
|
1303
|
+
type: "image/vnd.dxf"
|
|
1304
|
+
});
|
|
1305
|
+
downloadBlob(dxfBlob, fileName);
|
|
1306
|
+
} catch (err) {
|
|
1307
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1308
|
+
console.error("[DXF] Network error:", err);
|
|
1309
|
+
alert("DXF export failed (network): " + msg);
|
|
1310
|
+
}
|
|
1384
1311
|
}, [collectElementsFromGroup, projectNumber, version]);
|
|
1385
1312
|
return {
|
|
1386
|
-
collectElementsFromGroup
|
|
1387
|
-
exportDxfFromServer
|
|
1313
|
+
collectElementsFromGroup,
|
|
1314
|
+
exportDxfFromServer
|
|
1388
1315
|
};
|
|
1389
1316
|
}
|
|
1390
1317
|
|
|
@@ -2389,12 +2316,9 @@ function DoorLeaf(_ref) {
|
|
|
2389
2316
|
secondDoorStopWidth,
|
|
2390
2317
|
secondDoorStopDepth
|
|
2391
2318
|
} = doorFrame;
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
initialDoorHeight.current = doorHeight;
|
|
2396
|
-
}
|
|
2397
|
-
}, [doorHeight]);
|
|
2319
|
+
|
|
2320
|
+
// Removed unused initialDoorHeight ref
|
|
2321
|
+
|
|
2398
2322
|
const {
|
|
2399
2323
|
x1: occulusX1,
|
|
2400
2324
|
x2: occulusX2,
|
|
@@ -2720,7 +2644,9 @@ function DoorModels(props) {
|
|
|
2720
2644
|
setTotalHeight,
|
|
2721
2645
|
setTotalDepth,
|
|
2722
2646
|
setExportDXF,
|
|
2723
|
-
setCollectElementsFromGroup
|
|
2647
|
+
setCollectElementsFromGroup,
|
|
2648
|
+
initialDoorHeight,
|
|
2649
|
+
setInitialDoorHeight
|
|
2724
2650
|
} = useConfigurator();
|
|
2725
2651
|
|
|
2726
2652
|
/**
|
|
@@ -2820,16 +2746,15 @@ function DoorModels(props) {
|
|
|
2820
2746
|
topThk,
|
|
2821
2747
|
frameDepth
|
|
2822
2748
|
} = doorFrame;
|
|
2823
|
-
const initialDoorHeight = React.useRef(null);
|
|
2824
2749
|
React.useEffect(() => {
|
|
2825
|
-
if (initialDoorHeight
|
|
2826
|
-
|
|
2750
|
+
if (initialDoorHeight === null && doorHeight > 0) {
|
|
2751
|
+
setInitialDoorHeight(doorHeight);
|
|
2827
2752
|
}
|
|
2828
|
-
}, [doorHeight]);
|
|
2753
|
+
}, [doorHeight, initialDoorHeight, setInitialDoorHeight]);
|
|
2829
2754
|
const pivotNewPosition = React.useMemo(() => {
|
|
2830
|
-
if (initialDoorHeight
|
|
2831
|
-
return (doorHeight - initialDoorHeight
|
|
2832
|
-
}, [doorHeight]);
|
|
2755
|
+
if (initialDoorHeight === null || initialDoorHeight === 0) return 0;
|
|
2756
|
+
return (doorHeight - initialDoorHeight) / 2 / 1000;
|
|
2757
|
+
}, [doorHeight, initialDoorHeight]);
|
|
2833
2758
|
const topThkValue = parseInt(topThk) || 20;
|
|
2834
2759
|
|
|
2835
2760
|
// Convert dimensions from mm to meters
|
|
@@ -2881,6 +2806,7 @@ function DoorModels(props) {
|
|
|
2881
2806
|
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
2882
2807
|
children: /*#__PURE__*/jsxRuntime.jsxs("group", {
|
|
2883
2808
|
ref: exportGroupRef,
|
|
2809
|
+
"position-y": 0,
|
|
2884
2810
|
children: [/*#__PURE__*/jsxRuntime.jsx("mesh", {
|
|
2885
2811
|
visible: false,
|
|
2886
2812
|
children: /*#__PURE__*/jsxRuntime.jsx("boxGeometry", {
|