1 | import { Audio } from "./Audio.js";
|
2 | import { AudioListener } from "./AudioListener.js";
|
3 |
|
4 | /**
|
5 | * Create a positional audio object.
|
6 | * This uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API | Web Audio API}.
|
7 | * @example
|
8 | * ```typescript
|
9 | * // create an AudioListener and add it to the camera
|
10 | * const listener = new THREE.AudioListener();
|
11 | * camera.add(listener);
|
12 | * // create the {@link PositionalAudio} object (passing in the listener)
|
13 | * const sound = new THREE.PositionalAudio(listener);
|
14 | * // load a sound and set it as the {@link PositionalAudio} object's buffer
|
15 | * const audioLoader = new THREE.AudioLoader();
|
16 | * audioLoader.load('sounds/song.ogg', function (buffer) {
|
17 | * sound.setBuffer(buffer);
|
18 | * sound.setRefDistance(20);
|
19 | * sound.play();
|
20 | * });
|
21 | * // create an object for the sound to play from
|
22 | * const sphere = new THREE.SphereGeometry(20, 32, 16);
|
23 | * const material = new THREE.MeshPhongMaterial({
|
24 | * color: 0xff2200
|
25 | * });
|
26 | * const mesh = new THREE.Mesh(sphere, material);
|
27 | * scene.add(mesh);
|
28 | * // finally add the sound to the mesh
|
29 | * mesh.add(sound);
|
30 | * ```
|
31 | * @see Example: {@link https://threejs.org/examples/#webaudio_orientation | webaudio / orientation }
|
32 | * @see Example: {@link https://threejs.org/examples/#webaudio_sandbox | webaudio / sandbox }
|
33 | * @see Example: {@link https://threejs.org/examples/#webaudio_timing | webaudio / timing }
|
34 | * @see {@link https://threejs.org/docs/index.html#api/en/audio/PositionalAudio | Official Documentation}
|
35 | * @see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/PositionalAudio.js | Source}
|
36 | */
|
37 | export class PositionalAudio extends Audio<PannerNode> {
|
38 | /**
|
39 | * Create a new instance of {@link PositionalAudio}
|
40 | * @param listener (required) {@link AudioListener | AudioListener} instance.
|
41 | */
|
42 | constructor(listener: AudioListener);
|
43 |
|
44 | /**
|
45 | * The PositionalAudio's {//developer.mozilla.org/en-US/docs/Web/API/PannerNode | PannerNode}.
https: |
46 | */
|
47 | panner: PannerNode;
|
48 |
|
49 | /**
|
50 | * Returns the {@link PositionalAudio.panner | panner}.
|
51 | */
|
52 | getOutput(): PannerNode;
|
53 |
|
54 | /**
|
55 | * Returns the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance | panner.refDistance}.
|
56 | */
|
57 | getRefDistance(): number;
|
58 | /**
|
59 | * Sets the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance | panner.refDistance}.
|
60 | * @param value Expects a `Float`
|
61 | */
|
62 | setRefDistance(value: number): this;
|
63 |
|
64 | /**
|
65 | * Returns the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor | panner.rolloffFactor}.
|
66 | */
|
67 | getRolloffFactor(): number;
|
68 | /**
|
69 | * Sets the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor | panner.rolloffFactor}.
|
70 | * @param value Expects a `Float`
|
71 | */
|
72 | setRolloffFactor(value: number): this;
|
73 |
|
74 | /**
|
75 | * Returns the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel | panner.distanceModel}.
|
76 | */
|
77 | getDistanceModel(): string;
|
78 | /**
|
79 | * Sets the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel | panner.distanceModel}.
|
80 | * @param value
|
81 | */
|
82 | setDistanceModel(value: string): this;
|
83 |
|
84 | /**
|
85 | * Returns the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance | panner.maxDistance}.
|
86 | */
|
87 | getMaxDistance(): number;
|
88 | /**
|
89 | * Sets the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance | panner.maxDistance}.
|
90 | * @param value Expects a `Float`
|
91 | */
|
92 | setMaxDistance(value: number): this;
|
93 |
|
94 | /**
|
95 | * This method can be used in order to transform an omnidirectional sound into a {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode | directional sound}.
|
96 | * @param coneInnerAngle Expects a `Float`
|
97 | * @param coneOuterAngle Expects a `Float`
|
98 | * @param coneOuterGain Expects a `Float`
|
99 | */
|
100 | setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): this;
|
101 | }
|