Skip to content
This repository was archived by the owner on Jul 20, 2020. It is now read-only.

MeshStandardMaterial not showing alphaMap #225

@MaartenBreeedveld

Description

@MaartenBreeedveld

In my project I noticed that the alphaMap is not working correctly.

though this only occurs on 3d models (I've currently only tried OBJ models) with nested materials (i.e. model.children.material(this is sometimes an array).{someMaterial})

The alphaMap slot is correctly updated, the needUpdate flag is set to true and the transparant flag is also set to true. but the material is not updated in the view. I use the following function for updating the material:

`

materials.forEach( ( mtl ) => {
  if ( mtl.name === material.name ) {
    if(type === 'opacity' ) { color === 1 ? mtl.transparent = false :  mtl.transparent = true }
    console.log('type: ' + type + ' clr: ' + color + ' transp = ' + mtl.transparent)
    mtl[type] = color;
  }
});

const object = Object.assign(this.state.object)

object.traverse( ( child ) => {
  if ( child instanceof THREE.Mesh ) {
    if(child.material.name === material.name){
      child.material[type] = material[type];
      child.material.needsUpdate = true;
      update++;
    }
    if ( child.material.length > 0 ) {
      child.material.forEach( mat => {
        if(mat.name === material.name) {
          mat[type] = material[type];
          mat.needsUpdate = true;
          update++;
        }
      })
    }
  }
});`

Would I need to update all the materials recursively? I'd rather don't, because of the performance impact...

I posted a copy of the console.log of the material.

{…} ​ alphaMap: Object { uuid: "5360E61B-F16E-4951-9412-917382AF339C", mapping: 300, wrapS: 1001, … } ​ alphaTest: 0 ​ aoMap: null ​ aoMapIntensity: 1 ​ blendDst: 205 ​ blendDstAlpha: null ​ blendEquation: 100 ​ blendEquationAlpha: null ​ blendSrc: 204 ​ blendSrcAlpha: null ​ blending: 1 ​ bumpMap: null ​ bumpScale: 1 ​ clipIntersection: false ​ clipShadows: false ​ clippingPlanes: null ​ color: Object { r: 1, g: 1, b: 1 } ​ colorWrite: true ​ defines: Object { STANDARD: "" } ​ depthFunc: 3 ​ depthTest: true ​ depthWrite: true ​ displacementBias: 0 ​ displacementMap: null ​ displacementScale: 1 ​ dithering: false ​ emissive: Object { r: 0, g: 0, b: 0 } ​ emissiveIntensity: 1 ​ emissiveMap: null ​ envMap: null ​ envMapIntensity: 1 ​ fog: true ​ id: 1283 ​ lightMap: null ​ lightMapIntensity: 1 ​ lights: true ​ map: Object { uuid: "AF21EB78-2C8F-4B72-8ADE-2F406FA57275", mapping: 300, wrapS: 1001, … } ​ metalness: 0 ​ metalnessMap: null ​ morphNormals: false ​ morphTargets: false ​ name: "Material__943" ​ needsUpdate: true ​ normalMap: null ​ normalScale: Object { x: 1, y: 1 } ​ opacity: 1 ​ overdraw: 0 ​ polygonOffset: false ​ polygonOffsetFactor: 0 ​ polygonOffsetUnits: 0 ​ precision: null ​ premultipliedAlpha: false ​ refractionRatio: 0.98 ​ roughness: 0 ​ roughnessMap: null ​ shading: 2 ​ side: 0 ​ skinning: false ​ transparent: true ​ type: "MeshStandardMaterial" ​ uuid: "5C182132-7CC2-4BF2-9287-F3B4C9B5340E" ​ vertexColors: 0 ​ visible: true ​ wireframe: false ​ wireframeLinecap: "round" ​ wireframeLinejoin: "round" ​ wireframeLinewidth: 1 ​ __proto__: Object { constructor: MeshStandardMaterial(), isMeshStandardMaterial: true, copy: copy() }

Your help is much appreciated! Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions