我正在使用Three.js 57版本。现在我正在使用JSONLoader进行动画制作。我成功地获得了动画。但我想为动画中的每个帧更新网格的完整顶点颜色。这可能是在three.js
中先谢谢
答案 0 :(得分:8)
CanvasRenderer
目前不支持顶点颜色。
以下是您需要遵循的WebGLRenderer
模式:
在为网格物体创建材质时设置THREE.VertexColors
;
material.vertexColors = THREE.VertexColors;
还要确保为几何体的每个面定义vertexColors
。
geometry.faces[ faceIndex ].vertexColors[ vertexIndex ] = new THREE.Color( 0xff0000 );
然后在渲染循环中,要更改顶点颜色,请执行以下操作:
geometry.faces[ faceIndex ].vertexColors[ vertexIndex ].setHSL( Math.random(), 0.5, 0.5 );
mesh.geometry.colorsNeedUpdate = true;
three.js r.59