Components with dependencies attach extra components to entities even when component of same type is attached.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 17.6k
- Forks
- 4.4k
- PR merge metrics
- No merged PRs in 30d
Description
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.
- A-Frame Version: 1.0.0-1.6.0
- Platform / Device: Windows / Chromium Browsers
- Reproducible Code Snippet or URL: Glitch | aframe-extra-component-attach
Test scene:
<html>
<head>
<script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script>
<script>
AFRAME.registerComponent("test-component-with-dependency", {
dependencies: ["animation"],
init: function () {
console.log("components:", this.el.id, this.el.components);
},
});
</script>
<script>
AFRAME.registerComponent("test-component-without-dependency", {
init: function () {
console.log("components:", this.el.id, this.el.components);
},
});
</script>
</head>
<body>
<!-- Will attach additional animation component to entity even though
animation components are already attached. -->
<a-entity
id="with-dependency"
test-component-with-dependency
animation__0
animation__1
></a-entity>
<!-- Will not attach additional animation component to entity. -->
<a-entity
id="without-dependency"
test-component-without-dependency
animation__0
animation__1
></a-entity>
<a-scene>
<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
<a-cylinder
position="1 0.75 -3"
radius="0.5"
height="1.5"
color="#FFC65D"
></a-cylinder>
<a-plane
position="0 0 -4"
rotation="-90 0 0"
width="4"
height="4"
color="#7BC8A4"
></a-plane>
<a-sky color="#ECECEC"></a-sky>
</a-scene>
</body>
</html>
Resulting console output demonstrating extra animation component attached:
components: with-dependency
Object
animation: n {el: a-entity#with-dependency, id: undefined, attrName: 'animation', evtDetail: {…}, initialized: true, …}
animation__0: n {el: a-entity#with-dependency, id: '0', attrName: 'animation__0', evtDetail: {…}, initialized: true, …}
animation__1: n {el: a-entity#with-dependency, id: '1', attrName: 'animation__1', evtDetail: {…}, initialized: true, …}
test-component-with-dependency: n {el: a-entity#with-dependency, id: undefined, attrName: 'test-component-with-dependency', evtDetail: {…}, initialized: true, …}
[[Prototype]]: Object
components: without-dependency
Object
animation__0: n {el: a-entity#without-dependency, id: '0', attrName: 'animation__0', evtDetail: {…}, initialized: true, …}
animation__1: n {el: a-entity#without-dependency, id: '1', attrName: 'animation__1', evtDetail: {…}, initialized: true, …}
test-component-without-dependency: n {el: a-entity#without-dependency, id: undefined, attrName: 'test-component-without-dependency', evtDetail: {…}, initialized: true, …}
[[Prototype]]: Object
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Glitch reproduction and the test scene showing animation__0 and animation__1 alongside a dependency on animation. Trace A-Frame's component dependency attachment path and verify that ID-suffixed components satisfy the dependency without adding an unsuffixed component. Done when the reproduced entity no longer receives the extra animation component and existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100