Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(
this.mapView,
this.camera,
this.mapView.projection.unprojectPoint(centerScreenTarget)
).tilt;
const deltaTilt = tilt - this.m_maxTiltAngle;
if (deltaTilt > 0) {
MapViewUtils.orbitFocusPoint(this.mapView, 0, deltaTilt, this.m_maxTiltAngle);
}
}
}
this.updateMapView();
this.mapView.addEventListener(
MapViewEventNames.AfterRender,
this.assignZoomAfterTouchZoomRender
);
pointToNorth() {
const target = MapViewUtils.rayCastWorldCoordinates(this.mapView, 0, 0);
if (target === null) {
throw new Error("MapView does not support a view pointing in the void.");
}
this.m_startAzimuth =
Math.PI +
MapViewUtils.extractSphericalCoordinatesFromLocation(
this.mapView,
this.camera,
this.mapView.projection.unprojectPoint(target)
).azimuth;
// Wrap between -PI and PI.
this.m_startAzimuth = Math.atan2(
Math.sin(this.m_startAzimuth),
Math.cos(this.m_startAzimuth)
);
if (this.m_startAzimuth === 0) {
return;
}
this.stopExistingAnimations();
this.m_resetNorthAnimationDuration = this.northResetAnimationDuration;
this.m_currentAzimuth = this.m_startAzimuth;
this.m_resetNorthStartTime = performance.now();
private get currentTilt(): number {
const target = MapViewUtils.rayCastWorldCoordinates(this.mapView, 0, 0);
if (target === null) {
throw new Error("MapView does not support a view pointing in the void.");
}
return MapViewUtils.extractSphericalCoordinatesFromLocation(
this.mapView,
this.camera,
this.mapView.projection.unprojectPoint(target)
).tilt;
}