@turbox3d/math
Version:
Large-scale graphics application math library
106 lines (105 loc) • 3.81 kB
TypeScript
import { Euler } from './Euler';
import { Matrix3 } from './Matrix3';
import { Matrix4 } from './Matrix4';
import { Quaternion } from './Quaternion';
import { Tolerance } from './Tolerance';
import { Vector2 } from './Vector2';
declare class Vector3 {
static fromObject(obj: {
x: number;
y: number;
z?: number;
}): Vector3;
readonly isVector3: boolean;
x: number;
y: number;
z: number;
constructor(x?: number, y?: number, z?: number);
set(x: number, y: number, z: number): this;
setScalar(scalar: number): this;
setX(x: number): this;
setY(y: number): this;
setZ(z: number): this;
setComponent(index: number, value: number): this;
getComponent(index: number): number;
clone(): Vector3;
copy(v: Vector3): this;
add(v: Vector3): this;
added(v: Vector3): Vector3;
addScalar(s: number): this;
addVectors(a: Vector3, b: Vector3): this;
addScaledVector(v: Vector3, s: number): this;
sub(v: Vector3): this;
subtracted(v: Vector3): Vector3;
subScalar(s: number): this;
subVectors(a: Vector3, b: Vector3): this;
multiply(v: Vector3): this;
multiplied(v: Vector3): Vector3;
multiplyScalar(scalar: number): this;
multiplyVectors(a: Vector3, b: Vector3): this;
applyEuler(euler: Euler): this;
appliedEuler(euler: Euler): Vector3;
applyAxisAngle(axis: Vector3, angle: number): this;
applyMatrix3(m: Matrix3): this;
applyNormalMatrix(m: Matrix3): this;
applyMatrix4(m: Matrix4): this;
appliedMatrix4(m: Matrix4): Vector3;
applyQuaternion(q: Quaternion): this;
appliedQuaternion(q: Quaternion): Vector3;
transformDirection(m: Matrix4): this;
divide(v: Vector3): this;
divideScalar(scalar: number): this;
min(v: Vector3): this;
max(v: Vector3): this;
clamp(min: Vector3, max: Vector3): this;
clampScalar(minVal: number, maxVal: number): this;
clampLength(min: number, max: number): this;
floor(): this;
ceil(): this;
round(): this;
roundToZero(): this;
negate(): this;
dot(v: Vector3): number;
get lengthSq(): number;
get length(): number;
get manhattanLength(): number;
normalize(): this;
normalized(): Vector3;
reverse(): this;
reversed(): Vector3;
setLength(length: number): this;
lerp(v: Vector3, alpha: number): this;
lerpVectors(v1: Vector3, v2: Vector3, alpha: number): this;
toVector2(): Vector2;
cross(v: Vector3): this;
crossed(vec: Vector3): Vector3;
crossVectors(a: Vector3, b: Vector3): this;
projectOnVector(v: Vector3): this;
projectOnPlane(planeNormal: Vector3): this;
reflect(normal: Vector3): this;
/**
* The angle in [0, PI]
*/
angle(v: Vector3): number;
/**
* The angle in [0, 2PI)
*/
angleTo(v: Vector3, vecRef: Vector3): number;
distanceTo(v: Vector3): number;
distanceToSquared(v: Vector3): number;
manhattanDistanceTo(v: Vector3): number;
setFromMatrixPosition(m: Matrix4): this;
setFromMatrixScale(m: Matrix4): this;
setFromMatrixColumn(m: Matrix4, index: number): this;
setFromMatrix3Column(m: Matrix3, index: number): this;
equals(v: Vector3, distTol?: number, cosTol?: number): boolean;
isPerpendicular(vec: Vector3, tol?: Tolerance, checkZeroVec?: boolean): boolean;
isParallel(vec: Vector3, tol?: Tolerance, checkZeroVec?: boolean): boolean;
isSameDirection(vec: Vector3, tol?: Tolerance, checkZeroVec?: boolean): boolean;
isOpposite(vec: Vector3, tol?: Tolerance, checkZeroVec?: boolean): boolean;
isZero(distTol?: number): boolean;
fromArray(array: number[] | ArrayLike<number>, offset?: number): this;
toArray(array?: number[], offset?: number): number[];
random(): this;
}
export { Vector3 };