[aabb-collider] data-aabb-collider-dynamic attribute not working without any value
marlon360 opened this issue · 3 comments
If you set the attribute data-aabb-collider-dynamic
on the target, it is not recognized as dynamic.
Solution:
Write any value to the attribute.
<a-entity data-aabb-collider-dynamic="true">
Reason for that behavior:
el.dataset.aabbColliderDynamic
equals ''
which is equal to false
.
Therefor this if-statement is false, when the attribute is added without any value.
// Dynamic, recalculate each tick.
if (el.dataset.aabbColliderDynamic) {
// Box.
boundingBox.setFromObject(el.object3D);
box = boundingBox;
...
Solution to support the attribute without any value:
Check against null
:
// Dynamic, recalculate each tick.
if (el.dataset.aabbColliderDynamic != null) {
// Box.
boundingBox.setFromObject(el.object3D);
box = boundingBox;
...
When the data-aabb-collider-dynamic
is absent, el.dataset.aabbColliderDynamic
is undefined
, indeed el.dataset.aabbColliderDynamic != null
is ok, but be careful el.dataset.aabbColliderDynamic !== null
is not.
Better fix should probably be el.dataset.aabbColliderDynamic !== undefined
and you need to replace the second condition if (!el.dataset.aabbColliderDynamic)
by if (el.dataset.aabbColliderDynamic === undefined)
otherwise box variable will be overridden anyway.
I created #308 with the fix.