Skip to main content

<pc-sounds>

The <pc-sounds> tag is used to define a sound component.

Usage

Attributes

AttributeTypeDefaultDescription
distance-modelEnum"linear"Distance attenuation model: "exponential" | "inverse" | "linear"
enabledBoolean"true"Enabled state of the component
max-distanceNumber"10000"Maximum distance for audio falloff
pitchNumber"1"Pitch multiplier for all sounds in this component
positionalBoolean"false"Whether the sound is positional (3D spatial audio)
ref-distanceNumber"1"Reference distance for full volume
roll-off-factorNumber"1"Falloff rate factor for distance attenuation
volumeNumber"1"Master volume for all sounds in this component

Example

<pc-app>
<pc-asset src="assets/audio/music.mp3" id="music"></pc-asset>
<pc-scene>
<pc-entity>
<pc-sounds volume="0.5">
<pc-sound asset="music"></pc-sound>
</pc-sounds>
</pc-entity>
</pc-scene>
</pc-app>

JavaScript Interface

You can programmatically create and manipulate <pc-sounds> elements using the SoundComponentElement API.