@types/three 0.150.0 → 0.150.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/controls/OrbitControls.d.ts +3 -3
  3. three/examples/jsm/controls/TrackballControls.d.ts +2 -2
  4. three/examples/jsm/controls/TransformControls.d.ts +2 -6
  5. three/examples/jsm/geometries/TextGeometry.d.ts +92 -15
  6. three/examples/jsm/loaders/EXRLoader.d.ts +3 -2
  7. three/examples/jsm/misc/GPUComputationRenderer.d.ts +4 -2
  8. three/package.json +2 -2
  9. three/src/audio/Audio.d.ts +184 -20
  10. three/src/audio/AudioAnalyser.d.ts +42 -4
  11. three/src/audio/AudioContext.d.ts +12 -1
  12. three/src/audio/AudioListener.d.ts +76 -8
  13. three/src/audio/PositionalAudio.d.ts +86 -5
  14. three/src/cameras/ArrayCamera.d.ts +23 -2
  15. three/src/cameras/Camera.d.ts +42 -13
  16. three/src/cameras/CubeCamera.d.ts +49 -1
  17. three/src/cameras/OrthographicCamera.d.ts +77 -25
  18. three/src/cameras/PerspectiveCamera.d.ts +132 -56
  19. three/src/cameras/StereoCamera.d.ts +29 -2
  20. three/src/constants.d.ts +431 -26
  21. three/src/core/BufferGeometry.d.ts +5 -3
  22. three/src/core/Object3D.d.ts +17 -13
  23. three/src/core/Raycaster.d.ts +1 -0
  24. three/src/geometries/BoxGeometry.d.ts +39 -16
  25. three/src/geometries/CapsuleGeometry.d.ts +35 -12
  26. three/src/geometries/CircleGeometry.d.ts +38 -12
  27. three/src/geometries/ConeGeometry.d.ts +45 -10
  28. three/src/geometries/CylinderGeometry.d.ts +41 -19
  29. three/src/geometries/DodecahedronGeometry.d.ts +14 -5
  30. three/src/geometries/EdgesGeometry.d.ts +30 -8
  31. three/src/geometries/ExtrudeGeometry.d.ts +93 -12
  32. three/src/geometries/IcosahedronGeometry.d.ts +15 -5
  33. three/src/geometries/LatheGeometry.d.ts +41 -12
  34. three/src/geometries/OctahedronGeometry.d.ts +14 -5
  35. three/src/geometries/PlaneGeometry.d.ts +35 -12
  36. three/src/geometries/PolyhedronGeometry.d.ts +41 -12
  37. three/src/geometries/RingGeometry.d.ts +39 -16
  38. three/src/geometries/ShapeGeometry.d.ts +44 -4
  39. three/src/geometries/SphereGeometry.d.ts +43 -21
  40. three/src/geometries/TetrahedronGeometry.d.ts +14 -5
  41. three/src/geometries/TorusGeometry.d.ts +35 -13
  42. three/src/geometries/TorusKnotGeometry.d.ts +39 -16
  43. three/src/geometries/TubeGeometry.d.ts +63 -15
  44. three/src/geometries/WireframeGeometry.d.ts +30 -4
  45. three/src/math/ColorManagement.d.ts +2 -2
  46. three/src/objects/Bone.d.ts +30 -3
  47. three/src/objects/Group.d.ts +37 -1
  48. three/src/objects/InstancedMesh.d.ts +122 -3
  49. three/src/objects/LOD.d.ts +62 -18
  50. three/src/objects/Line.d.ts +67 -4
  51. three/src/objects/LineLoop.d.ts +26 -1
  52. three/src/objects/LineSegments.d.ts +21 -9
  53. three/src/objects/Mesh.d.ts +60 -4
  54. three/src/objects/Points.d.ts +39 -8
  55. three/src/objects/Skeleton.d.ts +89 -3
  56. three/src/objects/SkinnedMesh.d.ts +122 -3
  57. three/src/objects/Sprite.d.ts +51 -4
  58. three/src/renderers/WebGLRenderTarget.d.ts +9 -3
  59. three/src/scenes/Fog.d.ts +59 -7
  60. three/src/scenes/FogExp2.d.ts +41 -6
  61. three/src/scenes/Scene.d.ts +45 -22
  62. three/src/textures/CanvasTexture.d.ts +35 -13
  63. three/src/textures/CompressedArrayTexture.d.ts +39 -5
  64. three/src/textures/CompressedTexture.d.ts +49 -20
  65. three/src/textures/CubeTexture.d.ts +71 -18
  66. three/src/textures/Data3DTexture.d.ts +74 -10
  67. three/src/textures/DataArrayTexture.d.ts +83 -9
  68. three/src/textures/DataTexture.d.ts +81 -26
  69. three/src/textures/DepthTexture.d.ts +71 -15
  70. three/src/textures/FramebufferTexture.d.ts +57 -2
  71. three/src/textures/Source.d.ts +23 -13
  72. three/src/textures/Texture.d.ts +289 -73
  73. three/src/textures/VideoTexture.d.ts +69 -13
  74. three/src/textures/types.d.ts +9 -0
