three.js顶点颜色插值THREE.VertexColors无效

// 创建属性缓冲区对象

var attribue = new THREE.BufferAttribute(vertices, 3); //3个为一组,作为一个顶点的xyz坐标

// 设置几何体attributes属性的位置position属性

geometry.attributes.position = attribue;

//类型数组创建顶点颜色color数据

var colors = new Float32Array([

1, 0, 0, //顶点1颜色

0, 1, 0, //顶点2颜色

0, 0, 1, //顶点3颜色

1, 1, 0, //顶点4颜色

0, 1, 1, //顶点5颜色

1, 0, 1, //顶点6颜色

]);

// 设置几何体attributes属性的颜色color属性

geometry.attributes.color = new THREE.BufferAttribute(colors, 3); //3个为一组,表示一个顶点的颜色数据RGB

//材质对象

var material = new THREE.PointsMaterial({

// 使用顶点颜色数据渲染模型,不需要再定义color属性

// color: 0xff0000,

vertexColors: THREE.VertexColors,

//以顶点颜色为准

size: 10.0 //点对象像素尺寸

});

结果发现两个三角形的颜色并没有出来,打印THREE,发现并没有VertexColors,于是查找资料中才发现把vertexColors: THREE.VertexColors设置为vertexColors: true即可


————————————————
版权声明:本文为CSDN博主「小江江12」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_39966730/article/details/126657543

猜你喜欢

转载自blog.csdn.net/sunboylife/article/details/130266682