[page:Object3D] →

线([name])

一条连续的线。

它几乎和[page:LineSegments]是一样的,唯一的区别是它在渲染时使用的是[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.LINE_STRIP], 而不是[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.LINES]。

代码示例

const material = new THREE.LineBasicMaterial({ color: 0x0000ff }); const points = []; points.push( new THREE.Vector3( - 10, 0, 0 ) ); points.push( new THREE.Vector3( 0, 10, 0 ) ); points.push( new THREE.Vector3( 10, 0, 0 ) ); const geometry = new THREE.BufferGeometry().setFromPoints( points ); const line = new THREE.Line( geometry, material ); scene.add( line );

构造器

[name]( [param:BufferGeometry geometry], [param:Material material] )

[page:BufferGeometry geometry] —— 表示线段的顶点,默认值是一个新的[page:BufferGeometry]。
[page:Material material] —— 线的材质,默认值是一个新的具有随机颜色的[page:LineBasicMaterial]。

属性

共有属性请参见其基类[page:Object3D]。

[property:BufferGeometry geometry]

表示线段的顶点。

[property:Boolean isLine]

Read-only flag to check if a given object is of type [name].

[property:Material material]

线的材质。

[property:Array morphTargetInfluences]

An array of weights typically from 0-1 that specify how much of the morph is applied. Undefined by default, but reset to a blank array by [page:.updateMorphTargets]().

[property:Object morphTargetDictionary]

A dictionary of morphTargets based on the morphTarget.name property. Undefined by default, but rebuilt [page:.updateMorphTargets]().

方法

共有方法请参见其基类 [page:Object3D]。

[method:this computeLineDistances]()

计算[page:LineDashedMaterial]所需的距离的值的数组。 对于几何体中的每一个顶点,这个方法计算出了当前点到线的起始点的累积长度。

[method:undefined raycast]( [param:Raycaster raycaster], [param:Array intersects] )

在一条投射出去的[page:Ray](射线)和这条线之间产生交互。 [page:Raycaster.intersectObject]将会调用这个方法。

[method:Line clone]()

返回这条线及其子集的一个克隆对象。

[method:undefined updateMorphTargets]()

Updates the morphTargets to have no influence on the object. Resets the [page:.morphTargetInfluences] and [page:.morphTargetDictionary] properties.

源代码

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]