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.

137 lines (136 loc) 6.25 kB
import { GeospatialCameraInputsManager } from "./geospatialCameraInputsManager.js"; import { Vector3, Matrix } from "../Maths/math.vector.js"; import { Camera } from "./camera.js"; import type { Scene } from "../scene.js"; import type { MeshPredicate } from "../Culling/ray.core.js"; import { GeospatialLimits } from "./Limits/geospatialLimits.js"; import { GeospatialCameraMovement } from "./geospatialCameraMovement.js"; import type { IVector3Like } from "../Maths/math.like.js"; import type { EasingFunction } from "../Animations/easing.js"; type CameraOptions = { planetRadius: number; }; /** * @experimental * This camera's movements are limited to a camera orbiting a globe, and as the API evolves it will introduce conversions between cartesian coordinates and true lat/long/alt * * Please note this is marked as experimental and the API (including the constructor!) will change until we remove that flag */ export declare class GeospatialCamera extends Camera { inputs: GeospatialCameraInputsManager; /** If supplied, will be used when picking the globe */ pickPredicate?: MeshPredicate; /** Movement controller that turns input pixelDeltas into currentFrameDeltas used by camera*/ readonly movement: GeospatialCameraMovement; private _tempPosition; private _tempCenter; private _viewMatrix; private _isViewMatrixDirty; private _lookAtVector; /** Behavior used for smooth flying animations */ private _flyingBehavior; private _flyToTargets; constructor(name: string, scene: Scene, options: CameraOptions, pickPredicate?: MeshPredicate); private _center; /** The point on the globe that we are anchoring around. If no alternate rotation point is supplied, this will represent the center of screen*/ get center(): Vector3; /** * Sets the camera position to orbit around a new center point * @param center The world position (ECEF) to orbit around */ set center(center: IVector3Like); private _yaw; /** * Gets the camera's yaw (rotation around the geocentric normal) in radians */ get yaw(): number; /** * Sets the camera's yaw (rotation around the geocentric normal). Will wrap value to [-π, π) * @param yaw The desired yaw angle in radians (0 = north, π/2 = east) */ set yaw(yaw: number); private _pitch; /** * Gets the camera's pitch (angle from looking straight at globe) * Pitch is measured from looking straight down at planet center: * - zero pitch = looking straight at planet center (down) * - positive pitch = tilting up away from planet * - π/2 pitch = looking at horizon (perpendicular to geocentric normal) */ get pitch(): number; /** * Sets the camera's pitch (angle from looking straight at globe). Will wrap value to [-π, π) * @param pitch The desired pitch angle in radians (0 = looking at planet center, π/2 = looking at horizon) */ set pitch(pitch: number); private _radius; get radius(): number; /** * Sets the camera's distance from the current center point * @param radius The desired radius */ set radius(radius: number); protected _checkLimits(): void; private _tempVect; private _tempEast; private _tempNorth; private _tempUp; private _setOrientation; /** The point around which the camera will geocentrically rotate. Uses center (pt we are anchored to) if no alternateRotationPt is defined */ private get _geocentricRotationPt(); /** * If camera is actively in flight, will update the target properties and use up the remaining duration from original flyTo call * * To start a new flyTo curve entirely, call into flyToAsync again (it will stop the inflight animation) * @param targetYaw * @param targetPitch * @param targetRadius * @param targetCenter */ updateFlyToDestination(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3): void; /** * Animate camera towards passed in property values. If undefined, will use current value * @param targetYaw * @param targetPitch * @param targetRadius * @param targetCenter * @param flightDurationMs * @param easingFunction * @param centerHopScale If supplied, will define the parabolic hop height scale for center animation to create a "bounce" effect * @returns Promise that will return when the animation is complete (or interuppted by pointer input) */ flyToAsync(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3, flightDurationMs?: number, easingFunction?: EasingFunction, centerHopScale?: number): Promise<void>; /** * Helper function to move camera towards a given point by radiusScale% of radius (by default 50%) * @param destination point to move towards * @param radiusScale value between 0 and 1, % of radius to move * @param durationMs duration of flight, default 1s * @param easingFn optional easing function for flight interpolation of properties * @param overshootRadiusScale optional scale to apply to the current radius to achieve a 'hop' animation */ flyToPointAsync(destination: Vector3, radiusScale?: number, durationMs?: number, easingFn?: EasingFunction, overshootRadiusScale?: number): Promise<void>; private _limits; get limits(): GeospatialLimits; private _resetToDefault; /** @internal */ _getViewMatrix(): Matrix; /** @internal */ _isSynchronizedViewMatrix(): boolean; private _applyGeocentricTranslation; /** * This rotation keeps the camera oriented towards the globe as it orbits around it. This is different from cameraCentricRotation which is when the camera rotates around its own axis */ private _applyGeocentricRotation; private _getCenterAndRadiusFromZoomToPoint; /** * Apply zoom by moving the camera toward/away from a target point. */ private _applyZoom; private _zoomToPoint; private _zoomAlongLookAt; _checkInputs(): void; private _recalculateCenter; attachControl(noPreventDefault?: boolean): void; detachControl(): void; } export {};