1

I write an algorithm that can explode (fold and unfold) mechanical set by double clicking on then.

But i want to move the camera backward or forward after that to see all my objects in the fov. I'm trying to use frustum to calculate intersection between frustum and objects, but i don't undestand how to use planes. I'm working with OrthographicCamera.

What i do :

  1. At every frame i recalculate the new frustum (when camera move):

    projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
    frustum.setFromMatrix(projScreenMatrix);
    
  2. Then i do a loop over the 6 planes and bounding box of all objects in the scene :

    for (var i = 0; i < planes.length; i++) {
            var plane = planes[i];
            for (var j = 0; j < boxs.length; j++) {
                var box = boxs[j];
                var line = new THREE.Line3(box.min, nox.max);
                //console.log({'plane': plane, 'line': line});
                if (plane.isIntersectionLine(line))
                    // move camera
            };
    };
    

but plane.isIntersectionLine(line) is always false.

Do you have any ideas ?

Thanks

  • this post explains it all: http://stackoverflow.com/questions/14614252/how-to-fit-camera-to-object – gaitat Jun 04 '15 at 15:16
  • thank you, that help me found a solution. Know i have the the zoom in, i have to do the zoom out. – Guillaume Dauster Jun 09 '15 at 07:23
  • Voting to close as duplicate of [How to Fit Camera to Object](https://stackoverflow.com/questions/14614252/how-to-fit-camera-to-object) – Ivan Jan 02 '21 at 15:24

0 Answers0