door_models 5.2.1 → 5.2.2
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 +61 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +61 -17
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -73,8 +73,10 @@ const ConfiguratorContext = /*#__PURE__*/createContext(undefined);
|
|
|
73
73
|
const ConfiguratorProvider = _ref => {
|
|
74
74
|
let {
|
|
75
75
|
children,
|
|
76
|
-
initialIs2D = false
|
|
76
|
+
initialIs2D = false,
|
|
77
|
+
initialMaterials = {}
|
|
77
78
|
} = _ref;
|
|
79
|
+
const [materials, setMaterials] = useState(initialMaterials);
|
|
78
80
|
const [is2D, setIs2D] = useState(initialIs2D);
|
|
79
81
|
const [isPlaneVisible, setIsPlaneVisible] = useState(false);
|
|
80
82
|
const [isFrameVisible, setIsFrameVisible] = useState(true);
|
|
@@ -162,8 +164,6 @@ const ConfiguratorProvider = _ref => {
|
|
|
162
164
|
depth: 20
|
|
163
165
|
});
|
|
164
166
|
const defaultOptions = ["D_PRF_COLOR", "D_FR_SRF_DECOR", "D_FR_SRF_DECOR_S2"];
|
|
165
|
-
|
|
166
|
-
// Function to pick the first valid value
|
|
167
167
|
function getFirstValidValue(values, isValid) {
|
|
168
168
|
for (const val of values) {
|
|
169
169
|
if (isValid(val)) return val;
|
|
@@ -196,6 +196,11 @@ const ConfiguratorProvider = _ref => {
|
|
|
196
196
|
useEffect(() => {
|
|
197
197
|
setIs2D(initialIs2D);
|
|
198
198
|
}, [initialIs2D]);
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
if (initialMaterials) {
|
|
201
|
+
setMaterials(initialMaterials);
|
|
202
|
+
}
|
|
203
|
+
}, [initialMaterials]);
|
|
199
204
|
const handleParseCpid = useCallback(cpidToParse => {
|
|
200
205
|
const showMessage = function (text) {
|
|
201
206
|
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "error";
|
|
@@ -658,6 +663,7 @@ const ConfiguratorProvider = _ref => {
|
|
|
658
663
|
}, [totalWidth, doorFrame.sidesThk, isDoubleDoor]);
|
|
659
664
|
return /*#__PURE__*/jsx(ConfiguratorContext.Provider, {
|
|
660
665
|
value: {
|
|
666
|
+
materials,
|
|
661
667
|
is2D,
|
|
662
668
|
setIs2D,
|
|
663
669
|
isPlaneVisible,
|
|
@@ -744,8 +750,35 @@ const useConfigurator = () => {
|
|
|
744
750
|
return context;
|
|
745
751
|
};
|
|
746
752
|
|
|
753
|
+
const isUrl = string => {
|
|
754
|
+
try {
|
|
755
|
+
new URL(string);
|
|
756
|
+
return true;
|
|
757
|
+
} catch (_) {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
const createMaterialFromProp = value => {
|
|
762
|
+
if (!value) return null;
|
|
763
|
+
if (value.startsWith("#")) {
|
|
764
|
+
return new THREE.MeshStandardMaterial({
|
|
765
|
+
color: value,
|
|
766
|
+
roughness: 0.8
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
if (isUrl(value)) {
|
|
770
|
+
const texture = textureLoader.load(value);
|
|
771
|
+
texture.wrapS = THREE.RepeatWrapping;
|
|
772
|
+
texture.wrapT = THREE.RepeatWrapping;
|
|
773
|
+
return new THREE.MeshStandardMaterial({
|
|
774
|
+
map: texture,
|
|
775
|
+
roughness: 0.8
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
return null;
|
|
779
|
+
};
|
|
747
780
|
const textureLoader = new THREE.TextureLoader();
|
|
748
|
-
const bodyInt = textureLoader.load("
|
|
781
|
+
const bodyInt = textureLoader.load("http://192.168.30.92:3009/api/proxy?path=IVIS/E_TEX00.JPG");
|
|
749
782
|
const bodyExt = textureLoader.load("https://threejs.org/examples/textures/brick_diffuse.jpg");
|
|
750
783
|
const frameAlu = textureLoader.load("https://threejs.org/examples/textures/brick_diffuse.jpg");
|
|
751
784
|
const frameWoodenInt = textureLoader.load("https://threejs.org/examples/textures/brick_diffuse.jpg");
|
|
@@ -1365,7 +1398,8 @@ function DoorModels(_ref7) {
|
|
|
1365
1398
|
glassDepth,
|
|
1366
1399
|
cpid,
|
|
1367
1400
|
handleParseCpid,
|
|
1368
|
-
isDoubleDoor
|
|
1401
|
+
isDoubleDoor,
|
|
1402
|
+
materials
|
|
1369
1403
|
} = useConfigurator();
|
|
1370
1404
|
useEffect(() => {
|
|
1371
1405
|
if (doorName) {
|
|
@@ -1407,29 +1441,38 @@ function DoorModels(_ref7) {
|
|
|
1407
1441
|
const {
|
|
1408
1442
|
material: backDoorPlaneMaterialName
|
|
1409
1443
|
} = backDoorPlane;
|
|
1410
|
-
|
|
1444
|
+
const pers = useMemo(() => {
|
|
1445
|
+
const dynamicMaterials = {};
|
|
1446
|
+
for (const key in materials) {
|
|
1447
|
+
if (Object.prototype.hasOwnProperty.call(materials, key)) {
|
|
1448
|
+
const value = materials[key];
|
|
1449
|
+
dynamicMaterials[key] = createMaterialFromProp(value);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
return dynamicMaterials;
|
|
1453
|
+
}, [materials]);
|
|
1411
1454
|
// --- Material Logic ---
|
|
1412
1455
|
useMemo(() => availableMaterials[testDoorMaterial] || availableMaterials[doorMaterialName] || placeholderMaterial, [testDoorMaterial, doorMaterialName]);
|
|
1413
|
-
const frameMaterial = useMemo(() => availableMaterials[testFrameMaterial] || availableMaterials[frameMaterialName] || placeholderMaterialforFrames, [testFrameMaterial, frameMaterialName]);
|
|
1414
|
-
const gasketMaterial = useMemo(() => availableMaterials[testGasketMaterial] || availableMaterials[gasketMaterialName] || new THREE.MeshStandardMaterial({
|
|
1456
|
+
const frameMaterial = useMemo(() => pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || availableMaterials[testFrameMaterial] || availableMaterials[frameMaterialName] || placeholderMaterialforFrames, [testFrameMaterial, frameMaterialName]);
|
|
1457
|
+
const gasketMaterial = useMemo(() => pers.D_GASKET || availableMaterials[testGasketMaterial] || availableMaterials[gasketMaterialName] || new THREE.MeshStandardMaterial({
|
|
1415
1458
|
color: "#111111"
|
|
1416
1459
|
}), [testGasketMaterial, gasketMaterialName]);
|
|
1417
1460
|
const doorStopMaterial = useMemo(() => {
|
|
1418
|
-
return availableMaterials[testDoorStopMaterial] || availableMaterials[doorStopMaterialName || ""] || frameMaterial;
|
|
1461
|
+
return pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || availableMaterials[testDoorStopMaterial] || availableMaterials[doorStopMaterialName || ""] || frameMaterial;
|
|
1419
1462
|
}, [testDoorStopMaterial, doorStopMaterialName, frameType, frameMaterial]);
|
|
1420
|
-
const interiorFanlightMaterial = useMemo(() => availableMaterials[testInteriorFanlightMaterial] || availableMaterials[interiorFanlightMaterialName] || placeholderMaterial, [testInteriorFanlightMaterial, interiorFanlightMaterialName]);
|
|
1463
|
+
const interiorFanlightMaterial = useMemo(() => pers.D_SRF_DECOR_2 || availableMaterials[testInteriorFanlightMaterial] || availableMaterials[interiorFanlightMaterialName] || placeholderMaterial, [testInteriorFanlightMaterial, interiorFanlightMaterialName]);
|
|
1421
1464
|
const exteriorFanlightMaterial = useMemo(() => availableMaterials[testExteriorFanlightMaterial] || availableMaterials[exteriorFanlightMaterialName] || placeholderMaterial, [testExteriorFanlightMaterial, exteriorFanlightMaterialName]);
|
|
1422
1465
|
useMemo(() => availableMaterials[testOcculusInfillMaterial] || availableMaterials[occulusInfillMaterialName] || placeholderMaterial, [testOcculusInfillMaterial, occulusInfillMaterialName]);
|
|
1423
|
-
const glassInfillMaterial = useMemo(() => availableMaterials[testGlassInfillMaterial] || availableMaterials[glassInfillMaterialName] || placeholderMaterial, [testGlassInfillMaterial, glassInfillMaterialName]);
|
|
1466
|
+
const glassInfillMaterial = useMemo(() => pers.D_FR_COLOR || availableMaterials[testGlassInfillMaterial] || availableMaterials[glassInfillMaterialName] || placeholderMaterial, [testGlassInfillMaterial, glassInfillMaterialName]);
|
|
1424
1467
|
useMemo(() => availableMaterials[testHingeMaterial] || availableMaterials[hingeMaterialName] || new THREE.MeshStandardMaterial({
|
|
1425
1468
|
color: "#d4d4d4",
|
|
1426
1469
|
metalness: 1.0,
|
|
1427
1470
|
roughness: 0.4
|
|
1428
1471
|
}), [testHingeMaterial, hingeMaterialName]);
|
|
1429
|
-
const frontCoverPanelMaterial = useMemo(() => availableMaterials[testFrontCoverPanelMaterial] || availableMaterials[frontCoverPanelMaterialName] || placeholderMaterial, [testFrontCoverPanelMaterial, frontCoverPanelMaterialName]);
|
|
1430
|
-
const backCoverPanelMaterial = useMemo(() => availableMaterials[testBackCoverPanelMaterial] || availableMaterials[backCoverPanelMaterialName] || placeholderMaterial, [testBackCoverPanelMaterial, backCoverPanelMaterialName]);
|
|
1431
|
-
useMemo(() => availableMaterials[testFrontDoorPlaneMaterial] || availableMaterials[frontDoorPlaneMaterialName] || placeholderMaterial, [testFrontDoorPlaneMaterial, frontDoorPlaneMaterialName]);
|
|
1432
|
-
useMemo(() => availableMaterials[testBackDoorPlaneMaterial] || availableMaterials[backDoorPlaneMaterialName] || placeholderMaterial, [testBackDoorPlaneMaterial, backDoorPlaneMaterialName]);
|
|
1472
|
+
const frontCoverPanelMaterial = useMemo(() => pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || availableMaterials[testFrontCoverPanelMaterial] || availableMaterials[frontCoverPanelMaterialName] || placeholderMaterial, [testFrontCoverPanelMaterial, frontCoverPanelMaterialName]);
|
|
1473
|
+
const backCoverPanelMaterial = useMemo(() => pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || availableMaterials[testBackCoverPanelMaterial] || availableMaterials[backCoverPanelMaterialName] || placeholderMaterial, [testBackCoverPanelMaterial, backCoverPanelMaterialName]);
|
|
1474
|
+
useMemo(() => pers.D_SRF_DECOR_2 || availableMaterials[testFrontDoorPlaneMaterial] || availableMaterials[frontDoorPlaneMaterialName] || placeholderMaterial, [testFrontDoorPlaneMaterial, frontDoorPlaneMaterialName]);
|
|
1475
|
+
useMemo(() => pers.D_SRF_DECOR || availableMaterials[testBackDoorPlaneMaterial] || availableMaterials[backDoorPlaneMaterialName] || placeholderMaterial, [testBackDoorPlaneMaterial, backDoorPlaneMaterialName]);
|
|
1433
1476
|
useMemo(() => new THREE.MeshStandardMaterial({
|
|
1434
1477
|
color: "#1a1a1a",
|
|
1435
1478
|
roughness: 0.1
|
|
@@ -2441,11 +2484,12 @@ function DoorLeaf(_ref8) {
|
|
|
2441
2484
|
const DoorConfigurator = _ref => {
|
|
2442
2485
|
let {
|
|
2443
2486
|
doorName,
|
|
2444
|
-
|
|
2445
|
-
|
|
2487
|
+
is2D = false,
|
|
2488
|
+
materials
|
|
2446
2489
|
} = _ref;
|
|
2447
2490
|
return /*#__PURE__*/jsx(ConfiguratorProvider, {
|
|
2448
2491
|
initialIs2D: is2D,
|
|
2492
|
+
initialMaterials: materials,
|
|
2449
2493
|
children: /*#__PURE__*/jsx(DoorModels, {
|
|
2450
2494
|
doorName: doorName
|
|
2451
2495
|
})
|