UNPKG

toosoon-utils

Version:
102 lines (101 loc) 3.7 kB
import type { Point3 } from '../../types'; import { Vector3 } from '../geometry'; import Curve from './Curve'; /** * Utility class for manipulating Cubic Bézier 3D curves * * @exports * @class CubicBezierCurve3 * @extends Curve */ export default class CubicBezierCurve3 extends Curve<Vector3> { readonly type: string; /** * X-axis coordinate of the start point */ x1: number; /** * Y-axis coordinate of the start point */ y1: number; /** * Z-axis coordinate of the start point */ z1: number; /** * X-axis coordinate of the first control point */ cp1x: number; /** * Y-axis coordinate of the first control point */ cp1y: number; /** * Z-axis coordinate of the first control point */ cp1z: number; /** * X-axis coordinate of the second control point */ cp2x: number; /** * Y-axis coordinate of the second control point */ cp2y: number; /** * Z-axis coordinate of the second control point */ cp2z: number; /** * X-axis coordinate of the end point */ x2: number; /** * Y-axis coordinate of the end point */ y2: number; /** * Z-axis coordinate of the end point */ z2: number; /** * @param {number} x1 X-axis coordinate of the start point * @param {number} y1 Y-axis coordinate of the start point * @param {number} z1 Z-axis coordinate of the start point * @param {number} cp1x X-axis coordinate of the first control point * @param {number} cp1y Y-axis coordinate of the first control point * @param {number} cp1z Z-axis coordinate of the first control point * @param {number} cp2x X-axis coordinate of the second control point * @param {number} cp2y Y-axis coordinate of the second control point * @param {number} cp2z Z-axis coordinate of the second control point * @param {number} x2 X-axis coordinate of the end point * @param {number} y2 Y-axis coordinate of the end point * @param {number} z2 Z-axis coordinate of the end point */ constructor(x1: number, y1: number, z1: number, cp1x: number, cp1y: number, cp1z: number, cp2x: number, cp2y: number, cp2z: number, x2: number, y2: number, z2: number); /** * Interpolate a point on this curve * * @param {number} t Normalized time value to interpolate * @returns {Vector3} Interpolated coordinates on this curve */ getPoint(t: number): Vector3; /** * Interpolate a point on a 3D Cubic Bézier curve * * @param {number} x1 X-axis coordinate of the start point * @param {number} y1 Y-axis coordinate of the start point * @param {number} z1 Z-axis coordinate of the start point * @param {number} cp1x X-axis coordinate of the first control point * @param {number} cp1y Y-axis coordinate of the first control point * @param {number} cp1z Z-axis coordinate of the first control point * @param {number} cp2x X-axis coordinate of the second control point * @param {number} cp2y Y-axis coordinate of the second control point * @param {number} cp2z Z-axis coordinate of the second control point * @param {number} x2 X-axis coordinate of the end point * @param {number} y2 Y-axis coordinate of the end point * @param {number} z2 Z-axis coordinate of the end point * @returns {Point2} Interpolated coordinates on the curve */ static interpolate(t: number, x1: number, y1: number, z1: number, cp1x: number, cp1y: number, cp1z: number, cp2x: number, cp2y: number, cp2z: number, x2: number, y2: number, z2: number): Point3; }