@ue-too/board
Version:
208 lines (207 loc) • 7.15 kB
TypeScript
import { PanHandlerConfig } from "./pan-handler";
import { ZoomHandlerConfig } from "./zoom-handler";
import type { RotationHandlerConfig } from "./rotation-handler";
import { ObservableBoardCamera } from "../interface";
import { PanContext } from "../camera-mux/animation-and-lock/pan-control-state-machine";
import { ZoomContext } from "../camera-mux/animation-and-lock/zoom-control-state-machine";
import { Point } from "@ue-too/math";
import { RotateContext } from "../camera-mux/animation-and-lock/rotation-control-state-machine";
/**
* @description The config for the camera rig.
* Camera rig combines pan, zoom and rotation handlers.
*
* @category Input Flow Control
*/
export type CameraRigConfig = PanHandlerConfig & ZoomHandlerConfig & RotationHandlerConfig;
export interface CameraRig extends PanContext, ZoomContext, RotateContext {
camera: ObservableBoardCamera;
config: CameraRigConfig;
configure(config: Partial<CameraRigConfig>): void;
update(): void;
}
/**
* @description The camera rig.
*
* This is a consolidated handler function for pan, zoom and rotation.
* Essentially, it is a controller that controls the camera, so you don't have to figure out some of the math that is involved in panning, zooming and rotating the camera.
*
* @category Camera
*/
export declare class CameraRigWithUpdateBatcher implements CameraRig {
private _panBy;
private _panTo;
private _zoomTo;
private _zoomBy;
private _rotateBy;
private _rotateTo;
private _config;
private _camera;
private _positionBatcher;
private _zoomBatcher;
private _rotationBatcher;
constructor(config: PanHandlerConfig & ZoomHandlerConfig, camera?: ObservableBoardCamera);
/**
* @description Zoom to a certain zoom level at a certain point. The point is in the viewport coordinate system.
*/
zoomToAt(targetZoom: number, at: Point): void;
/**
* @description Zoom by a certain amount at a certain point. The point is in the viewport coordinate system.
*/
zoomByAt(delta: number, at: Point): void;
/**
* @description Zoom to a certain zoom level with respect to the center of the viewport.
*/
zoomTo(targetZoom: number): void;
/**
* @description Zoom by a certain amount with respect to the center of the viewport.
*/
zoomBy(delta: number): void;
/**
* @description Zoom to a certain zoom level with respect to a point in the world coordinate system.
*/
zoomToAtWorld(targetZoom: number, at: Point): void;
/**
* @description Zoom by a certain amount with respect to a point in the world coordinate system.
*/
zoomByAtWorld(delta: number, at: Point): void;
/**
* @description Pan to a certain point. (target is in the world coordinate system)
*/
private _actualPanByWorld;
/**
* @description Pan to a certain point. (target is in the world coordinate system)
*/
private _actualPanToWorld;
panByWorld(delta: Point): void;
panByViewPort(delta: Point): void;
panToWorld(target: Point): void;
panToViewPort(target: Point): void;
/**
* @description Rotate by a certain amount.
*/
rotateBy(delta: number): void;
/**
* @description Rotate to a certain angle.
*/
rotateTo(target: number): void;
set limitEntireViewPort(limit: boolean);
/**
* @description Whether the entire view port is limited.
*/
get limitEntireViewPort(): boolean;
get camera(): ObservableBoardCamera;
get config(): CameraRigConfig;
set config(config: CameraRigConfig);
updatePosition(): void;
updateZoom(): void;
updateRotation(): void;
update(): void;
private _zoomToAtViewPort;
private _zoomToAtWorld;
private _zoomByAtViewPort;
private _zoomByAtWorld;
/**
* @description Configure the camera rig.
*/
configure(config: Partial<CameraRigConfig>): void;
/**
* @description Cleanup the camera rig.
*/
cleanup(): void;
/**
* @description Setup the camera rig.
*/
setup(): void;
}
/**
* @description Create a default camera rig with update batcher.
*
* @category Camera
*/
export declare function createDefaultCameraRigWithUpdateBatcher(camera: ObservableBoardCamera): CameraRigWithUpdateBatcher;
export declare class DefaultCameraRig implements CameraRig {
private _panBy;
private _panTo;
private _zoomTo;
private _zoomBy;
private _rotateBy;
private _rotateTo;
private _config;
private _camera;
constructor(config: PanHandlerConfig & ZoomHandlerConfig, camera?: ObservableBoardCamera);
/**
* @description Zoom to a certain zoom level at a certain point. The point is in the viewport coordinate system.
*/
zoomToAt(targetZoom: number, at: Point): void;
/**
* @description Zoom by a certain amount at a certain point. The point is in the viewport coordinate system.
*/
zoomByAt(delta: number, at: Point): void;
/**
* @description Zoom to a certain zoom level with respect to the center of the viewport.
*/
zoomTo(targetZoom: number): void;
/**
* @description Zoom by a certain amount with respect to the center of the viewport.
*/
zoomBy(delta: number): void;
/**
* @description Zoom to a certain zoom level with respect to a point in the world coordinate system.
*/
zoomToAtWorld(targetZoom: number, at: Point): void;
/**
* @description Zoom by a certain amount with respect to a point in the world coordinate system.
*/
zoomByAtWorld(delta: number, at: Point): void;
/**
* @description Pan By a certain amount. (delta is in the viewport coordinate system)
*/
panByViewPort(delta: Point): void;
/**
* @description Pan to a certain point. (target is in the world coordinate system)
*/
panByWorld(delta: Point): void;
/**
* @description Pan to a certain point. (target is in the world coordinate system)
*/
panToWorld(target: Point): void;
/**
* @description Pan to a certain point. (target is in the viewport coordinate system)
*/
panToViewPort(target: Point): void;
/**
* @description Rotate by a certain amount.
*/
rotateBy(delta: number): void;
/**
* @description Rotate to a certain angle.
*/
rotateTo(target: number): void;
set limitEntireViewPort(limit: boolean);
/**
* @description Whether the entire view port is limited.
*/
get limitEntireViewPort(): boolean;
get camera(): ObservableBoardCamera;
get config(): CameraRigConfig;
set config(config: CameraRigConfig);
/**
* @description Configure the camera rig.
*/
configure(config: Partial<CameraRigConfig>): void;
/**
* @description Cleanup the camera rig.
*/
cleanup(): void;
/**
* @description Setup the camera rig.
*/
setup(): void;
update(): void;
}
/**
* @description Create a default camera rig.
*
* @category Camera
*/
export declare function createDefaultCameraRig(camera: ObservableBoardCamera): CameraRig;