Hey, i have a question. Why do I need to call app.removeChild(renderer) and app.addChild(renderer) in Update everytime i change the values of my vertices to have proper BoundingBoxes. .
I thought mesh.update() should do the work.
BoundingBoxTest.prototype.update = function (dt) {
Hmm, it maybe that the MeshInstance using that Mesh may be caching the aabb for performance reasons.
A bounding box is in world units, and even though the mesh has its own, each mesh instance based on its node/entity world position has a different bounding box.
No need to remove/add the child, you can just update the mesh instance aabb. @mvaligursky is there an official way of forcing a mesh instance to do that?
Agreed with Lexxik, the boundingBox of the mesh is getting updated properly, but the boundingBox of the MeshInstance does not update and i think the frustum Culling of an camera is using the meshInstance BoundingBox.
I try to explain my project. I am trying to create an VR Framework for my company and i am casting an Arc out of an Controller. The arc is only displayed when i look at the ground (0,0,0) because the boundingBox of my MeshInstance of the Arc is not getting updated.
If i disable frustum Culling and render everything it works properly. But i want to enable frustum Culling of course, so if i enable frustumCulling and use removeChild and addChild the meshInstance boundingBox is getting updated and my ray is displayed properly and i have no problems.
I hope my thesis make sense and thank you for your fast replies.
Yes, that makes sense. I would probably do it using a custom AABB. When you set a custom AABB on a render component, it will be assigned to the mesh instance. The default AABB would not be used. Then you could do something like:
put a breakpoint in MeshInstance.get aabb to see what happens there for your mesh. Hack something on your mesh, say mesh.hack = true; and set up conditional breakpoint for this, you should see if the world space aabb gets updated there correctly.