import type { DeepImmutable, Nullable } from "../types"; import { Vector2, Vector3 } from "./math.vector"; import type { Vector4 } from "./math.vector"; /** * Defines potential orientation for back face culling */ export declare enum Orientation { /** * Clockwise */ CW = 0, /** Counter clockwise */ CCW = 1 } /** Class used to represent a Bezier curve */ export declare class BezierCurve { /** * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats * @param t defines the time * @param x1 defines the left coordinate on X axis * @param y1 defines the left coordinate on Y axis * @param x2 defines the right coordinate on X axis * @param y2 defines the right coordinate on Y axis * @returns the interpolated value */ static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; } /** * Defines angle representation */ export declare class Angle { private _radians; /** * Creates an Angle object of "radians" radians (float). * @param radians the angle in radians */ constructor(radians: number); /** * Get value in degrees * @returns the Angle value in degrees (float) */ degrees(): number; /** * Get value in radians * @returns the Angle value in radians (float) */ radians(): number; /** * Gets a new Angle object with a value of the angle (in radians) between the line connecting the two points and the x-axis * @param a defines first point as the origin * @param b defines point * @returns a new Angle */ static BetweenTwoPoints(a: DeepImmutable, b: DeepImmutable): Angle; /** * Gets the angle between the two vectors * @param a defines first vector * @param b defines vector * @returns Returns an new Angle between 0 and PI */ static BetweenTwoVectors(a: DeepImmutable, b: DeepImmutable): Angle; /** * Gets a new Angle object from the given float in radians * @param radians defines the angle value in radians * @returns a new Angle */ static FromRadians(radians: number): Angle; /** * Gets a new Angle object from the given float in degrees * @param degrees defines the angle value in degrees * @returns a new Angle */ static FromDegrees(degrees: number): Angle; } /** * This represents an arc in a 2d space. */ export declare class Arc2 { /** Defines the start point of the arc */ startPoint: Vector2; /** Defines the mid point of the arc */ midPoint: Vector2; /** Defines the end point of the arc */ endPoint: Vector2; /** * Defines the center point of the arc. */ centerPoint: Vector2; /** * Defines the radius of the arc. */ radius: number; /** * Defines the angle of the arc (from mid point to end point). */ angle: Angle; /** * Defines the start angle of the arc (from start point to middle point). */ startAngle: Angle; /** * Defines the orientation of the arc (clock wise/counter clock wise). */ orientation: Orientation; /** * Creates an Arc object from the three given points : start, middle and end. * @param startPoint Defines the start point of the arc * @param midPoint Defines the middle point of the arc * @param endPoint Defines the end point of the arc */ constructor( /** Defines the start point of the arc */ startPoint: Vector2, /** Defines the mid point of the arc */ midPoint: Vector2, /** Defines the end point of the arc */ endPoint: Vector2); } /** * Represents a 2D path made up of multiple 2D points */ export declare class Path2 { private _points; private _length; /** * If the path start and end point are the same */ closed: boolean; /** * Creates a Path2 object from the starting 2D coordinates x and y. * @param x the starting points x value * @param y the starting points y value */ constructor(x: number, y: number); /** * Adds a new segment until the given coordinates (x, y) to the current Path2. * @param x the added points x value * @param y the added points y value * @returns the updated Path2. */ addLineTo(x: number, y: number): Path2; /** * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. * @param midX middle point x value * @param midY middle point y value * @param endX end point x value * @param endY end point y value * @param numberOfSegments (default: 36) * @returns the updated Path2. */ addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; /** * Adds _numberOfSegments_ segments according to the quadratic curve definition to the current Path2. * @param controlX control point x value * @param controlY control point y value * @param endX end point x value * @param endY end point y value * @param numberOfSegments (default: 36) * @returns the updated Path2. */ addQuadraticCurveTo(controlX: number, controlY: number, endX: number, endY: number, numberOfSegments?: number): Path2; /** * Adds _numberOfSegments_ segments according to the bezier curve definition to the current Path2. * @param originTangentX tangent vector at the origin point x value * @param originTangentY tangent vector at the origin point y value * @param destinationTangentX tangent vector at the destination point x value * @param destinationTangentY tangent vector at the destination point y value * @param endX end point x value * @param endY end point y value * @param numberOfSegments (default: 36) * @returns the updated Path2. */ addBezierCurveTo(originTangentX: number, originTangentY: number, destinationTangentX: number, destinationTangentY: number, endX: number, endY: number, numberOfSegments?: number): Path2; /** * Defines if a given point is inside the polygon defines by the path * @param point defines the point to test * @returns true if the point is inside */ isPointInside(point: Vector2): boolean; /** * Closes the Path2. * @returns the Path2. */ close(): Path2; /** * Gets the sum of the distance between each sequential point in the path * @returns the Path2 total length (float). */ length(): number; /** * Gets the area of the polygon defined by the path * @returns area value */ area(): number; /** * Gets the points which construct the path * @returns the Path2 internal array of points. */ getPoints(): Vector2[]; /** * Retrieves the point at the distance aways from the starting point * @param normalizedLengthPosition the length along the path to retrieve the point from * @returns a new Vector2 located at a percentage of the Path2 total length on this path. */ getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; /** * Creates a new path starting from an x and y position * @param x starting x value * @param y starting y value * @returns a new Path2 starting at the coordinates (x, y). */ static StartingAt(x: number, y: number): Path2; } /** * Represents a 3D path made up of multiple 3D points * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/path3D */ export declare class Path3D { /** * an array of Vector3, the curve axis of the Path3D */ path: Vector3[]; private _curve; private _distances; private _tangents; private _normals; private _binormals; private _raw; private _alignTangentsWithPath; private readonly _pointAtData; /** * new Path3D(path, normal, raw) * Creates a Path3D. A Path3D is a logical math object, so not a mesh. * please read the description in the tutorial : https://doc.babylonjs.com/features/featuresDeepDive/mesh/path3D * @param path an array of Vector3, the curve axis of the Path3D * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path. */ constructor( /** * an array of Vector3, the curve axis of the Path3D */ path: Vector3[], firstNormal?: Nullable, raw?: boolean, alignTangentsWithPath?: boolean); /** * Returns the Path3D array of successive Vector3 designing its curve. * @returns the Path3D array of successive Vector3 designing its curve. */ getCurve(): Vector3[]; /** * Returns the Path3D array of successive Vector3 designing its curve. * @returns the Path3D array of successive Vector3 designing its curve. */ getPoints(): Vector3[]; /** * @returns the computed length (float) of the path. */ length(): number; /** * Returns an array populated with tangent vectors on each Path3D curve point. * @returns an array populated with tangent vectors on each Path3D curve point. */ getTangents(): Vector3[]; /** * Returns an array populated with normal vectors on each Path3D curve point. * @returns an array populated with normal vectors on each Path3D curve point. */ getNormals(): Vector3[]; /** * Returns an array populated with binormal vectors on each Path3D curve point. * @returns an array populated with binormal vectors on each Path3D curve point. */ getBinormals(): Vector3[]; /** * Returns an array populated with distances (float) of the i-th point from the first curve point. * @returns an array populated with distances (float) of the i-th point from the first curve point. */ getDistances(): number[]; /** * Returns an interpolated point along this path * @param position the position of the point along this path, from 0.0 to 1.0 * @returns a new Vector3 as the point */ getPointAt(position: number): Vector3; /** * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path. * @param position the position of the point along this path, from 0.0 to 1.0 * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array. */ getTangentAt(position: number, interpolated?: boolean): Vector3; /** * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path. * @param position the position of the point along this path, from 0.0 to 1.0 * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array. */ getNormalAt(position: number, interpolated?: boolean): Vector3; /** * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path. * @param position the position of the point along this path, from 0.0 to 1.0 * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array. */ getBinormalAt(position: number, interpolated?: boolean): Vector3; /** * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path. * @param position the position of the point along this path, from 0.0 to 1.0 * @returns the distance of the interpolated Path3D curve point at the specified position along this path. */ getDistanceAt(position: number): number; /** * Returns the array index of the previous point of an interpolated point along this path * @param position the position of the point to interpolate along this path, from 0.0 to 1.0 * @returns the array index */ getPreviousPointIndexAt(position: number): number; /** * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B) * @param position the position of the point to interpolate along this path, from 0.0 to 1.0 * @returns the sub position */ getSubPositionAt(position: number): number; /** * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0 * @param target the vector of which to get the closest position to * @returns the position of the closest virtual point on this path to the target vector */ getClosestPositionTo(target: Vector3): number; /** * Returns a sub path (slice) of this path * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values * @returns a sub path (slice) of this path */ slice(start?: number, end?: number): Path3D; /** * Forces the Path3D tangent, normal, binormal and distance recomputation. * @param path path which all values are copied into the curves points * @param firstNormal which should be projected onto the curve * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path * @returns the same object updated. */ update(path: Vector3[], firstNormal?: Nullable, alignTangentsWithPath?: boolean): Path3D; private _compute; private _getFirstNonNullVector; private _getLastNonNullVector; private _normalVector; /** * Updates the point at data for an interpolated point along this curve * @param position the position of the point along this curve, from 0.0 to 1.0 * @param interpolateTNB * @interpolateTNB whether to compute the interpolated tangent, normal and binormal * @returns the (updated) point at data */ private _updatePointAtData; /** * Updates the point at data from the specified parameters * @param position where along the path the interpolated point is, from 0.0 to 1.0 * @param subPosition * @param point the interpolated point * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point * @param interpolateTNB whether to compute the interpolated tangent, normal and binormal * @returns the (updated) point at data */ private _setPointAtData; /** * Updates the point at interpolation matrix for the tangents, normals and binormals */ private _updateInterpolationMatrix; } /** * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. * A Curve3 is designed from a series of successive Vector3. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/drawCurves */ export declare class Curve3 { private _points; private _length; /** * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/features/featuresDeepDive/mesh/drawCurves#quadratic-bezier-curve * @param v0 (Vector3) the origin point of the Quadratic Bezier * @param v1 (Vector3) the control point * @param v2 (Vector3) the end point of the Quadratic Bezier * @param nbPoints (integer) the wanted number of points in the curve * @returns the created Curve3 */ static CreateQuadraticBezier(v0: DeepImmutable, v1: DeepImmutable, v2: DeepImmutable, nbPoints: number): Curve3; /** * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/features/featuresDeepDive/mesh/drawCurves#cubic-bezier-curve * @param v0 (Vector3) the origin point of the Cubic Bezier * @param v1 (Vector3) the first control point * @param v2 (Vector3) the second control point * @param v3 (Vector3) the end point of the Cubic Bezier * @param nbPoints (integer) the wanted number of points in the curve * @returns the created Curve3 */ static CreateCubicBezier(v0: DeepImmutable, v1: DeepImmutable, v2: DeepImmutable, v3: DeepImmutable, nbPoints: number): Curve3; /** * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/features/featuresDeepDive/mesh/drawCurves#hermite-spline * @param p1 (Vector3) the origin point of the Hermite Spline * @param t1 (Vector3) the tangent vector at the origin point * @param p2 (Vector3) the end point of the Hermite Spline * @param t2 (Vector3) the tangent vector at the end point * @param nSeg (integer) the number of curve segments or nSeg + 1 points in the array * @returns the created Curve3 */ static CreateHermiteSpline(p1: DeepImmutable, t1: DeepImmutable, p2: DeepImmutable, t2: DeepImmutable, nSeg: number): Curve3; /** * Returns a Curve3 object along a CatmullRom Spline curve : * @param points (array of Vector3) the points the spline must pass through. At least, four points required * @param nbPoints (integer) the wanted number of points between each curve control points * @param closed (boolean) optional with default false, when true forms a closed loop from the points * @returns the created Curve3 */ static CreateCatmullRomSpline(points: DeepImmutable, nbPoints: number, closed?: boolean): Curve3; /** * Returns a Curve3 object along an arc through three vector3 points: * The three points should not be colinear. When they are the Curve3 is empty. * @param first (Vector3) the first point the arc must pass through. * @param second (Vector3) the second point the arc must pass through. * @param third (Vector3) the third point the arc must pass through. * @param steps (number) the larger the number of steps the more detailed the arc. * @param closed (boolean) optional with default false, when true forms the chord from the first and third point * @param fullCircle Circle (boolean) optional with default false, when true forms the complete circle through the three points * @returns the created Curve3 */ static ArcThru3Points(first: Vector3, second: Vector3, third: Vector3, steps?: number, closed?: boolean, fullCircle?: boolean): Curve3; /** * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. * A Curve3 is designed from a series of successive Vector3. * Tuto : https://doc.babylonjs.com/features/featuresDeepDive/mesh/drawCurves#curve3-object * @param points points which make up the curve */ constructor(points: Vector3[]); /** * @returns the Curve3 stored array of successive Vector3 */ getPoints(): Vector3[]; /** * @returns the computed length (float) of the curve. */ length(): number; /** * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. * curveA and curveB keep unchanged. * @param curve the curve to continue from this curve * @returns the newly constructed curve */ continue(curve: DeepImmutable): Curve3; private _computeLength; }