/** * 3D Raycasting utilities for picking/selection. * Implements ray-sphere intersection for bubble selection. */ export interface Ray3D { origin: [number, number, number]; direction: [number, number, number]; } export interface HitResult { index: number; distance: number; point: [number, number, number]; } /** * Creates a ray from screen coordinates through the scene. * @param screenX Screen X coordinate (pixels from left) * @param screenY Screen Y coordinate (pixels from top) * @param canvasWidth Canvas width in pixels * @param canvasHeight Canvas height in pixels * @param viewProjectionMatrix Combined view-projection matrix * @returns Ray in world space */ export declare function createRayFromScreen(screenX: number, screenY: number, canvasWidth: number, canvasHeight: number, viewProjectionMatrix: Float32Array): Ray3D; /** * Test ray-sphere intersection. * @param ray The ray to test * @param center Sphere center * @param radius Sphere radius * @returns Distance to intersection, or null if no hit */ export declare function raySphereIntersection(ray: Ray3D, center: [number, number, number], radius: number): number | null; /** * Find the closest bubble hit by a ray. * @param ray The ray to test * @param positions Float32Array of positions (x,y,z interleaved) * @param scales Float32Array of scales (radii) * @param baseRadius Base radius multiplier * @returns Hit result or null if no hit */ export declare function pickBubble(ray: Ray3D, positions: Float32Array, scales: Float32Array, baseRadius?: number): HitResult | null; /** * Batch pick bubbles - returns all bubbles within a tolerance of the ray. * More efficient for hover detection. */ export declare function pickBubblesInRange(ray: Ray3D, positions: Float32Array, scales: Float32Array, baseRadius?: number, maxResults?: number): HitResult[]; /** * Calculate distance from a point to a ray (for approximate/fast picking). */ export declare function pointToRayDistance(ray: Ray3D, point: [number, number, number]): number; /** * Result of a surface mesh hit test */ export interface SurfaceHitResult { /** Distance from ray origin to hit point */ distance: number; /** Hit point in world coordinates */ point: [number, number, number]; /** Grid row and column indices */ row: number; col: number; /** Interpolated Y value at hit point */ yValue: number; /** Barycentric coordinates for interpolation */ baryU: number; baryV: number; } /** * Ray-triangle intersection using Möller-Trumbore algorithm. * Returns distance to intersection or null if no hit. */ export declare function rayTriangleIntersection(ray: Ray3D, v0: [number, number, number], v1: [number, number, number], v2: [number, number, number]): { distance: number; u: number; v: number; } | null; /** * Pick a point on a surface mesh grid. * Tests ray against all triangles in the grid. * * @param ray The picking ray * @param xValues X coordinates array (columns) * @param zValues Z coordinates array (rows) * @param yValues Y values array (row-major: row * cols + col) * @returns Hit result or null if no intersection */ export declare function pickSurfaceMesh(ray: Ray3D, xValues: Float32Array, zValues: Float32Array, yValues: Float32Array): SurfaceHitResult | null; /** * Calculate the shortest distance between a ray and a line segment. * Useful for picking lines and thin tubes. */ export declare function raySegmentDistance(ray: Ray3D, p0: [number, number, number], p1: [number, number, number]): { distance: number; pointOnRay: [number, number, number]; pointOnSegment: [number, number, number]; t: number; }; /** * Pick a series index and point index from a 3D line. */ export declare function pickLine(ray: Ray3D, lines: { x: Float32Array; y: Float32Array; z: Float32Array; }[], threshold?: number): { seriesIndex: number; pointIndex: number; distance: number; point: [number, number, number]; } | null; /** * Pick a point from an impulse/stem series. */ export declare function pickImpulse(ray: Ray3D, data: { x: Float32Array; y: Float32Array; z: Float32Array; baseY?: number; }, threshold?: number): { index: number; distance: number; point: [number, number, number]; } | null; /** * Pick a series index and point index from a 3D area (curtain). * Checks the top line of the area. */ export declare function pickArea(ray: Ray3D, areas: { x: Float32Array; y: Float32Array; z: Float32Array; baseY?: number; }[], threshold?: number): { seriesIndex: number; pointIndex: number; distance: number; point: [number, number, number]; } | null;