@tolokoban/tgd
Version:
ToloGameDev library for WebGL2
176 lines • 5.55 kB
TypeScript
import { TgdCamera, TgdCameraState } from "../../camera";
import { TgdContext } from "../../context";
import { TgdEvent } from "../../event";
import { TgdInputPointerModifierKeys } from "../../types";
export interface TgdControllerCameraOrbitZoomRequest extends TgdInputPointerModifierKeys {
x: number;
y: number;
/**
* The computed zoom, if accepted.
*/
zoom: number;
}
export interface TgdControllerCameraOrbitOptions {
name?: string;
zoom: number;
minZoom: number;
maxZoom: number;
speedOrbit: number;
/**
* Number of seconds for the zoom to go
* from 1 to 2, or from 1 to 0.5.
*/
speedZoom: number;
speedPanning: number;
/**
* Time in msec during which the orbiting continues
* after the pointer stop touching.
*/
inertiaOrbit: number;
/**
* Time in msec during which the zooming continues
* after the pointer stop touching.
*
* Default to 0.
*/
inertiaZoom: number;
/**
* Time in msec during which the panning continues
* after the pointer stop touching.
*
* Default to 0.
*/
inertiaPanning: number;
/**
* If `true`, pannig will only act on `camera.shift`,
* not on `camera.target`.
*
* Default to 0.
*/
fixedTarget: boolean;
/**
* Zooming can be done by the mouse wheel.
* In this case, we may want to prevent it when the
* canvas is not in fullscreen, to let the rest of
* the page to scroll.
*
* This function, if defined, will be called just
* before the zoom event. If it returns `false`,
* the event is not dispatched.
*/
onZoomRequest(this: void, event: TgdControllerCameraOrbitZoomRequest): boolean;
/**
* If this attribute is defined, the orbit will follow latitude/longitude.
* You can also add limits.
*/
geo: Partial<{
/** Expressed in radians */
lat: number;
/** Expressed in radians */
lng: number;
/** Expressed in radians */
minLat: number;
/** Expressed in radians */
maxLat: number;
/** Expressed in radians */
maxLng: number;
/** Expressed in radians */
minLng: number;
}>;
/**
* The position where the `reset()` method will bring you.
* If undefined, the context camera state will be used.
*/
cameraInitialState?: Readonly<Partial<TgdCameraState>>;
/**
* If `debug` is set, the special hotkey `?` will drop the
* current camera status to the console.
*/
debug?: boolean;
}
export declare class TgdControllerCameraOrbit {
private static ID;
readonly name: string;
readonly id: string;
readonly eventChange: TgdEvent<TgdCamera>;
readonly debug: boolean;
minZoom: number;
maxZoom: number;
speedZoom: number;
speedOrbit: number;
speedPanning: number;
inertiaZoom: number;
inertiaOrbit: number;
inertiaPanning: number;
/**
* If `true`, pannig will only act on `camera.shift`,
* not on `camera.target`.
*/
fixedTarget: boolean;
cameraInitialState: Readonly<TgdCameraState>;
/**
* Zooming can be done by the mouse wheel.
* In this case, we may want to prevent it when the
* canvas is not in fullscreen, to let the rest of
* the page to scroll.
*
* This function, if defined, will be called just
* before the zoom event. If it returns `false`,
* the event is not dispatched.
*/
onZoomRequest: (this: void, event: TgdControllerCameraOrbitZoomRequest) => boolean;
/**
* The camera will only move if `enabled === true`.
*/
private _enabled;
private animGestureInertia;
/**
* This is the space height at target for zoom == 1.0
*
* @see resetZoom()
*/
private spaceHeightAtTargetForZoom1;
/**
* It can be usefull to disable to orbit controller for some time
* because an animation is going on on the camera, for instance.
*/
private disabledUntil;
private readonly geo?;
private readonly tmpQuat;
private lastPointerEventTimestamp;
private _context;
private currentGesture;
constructor(context: TgdContext, { name, geo, zoom, minZoom, maxZoom, speedZoom, speedOrbit, speedPanning, inertiaZoom, inertiaOrbit, inertiaPanning, fixedTarget, debug, onZoomRequest, cameraInitialState, }?: Partial<TgdControllerCameraOrbitOptions>);
get context(): TgdContext;
set context(context: TgdContext);
get zoom(): number;
set zoom(value: number);
get enabled(): boolean;
set enabled(value: boolean);
reset(animDuration: number, { easingFunction, onEnd, onAction, delay, }?: {
easingFunction?: (x: number) => number;
onAction?: (t: number) => void;
onEnd?: () => void;
delay?: number;
}): void;
disableForSomeTime(delayInMsec: number): void;
detach(): void;
private readonly handleMove;
private readonly actualMove;
private orbit;
/**
* Set the camera orientation from latitude/longitude
* @param lat Expressed in radians
* @param lng Expressed in radians
*/
orbitGeo(lat: number, lng: number): void;
private readonly handleMoveStart;
private readonly handleMoveEnd;
private handlePan;
private handleRotateAroundZ;
private fireOrbitChange;
private readonly handleZoom;
private fireZoomChange;
private readonly handleDebug;
}
//# sourceMappingURL=orbit.d.ts.map