threeJs基础(2)

基础元素

1.点

var point1 = new THREE.Vector3(x,y,z);

2.线

var  geometry = new THREE.Geometry(); 定义几何体

var material = new THREE.LineBasicMaterial({});定义线条的材质,包括color(线条颜色)、lineWidth(线条宽度)、linecap(线条两端的外观)、                                                                                          vertexColors(线条是否使用顶点颜色)、fog(是否受全局雾效的影响)

var color1 =  new THREE.Color(0xcccccc) , color2 = new THREE.Color(0x000000);定义两个颜色值,用16进制表示

var p1 = new THREE.Vector3(0,-10,10) , p2 = new THREE.Vector3(12,-23,-4345);定义两点,两点确定一条线

geometry.vertices.push(p1,p2);将两点放在几何体上

geometry.vertices.push(color1,color2);为点设置颜色

var line1 = new THREE.Line(geometry,material,THREE.LinePieces);生成一条线,第三个参数定义点的连接方式

scene.add(line1);

你可能感兴趣的:(threeJs基础(2))