UNPKG

3.44 kBTypeScriptView Raw
1import { BufferGeometry } from "../core/BufferGeometry.js";
2import { Object3D, Object3DEventMap } from "../core/Object3D.js";
3import { Material } from "../materials/Material.js";
4
5/**
6 * A continuous line.
7 * @remarks
8 * This is nearly the same as {@link THREE.LineSegments | LineSegments},
9 * the only difference is that it is rendered using {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements | gl.LINE_STRIP}
10 * instead of {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements | gl.LINES}
11 * @example
12 * ```typescript
13 * const material = new THREE.LineBasicMaterial({
14 * color: 0x0000ff
15 * });
16 * const points = [];
17 * points.push(new THREE.Vector3(-10, 0, 0));
18 * points.push(new THREE.Vector3(0, 10, 0));
19 * points.push(new THREE.Vector3(10, 0, 0));
20 * const geometry = new THREE.BufferGeometry().setFromPoints(points);
21 * const {@link Line} = new THREE.Line(geometry, material);
22 * scene.add(line);
23 * ```
24 * @see {@link https://threejs.org/docs/index.html#api/en/objects/Line | Official Documentation}
25 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Line.js | Source}
26 */
27export class Line<
28 TGeometry extends BufferGeometry = BufferGeometry,
29 TMaterial extends Material | Material[] = Material | Material[],
30 TEventMap extends Object3DEventMap = Object3DEventMap,
31> extends Object3D<TEventMap> {
32 /**
33 * Create a new instance of {@link Line}
34 * @param geometry Vertices representing the {@link Line} segment(s). Default {@link THREE.BufferGeometry | `new THREE.BufferGeometry()`}.
35 * @param material Material for the line. Default {@link THREE.LineBasicMaterial | `new THREE.LineBasicMaterial()`}.
36 */
37 constructor(geometry?: TGeometry, material?: TMaterial);
38
39 /**
40 * Read-only flag to check if a given object is of type {@link Line}.
41 * @remarks This is a _constant_ value
42 * @defaultValue `true`
43 */
44 readonly isLine: true;
45
46 /**
47 * @override
48 * @defaultValue `Line`
49 */
50 override readonly type: string | "Line";
51
52 /**
53 * Vertices representing the {@link Line} segment(s).
54 */
55 geometry: TGeometry;
56
57 /**
58 * Material for the line.
59 */
60 material: TMaterial;
61
62 /**
63 * An array of weights typically from `0-1` that specify how much of the morph is applied.
64 * @defaultValue `undefined`, but reset to a blank array by {@link updateMorphTargets | .updateMorphTargets()}.
65 */
66 morphTargetInfluences?: number[] | undefined;
67
68 /**
69 * A dictionary of morphTargets based on the `morphTarget.name` property.
70 * @defaultValue `undefined`, but reset to a blank array by {@link updateMorphTargets | .updateMorphTargets()}.
71 */
72 morphTargetDictionary?: { [key: string]: number } | undefined;
73
74 /**
75 * Computes an array of distance values which are necessary for {@link THREE.LineDashedMaterial | LineDashedMaterial}
76 * @remarks
77 * For each vertex in the geometry, the method calculates the cumulative length from the current point to the very beginning of the line.
78 */
79 computeLineDistances(): this;
80
81 /**
82 * Updates the morphTargets to have no influence on the object
83 * @remarks
84 * Resets the {@link morphTargetInfluences | .morphTargetInfluences} and {@link morphTargetDictionary | .morphTargetDictionary} properties.
85 */
86 updateMorphTargets(): void;
87}