In regards to A-Frame's <a-sound> component, why does switching the "positional" property to false only work when used within an <a-entity>?

Viewed 13

In regards to A-Frame's <a-sound> component, why does switching the "positional" property to false only work when used within an <a-entity>?

I'm making a VR webpage to show off my resume in a flashy and theatrical way and am using the sound component to make a "world audio track" (I don't know any of the correct the technical terms) upon which I can play some music and/or play sounds that need to be heard across the whole scene.

I've found that this can only be accomplished by applying a sound to an entity. It isn't a big deal, it's just a matter of tossing all the sound properties into the entity object.

Here is my question though: Is it intentional that this only works with entities, or is it some bug or something that they intend to fix? Now that I think about it, a lot of the other properties like rolloffFactor and maxDistance didn't seem to do much. Am I just getting something wrong when I call the sound component?

Here is an example.

This is what works:

    <a-entity id="worldspacemusic" sound="src:Sounds/RobotWaitingRoom4.mp3; autoplay:true; loop:true; volume:0.1; positional:false;"></a-entity>

And this does not work:

    <a-sound id="music" src="Sounds/RobotWaitingRoom4.mp3" autoplay="true" loop="true" volume="0.25" positional="false"></a-sound>

It's not that big of a deal, it just kinda bugs me that for this singular reason I have to make a whole bunch of my sound elements into entities. It's probably better form to make entities rather than a bunch of sound objects as it'd likely open up a lot more in terms of other non-audio related properties, but still- it bothers me. I'm mostly looking for an explanation since I was easily able to resolve the issue.

1 Answers

As per docs syntax should be:

<a-sound id="music" src="src: url(Sounds/RobotWaitingRoom4.mp3)" autoplay="true" loop="true" volume="0.25" positional="false"></a-sound>

In general I recommend using <a-entity> over primitives. More clarity (one less layer of abstraction) and consistency.

Related