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.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,8 +777,35 @@ const useConfigurator = () => {
|
|
|
771
777
|
return context;
|
|
772
778
|
};
|
|
773
779
|
|
|
780
|
+
const isUrl = string => {
|
|
781
|
+
try {
|
|
782
|
+
new URL(string);
|
|
783
|
+
return true;
|
|
784
|
+
} catch (_) {
|
|
785
|
+
return false;
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
const createMaterialFromProp = value => {
|
|
789
|
+
if (!value) return null;
|
|
790
|
+
if (value.startsWith("#")) {
|
|
791
|
+
return new THREE__namespace.MeshStandardMaterial({
|
|
792
|
+
color: value,
|
|
793
|
+
roughness: 0.8
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
if (isUrl(value)) {
|
|
797
|
+
const texture = textureLoader.load(value);
|
|
798
|
+
texture.wrapS = THREE__namespace.RepeatWrapping;
|
|
799
|
+
texture.wrapT = THREE__namespace.RepeatWrapping;
|
|
800
|
+
return new THREE__namespace.MeshStandardMaterial({
|
|
801
|
+
map: texture,
|
|
802
|
+
roughness: 0.8
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
return null;
|
|
806
|
+
};
|
|
774
807
|
const textureLoader = new THREE__namespace.TextureLoader();
|
|
775
|
-
const bodyInt = textureLoader.load("
|
|
808
|
+
const bodyInt = textureLoader.load("http://192.168.30.92:3009/api/proxy?path=IVIS/E_TEX00.JPG");
|
|
776
809
|
const bodyExt = textureLoader.load("https://threejs.org/examples/textures/brick_diffuse.jpg");
|
|
777
810
|
const frameAlu = textureLoader.load("https://threejs.org/examples/textures/brick_diffuse.jpg");
|
|
778
811
|
const frameWoodenInt = textureLoader.load("https://threejs.org/examples/textures/brick_diffuse.jpg");
|
|
@@ -1392,7 +1425,8 @@ function DoorModels(_ref7) {
|
|
|
1392
1425
|
glassDepth,
|
|
1393
1426
|
cpid,
|
|
1394
1427
|
handleParseCpid,
|
|
1395
|
-
isDoubleDoor
|
|
1428
|
+
isDoubleDoor,
|
|
1429
|
+
materials
|
|
1396
1430
|
} = useConfigurator();
|
|
1397
1431
|
React.useEffect(() => {
|
|
1398
1432
|
if (doorName) {
|
|
@@ -1434,29 +1468,38 @@ function DoorModels(_ref7) {
|
|
|
1434
1468
|
const {
|
|
1435
1469
|
material: backDoorPlaneMaterialName
|
|
1436
1470
|
} = backDoorPlane;
|
|
1437
|
-
|
|
1471
|
+
const pers = React.useMemo(() => {
|
|
1472
|
+
const dynamicMaterials = {};
|
|
1473
|
+
for (const key in materials) {
|
|
1474
|
+
if (Object.prototype.hasOwnProperty.call(materials, key)) {
|
|
1475
|
+
const value = materials[key];
|
|
1476
|
+
dynamicMaterials[key] = createMaterialFromProp(value);
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
return dynamicMaterials;
|
|
1480
|
+
}, [materials]);
|
|
1438
1481
|
// --- Material Logic ---
|
|
1439
1482
|
React.useMemo(() => availableMaterials[testDoorMaterial] || availableMaterials[doorMaterialName] || placeholderMaterial, [testDoorMaterial, doorMaterialName]);
|
|
1440
|
-
const frameMaterial = React.useMemo(() => availableMaterials[testFrameMaterial] || availableMaterials[frameMaterialName] || placeholderMaterialforFrames, [testFrameMaterial, frameMaterialName]);
|
|
1441
|
-
const gasketMaterial = React.useMemo(() => availableMaterials[testGasketMaterial] || availableMaterials[gasketMaterialName] || new THREE__namespace.MeshStandardMaterial({
|
|
1483
|
+
const frameMaterial = React.useMemo(() => pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || availableMaterials[testFrameMaterial] || availableMaterials[frameMaterialName] || placeholderMaterialforFrames, [testFrameMaterial, frameMaterialName]);
|
|
1484
|
+
const gasketMaterial = React.useMemo(() => pers.D_GASKET || availableMaterials[testGasketMaterial] || availableMaterials[gasketMaterialName] || new THREE__namespace.MeshStandardMaterial({
|
|
1442
1485
|
color: "#111111"
|
|
1443
1486
|
}), [testGasketMaterial, gasketMaterialName]);
|
|
1444
1487
|
const doorStopMaterial = React.useMemo(() => {
|
|
1445
|
-
return availableMaterials[testDoorStopMaterial] || availableMaterials[doorStopMaterialName || ""] || frameMaterial;
|
|
1488
|
+
return pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || availableMaterials[testDoorStopMaterial] || availableMaterials[doorStopMaterialName || ""] || frameMaterial;
|
|
1446
1489
|
}, [testDoorStopMaterial, doorStopMaterialName, frameType, frameMaterial]);
|
|
1447
|
-
const interiorFanlightMaterial = React.useMemo(() => availableMaterials[testInteriorFanlightMaterial] || availableMaterials[interiorFanlightMaterialName] || placeholderMaterial, [testInteriorFanlightMaterial, interiorFanlightMaterialName]);
|
|
1490
|
+
const interiorFanlightMaterial = React.useMemo(() => pers.D_SRF_DECOR_2 || availableMaterials[testInteriorFanlightMaterial] || availableMaterials[interiorFanlightMaterialName] || placeholderMaterial, [testInteriorFanlightMaterial, interiorFanlightMaterialName]);
|
|
1448
1491
|
const exteriorFanlightMaterial = React.useMemo(() => availableMaterials[testExteriorFanlightMaterial] || availableMaterials[exteriorFanlightMaterialName] || placeholderMaterial, [testExteriorFanlightMaterial, exteriorFanlightMaterialName]);
|
|
1449
1492
|
React.useMemo(() => availableMaterials[testOcculusInfillMaterial] || availableMaterials[occulusInfillMaterialName] || placeholderMaterial, [testOcculusInfillMaterial, occulusInfillMaterialName]);
|
|
1450
|
-
const glassInfillMaterial = React.useMemo(() => availableMaterials[testGlassInfillMaterial] || availableMaterials[glassInfillMaterialName] || placeholderMaterial, [testGlassInfillMaterial, glassInfillMaterialName]);
|
|
1493
|
+
const glassInfillMaterial = React.useMemo(() => pers.D_FR_COLOR || availableMaterials[testGlassInfillMaterial] || availableMaterials[glassInfillMaterialName] || placeholderMaterial, [testGlassInfillMaterial, glassInfillMaterialName]);
|
|
1451
1494
|
React.useMemo(() => availableMaterials[testHingeMaterial] || availableMaterials[hingeMaterialName] || new THREE__namespace.MeshStandardMaterial({
|
|
1452
1495
|
color: "#d4d4d4",
|
|
1453
1496
|
metalness: 1.0,
|
|
1454
1497
|
roughness: 0.4
|
|
1455
1498
|
}), [testHingeMaterial, hingeMaterialName]);
|
|
1456
|
-
const frontCoverPanelMaterial = React.useMemo(() => availableMaterials[testFrontCoverPanelMaterial] || availableMaterials[frontCoverPanelMaterialName] || placeholderMaterial, [testFrontCoverPanelMaterial, frontCoverPanelMaterialName]);
|
|
1457
|
-
const backCoverPanelMaterial = React.useMemo(() => availableMaterials[testBackCoverPanelMaterial] || availableMaterials[backCoverPanelMaterialName] || placeholderMaterial, [testBackCoverPanelMaterial, backCoverPanelMaterialName]);
|
|
1458
|
-
React.useMemo(() => availableMaterials[testFrontDoorPlaneMaterial] || availableMaterials[frontDoorPlaneMaterialName] || placeholderMaterial, [testFrontDoorPlaneMaterial, frontDoorPlaneMaterialName]);
|
|
1459
|
-
React.useMemo(() => availableMaterials[testBackDoorPlaneMaterial] || availableMaterials[backDoorPlaneMaterialName] || placeholderMaterial, [testBackDoorPlaneMaterial, backDoorPlaneMaterialName]);
|
|
1499
|
+
const frontCoverPanelMaterial = React.useMemo(() => pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || availableMaterials[testFrontCoverPanelMaterial] || availableMaterials[frontCoverPanelMaterialName] || placeholderMaterial, [testFrontCoverPanelMaterial, frontCoverPanelMaterialName]);
|
|
1500
|
+
const backCoverPanelMaterial = React.useMemo(() => pers.D_PRF_COLOR || pers.D_FR_SRF_DECOR || pers.D_FR_SRF_DECOR_S2 || availableMaterials[testBackCoverPanelMaterial] || availableMaterials[backCoverPanelMaterialName] || placeholderMaterial, [testBackCoverPanelMaterial, backCoverPanelMaterialName]);
|
|
1501
|
+
React.useMemo(() => pers.D_SRF_DECOR_2 || availableMaterials[testFrontDoorPlaneMaterial] || availableMaterials[frontDoorPlaneMaterialName] || placeholderMaterial, [testFrontDoorPlaneMaterial, frontDoorPlaneMaterialName]);
|
|
1502
|
+
React.useMemo(() => pers.D_SRF_DECOR || availableMaterials[testBackDoorPlaneMaterial] || availableMaterials[backDoorPlaneMaterialName] || placeholderMaterial, [testBackDoorPlaneMaterial, backDoorPlaneMaterialName]);
|
|
1460
1503
|
React.useMemo(() => new THREE__namespace.MeshStandardMaterial({
|
|
1461
1504
|
color: "#1a1a1a",
|
|
1462
1505
|
roughness: 0.1
|
|
@@ -2468,11 +2511,12 @@ function DoorLeaf(_ref8) {
|
|
|
2468
2511
|
const DoorConfigurator = _ref => {
|
|
2469
2512
|
let {
|
|
2470
2513
|
doorName,
|
|
2471
|
-
|
|
2472
|
-
|
|
2514
|
+
is2D = false,
|
|
2515
|
+
materials
|
|
2473
2516
|
} = _ref;
|
|
2474
2517
|
return /*#__PURE__*/jsxRuntime.jsx(ConfiguratorProvider, {
|
|
2475
2518
|
initialIs2D: is2D,
|
|
2519
|
+
initialMaterials: materials,
|
|
2476
2520
|
children: /*#__PURE__*/jsxRuntime.jsx(DoorModels, {
|
|
2477
2521
|
doorName: doorName
|
|
2478
2522
|
})
|