door_models 5.3.6 → 5.3.8
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 +49 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +49 -29
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -777,8 +777,6 @@ new THREE.MeshStandardMaterial({
|
|
|
777
777
|
roughness: 0.8
|
|
778
778
|
});
|
|
779
779
|
|
|
780
|
-
// Type definition for a material prop (string or object with opacity)
|
|
781
|
-
|
|
782
780
|
// Helper function to check for hex color codes
|
|
783
781
|
const isHexColor = str => /^#([0-9A-F]{3}){1,2}$/i.test(str);
|
|
784
782
|
|
|
@@ -803,13 +801,9 @@ const buildMaterial = (prop, textures) => {
|
|
|
803
801
|
};
|
|
804
802
|
if (isHexColor(sourceValue)) {
|
|
805
803
|
params.color = sourceValue;
|
|
806
|
-
}
|
|
807
|
-
// Check if it's a URL and if it exists in the pre-loaded texture map
|
|
808
|
-
else if (textures && textures[sourceValue]) {
|
|
804
|
+
} else if (textures && textures[sourceValue]) {
|
|
809
805
|
params.map = textures[sourceValue];
|
|
810
|
-
}
|
|
811
|
-
// Fallback for invalid values
|
|
812
|
-
else {
|
|
806
|
+
} else {
|
|
813
807
|
params.color = "#cccccc";
|
|
814
808
|
}
|
|
815
809
|
if (opacity !== undefined && opacity < 1) {
|
|
@@ -818,8 +812,6 @@ const buildMaterial = (prop, textures) => {
|
|
|
818
812
|
}
|
|
819
813
|
return new THREE.MeshStandardMaterial(params);
|
|
820
814
|
};
|
|
821
|
-
|
|
822
|
-
// getFirstValidValue remains useful for fallbacks, so we keep it.
|
|
823
815
|
const getFirstValidValue = values => {
|
|
824
816
|
for (const val of values) {
|
|
825
817
|
if (val) {
|
|
@@ -1386,7 +1378,10 @@ function DoorModels(_ref7) {
|
|
|
1386
1378
|
doorName,
|
|
1387
1379
|
materials: materialsProp,
|
|
1388
1380
|
doorPivot: doorPivotProp,
|
|
1389
|
-
doorOpening: doorOpeningProp
|
|
1381
|
+
doorOpening: doorOpeningProp,
|
|
1382
|
+
totalWidth: totalWidthProp,
|
|
1383
|
+
totalHeight: totalHeightProp,
|
|
1384
|
+
frameDepth: frameDepthProp
|
|
1390
1385
|
} = _ref7;
|
|
1391
1386
|
const {
|
|
1392
1387
|
is2D,
|
|
@@ -1395,6 +1390,7 @@ function DoorModels(_ref7) {
|
|
|
1395
1390
|
door,
|
|
1396
1391
|
setDoor,
|
|
1397
1392
|
doorFrame,
|
|
1393
|
+
setDoorFrame,
|
|
1398
1394
|
interiorFanlight,
|
|
1399
1395
|
exteriorFanlight,
|
|
1400
1396
|
frontCoverPanel,
|
|
@@ -1404,7 +1400,9 @@ function DoorModels(_ref7) {
|
|
|
1404
1400
|
glassDepth,
|
|
1405
1401
|
handleParseCpid,
|
|
1406
1402
|
isDoubleDoor,
|
|
1407
|
-
setMaterials
|
|
1403
|
+
setMaterials,
|
|
1404
|
+
setTotalWidth,
|
|
1405
|
+
setTotalHeight
|
|
1408
1406
|
} = useConfigurator();
|
|
1409
1407
|
useEffect(() => {
|
|
1410
1408
|
if (doorName) {
|
|
@@ -1416,12 +1414,6 @@ function DoorModels(_ref7) {
|
|
|
1416
1414
|
setMaterials(materialsProp);
|
|
1417
1415
|
}
|
|
1418
1416
|
}, [materialsProp, setMaterials]);
|
|
1419
|
-
useEffect(() => {
|
|
1420
|
-
if (doorName) handleParseCpid(doorName);
|
|
1421
|
-
}, [doorName, handleParseCpid]);
|
|
1422
|
-
useEffect(() => {
|
|
1423
|
-
if (materialsProp) setMaterials(materialsProp);
|
|
1424
|
-
}, [materialsProp, setMaterials]);
|
|
1425
1417
|
useEffect(() => {
|
|
1426
1418
|
if (doorPivotProp || doorOpeningProp) {
|
|
1427
1419
|
setDoor(prevDoor => _objectSpread2(_objectSpread2(_objectSpread2({}, prevDoor), doorPivotProp && {
|
|
@@ -1431,6 +1423,23 @@ function DoorModels(_ref7) {
|
|
|
1431
1423
|
}));
|
|
1432
1424
|
}
|
|
1433
1425
|
}, [doorPivotProp, doorOpeningProp, setDoor]);
|
|
1426
|
+
useEffect(() => {
|
|
1427
|
+
if (totalWidthProp !== undefined) {
|
|
1428
|
+
setTotalWidth(totalWidthProp);
|
|
1429
|
+
}
|
|
1430
|
+
}, [totalWidthProp, setTotalWidth]);
|
|
1431
|
+
useEffect(() => {
|
|
1432
|
+
if (totalHeightProp !== undefined) {
|
|
1433
|
+
setTotalHeight(totalHeightProp);
|
|
1434
|
+
}
|
|
1435
|
+
}, [totalHeightProp, setTotalHeight]);
|
|
1436
|
+
useEffect(() => {
|
|
1437
|
+
if (frameDepthProp !== undefined) {
|
|
1438
|
+
setDoorFrame(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
1439
|
+
frameDepth: frameDepthProp
|
|
1440
|
+
}));
|
|
1441
|
+
}
|
|
1442
|
+
}, [frameDepthProp, setDoorFrame]);
|
|
1434
1443
|
|
|
1435
1444
|
// --- Material Logic (Centralized in parent component) ---
|
|
1436
1445
|
const allMaterials = useDoorMaterials(materialsProp);
|
|
@@ -1460,20 +1469,12 @@ function DoorModels(_ref7) {
|
|
|
1460
1469
|
} = doorFrame;
|
|
1461
1470
|
const initialDoorHeight = useRef(null);
|
|
1462
1471
|
useEffect(() => {
|
|
1463
|
-
// If our initial height hasn't been set yet AND we have a valid height...
|
|
1464
1472
|
if (initialDoorHeight.current === null && doorHeight > 0) {
|
|
1465
|
-
// ...set it. This will now be the stable base value for your logic.
|
|
1466
|
-
// This line will only run once for the initial valid height.
|
|
1467
1473
|
initialDoorHeight.current = doorHeight;
|
|
1468
1474
|
}
|
|
1469
|
-
}, [doorHeight]);
|
|
1470
|
-
|
|
1471
|
-
// YOUR ORIGINAL LOGIC IS UNCHANGED, we just add a safety check.
|
|
1475
|
+
}, [doorHeight]);
|
|
1472
1476
|
const pivotNewPosition = useMemo(() => {
|
|
1473
|
-
// If the initial value hasn't been captured, don't move the door.
|
|
1474
1477
|
if (initialDoorHeight.current === null || initialDoorHeight.current === 0) return 0;
|
|
1475
|
-
|
|
1476
|
-
// Your existing, correct logic now works because initialDoorHeight.current is correct.
|
|
1477
1478
|
return (doorHeight - initialDoorHeight.current) / 2 / 1000;
|
|
1478
1479
|
}, [doorHeight]);
|
|
1479
1480
|
const {
|
|
@@ -1975,6 +1976,19 @@ function DoorLeaf(_ref8) {
|
|
|
1975
1976
|
const occulusHeightM = mainDoorHeightM - occulusY1M - occulusY2M;
|
|
1976
1977
|
const occulusPositionXM = (occulusX1M - occulusX2M) / 2;
|
|
1977
1978
|
const occulusPositionYM = (occulusY2M - occulusY1M) / 2;
|
|
1979
|
+
useEffect(() => {
|
|
1980
|
+
const materialsToUpdate = [frontDoorPlaneMaterial, backDoorPlaneMaterial];
|
|
1981
|
+
materialsToUpdate.forEach(material => {
|
|
1982
|
+
// Check if the material has a texture map
|
|
1983
|
+
if (material.map) {
|
|
1984
|
+
// Set the texture to repeat
|
|
1985
|
+
material.map.wrapS = THREE.RepeatWrapping;
|
|
1986
|
+
material.map.wrapT = THREE.RepeatWrapping;
|
|
1987
|
+
material.map.repeat.set(doorWidthM, mainDoorHeightM);
|
|
1988
|
+
material.map.needsUpdate = true;
|
|
1989
|
+
}
|
|
1990
|
+
});
|
|
1991
|
+
}, [doorWidthM, mainDoorHeightM, frontDoorPlaneMaterial, backDoorPlaneMaterial]);
|
|
1978
1992
|
const [isOpen, setIsOpen] = useState(false);
|
|
1979
1993
|
const hingeSideX = pivot === "left" ? -doorWidthM / 2 : doorWidthM / 2;
|
|
1980
1994
|
|
|
@@ -2219,7 +2233,10 @@ const DoorConfigurator = _ref => {
|
|
|
2219
2233
|
materials,
|
|
2220
2234
|
doorPivot,
|
|
2221
2235
|
doorOpening,
|
|
2222
|
-
is2D = false
|
|
2236
|
+
is2D = false,
|
|
2237
|
+
totalWidth,
|
|
2238
|
+
totalHeight,
|
|
2239
|
+
frameDepth
|
|
2223
2240
|
} = _ref;
|
|
2224
2241
|
return /*#__PURE__*/jsx(ConfiguratorProvider, {
|
|
2225
2242
|
initialIs2D: is2D,
|
|
@@ -2227,7 +2244,10 @@ const DoorConfigurator = _ref => {
|
|
|
2227
2244
|
doorName: doorName,
|
|
2228
2245
|
materials: materials,
|
|
2229
2246
|
doorPivot: doorPivot,
|
|
2230
|
-
doorOpening: doorOpening
|
|
2247
|
+
doorOpening: doorOpening,
|
|
2248
|
+
totalWidth: totalWidth,
|
|
2249
|
+
totalHeight: totalHeight,
|
|
2250
|
+
frameDepth: frameDepth
|
|
2231
2251
|
})
|
|
2232
2252
|
});
|
|
2233
2253
|
};
|