I’m looking to enable collisions during camera animations. I saw on this topic (here) that this is not the case for performance reasons.
But I’m using very simple elements (cube and low poly sphere) and I’d like to change the current behavior to enable collisions during animations.
I use collisions to block the camera in some areas (with sliding response effect) and animations for built-in interpolation.
What I have investigated for the moment is that the _getViewMatrix function of my ArcRotateCamera is well executed during animations but no collisions are found.
Could someone give me some hints to accomplish this? Or more important explanations on how collisions are disabled during animations?
So just like the referenced topic says, collisions are not checked for during an animation so there’s currently nothing to enable/disable for collisions, at least as far as I understand. You could use moveWithCollisions inside of the Render Loop to move things, depending on what kind of movements you need to make. I could potentially see using mesh.intersectsMesh and build key frames on the fly for a new animation but that’d be a pretty complex option. At least that’s what I can think of off the top of my head.
Nice. Did you notice anything in terms of performance?
Anyways, I’m gonna bookmark this. Can be very useful so thanks a lot for sharing (and for the thinking) GJ,
I have not observed any impact on performance but I use very simple meshes for these collisions.
In some cases, with concave meshes, we can observe a camera shaking effect.
To limit this, I added the line below in _checkCollisionsAfterward :
if (this._camera.lastCollidedMesh) this._stopCameraShakingIfNeeded();
The _stopCameraShakingIfNeeded function checks if the camera shakes and stops its animations if it does. To determine if the camera is shaking, I check if consecutive collision directions are in the opposite direction.
I can’t spend more time on this right now. But if I find new ideas or solutions, I will add them in this topic.