API Reference

Class List

pc.AudioSourceComponent

Extends: pc.Component

The AudioSource Component controls playback of an audio sample. This class will be deprecated in favor of pc.SoundComponent.

Summary

Properties

3dIf 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 pc.AudioListenerComponent
activateIf true the audio will begin playing as soon as the Pack is loaded
assetsThe list of audio assets - can also be an array of asset ids.
distanceModelDetermines which algorithm to use to reduce the volume of the audio as it moves away from the listener.
loopIf true the audio will restart when it finishes playing
maxDistanceThe maximum distance from the listener at which audio falloff stops.
minDistanceThe minimum distance from the listener at which audio falloff begins.
pitchThe pitch modifier to play the audio with.
rollOffFactorThe factor used in the falloff equation.
volumeThe volume modifier to play the audio with.

Methods

pausePause playback of the audio that is playing on the Entity.
playBegin playback of an audio asset in the component attached to an entity
stopStop playback on an Entity.
unpauseResume playback of the audio if paused.

Inherited

Properties

enabledEnables or disables the component.

Details

Constructor

AudioSourceComponent(system, entity)

Create a new AudioSource Component

Parameters

systempc.AudioSourceComponentSystemThe ComponentSystem that created this Component
entitypc.EntityThe entity that the Component is attached to

Properties

Boolean3d

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 pc.AudioListenerComponent

Booleanactivate

If true the audio will begin playing as soon as the Pack is loaded

pc.Asset[]assets

The list of audio assets - can also be an array of asset ids.

StringdistanceModel

Determines which algorithm to use to reduce the volume of the audio as it moves away from the listener. Can be one of 'linear', 'inverse' or 'exponential'. Default is 'inverse'.

Booleanloop

If true the audio will restart when it finishes playing

NumbermaxDistance

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

NumberminDistance

The minimum distance from the listener at which audio falloff begins.

Numberpitch

The pitch modifier to play the audio with. Must be larger than 0.01

NumberrollOffFactor

The factor used in the falloff equation.

Numbervolume

The volume modifier to play the audio with. In range 0-1.

Methods

pause()

Pause playback of the audio that is playing on the Entity. Playback can be resumed by calling pc.AudioSourceComponent#unpause

play(name)

Begin playback of an audio asset in the component attached to an entity

Parameters

nameStringThe name of the Asset to play

stop()

Stop playback on an Entity. Playback can not be resumed after being stopped.

unpause()

Resume playback of the audio if paused. Playback is resumed at the time it was paused.

Inherited

Properties

Booleanenabled

Enables or disables the component.