javascript - Three.js WebGL renderer not updating Color property on faces -


i have simple plane mesh want change color of face @ run-time (actually when character walks on "floor tile").

i try following:

face.color.setrgb(math.random(), math.random(), math.random()); 

this works fine canvasrenderer, when switch webglrenderer, stops working.

i have tried setting geometry.colorsneedupdate flag, no success, mesh , geometry set dynamic, there else missing?

(using three.js r59)

thanks,

phil.

for webglrenderer, here pattern need follow three.geometry.

assign color each face.

for ( var = 0; < geometry.faces.length; ++ ) {     geometry.faces[ ].color.sethex( math.random() * 0xffffff ); } 

set vertexcolors = three.facecolors in material.

material = new three.meshphongmaterial( { color: 0xffffff, vertexcolors: three.facecolors } ); 

set colorsneedsupdate after color change.

mesh.geometry.colorsneedupdate = true; 

three.js.r.76


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -