@motion-core/motion-gpu
Version:
Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.
96 lines • 2.83 kB
TypeScript
import type { RenderMode } from './types.js';
/**
* Pointer kind normalized from DOM `PointerEvent.pointerType`.
*/
export type PointerKind = 'mouse' | 'pen' | 'touch';
/**
* 2D tuple used by pointer coordinate payloads.
*/
export type PointerVec2 = [number, number];
/**
* Normalized pointer coordinates exposed to runtime hooks.
*/
export interface PointerPoint {
/**
* CSS pixel coordinates relative to canvas top-left corner.
*/
px: PointerVec2;
/**
* UV coordinates in shader-friendly orientation (`y` grows upward).
*/
uv: PointerVec2;
/**
* Normalized device coordinates (`-1..1`, `y` grows upward).
*/
ndc: PointerVec2;
}
/**
* Mutable pointer state snapshot exposed by `usePointer`.
*/
export interface PointerState extends PointerPoint {
inside: boolean;
pressed: boolean;
dragging: boolean;
pointerType: PointerKind | null;
pointerId: number | null;
button: number | null;
buttons: number;
time: number;
downPx: PointerVec2 | null;
downUv: PointerVec2 | null;
deltaPx: PointerVec2;
deltaUv: PointerVec2;
velocityPx: PointerVec2;
velocityUv: PointerVec2;
}
/**
* Modifier key snapshot attached to pointer click events.
*/
export interface PointerModifiers {
alt: boolean;
ctrl: boolean;
shift: boolean;
meta: boolean;
}
/**
* Click/tap payload produced by `usePointer`.
*/
export interface PointerClick extends PointerPoint {
id: number;
time: number;
pointerType: PointerKind;
pointerId: number;
button: number;
modifiers: PointerModifiers;
}
/**
* Frame wake-up strategy for pointer-driven interactions.
*/
export type PointerFrameRequestMode = 'advance' | 'auto' | 'invalidate' | 'none';
/**
* Returns a monotonic timestamp in seconds.
*/
export declare function getPointerNowSeconds(): number;
/**
* Creates the initial pointer state snapshot.
*/
export declare function createInitialPointerState(): PointerState;
/**
* Normalized coordinate payload for a pointer position against a canvas rect.
*/
export interface PointerCoordinates extends PointerPoint {
inside: boolean;
}
/**
* Converts client coordinates to canvas-relative pointer coordinates.
*/
export declare function getPointerCoordinates(clientX: number, clientY: number, rect: Pick<DOMRectReadOnly, 'height' | 'left' | 'top' | 'width'>): PointerCoordinates;
/**
* Resolves frame wake-up strategy for pointer-driven updates.
*/
export declare function resolvePointerFrameRequestMode(mode: PointerFrameRequestMode, renderMode: RenderMode): Exclude<PointerFrameRequestMode, 'auto'>;
/**
* Normalizes unknown pointer kind values to the public `PointerKind`.
*/
export declare function normalizePointerKind(pointerType: string): PointerKind;
//# sourceMappingURL=pointer.d.ts.map