更改多维数据集的面的颜色 [英] Change the colors of a cube's faces

查看:256
本文介绍了更改多维数据集的面的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上找到了这个问题,但它表示 material.color 不存在。我需要知道如何改变我绘制的多维数据集的各种面孔的颜色:

I actually found this question, but it says material.color doesn't exist. I need to know how to change the colors of the various faces of a cube I'm drawing:

var newCube = new THREE.Mesh(new three.CubeGeometry(size, size, size), new three.MeshNormalMaterial({ vertexColors: three.FaceColors }));


推荐答案

这里是如何设置和更改

var geometry = new THREE.BoxGeometry( size, size, size );
for ( var i = 0; i < geometry.faces.length; i ++ ) {
    geometry.faces[ i ].color.setHex( Math.random() * 0xffffff );
}

var material = new THREE.MeshBasicMaterial( { color: 0xffffff, vertexColors: THREE.FaceColors } );

如果 geometry.faces [i] .color 已更改,请设置 geometry.colorsNeedUpdate = true 。 ( canvasRenderer 不需要)

If geometry.faces[i].color is changed, set geometry.colorsNeedUpdate = true. ( This is not required for canvasRenderer. )

three.js r.71

three.js r.71

这篇关于更改多维数据集的面的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