door_models 5.4.3 → 5.4.5

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
@@ -111,6 +111,7 @@ const ConfiguratorProvider = _ref => {
111
111
  const [cpid, setCpid] = React.useState("");
112
112
  const [totalHeight, setTotalHeight] = React.useState(2700);
113
113
  const [totalWidth, setTotalWidth] = React.useState(974);
114
+ const [totalDepth, setTotalDepth] = React.useState(103);
114
115
  const [glassVisible, setGlassVisible] = React.useState(false);
115
116
  const [glassDepth, setGlassDepth] = React.useState(8);
116
117
  const [isDoubleDoor, setIsDoubleDoor] = React.useState(false);
@@ -191,6 +192,7 @@ const ConfiguratorProvider = _ref => {
191
192
  material: "infill_material",
192
193
  depth: 20
193
194
  });
195
+ const [baseConfig, setBaseConfig] = React.useState(null);
194
196
  const [frameType, setFrameType] = React.useState("AF20_40");
195
197
  const [bodyType, setBodyType] = React.useState("40");
196
198
  const [exteriorFanlightType, setExteriorFanlightType] = React.useState("WPFL");
@@ -599,6 +601,9 @@ const ConfiguratorProvider = _ref => {
599
601
  };
600
602
  break;
601
603
  }
604
+
605
+ // Store pristine settings for scaling
606
+ setBaseConfig(newSettings);
602
607
  const isMxCaf = frameType.startsWith("MXCAF");
603
608
  setFrontCoverPanel(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
604
609
  visible: isMxCaf
@@ -616,8 +621,65 @@ const ConfiguratorProvider = _ref => {
616
621
  theDoorDepth: doorDepth
617
622
  }));
618
623
  }
624
+
625
+ // Sync totalDepth with the frame's default depth when frame type changes.
626
+ if (newSettings.frameDepth) {
627
+ setTotalDepth(newSettings.frameDepth);
628
+ }
619
629
  }, [frameType]);
620
630
 
631
+ // --- useEffect for scaling based on totalDepth ---
632
+ React.useEffect(() => {
633
+ if (!baseConfig || !baseConfig.frameDepth || baseConfig.frameDepth === 0) return;
634
+ const baseFrameDepth = baseConfig.frameDepth;
635
+ const ratio = totalDepth / baseFrameDepth;
636
+ const scaleProportionally = value => {
637
+ if (typeof value === "number") {
638
+ return value * ratio;
639
+ }
640
+ if (typeof value === "string" && value.endsWith("mm")) {
641
+ const num = parseFloat(value);
642
+ if (!isNaN(num)) {
643
+ return num * ratio + "mm";
644
+ }
645
+ }
646
+ return value; // Return original if not scalable
647
+ };
648
+ setDoorFrame(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
649
+ frameDepth: totalDepth,
650
+ doorStopDepth: scaleProportionally(baseConfig.doorStopDepth),
651
+ notchDepth: scaleProportionally(baseConfig.notchDepth),
652
+ gasketDepth: scaleProportionally(baseConfig.gasketDepth),
653
+ secondDoorStopDepth: scaleProportionally(baseConfig.secondDoorStopDepth)
654
+ }));
655
+ if (baseConfig.doorDepth !== undefined) {
656
+ const baseDoorDepth = baseConfig.doorDepth;
657
+ const frameDelta = totalDepth - baseFrameDepth;
658
+ let newDoorDepth;
659
+ if (frameDelta > 0) {
660
+ // --- THIS IS THE VALUE TO TWEAK ---
661
+ // Increase this multiplier to make the door body grow faster when totalDepth increases.
662
+ // A value of 1.0 means it grows at the same rate as the frame.
663
+ // A value of 2.0 means it grows twice as fast as the frame.
664
+ const increaseMultiplier = 0.8;
665
+ newDoorDepth = baseDoorDepth + frameDelta * increaseMultiplier;
666
+ } else {
667
+ // When decreasing totalDepth, the door body scales down proportionally.
668
+ newDoorDepth = baseDoorDepth * ratio;
669
+ }
670
+ setDoor(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
671
+ theDoorDepth: newDoorDepth
672
+ }));
673
+ }
674
+ const baseCoverPanelDepth = 12;
675
+ setFrontCoverPanel(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
676
+ depth: baseCoverPanelDepth * ratio
677
+ }));
678
+ setBackCoverPanel(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
679
+ depth: baseCoverPanelDepth * ratio
680
+ }));
681
+ }, [totalDepth, baseConfig]);
682
+
621
683
  // --- Exterior Fanlight Logic ---
