door_models 5.2.1 → 5.2.3
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 +103 -130
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +103 -130
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -100,8 +100,10 @@ const ConfiguratorContext = /*#__PURE__*/React.createContext(undefined);
|
|
|
100
100
|
const ConfiguratorProvider = _ref => {
|
|
101
101
|
let {
|
|
102
102
|
children,
|
|
103
|
-
initialIs2D = false
|
|
103
|
+
initialIs2D = false,
|
|
104
|
+
initialMaterials = {}
|
|
104
105
|
} = _ref;
|
|
106
|
+
const [materials, setMaterials] = React.useState(initialMaterials);
|
|
105
107
|
const [is2D, setIs2D] = React.useState(initialIs2D);
|
|
106
108
|
const [isPlaneVisible, setIsPlaneVisible] = React.useState(false);
|
|
107
109
|
const [isFrameVisible, setIsFrameVisible] = React.useState(true);
|
|
@@ -189,8 +191,6 @@ const ConfiguratorProvider = _ref => {
|
|
|
189
191
|
depth: 20
|
|
190
192
|
});
|
|
191
193
|
const defaultOptions = ["D_PRF_COLOR", "D_FR_SRF_DECOR", "D_FR_SRF_DECOR_S2"];
|
|
192
|
-
|
|
193
|
-
// Function to pick the first valid value
|
|
194
194
|
function getFirstValidValue(values, isValid) {
|
|
195
195
|
for (const val of values) {
|
|
196
196
|
if (isValid(val)) return val;
|
|
@@ -223,6 +223,11 @@ const ConfiguratorProvider = _ref => {
|
|
|
223
223
|
React.useEffect(() => {
|
|
224
224
|
setIs2D(initialIs2D);
|
|
225
225
|
}, [initialIs2D]);
|
|
226
|
+
React.useEffect(() => {
|
|
227
|
+
if (initialMaterials) {
|
|
228
|
+
setMaterials(initialMaterials);
|
|
229
|
+
}
|
|
230
|
+
}, [initialMaterials]);
|
|
226
231
|
const handleParseCpid = React.useCallback(cpidToParse => {
|
|
227
232
|
const showMessage = function (text) {
|
|
228
233
|
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "error";
|
|
@@ -685,6 +690,7 @@ const ConfiguratorProvider = _ref => {
|
|
|
685
690
|
}, [totalWidth, doorFrame.sidesThk, isDoubleDoor]);
|
|
686
691
|
return /*#__PURE__*/jsxRuntime.jsx(ConfiguratorContext.Provider, {
|
|
687
692
|
value: {
|
|
693
|
+
materials,
|
|
688
694
|
is2D,
|
|
689
695
|
setIs2D,
|
|
690
696
|
isPlaneVisible,
|
|
@@ -771,76 +777,63 @@ const useConfigurator = () => {
|
|
|
771
777
|
return context;
|
|
772
778
|
};
|
|
773
779
|
|
|
780
|
+
// Keep the textureLoader instance
|
|
774
781
|
const textureLoader = new THREE__namespace.TextureLoader();
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
const
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
782
|
+
|
|
783
|
+
// This is your new core logic. It's self-contained.
|
|
784
|
+
const isUrl = string => {
|
|
785
|
+
try {
|
|
786
|
+
new URL(string);
|
|
787
|
+
return true;
|
|
788
|
+
} catch (_) {
|
|
789
|
+
return false;
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
const createMaterialFromProp = value => {
|
|
793
|
+
if (!value) return null;
|
|
794
|
+
|
|
795
|
+
// Handle HEX colors
|
|
796
|
+
if (value.startsWith("#")) {
|
|
797
|
+
return new THREE__namespace.MeshStandardMaterial({
|
|
798
|
+
color: value,
|
|
799
|
+
roughness: 0.8
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// Handle URLs
|
|
804
|
+
if (isUrl(value)) {
|
|
805
|
+
const texture = textureLoader.load(value);
|
|
806
|
+
texture.wrapS = THREE__namespace.RepeatWrapping;
|
|
807
|
+
texture.wrapT = THREE__namespace.RepeatWrapping;
|
|
808
|
+
return new THREE__namespace.MeshStandardMaterial({
|
|
809
|
+
map: texture,
|
|
810
|
+
roughness: 0.8
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// It's good practice to return null if the format is not recognized.
|
|
815
|
+
return null;
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
// --- REMOVED THE ENTIRE `availableMaterials` OBJECT ---
|
|
819
|
+
// It is no longer needed.
|
|
820
|
+
|
|
821
|
+
// Keep placeholder materials as a fallback if a material prop isn't provided
|
|
822
|
+
const placeholderMaterial = new THREE__namespace.MeshStandardMaterial({
|
|
823
|
+
color: "#cccccc",
|
|
824
|
+
// A neutral grey
|
|
825
|
+
roughness: 0.8
|
|
826
|
+
});
|
|
827
|
+
const placeholderMaterialforFrames = new THREE__namespace.MeshStandardMaterial({
|
|
828
|
+
color: "#555555",
|
|
829
|
+
// A darker grey for frames
|
|
830
|
+
roughness: 0.8
|
|
831
|
+
});
|
|
832
|
+
|
|
786
833
|
const availableMaterials = {
|
|
787
|
-
D_SRF_DECOR_2: new THREE__namespace.MeshStandardMaterial({
|
|
788
|
-
map: bodyInt,
|
|
789
|
-
roughness: 0.8
|
|
790
|
-
}),
|
|
791
|
-
D_SRF_DECOR: new THREE__namespace.MeshStandardMaterial({
|
|
792
|
-
map: bodyExt,
|
|
793
|
-
roughness: 0.8
|
|
794
|
-
}),
|
|
795
|
-
D_PRF_COLOR: new THREE__namespace.MeshStandardMaterial({
|
|
796
|
-
map: frameAlu,
|
|
797
|
-
roughness: 0.8
|
|
798
|
-
}),
|
|
799
|
-
D_FR_SRF_DECOR: new THREE__namespace.MeshStandardMaterial({
|
|
800
|
-
map: frameWoodenInt,
|
|
801
|
-
roughness: 0.8
|
|
802
|
-
}),
|
|
803
|
-
D_FR_SRF_DECOR_S2: new THREE__namespace.MeshStandardMaterial({
|
|
804
|
-
map: frameWoodenInt,
|
|
805
|
-
roughness: 0.8
|
|
806
|
-
}),
|
|
807
|
-
D_FR_COLOR: new THREE__namespace.MeshStandardMaterial({
|
|
808
|
-
map: wdg,
|
|
809
|
-
roughness: 0.8
|
|
810
|
-
}),
|
|
811
|
-
D_GASKET: new THREE__namespace.MeshStandardMaterial({
|
|
812
|
-
map: gasket,
|
|
813
|
-
roughness: 0.8
|
|
814
|
-
}),
|
|
815
834
|
black: new THREE__namespace.MeshStandardMaterial({
|
|
816
835
|
color: "#000000"
|
|
817
836
|
}),
|
|
818
|
-
metal: new THREE__namespace.MeshStandardMaterial({
|
|
819
|
-
color: "#aaaaaa",
|
|
820
|
-
metalness: 1.0,
|
|
821
|
-
roughness: 0.4
|
|
822
|
-
}),
|
|
823
|
-
darkgrey: new THREE__namespace.MeshStandardMaterial({
|
|
824
|
-
color: "#5e5e5e"
|
|
825
|
-
}),
|
|
826
|
-
grey: new THREE__namespace.MeshStandardMaterial({
|
|
827
|
-
color: "#cccccc"
|
|
828
|
-
}),
|
|
829
|
-
yellow: new THREE__namespace.MeshStandardMaterial({
|
|
830
|
-
color: "#ffff00"
|
|
831
|
-
}),
|
|
832
|
-
darkBrown: new THREE__namespace.MeshStandardMaterial({
|
|
833
|
-
color: "#a0522d"
|
|
834
|
-
}),
|
|
835
|
-
brown: new THREE__namespace.MeshStandardMaterial({
|
|
836
|
-
color: "#d2b48c"
|
|
837
|
-
}),
|
|
838
|
-
glass: new THREE__namespace.MeshStandardMaterial({
|
|
839
|
-
color: "#ffffff",
|
|
840
|
-
roughness: 0.1,
|
|
841
|
-
transparent: true,
|
|
842
|
-
opacity: 0.7
|
|
843
|
-
}),
|
|
844
837
|
aluminum: new THREE__namespace.MeshStandardMaterial({
|
|
845
838
|
color: "#abb0aa",
|
|
846
839
|
metalness: 0.8,
|
|
@@ -858,39 +851,10 @@ const availableMaterials = {
|
|
|
858
851
|
metalness: 0.8,
|
|
859
852
|
roughness: 0.5,
|
|
860
853
|
envMapIntensity: 1.2
|
|
861
|
-
}),
|
|
862
|
-
silver: new THREE__namespace.MeshStandardMaterial({
|
|
863
|
-
color: "#c0c0c0",
|
|
864
|
-
metalness: 1.0,
|
|
865
|
-
roughness: 0.2
|
|
866
|
-
}),
|
|
867
|
-
gold: new THREE__namespace.MeshStandardMaterial({
|
|
868
|
-
color: "#ffd700",
|
|
869
|
-
metalness: 1.0,
|
|
870
|
-
roughness: 0.3
|
|
871
|
-
}),
|
|
872
|
-
diamond: new THREE__namespace.MeshStandardMaterial({
|
|
873
|
-
color: "#e0f7fa",
|
|
874
|
-
metalness: 0.9,
|
|
875
|
-
roughness: 0.05,
|
|
876
|
-
transparent: true,
|
|
877
|
-
opacity: 0.9,
|
|
878
|
-
envMapIntensity: 1.5
|
|
879
|
-
}),
|
|
880
|
-
test_material: new THREE__namespace.MeshStandardMaterial({
|
|
881
|
-
color: "red",
|
|
882
|
-
roughness: 0.1
|
|
883
854
|
})
|
|
884
855
|
};
|
|
885
|
-
const placeholderMaterial = new THREE__namespace.MeshStandardMaterial({
|
|
886
|
-
color: "#cccccc",
|
|
887
|
-
roughness: 0.8
|
|
888
|
-
});
|
|
889
|
-
const placeholderMaterialforFrames = new THREE__namespace.MeshStandardMaterial({
|
|
890
|
-
color: "#000",
|
|
891
|
-
roughness: 0.8
|
|
892
|
-
});
|
|
893
856
|
|
|
857
|
+
// Custom hook for door handle calculations
|
|
894
858
|
function StandardHandle(_ref) {
|
|
895
859
|
let {
|
|
896
860
|
position,
|
|
@@ -1392,7 +1356,8 @@ function DoorModels(_ref7) {
|
|
|
1392
1356
|
glassDepth,
|
|
1393
1357
|
cpid,
|
|
1394
1358
|
handleParseCpid,
|
|
1395
|
-
isDoubleDoor
|
|
1359
|
+
isDoubleDoor,
|
|
1360
|
+
materials
|
|
1396
1361
|
} = useConfigurator();
|
|
1397
1362
|
React.useEffect(() => {
|
|
1398
1363
|
if (doorName) {
|
|
@@ -1434,29 +1399,36 @@ function DoorModels(_ref7) {
|
|
|
1434
1399
|
const {
|
|
1435
1400
|
material: backDoorPlaneMaterialName
|
|
1436
1401
|
} = backDoorPlane;
|
|
1437
|
-
|
|
1402
|
+
const pers = React.useMemo(() => {
|
|
1403
|
+
const dynamicMaterials = {};
|
|
1404
|
+
for (const key in materials) {
|
|
1405
|
+
if (Object.prototype.hasOwnProperty.call(materials, key)) {
|
|
1406
|
+
const value = materials[key];
|
|
1407
|
+
dynamicMaterials[key] = createMaterialFromProp(value);
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
return dynamicMaterials;
|
|
1411
|
+
}, [materials]);
|
|
1438
1412
|
// --- Material Logic ---
|
|
1439
|
-
React.useMemo(() =>
|
|
1440
|
-
const frameMaterial = React.useMemo(() =>
|
|
1441
|
-
const gasketMaterial = React.useMemo(() =>
|
|
1442
|
-
color: "#111111"
|
|
1443
|
-
}), [testGasketMaterial, gasketMaterialName]);
|
|
1413
|
+
React.useMemo(() => placeholderMaterial, [testDoorMaterial, doorMaterialName]);
|
|
1414
|
+
const frameMaterial = React.useMemo(() => pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || placeholderMaterialforFrames, [testFrameMaterial, frameMaterialName]);
|
|
1415
|
+
const gasketMaterial = React.useMemo(() => pers.D_GASKET || availableMaterials.black, [testGasketMaterial, gasketMaterialName]);
|
|
1444
1416
|
const doorStopMaterial = React.useMemo(() => {
|
|
1445
|
-
return
|
|
1417
|
+
return pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || frameMaterial;
|
|
1446
1418
|
}, [testDoorStopMaterial, doorStopMaterialName, frameType, frameMaterial]);
|
|
1447
|
-
const interiorFanlightMaterial = React.useMemo(() =>
|
|
1448
|
-
const exteriorFanlightMaterial = React.useMemo(() =>
|
|
1449
|
-
React.useMemo(() =>
|
|
1450
|
-
const glassInfillMaterial = React.useMemo(() =>
|
|
1451
|
-
React.useMemo(() =>
|
|
1419
|
+
const interiorFanlightMaterial = React.useMemo(() => pers.D_SRF_DECOR_2 || placeholderMaterial, [testInteriorFanlightMaterial, interiorFanlightMaterialName]);
|
|
1420
|
+
const exteriorFanlightMaterial = React.useMemo(() => placeholderMaterial, [testExteriorFanlightMaterial, exteriorFanlightMaterialName]);
|
|
1421
|
+
React.useMemo(() => placeholderMaterial, [testOcculusInfillMaterial, occulusInfillMaterialName]);
|
|
1422
|
+
const glassInfillMaterial = React.useMemo(() => pers.D_FR_COLOR || placeholderMaterial, [testGlassInfillMaterial, glassInfillMaterialName]);
|
|
1423
|
+
React.useMemo(() => new THREE__namespace.MeshStandardMaterial({
|
|
1452
1424
|
color: "#d4d4d4",
|
|
1453
1425
|
metalness: 1.0,
|
|
1454
1426
|
roughness: 0.4
|
|
1455
1427
|
}), [testHingeMaterial, hingeMaterialName]);
|
|
1456
|
-
const frontCoverPanelMaterial = React.useMemo(() =>
|
|
1457
|
-
const backCoverPanelMaterial = React.useMemo(() =>
|
|
1458
|
-
React.useMemo(() =>
|
|
1459
|
-
React.useMemo(() =>
|
|
1428
|
+
const frontCoverPanelMaterial = React.useMemo(() => pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || placeholderMaterial, [testFrontCoverPanelMaterial, frontCoverPanelMaterialName]);
|
|
1429
|
+
const backCoverPanelMaterial = React.useMemo(() => pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || placeholderMaterial, [testBackCoverPanelMaterial, backCoverPanelMaterialName]);
|
|
1430
|
+
React.useMemo(() => pers.D_SRF_DECOR_2 || placeholderMaterial, [testFrontDoorPlaneMaterial, frontDoorPlaneMaterialName]);
|
|
1431
|
+
React.useMemo(() => pers.D_SRF_DECOR || placeholderMaterial, [testBackDoorPlaneMaterial, backDoorPlaneMaterialName]);
|
|
1460
1432
|
React.useMemo(() => new THREE__namespace.MeshStandardMaterial({
|
|
1461
1433
|
color: "#1a1a1a",
|
|
1462
1434
|
roughness: 0.1
|
|
@@ -2052,27 +2024,27 @@ function DoorLeaf(_ref8) {
|
|
|
2052
2024
|
} = backDoorPlane;
|
|
2053
2025
|
|
|
2054
2026
|
// --- Material Logic ---
|
|
2055
|
-
const doorMaterial = React.useMemo(() =>
|
|
2056
|
-
const frameMaterial = React.useMemo(() =>
|
|
2057
|
-
const gasketMaterial = React.useMemo(() =>
|
|
2027
|
+
const doorMaterial = React.useMemo(() => placeholderMaterial, [testDoorMaterial, doorMaterialName]);
|
|
2028
|
+
const frameMaterial = React.useMemo(() => placeholderMaterialforFrames, [testFrameMaterial, frameMaterialName]);
|
|
2029
|
+
const gasketMaterial = React.useMemo(() => new THREE__namespace.MeshStandardMaterial({
|
|
2058
2030
|
color: "#111111"
|
|
2059
2031
|
}), [testGasketMaterial, gasketMaterialName]);
|
|
2060
2032
|
React.useMemo(() => {
|
|
2061
|
-
return
|
|
2033
|
+
return frameMaterial;
|
|
2062
2034
|
}, [testDoorStopMaterial, doorStopMaterialName, frameType, frameMaterial]);
|
|
2063
|
-
React.useMemo(() =>
|
|
2064
|
-
React.useMemo(() =>
|
|
2065
|
-
const occulusInfillMaterial = React.useMemo(() =>
|
|
2066
|
-
const glassInfillMaterial = React.useMemo(() =>
|
|
2067
|
-
const hingeBodyMaterial = React.useMemo(() =>
|
|
2035
|
+
React.useMemo(() => placeholderMaterial, [testInteriorFanlightMaterial, interiorFanlightMaterialName]);
|
|
2036
|
+
React.useMemo(() => placeholderMaterial, [testExteriorFanlightMaterial, exteriorFanlightMaterialName]);
|
|
2037
|
+
const occulusInfillMaterial = React.useMemo(() => placeholderMaterial, [testOcculusInfillMaterial, occulusInfillMaterialName]);
|
|
2038
|
+
const glassInfillMaterial = React.useMemo(() => placeholderMaterial, [testGlassInfillMaterial, glassInfillMaterialName]);
|
|
2039
|
+
const hingeBodyMaterial = React.useMemo(() => new THREE__namespace.MeshStandardMaterial({
|
|
2068
2040
|
color: "#d4d4d4",
|
|
2069
2041
|
metalness: 1.0,
|
|
2070
2042
|
roughness: 0.4
|
|
2071
2043
|
}), [testHingeMaterial, hingeMaterialName]);
|
|
2072
|
-
React.useMemo(() =>
|
|
2073
|
-
React.useMemo(() =>
|
|
2074
|
-
const frontDoorPlaneMaterial = React.useMemo(() =>
|
|
2075
|
-
const backDoorPlaneMaterial = React.useMemo(() =>
|
|
2044
|
+
React.useMemo(() => placeholderMaterial, [testFrontCoverPanelMaterial, frontCoverPanelMaterialName]);
|
|
2045
|
+
React.useMemo(() => placeholderMaterial, [testBackCoverPanelMaterial, backCoverPanelMaterialName]);
|
|
2046
|
+
const frontDoorPlaneMaterial = React.useMemo(() => placeholderMaterial, [testFrontDoorPlaneMaterial, frontDoorPlaneMaterialName]);
|
|
2047
|
+
const backDoorPlaneMaterial = React.useMemo(() => placeholderMaterial, [testBackDoorPlaneMaterial, backDoorPlaneMaterialName]);
|
|
2076
2048
|
const hingeAccentMaterial = React.useMemo(() => new THREE__namespace.MeshStandardMaterial({
|
|
2077
2049
|
color: "#1a1a1a",
|
|
2078
2050
|
roughness: 0.1
|
|
@@ -2468,11 +2440,12 @@ function DoorLeaf(_ref8) {
|
|
|
2468
2440
|
const DoorConfigurator = _ref => {
|
|
2469
2441
|
let {
|
|
2470
2442
|
doorName,
|
|
2471
|
-
|
|
2472
|
-
|
|
2443
|
+
is2D = false,
|
|
2444
|
+
materials
|
|
2473
2445
|
} = _ref;
|
|
2474
2446
|
return /*#__PURE__*/jsxRuntime.jsx(ConfiguratorProvider, {
|
|
2475
2447
|
initialIs2D: is2D,
|
|
2448
|
+
initialMaterials: materials,
|
|
2476
2449
|
children: /*#__PURE__*/jsxRuntime.jsx(DoorModels, {
|
|
2477
2450
|
doorName: doorName
|
|
2478
2451
|
})
|