-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Components with dependencies attach extra components to entities even when component of same type is attached. #5536
Comments
Yeah. I don't think dependencies consider multiple components instances. Can you share in what exact context you found the issue? I'm assuming was not with animation. |
I originally found it trying to enable functionality where something like var fooComponents = this.el.components.foo; would return all of the Based on my understanding of the dependencies documentation I did not expect it to attach an extra instance to the entity; and I would expect that the dependency requirement is satisfied even if an ID is specified. I assumed that it would throw an error or a warning if the component is not attached, not that it would automatically attach one. This behavior probably provides a lot of convienience in a lot of situations, but if you're not expecting it (i.e., it's not documented) it might cause some confusion; but it only seems to add an extra instance when you have an instance attached using an ID and it doesn't recognize it. The multiple documentation gives the following example <a-scene>
<a-entity
sound="src: url(sound.mp3)"
sound__beep="src: url(beep.mp3)"
sound__boop="src: url(boop.mp3)"
></a-entity>
</a-scene> which correctly avoids adding an extra sound component. I do think it's useful when having multiple component instances on an entity for them to all have unique IDs to keep them better organized. In that case I would have something more like: <a-scene>
<a-entity
sound__beep="src: url(beep.mp3)"
sound__boop="src: url(boop.mp3)"
sound__blop="src: url(blop.mp3)"
></a-entity>
</a-scene> |
I was thinking about this a little more, and I think the other side of this is that if you have multiple components of the same type attached and that component type is specified in the dependencies that only the component without the IDs get loaded in the specified order. For example if you had a component with: dependencies: [ "sound", "animation" ] and the following scene: <a-scene>
<a-entity
animation
sound="src: url(sound.mp3)"
sound__beep="src: url(beep.mp3)"
sound__boop="src: url(boop.mp3)"
foo
animation__1
></a-entity>
</a-scene> I think the order the components will load is I would expect it to load all of the If we change it up a little further like: <a-scene>
<a-entity
foo
animation__0
sound__beep="src: url(beep.mp3)"
sound__boop="src: url(boop.mp3)"
sound__blop="src: url(blop.mp3"
animation__1
></a-entity>
</a-scene> I think that same component with the In fairness, there's nothing in the documentation that explicitly supports my assumptions. But I think the mental model is much clearer if it takes IDs into account. |
Description:
A-Frame components with dependencies add additional components to entities even when that type of component is already attached to the entity. It appears that the extra attachment happens when the entity has the component using an ID (e.g.,
foo__1
) but does not have an attached component using just the base component name (e.g.,foo
).Expected: Components using the ID should be recognized as satifying the dependency so that extra components are not attached.
Note: The animation component is used as an example, but the same thing happens with other components.
Test scene:
Resulting console output demonstrating extra animation component attached:
The text was updated successfully, but these errors were encountered: