door_models 5.4.1 → 5.4.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 CHANGED
@@ -8,6 +8,7 @@ var csg = require('@react-three/csg');
8
8
  var three = require('@react-spring/three');
9
9
  var THREE = require('three');
10
10
  var drei = require('@react-three/drei');
11
+ var fiber = require('@react-three/fiber');
11
12
 
12
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
14
 
@@ -102,8 +103,7 @@ const ConfiguratorProvider = _ref => {
102
103
  let {
103
104
  children,
104
105
  initialIs2D = false,
105
- initialMaterials = {},
106
- totalDepth
106
+ initialMaterials = {}
107
107
  } = _ref;
108
108
  const [materials, setMaterials] = React.useState(initialMaterials);
109
109
  const [is2D, setIs2D] = React.useState(initialIs2D);
@@ -600,35 +600,13 @@ const ConfiguratorProvider = _ref => {
600
600
  };
601
601
  break;
602
602
  }
603
- const baseTotalDepth = 103; // Define the reference depth for scaling (103mm is a common default)
604
- const scaleFactor = totalDepth !== undefined && baseTotalDepth > 0 ? totalDepth / baseTotalDepth : 1;
605
-
606
- // Apply the scaling factor to all depth-related settings
607
- if (scaleFactor !== 1) {
608
- if (newSettings.frameDepth !== undefined) newSettings.frameDepth *= scaleFactor;
609
- if (newSettings.doorDepth !== undefined) newSettings.doorDepth *= scaleFactor;
610
- if (newSettings.doorStopDepth !== undefined) newSettings.doorStopDepth *= scaleFactor;
611
- if (newSettings.secondDoorStopDepth !== undefined) newSettings.secondDoorStopDepth *= scaleFactor;
612
- if (newSettings.gasketDepth !== undefined) newSettings.gasketDepth *= scaleFactor;
613
-
614
- // Handle string-based depths like "40mm" for notchDepth
615
- if (typeof newSettings.notchDepth === "string") {
616
- const num = parseInt(newSettings.notchDepth, 10);
617
- if (!isNaN(num)) {
618
- newSettings.notchDepth = "".concat(num * scaleFactor, "mm");
619
- }
620
- }
621
- }
622
603
  const isMxCaf = frameType.startsWith("MXCAF");
623
604
  setFrontCoverPanel(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
624
- visible: isMxCaf,
625
- depth: 12 * scaleFactor
605
+ visible: isMxCaf
626
606
  }));
627
607
  setBackCoverPanel(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
628
- visible: isMxCaf,
629
- depth: 12 * scaleFactor
608
+ visible: isMxCaf
630
609
  }));
631
- setGlassDepth(8 * scaleFactor);
632
610
  const {
633
611
  doorDepth
634
612
  } = newSettings,
@@ -639,7 +617,7 @@ const ConfiguratorProvider = _ref => {
639
617
  theDoorDepth: doorDepth
640
618
  }));
641
619
  }
642
- }, [frameType, totalDepth]);
620
+ }, [frameType]);
643
621
 
644
622
  // --- Exterior Fanlight Logic ---
645
623
  React.useEffect(() => {
@@ -854,7 +832,8 @@ const isHexColor = str => /^#([0-9A-F]{3}){1,2}$/i.test(str);
854
832
  * @param textures - A map of URL -> THREE.Texture, provided by useTexture.
855
833
  * @returns A THREE.MeshStandardMaterial instance.
856
834
  */
857
- const buildMaterial = (prop, textures) => {
835
+ const BuildMaterial = (prop, textures) => {
836
+ const texture = fiber.useLoader(THREE.TextureLoader, "https://threejs.org/examples/textures/hardwood2_diffuse.jpg");
858
837
  if (!prop) {
859
838
  return new THREE__namespace.MeshStandardMaterial({
860
839
  color: "#cccccc",
@@ -864,15 +843,14 @@ const buildMaterial = (prop, textures) => {
864
843
  const sourceValue = typeof prop === "string" ? prop : prop.value;
865
844
  const opacity = typeof prop === "object" ? prop.opacity : 1;
866
845
  const params = {
867
- roughness: 0.8,
868
- side: THREE__namespace.DoubleSide
846
+ roughness: 0.8
869
847
  };
870
848
  if (isHexColor(sourceValue)) {
871
849
  params.color = sourceValue;
872
850
  } else if (textures && textures[sourceValue]) {
873
- params.map = textures[sourceValue];
851
+ params.map = texture;
874
852
  } else {
875
- params.color = "yellow";
853
+ params.color = "#cccccc";
876
854
  }
877
855
  if (opacity !== undefined && opacity < 1) {
878
856
  params.transparent = true;
@@ -926,7 +904,7 @@ const useDoorMaterials = function () {
926
904
  // 4. Now that textures are guaranteed to be loaded, build all materials.
927
905
  // This memo ensures the materials are only created when props or textures change.
928
906
  return React.useMemo(() => {
929
- const build = prop => buildMaterial(prop, textureMap);
907
+ const build = prop => BuildMaterial(prop, textureMap);
930
908
  return {
931
909
  doorMaterial: build(materialsProp.Body),
932
910
  frameMaterial: build(getFirstValidValue([materialsProp.D_PRF_COLOR, materialsProp.D_FR_SRF_DECOR, materialsProp.D_FR_SRF_DECOR_S2])),
@@ -2311,24 +2289,20 @@ const DoorConfigurator = _ref => {
2311
2289
  is2D = false,
2312
2290
  totalWidth,
2313
2291
  totalHeight,
2314
- totalDepth // Destructure the new prop
2292
+ frameDepth
2315
2293
  } = _ref;
2316
- return (
2317
- /*#__PURE__*/
2318
- // Pass the totalDepth prop to the Provider
2319
- jsxRuntime.jsx(ConfiguratorProvider, {
2320
- initialIs2D: is2D,
2321
- totalDepth: totalDepth,
2322
- children: /*#__PURE__*/jsxRuntime.jsx(DoorModels, {
2323
- doorName: doorName,
2324
- materials: materials,
2325
- doorPivot: doorPivot,
2326
- doorOpening: doorOpening,
2327
- totalWidth: totalWidth,
2328
- totalHeight: totalHeight
2329
- })
2294
+ return /*#__PURE__*/jsxRuntime.jsx(ConfiguratorProvider, {
2295
+ initialIs2D: is2D,
2296
+ children: /*#__PURE__*/jsxRuntime.jsx(DoorModels, {
2297
+ doorName: doorName,
2298
+ materials: materials,
2299
+ doorPivot: doorPivot,
2300
+ doorOpening: doorOpening,
2301
+ totalWidth: totalWidth,
2302
+ totalHeight: totalHeight,
2303
+ frameDepth: frameDepth
2330
2304
  })
2331
- );
2305
+ });
2332
2306
  };
2333
2307
 
2334
2308
  exports["default"] = DoorConfigurator;