mrdoob/three.js — Issue #1051: change material on mesh
Author: dwegner79
Created: 2012-01-08 21:50:27+00:00
State: open

Is it possible to trigger an even that will change the material assignment of the mesh?

I want to swap a phong shader:

phongMaterial = [new THREE.MeshPhongMaterial( { ambient: 0x555555, color: 0x555555, specular: 0xffffff, shininess: 50, shading: THREE.SmoothShading } )];

with this basic material:

basicMaterial = [new THREE.MeshBasicMaterial( { vertexColors: THREE.FaceColors } ),new THREE.MeshBasicMaterial({color: 0xffffff, opacity: 1, wireframe: true} ) ]

when a certain event is triggered I switch using this code:

myMesh.materials = basicMaterial

and switching back:

myMesh.materials = phongMaterial

however when I switch from the phong to the basic the mesh just disappears (it comes back when I switch back)