@types/three 0.149.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 +2 -2
- three/build/three.d.cts +2 -0
- three/build/three.d.ts +2 -0
- three/build/three.module.d.ts +2 -0
- three/examples/jsm/controls/OrbitControls.d.ts +5 -0
- three/examples/jsm/controls/TransformControls.d.ts +1 -5
- three/examples/jsm/geometries/TextGeometry.d.ts +92 -15
- three/examples/jsm/helpers/OctreeHelper.d.ts +1 -1
- three/examples/jsm/libs/fflate.module.d.ts +1 -0
- three/examples/jsm/libs/lil-gui.module.min.d.ts +1 -0
- three/examples/jsm/libs/stats.module.d.ts +2 -23
- three/examples/jsm/loaders/EXRLoader.d.ts +3 -2
- three/examples/jsm/misc/GPUComputationRenderer.d.ts +4 -2
- three/examples/jsm/nodes/shadernode/ShaderNode.d.ts +3 -4
- three/examples/jsm/objects/MarchingCubes.d.ts +1 -0
- three/examples/jsm/shaders/VelocityShader.d.ts +2 -2
- three/index.d.ts +1 -1
- three/package.json +19 -4
- three/src/Three.d.ts +0 -1
- 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 +790 -245
- three/src/core/BufferAttribute.d.ts +456 -85
- three/src/core/BufferGeometry.d.ts +237 -67
- three/src/core/Clock.d.ts +28 -20
- three/src/core/EventDispatcher.d.ts +20 -4
- three/src/core/GLBufferAttribute.d.ts +102 -8
- three/src/core/InstancedBufferAttribute.d.ts +13 -24
- three/src/core/InstancedBufferGeometry.d.ts +22 -4
- three/src/core/InstancedInterleavedBuffer.d.ts +10 -2
- three/src/core/InterleavedBuffer.d.ts +98 -14
- three/src/core/InterleavedBufferAttribute.d.ts +146 -7
- three/src/core/Layers.d.ts +61 -6
- three/src/core/Object3D.d.ts +244 -123
- three/src/core/Raycaster.d.ts +104 -27
- three/src/core/Uniform.d.ts +28 -11
- three/src/core/UniformsGroup.d.ts +10 -4
- three/src/extras/Earcut.d.ts +3 -4
- 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/materials/MeshPhysicalMaterial.d.ts +13 -1
- three/src/math/Color.d.ts +157 -3
- three/src/math/ColorManagement.d.ts +13 -7
- 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/renderers/WebGLRenderer.d.ts +2 -2
- 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/src/utils.d.ts +5 -2
- three/examples/jsm/libs/fflate.module.min.d.ts +0 -1185
three/README.md
CHANGED
|
@@ -8,8 +8,8 @@ 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:
|
|
12
|
-
* Dependencies: [@types/webxr](https://npmjs.com/package/@types/webxr)
|
|
11
|
+
* Last updated: Sun, 02 Apr 2023 10:33:00 GMT
|
|
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
|
|
|
15
15
|
# Credits
|
three/build/three.d.cts
ADDED
three/build/three.d.ts
ADDED
|
@@ -230,6 +230,11 @@ export class OrbitControls {
|
|
|
230
230
|
*/
|
|
231
231
|
listenToKeyEvents(domElement: HTMLElement | Window): void;
|
|
232
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Removes the key event listener previously defined with {@link listenToKeyEvents}.
|
|
235
|
+
*/
|
|
236
|
+
stopListenToKeyEvents(): void;
|
|
237
|
+
|
|
233
238
|
/**
|
|
234
239
|
* Save the current state of the controls. This can later be
|
|
235
240
|
* recovered with .reset.
|
|
@@ -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: MOUSE;
|
|
26
|
-
MIDDLE: MOUSE;
|
|
27
|
-
RIGHT: MOUSE;
|
|
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
|
|
|
@@ -2,7 +2,7 @@ import { ColorRepresentation, LineSegments } from '../../../src/Three';
|
|
|
2
2
|
import { Octree } from '../math/Octree';
|
|
3
3
|
|
|
4
4
|
export class OctreeHelper extends LineSegments {
|
|
5
|
-
constructor(octree: Octree, color
|
|
5
|
+
constructor(octree: Octree, color?: ColorRepresentation);
|
|
6
6
|
|
|
7
7
|
octree: Octree;
|
|
8
8
|
color: ColorRepresentation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'fflate';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'lil-gui';
|
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
REVISION: number;
|
|
3
|
-
dom: HTMLDivElement;
|
|
4
|
-
addPanel(panel: Stats.Panel): Stats.Panel;
|
|
5
|
-
showPanel(id: number): void;
|
|
6
|
-
begin(): void;
|
|
7
|
-
end(): number;
|
|
8
|
-
update(): void;
|
|
9
|
-
domElement: HTMLDivElement;
|
|
10
|
-
setMode(id: number): void;
|
|
11
|
-
}
|
|
1
|
+
import Stats = require('stats.js');
|
|
12
2
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
declare namespace Stats {
|
|
16
|
-
interface Panel {
|
|
17
|
-
dom: HTMLCanvasElement;
|
|
18
|
-
update(value: number, maxValue: number): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function Panel(name?: string, fg?: string, bg?: string): Panel;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default Stats;
|
|
3
|
+
export = Stats;
|
|
@@ -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;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ConstNode, Node, NodeBuilder, NodeTypeOption, SwizzleOption } from '../Nodes';
|
|
2
2
|
// lot of private typescript magic here
|
|
3
3
|
export {};
|
|
4
|
-
export type Swizzable<T extends Node = Node> = T &
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
4
|
+
export type Swizzable<T extends Node = Node> = T & {
|
|
5
|
+
[key in SwizzleOption | number]: Swizzable;
|
|
6
|
+
};
|
|
8
7
|
|
|
9
8
|
/** anything that can be passed to {@link nodeObject} and returns a proxy */
|
|
10
9
|
export type NodeRepresentation<T extends Node = Node> = number | boolean | Node | Swizzable<T>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IUniform, UniformsLib } from '../../../src/Three';
|
|
2
2
|
|
|
3
3
|
export const VelocityShader: {
|
|
4
|
-
uniforms: typeof UniformsLib['common'] &
|
|
5
|
-
typeof UniformsLib['displacementmap'] & {
|
|
4
|
+
uniforms: (typeof UniformsLib)['common'] &
|
|
5
|
+
(typeof UniformsLib)['displacementmap'] & {
|
|
6
6
|
modelMatrixPrev: IUniform;
|
|
7
7
|
currentProjectionViewMatrix: IUniform;
|
|
8
8
|
previousProjectionViewMatrix: IUniform;
|
three/index.d.ts
CHANGED
three/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/three",
|
|
3
|
-
"version": "0.
|
|
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",
|
|
@@ -25,8 +25,23 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@types/
|
|
28
|
+
"@types/stats.js": "*",
|
|
29
|
+
"@types/webxr": "*",
|
|
30
|
+
"fflate": "~0.6.9",
|
|
31
|
+
"lil-gui": "~0.17.0"
|
|
29
32
|
},
|
|
30
|
-
"typesPublisherContentHash": "
|
|
31
|
-
"typeScriptVersion": "4.4"
|
|
33
|
+
"typesPublisherContentHash": "c7ff42de666a86340964d8f399b86ddfa5b1abfa546b40ede1e3385f993d5903",
|
|
34
|
+
"typeScriptVersion": "4.4",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"import": "./build/three.module.js",
|
|
38
|
+
"require": "./build/three.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./examples/fonts/*": "./examples/fonts/*",
|
|
41
|
+
"./examples/jsm/*": "./examples/jsm/*",
|
|
42
|
+
"./addons/*": "./examples/jsm/*",
|
|
43
|
+
"./src/*": "./src/*",
|
|
44
|
+
"./nodes": "./examples/jsm/nodes/Nodes.js",
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
}
|
|
32
47
|
}
|
three/src/Three.d.ts
CHANGED
|
@@ -67,7 +67,6 @@ export * from './extras/core/ShapePath';
|
|
|
67
67
|
export * from './extras/core/CurvePath';
|
|
68
68
|
export * from './extras/core/Curve';
|
|
69
69
|
export * as DataUtils from './extras/DataUtils';
|
|
70
|
-
export * from './extras/Earcut';
|
|
71
70
|
export * from './extras/ImageUtils';
|
|
72
71
|
export * from './extras/ShapeUtils';
|
|
73
72
|
export * from './extras/PMREMGenerator';
|
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
|
}
|