动态更改Three.js中的顶点颜色

时间:2013-07-26 06:48:37

标签: three.js

我正在使用Three.js 57版本。现在我正在使用JSONLoader进行动画制作。我成功地获得了动画。但我想为动画中的每个帧更新网格的完整顶点颜色。这可能是在three.js

先谢谢

1 个答案:

答案 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

相关问题