@@ -2,37 +2,85 @@ import { Curve } from './../extras/core/Curve';
2
2
  import { Vector3 } from './../math/Vector3';
3
3
  import { BufferGeometry } from './../core/BufferGeometry';
4
4
 
5
+ /**
6
+ * Creates a tube that extrudes along a 3d curve.
7
+ * @example
8
+ * ```typescript
9
+ * class CustomSinCurve extends THREE.Curve {
10
+ * constructor(scale = 1) {
11
+ * super();
12
+ * this.scale = scale;
13
+ * }
14
+ * getPoint(t, optionalTarget = new THREE.Vector3()) {
15
+ * const tx = t * 3 - 1.5;
16
+ * const ty = Math.sin(2 * Math.PI * t);
17
+ * const tz = 0;
18
+ * return optionalTarget.set(tx, ty, tz).multiplyScalar(this.scale);
19
+ * }
20
+ * }
21
+ * const path = new CustomSinCurve(10);
22
+ * const geometry = new THREE.TubeGeometry(path, 20, 2, 8, false);
23
+ * const material = new THREE.MeshBasicMaterial({
24
+ * color: 0x00ff00
25
+ * });
26
+ * const mesh = new THREE.Mesh(geometry, material);
27
+ * scene.add(mesh);
28
+ * ```
29
+ * @see {@link https://threejs.org/docs/index.html#api/en/geometries/TubeGeometry | Official Documentation}
30
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/geometries/TubeGeometry.js | Source}
31
+ */
5
32
  export class TubeGeometry extends BufferGeometry {
6
33
  /**
7
- * @param path
8
- * @param [tubularSegments=64]
9
- * @param [radius=1]
10
- * @param [radiusSegments=8]
11
- * @param [closed=false]
34
+ * Create a new instance of {@link TubeGeometry}
35
+ * @param path A 3D path that inherits from the {@link THREE.Curve | Curve} base class.
36
+ * Default {@link THREE.QuadraticBezierCurve3 | new THREE.QuadraticBezierCurve3(new Vector3(-1, -1, 0 ), new Vector3(-1, 1, 0), new Vector3(1, 1, 0))}.
37
+ * @param tubularSegments The number of segments that make up the tube. Expects a `Integer`. Default `64`.
38
+ * @param radius The radius of the tube. Expects a `Float`. Default `1`.
39
+ * @param radialSegments The number of segments that make up the cross-section. Expects a `Integer`. Default `8`.
40
+ * @param closed Is the tube open or closed. Default `false`.
12
41
  */
13
42
  constructor(
14
43
  path?: Curve<Vector3>,
15
44
  tubularSegments?: number,
16
45
  radius?: number,
17
- radiusSegments?: number,
46
+ radialSegments?: number,
18
47
  closed?: boolean,
19
48
  );
20
49
 
21
50
  /**
22
- * @default 'TubeGeometry'
51
+ * A Read-only _string_ to check if `this` object type.
52
+ * @remarks Sub-classes will update this value.
53
+ * @defaultValue `TubeGeometry`
23
54
  */
24
- type: string;
55
+ override readonly type: string | 'TubeGeometry';
25
56
 
26
- parameters: {
27
- path: Curve<Vector3>;
28
- tubularSegments: number;
29
- radius: number;
30
- radialSegments: number;
31
- closed: boolean;
57
+ /**
58
+ * An object with a property for each of the constructor parameters.
59
+ * @remarks Any modification after instantiation does not change the geometry.
60
+ */
61
+ readonly parameters: {
62
+ readonly path: Curve<Vector3>;
63
+ readonly tubularSegments: number;
64
+ readonly radius: number;
65
+ readonly radialSegments: number;
66
+ readonly closed: boolean;
32
67
  };
68
+
69
+ /**
70
+ * An array of {@link THREE.Vector3 | Vector3} tangents
71
+ */
33
72
  tangents: Vector3[];
73
+
74
+ /**
75
+ * An array of {@link THREE.Vector3 | Vector3} normals
76
+ */
34
77
  normals: Vector3[];
78
+
79
+ /**
80
+ * An array of {@link THREE.Vector3 | Vector3} binormals
81
+ */
35
82
  binormals: Vector3[];
36
83
 
37
- static fromJSON(data: any): TubeGeometry;
84
+ /** @internal */
85
+ static fromJSON(data: {}): TubeGeometry;
38
86
  }
@@ -1,14 +1,40 @@
1
1
  import { BufferGeometry } from './../core/BufferGeometry';
2
2
 
3
+ /**
4
+ * This can be used as a helper object to view a {@link BufferGeometry | geometry} as a wireframe.
5
+ * @example
6
+ * ```typescript
7
+ * const geometry = new THREE.SphereGeometry(100, 100, 100);
8
+ * const wireframe = new THREE.WireframeGeometry(geometry);
9
+ * const line = new THREE.LineSegments(wireframe);
10
+ * line.material.depthTest = false;
11
+ * line.material.opacity = 0.25;
12
+ * line.material.transparent = true;
13
+ * scene.add(line);
14
+ * ```
15
+ * @see Example: {@link https://threejs.org/examples/#webgl_helpers | helpers}
16
+ * @see {@link https://threejs.org/docs/index.html#api/en/geometries/WireframeGeometry | Official Documentation}
17
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/geometries/WireframeGeometry.js | Source}
18
+ */
3
19
  export class WireframeGeometry<TBufferGeometry extends BufferGeometry = BufferGeometry> extends BufferGeometry {
20
+ /**
21
+ * Create a new instance of {@link WireframeGeometry}
22
+ * @param geometry Any geometry object. Default `null`.
23
+ */
4
24
  constructor(geometry?: TBufferGeometry);
5
25
 
6
26
  /**
7
- * @default 'WireframeGeometry'
27
+ * A Read-only _string_ to check if `this` object type.
28
+ * @remarks Sub-classes will update this value.
29
+ * @defaultValue `WireframeGeometry`
8
30
  */
9
- type: string;
31
+ override readonly type: string | 'WireframeGeometry';
10
32
 
11
- parameters: {
12
- geometry: TBufferGeometry;
33
+ /**
34
+ * An object with a property for each of the constructor parameters.
35
+ * @remarks Any modification after instantiation does not change the geometry.
36
+ */
37
+ readonly parameters: {
38
+ readonly geometry: TBufferGeometry;
13
39
  };
14
40
  }
@@ -24,11 +24,11 @@ export namespace ColorManagement {
24
24
 
25
25
  function fromWorkingColorSpace(
26
26
  color: Color,
27
- targetColorSpace: typeof SRGBColorSpace | typeof LinearSRGBColorSpace,
27
+ targetColorSpace: typeof SRGBColorSpace | typeof LinearSRGBColorSpace | typeof DisplayP3ColorSpace,
28
28
  ): Color;
29
29
 
30
30
  function toWorkingColorSpace(
31
31
  color: Color,
32
- sourceColorSpace: typeof SRGBColorSpace | typeof LinearSRGBColorSpace,
32
+ sourceColorSpace: typeof SRGBColorSpace | typeof LinearSRGBColorSpace | typeof DisplayP3ColorSpace,
33
33
  ): Color;
34
34
  }
@@ -1,9 +1,36 @@
1
1
  import { Object3D } from './../core/Object3D';
2
2
 
3
- // Objects //////////////////////////////////////////////////////////////////////////////////
4
-
3
+ /**
4
+ * A {@link Bone} which is part of a {@link THREE.Skeleton | Skeleton}
5
+ * @remarks
6
+ * The skeleton in turn is used by the {@link THREE.SkinnedMesh | SkinnedMesh}
7
+ * Bones are almost identical to a blank {@link THREE.Object3D | Object3D}.
8
+ * @example
9
+ * ```typescript
10
+ * const root = new THREE.Bone();
11
+ * const child = new THREE.Bone();
12
+ * root.add(child);
13
+ * child.position.y = 5;
14
+ * ```
15
+ * @see {@link https://threejs.org/docs/index.html#api/en/objects/Bone | Official Documentation}
16
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Bone.js | Source}
17
+ */
5
18
  export class Bone extends Object3D {
19
+ /**
20
+ * Creates a new {@link Bone}.
21
+ */
6
22
  constructor();
23
+
24
+ /**
25
+ * Read-only flag to check if a given object is of type {@link Bone}.
26
+ * @remarks This is a _constant_ value
27
+ * @defaultValue `true`
28
+ */
7
29
  readonly isBone: true;
8
- type: 'Bone';
30
+
31
+ /**
32
+ * @override
33
+ * @defaultValue `Bone`
34
+ */
35
+ override readonly type: string | 'Bone';
9
36
  }
@@ -1,7 +1,43 @@
1
1
  import { Object3D } from './../core/Object3D';
2
2
 
3
+ /**
4
+ * Its purpose is to make working with groups of objects syntactically clearer.
5
+ * @remarks This is almost identical to an {@link Object3D | Object3D}
6
+ * @example
7
+ * ```typescript
8
+ * const geometry = new THREE.BoxGeometry(1, 1, 1);
9
+ * const material = new THREE.MeshBasicMaterial({
10
+ * color: 0x00ff00
11
+ * });
12
+ * const cubeA = new THREE.Mesh(geometry, material);
13
+ * cubeA.position.set(100, 100, 0);
14
+ * const cubeB = new THREE.Mesh(geometry, material);
15
+ * cubeB.position.set(-100, -100, 0);
16
+ * //create a {@link Group} and add the two cubes
17
+ * //These cubes can now be rotated / scaled etc as a {@link Group} * const {@link Group} = new THREE.Group();
18
+ * group.add(cubeA);
19
+ * group.add(cubeB);
20
+ * scene.add(group);
21
+ * ```
22
+ * @see {@link https://threejs.org/docs/index.html#api/en/objects/Group | Official Documentation}
23
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Group.js | Source}
24
+ */
3
25
  export class Group extends Object3D {
26
+ /**
27
+ * Creates a new {@link Bone}.
28
+ */
4
29
  constructor();
5
- type: 'Group';
30
+
31
+ /**
32
+ * Read-only flag to check if a given object is of type {@link Group}.
33
+ * @remarks This is a _constant_ value
34
+ * @defaultValue `true`
35
+ */
6
36
  readonly isGroup: true;
37
+
38
+ /**
39
+ * @override
40
+ * @defaultValue `Group`
41
+ */
42
+ override readonly type: string | 'Group';
7
43
  }
@@ -5,21 +5,140 @@ import { InstancedBufferAttribute } from '../core/InstancedBufferAttribute';
5
5
  import { Mesh } from './Mesh';
6
6
  import { Matrix4 } from './../math/Matrix4';
7
7
  import { Color } from './../math/Color';
8
+ import { Box3, Sphere } from '../Three';
8
9
 
10
+ /**
11
+ * A special version of {@link THREE.Mesh | Mesh} with instanced rendering support
12
+ * @remarks
13
+ * Use {@link InstancedMesh} if you have to render a large number of objects with the same geometry and material but with different world transformations
14
+ * @remarks
15
+ * The usage of {@link InstancedMesh} will help you to reduce the number of draw calls and thus improve the overall rendering performance in your application.
16
+ * @see Example: {@link https://threejs.org/examples/#webgl_instancing_dynamic | WebGL / instancing / dynamic}
17
+ * @see Example: {@link https://threejs.org/examples/#webgl_instancing_performance | WebGL / instancing / performance}
18
+ * @see Example: {@link https://threejs.org/examples/#webgl_instancing_scatter | WebGL / instancing / scatter}
19
+ * @see Example: {@link https://threejs.org/examples/#webgl_instancing_raycast | WebGL / instancing / raycast}
20
+ * @see {@link https://threejs.org/docs/index.html#api/en/objects/InstancedMesh | Official Documentation}
21
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/InstancedMesh.js | Source}
22
+ */
9
23
  export class InstancedMesh<
10
24
  TGeometry extends BufferGeometry = BufferGeometry,
11
25
  TMaterial extends Material | Material[] = Material | Material[],
12
26
  > extends Mesh<TGeometry, TMaterial> {
27
+ /**
28
+ * Create a new instance of {@link InstancedMesh}
29
+ * @param geometry An instance of {@link THREE.BufferGeometry | BufferGeometry}.
30
+ * @param material A single or an array of {@link THREE.Material | Material}. Default {@link THREE.MeshBasicMaterial | `new THREE.MeshBasicMaterial()`}.
31
+ * @param count The **maximum** number of instances of this Mesh. Expects a `Integer`
32
+ */
13
33
  constructor(geometry: TGeometry | undefined, material: TMaterial | undefined, count: number);
14
34
 
35
+ /**
36
+ * Read-only flag to check if a given object is of type {@link InstancedMesh}.
37
+ * @remarks This is a _constant_ value
38
+ * @defaultValue `true`
39
+ */
40
+ readonly isInstancedMesh: true;
41
+
42
+ /////////////////////////////////////////////////
43
+ // FUTURE - r151
44
+ /////////////////////////////////////////////////
45
+ // /**
46
+ // * This bounding box encloses all instances of the {@link InstancedMesh},, which can be calculated with {@link computeBoundingBox | .computeBoundingBox()}.
47
+ // * @remarks Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
48
+ // * @defaultValue `null`
49
+ // */
50
+ // boundingBox: Box3 | null;
51
+
52
+ // /**
53
+ // * This bounding sphere encloses all instances of the {@link InstancedMesh}, which can be calculated with {@link computeBoundingSphere | .computeBoundingSphere()}.
54
+ // * @remarks bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
55
+ // * @defaultValue `null`
56
+ // */
57
+ // boundingSphere: Sphere | null;
58
+ /////////////////////////////////////////////////
59
+
60
+ /**
61
+ * The number of instances.
62
+ * @remarks
63
+ * The `count` value passed into the {@link InstancedMesh | constructor} represents the **maximum** number of instances of this mesh.
64
+ * You can change the number of instances at runtime to an integer value in the range `[0, count]`.
65
+ * @remarks If you need more instances than the original `count` value, you have to create a new InstancedMesh.
66
+ * @remarks Expects a `Integer`
67
+ */
15
68
  count: number;
16
- instanceColor: null | InstancedBufferAttribute;
69
+
70
+ /**
71
+ * Represents the colors of all instances.
72
+ * You have to set {@link InstancedBufferAttribute.needsUpdate | .instanceColor.needsUpdate()} flag to `true` if you modify instanced data via {@link setColorAt | .setColorAt()}.
73
+ * @defaultValue `null`
74
+ */
75
+ instanceColor: InstancedBufferAttribute | null;
76
+
77
+ /**
78
+ * Represents the local transformation of all instances.
79
+ * You have to set {@link InstancedBufferAttribute.needsUpdate | .instanceMatrix.needsUpdate()} flag to `true` if you modify instanced data via {@link setMatrixAt | .setMatrixAt()}.
80
+ */
17
81
  instanceMatrix: InstancedBufferAttribute;
18
- readonly isInstancedMesh: true;
19
82
 
83
+ /////////////////////////////////////////////////
84
+ // FUTURE - r151
85
+ /////////////////////////////////////////////////
86
+ // /**
87
+ // * Computes bounding box of the all instances, updating {@link boundingBox | .boundingBox} attribute.
88
+ // * @remarks Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
89
+ // */
90
+ // computeBoundingBox(): void;
91
+
92
+ // /**
93
+ // * Computes bounding sphere of the all instances, updating {@link boundingSphere | .boundingSphere} attribute.
94
+ // * @remarks bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
95
+ // */
96
+ // computeBoundingSphere(): void;
97
+ /////////////////////////////////////////////////
98
+
99
+ /**
100
+ * Get the color of the defined instance.
101
+ * @param index The index of an instance. Values have to be in the range `[0, count]`. Expects a `Integer`
102
+ * @param color This color object will be set to the color of the defined instance.
103
+ */
20
104
  getColorAt(index: number, color: Color): void;
21
- getMatrixAt(index: number, matrix: Matrix4): void;
105
+
106
+ /**
107
+ * Sets the given color to the defined instance
108
+ * @remarks
109
+ * Make sure you set {@link InstancedBufferAttribute.needsUpdate | .instanceColor.needsUpdate()} to `true` after updating all the colors.
110
+ * @param index The index of an instance. Values have to be in the range `[0, count]`. Expects a `Integer`
111
+ * @param color The color of a single instance.
112
+ */
22
113
  setColorAt(index: number, color: Color): void;
114
+
115
+ /**
116
+ * Get the local transformation matrix of the defined instance.
117
+ * @param index The index of an instance Values have to be in the range `[0, count]`. Expects a `Integer`
118
+ * @param matrix This 4x4 matrix will be set to the local transformation matrix of the defined instance.
119
+ */
120
+ getMatrixAt(index: number, matrix: Matrix4): void;
121
+
122
+ /**
123
+ * Sets the given local transformation matrix to the defined instance.
124
+ * @remarks
125
+ * Make sure you set {@link InstancedBufferAttribute.needsUpdate | .instanceMatrix.needsUpdate()} flag to `true` after updating all the matrices.
126
+ * @param index The index of an instance. Values have to be in the range `[0, count]`. Expects a `Integer`
127
+ * @param matrix A 4x4 matrix representing the local transformation of a single instance.
128
+ */
23
129
  setMatrixAt(index: number, matrix: Matrix4): void;
130
+
131
+ /**
132
+ * No effect in {@link InstancedMesh}.
133
+ * @ignore
134
+ * @hidden
135
+ */
136
+ override updateMorphTargets(): void;
137
+
138
+ /**
139
+ * Frees the GPU-related resources allocated by this instance
140
+ * @remarks
141
+ * Call this method whenever this instance is no longer used in your app.
142
+ */
24
143
  dispose(): void;
25
144
  }
@@ -3,44 +3,88 @@ import { Raycaster } from './../core/Raycaster';
3
3
  import { Camera } from './../cameras/Camera';
4
4
  import { Intersection } from '../core/Raycaster';
5
5
 
6
+ /**
7
+ * Every level is associated with an object, and rendering can be switched between them at the distances specified
8
+ * @remarks
9
+ * Typically you would create, say, three meshes, one for far away (low detail), one for mid range (medium detail) and one for close up (high detail).
10
+ * @example
11
+ * ```typescript
12
+ * const {@link LOD} = new THREE.LOD();
13
+ * //Create spheres with 3 levels of detail and create new {@link LOD} levels for them
14
+ * for (let i = 0; i & lt; 3; i++) {
15
+ * const geometry = new THREE.IcosahedronGeometry(10, 3 - i)
16
+ * const mesh = new THREE.Mesh(geometry, material);
17
+ * lod.addLevel(mesh, i * 75);
18
+ * }
19
+ * scene.add(lod);
20
+ * ```
21
+ * @see Example: {@link https://threejs.org/examples/#webgl_lod | webgl / {@link LOD} }
22
+ * @see {@link https://threejs.org/docs/index.html#api/en/objects/LOD | Official Documentation}
23
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/LOD.js | Source}
24
+ */
6
25
  export class LOD extends Object3D {
26
+ /**
27
+ * Creates a new {@link LOD}.
28
+ */
7
29
  constructor();
8
30
 
9
- type: 'LOD';
31
+ /**
32
+ * Read-only flag to check if a given object is of type {@link LOD}.
33
+ * @remarks This is a _constant_ value
34
+ * @defaultValue `true`
35
+ */
36
+ readonly isLOD: true;
37
+
38
+ /**
39
+ * @override
40
+ * @defaultValue `LOD`
41
+ */
42
+ override readonly type: string | 'LOD';
10
43
 
11
44
  /**
12
- *
13
45
  * An array of level objects
14
- *
15
- * Each level is an object with the following properties:
16
- *
17
- * - object - The Object3D to display at this level.
18
- * - distance - The distance at which to display this level of detail.
19
- * - hysteresis - Threshold used to avoid flickering at LOD boundaries, as a fraction of distance.
20
46
  */
21
- levels: Array<{ distance: number; hysteresis: number; object: Object3D }>;
47
+ levels: Array<{
48
+ /** The Object3D to display at this level. */
49
+ object: Object3D;
50
+ /** The distance at which to display this level of detail. Expects a `Float`. */
51
+ distance: number;
52
+ /** Threshold used to avoid flickering at LOD boundaries, as a fraction of distance. Expects a `Float`. */
53
+ hysteresis: number;
54
+ }>;
22
55
 
56
+ /**
57
+ * Whether the {@link LOD} object is updated automatically by the renderer per frame or not.
58
+ * If set to `false`, you have to call {@link update | .update()} in the render loop by yourself.
59
+ * @defaultValue `true`
60
+ */
23
61
  autoUpdate: boolean;
24
- readonly isLOD: true;
25
62
 
26
63
  /**
27
64
  * Adds a mesh that will display at a certain distance and greater. Typically the further away the distance, the lower the detail on the mesh.
28
65
  *
29
66
  * @param object The Object3D to display at this level.
30
- * @param distance The distance at which to display this level of detail. Default 0.0.
31
- * @param hysteresis Threshold used to avoid flickering at LOD boundaries, as a fraction of distance. Default 0.0.
67
+ * @param distance The distance at which to display this level of detail. Expects a `Float`. Default `0.0`.
68
+ * @param hysteresis Threshold used to avoid flickering at LOD boundaries, as a fraction of distance. Expects a `Float`. Default `0.0`.
32
69
  */
33
70
  addLevel(object: Object3D, distance?: number, hysteresis?: number): this;
34
71
 
72
+ /**
73
+ * Get the currently active {@link LOD} level
74
+ * @remarks
75
+ * As index of the levels array.
76
+ */
35
77
  getCurrentLevel(): number;
78
+
79
+ /**
80
+ * Get a reference to the first {@link THREE.Object3D | Object3D} (mesh) that is greater than {@link distance}.
81
+ * @param distance Expects a `Float`
82
+ */
36
83
  getObjectForDistance(distance: number): Object3D | null;
37
- raycast(raycaster: Raycaster, intersects: Intersection[]): void;
38
- update(camera: Camera): void;
39
- toJSON(meta: any): any;
40
84
 
41
- // TODO: Remove this
42
85
  /**
43
- * @deprecated Use {@link LOD#levels .levels} instead.
86
+ * Set the visibility of each {@link levels | level}'s {@link THREE.Object3D | object} based on distance from the {@link THREE.Camera | camera}.
87
+ * @param camera
44
88
  */
45
- objects: any[];
89
+ update(camera: Camera): void;
46
90
  }
@@ -4,22 +4,85 @@ import { Object3D } from './../core/Object3D';
4
4
  import { BufferGeometry } from '../core/BufferGeometry';
5
5
  import { Intersection } from '../core/Raycaster';
6
6
 
7
+ /**
8
+ * A continuous line.
9
+ * @remarks
10
+ * This is nearly the same as {@link THREE.LineSegments | LineSegments},
11
+ * the only difference is that it is rendered using {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements | gl.LINE_STRIP}
12
+ * instead of {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements | gl.LINES}
13
+ * @example
14
+ * ```typescript
15
+ * const material = new THREE.LineBasicMaterial({
16
+ * color: 0x0000ff
17
+ * });
18
+ * const points = [];
19
+ * points.push(new THREE.Vector3(-10, 0, 0));
20
+ * points.push(new THREE.Vector3(0, 10, 0));
21
+ * points.push(new THREE.Vector3(10, 0, 0));
22
+ * const geometry = new THREE.BufferGeometry().setFromPoints(points);
23
+ * const {@link Line} = new THREE.Line(geometry, material);
24
+ * scene.add(line);
25
+ * ```
26
+ * @see {@link https://threejs.org/docs/index.html#api/en/objects/Line | Official Documentation}
27
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Line.js | Source}
28
+ */
7
29
  export class Line<
8
30
  TGeometry extends BufferGeometry = BufferGeometry,
9
31
  TMaterial extends Material | Material[] = Material | Material[],
10
32
  > extends Object3D {
33
+ /**
34
+ * Create a new instance of {@link Line}
35
+ * @param geometry Vertices representing the {@link Line} segment(s). Default {@link THREE.BufferGeometry | `new THREE.BufferGeometry()`}.
36
+ * @param material Material for the line. Default {@link THREE.LineBasicMaterial | `new THREE.LineBasicMaterial()`}.
37
+ */
11
38
  constructor(geometry?: TGeometry, material?: TMaterial);
12
39
 
40
+ /**
41
+ * Read-only flag to check if a given object is of type {@link Line}.
42
+ * @remarks This is a _constant_ value
43
+ * @defaultValue `true`
44
+ */
45
+ readonly isLine: true;
46
+
47
+ /**
48
+ * @override
49
+ * @defaultValue `Line`
50
+ */
51
+ override readonly type: string | 'Line';
52
+
53
+ /**
54
+ * Vertices representing the {@link Line} segment(s).
55
+ */
13
56
  geometry: TGeometry;
14
- material: TMaterial;
15
57
 
16
- type: 'Line' | 'LineLoop' | 'LineSegments' | string;
17
- readonly isLine: true;
58
+ /**
59
+ * Material for the line.
60
+ */
61
+ material: TMaterial;
18
62
 
63
+ /**
64
+ * An array of weights typically from `0-1` that specify how much of the morph is applied.
65
+ * @defaultValue `undefined`, but reset to a blank array by {@link updateMorphTargets | .updateMorphTargets()}.
66
+ */
19
67
  morphTargetInfluences?: number[] | undefined;
68
+
69
+ /**
70
+ * A dictionary of morphTargets based on the `morphTarget.name` property.
71
+ * @defaultValue `undefined`, but reset to a blank array by {@link updateMorphTargets | .updateMorphTargets()}.
72
+ */
20
73
  morphTargetDictionary?: { [key: string]: number } | undefined;
21
74
 
75
+ /**
76
+ * Computes an array of distance values which are necessary for {@link THREE.LineDashedMaterial | LineDashedMaterial}
77
+ * @remarks
78
+ * For each vertex in the geometry, the method calculates the cumulative length from the current point to the very beginning of the line.
79
+ */
22
80
  computeLineDistances(): this;
23
- raycast(raycaster: Raycaster, intersects: Intersection[]): void;
81
+
82
+ /**
83
+ * Updates the morphTargets to have no influence on the object
84
+ * @remarks
85
+ * Resets the {@link morphTargetInfluences | .morphTargetInfluences} and {@link morphTargetDictionary | .morphTargetDictionary} properties.
86
+ */
24
87
  updateMorphTargets(): void;
25
88
  }
@@ -2,12 +2,37 @@ import { Line } from './Line';
2
2
  import { Material } from './../materials/Material';
3
3
  import { BufferGeometry } from '../core/BufferGeometry';
4
4
 
5
+ /**
6
+ * A continuous line that connects back to the start.
7
+ * @remarks
8
+ * This is nearly the same as {@link THREE.Line | Line},
9
+ * the only difference is that it is rendered using {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements | gl.LINE_LOOP}
10
+ * instead of {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements | gl.LINE_STRIP},
11
+ * which draws a straight line to the next vertex, and connects the last vertex back to the first.
12
+ * @see {@link https://threejs.org/docs/index.html#api/en/objects/LineLoop | Official Documentation}
13
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/LineLoop.js | Source}
14
+ */
5
15
  export class LineLoop<
6
16
  TGeometry extends BufferGeometry = BufferGeometry,
7
17
  TMaterial extends Material | Material[] = Material | Material[],
8
18
  > extends Line<TGeometry, TMaterial> {
19
+ /**
20
+ * Create a new instance of {@link LineLoop}
21
+ * @param geometry List of vertices representing points on the line loop. Default {@link THREE.BufferGeometry | `new THREE.BufferGeometry()`}.
22
+ * @param material Material for the line. Default {@link THREE.LineBasicMaterial | `new THREE.LineBasicMaterial()`}.
23
+ */
9
24
  constructor(geometry?: TGeometry, material?: TMaterial);
10
25
 
11
- type: 'LineLoop';
26
+ /**
27
+ * Read-only flag to check if a given object is of type {@link LineLoop}.
28
+ * @remarks This is a _constant_ value
29
+ * @defaultValue `true`
30
+ */
12
31
  readonly isLineLoop: true;
32
+
33
+ /**
34
+ * @override
35
+ * @defaultValue `LineLoop`
36
+ */
37
+ override readonly type: string | 'LineLoop';
13
38
  }