UNPKG

s2maps-gpu

Version:

S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.

91 lines (90 loc) 2.68 kB
import type { Projector, TileInView } from './projector/index.js'; /** Easing function */ export type Easing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out'; /** Animation directions object */ export interface AnimationDirections { lon?: number; lat?: number; zoom?: number; bearing?: number; pitch?: number; speed?: number; duration?: number; easing?: Easing; } /** Animation type */ export type AnimationType = 'easeTo' | 'flyTo'; /** Increment State Response */ export type IncrementResponse = [ finished: boolean, [ lon: number, lat: number, zoom: number, bearing: number, pitch: number ] ]; /** * Animator class handles user defined animations of the camera. */ export default class Animator { #private; startTime?: number; startLon: number; startLat: number; startZoom: number; startBearing: number; startPitch: number; endLon: number; endLat: number; endZoom: number; endBearing: number; endPitch: number; deltaLon: number; deltaLat: number; deltaZoom: number; deltaBearing: number; deltaPitch: number; speed: number; duration: number; velocity: number; futureOffset: number; futureTiles: Map<number, TileInView[]>; futureKeys: number[]; ease: (time: number, start: number, delta: number, duration: number) => number; projector: Projector; /** * @param projector - projection state * @param directions - Animation directions guide */ constructor(projector: Projector, directions?: AnimationDirections); /** * Updates the position based upon time. returns whether complete or not. * @param time - current time * @returns - true if the animation was built successfully */ increment(time: number): boolean; /** Handles zoom animations. */ zoomTo(): void; /** Handles rotation animations. */ compassTo(): void; /** * Handles swiping animations. * @param movementX - swipe change in the x direction * @param movementY - swipe change in the y direction */ swipeTo(movementX: number, movementY: number): void; /** * Handles easing mechanic * @returns - true if the animation was built successfully */ easeTo(): boolean; /** * Handles flying animation with both panning and zooming combined. * Van Wijk, Jarke J.; Nuij, Wim A. A. “Smooth and efficient zooming and panning.” INFOVIS * ’03. pp. 15–22. <https://www.win.tue.nl/~vanwijk/zoompan.pdf#page=5>. * @returns true if a flyTo animation is built successfully */ flyTo(): boolean; }