spite / THREE.MeshLine

Mesh replacement for THREE.Line
MIT License
2.13k stars 379 forks source link

Update color dynamically possible of MeshLine? #67

Closed AngeloETH closed 4 years ago

AngeloETH commented 5 years ago

I want to develop a method can change the color of MeshLine by listening the event from client like this: http://jsfiddle.net/ebeit303/Lfr5my2s/. In the above case, the material is THREE.LineBasicMaterial in line29. In MeshLine, the material available is MeshLineMaterial. However, I can't update color of MeshLineMaterial like example. Is it possible to update color dynamically using MeshLine?

jimtang commented 5 years ago

You can set the mesh's color directly like this: lineMesh.material.uniforms.color.value = new Color('red');

myleskeller commented 3 years ago

You can set the mesh's color directly like this: lineMesh.material.uniforms.color.value = new Color('red');

for anyone else that tried implementing this snippet but received Failed to execute 'uniform3fv' on 'WebGLRenderingContext' in the JS console, according to this issue, the correct syntax is now: lineMesh.material.uniforms.color.value = new THREE.Color('red');