import { EventDispatcher, Vector3Like } from 'three/webgpu'; import { DIVECameraComponent, DIVEInput, DIVETicker } from '../../../index.ts'; /** * A camera pose: where it stands and what it looks at. * * @experimental See {@link TiltController}. */ export type TiltControllerPose = { position: Vector3Like; target: Vector3Like; }; /** @experimental See {@link TiltController}. */ export type TiltControllerSettings = { enabled?: boolean; /** Tilt in radians that turns the camera all the way, per axis. */ maxTilt?: { x: number; y: number; }; /** How far up or down a full forward or backward tilt looks, in radians. */ maxPolarOffset?: number; /** How quickly the camera follows the tilt, per second. Higher is snappier. */ smoothing?: number; }; /** @experimental See {@link TiltController}. */ export declare const TiltControllerDefaultSettings: Required; type EventMap = { change: { type: 'change'; }; dispose: { type: 'dispose'; }; }; /** * Turns the camera around its home pose by how a device is tilted. * * Absolute, not integrated, with limits that move along: within the limits an * `axis` value maps to one camera pose. Past a limit the camera stays at the * stop and the limit follows the device, so turning back moves the camera at * once instead of first winding off the excess -- the front then lies that much * further over. A limit only follows a movement mainly along its own axis, so * the sideways wobble of moving the device up and down is held at the stop * rather than kept. A sideways tilt of {@link maxTilt}`.x` turns the camera * half way round -- to the middle of the back, from either side. Tilting * forward or backward moves the polar angle by up to {@link maxPolarOffset}. * * Nothing moves before {@link setHome} has been called. * * @experimental The mapping is still being tuned on devices; behaviour, * defaults and settings may change without a major release. */ export declare class TiltController extends EventDispatcher implements DIVETicker { readonly uuid: string; /** The camera component this controller drives; it moves `object.owner`. */ readonly object: DIVECameraComponent; maxTilt: { x: number; y: number; }; maxPolarOffset: number; smoothing: number; /** * Whether the controller moves the camera. Turning it on starts from wherever * the camera is, and eases into the pose the tilt asks for. */ get enabled(): boolean; set enabled(enabled: boolean); private _enabled; private _home; /** The latest tilt, measured from where the limits have moved to. */ private readonly _tilt; /** How far the limits have been dragged along past their start. */ private readonly _slack; /** * The previous report, to tell which axis a movement is along. Neutral * before the first one, which is where a calibrated device starts. */ private readonly _last; /** * Where the camera is on its way to the goal, as fractions of the full turn * (`x`: of half a turn, `y`: of {@link maxPolarOffset}), plus distance and * target. Eased in fraction space rather than angle space, so there is no * shortest-way-round to get wrong at the back. */ private readonly _fraction; private _radius; private readonly _target; private _seeded; private readonly _connections; private readonly _quat; private readonly _quatInverse; private readonly _offset; private readonly _spherical; constructor(cameraComponent: DIVECameraComponent, settings?: TiltControllerSettings); /** The pose an untilted device shows -- the front. */ setHome(pose: TiltControllerPose): void; /** Listens to an input's `axis` on `orientation`. Connecting twice changes nothing. */ connect(input: DIVEInput): void; disconnect(input: DIVEInput): void; dispose(): void; tick(deltaTime: number): void; /** * Takes a reported tilt, dragging a limit along by whatever goes past it -- * but only the limit of the axis the device mainly moved along. Past the * other one the tilt is just held at the stop, so a wobble that comes back * leaves nothing behind. */ private _follow; /** Back to limits around the neutral pose, as after a fresh calibration. */ private _resetTilt; /** * Takes the camera's current pose as the starting point of the easing. * * The target is taken to lie straight ahead, as far away as home's target is, * which is exact for a camera that came from orbiting around it. */ private _seed; } export {};