/** * @license * Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ import { Vec3Array, Mat4Array, Mat3Array, QuatArray } from './common'; export type { Vec3Array }; /** * Creates a new, empty vec3 * * @returns a new 3D vector */ export declare function create(): Vec3Array; /** * Creates a new vec3 initialized with values from an existing vector * * @param a vector to clone * @returns a new 3D vector */ export declare function clone(a: number[]): Vec3Array; /** * Creates a new vec3 initialized with the given values * * @param x X component * @param y Y component * @param z Z component * @returns a new 3D vector */ export declare function fromValues(x: number, y: number, z: number): Vec3Array; /** * Copy the values from one vec3 to another * * @param out the receiving vector * @param a the source vector * @returns out */ export declare function copy(out: Vec3Array, a: Vec3Array): Vec3Array; /** * Set the components of a vec3 to the given values * * @param out the receiving vector * @param x X component * @param y Y component * @param z Z component * @returns out */ export declare function set(out: Vec3Array, x: number, y: number, z: number): Vec3Array; /** * Adds two vec3's * * @param out the receiving vector * @param a the first operand * @param b the second operand * @returns out */ export declare function add(out: Vec3Array, a: Vec3Array, b: Vec3Array): Vec3Array; /** * Subtracts vector b from vector a * * @param out the receiving vector * @param a the first operand * @param b the second operand * @returns out */ export declare function subtract(out: Vec3Array, a: Vec3Array, b: Vec3Array): Vec3Array; /** * Alias for {@link vec3.subtract} * @function */ export declare const sub: typeof subtract; /** * Multiplies two vec3's * * @param out the receiving vector * @param a the first operand * @param b the second operand * @returns out */ export declare function multiply(out: Vec3Array, a: Vec3Array, b: Vec3Array): Vec3Array; /** * Alias for {@link vec3.multiply} * @function */ export declare const mul: typeof multiply; /** * Divides two vec3's * * @param out the receiving vector * @param a the first operand * @param b the second operand * @returns out */ export declare function divide(out: Vec3Array, a: Vec3Array, b: Vec3Array): Vec3Array; /** * Alias for {@link vec3.divide} * @function */ export declare const div: typeof divide; /** * Returns the minimum of two vec3's * * @param out the receiving vector * @param a the first operand * @param b the second operand * @returns out */ export declare function min(out: Vec3Array, a: Vec3Array, b: Vec3Array): Vec3Array; /** * Returns the maximum of two vec3's * * @param out the receiving vector * @param a the first operand * @param b the second operand * @returns out */ export declare function max(out: Vec3Array, a: Vec3Array, b: Vec3Array): Vec3Array; /** * Scales a vec3 by a scalar number * * @param out the receiving vector * @param a the vector to scale * @param b amount to scale the vector by * @returns out */ export declare function scale(out: Vec3Array, a: Vec3Array, b: number): Vec3Array; /** * Adds two vec3's after scaling the second operand by a scalar value * * @param out the receiving vector * @param a the first operand * @param b the second operand * @param scale the amount to scale b by before adding * @returns out */ export declare function scaleAndAdd(out: Vec3Array, a: Vec3Array, b: Vec3Array, scale: number): Vec3Array; /** * Calculates the euclidian distance between two vec3's * * @param a the first operand * @param b the second operand * @returns distance between a and b */ export declare function distance(a: Vec3Array, b: Vec3Array): number; /** * Alias for {@link vec3.distance} * @function */ export declare const dist: typeof distance; /** * Calculates the squared euclidian distance between two vec3's * * @param a the first operand * @param b the second operand * @returns squared distance between a and b */ export declare function squaredDistance(a: Vec3Array, b: Vec3Array): number; /** * Alias for {@link vec3.squaredDistance} * @function */ export declare const sqrDist: typeof squaredDistance; /** * Calculates the length of a vec3 * * @param a vector to calculate length of * @returns length of a */ export declare function length(a: Vec3Array): number; /** * Alias for {@link vec3.length} * @function */ export declare const len: typeof length; /** * Calculates the squared length of a vec3 * * @param a vector to calculate squared length of * @returns squared length of a */ export declare function squaredLength(a: Vec3Array): number; /** * Alias for {@link vec3.squaredLength} * @function */ export declare const sqrLen: typeof squaredLength; /** * Negates the components of a vec3 * * @param out the receiving vector * @param a vector to negate * @returns out */ export declare function negate(out: Vec3Array, a: Vec3Array): Vec3Array; /** * Returns the inverse of the components of a vec3 * * @param out the receiving vector * @param a vector to invert * @returns out */ export declare function inverse(out: Vec3Array, a: Vec3Array): Vec3Array; /** * Normalize a vec3 * * @param out the receiving vector * @param a vector to normalize * @returns out */ export declare function normalize(out: Vec3Array, a: Vec3Array): Vec3Array; /** * Calculates the dot product of two vec3's * * @param a the first operand * @param b the second operand * @returns dot product of a and b */ export declare function dot(a: Vec3Array, b: Vec3Array): number; /** * Computes the cross product of two vec3's * * @param out the receiving vector * @param a the first operand * @param b the second operand * @returns out */ export declare function cross(out: Vec3Array, a: Vec3Array, b: Vec3Array): Vec3Array; /** * Performs a linear interpolation between two vec3's * * @param out the receiving vector * @param a the first operand * @param b the second operand * @param t interpolation amount between the two inputs * @returns out */ export declare function lerp(out: Vec3Array, a: Vec3Array, b: Vec3Array, t: number): Vec3Array; /** * Generates a random vector with the given scale * * @param out the receiving vector * @param [scale] Length of the resulting vector. If ommitted, a unit vector will be returned * @returns out */ export declare function random(out: Vec3Array, scale: number): Vec3Array; /** * Transforms the vec3 with a mat4. * 4th vector component is implicitly '1' * * @param out the receiving vector * @param a the vector to transform * @param m matrix to transform with * @returns out */ export declare function transformMat4(out: Vec3Array, a: Vec3Array, m: Mat4Array): Vec3Array; /** * Transforms the vec3 with a mat3. * * @param out the receiving vector * @param a the vector to transform * @param m the 3x3 matrix to transform with * @returns out */ export declare function transformMat3(out: Vec3Array, a: Vec3Array, m: Mat3Array): Vec3Array; /** * Transforms the vec3 with a quat * * @param out the receiving vector * @param a the vector to transform * @param q quaternion to transform with * @returns out */ export declare function transformQuat(out: Vec3Array, a: Vec3Array, q: QuatArray): Vec3Array; /** * Rotate a 3D vector around the x-axis * @param out The receiving vec3 * @param a The vec3 point to rotate * @param b The origin of the rotation * @param c The angle of rotation * @returns out */ export declare function rotateX(out: Vec3Array, a: Vec3Array, b: Vec3Array, c: number): Vec3Array; /** * Rotate a 3D vector around the y-axis * @param out The receiving vec3 * @param a The vec3 point to rotate * @param b The origin of the rotation * @param c The angle of rotation * @returns out */ export declare function rotateY(out: Vec3Array, a: Vec3Array, b: Vec3Array, c: number): Vec3Array; /** * Rotate a 3D vector around the z-axis * @param out The receiving vec3 * @param a The vec3 point to rotate * @param b The origin of the rotation * @param c The angle of rotation * @returns out */ export declare function rotateZ(out: Vec3Array, a: Vec3Array, b: Vec3Array, c: number): Vec3Array; /** * Perform some operation over an array of vec3s. * * @param a the array of vectors to iterate over * @param stride Number of elements between the start of each vec3. If 0 assumes tightly packed * @param offset Number of elements to skip at the beginning of the array * @param count Number of vec3s to iterate over. If 0 iterates over entire array * @param fn Function to call for each vector in the array * @param arg additional argument to pass to fn * @returns a * @function */ export declare const forEach: (a: { readonly length: number; [n: number]: number; }, stride: number | undefined, offset: number | undefined, count: number | undefined, fn: undefined extends T ? (a: Vec3Array, b: Vec3Array) => void : (a: Vec3Array, b: Vec3Array, arg: T) => void, arg?: T) => { [n: number]: number; readonly length: number; }; /** * Get the angle between two 3D vectors * @param a The first operand * @param b The second operand * @returns The angle in radians */ export declare function angle(a: Vec3Array, b: Vec3Array): number;