@animech-public/playcanvas
Version:
PlayCanvas WebGL game engine
74 lines (73 loc) • 3.36 kB
TypeScript
/**
* The AudioSource Component controls playback of an audio sample. This class will be deprecated
* in favor of {@link SoundComponent}.
*
* @property {Asset[]} assets The list of audio assets - can also be an array of asset ids.
* @property {boolean} activate If true the audio will begin playing as soon as the scene is
* loaded.
* @property {number} volume The volume modifier to play the audio with. In range 0-1.
* @property {number} pitch The pitch modifier to play the audio with. Must be larger than 0.01.
* @property {boolean} loop If true the audio will restart when it finishes playing.
* @property {boolean} 3d If true the audio will play back at the location of the entity in space,
* so the audio will be affect by the position of the {@link AudioListenerComponent}.
* @property {string} distanceModel Determines which algorithm to use to reduce the volume of the
* audio as it moves away from the listener. Can be:
*
* - "linear"
* - "inverse"
* - "exponential"
*
* Default is "inverse".
* @property {number} minDistance The minimum distance from the listener at which audio falloff
* begins.
* @property {number} maxDistance The maximum distance from the listener at which audio falloff
* stops. Note the volume of the audio is not 0 after this distance, but just doesn't fall off
* anymore.
* @property {number} rollOffFactor The factor used in the falloff equation.
*
* @ignore
*/
export class AudioSourceComponent extends Component {
/**
* Create a new AudioSource Component instance.
*
* @param {import('./system.js').AudioSourceComponentSystem} system - The ComponentSystem that
* created this component.
* @param {import('../../entity.js').Entity} entity - The entity that the Component is attached
* to.
*/
constructor(system: import("./system.js").AudioSourceComponentSystem, entity: import("../../entity.js").Entity);
/**
* Begin playback of an audio asset in the component attached to an entity.
*
* @param {string} name - The name of the Asset to play.
*/
play(name: string): void;
/**
* Pause playback of the audio that is playing on the Entity. Playback can be resumed by
* calling {@link AudioSourceComponent#unpause}.
*/
pause(): void;
/**
* Resume playback of the audio if paused. Playback is resumed at the time it was paused.
*/
unpause(): void;
/**
* Stop playback on an Entity. Playback can not be resumed after being stopped.
*/
stop(): void;
channel: any;
onSetAssets(name: any, oldValue: any, newValue: any): void;
onAssetChanged(asset: any, attribute: any, newValue: any, oldValue: any): void;
onAssetRemoved(asset: any): void;
onSetLoop(name: any, oldValue: any, newValue: any): void;
onSetVolume(name: any, oldValue: any, newValue: any): void;
onSetPitch(name: any, oldValue: any, newValue: any): void;
onSetMaxDistance(name: any, oldValue: any, newValue: any): void;
onSetMinDistance(name: any, oldValue: any, newValue: any): void;
onSetRollOffFactor(name: any, oldValue: any, newValue: any): void;
onSetDistanceModel(name: any, oldValue: any, newValue: any): void;
onSet3d(name: any, oldValue: any, newValue: any): void;
loadAudioSourceAssets(ids: any): void;
}
import { Component } from '../component.js';