Vousk-prod. Posted February 24, 2015 Share Posted February 24, 2015 Hello,I'm playing with an ArcRotateCamera and collisions and I wonder if I can be informed that collision occurs.I'm simply usingscene.collisionsEnabled = true;camera.checkCollisions = true;myMesh.checkCollisions = true;Works great, but I'd like to be informed when my camera collide with the mesh. Is there a callback system or something ? I didn't find such in the source code.I could eventually use mesh.intersectsPoint() and define my camera position as the checked point, but that won't take the camera's collisionRadius in account. I can aslo create a non visible sphere, parent it to the camera and check for mesh intersecting with this dummy sphere, but that's not so elegant. Is there a direct way to know collision occured ? Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 24, 2015 Share Posted February 24, 2015 You could create a box the size of the camera and use the intersection actions with the meshes you want to check against.Or maybe use this box to check for intersections with specific meshes in the beforeRender loop. Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 24, 2015 Author Share Posted February 24, 2015 But if I have lots of meshes added on the fly, with camera collision system to call newMesh.checkCollisions = true at each spawn is enough to take every required meshes in account, but with mesh intersection system I'll have to check the dummy object intersecting with every mesh at each render loop... wouldn't that drop down performance ? Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 24, 2015 Share Posted February 24, 2015 Just checked - both the FreeCamera and the ArcRotate have an onCollide variable to which you can assign a function:camera.onCollide = function(collidedMesh) { //happy collisions! :-)}That would be much better in terms of performance, that's for sure Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 24, 2015 Author Share Posted February 24, 2015 Oh yes !There is a onCollide called in _getViewMatrix. The variable in not defined in the constructor so I didn't notice it.That's exactly what I was looking for ! Thanks a lot RaananW ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.