door_models 5.4.3 → 5.4.4

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
@@ -823,21 +823,39 @@ const buildMaterial = (prop, textures) => {
823
823
  }
824
824
  const sourceValue = typeof prop === "string" ? prop : prop.value;
825
825
  const opacity = typeof prop === "object" ? prop.opacity : 1;
826
+
827
+ // Start with base parameters.
826
828
  const params = {
827
829
  roughness: 0.8,
828
830
  side: THREE__namespace.DoubleSide
829
831
  };
830
832
  if (isHexColor(sourceValue)) {
833
+ // It's a color. Explicitly set the color and ensure no texture is applied.
831
834
  params.color = sourceValue;
832
- } else if (textures && textures[sourceValue]) {
833
- params.map = textures[sourceValue];
835
+ params.map = null;
834
836
  } else {
835
- const texture = new THREE__namespace.TextureLoader().load(sourceValue);
837
+ // It's a texture. Explicitly set the color to white to avoid tinting the texture.
838
+ params.color = "#ffffff";
839
+ let texture = null;
840
+ if (textures && textures[sourceValue]) {
841
+ // Use the pre-loaded texture.
842
+ texture = textures[sourceValue];
843
+ } else if (sourceValue) {
844
+ // Not pre-loaded, so load it now.
845
+ // TextureLoader caches results internally, so this is efficient.
846
+ texture = new THREE__namespace.TextureLoader().load(sourceValue);
847
+ }
836
848
  params.map = texture;
837
849
  }
850
+
851
+ // Handle transparency explicitly to prevent lingering state.
838
852
  if (opacity !== undefined && opacity < 1) {
839
853
  params.transparent = true;
840
854
  params.opacity = opacity;
855
+ } else {
856
+ // Explicitly turn transparency off if opacity is 1 or undefined.
857
+ params.transparent = false;
858
+ params.opacity = 1;
841
859
  }
842
860
  return new THREE__namespace.MeshStandardMaterial(params);
843
861
  };