-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CameraTransition: Improve transition capabilities #932
Milestone
Comments
When calculating the top down orientation of the ortho camera, ensure the same screen space position of the pivot point. Though calculating the top-orientation of the offset position in that case is not necessarily trivial. Requiring a centered position is easiest. |
if ( ! manager.animating ) {
// Force the fixed point to be in the camera center
raycaster.ray.direction.set( 0, 0, - 1 ).transformDirection( manager.camera.matrixWorld );
raycaster.ray.origin.setFromMatrixPosition( manager.camera.matrixWorld );
const hit = raycaster.intersectObject( scene )[ 0 ];
if ( hit ) {
manager.fixedPoint.copy( hit.point );
manager.syncCameras();
} else {
controls.getPivotPoint( manager.fixedPoint );
manager.syncCameras();
}
if ( targetCamera.isOrthographicCamera ) {
targetCamera.updateMatrixWorld();
downVector.set( 0, - 1, 0 );
// transition the camera view to the top down while retaining same general pointing direction
const angle = downVector.angleTo( raycaster.ray.direction );
axis.crossVectors( downVector, raycaster.ray.direction );
quat.setFromAxisAngle( axis, - angle ).normalize() ;
makeRotateAroundPoint( manager.fixedPoint, quat, matrix );
targetCamera.matrixWorld.premultiply( matrix );
targetCamera.matrixWorld.decompose(
targetCamera.position,
targetCamera.quaternion,
targetCamera.scale,
);
} else {
targetCamera.updateMatrixWorld();
downVector.set( 0, - 1, 0 );
// tilt the perspective down slightly
let angle = downVector.angleTo( raycaster.ray.direction );
angle = Math.max( 65 * MathUtils.DEG2RAD - angle, 0 );
axis.set( 1, 0, 0 ).transformDirection( targetCamera.matrixWorld );
quat.setFromAxisAngle( axis, angle ).normalize() ;
makeRotateAroundPoint( manager.fixedPoint, quat, matrix );
targetCamera.matrixWorld.premultiply( matrix );
targetCamera.matrixWorld.decompose(
targetCamera.position,
targetCamera.quaternion,
targetCamera.scale,
);
}
}
controls.adjustCamera( manager.perspectiveCamera );
controls.adjustCamera( manager.orthographicCamera ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: