@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.
- three/README.md +1 -1
- three/examples/jsm/controls/OrbitControls.d.ts +3 -3
- three/examples/jsm/controls/TrackballControls.d.ts +2 -2
- three/examples/jsm/controls/TransformControls.d.ts +2 -6
- three/examples/jsm/geometries/TextGeometry.d.ts +92 -15
- three/examples/jsm/loaders/EXRLoader.d.ts +3 -2
- three/examples/jsm/misc/GPUComputationRenderer.d.ts +4 -2
- three/package.json +2 -2
- three/src/audio/Audio.d.ts +184 -20
- three/src/audio/AudioAnalyser.d.ts +42 -4
- three/src/audio/AudioContext.d.ts +12 -1
- three/src/audio/AudioListener.d.ts +76 -8
- three/src/audio/PositionalAudio.d.ts +86 -5
- three/src/cameras/ArrayCamera.d.ts +23 -2
- three/src/cameras/Camera.d.ts +42 -13
- three/src/cameras/CubeCamera.d.ts +49 -1
- three/src/cameras/OrthographicCamera.d.ts +77 -25
- three/src/cameras/PerspectiveCamera.d.ts +132 -56
- three/src/cameras/StereoCamera.d.ts +29 -2
- three/src/constants.d.ts +431 -26
- three/src/core/BufferGeometry.d.ts +5 -3
- three/src/core/Object3D.d.ts +17 -13
- three/src/core/Raycaster.d.ts +1 -0
- three/src/geometries/BoxGeometry.d.ts +39 -16
- three/src/geometries/CapsuleGeometry.d.ts +35 -12
- three/src/geometries/CircleGeometry.d.ts +38 -12
- three/src/geometries/ConeGeometry.d.ts +45 -10
- three/src/geometries/CylinderGeometry.d.ts +41 -19
- three/src/geometries/DodecahedronGeometry.d.ts +14 -5
- three/src/geometries/EdgesGeometry.d.ts +30 -8
- three/src/geometries/ExtrudeGeometry.d.ts +93 -12
- three/src/geometries/IcosahedronGeometry.d.ts +15 -5
- three/src/geometries/LatheGeometry.d.ts +41 -12
- three/src/geometries/OctahedronGeometry.d.ts +14 -5
- three/src/geometries/PlaneGeometry.d.ts +35 -12
- three/src/geometries/PolyhedronGeometry.d.ts +41 -12
- three/src/geometries/RingGeometry.d.ts +39 -16
- three/src/geometries/ShapeGeometry.d.ts +44 -4
- three/src/geometries/SphereGeometry.d.ts +43 -21
- three/src/geometries/TetrahedronGeometry.d.ts +14 -5
- three/src/geometries/TorusGeometry.d.ts +35 -13
- three/src/geometries/TorusKnotGeometry.d.ts +39 -16
- three/src/geometries/TubeGeometry.d.ts +63 -15
- three/src/geometries/WireframeGeometry.d.ts +30 -4
- three/src/math/ColorManagement.d.ts +2 -2
- three/src/objects/Bone.d.ts +30 -3
- three/src/objects/Group.d.ts +37 -1
- three/src/objects/InstancedMesh.d.ts +122 -3
- three/src/objects/LOD.d.ts +62 -18
- three/src/objects/Line.d.ts +67 -4
- three/src/objects/LineLoop.d.ts +26 -1
- three/src/objects/LineSegments.d.ts +21 -9
- three/src/objects/Mesh.d.ts +60 -4
- three/src/objects/Points.d.ts +39 -8
- three/src/objects/Skeleton.d.ts +89 -3
- three/src/objects/SkinnedMesh.d.ts +122 -3
- three/src/objects/Sprite.d.ts +51 -4
- three/src/renderers/WebGLRenderTarget.d.ts +9 -3
- three/src/scenes/Fog.d.ts +59 -7
- three/src/scenes/FogExp2.d.ts +41 -6
- three/src/scenes/Scene.d.ts +45 -22
- three/src/textures/CanvasTexture.d.ts +35 -13
- three/src/textures/CompressedArrayTexture.d.ts +39 -5
- three/src/textures/CompressedTexture.d.ts +49 -20
- three/src/textures/CubeTexture.d.ts +71 -18
- three/src/textures/Data3DTexture.d.ts +74 -10
- three/src/textures/DataArrayTexture.d.ts +83 -9
- three/src/textures/DataTexture.d.ts +81 -26
- three/src/textures/DepthTexture.d.ts +71 -15
- three/src/textures/FramebufferTexture.d.ts +57 -2
- three/src/textures/Source.d.ts +23 -13
- three/src/textures/Texture.d.ts +289 -73
- three/src/textures/VideoTexture.d.ts +69 -13
- three/src/textures/types.d.ts +9 -0
three/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for three (https://threejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/three.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Sun, 02 Apr 2023 10:33:00 GMT
|
|
12
12
|
* Dependencies: [@types/fflate](https://npmjs.com/package/@types/fflate), [@types/lil-gui](https://npmjs.com/package/@types/lil-gui), [@types/stats.js](https://npmjs.com/package/@types/stats.js), [@types/webxr](https://npmjs.com/package/@types/webxr)
|
|
13
13
|
* Global values: `THREE`
|
|
14
14
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Camera, MOUSE,
|
|
1
|
+
import { Camera, MOUSE, TOUCH, Vector3 } from '../../../src/Three';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Orbit controls allow the camera to orbit around a target.
|
|
@@ -193,13 +193,13 @@ export class OrbitControls {
|
|
|
193
193
|
* This object contains references to the mouse actions used
|
|
194
194
|
* by the controls.
|
|
195
195
|
*/
|
|
196
|
-
mouseButtons: Partial<{ LEFT:
|
|
196
|
+
mouseButtons: Partial<{ LEFT: MOUSE; MIDDLE: MOUSE; RIGHT: MOUSE }>;
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
199
|
* This object contains references to the touch actions used by
|
|
200
200
|
* the controls.
|
|
201
201
|
*/
|
|
202
|
-
touches: Partial<{ ONE:
|
|
202
|
+
touches: Partial<{ ONE: TOUCH; TWO: TOUCH }>;
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* Used internally by the .saveState and .reset methods.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Camera, EventDispatcher, MOUSE,
|
|
1
|
+
import { Camera, EventDispatcher, MOUSE, Vector3 } from '../../../src/Three';
|
|
2
2
|
|
|
3
3
|
export class TrackballControls extends EventDispatcher {
|
|
4
4
|
constructor(object: Camera, domElement?: HTMLElement);
|
|
@@ -21,7 +21,7 @@ export class TrackballControls extends EventDispatcher {
|
|
|
21
21
|
minDistance: number;
|
|
22
22
|
maxDistance: number;
|
|
23
23
|
keys: string[];
|
|
24
|
-
mouseButtons: { LEFT:
|
|
24
|
+
mouseButtons: { LEFT: MOUSE; MIDDLE: MOUSE; RIGHT: MOUSE };
|
|
25
25
|
|
|
26
26
|
target: Vector3;
|
|
27
27
|
position0: Vector3;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Object3D, Camera, MOUSE, Raycaster, Mesh, Vector3, Quaternion
|
|
1
|
+
import { Object3D, Camera, MOUSE, Raycaster, Mesh, Vector3, Quaternion } from '../../../src/Three';
|
|
2
2
|
|
|
3
3
|
export class TransformControls extends Object3D {
|
|
4
4
|
constructor(object: Camera, domElement?: HTMLElement);
|
|
@@ -21,11 +21,7 @@ export class TransformControls extends Object3D {
|
|
|
21
21
|
showY: boolean;
|
|
22
22
|
showZ: boolean;
|
|
23
23
|
readonly isTransformControls: true;
|
|
24
|
-
mouseButtons: {
|
|
25
|
-
LEFT: MouseButton;
|
|
26
|
-
MIDDLE: MouseButton;
|
|
27
|
-
RIGHT: MouseButton;
|
|
28
|
-
};
|
|
24
|
+
mouseButtons: { LEFT: MOUSE; MIDDLE: MOUSE; RIGHT: MOUSE };
|
|
29
25
|
|
|
30
26
|
attach(object: Object3D): this;
|
|
31
27
|
detach(): this;
|
|
@@ -1,37 +1,114 @@
|
|
|
1
|
-
import { ExtrudeGeometry } from '../../../src/Three';
|
|
1
|
+
import { ExtrudeGeometry, ExtrudeGeometryOptions, Shape } from '../../../src/Three';
|
|
2
2
|
|
|
3
3
|
import { Font } from '../loaders/FontLoader';
|
|
4
4
|
|
|
5
|
-
export interface TextGeometryParameters {
|
|
5
|
+
export interface TextGeometryParameters extends ExtrudeGeometryOptions {
|
|
6
6
|
font: Font;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Size of the text
|
|
10
|
+
* Expects a `Float`.
|
|
11
|
+
* @defaultValue `100`
|
|
12
|
+
*/
|
|
7
13
|
size?: number | undefined;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Thickness to extrude text.
|
|
17
|
+
* Expects a `Float`.
|
|
18
|
+
* @defaultValue `50`
|
|
19
|
+
*/
|
|
8
20
|
height?: number | undefined;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @override
|
|
24
|
+
* @defaultValue `12`
|
|
25
|
+
*/
|
|
9
26
|
curveSegments?: number | undefined;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @defaultValue `false`
|
|
30
|
+
*/
|
|
10
31
|
bevelEnabled?: boolean | undefined;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* How deep into text bevel goes.
|
|
35
|
+
* Expects a `Float`.
|
|
36
|
+
* @override
|
|
37
|
+
* @defaultValue `10`
|
|
38
|
+
*/
|
|
11
39
|
bevelThickness?: number | undefined;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* How far from text outline is bevel.
|
|
43
|
+
* Expects a `Float`.
|
|
44
|
+
* @override
|
|
45
|
+
* @defaultValue `8`
|
|
46
|
+
*/
|
|
12
47
|
bevelSize?: number | undefined;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* How far from text outline bevel starts.
|
|
51
|
+
* Expects a `Float`.
|
|
52
|
+
* @override
|
|
53
|
+
* @defaultValue `0`
|
|
54
|
+
*/
|
|
13
55
|
bevelOffset?: number | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @override
|
|
59
|
+
* @defaultValue `3`
|
|
60
|
+
*/
|
|
14
61
|
bevelSegments?: number | undefined;
|
|
15
62
|
}
|
|
16
63
|
|
|
64
|
+
/**
|
|
65
|
+
* A class for generating text as a single geometry
|
|
66
|
+
* @remarks
|
|
67
|
+
* It is constructed by providing a string of text, and a set of parameters consisting of a loaded font and settings for the geometry's parent {@link THREE.ExtrudeGeometry | ExtrudeGeometry}
|
|
68
|
+
* See the {@link THREE.FontLoader | FontLoader} page for additional details.
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const loader = new FontLoader();
|
|
72
|
+
* loader.load('fonts/helvetiker_regular.typeface.json', function (font) {
|
|
73
|
+
* const geometry = new TextGeometry('Hello three.js!', {
|
|
74
|
+
* font: font,
|
|
75
|
+
* size: 80,
|
|
76
|
+
* height: 5,
|
|
77
|
+
* curveSegments: 12,
|
|
78
|
+
* bevelEnabled: true,
|
|
79
|
+
* bevelThickness: 10,
|
|
80
|
+
* bevelSize: 8,
|
|
81
|
+
* bevelOffset: 0,
|
|
82
|
+
* bevelSegments: 5
|
|
83
|
+
* });
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
* @see Example: {@link https://threejs.org/examples/#webgl_geometry_text | geometry / text }
|
|
87
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/C:/rafaelsc/Source/threejs/three.js/docs/examples/en/geometries/TextGeometry | Official Documentation}
|
|
88
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/TextGeometry.js | Source}
|
|
89
|
+
*/
|
|
17
90
|
export class TextGeometry extends ExtrudeGeometry {
|
|
18
91
|
/**
|
|
19
|
-
* @
|
|
92
|
+
* Create a new instance of {@link TextGeometry}
|
|
93
|
+
* @param text The text that needs to be shown.
|
|
94
|
+
* @param parameters Object that can contain the following parameters. @see {@link TextGeometryParameters} for defaults.
|
|
20
95
|
*/
|
|
21
|
-
|
|
96
|
+
constructor(text: string, parameters?: TextGeometryParameters);
|
|
22
97
|
|
|
23
|
-
|
|
98
|
+
/**
|
|
99
|
+
* A Read-only _string_ to check if `this` object type.
|
|
100
|
+
* @remarks Sub-classes will update this value.
|
|
101
|
+
* @defaultValue `TextGeometry`
|
|
102
|
+
*/
|
|
103
|
+
override readonly type: string | 'TextGeometry';
|
|
24
104
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
bevelSize: number;
|
|
33
|
-
bevelOffset: number;
|
|
34
|
-
bevelSegments: number;
|
|
105
|
+
/**
|
|
106
|
+
* An object with a property for each of the constructor parameters.
|
|
107
|
+
* @remarks Any modification after instantiation does not change the geometry.
|
|
108
|
+
*/
|
|
109
|
+
readonly parameters: {
|
|
110
|
+
readonly shapes: Shape | Shape[];
|
|
111
|
+
readonly options: TextGeometryParameters;
|
|
35
112
|
};
|
|
36
113
|
}
|
|
37
114
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { LoadingManager,
|
|
1
|
+
import { DataTextureLoader, LoadingManager, PixelFormat, TextureDataType, TextureEncoding } from '../../../src/Three';
|
|
2
2
|
|
|
3
3
|
export interface EXR {
|
|
4
4
|
header: object;
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
7
|
-
data: Float32Array;
|
|
7
|
+
data: Float32Array | Uint16Array;
|
|
8
8
|
format: PixelFormat;
|
|
9
|
+
encoding: TextureEncoding;
|
|
9
10
|
type: TextureDataType;
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
TextureFilter,
|
|
10
10
|
TextureDataType,
|
|
11
11
|
IUniform,
|
|
12
|
+
MagnificationTextureFilter,
|
|
13
|
+
MinificationTextureFilter,
|
|
12
14
|
} from '../../../src/Three';
|
|
13
15
|
|
|
14
16
|
export interface Variable {
|
|
@@ -43,8 +45,8 @@ export class GPUComputationRenderer {
|
|
|
43
45
|
sizeYTexture: number,
|
|
44
46
|
wrapS: Wrapping,
|
|
45
47
|
wrapT: number,
|
|
46
|
-
minFilter:
|
|
47
|
-
magFilter:
|
|
48
|
+
minFilter: MinificationTextureFilter,
|
|
49
|
+
magFilter: MagnificationTextureFilter,
|
|
48
50
|
): WebGLRenderTarget;
|
|
49
51
|
createTexture(): DataTexture;
|
|
50
52
|
renderTexture(input: Texture, output: Texture): void;
|
three/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/three",
|
|
3
|
-
"version": "0.150.
|
|
3
|
+
"version": "0.150.1",
|
|
4
4
|
"description": "TypeScript definitions for three",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/three",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"fflate": "~0.6.9",
|
|
31
31
|
"lil-gui": "~0.17.0"
|
|
32
32
|
},
|
|
33
|
-
"typesPublisherContentHash": "
|
|
33
|
+
"typesPublisherContentHash": "c7ff42de666a86340964d8f399b86ddfa5b1abfa546b40ede1e3385f993d5903",
|
|
34
34
|
"typeScriptVersion": "4.4",
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
three/src/audio/Audio.d.ts
CHANGED
|
@@ -4,22 +4,71 @@ import { AudioContext } from './AudioContext';
|
|
|
4
4
|
|
|
5
5
|
// Extras / Audio /////////////////////////////////////////////////////////////////////
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Create a non-positional ( global ) {@link Audio} object.
|
|
9
|
+
* This uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API | Web {@link Audio} API}.
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // create an AudioListener and add it to the camera
|
|
13
|
+
* const listener = new THREE.AudioListener();
|
|
14
|
+
* camera.add(listener);
|
|
15
|
+
* // create a global {@link Audio} source
|
|
16
|
+
* const sound = new THREE.Audio(listener);
|
|
17
|
+
* // load a sound and set it as the {@link Audio} object's buffer
|
|
18
|
+
* const audioLoader = new THREE.AudioLoader();
|
|
19
|
+
* audioLoader.load('sounds/ambient.ogg', function (buffer) {
|
|
20
|
+
* sound.setBuffer(buffer);
|
|
21
|
+
* sound.setLoop(true);
|
|
22
|
+
* sound.setVolume(0.5);
|
|
23
|
+
* sound.play();
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
* @see Example: {@link https://threejs.org/examples/#webaudio_sandbox | webaudio / sandbox }
|
|
27
|
+
* @see Example: {@link https://threejs.org/examples/#webaudio_visualizer | webaudio / visualizer }
|
|
28
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/audio/Audio | Official Documentation}
|
|
29
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/Audio.js | Source}
|
|
30
|
+
*/
|
|
7
31
|
export class Audio<NodeType extends AudioNode = GainNode> extends Object3D {
|
|
32
|
+
/**
|
|
33
|
+
* Create a new instance of {@link Audio}
|
|
34
|
+
* @param listener (required) {@link AudioListener | AudioListener} instance.
|
|
35
|
+
*/
|
|
8
36
|
constructor(listener: AudioListener);
|
|
9
|
-
type: 'Audio';
|
|
10
37
|
|
|
38
|
+
/**
|
|
39
|
+
* A Read-only _string_ to check if `this` object type.
|
|
40
|
+
* @remarks Sub-classes will update this value.
|
|
41
|
+
* @defaultValue `Audio`
|
|
42
|
+
*/
|
|
43
|
+
readonly type: string | 'Audio';
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A reference to the listener object of this audio.
|
|
47
|
+
*/
|
|
11
48
|
listener: AudioListener;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext | AudioContext} of the {@link AudioListener | listener} given in the constructor.
|
|
52
|
+
*/
|
|
12
53
|
context: AudioContext;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/GainNode | GainNode} created using
|
|
57
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain | AudioContext.createGain}().
|
|
58
|
+
*/
|
|
13
59
|
gain: GainNode;
|
|
14
60
|
|
|
15
61
|
/**
|
|
16
|
-
*
|
|
62
|
+
* Whether to start playback automatically.
|
|
63
|
+
* @defaultValue `false`
|
|
17
64
|
*/
|
|
18
65
|
autoplay: boolean;
|
|
19
|
-
|
|
66
|
+
|
|
67
|
+
buffer: AudioBuffer | null;
|
|
20
68
|
|
|
21
69
|
/**
|
|
22
|
-
*
|
|
70
|
+
* Modify pitch, measured in cents. +/- 100 is a semitone. +/- 1200 is an octave.
|
|
71
|
+
* @defaultValue `0`
|
|
23
72
|
*/
|
|
24
73
|
detune: number;
|
|
25
74
|
|
|
@@ -39,68 +88,183 @@ export class Audio<NodeType extends AudioNode = GainNode> extends Object3D {
|
|
|
39
88
|
loopEnd: number;
|
|
40
89
|
|
|
41
90
|
/**
|
|
42
|
-
* @
|
|
91
|
+
* An offset to the time within the {@link Audio} buffer that playback should begin.
|
|
92
|
+
* Same as the {@link Audio.offset | offset} parameter of {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start | AudioBufferSourceNode.start()}.
|
|
93
|
+
* @defaultValue `0`
|
|
43
94
|
*/
|
|
44
95
|
offset: number;
|
|
45
96
|
|
|
46
97
|
/**
|
|
47
|
-
* @
|
|
98
|
+
* Overrides the duration of the audio. Same as the {@link Audio.duration | duration} parameter of
|
|
99
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start | AudioBufferSourceNode.start()}.
|
|
100
|
+
* @defaultValue `undefined` _to play the whole buffer_.
|
|
48
101
|
*/
|
|
49
102
|
duration: number | undefined;
|
|
50
103
|
|
|
51
104
|
/**
|
|
52
|
-
*
|
|
105
|
+
* Speed of playback.
|
|
106
|
+
* @defaultValue `1`
|
|
53
107
|
*/
|
|
54
108
|
playbackRate: number;
|
|
55
109
|
|
|
56
110
|
/**
|
|
57
|
-
* @
|
|
111
|
+
* Whether the {@link Audio} is currently playing.
|
|
112
|
+
* @defaultValue `false`
|
|
58
113
|
*/
|
|
59
114
|
isPlaying: boolean;
|
|
60
115
|
|
|
61
116
|
/**
|
|
62
|
-
* @
|
|
117
|
+
* Whether playback can be controlled using the {@link Audio.play | play}(), {@link Audio.pause | pause}() etc. methods.
|
|
118
|
+
* @defaultValue `true`
|
|
63
119
|
*/
|
|
64
120
|
hasPlaybackControl: boolean;
|
|
65
121
|
|
|
66
122
|
/**
|
|
67
|
-
* @
|
|
123
|
+
* Type of the {@link Audio} source.
|
|
124
|
+
* @defaultValue 'empty'.
|
|
68
125
|
*/
|
|
69
126
|
sourceType: string;
|
|
70
|
-
source: null | AudioBufferSourceNode;
|
|
71
127
|
|
|
72
128
|
/**
|
|
73
|
-
* @
|
|
129
|
+
* An {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode | AudioBufferSourceNode} created using
|
|
130
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createBufferSource | AudioContext.createBufferSource()}.
|
|
131
|
+
*/
|
|
132
|
+
source: AudioBufferSourceNode | null;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Represents an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioNode | AudioNodes}.
|
|
136
|
+
* Can be used to apply a variety of low-order filters to create more complex sound effects.
|
|
137
|
+
* In most cases, the array contains instances of {@link https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode | BiquadFilterNodes}.
|
|
138
|
+
* Filters are set via {@link THREE.Audio.setFilter | Audio.setFilter} or {@link THREE.Audio.setFilters | Audio.setFilters}.
|
|
139
|
+
* @defaultValue `[]`
|
|
74
140
|
*/
|
|
75
141
|
filters: AudioNode[];
|
|
76
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Return the {@link Audio.gain | gainNode}.
|
|
145
|
+
*/
|
|
77
146
|
getOutput(): NodeType;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Setup the {@link Audio.source | source} to the audioBuffer, and sets {@link Audio.sourceType | sourceType} to 'audioNode'.
|
|
150
|
+
* @remarks Also sets {@link Audio.hasPlaybackControl | hasPlaybackControl} to false.
|
|
151
|
+
*/
|
|
78
152
|
setNodeSource(audioNode: AudioBufferSourceNode): this;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Applies the given object of type {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement | HTMLMediaElement} as the source of this audio.
|
|
156
|
+
* @remarks Also sets {@link Audio.hasPlaybackControl | hasPlaybackControl} to false.
|
|
157
|
+
*/
|
|
79
158
|
setMediaElementSource(mediaElement: HTMLMediaElement): this;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Applies the given object of type {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStream | MediaStream} as the source of this audio.
|
|
162
|
+
* @remarks Also sets {@link Audio.hasPlaybackControl | hasPlaybackControl} to false.
|
|
163
|
+
*/
|
|
80
164
|
setMediaStreamSource(mediaStream: MediaStream): this;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Setup the {@link Audio.source | source} to the audioBuffer, and sets {@link Audio.sourceType | sourceType} to 'buffer'.
|
|
168
|
+
* @remarks If {@link Audio.autoplay | autoplay}, also starts playback.
|
|
169
|
+
*/
|
|
81
170
|
setBuffer(audioBuffer: AudioBuffer): this;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* If {@link Audio.hasPlaybackControl | hasPlaybackControl} is true, starts playback.
|
|
174
|
+
*/
|
|
82
175
|
play(delay?: number): this;
|
|
83
|
-
|
|
176
|
+
/**
|
|
177
|
+
* If {@link Audio.hasPlaybackControl | hasPlaybackControl} is true, pauses playback.
|
|
178
|
+
*/
|
|
84
179
|
pause(): this;
|
|
180
|
+
/**
|
|
181
|
+
* If {@link Audio.hasPlaybackControl | hasPlaybackControl} is enabled, stops playback.
|
|
182
|
+
*/
|
|
85
183
|
stop(): this;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Called automatically when playback finished.
|
|
187
|
+
*/
|
|
188
|
+
onEnded(): void;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Connect to the {@link THREE.Audio.source | Audio.source}
|
|
192
|
+
* @remarks This is used internally on initialisation and when setting / removing filters.
|
|
193
|
+
*/
|
|
86
194
|
connect(): this;
|
|
195
|
+
/**
|
|
196
|
+
* Disconnect from the {@link THREE.Audio.source | Audio.source}
|
|
197
|
+
* @remarks This is used internally when setting / removing filters.
|
|
198
|
+
*/
|
|
87
199
|
disconnect(): this;
|
|
88
|
-
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Returns the detuning of oscillation in cents.
|
|
203
|
+
*/
|
|
89
204
|
getDetune(): number;
|
|
90
|
-
|
|
91
|
-
|
|
205
|
+
/**
|
|
206
|
+
* Defines the detuning of oscillation in cents.
|
|
207
|
+
* @param value Expects a `Float`
|
|
208
|
+
*/
|
|
209
|
+
setDetune(value: number): this;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Returns the first element of the {@link Audio.filters | filters} array.
|
|
213
|
+
*/
|
|
92
214
|
getFilter(): AudioNode;
|
|
215
|
+
/**
|
|
216
|
+
* Applies a single filter node to the audio.
|
|
217
|
+
*/
|
|
93
218
|
setFilter(filter: AudioNode): this;
|
|
94
|
-
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Returns the {@link Audio.filters | filters} array.
|
|
222
|
+
*/
|
|
223
|
+
getFilters(): AudioNode[];
|
|
224
|
+
/**
|
|
225
|
+
* Applies an array of filter nodes to the audio.
|
|
226
|
+
* @param value Arrays of filters.
|
|
227
|
+
*/
|
|
228
|
+
setFilters(value: AudioNode[]): this;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Return the value of {@link Audio.playbackRate | playbackRate}.
|
|
232
|
+
*/
|
|
95
233
|
getPlaybackRate(): number;
|
|
234
|
+
/**
|
|
235
|
+
* If {@link Audio.hasPlaybackControl | hasPlaybackControl} is enabled, set the {@link Audio.playbackRate | playbackRate} to `value`.
|
|
236
|
+
* @param value Expects a `Float`
|
|
237
|
+
*/
|
|
238
|
+
setPlaybackRate(value: number): this;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Return the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loop | source.loop} (whether playback should loop).
|
|
242
|
+
*/
|
|
96
243
|
getLoop(): boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Set {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loop | source.loop} to `value` (whether playback should loop).
|
|
246
|
+
* @param value
|
|
247
|
+
*/
|
|
97
248
|
setLoop(value: boolean): this;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Set {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loopStart | source.loopStart} to `value`.
|
|
252
|
+
* @param value Expects a `Float`
|
|
253
|
+
*/
|
|
98
254
|
setLoopStart(value: number): this;
|
|
255
|
+
/**
|
|
256
|
+
* Set {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loopEnd | source.loopEnd} to `value`.
|
|
257
|
+
* @param value Expects a `Float`
|
|
258
|
+
*/
|
|
99
259
|
setLoopEnd(value: number): this;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Return the current volume.
|
|
263
|
+
*/
|
|
100
264
|
getVolume(): number;
|
|
101
|
-
setVolume(value: number): this;
|
|
102
265
|
/**
|
|
103
|
-
*
|
|
266
|
+
* Set the volume.
|
|
267
|
+
* @param value Expects a `Float`
|
|
104
268
|
*/
|
|
105
|
-
|
|
269
|
+
setVolume(value: number): this;
|
|
106
270
|
}
|
|
@@ -1,20 +1,58 @@
|
|
|
1
1
|
import { Audio } from './Audio';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Create a {@link AudioAnalyser} object, which uses an {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode | AnalyserNode} to analyse audio data.
|
|
5
|
+
* This uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API | Web Audio API}.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // create an AudioListener and add it to the camera
|
|
9
|
+
* const listener = new THREE.AudioListener();
|
|
10
|
+
* camera.add(listener);
|
|
11
|
+
* // create an Audio source
|
|
12
|
+
* const sound = new THREE.Audio(listener);
|
|
13
|
+
* // load a sound and set it as the Audio object's buffer
|
|
14
|
+
* const audioLoader = new THREE.AudioLoader();
|
|
15
|
+
* audioLoader.load('sounds/ambient.ogg', function (buffer) {
|
|
16
|
+
* sound.setBuffer(buffer);
|
|
17
|
+
* sound.setLoop(true);
|
|
18
|
+
* sound.setVolume(0.5);
|
|
19
|
+
* sound.play();
|
|
20
|
+
* });
|
|
21
|
+
* // create an AudioAnalyser, passing in the sound and desired fftSize
|
|
22
|
+
* const analyser = new THREE.AudioAnalyser(sound, 32);
|
|
23
|
+
* // get the average frequency of the sound
|
|
24
|
+
* const data = analyser.getAverageFrequency();
|
|
25
|
+
* ```
|
|
26
|
+
* @see Example: {@link https://threejs.org/examples/#webaudio_sandbox | webaudio / sandbox }
|
|
27
|
+
* @see Example: {@link https://threejs.org/examples/#webaudio_visualizer | webaudio / visualizer }
|
|
28
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/audio/AudioAnalyser | Official Documentation}
|
|
29
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/AudioAnalyser.js | Source}
|
|
30
|
+
*/
|
|
3
31
|
export class AudioAnalyser {
|
|
4
32
|
/**
|
|
33
|
+
* Create a new {@link {@link AudioAnalyser} | AudioAnalyser}.
|
|
5
34
|
* @param audio
|
|
6
|
-
* @param
|
|
35
|
+
* @param fftSize See {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize | AnalyserNode.fftSize }. Expects a `unsigned integer`. Default `2048`.
|
|
7
36
|
*/
|
|
8
37
|
constructor(audio: Audio<AudioNode>, fftSize?: number);
|
|
9
38
|
|
|
39
|
+
/**
|
|
40
|
+
* An {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode | AnalyserNode} used to analyze audio.
|
|
41
|
+
*/
|
|
10
42
|
analyser: AnalyserNode;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A Uint8Array with size determined by {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount | analyser.frequencyBinCount} used to hold analysis data.
|
|
46
|
+
*/
|
|
11
47
|
data: Uint8Array;
|
|
12
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Uses the Web Audio's {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData | getByteFrequencyData} method
|
|
51
|
+
*/
|
|
13
52
|
getFrequencyData(): Uint8Array;
|
|
14
|
-
getAverageFrequency(): number;
|
|
15
53
|
|
|
16
54
|
/**
|
|
17
|
-
*
|
|
55
|
+
* Get the average of the frequencies returned by the {@link AudioAnalyser.getFrequencyData | getFrequencyData} method.
|
|
18
56
|
*/
|
|
19
|
-
|
|
57
|
+
getAverageFrequency(): number;
|
|
20
58
|
}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* This contains methods for setting up an {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext | AudioContext}.
|
|
3
|
+
* Used internally by the {@link AudioListener | AudioListener} and {@link AudioLoader | AudioLoader} classes.
|
|
4
|
+
* This uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API | Web Audio API}.
|
|
5
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/audio/AudioContext | Official Documentation}
|
|
6
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/AudioContext.js | Source}
|
|
3
7
|
*/
|
|
4
8
|
export namespace AudioContext {
|
|
9
|
+
/**
|
|
10
|
+
* Return the value of the variable `context` in the outer scope, if defined, otherwise set it to a new {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext | AudioContext}.
|
|
11
|
+
*/
|
|
5
12
|
function getContext(): AudioContext;
|
|
6
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Set the variable `context` in the outer scope to `value`.
|
|
16
|
+
* @param value
|
|
17
|
+
*/
|
|
7
18
|
function setContext(context: AudioContext): void;
|
|
8
19
|
}
|