622
684
  React.useEffect(() => {
623
685
  if (!exteriorFanlight.visible) return;
@@ -698,6 +760,8 @@ const ConfiguratorProvider = _ref => {
698
760
  setBodyType,
699
761
  totalHeight,
700
762
  setTotalHeight,
763
+ totalDepth,
764
+ setTotalDepth,
701
765
  totalWidth,
702
766
  setTotalWidth,
703
767
  exteriorFanlightType,
@@ -823,21 +887,39 @@ const buildMaterial = (prop, textures) => {
823
887
  }
824
888
  const sourceValue = typeof prop === "string" ? prop : prop.value;
825
889
  const opacity = typeof prop === "object" ? prop.opacity : 1;
890
+
891
+ // Start with base parameters.
826
892
  const params = {
827
893
  roughness: 0.8,
828
894
  side: THREE__namespace.DoubleSide
829
895
  };
830
896
  if (isHexColor(sourceValue)) {
897
+ // It's a color. Explicitly set the color and ensure no texture is applied.
831
898
  params.color = sourceValue;
832
- } else if (textures && textures[sourceValue]) {
833
- params.map = textures[sourceValue];
899
+ params.map = null;
834
900
  } else {
835
- const texture = new THREE__namespace.TextureLoader().load(sourceValue);
901
+ // It's a texture. Explicitly set the color to white to avoid tinting the texture.
902
+ params.color = "#ffffff";
903
+ let texture = null;
904
+ if (textures && textures[sourceValue]) {
905
+ // Use the pre-loaded texture.
906
+ texture = textures[sourceValue];
907
+ } else if (sourceValue) {
908
+ // Not pre-loaded, so load it now.
909
+ // TextureLoader caches results internally, so this is efficient.
910
+ texture = new THREE__namespace.TextureLoader().load(sourceValue);
911
+ }
836
912
  params.map = texture;
837
913
  }
914
+
915
+ // Handle transparency explicitly to prevent lingering state.
838
916
  if (opacity !== undefined && opacity < 1) {
839
917
  params.transparent = true;
840
918
  params.opacity = opacity;
919
+ } else {
920
+ // Explicitly turn transparency off if opacity is 1 or undefined.
921
+ params.transparent = false;
922
+ params.opacity = 1;
841
923
  }
842
924
  return new THREE__namespace.MeshStandardMaterial(params);
843
925
  };
@@ -1410,7 +1492,7 @@ function DoorModels(_ref7) {
1410
1492
  doorOpening: doorOpeningProp,
1411
1493
  totalWidth: totalWidthProp,
1412
1494
  totalHeight: totalHeightProp,
1413
- frameDepth: frameDepthProp
1495
+ totalDepth: totalDepthProp
1414
1496
  } = _ref7;
1415
1497
  const {
1416
1498
  is2D,
@@ -1431,7 +1513,8 @@ function DoorModels(_ref7) {
1431
1513
  isDoubleDoor,
1432
1514
  setMaterials,
1433
1515
  setTotalWidth,
1434
- setTotalHeight
1516
+ setTotalHeight,
1517
+ setTotalDepth
1435
1518
  } = useConfigurator();
1436
1519
  React.useEffect(() => {
1437
1520
  if (doorName) {
@@ -1463,12 +1546,10 @@ function DoorModels(_ref7) {
1463
1546
  }
1464
1547
  }, [totalHeightProp, setTotalHeight]);
1465
1548
  React.useEffect(() => {
1466
- if (frameDepthProp !== undefined) {
1467
- setDoorFrame(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
1468
- frameDepth: frameDepthProp
1469
- }));
1549
+ if (totalDepthProp !== undefined) {
1550
+ setTotalDepth(totalDepthProp);
1470
1551
  }
1471
- }, [frameDepthProp, setDoorFrame]);
1552
+ }, [totalDepthProp, setTotalDepth]);
1472
1553
 
1473
1554
  // --- Material Logic (Centralized in parent component) ---
1474
1555
  const allMaterials = useDoorMaterials(materialsProp);
@@ -2272,7 +2353,7 @@ const DoorConfigurator = _ref => {
2272
2353
  is2D = false,
2273
2354
  totalWidth,
2274
2355
  totalHeight,
2275
- frameDepth
2356
+ totalDepth
2276
2357
  } = _ref;
2277
2358
  return /*#__PURE__*/jsxRuntime.jsx(ConfiguratorProvider, {
2278
2359
  initialIs2D: is2D,
@@ -2283,7 +2364,7 @@ const DoorConfigurator = _ref => {
2283
2364
  doorOpening: doorOpening,
2284
2365
  totalWidth: totalWidth,
2285
2366
  totalHeight: totalHeight,
2286
- frameDepth: frameDepth
2367
+ totalDepth: totalDepth
2287
2368
  })
2288
2369
  });
2289
2370
  };