UNPKG

react-three-nurbs

Version:

A React component library for NURBS (Non-Uniform Rational B-Spline) curves, surfaces, and solids in Three.js. Built with React Three Fiber, zero external NURBS dependencies — all math implemented from scratch. Boolean operations powered by OpenCASCADE WAS

38 lines (37 loc) 1.84 kB
import { Vector3 } from "three"; import type { NurbsCurve } from "../core"; import type { NurbsSurface } from "../core"; /** * Generates a clamped uniform knot vector for given number of control points and degree. */ export declare function generateUniformKnots(numControlPoints: number, degree: number): number[]; /** * Evaluates a surface point and wraps it in a Vector3. */ export declare function projectPointToSurface(surface: NurbsSurface, u: number, v: number): Vector3; /** * Computes the surface normal at (u, v) using verb's analytical normal. */ export declare function computeNormal(surface: NurbsSurface, u: number, v: number): Vector3; /** * Uniformly samples a NURBS curve in 2D (UV space). */ export declare function sampleNurbsCurve2D(curve: NurbsCurve, numPoints?: number): [number, number][]; /** * Adaptively samples a NURBS curve in 2D (UV space) based on angle threshold. */ export declare function adaptiveSampleNurbsCurve2D(curve: NurbsCurve, maxAngleDeg?: number, maxDepth?: number): [number, number][]; /** * Projects a 3D point onto a surface, returning the closest UV parameters. */ export declare function projectPointToSurfaceUV(surface: NurbsSurface, point: number[]): [number, number] | null; /** * Projects an entire 3D curve onto a surface, returning UV-space points. * Uses marching approach: each projected point uses the previous result as * initial guess for Newton iteration, ensuring continuity and speed. * * This is significantly more robust than projecting points independently, * especially for curves that run near surface boundaries or along near-tangent * directions. Based on the approach described in Section 6.1 of The NURBS Book. */ export declare function projectCurveOntoSurface(surface: NurbsSurface, curve: NurbsCurve, numSamples?: number): [number, number][];