[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]

只读属性,用于检查给定对象是否为[name]类型。

[property:Material material]

线的材质。

[property:Array morphTargetInfluences]

一个权重数组,通常取值范围为 0-1,用于指定应用的变形程度。默认为 undefined,但可通过 [page:.updateMorphTargets]() 重置为空数组。

[property:Object morphTargetDictionary]

基于 morphTarget.name 属性的 morphTargets 字典。 默认为 undefined,但可通过 [page:.updateMorphTargets]() 重建。

方法

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

[method:this computeLineDistances]()

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

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

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

[method:undefined updateMorphTargets]()

更新 morphTargets,使其不对对象产生影响。重置 [page:.morphTargetInfluences] 和 [page:.morphTargetDictionary] 属性。

源代码

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