UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

89 lines 2.93 kB
import { Epsilon } from "../../Maths/math.constants.js"; /** * Limits for geospatial cameras with altitude/radius synchronization */ export class GeospatialLimits { /** * @param planetRadius The radius of the planet (used for altitude/radius conversions) */ constructor(planetRadius) { this._altitudeMin = Epsilon; this._radiusMin = Epsilon; this._radiusMax = Infinity; /** Gets the minimum pitch angle (angle from horizon) -- 0 means looking straight down at planet */ this.pitchMin = Epsilon; /** Gets the maximum pitch angle (angle from horizon) -- Pi/1 means looking at horizon */ this.pitchMax = Math.PI / 2; /** Gets the minimum yaw angle (rotation around up axis) */ this.yawMin = -Infinity; /** Gets the maximum yaw angle (rotation around up axis) */ this.yawMax = Infinity; /** * Defines the distance used to consider the camera in pan mode vs pinch/zoom. * Basically if your fingers moves away from more than this distance you will be considered * in pinch mode. */ this.pinchToPanMax = 20; this._planetRadius = planetRadius; } /** * Gets the minimum altitude (height above planet surface) */ get altitudeMin() { return this._altitudeMin; } /** * Sets the minimum altitude and syncs it with radius */ set altitudeMin(value) { this._altitudeMin = value; this._radiusMin = this._planetRadius + value; } /** * Gets the maximum altitude (height above planet surface) */ get altitudeMax() { return this._altitudeMax; } /** * Sets the maximum altitude and syncs it with radius */ set altitudeMax(value) { this._altitudeMax = value; this._radiusMax = this._planetRadius + value; } get radiusMin() { return this._radiusMin; } /** * Sets the minimum radius and syncs it with altitude */ set radiusMin(value) { this._radiusMin = value; this._altitudeMin = value - this._planetRadius; } get radiusMax() { return this._radiusMax; } /** * Sets the maximum radius and syncs it with altitude */ set radiusMax(value) { this._radiusMax = value; this._altitudeMax = value - this._planetRadius; } /** * Gets the planet radius used for altitude/radius conversions */ get planetRadius() { return this._planetRadius; } /** Sets the planet radius and updates the radius limits to maintain current altitude */ set planetRadius(value) { this._planetRadius = value; // Update radius limits to maintain current altitude this._radiusMin = value + this._altitudeMin; this._radiusMax = value + this._altitudeMax; } } //# sourceMappingURL=geospatialLimits.js.map