2

I'm trying to migrate multi-material to r85 but can't seem to see any result.

Previously I had:

mesh = THREE.SceneUtils.createMultiMaterialObject( geometry, [ material1, material2 ] );
mesh.children[1].material.transparent = true;

Example Pen.

Now I do:

materials = [ material1, material2 ];
mesh = new THREE.Mesh( geometry, materials );
material2.transparent = true;

Example Pen.

But I can't see both materials. Why?

ALx
  • 611
  • 9
  • 24
  • `THREE.Mesh()` doesn't accept an array of materials in the second parameter, there should be just a single material (saying in the [documentation](https://threejs.org/docs/index.html#api/objects/Mesh)). The approach with `THREE.SceneUtils.createMultiMaterialObject()` works well for me in your pen example. – prisoner849 Apr 28 '17 at 09:29
  • Are you sure? Please refer to this update in r85: https://github.com/mrdoob/three.js/issues/10931 – ALx Apr 28 '17 at 09:47
  • A-ha, if I got it correctly, `MultiMaterial` was using for assigning different materials to mesh's faces. You can't assign two materials to the same face. `createMultiMaterialObject()` works differently and intended for different purposes: it creates a group of objects with the same geometry, but with different materials (where one of materials must be transparent). So, I'm still sure (though I don't insist) that the correct way is to use `createMultiMaterialObject`. And for the other options, refer to this [SO answer](http://stackoverflow.com/a/16781472/4045502) – prisoner849 Apr 28 '17 at 10:40
  • Doh! For some reason I thought the'd solved the layering of materials on the same face. I guess, I'll have to give some love to `ShaderMaterial` then. – ALx Apr 28 '17 at 11:29
  • 1
    There's also this example: https://threejs.org/examples/#webgl_materials_nodes – ALx Apr 28 '17 at 11:36

0 Answers0