Line 连续线段

—> Object3D

把点集放进一个数组里, 然后赋值给 geometry.vertices, 就可把这些点连接起来. 运用 WebGL 中的 gl.LINE_STRIP. 相关的还有 LineLoopLineSegments.

function Line( geometry, material, mode ) { } var pointArr = [], radius = 3 angle = 0, step = Math.PI / 3; for(var i = 0; i < 6; i++){ var x = radius * Math.cos(angle), y = radius * Math.sin(angle), z = 0; pointArr.push(new THREE.Vector3(x, y, z)); angle += step; } var geometry = new THREE.Geometry(); geometry.vertices = pointArr; var material = new THREE.LineBasicMaterial({ color: 0xff3399 }); var line = new THREE.Line(geometry, material); scene.add(line);

Attributes

type : String

Default value : Line
Description : 类型.

isLine : Boolean

Default value : true (只读)
Description : 类型是否为Line.

geometry : Geometry

Default value : new BufferGeometry()
Description : 几何形状.

material : Material

Default value : new LineBasicMaterial( { color: Math.random() * 0xffffff } )
Description : 材质.

Methods

computeLineDistances( )

计算LineDashedMaterial所需的距离值数组.

raycast( raycaster, intersects )
raycaster Raycaster 光线投掷者
intersects Array 相交

求射线与线段的交点, Raycaster.intersectObject 调用这方法.