geometry primitive undefined so fallback to box
See original GitHub issueDescription:
- A-Frame Version: 0.9.0
- Platform / Device: Chrome on desktop
- Reproducible Code Snippet or URL:
I have simple code that do
const plane = document.createElement("a-plane");
plane.setAttribute("height", 0.196);
plane.setAttribute("width", 0.196);
AFRAME.scenes[0].appendChild(plane)
initially it shows a plane, now if I remove the plane element AFRAME.scenes[0].removeChild(plane)
and recreate it, it will take an object from the pool and it will sometime show a box instead of a plane. Somehow I get “primitive: undefined” in the object.
Putting a console.log(this.attrValue, this.data)
in src/core/component.js
initComponent
, I get initially
attrValue: {width: "0.196", height: "0.196", primitive: "plane"}
data: {
buffer: true
height: 0.196
primitive: "plane"
segmentsHeight: 1
segmentsWidth: 1
skipCache: false
width: 0.196
}
and if it take an existing object from the pool (when I remove plane and recreate it), I can get this:
attrValue: {width: "0.196", height: "0.196", primitive: undefined}
or attrValue: {height: "0.196", width: "0.196", primitive: undefined, buffer: undefined, skipCache: undefined, …}
data: {
buffer: true
depth: 1
height: 0.196
primitive: "box"
segmentsDepth: 1
segmentsHeight: 1
segmentsWidth: 1
skipCache: false
width: 0.196
}
and other time:
{radius: undefined, width: 0.196, height: 0.196, primitive: "plane", buffer: true, …}
triggering a warning:
core:schema:warn Unknown property radius
for component/system geometry
. see #4012 for this one.
Now If I change the implementation of clearObject
to delete the keys:
for (key in obj) { delete obj[key]; }
all the issues goes away.
The issue comes from the commit https://github.com/aframevr/aframe/commit/6deaea0564d18c91b94d801db0e39535b094f044 from the component.js file. I tested master with the component.js file before this commit and I don’t have the issue. The PR #4016 doesn’t fix the issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top GitHub Comments
workaround: If you set geometry attribute manually, it fixes this error.
After creating your a-plane, do this:
plane.setAttribute('geometry', 'primitive: plane')
Thanks @ngokevin ! Your changes indeed fix the issue.