Object3D

线(Line)

一条连续的线。

它几乎和LineSegments是一样的,唯一的区别是它在渲染时使用的是gl.LINE_STRIP, 而不是gl.LINES

代码示例

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

构造函数

Line(geometry : Geometry, material : Material)

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

属性

共有属性请参见其基类Object3D

.geometry : Geometry

表示线段的顶点。

.material : Material

线的材质。

.morphTargetInfluences : Array

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 .updateMorphTargets().

.morphTargetDictionary : Object

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

方法

共有方法请参见其基类 Object3D

.computeLineDistances() → Line

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

.raycast(raycaster : Raycaster, intersects : Array) → null

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

.clone() → Line

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

.updateMorphTargets() → null

Updates the morphTargets to have no influence on the object. Resets the .morphTargetInfluences and .morphTargetDictionary properties.

源代码

src/objects/Line.js