I have a problem moving a camera following a plane

Hi There!

'm trying to move an orthographic camera following a plane with forward and backward buttons. It’s already almost functional but I have a problem moving the camera backwards. I don’t know what the problem can be (I’m a bit new in three.js and computer graphics), The backward button does the same than the fordward.

The idea behind this is to clik on lines and poligons, create a plane from them and then set the camera to have a view of perpendicular to the plane created (like a slice). The code is the step zero of that. If you know a better way please guide me.

Here’s the code


If you only change Plane.constant, you can compute the new camera position with Plane.normal. It’s also not necessary to update the projection matrix if you just transform the camera in 3D space.

Thanks Michael so much for the answer…

I have another one if it’s not much trouble.

This new code has a few lines and the same cube with the forward/backward buttons. I have two questions:

  1. Why I only see the faces of the cube and not the contour when I’m looking inside it?
  2. It seems that when I move the camera into the origin something happened with it and it change the orientation (see the gif)

Back faces are not rendered by default. You can change this by setting the side property of the cube’s material to THREE.DoubleSide.

That happens because OrbitControls controls the orientation of the camera. It ensures to always look at the target which is the origin.

Thanks again!

I removed the controls and works :+1:.

Updated code

Also set the side property, but I can’t see the box edges, only in wireframe i can see but a part of it. Maybe the plane is not aligned to the cube?