-
You are generating a ray per frame in your castRay() function. This function creates an helper which in turn generate a mesh (per frame again). So no wonder why it is slow Why are you generating a ray per frame? (scene.registerBeforeRender is called once a frame)
-
You can create a dummy box, attach your box to the bone with mesh.attachToBone and then attach your ray to this dummy box
2 Likes