door_models 5.2.7 → 5.2.8

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
@@ -2002,36 +2002,37 @@ function DoorLeaf(_ref8) {
2002
2002
  }, [frameType, isGlassDoor]);
2003
2003
 
2004
2004
  // --- DYNAMIC TEXTURE MATERIALS ---
2005
- const dynamicFrontDoorPlaneMaterial = React.useMemo(() => {
2006
- const newMaterial = frontDoorPlaneMaterial.clone();
2007
- if (newMaterial.map) {
2008
- newMaterial.map = newMaterial.map.clone();
2009
- newMaterial.map.needsUpdate = true;
2010
- newMaterial.map.wrapS = THREE__namespace.RepeatWrapping;
2011
- newMaterial.map.wrapT = THREE__namespace.RepeatWrapping;
2005
+ React.useEffect(() => {
2006
+ // This effect runs when the material or dimensions change
2007
+ if (frontDoorPlaneMaterial.map) {
2008
+ const texture = frontDoorPlaneMaterial.map;
2009
+
2010
+ // Ensure the texture repeats
2011
+ texture.wrapS = THREE__namespace.RepeatWrapping;
2012
+ texture.wrapT = THREE__namespace.RepeatWrapping;
2012
2013
  const initialHeightM = initialDoorHeight.current ? initialDoorHeight.current / 1000 : mainDoorHeightM;
2013
2014
  const initialWidthM = initialDoorWidth.current ? initialDoorWidth.current / 1000 : doorWidthM;
2014
2015
  const repeatY = initialHeightM > 0 ? mainDoorHeightM / initialHeightM : 1;
2015
2016
  const repeatX = initialWidthM > 0 ? doorWidthM / initialWidthM : 1;
2016
- newMaterial.map.repeat.set(repeatX, repeatY * 2);
2017
- console.log(repeatX, repeatY);
2017
+ texture.repeat.set(repeatX, repeatY * 2);
2018
+
2019
+ // Tell Three.js the texture needs to be updated
2020
+ texture.needsUpdate = true;
2018
2021
  }
2019
- return newMaterial;
2020
2022
  }, [frontDoorPlaneMaterial, mainDoorHeightM, doorWidthM]);
2021
- const dynamicBackDoorPlaneMaterial = React.useMemo(() => {
2022
- const newMaterial = backDoorPlaneMaterial.clone();
2023
- if (newMaterial.map) {
2024
- newMaterial.map = newMaterial.map.clone();
2025
- newMaterial.map.needsUpdate = true;
2026
- newMaterial.map.wrapS = THREE__namespace.RepeatWrapping;
2027
- newMaterial.map.wrapT = THREE__namespace.RepeatWrapping;
2023
+ React.useEffect(() => {
2024
+ // Same logic for the back material
2025
+ if (backDoorPlaneMaterial.map) {
2026
+ const texture = backDoorPlaneMaterial.map;
2027
+ texture.wrapS = THREE__namespace.RepeatWrapping;
2028
+ texture.wrapT = THREE__namespace.RepeatWrapping;
2028
2029
  const initialHeightM = initialDoorHeight.current ? initialDoorHeight.current / 1000 : mainDoorHeightM;
2029
2030
  const initialWidthM = initialDoorWidth.current ? initialDoorWidth.current / 1000 : doorWidthM;
2030
2031
  const repeatY = initialHeightM > 0 ? mainDoorHeightM / initialHeightM : 1;
2031
2032
  const repeatX = initialWidthM > 0 ? doorWidthM / initialWidthM : 1;
2032
- newMaterial.map.repeat.set(repeatX, repeatY * 2);
2033
+ texture.repeat.set(repeatX, repeatY * 2);
2034
+ texture.needsUpdate = true;
2033
2035
  }
2034
- return newMaterial;
2035
2036
  }, [backDoorPlaneMaterial, mainDoorHeightM, doorWidthM]);
2036
2037
  return /*#__PURE__*/jsxRuntime.jsxs("group", {
2037
2038
  "position-x": xOffset,
@@ -2159,7 +2160,7 @@ function DoorLeaf(_ref8) {
2159
2160
  children: /*#__PURE__*/jsxRuntime.jsxs(csg.Geometry, {
2160
2161
  useGroups: true,
2161
2162
  children: [/*#__PURE__*/jsxRuntime.jsx(csg.Base, {
2162
- material: dynamicFrontDoorPlaneMaterial,
2163
+ material: frontDoorPlaneMaterial,
2163
2164
  children: /*#__PURE__*/jsxRuntime.jsx("boxGeometry", {
2164
2165
  args: [doorWidthM, mainDoorHeightM, 0.001]
2165
2166
  })
@@ -2176,7 +2177,7 @@ function DoorLeaf(_ref8) {
2176
2177
  children: /*#__PURE__*/jsxRuntime.jsxs(csg.Geometry, {
2177
2178
  useGroups: true,
2178
2179
  children: [/*#__PURE__*/jsxRuntime.jsx(csg.Base, {
2179
- material: dynamicBackDoorPlaneMaterial,
2180
+ material: backDoorPlaneMaterial,
2180
2181
  children: /*#__PURE__*/jsxRuntime.jsx("boxGeometry", {
2181
2182
  args: [doorWidthM, mainDoorHeightM, 0.0001]
2182
2183
  })