I have an issue with the camera component. You can see the issue in the clip:
You may notice the black screen appearing at the bottom. After some debugging, I found that it was because the viewMatrix has changed, and as a result affected the camera frustum:
vs
I would like to know what actions may affect the camera viewMatrix? I think the only thing I do with the camera is move it by .setPosition().
Well, I do re-use the Vec3 position, which holds the new camera position:
this.targetPosition = CameraHandler._p2; // re-use Vec3
this.targetPosition.copy(cameraPos).add(temp); // calc new position
this.camera.setPosition(this.targetPosition); // set camera to new pos
Nope, the orthographic camera is in the root as a standalone entity. It is not attached to anything. So, you guys think this might come from scaling? The only things I scale are the platform meshes. I will look into it to make sure the camera doesn’t use any scale objects from there, but it shouldn’t.
I think what might happen is that the ground plane goes into the near plane of the camera frustum. However, I would think that if the camera moves back, the frustum should include the previously cut parts? I will play with this a bit more.
Got it. The issue was with the current camera position height vs the new position height. I find the new position by casting the ray. That ray could hit an existing platform, which made the ground level elevated. That affected the math responsible for calculating the new camera position. The orthographic camera didn’t show the change in height, but switching it to perspective immediately showed the camera gradually moving towards the ground. As a result, the ground plane got inside the near plane of the frustum, effectively getting cut. Ignoring the height of the possible obstacle on the ground solved it by keeping the camera at the same distance from the ground.