123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453 |
- 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<Vector2>, b: DeepImmutable<Vector2>): 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<Vec extends Vector2 | Vector3 | Vector4>(a: DeepImmutable<Vec>, b: DeepImmutable<Vec>): 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<Vector3>, 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<Vector3>, 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<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, 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<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, 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<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, 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<Vector3[]>, 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>): Curve3;
- private _computeLength;
- }
|