videx-3d
Version:
React 3D component library designed for sub surface visualizations in the browser
47 lines (46 loc) • 1.63 kB
TypeScript
import { Vec3 } from '../../types/common';
/**
* Interface for interpolating points on a 3d curve
*/
export interface Curve3D {
getPointAt: (pos: number) => Vec3;
getPoints: (nSamples: number, from?: number, to?: number) => Vec3[];
getTangentAt: (pos: number) => Vec3;
getNormalAt: (pos: number) => Vec3;
getBoundingBox: (from?: number, to?: number) => {
min: Vec3;
max: Vec3;
};
nearest: (point: Vec3) => {
position: number;
point: Vec3;
distance: number;
};
length: number;
closed: boolean;
}
/**
* Returns an implementation of `SplineCurve` using `CurveInterpolator`
**/
export declare function getSplineCurve(points: Vec3[], closed?: boolean): Curve3D | null;
export type FrenetFrame = {
curvePosition: number;
position: Vec3;
tangent: Vec3;
normal: Vec3;
binormal: Vec3;
};
/**
* Calculate a stable and balanced set of Frenet Frames for a curve at the
* specified positions.
*/
export declare function calculateFrenetFrames(curve: Curve3D, curvePositions: number[]): FrenetFrame[];
/**
* Get a set of positions along a curve according to a number of segments per meter,
* optionally simplified/optimized by specifying a simplification threshold.
*
* To get a sub section, use the from and/or to parameters.
*
* @remarks segments per meter is always calculated from the start of the curve to ensure alingment when optimizing the number of vertices
*/
export declare function getCurvePositions(curve: Curve3D, from?: number, to?: number, segmentsPerMeter?: number, simplificationThreshold?: number): number[];