@pmndrs/uikit
Version:
Build performant 3D user interfaces with Three.js and yoga.
42 lines (41 loc) • 2.7 kB
TypeScript
import { Intersection, Matrix4, Mesh, Object3D, Sphere, Vector2Tuple } from 'three';
import { ClippingRect } from '../clipping.js';
import { Signal } from '@preact/signals-core';
import { OrderInfo } from '../order.js';
import { createContainerState, createContentState, createCustomContainerState, createIconState, createImageState, createInputState, createRootState, createSvgState, createTextState, FlexNodeState } from '../internals.js';
export type AllowedPointerEventsType = 'all' | ((poinerId: number, pointerType: string, pointerState: unknown) => boolean) | {
allow: string | Array<string>;
} | {
deny: string | Array<string>;
};
declare module 'three' {
interface Object3D extends PointerEventsProperties {
spherecast?(sphere: Sphere, intersects: Array<Intersection>): void;
intersectChildren?: boolean;
interactableDescendants?: Array<Object3D>;
ancestorsHaveListeners?: boolean;
defaultPointerEvents?: PointerEventsProperties['pointerEvents'];
}
}
export type PointerEventsProperties = {
pointerEvents?: 'none' | 'auto' | 'listener';
pointerEventsType?: AllowedPointerEventsType;
pointerEventsOrder?: number;
};
export declare function makePanelSpherecast(rootObjectRef: {
current?: Object3D | null;
}, globalSphereWithLocalScale: Sphere, globalMatrixSignal: Signal<Matrix4 | undefined>, object: Object3D): Exclude<Mesh['spherecast'], undefined>;
export declare function makePanelRaycast(raycast: Mesh['raycast'], rootObjectRef: {
current?: Object3D | null;
}, globalSphereWithLocalScale: Sphere, globalMatrixSignal: Signal<Matrix4 | undefined>, object: Object3D): Mesh['raycast'];
export declare function isInteractionPanel(object: Object3D): object is Object3D & {
internals: ReturnType<typeof createContainerState | typeof createContentState | typeof createImageState | typeof createRootState | typeof createSvgState | typeof createTextState | typeof createIconState | typeof createInputState | typeof createCustomContainerState>;
};
export declare function setupBoundingSphere(target: Sphere, pixelSize: Signal<number>, globalMatrixSignal: Signal<Matrix4 | undefined>, size: Signal<Vector2Tuple | undefined>, abortSignal: AbortSignal): void;
/**
* clips the sphere / raycast
* also marks the mesh as a interaction panel
*/
export declare function makeClippedCast<T extends Mesh['raycast'] | Exclude<Mesh['spherecast'], undefined>>(mesh: Mesh, fn: T, rootObject: {
current?: Object3D | null;
}, clippingRect: Signal<ClippingRect | undefined> | undefined, orderInfoSignal: Signal<OrderInfo | undefined>, internals: FlexNodeState): (raycaster: Parameters<T>[0], intersects: Parameters<T>[1]) => void;