supermedium / superframe

:package: A super collection of A-Frame components.
https://supermedium.com/superframe/
MIT License
1.37k stars 423 forks source link

[aabb-collider] Be sure parent matrixWorld is up to date before calculating the static box #307

Closed vincentfretin closed 1 year ago

vincentfretin commented 1 year ago

Calculating the static box that is only done once may be wrong if parent matrixWorld wasn't up to date. Calling el.object3D.updateWorldMatrix(true, false); before setFromObject fixes the issue. Please note that el.object3D.updateWorldMatrix(false, false); is executed for the a-sphere and children already in the setFromObject function.

For example if you put a a-sphere as a child of a a-entity:

<a-entity position="3 0 0">
  <a-sphere radius="1" class="collidable"></a-sphere>
</a-entity>
<a-entity hand-controls="right" aabb-collider="objects: .collidable"></a-entity>

Without the fix, box.max will be 1 1 1. With the fix it will be properly of 4 1 1.

dmarcos commented 1 year ago

Thanks!