Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.m_currentViewDirection.multiplyScalar(amount);
if (this.mapView.projection.type === geoUtils.ProjectionType.Planar) {
this.camera.position.z += this.m_currentViewDirection.z;
this.camera.position.z = Math.max(
minDistance,
Math.min(maxDistance, this.camera.position.z)
);
} else if (this.mapView.projection.type === geoUtils.ProjectionType.Spherical) {
const zOnVertical =
Math.cos(this.camera.position.angleTo(this.m_currentViewDirection)) *
this.m_currentViewDirection.length();
this.camera.position.setLength(
Math.max(
minDistance + geoUtils.EarthConstants.EQUATORIAL_RADIUS,
Math.min(
maxDistance + geoUtils.EarthConstants.EQUATORIAL_RADIUS,
this.camera.position.length() + zOnVertical
)
)
);
}
// In sphere, we may have to also orbit the camera around the position located at the
// center of the screen, in order to limit the tilt to `maxTiltAngle`, as we change
// this tilt by changing the camera's height above.
if (
this.mapView.projection.type === geoUtils.ProjectionType.Spherical &&
this.m_maxTiltAngle !== undefined
) {
const centerScreenTarget = MapViewUtils.rayCastWorldCoordinates(this.mapView, 0, 0);
if (centerScreenTarget !== null) {
const tilt = MapViewUtils.extractSphericalCoordinatesFromLocation(