Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
three.js中每行的单色_Three.js_X3d - Fatal编程技术网

three.js中每行的单色

three.js中每行的单色,three.js,x3d,Three.js,X3d,是否可以在three.js中使用单一颜色属性绘制一条线,类似于x3d的indexedLineSet,而不是定义每个顶点的颜色 let material = new THREE.LineBasicMaterial( { color: 0xff0000, vertexColors: THREE.VertexColors } ); 可以使用线段和相应的几何图形对象来实现这一点。没有任何线条材质选项可以替代这样的颜色定义 var geometry=new THREE.BufferGeo

是否可以在three.js中使用单一颜色属性绘制一条线,类似于x3d的indexedLineSet,而不是定义每个顶点的颜色

let material = new THREE.LineBasicMaterial( {
    color: 0xff0000,
    vertexColors: THREE.VertexColors
} );

可以使用
线段
和相应的几何图形对象来实现这一点。没有任何线条材质选项可以替代这样的颜色定义

var geometry=new THREE.BufferGeometry();
var顶点=[];
var颜色=[];
//具有不同颜色的三条线段的几何图形数据
顶点。推(0,0,0);
顶点。推(1,0,0);
顶点。推(1,0,0);
顶点。推(1,1,0);
顶点。推(1,1,0);
顶点。推(0,1,0);
颜色。推送(1,0,0);
颜色。推送(1,0,0);
颜色。推送(0,1,0);
颜色。推送(0,1,0);
颜色。推送(0,0,1);
颜色。推送(0,0,1);
geometry.addAttribute('position',新的三个.Float32BufferAttribute(顶点,3));
geometry.addAttribute('color',新的三个.Float32BufferAttribute(colors,3));
var material=新的三个.LineBasicMaterial({vertexColors:THREE.vertexColors});
var lines=新的三条线段(几何体、材质);
场景。添加(行);


three.js R109

x3d的indexedLineSet有一个布尔属性“colorPerVertex”,如果为false,则每行定义一种颜色。在three.js中,必须为一条直线定义两种颜色,即起点和终点顶点。是的,否则将看到插值效果。如果你想达到预期的效果,那是没有办法的。