Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@math.gl/core

Package Overview
Dependencies
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@math.gl/core - npm Package Compare versions

Comparing version 3.6.0-alpha.1 to 3.6.0-alpha.2

dist/es5/lib/gl-matrix.d.js

92

dist/classes/base/math-array.d.ts

@@ -1,36 +0,66 @@

export default class MathArray extends Array<any> {
constructor(arrayLength?: number);
constructor(arrayLength: number);
constructor(...items: any[]);
get ELEMENTS(): number;
clone(): any;
from(arrayOrObject: any): any;
fromArray(array: any, offset?: number): MathArray;
to(arrayOrObject: any): any;
import { NumericArray } from '@math.gl/types';
import { ConfigurationOptions } from '../../lib/common';
/** Base class for vectors and matrices */
export default abstract class MathArray extends Array<number> {
/** Number of elements (values) in this array */
abstract get ELEMENTS(): number;
abstract copy(vector: Readonly<NumericArray>): this;
abstract fromObject(object: object): this;
/**
* Clone the current object
* @returns a new copy of this object
*/
clone(): this;
fromArray(array: Readonly<NumericArray>, offset?: number): this;
toArray<TypedArray>(targetArray: TypedArray, offset?: number): TypedArray;
toArray(targetArray?: number[], offset?: number): NumericArray;
from(arrayOrObject: Readonly<NumericArray> | object): this;
to<T extends NumericArray | object>(arrayOrObject: T): T;
toTarget(target: any): any;
toArray(array?: any[], offset?: number): any[];
/** @deprecated */
toFloat32Array(): Float32Array;
formatString(opts: any): string;
equals(array: any): boolean;
exactEquals(array: any): boolean;
negate(): MathArray;
lerp(a: any, b: any, t: any): MathArray;
min(vector: any): MathArray;
max(vector: any): MathArray;
clamp(minVector: any, maxVector: any): MathArray;
add(...vectors: any[]): MathArray;
subtract(...vectors: any[]): MathArray;
scale(scale: any): any;
sub(a: any): MathArray;
setScalar(a: any): MathArray;
addScalar(a: any): MathArray;
subScalar(a: any): MathArray;
multiplyScalar(scalar: any): MathArray;
divideScalar(a: any): any;
clampScalar(min: any, max: any): MathArray;
multiplyByScalar(scalar: any): any;
get elements(): MathArray;
check(): MathArray;
toString(): string;
/** Formats string according to options */
formatString(opts: ConfigurationOptions): string;
equals(array: Readonly<NumericArray>): boolean;
exactEquals(array: Readonly<NumericArray>): boolean;
/** Negates all values in this object */
negate(): this;
/** Linearly interpolates between two values */
lerp(a: Readonly<NumericArray>, t: number): this;
lerp(a: Readonly<NumericArray>, b: Readonly<NumericArray>, t: number): this;
/** Minimal */
min(vector: Readonly<NumericArray>): this;
/** Maximal */
max(vector: Readonly<NumericArray>): this;
clamp(minVector: Readonly<NumericArray>, maxVector: Readonly<NumericArray>): this;
add(...vectors: Readonly<NumericArray>[]): this;
subtract(...vectors: Readonly<NumericArray>[]): this;
scale(scale: number | Readonly<NumericArray>): this;
/**
* Multiplies all elements by `scale`
* Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
*/
multiplyByScalar(scalar: number): this;
/** Throws an error if array length is incorrect or contains illegal values */
check(): this;
/** Returns false if the array length is incorrect or contains illegal values */
validate(): boolean;
/** @deprecated */
sub(a: Readonly<NumericArray>): this;
/** @deprecated */
setScalar(a: number): this;
/** @deprecated */
addScalar(a: number): this;
/** @deprecated */
subScalar(a: number): this;
/** @deprecated */
multiplyScalar(scalar: number): this;
/** @deprecated */
divideScalar(a: number): this;
/** @deprecated */
clampScalar(min: number, max: number): this;
/** @deprecated */
get elements(): NumericArray;
}
//# sourceMappingURL=math-array.d.ts.map

@@ -1,36 +0,13 @@

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import { config, formatValue, equals, isArray } from '../../lib/common';
import assert from '../../lib/assert';
/** Base class for vectors and matrices */
export default class MathArray extends Array {
// Defined by derived class
get ELEMENTS() {
assert(false);
return 0;
}
// Common methods
/**
* Clone the current object
* @returns a new copy of this object
*/
clone() {
// @ts-ignore error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
return new this.constructor().copy(this);
// @ts-expect-error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
return new this.constructor().copy(this); // eslint-disable-line
}
from(arrayOrObject) {
// @ts-ignore error TS2339: Property 'copy' does not exist on type 'MathArray'.
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
}
fromArray(array, offset = 0) {

@@ -42,7 +19,17 @@ for (let i = 0; i < this.ELEMENTS; ++i) {

}
toArray(targetArray = [], offset = 0) {
for (let i = 0; i < this.ELEMENTS; ++i) {
targetArray[offset + i] = this[i];
}
return targetArray;
}
from(arrayOrObject) {
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
}
to(arrayOrObject) {
// @ts-ignore
if (arrayOrObject === this) {
return this;
}
// @ts-ignore error TS2339: Property 'toObject' does not exist on type 'MathArray'.
// @ts-expect-error TS2339: Property 'toObject' does not exist on type 'MathArray'.
return isArray(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject);

@@ -53,8 +40,3 @@ }

}
toArray(array = [], offset = 0) {
for (let i = 0; i < this.ELEMENTS; ++i) {
array[offset + i] = this[i];
}
return array;
}
/** @deprecated */
toFloat32Array() {

@@ -66,2 +48,3 @@ return new Float32Array(this);

}
/** Formats string according to options */
formatString(opts) {

@@ -97,2 +80,3 @@ let string = '';

// Modifiers
/** Negates all values in this object */
negate() {

@@ -106,5 +90,3 @@ for (let i = 0; i < this.ELEMENTS; ++i) {

if (t === undefined) {
t = b;
b = a;
a = this; // eslint-disable-line
return this.lerp(this, a, b);
}

@@ -117,2 +99,3 @@ for (let i = 0; i < this.ELEMENTS; ++i) {

}
/** Minimal */
min(vector) {

@@ -124,2 +107,3 @@ for (let i = 0; i < this.ELEMENTS; ++i) {

}
/** Maximal */
max(vector) {

@@ -154,15 +138,46 @@ for (let i = 0; i < this.ELEMENTS; ++i) {

scale(scale) {
if (Array.isArray(scale)) {
// @ts-ignore error TS2339: Property 'multiply' does not exist on type 'MathArray'.
return this.multiply(scale);
if (typeof scale === 'number') {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] *= scale;
}
}
else {
for (let i = 0; i < this.ELEMENTS && i < scale.length; ++i) {
this[i] *= scale[i];
}
}
return this.check();
}
/**
* Multiplies all elements by `scale`
* Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
*/
multiplyByScalar(scalar) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] *= scale;
this[i] *= scalar;
}
return this.check();
}
// Debug checks
/** Throws an error if array length is incorrect or contains illegal values */
check() {
if (config.debug && !this.validate()) {
throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
}
return this;
}
/** Returns false if the array length is incorrect or contains illegal values */
validate() {
let valid = this.length === this.ELEMENTS;
for (let i = 0; i < this.ELEMENTS; ++i) {
valid = valid && Number.isFinite(this[i]);
}
return valid;
}
// three.js compatibility
/** @deprecated */
sub(a) {
return this.subtract(a);
}
/** @deprecated */
setScalar(a) {

@@ -174,2 +189,3 @@ for (let i = 0; i < this.ELEMENTS; ++i) {

}
/** @deprecated */
addScalar(a) {

@@ -181,5 +197,7 @@ for (let i = 0; i < this.ELEMENTS; ++i) {

}
/** @deprecated */
subScalar(a) {
return this.addScalar(-a);
}
/** @deprecated */
multiplyScalar(scalar) {

@@ -193,5 +211,7 @@ // Multiplies all elements

}
/** @deprecated */
divideScalar(a) {
return this.scale(1 / a);
return this.multiplyByScalar(1 / a);
}
/** @deprecated */
clampScalar(min, max) {

@@ -203,24 +223,6 @@ for (let i = 0; i < this.ELEMENTS; ++i) {

}
// Cesium compatibility
multiplyByScalar(scalar) {
return this.scale(scalar);
}
// THREE.js compatibility
/** @deprecated */
get elements() {
return this;
}
// Debug checks
check() {
if (config.debug && !this.validate()) {
throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
}
return this;
}
validate() {
let valid = this.length === this.ELEMENTS;
for (let i = 0; i < this.ELEMENTS; ++i) {
valid = valid && Number.isFinite(this[i]);
}
return valid;
}
}

@@ -1,12 +0,14 @@

export default class Matrix extends MathArray<any> {
constructor(arrayLength: number);
constructor(...items: number[]);
get RANK(): number;
getElementIndex(row: any, col: any): any;
getElement(row: any, col: any): number;
setElement(row: any, col: any, value: any): Matrix;
getColumn(columnIndex: any, result?: any[]): any[];
setColumn(columnIndex: any, columnVector: any): Matrix;
import { NumericArray } from '@math.gl/types';
import MathArray from './math-array';
/** Base class for matrices */
export default abstract class Matrix extends MathArray {
abstract get RANK(): number;
toString(): string;
getElementIndex(row: number, col: number): number;
getElement(row: number, col: number): number;
setElement(row: number, col: number, value: number): this;
getColumn<NumArrayT>(columnIndex: number, result: NumArrayT): NumArrayT;
getColumn(columnIndex: number): number[];
setColumn(columnIndex: number, columnVector: Readonly<NumericArray>): this;
}
import MathArray from "./math-array";
//# sourceMappingURL=matrix.d.ts.map
import MathArray from './math-array';
import { checkNumber } from '../../lib/validators';
import { config } from '../../lib/common';
import assert from '../../lib/assert';
/** Base class for matrices */
export default class Matrix extends MathArray {
// Defined by derived class
get ELEMENTS() {
assert(false);
return 0;
}
get RANK() {
assert(false);
return 0;
}
// fromObject(object) {

@@ -24,2 +15,3 @@ // const array = object.elements;

// }
// TODO better override formatString?
toString() {

@@ -26,0 +18,0 @@ let string = '[';

@@ -1,32 +0,44 @@

export default class Vector extends MathArray<any> {
constructor(arrayLength: number);
constructor(...items: number[]);
copy(vector: any): Vector;
set x(arg: any);
get x(): any;
0: any;
set y(arg: any);
get y(): any;
1: any;
import { NumericArray } from '@math.gl/types';
import MathArray from './math-array';
/** Base class for vectors with at least 2 elements */
export default abstract class Vector extends MathArray {
get x(): number;
set x(value: number);
get y(): number;
set y(value: number);
/**
* Returns the length of the vector from the origin to the point described by this vector
*
* @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
* Instead we provide `len` and `magnitude`
*/
len(): number;
/**
* Returns the length of the vector from the origin to the point described by this vector
*/
magnitude(): number;
/**
* Returns the squared length of the vector from the origin to the point described by this vector
*/
lengthSquared(): number;
/**
* Returns the squared length of the vector from the origin to the point described by this vector
*/
magnitudeSquared(): number;
distance(mathArray: any): number;
distanceSquared(mathArray: any): any;
dot(mathArray: any): any;
normalize(): any;
multiply(...vectors: any[]): any;
divide(...vectors: any[]): any;
distance(mathArray: Readonly<NumericArray>): number;
distanceSquared(mathArray: Readonly<NumericArray>): number;
dot(mathArray: Readonly<NumericArray>): number;
normalize(): this;
multiply(...vectors: Readonly<NumericArray>[]): this;
divide(...vectors: Readonly<NumericArray>[]): this;
lengthSq(): number;
distanceTo(vector: any): number;
distanceToSquared(vector: any): any;
getComponent(i: any): any;
setComponent(i: any, value: any): any;
addVectors(a: any, b: any): any;
subVectors(a: any, b: any): any;
multiplyVectors(a: any, b: any): any;
addScaledVector(a: any, b: any): any;
distanceTo(vector: Readonly<NumericArray>): number;
distanceToSquared(vector: Readonly<NumericArray>): number;
getComponent(i: number): number;
setComponent(i: number, value: number): this;
addVectors(a: Readonly<NumericArray>, b: Readonly<NumericArray>): this;
subVectors(a: Readonly<NumericArray>, b: Readonly<NumericArray>): this;
multiplyVectors(a: Readonly<NumericArray>, b: Readonly<NumericArray>): this;
addScaledVector(a: Readonly<NumericArray>, b: number): this;
}
import MathArray from "./math-array";
//# sourceMappingURL=vector.d.ts.map
import MathArray from './math-array';
import { checkNumber } from '../../lib/validators';
import assert from '../../lib/assert';
/** Base class for vectors with at least 2 elements */
export default class Vector extends MathArray {
get ELEMENTS() {
assert(false);
return 0;
}
// VIRTUAL METHODS
copy(vector) {
assert(false);
return this;
}
// ACCESSORS

@@ -27,10 +19,20 @@ get x() {

}
// NOTE: `length` is a reserved word for Arrays, so we can't use `v.length()`
// Offer `len` and `magnitude`
/**
* Returns the length of the vector from the origin to the point described by this vector
*
* @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
* Instead we provide `len` and `magnitude`
*/
len() {
return Math.sqrt(this.lengthSquared());
}
/**
* Returns the length of the vector from the origin to the point described by this vector
*/
magnitude() {
return this.len();
}
/**
* Returns the squared length of the vector from the origin to the point described by this vector
*/
lengthSquared() {

@@ -43,2 +45,5 @@ let length = 0;

}
/**
* Returns the squared length of the vector from the origin to the point described by this vector
*/
magnitudeSquared() {

@@ -75,14 +80,2 @@ return this.lengthSquared();

}
// negate() {
// for (let i = 0; i < this.ELEMENTS; ++i) {
// this[i] = -this[i];
// }
// return this.check();
// }
// inverse() {
// for (let i = 0; i < this.ELEMENTS; ++i) {
// this[i] = 1 / this[i];
// }
// return this.check();
// }
multiply(...vectors) {

@@ -133,5 +126,5 @@ for (const vector of vectors) {

addScaledVector(a, b) {
// @ts-ignore error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
// @ts-expect-error error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
return this.add(new this.constructor(a).multiplyScalar(b));
}
}

@@ -1,12 +0,24 @@

export default class Euler extends MathArray<any> {
static get ZYX(): number;
static get YXZ(): number;
static get XZY(): number;
static get ZXY(): number;
static get YZX(): number;
static get XYZ(): number;
static get RollPitchYaw(): number;
static get DefaultOrder(): number;
static get RotationOrders(): string[];
static rotationOrder(order: any): string;
import MathArray from './base/math-array';
import Quaternion from './quaternion';
import { NumericArray } from '@math.gl/types';
declare enum RotationOrder {
ZYX = 0,
YXZ = 1,
XZY = 2,
ZXY = 3,
YZX = 4,
XYZ = 5
}
export default class Euler extends MathArray {
static get ZYX(): RotationOrder;
static get YXZ(): RotationOrder;
static get XZY(): RotationOrder;
static get ZXY(): RotationOrder;
static get YZX(): RotationOrder;
static get XYZ(): RotationOrder;
static get RollPitchYaw(): RotationOrder;
static get DefaultOrder(): RotationOrder;
static get RotationOrders(): typeof RotationOrder;
static rotationOrder(order: RotationOrder): string;
get ELEMENTS(): number;
/**

@@ -19,56 +31,48 @@ * @class

*/
constructor(x?: number | number[], y?: number | undefined, z?: number | undefined, order?: number | undefined, ...args: any[]);
fromQuaternion(quaternion: any): Euler;
copy(array: any): any;
0: any;
1: any;
2: any;
3: any;
set(x: number, y: number, z: number, order: any): any;
constructor(x?: number, y?: number, z?: number, order?: RotationOrder);
fromQuaternion(quaternion: Readonly<NumericArray>): this;
fromObject(object: object): this;
copy(array: Readonly<NumericArray>): this;
set(x: number, y: number, z: number, order: RotationOrder): this;
validate(): boolean;
toArray4(array?: any[], offset?: number): any[];
toVector3(result?: number[]): number[];
set x(arg: number);
/** @type {number} */
toArray(array?: NumericArray, offset?: number): NumericArray;
toArray4(array?: NumericArray, offset?: number): NumericArray;
toVector3(result?: NumericArray): NumericArray;
get x(): number;
set y(arg: number);
/** @type {number} */
set x(value: number);
get y(): number;
set z(arg: number);
/** @type {number} */
set y(value: number);
get z(): number;
set alpha(arg: any);
get alpha(): any;
set beta(arg: any);
get beta(): any;
set gamma(arg: any);
get gamma(): any;
set phi(arg: any);
get phi(): any;
set theta(arg: any);
get theta(): any;
set psi(arg: any);
get psi(): any;
set roll(arg: number);
/** @type {number} */
set z(value: number);
get alpha(): number;
set alpha(value: number);
get beta(): number;
set beta(value: number);
get gamma(): number;
set gamma(value: number);
get phi(): number;
set phi(value: number);
get theta(): number;
set theta(value: number);
get psi(): number;
set psi(value: number);
get roll(): number;
set pitch(arg: number);
/** @type {number} */
set roll(value: number);
get pitch(): number;
set yaw(arg: number);
/** @type {number} */
set pitch(value: number);
get yaw(): number;
set order(arg: any);
get order(): any;
fromVector3(v: any, order: any): any;
fromRollPitchYaw(roll: any, pitch: any, yaw: any): any;
fromRotationMatrix(m: any, order?: number): any;
getRotationMatrix(m: any): any;
set yaw(value: number);
get order(): RotationOrder;
set order(value: RotationOrder);
fromVector3(v: Readonly<NumericArray>, order: RotationOrder): this;
fromArray(array: Readonly<NumericArray>, offset?: number): this;
fromRollPitchYaw(roll: number, pitch: number, yaw: number): this;
fromRotationMatrix(m: Readonly<NumericArray>, order?: RotationOrder): this;
getRotationMatrix(m: NumericArray): NumericArray;
getQuaternion(): Quaternion;
_fromRotationMatrix(m: any, order?: number): Euler;
_getRotationMatrix(result: any): any;
_fromRotationMatrix(m: Readonly<NumericArray>, order?: RotationOrder): this;
_getRotationMatrix(result: NumericArray): NumericArray;
toQuaternion(): Quaternion;
}
import MathArray from "./base/math-array";
import Quaternion from "./quaternion";
export {};
//# sourceMappingURL=euler.d.ts.map
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// MIT License
import MathArray from './base/math-array';
import Quaternion from './quaternion';
import { clamp } from '../lib/common';
import { checkNumber } from '../lib/validators';
import Quaternion from './quaternion';
// Internal constants
const ERR_UNKNOWN_ORDER = 'Unknown Euler angle order';
const ALMOST_ONE = 0.99999;
function validateOrder(value) {
return value >= 0 && value < 6;
}
function checkOrder(value) {
if (value < 0 && value >= 6) {
throw new Error(ERR_UNKNOWN_ORDER);
}
return value;
}
var RotationOrder;
(function (RotationOrder) {
RotationOrder[RotationOrder["ZYX"] = 0] = "ZYX";
RotationOrder[RotationOrder["YXZ"] = 1] = "YXZ";
RotationOrder[RotationOrder["XZY"] = 2] = "XZY";
RotationOrder[RotationOrder["ZXY"] = 3] = "ZXY";
RotationOrder[RotationOrder["YZX"] = 4] = "YZX";
RotationOrder[RotationOrder["XYZ"] = 5] = "XYZ";
})(RotationOrder || (RotationOrder = {}));
export default class Euler extends MathArray {
// static XYZ = 0;
// static YZX = 1;
// static ZXY = 2;
// static XZY = 3;
// static YXZ = 4;
// static ZYX = 5;
// static RollPitchYaw = 0;
// static DefaultOrder = 0;
// Constants
/* eslint-disable no-multi-spaces, brace-style, no-return-assign */
static get ZYX() {
return 0;
return RotationOrder.ZYX;
}
static get YXZ() {
return 1;
return RotationOrder.YXZ;
}
static get XZY() {
return 2;
return RotationOrder.XZY;
}
static get ZXY() {
return 3;
return RotationOrder.ZXY;
}
static get YZX() {
return 4;
return RotationOrder.YZX;
}
static get XYZ() {
return 5;
return RotationOrder.XYZ;
}
static get RollPitchYaw() {
return 0;
return RotationOrder.ZYX;
}
static get DefaultOrder() {
return Euler.ZYX;
return RotationOrder.ZYX;
}
static get RotationOrders() {
return ['ZYX', 'YXZ', 'XZY', 'ZXY', 'YZX', 'XYZ'];
return RotationOrder;
}
static rotationOrder(order) {
return Euler.RotationOrders[order];
return RotationOrder[order];
}

@@ -80,3 +54,2 @@ get ELEMENTS() {

}
/* eslint-enable no-multi-spaces, brace-style, no-return-assign */
/**

@@ -95,6 +68,6 @@ * @class

// eslint-disable-next-line prefer-rest-params
// @ts-expect-error
this.fromVector3(...arguments);
}
else {
// @ts-ignore error TS2345: Argument of type 'number | [number, number, number, number]' not assignable to 'number'
this.set(x, y, z, order);

@@ -106,14 +79,18 @@ }

const ysqr = y * y;
const t0 = -2.0 * (ysqr + z * z) + 1.0;
const t1 = +2.0 * (x * y + w * z);
let t2 = -2.0 * (x * z - w * y);
const t3 = +2.0 * (y * z + w * x);
const t4 = -2.0 * (x * x + ysqr) + 1.0;
t2 = t2 > 1.0 ? 1.0 : t2;
t2 = t2 < -1.0 ? -1.0 : t2;
const t0 = -2 * (ysqr + z * z) + 1;
const t1 = +2 * (x * y + w * z);
let t2 = -2 * (x * z - w * y);
const t3 = +2 * (y * z + w * x);
const t4 = -2 * (x * x + ysqr) + 1;
t2 = t2 > 1 ? 1 : t2;
t2 = t2 < -1 ? -1 : t2;
const roll = Math.atan2(t3, t4);
const pitch = Math.asin(t2);
const yaw = Math.atan2(t1, t0);
return new Euler(roll, pitch, yaw, Euler.RollPitchYaw);
return this.set(roll, pitch, yaw, Euler.RollPitchYaw);
}
fromObject(object) {
throw new Error('not implemented');
// return this.set(object.x, object.y, object.z, object.order);
}
// fromQuaternion(q, order) {

@@ -128,2 +105,3 @@ // this._fromRotationMat[-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];

this[2] = array[2];
// @ts-expect-error
this[3] = Number.isFinite(array[3]) || this.order;

@@ -170,3 +148,2 @@ return this.check();

// x, y, z angle notation (note: only corresponds to axis in XYZ orientation)
/** @type {number} */
get x() {

@@ -178,3 +155,2 @@ return this[0];

}
/** @type {number} */
get y() {

@@ -186,3 +162,2 @@ return this[1];

}
/** @type {number} */
get z() {

@@ -233,3 +208,2 @@ return this[2];

// roll, pitch, yaw angle notation
/** @type {number} */
get roll() {

@@ -241,3 +215,2 @@ return this[0];

}
/** @type {number} */
get pitch() {

@@ -249,3 +222,2 @@ return this[1];

}
/** @type {number} */
get yaw() {

@@ -264,3 +236,2 @@ return this[2];

}
/* eslint-disable no-multi-spaces, brace-style, no-return-assign */
// Constructors

@@ -282,3 +253,3 @@ fromVector3(v, order) {

fromRollPitchYaw(roll, pitch, yaw) {
return this.set(roll, pitch, yaw, Euler.ZYX);
return this.set(roll, pitch, yaw, RotationOrder.ZYX);
}

@@ -296,14 +267,14 @@ fromRotationMatrix(m, order = Euler.DefaultOrder) {

const q = new Quaternion();
switch (this[3]) {
case Euler.XYZ:
switch (this[4]) {
case RotationOrder.XYZ:
return q.rotateX(this[0]).rotateY(this[1]).rotateZ(this[2]);
case Euler.YXZ:
case RotationOrder.YXZ:
return q.rotateY(this[0]).rotateX(this[1]).rotateZ(this[2]);
case Euler.ZXY:
case RotationOrder.ZXY:
return q.rotateZ(this[0]).rotateX(this[1]).rotateY(this[2]);
case Euler.ZYX:
case RotationOrder.ZYX:
return q.rotateZ(this[0]).rotateY(this[1]).rotateX(this[2]);
case Euler.YZX:
case RotationOrder.YZX:
return q.rotateY(this[0]).rotateZ(this[1]).rotateX(this[2]);
case Euler.XZY:
case RotationOrder.XZY:
return q.rotateX(this[0]).rotateZ(this[1]).rotateY(this[2]);

@@ -315,3 +286,3 @@ default:

// INTERNAL METHODS
// Concersion from Euler to rotation matrix and from matrix to Euler
// Conversion from Euler to rotation matrix and from matrix to Euler
// Adapted from three.js under MIT license

@@ -325,6 +296,5 @@ // // WARNING: this discards revolution information -bhouston

// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
const te = m.elements;
const m11 = te[0], m12 = te[4], m13 = te[8];
const m21 = te[1], m22 = te[5], m23 = te[9];
const m31 = te[2], m32 = te[6], m33 = te[10];
const m11 = m[0], m12 = m[4], m13 = m[8];
const m21 = m[1], m22 = m[5], m23 = m[9];
const m31 = m[2], m32 = m[6], m33 = m[10];
order = order || this[3];

@@ -521,1 +491,11 @@ switch (order) {

}
// HELPER FUNCTIONS
function validateOrder(value) {
return value >= 0 && value < 6;
}
function checkOrder(value) {
if (value < 0 && value >= 6) {
throw new Error(ERR_UNKNOWN_ORDER);
}
return value;
}

@@ -1,43 +0,60 @@

export default class Matrix3 extends Matrix<any> {
static get IDENTITY(): any;
static get ZERO(): any;
constructor(array: any, ...args: any[]);
get INDICES(): Readonly<{
COL0ROW0: number;
COL0ROW1: number;
COL0ROW2: number;
COL1ROW0: number;
COL1ROW1: number;
COL1ROW2: number;
COL2ROW0: number;
COL2ROW1: number;
COL2ROW2: number;
}>;
copy(array: any): any;
0: any;
1: any;
2: any;
3: any;
4: any;
5: any;
6: any;
7: any;
8: any;
set(m00: any, m10: any, m20: any, m01: any, m11: any, m21: any, m02: any, m12: any, m22: any): any;
setRowMajor(m00: any, m01: any, m02: any, m10: any, m11: any, m12: any, m20: any, m21: any, m22: any): any;
determinant(): any;
identity(): any;
fromQuaternion(q: any): any;
transpose(): any;
invert(): any;
multiplyLeft(a: any): any;
multiplyRight(a: any): any;
rotate(radians: any): any;
translate(vec: any): any;
transform(vector: any, result: any): any;
transformVector(vector: any, result: any): any;
transformVector2(vector: any, result: any): any;
transformVector3(vector: any, result: any): any;
import Matrix from './base/matrix';
import { NumericArray } from '@math.gl/types';
declare enum INDICES {
COL0ROW0 = 0,
COL0ROW1 = 1,
COL0ROW2 = 2,
COL1ROW0 = 3,
COL1ROW1 = 4,
COL1ROW2 = 5,
COL2ROW0 = 6,
COL2ROW1 = 7,
COL2ROW2 = 8
}
import Matrix from "./base/matrix";
export default class Matrix3 extends Matrix {
static get IDENTITY(): Readonly<Matrix3>;
static get ZERO(): Readonly<Matrix3>;
get ELEMENTS(): number;
get RANK(): number;
get INDICES(): typeof INDICES;
constructor(array?: Readonly<NumericArray>);
/** @deprecated */
constructor(...args: number[]);
copy(array: Readonly<NumericArray>): this;
identity(): this;
/**
*
* @param object
* @returns self
*/
fromObject(object: {
[key: string]: any;
}): this;
fromQuaternion(q: Readonly<NumericArray>): this;
/**
* accepts column major order, stores in column major order
*/
set(m00: number, m10: number, m20: number, m01: number, m11: number, m21: number, m02: number, m12: number, m22: number): this;
/**
* accepts row major order, stores as column major
*/
setRowMajor(m00: number, m01: number, m02: number, m10: number, m11: number, m12: number, m20: number, m21: number, m22: number): this;
determinant(): number;
transpose(): this;
/** Invert a matrix. Note that this can fail if the matrix is not invertible */
invert(): this;
multiplyLeft(a: NumericArray): this;
multiplyRight(a: NumericArray): this;
rotate(radians: number): NumericArray;
scale(factor: NumericArray | number): this;
translate(vec: NumericArray): this;
transform(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
/** @deprecated */
transformVector(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
/** @deprecated */
transformVector2(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
/** @deprecated */
transformVector3(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
}
export {};
//# sourceMappingURL=matrix3.d.ts.map
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// MIT License
import Matrix from './base/matrix';
import { checkVector, deprecated } from '../lib/validators';
// eslint-disable-next-line camelcase
import { checkVector } from '../lib/validators';
/* eslint-disable camelcase */
import { vec4_transformMat3 } from '../lib/gl-matrix-extras';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as mat3 from 'gl-matrix/mat3';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec2 from 'gl-matrix/vec2';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec3 from 'gl-matrix/vec3';
const IDENTITY = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
const ZERO = Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0]);
const INDICES = Object.freeze({
COL0ROW0: 0,
COL0ROW1: 1,
COL0ROW2: 2,
COL1ROW0: 3,
COL1ROW1: 4,
COL1ROW2: 5,
COL2ROW0: 6,
COL2ROW1: 7,
COL2ROW2: 8
});
const constants = {};
var INDICES;
(function (INDICES) {
INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
INDICES[INDICES["COL0ROW1"] = 1] = "COL0ROW1";
INDICES[INDICES["COL0ROW2"] = 2] = "COL0ROW2";
INDICES[INDICES["COL1ROW0"] = 3] = "COL1ROW0";
INDICES[INDICES["COL1ROW1"] = 4] = "COL1ROW1";
INDICES[INDICES["COL1ROW2"] = 5] = "COL1ROW2";
INDICES[INDICES["COL2ROW0"] = 6] = "COL2ROW0";
INDICES[INDICES["COL2ROW1"] = 7] = "COL2ROW1";
INDICES[INDICES["COL2ROW2"] = 8] = "COL2ROW2";
})(INDICES || (INDICES = {}));
const IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
export default class Matrix3 extends Matrix {
static get IDENTITY() {
constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix3(IDENTITY));
return constants.IDENTITY;
return getIdentityMatrix();
}
static get ZERO() {
constants.ZERO = constants.ZERO || Object.freeze(new Matrix3(ZERO));
return constants.ZERO;
return getZeroMatrix();
}

@@ -62,3 +39,3 @@ get ELEMENTS() {

}
constructor(array) {
constructor(array, ...args) {
// PERF NOTE: initialize elements as double precision numbers

@@ -69,2 +46,5 @@ super(-0, -0, -0, -0, -0, -0, -0, -0, -0);

}
else if (args.length > 0) {
this.copy([array, ...args]);
}
else {

@@ -75,2 +55,3 @@ this.identity();

copy(array) {
// Element wise copy for performance
this[0] = array[0];

@@ -87,3 +68,23 @@ this[1] = array[1];

}
// accepts column major order, stores in column major order
// Constructors
identity() {
return this.copy(IDENTITY_MATRIX);
}
/**
*
* @param object
* @returns self
*/
fromObject(object) {
return this.check();
}
// Calculates a 3x3 matrix from the given quaternion
// q quat Quaternion to create matrix from
fromQuaternion(q) {
mat3.fromQuat(this, q);
return this.check();
}
/**
* accepts column major order, stores in column major order
*/
// eslint-disable-next-line max-params

@@ -102,3 +103,5 @@ set(m00, m10, m20, m01, m11, m21, m02, m12, m22) {

}
// accepts row major order, stores as column major
/**
* accepts row major order, stores as column major
*/
// eslint-disable-next-line max-params

@@ -121,12 +124,2 @@ setRowMajor(m00, m01, m02, m10, m11, m12, m20, m21, m22) {

}
// Constructors
identity() {
return this.copy(IDENTITY);
}
// Calculates a 3x3 matrix from the given quaternion
// q quat Quaternion to create matrix from
fromQuaternion(q) {
mat3.fromQuat(this, q);
return this.check();
}
// Modifiers

@@ -137,2 +130,3 @@ transpose() {

}
/** Invert a matrix. Note that this can fail if the matrix is not invertible */
invert() {

@@ -160,3 +154,3 @@ mat3.invert(this, this);

else {
mat3.scale(this, this, [factor, factor, factor]);
mat3.scale(this, this, [factor, factor]);
}

@@ -187,15 +181,30 @@ return this.check();

}
// DEPRECATED IN 3.0
/** @deprecated */
transformVector(vector, result) {
deprecated('Matrix3.transformVector');
return this.transform(vector, result);
}
/** @deprecated */
transformVector2(vector, result) {
deprecated('Matrix3.transformVector');
return this.transform(vector, result);
}
/** @deprecated */
transformVector3(vector, result) {
deprecated('Matrix3.transformVector');
return this.transform(vector, result);
}
}
let ZERO_MATRIX3;
let IDENTITY_MATRIX3;
function getZeroMatrix() {
if (!ZERO_MATRIX3) {
ZERO_MATRIX3 = new Matrix3([0, 0, 0, 0, 0, 0, 0, 0, 0]);
Object.freeze(ZERO_MATRIX3);
}
return ZERO_MATRIX3;
}
function getIdentityMatrix() {
if (!IDENTITY_MATRIX3) {
IDENTITY_MATRIX3 = new Matrix3();
Object.freeze(IDENTITY_MATRIX3);
}
return IDENTITY_MATRIX3;
}

@@ -1,64 +0,110 @@

export default class Matrix4 extends Matrix<any> {
static get IDENTITY(): any;
static get ZERO(): any;
static _computeInfinitePerspectiveOffCenter(result: any, left: any, right: any, bottom: any, top: any, near: any): any;
constructor(array: any, ...args: any[]);
get INDICES(): Readonly<{
COL0ROW0: number;
COL0ROW1: number;
COL0ROW2: number;
COL0ROW3: number;
COL1ROW0: number;
COL1ROW1: number;
COL1ROW2: number;
COL1ROW3: number;
COL2ROW0: number;
COL2ROW1: number;
COL2ROW2: number;
COL2ROW3: number;
COL3ROW0: number;
COL3ROW1: number;
COL3ROW2: number;
COL3ROW3: number;
}>;
copy(array: any): any;
0: any;
1: any;
2: any;
3: any;
4: any;
5: any;
6: any;
7: any;
8: any;
9: any;
10: any;
11: any;
12: any;
13: any;
14: any;
15: any;
set(m00: any, m10: any, m20: any, m30: any, m01: any, m11: any, m21: any, m31: any, m02: any, m12: any, m22: any, m32: any, m03: any, m13: any, m23: any, m33: any): any;
setRowMajor(m00: any, m01: any, m02: any, m03: any, m10: any, m11: any, m12: any, m13: any, m20: any, m21: any, m22: any, m23: any, m30: any, m31: any, m32: any, m33: any): any;
toRowMajor(result: any): any;
identity(): any;
fromQuaternion(q: any): any;
frustum({ left, right, bottom, top, near, far }: {
left: any;
right: any;
bottom: any;
top: any;
near: any;
far: any;
}): any;
lookAt(eye: any, center: any, up: any, ...args: any[]): any;
ortho({ left, right, bottom, top, near, far }: {
left: any;
right: any;
bottom: any;
top: any;
import Matrix from './base/matrix';
import { NumericArray } from '@math.gl/types';
declare enum INDICES {
COL0ROW0 = 0,
COL0ROW1 = 1,
COL0ROW2 = 2,
COL0ROW3 = 3,
COL1ROW0 = 4,
COL1ROW1 = 5,
COL1ROW2 = 6,
COL1ROW3 = 7,
COL2ROW0 = 8,
COL2ROW1 = 9,
COL2ROW2 = 10,
COL2ROW3 = 11,
COL3ROW0 = 12,
COL3ROW1 = 13,
COL3ROW2 = 14,
COL3ROW3 = 15
}
/** 4x4 matrix */
export default class Matrix4 extends Matrix {
static get IDENTITY(): Readonly<Matrix4>;
static get ZERO(): Readonly<Matrix4>;
get ELEMENTS(): number;
get RANK(): number;
get INDICES(): typeof INDICES;
constructor(array?: Readonly<NumericArray>);
copy(array: Readonly<NumericArray>): this;
set(m00: number, m10: number, m20: number, m30: number, m01: number, m11: number, m21: number, m31: number, m02: number, m12: number, m22: number, m32: number, m03: number, m13: number, m23: number, m33: number): this;
setRowMajor(m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): this;
toRowMajor(result: NumericArray): NumericArray;
/** Set to identity matrix */
identity(): this;
/**
*
* @param object
* @returns self
*/
fromObject(object: {
[key: string]: any;
}): this;
/**
* Calculates a 4x4 matrix from the given quaternion
* @param quaternion Quaternion to create matrix from
* @returns self
*/
fromQuaternion(quaternion: Readonly<NumericArray>): this;
/**
* Generates a frustum matrix with the given bounds
* @param view.left - Left bound of the frustum
* @param view.right - Right bound of the frustum
* @param view.bottom - Bottom bound of the frustum
* @param view.top - Top bound of the frustum
* @param view.near - Near bound of the frustum
* @param view.far - Far bound of the frustum. Can be set to Infinity.
* @returns self
*/
frustum(view: {
left: number;
right: number;
bottom: number;
top: number;
near: number;
far?: number;
}): this;
/**
* Generates a look-at matrix with the given eye position, focal point,
* and up axis
* @param view.eye - (vector) Position of the viewer
* @param view.center - (vector) Point the viewer is looking at
* @param view.up - (vector) Up axis
* @returns self
*/
lookAt(view: {
eye: Readonly<NumericArray>;
center: Readonly<NumericArray>;
up: Readonly<NumericArray>;
}): this;
/**
* Generates a orthogonal projection matrix with the given bounds
* from "traditional" view space parameters
* @param view.left - Left bound of the frustum
* @param view.right number Right bound of the frustum
* @param view.bottom - Bottom bound of the frustum
* @param view.top number Top bound of the frustum
* @param view.near - Near bound of the frustum
* @param view.far number Far bound of the frustum
* @returns self
*/
ortho(view: {
left: number;
right: number;
bottom: number;
top: number;
near?: number;
far?: number;
}): any;
orthographic({ fovy, aspect, focalDistance, near, far }: {
}): this;
/**
* Generates an orthogonal projection matrix with the same parameters
* as a perspective matrix (plus focalDistance)
* @param view.fovy Vertical field of view in radians
* @param view.aspect Aspect ratio. Typically viewport width / viewport height
* @param view.focalDistance Distance in the view frustum used for extent calculations
* @param view.near Near bound of the frustum
* @param view.far Far bound of the frustum
* @returns self
*/
orthographic(view: {
fovy?: number;

@@ -69,35 +115,113 @@ aspect?: number;

far?: number;
}): any;
perspective({ fovy, fov, aspect, near, far }?: {
fovy?: any;
fov?: number;
}): this;
/**
* Generates a perspective projection matrix with the given bounds
* @param view.fovy Vertical field of view in radians
* @param view.aspect Aspect ratio. typically viewport width/height
* @param view.near Near bound of the frustum
* @param view.far Far bound of the frustum
* @returns self
*/
perspective(view: {
fovy: number;
aspect?: number;
near?: number;
far?: number;
}): any;
determinant(): any;
getScale(result?: number[]): number[];
getTranslation(result?: number[]): number[];
getRotation(result?: number[], scaleResult?: any): number[];
getRotationMatrix3(result?: number[], scaleResult?: any): number[];
transpose(): any;
invert(): any;
multiplyLeft(a: any): any;
multiplyRight(a: any): any;
rotateX(radians: any): any;
rotateY(radians: any): any;
rotateZ(radians: any): any;
rotateXYZ([rx, ry, rz]: [any, any, any]): any;
rotateAxis(radians: any, axis: any): any;
translate(vec: any): any;
transform(vector: any, result: any): any;
transformAsPoint(vector: any, result: any): any;
transformAsVector(vector: any, result: any): any;
makeRotationX(radians: any): any;
makeTranslation(x: any, y: any, z: any): any;
transformPoint(vector: any, result: any): any;
transformVector(vector: any, result: any): any;
transformDirection(vector: any, result: any): any;
}): this;
determinant(): number;
/**
* Extracts the non-uniform scale assuming the matrix is an affine transformation.
* The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
* @param result
* @returns self
*/
getScale(result?: NumericArray): NumericArray;
/**
* Gets the translation portion, assuming the matrix is a affine transformation matrix.
* @param result
* @returns self
*/
getTranslation(result?: NumericArray): NumericArray;
/**
* Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
* @param result
* @param scaleResult
* @returns self
*/
getRotation(result?: NumericArray, scaleResult?: NumericArray): NumericArray;
/**
*
* @param result
* @param scaleResult
* @returns self
*/
getRotationMatrix3(result?: NumericArray, scaleResult?: NumericArray): NumericArray;
transpose(): this;
invert(): this;
multiplyLeft(a: Readonly<NumericArray>): this;
multiplyRight(a: Readonly<NumericArray>): this;
rotateX(radians: number): this;
rotateY(radians: number): this;
/**
* Rotates a matrix by the given angle around the Z axis.
* @param radians
* @returns self
*/
rotateZ(radians: number): this;
/**
*
* @param param0
* @returns self
*/
rotateXYZ(angleXYZ: Readonly<NumericArray>): this;
/**
*
* @param radians
* @param axis
* @returns self
*/
rotateAxis(radians: number, axis: Readonly<NumericArray>): this;
/**
*
* @param factor
* @returns self
*/
scale(factor: number | Readonly<NumericArray>): this;
/**
*
* @param vec
* @returns self
*/
translate(vector: Readonly<NumericArray>): this;
/**
* Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
* @param vector
* @param result
* @returns self
*/
transform(vector: Readonly<NumericArray>, result: NumericArray): NumericArray;
/**
* Transforms any 2 or 3 element array as point (w implicitly 1)
* @param vector
* @param result
* @returns self
*/
transformAsPoint(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
/**
* Transforms any 2 or 3 element array as vector (w implicitly 0)
* @param vector
* @param result
* @returns self
*/
transformAsVector(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
/** @deprecated */
transformPoint(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
/** @deprecated */
transformVector(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
/** @deprecated */
transformDirection(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
makeRotationX(radians: number): this;
makeTranslation(x: number, y: number, z: number): this;
}
import Matrix from "./base/matrix";
export {};
//# sourceMappingURL=matrix4.d.ts.map
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import { checkVector, deprecated } from '../lib/validators';
// MIT License
import Matrix from './base/matrix';
// eslint-disable-next-line camelcase
import { checkVector } from '../lib/validators';
/* eslint-disable camelcase */
import { vec2_transformMat4AsVector, vec3_transformMat4AsVector } from '../lib/gl-matrix-extras';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as mat4 from 'gl-matrix/mat4';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec2 from 'gl-matrix/vec2';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec3 from 'gl-matrix/vec3';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec4 from 'gl-matrix/vec4';
const IDENTITY = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
const ZERO = Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
const INDICES = Object.freeze({
COL0ROW0: 0,
COL0ROW1: 1,
COL0ROW2: 2,
COL0ROW3: 3,
COL1ROW0: 4,
COL1ROW1: 5,
COL1ROW2: 6,
COL1ROW3: 7,
COL2ROW0: 8,
COL2ROW1: 9,
COL2ROW2: 10,
COL2ROW3: 11,
COL3ROW0: 12,
COL3ROW1: 13,
COL3ROW2: 14,
COL3ROW3: 15
});
const constants = {};
var INDICES;
(function (INDICES) {
INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
INDICES[INDICES["COL0ROW1"] = 1] = "COL0ROW1";
INDICES[INDICES["COL0ROW2"] = 2] = "COL0ROW2";
INDICES[INDICES["COL0ROW3"] = 3] = "COL0ROW3";
INDICES[INDICES["COL1ROW0"] = 4] = "COL1ROW0";
INDICES[INDICES["COL1ROW1"] = 5] = "COL1ROW1";
INDICES[INDICES["COL1ROW2"] = 6] = "COL1ROW2";
INDICES[INDICES["COL1ROW3"] = 7] = "COL1ROW3";
INDICES[INDICES["COL2ROW0"] = 8] = "COL2ROW0";
INDICES[INDICES["COL2ROW1"] = 9] = "COL2ROW1";
INDICES[INDICES["COL2ROW2"] = 10] = "COL2ROW2";
INDICES[INDICES["COL2ROW3"] = 11] = "COL2ROW3";
INDICES[INDICES["COL3ROW0"] = 12] = "COL3ROW0";
INDICES[INDICES["COL3ROW1"] = 13] = "COL3ROW1";
INDICES[INDICES["COL3ROW2"] = 14] = "COL3ROW2";
INDICES[INDICES["COL3ROW3"] = 15] = "COL3ROW3";
})(INDICES || (INDICES = {}));
const DEFAULT_FOVY = (45 * Math.PI) / 180;
const DEFAULT_ASPECT = 1;
const DEFAULT_NEAR = 0.1;
const DEFAULT_FAR = 500;
const IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
/** 4x4 matrix */
export default class Matrix4 extends Matrix {
static get IDENTITY() {
constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix4(IDENTITY));
return constants.IDENTITY;
return getIdentityMatrix();
}
static get ZERO() {
constants.ZERO = constants.ZERO || Object.freeze(new Matrix4(ZERO));
return constants.ZERO;
return getZeroMatrix();
}
get INDICES() {
return INDICES;
}
get ELEMENTS() {

@@ -71,2 +49,5 @@ return 16;

}
get INDICES() {
return INDICES;
}
constructor(array) {

@@ -162,21 +143,37 @@ // PERF NOTE: initialize elements as double precision numbers

// Constructors
/** Set to identity matrix */
identity() {
return this.copy(IDENTITY);
return this.copy(IDENTITY_MATRIX);
}
// Calculates a 4x4 matrix from the given quaternion
// q quat Quaternion to create matrix from
fromQuaternion(q) {
mat4.fromQuat(this, q);
/**
*
* @param object
* @returns self
*/
fromObject(object) {
return this.check();
}
// Generates a frustum matrix with the given bounds
// left Number Left bound of the frustum
// right Number Right bound of the frustum
// bottom Number Bottom bound of the frustum
// top Number Top bound of the frustum
// near Number Near bound of the frustum
// far Number Far bound of the frustum
frustum({ left, right, bottom, top, near, far }) {
/**
* Calculates a 4x4 matrix from the given quaternion
* @param quaternion Quaternion to create matrix from
* @returns self
*/
fromQuaternion(quaternion) {
mat4.fromQuat(this, quaternion);
return this.check();
}
/**
* Generates a frustum matrix with the given bounds
* @param view.left - Left bound of the frustum
* @param view.right - Right bound of the frustum
* @param view.bottom - Bottom bound of the frustum
* @param view.top - Top bound of the frustum
* @param view.near - Near bound of the frustum
* @param view.far - Far bound of the frustum. Can be set to Infinity.
* @returns self
*/
frustum(view) {
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
if (far === Infinity) {
Matrix4._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
}

@@ -188,71 +185,48 @@ else {

}
// eslint-disable-next-line max-params
static _computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
const column0Row0 = (2.0 * near) / (right - left);
const column1Row1 = (2.0 * near) / (top - bottom);
const column2Row0 = (right + left) / (right - left);
const column2Row1 = (top + bottom) / (top - bottom);
const column2Row2 = -1.0;
const column2Row3 = -1.0;
const column3Row2 = -2.0 * near;
result[0] = column0Row0;
result[1] = 0.0;
result[2] = 0.0;
result[3] = 0.0;
result[4] = 0.0;
result[5] = column1Row1;
result[6] = 0.0;
result[7] = 0.0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = column2Row3;
result[12] = 0.0;
result[13] = 0.0;
result[14] = column3Row2;
result[15] = 0.0;
return result;
}
// Generates a look-at matrix with the given eye position, focal point,
// and up axis
// eye vec3 Position of the viewer
// center vec3 Point the viewer is looking at
// up vec3 vec3 pointing up
lookAt(eye, center, up) {
// Signature: lookAt({eye, center = [0, 0, 0], up = [0, 1, 0]}))
if (arguments.length === 1) {
({ eye, center, up } = eye);
}
center = center || [0, 0, 0];
up = up || [0, 1, 0];
/**
* Generates a look-at matrix with the given eye position, focal point,
* and up axis
* @param view.eye - (vector) Position of the viewer
* @param view.center - (vector) Point the viewer is looking at
* @param view.up - (vector) Up axis
* @returns self
*/
lookAt(view) {
const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
mat4.lookAt(this, eye, center, up);
return this.check();
}
// Generates a orthogonal projection matrix with the given bounds
// from "traditional" view space parameters
// left number Left bound of the frustum
// right number Right bound of the frustum
// bottom number Bottom bound of the frustum
// top number Top bound of the frustum
// near number Near bound of the frustum
// far number Far bound of the frustum
ortho({ left, right, bottom, top, near = 0.1, far = 500 }) {
/**
* Generates a orthogonal projection matrix with the given bounds
* from "traditional" view space parameters
* @param view.left - Left bound of the frustum
* @param view.right number Right bound of the frustum
* @param view.bottom - Bottom bound of the frustum
* @param view.top number Top bound of the frustum
* @param view.near - Near bound of the frustum
* @param view.far number Far bound of the frustum
* @returns self
*/
ortho(view) {
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
mat4.ortho(this, left, right, bottom, top, near, far);
return this.check();
}
// Generates an orthogonal projection matrix with the same parameters
// as a perspective matrix (plus focalDistance)
// fovy number Vertical field of view in radians
// aspect number Aspect ratio. typically viewport width/height
// focalDistance distance in the view frustum used for extent calculations
// near number Near bound of the frustum
// far number Far bound of the frustum
orthographic({ fovy = (45 * Math.PI) / 180, aspect = 1, focalDistance = 1, near = 0.1, far = 500 }) {
if (fovy > Math.PI * 2) {
throw Error('radians');
}
/**
* Generates an orthogonal projection matrix with the same parameters
* as a perspective matrix (plus focalDistance)
* @param view.fovy Vertical field of view in radians
* @param view.aspect Aspect ratio. Typically viewport width / viewport height
* @param view.focalDistance Distance in the view frustum used for extent calculations
* @param view.near Near bound of the frustum
* @param view.far Far bound of the frustum
* @returns self
*/
orthographic(view) {
const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
checkRadians(fovy);
const halfY = fovy / 2;
const top = focalDistance * Math.tan(halfY); // focus_plane is the distance from the camera
const right = top * aspect;
return new Matrix4().ortho({
return this.ortho({
left: -right,

@@ -266,13 +240,13 @@ right,

}
// Generates a perspective projection matrix with the given bounds
// fovy number Vertical field of view in radians
// aspect number Aspect ratio. typically viewport width/height
// near number Near bound of the frustum
// far number Far bound of the frustum
perspective({ fovy = undefined, fov = (45 * Math.PI) / 180, // DEPRECATED
aspect = 1, near = 0.1, far = 500 } = {}) {
fovy = fovy || fov;
if (fovy > Math.PI * 2) {
throw Error('radians');
}
/**
* Generates a perspective projection matrix with the given bounds
* @param view.fovy Vertical field of view in radians
* @param view.aspect Aspect ratio. typically viewport width/height
* @param view.near Near bound of the frustum
* @param view.far Far bound of the frustum
* @returns self
*/
perspective(view) {
const { fovy = (45 * Math.PI) / 180, aspect = 1, near = 0.1, far = 500 } = view;
checkRadians(fovy);
mat4.perspective(this, fovy, aspect, near, far);

@@ -285,4 +259,8 @@ return this.check();

}
// Extracts the non-uniform scale assuming the matrix is an affine transformation.
// The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
/**
* Extracts the non-uniform scale assuming the matrix is an affine transformation.
* The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
* @param result
* @returns self
*/
getScale(result = [-0, -0, -0]) {

@@ -298,3 +276,7 @@ // explicit is faster than hypot...

}
// Gets the translation portion, assuming the matrix is a affine transformation matrix.
/**
* Gets the translation portion, assuming the matrix is a affine transformation matrix.
* @param result
* @returns self
*/
getTranslation(result = [-0, -0, -0]) {

@@ -306,5 +288,12 @@ result[0] = this[12];

}
// Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
getRotation(result = [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0], scaleResult = null) {
const scale = this.getScale(scaleResult || [-0, -0, -0]);
/**
* Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
* @param result
* @param scaleResult
* @returns self
*/
getRotation(result, scaleResult) {
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
scaleResult = scaleResult || [-0, -0, -0];
const scale = this.getScale(scaleResult);
const inverseScale0 = 1 / scale[0];

@@ -331,4 +320,12 @@ const inverseScale1 = 1 / scale[1];

}
getRotationMatrix3(result = [-0, -0, -0, -0, -0, -0, -0, -0, -0], scaleResult = null) {
const scale = this.getScale(scaleResult || [-0, -0, -0]);
/**
*
* @param result
* @param scaleResult
* @returns self
*/
getRotationMatrix3(result, scaleResult) {
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
scaleResult = scaleResult || [-0, -0, -0];
const scale = this.getScale(scaleResult);
const inverseScale0 = 1 / scale[0];

@@ -378,3 +375,7 @@ const inverseScale1 = 1 / scale[1];

}
// Rotates a matrix by the given angle around the Z axis.
/**
* Rotates a matrix by the given angle around the Z axis.
* @param radians
* @returns self
*/
rotateZ(radians) {

@@ -385,5 +386,16 @@ mat4.rotateZ(this, this, radians);

}
rotateXYZ([rx, ry, rz]) {
return this.rotateX(rx).rotateY(ry).rotateZ(rz);
/**
*
* @param param0
* @returns self
*/
rotateXYZ(angleXYZ) {
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
}
/**
*
* @param radians
* @param axis
* @returns self
*/
rotateAxis(radians, axis) {

@@ -393,17 +405,27 @@ mat4.rotate(this, this, radians, axis);

}
/**
*
* @param factor
* @returns self
*/
scale(factor) {
if (Array.isArray(factor)) {
mat4.scale(this, this, factor);
}
else {
mat4.scale(this, this, [factor, factor, factor]);
}
mat4.scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
return this.check();
}
translate(vec) {
mat4.translate(this, this, vec);
/**
*
* @param vec
* @returns self
*/
translate(vector) {
mat4.translate(this, this, vector);
return this.check();
}
// Transforms
// Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
/**
* Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
* @param vector
* @param result
* @returns self
*/
transform(vector, result) {

@@ -417,3 +439,8 @@ if (vector.length === 4) {

}
// Transforms any 2 or 3 element array as point (w implicitly 1)
/**
* Transforms any 2 or 3 element array as point (w implicitly 1)
* @param vector
* @param result
* @returns self
*/
transformAsPoint(vector, result) {

@@ -434,3 +461,8 @@ const { length } = vector;

}
// Transforms any 2 or 3 element array as vector (w implicitly 0)
/**
* Transforms any 2 or 3 element array as vector (w implicitly 0)
* @param vector
* @param result
* @returns self
*/
transformAsVector(vector, result) {

@@ -450,2 +482,14 @@ switch (vector.length) {

}
/** @deprecated */
transformPoint(vector, result) {
return this.transformAsPoint(vector, result);
}
/** @deprecated */
transformVector(vector, result) {
return this.transformAsPoint(vector, result);
}
/** @deprecated */
transformDirection(vector, result) {
return this.transformAsVector(vector, result);
}
// three.js math API compatibility

@@ -458,15 +502,52 @@ makeRotationX(radians) {

}
// DEPRECATED in 3.0
transformPoint(vector, result) {
deprecated('Matrix4.transformPoint', '3.0');
return this.transformAsPoint(vector, result);
}
// TODO initializing static members directly is an option, but make sure no tree-shaking issues
let ZERO;
let IDENTITY;
function getZeroMatrix() {
if (!ZERO) {
ZERO = new Matrix4([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
Object.freeze(ZERO);
}
transformVector(vector, result) {
deprecated('Matrix4.transformVector', '3.0');
return this.transformAsPoint(vector, result);
return ZERO;
}
function getIdentityMatrix() {
if (!IDENTITY) {
IDENTITY = new Matrix4();
Object.freeze(IDENTITY);
}
transformDirection(vector, result) {
deprecated('Matrix4.transformDirection', '3.0');
return this.transformAsVector(vector, result);
return IDENTITY;
}
// HELPER FUNCTIONS
function checkRadians(possiblyDegrees) {
if (possiblyDegrees > Math.PI * 2) {
throw Error('expected radians');
}
}
// eslint-disable-next-line max-params
function computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
const column0Row0 = (2 * near) / (right - left);
const column1Row1 = (2 * near) / (top - bottom);
const column2Row0 = (right + left) / (right - left);
const column2Row1 = (top + bottom) / (top - bottom);
const column2Row2 = -1;
const column2Row3 = -1;
const column3Row2 = -2 * near;
result[0] = column0Row0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = column1Row1;
result[6] = 0;
result[7] = 0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = column2Row3;
result[12] = 0;
result[13] = 0;
result[14] = column3Row2;
result[15] = 0;
return result;
}

@@ -0,37 +1,40 @@

import Matrix4 from './matrix4';
import Vector3 from './vector3';
import Euler from './euler';
import { NumericArray } from '@math.gl/types';
declare type PoseOptions = {
position?: Readonly<NumericArray>;
orientation?: Readonly<NumericArray>;
x?: number;
y?: number;
z?: number;
roll?: number;
pitch?: number;
yaw?: number;
};
export default class Pose {
constructor({ x, y, z, roll, pitch, yaw, position, orientation }?: {
x?: number;
y?: number;
z?: number;
roll?: number;
pitch?: number;
yaw?: number;
position?: any;
orientation?: any;
});
position: Vector3;
orientation: Euler;
set x(arg: number);
readonly position: Vector3;
readonly orientation: Euler;
constructor({ x, y, z, roll, pitch, yaw, position, orientation }?: PoseOptions);
get x(): number;
set y(arg: number);
set x(value: number);
get y(): number;
set z(arg: number);
set y(value: number);
get z(): number;
set roll(arg: number);
set z(value: number);
get roll(): number;
set pitch(arg: number);
set roll(value: number);
get pitch(): number;
set yaw(arg: number);
set pitch(value: number);
get yaw(): number;
set yaw(value: number);
getPosition(): Vector3;
getOrientation(): Euler;
equals(pose: any): boolean;
exactEquals(pose: any): boolean;
getTransformationMatrix(): any;
getTransformationMatrixFromPose(pose: any): Matrix4;
getTransformationMatrixToPose(pose: any): Matrix4;
equals(pose: Pose): boolean;
exactEquals(pose: Pose): boolean;
getTransformationMatrix(): Matrix4;
getTransformationMatrixFromPose(pose: Pose): Matrix4;
getTransformationMatrixToPose(pose: Pose): Matrix4;
}
import Vector3 from "./vector3";
import Euler from "./euler";
import Matrix4 from "./matrix4";
export {};
//# sourceMappingURL=pose.d.ts.map
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// MIT License
import Matrix4 from './matrix4';

@@ -24,4 +7,3 @@ import Vector3 from './vector3';

export default class Pose {
// @ts-ignore TS2740: Type '{}' is missing the following properties from type
constructor({ x = 0, y = 0, z = 0, roll = 0, pitch = 0, yaw = 0, position = undefined, orientation = undefined } = {}) {
constructor({ x = 0, y = 0, z = 0, roll = 0, pitch = 0, yaw = 0, position, orientation } = {}) {
if (Array.isArray(position) && position.length === 3) {

@@ -34,2 +16,3 @@ this.position = new Vector3(position);

if (Array.isArray(orientation) && orientation.length === 4) {
// @ts-expect-error
this.orientation = new Euler(orientation, orientation[3]);

@@ -96,3 +79,3 @@ }

getTransformationMatrix() {
// setup precomputations for the sin/cos of the angles
// setup pre computations for the sin/cos of the angles
const sr = Math.sin(this.roll);

@@ -104,3 +87,4 @@ const sp = Math.sin(this.pitch);

const cw = Math.cos(this.yaw);
const matrix = new Matrix4().setRowMajor(cw * cp, // 0,0
// Create matrix
return new Matrix4().setRowMajor(cw * cp, // 0,0
-sw * cr + cw * sp * sr, // 0,1

@@ -118,3 +102,2 @@ sw * sr + cw * sp * cr, // 0,2

0, 0, 0, 1);
return matrix;
}

@@ -121,0 +104,0 @@ getTransformationMatrixFromPose(pose) {

@@ -1,42 +0,63 @@

export default class Quaternion extends MathArray<any> {
constructor(x?: number, y?: number, z?: number, w?: number, ...args: any[]);
copy(array: any): any;
0: any;
1: any;
2: any;
3: any;
set(x: any, y: any, z: any, w: any): any;
fromMatrix3(m: any): any;
identity(): any;
fromAxisRotation(axis: any, rad: any): any;
setAxisAngle(axis: any, rad: any): any;
set x(arg: any);
get x(): any;
set y(arg: any);
get y(): any;
set z(arg: any);
get z(): any;
set w(arg: any);
get w(): any;
len(): any;
lengthSquared(): any;
dot(a: any, b: any): any;
rotationTo(vectorA: any, vectorB: any): any;
calculateW(): any;
conjugate(): any;
invert(): any;
multiplyRight(a: any, b: any): any;
multiplyLeft(a: any, b: any): any;
normalize(): any;
rotateX(rad: any): any;
rotateY(rad: any): any;
rotateZ(rad: any): any;
slerp(start: any, target: any, ratio: any, ...args: any[]): any;
transformVector4(vector: any, result?: any): any;
lengthSq(): any;
setFromAxisAngle(axis: any, rad: any): any;
premultiply(a: any, b: any): any;
multiply(a: any, b: any): any;
import MathArray from './base/math-array';
import { NumericArray } from '@math.gl/types';
export default class Quaternion extends MathArray {
constructor(x?: number | Readonly<NumericArray>, y?: number, z?: number, w?: number);
copy(array: Readonly<NumericArray>): this;
set(x: number, y: number, z: number, w: number): this;
fromObject(object: {
x: number;
y: number;
z: number;
w: number;
}): this;
/**
* Creates a quaternion from the given 3x3 rotation matrix.
* NOTE: The resultant quaternion is not normalized, so you should
* be sure to renormalize the quaternion yourself where necessary.
* @param m
* @returns
*/
fromMatrix3(m: Readonly<NumericArray>): this;
fromAxisRotation(axis: Readonly<NumericArray>, rad: number): this;
/** Set a quat to the identity quaternion */
identity(): this;
setAxisAngle(axis: Readonly<NumericArray>, rad: number): this;
get ELEMENTS(): number;
get x(): number;
set x(value: number);
get y(): number;
set y(value: number);
get z(): number;
set z(value: number);
get w(): number;
set w(value: number);
len(): number;
lengthSquared(): number;
dot(a: Readonly<NumericArray>): number;
rotationTo(vectorA: NumericArray, vectorB: NumericArray): this;
add(a: Readonly<NumericArray>): this;
calculateW(): this;
conjugate(): this;
invert(): this;
lerp(a: Readonly<NumericArray>, b: Readonly<NumericArray> | number, t?: number): this;
multiplyRight(a: Readonly<NumericArray>): this;
multiplyLeft(a: Readonly<NumericArray>): this;
normalize(): this;
rotateX(rad: number): this;
rotateY(rad: number): this;
rotateZ(rad: number): this;
scale(b: number): this;
slerp(target: Readonly<NumericArray>, ratio: number): this;
slerp(start: Readonly<NumericArray>, target: Readonly<NumericArray>, ratio: number): this;
slerp(params: {
start: Readonly<NumericArray>;
target: Readonly<NumericArray>;
ratio: number;
}): this;
transformVector4(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
lengthSq(): number;
setFromAxisAngle(axis: Readonly<NumericArray>, rad: number): this;
premultiply(a: Readonly<NumericArray>): this;
multiply(a: Readonly<NumericArray>): this;
}
import MathArray from "./base/math-array";
//# sourceMappingURL=quaternion.d.ts.map
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// MIT License
import MathArray from './base/math-array';
import { checkNumber, checkVector } from '../lib/validators';
import assert from '../lib/assert';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import Vector4 from './vector4';
import * as quat from 'gl-matrix/quat';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec4 from 'gl-matrix/vec4';

@@ -54,5 +35,16 @@ const IDENTITY_QUATERNION = [0, 0, 0, 1];

}
// Creates a quaternion from the given 3x3 rotation matrix.
// NOTE: The resultant quaternion is not normalized, so you should
// be sure to renormalize the quaternion yourself where necessary.
fromObject(object) {
this[0] = object.x;
this[1] = object.y;
this[2] = object.z;
this[3] = object.w;
return this.check();
}
/**
* Creates a quaternion from the given 3x3 rotation matrix.
* NOTE: The resultant quaternion is not normalized, so you should
* be sure to renormalize the quaternion yourself where necessary.
* @param m
* @returns
*/
fromMatrix3(m) {

@@ -62,3 +54,7 @@ quat.fromMat3(this, m);

}
// Set a quat to the identity quaternion
fromAxisRotation(axis, rad) {
quat.setAxisAngle(this, axis, rad);
return this.check();
}
/** Set a quat to the identity quaternion */
identity() {

@@ -68,6 +64,2 @@ quat.identity(this);

}
fromAxisRotation(axis, rad) {
quat.setAxisAngle(this, axis, rad);
return this.check();
}
// Set the components of a quat to the given values

@@ -83,3 +75,2 @@ // set(i, j, k, l) {

// Getters/setters
/* eslint-disable no-multi-spaces, brace-style, no-return-assign */
get ELEMENTS() {

@@ -112,3 +103,2 @@ return 4;

}
/* eslint-enable no-multi-spaces, brace-style, no-return-assign */
// Calculates the length of a quat

@@ -124,6 +114,3 @@ len() {

// @return {Number}
dot(a, b) {
if (b !== undefined) {
throw new Error('Quaternion.dot only takes one argument');
}
dot(a) {
return quat.dot(this, a);

@@ -162,6 +149,3 @@ }

// Adds two quat's
add(a, b) {
if (b !== undefined) {
throw new Error('Quaternion.add only takes one argument');
}
add(a) {
quat.add(this, this, a);

@@ -189,2 +173,5 @@ return this.check();

lerp(a, b, t) {
if (t === undefined) {
return this.lerp(this, a, b);
}
quat.lerp(this, a, b, t);

@@ -194,9 +181,7 @@ return this.check();

// Multiplies two quat's
multiplyRight(a, b) {
assert(!b); // Quaternion.multiply only takes one argument
multiplyRight(a) {
quat.multiply(this, this, a);
return this.check();
}
multiplyLeft(a, b) {
assert(!b); // Quaternion.multiply only takes one argument
multiplyLeft(a) {
quat.multiply(this, a, this);

@@ -241,3 +226,6 @@ return this.check();

// Performs a spherical linear interpolation between two quat
slerp(start, target, ratio) {
slerp(arg0, arg1, arg2) {
let start;
let target;
let ratio;
// eslint-disable-next-line prefer-rest-params

@@ -247,10 +235,18 @@ switch (arguments.length) {

// eslint-disable-next-line prefer-rest-params
({ start = IDENTITY_QUATERNION, target, ratio } = arguments[0]);
({
start = IDENTITY_QUATERNION,
target,
ratio
} = arg0);
break;
case 2: // THREE.js compatibility signature (target, ration)
// eslint-disable-next-line prefer-rest-params
[target, ratio] = arguments;
start = this; // eslint-disable-line
target = arg0;
ratio = arg1;
break;
default: // Default signature: (start, target, ratio)
default:
// Default signature: (start, target, ratio)
start = arg0;
target = arg1;
ratio = arg2;
}

@@ -260,3 +256,3 @@ quat.slerp(this, start, target, ratio);

}
transformVector4(vector, result = vector) {
transformVector4(vector, result = new Vector4()) {
vec4.transformQuat(result, vector, this);

@@ -272,8 +268,8 @@ return checkVector(result, 4);

}
premultiply(a, b) {
return this.multiplyLeft(a, b);
premultiply(a) {
return this.multiplyLeft(a);
}
multiply(a, b) {
return this.multiplyRight(a, b);
multiply(a) {
return this.multiplyRight(a);
}
}

@@ -0,25 +1,45 @@

import Vector3 from './vector3';
import { NumericArray } from '@math.gl/types';
declare type SphericalCoordinatesOptions = {
phi?: number;
theta?: number;
radius?: number;
bearing?: number;
pitch?: number;
altitude?: number;
radiusScale?: number;
};
declare type FormatOptions = {
printTypes?: boolean;
};
/**
* The poles (phi) are at the positive and negative y axis.
* The equator starts at positive z.
* @link https://en.wikipedia.org/wiki/Spherical_coordinate_system
*/
export default class SphericalCoordinates {
constructor({ phi, theta, radius, bearing, pitch, altitude, radiusScale }?: {
phi?: number;
theta?: number;
radius?: number;
bearing?: any;
pitch?: any;
altitude?: any;
radiusScale?: number;
});
phi: number;
theta: number;
radius: any;
radius: number;
radiusScale: number;
set bearing(arg: number);
/**
* Creates a new SphericalCoordinates object
* @param options
* @param [options.phi] =0 - rotation around X (latitude)
* @param [options.theta] =0 - rotation around Y (longitude)
* @param [options.radius] =1 - Distance from center
* @param [options.bearing]
* @param [options.pitch]
* @param [options.altitude]
* @param [options.radiusScale] =1
*/
constructor({ phi, theta, radius, bearing, pitch, altitude, radiusScale }?: SphericalCoordinatesOptions);
toString(): string;
formatString({ printTypes }: FormatOptions): string;
equals(other: SphericalCoordinates): boolean;
exactEquals(other: SphericalCoordinates): boolean;
get bearing(): number;
set pitch(arg: number);
set bearing(v: number);
get pitch(): number;
toString(): string;
formatString({ printTypes }: {
printTypes?: boolean;
}): string;
equals(other: any): boolean;
exactEquals(other: any): boolean;
set pitch(v: number);
get longitude(): number;

@@ -30,12 +50,12 @@ get latitude(): number;

get z(): number;
set(radius: any, phi: any, theta: any): SphericalCoordinates;
set(radius: number, phi: number, theta: number): this;
clone(): SphericalCoordinates;
copy(other: any): SphericalCoordinates;
fromLngLatZ([lng, lat, z]: [any, any, any]): void;
fromVector3(v: any): SphericalCoordinates;
copy(other: SphericalCoordinates): this;
fromLngLatZ([lng, lat, z]: [number, number, number]): this;
fromVector3(v: Readonly<NumericArray>): this;
toVector3(): Vector3;
makeSafe(): SphericalCoordinates;
check(): SphericalCoordinates;
makeSafe(): this;
check(): this;
}
import Vector3 from "./vector3";
export {};
//# sourceMappingURL=spherical-coordinates.d.ts.map
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// MIT License
// Adaptation of THREE.js Spherical class, under MIT license
import Vector3 from './vector3';
import { formatValue, equals, config } from '../lib/common';
import { degrees, radians, clamp } from '../lib/common';
import Vector3 from './vector3';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec3 from 'gl-matrix/vec3';
// TODO - import epsilon
const EPSILON = 0.000001;
const EARTH_RADIUS_METERS = 6.371e6;
// Todo [rho, theta, phi] ?
const EARTH_RADIUS_METERS = 6371000;
/**
* The poles (phi) are at the positive and negative y axis.
* The equator starts at positive z.
* @link https://en.wikipedia.org/wiki/Spherical_coordinate_system
*/
export default class SphericalCoordinates {
// @ts-ignore TS2740: Type '{}' is missing the following properties from type
// bearing: number;
// pitch: number;
// altitude: number;
// lnglatZ coordinates
// longitude: number;
// latitude: number;
// lng: number;
// lat: number;
// z: number;
/**
* Creates a new SphericalCoordinates object
* @param options
* @param [options.phi] =0 - rotation around X (latitude)
* @param [options.theta] =0 - rotation around Y (longitude)
* @param [options.radius] =1 - Distance from center
* @param [options.bearing]
* @param [options.pitch]
* @param [options.altitude]
* @param [options.radiusScale] =1
*/
// eslint-disable-next-line complexity
constructor({ phi = 0, theta = 0, radius = 1, bearing = undefined, pitch = undefined, altitude = undefined, radiusScale = EARTH_RADIUS_METERS } = {}) {
constructor({ phi = 0, theta = 0, radius = 1, bearing, pitch, altitude, radiusScale = EARTH_RADIUS_METERS } = {}) {
this.phi = phi;

@@ -116,2 +121,3 @@ this.theta = theta;

this.theta = radians(lng);
return this.check();
}

@@ -118,0 +124,0 @@ fromVector3(v) {

@@ -1,19 +0,55 @@

export default class Vector2 extends Vector<any> {
constructor(x?: number, y?: number, ...args: any[]);
0: number;
1: number;
set(x: any, y: any): any;
copy(array: any): any;
fromObject(object: any): any;
toObject(object: any): any;
import Vector from './base/vector';
import { NumericArray } from '@math.gl/types';
/**
* Two-element vector class.
* Subclass of Array<number>
*/
export default class Vector2 extends Vector {
constructor(x?: number | Readonly<NumericArray>, y?: number);
set(x: number, y: number): this;
copy(array: Readonly<NumericArray>): this;
fromObject(object: {
x: number;
y: number;
}): this;
toObject(object: {
x?: number;
y?: number;
}): {
x: number;
y: number;
};
get ELEMENTS(): number;
/**
* Returns angle from x axis
* @returns
*/
horizontalAngle(): number;
/**
* Returns angle from y axis
* @returns
*/
verticalAngle(): number;
transform(matrix4: any): any;
transformAsPoint(matrix4: any): any;
transformAsVector(matrix4: any): any;
transformByMatrix3(matrix3: any): any;
transformByMatrix2x3(matrix2x3: any): any;
transformByMatrix2(matrix2: any): any;
/**
* Transforms as point
* @param matrix4
* @returns
*/
transform(matrix4: Readonly<NumericArray>): this;
/**
* transforms as point (4th component is implicitly 1)
* @param matrix4
* @returns
*/
transformAsPoint(matrix4: Readonly<NumericArray>): this;
/**
* transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
* @param matrix4
* @returns
*/
transformAsVector(matrix4: Readonly<NumericArray>): this;
transformByMatrix3(matrix3: Readonly<NumericArray>): this;
transformByMatrix2x3(matrix2x3: Readonly<NumericArray>): this;
transformByMatrix2(matrix2: Readonly<NumericArray>): this;
}
import Vector from "./base/vector";
//# sourceMappingURL=vector2.d.ts.map
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// MIT License
import Vector from './base/vector';
import { config, isArray } from '../lib/common';
import { checkNumber } from '../lib/validators';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec2 from 'gl-matrix/vec2';
// eslint-disable-next-line camelcase
/* eslint-disable camelcase */
import { vec2_transformMat4AsVector } from '../lib/gl-matrix-extras';
/**
* Two-element vector class.
* Subclass of Array<number>
*/
export default class Vector2 extends Vector {

@@ -72,6 +58,13 @@ // Creates a new, empty vec2

}
// x,y inherited from Vector
/**
* Returns angle from x axis
* @returns
*/
horizontalAngle() {
return Math.atan2(this.y, this.x);
}
/**
* Returns angle from y axis
* @returns
*/
verticalAngle() {

@@ -81,6 +74,15 @@ return Math.atan2(this.x, this.y);

// Transforms
/**
* Transforms as point
* @param matrix4
* @returns
*/
transform(matrix4) {
return this.transformAsPoint(matrix4);
}
// transforms as point (4th component is implicitly 1)
/**
* transforms as point (4th component is implicitly 1)
* @param matrix4
* @returns
*/
transformAsPoint(matrix4) {

@@ -90,3 +92,7 @@ vec2.transformMat4(this, this, matrix4);

}
// transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
/**
* transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
* @param matrix4
* @returns
*/
transformAsVector(matrix4) {

@@ -93,0 +99,0 @@ vec2_transformMat4AsVector(this, this, matrix4);

@@ -1,41 +0,56 @@

export default class Vector3 extends Vector<any> {
static get ZERO(): any;
import { NumericArray } from '@math.gl/types';
import Vector from './base/vector';
/**
* Three-element vector class.
* Subclass of Array<number>
*/
export default class Vector3 extends Vector {
static get ZERO(): Vector3;
/**
* @class
* @param {Number | [Number, Number, Number]} x
* @param {Number} y - rotation around X (latitude)
* @param {Number} z - rotation around X (latitude)
* @param x
* @param y
* @param z
*/
constructor(x?: number | [number, number, number], y?: number, z?: number, ...args: any[]);
0: number | [number, number, number];
1: number;
2: number;
set(x: any, y: any, z: any): any;
copy(array: any): any;
fromObject(object: any): any;
toObject(object: any): any;
set z(arg: number);
constructor(x?: number | Readonly<NumericArray>, y?: number, z?: number);
set(x: number, y: number, z: number): this;
copy(array: Readonly<NumericArray>): this;
fromObject(object: {
x: number;
y: number;
z: number;
}): this;
toObject(object: {
x?: number;
y?: number;
z?: number;
}): {
x: number;
y: number;
z: number;
};
get ELEMENTS(): number;
get z(): number;
angle(vector: any): any;
cross(vector: any): any;
set z(value: number);
angle(vector: Readonly<NumericArray>): number;
cross(vector: Readonly<NumericArray>): this;
rotateX({ radians, origin }: {
radians: any;
origin?: number[];
}): any;
radians: number;
origin?: Readonly<NumericArray>;
}): this;
rotateY({ radians, origin }: {
radians: any;
origin?: number[];
}): any;
radians: number;
origin?: Readonly<NumericArray>;
}): this;
rotateZ({ radians, origin }: {
radians: any;
origin?: number[];
}): any;
transform(matrix4: any): any;
transformAsPoint(matrix4: any): any;
transformAsVector(matrix4: any): any;
transformByMatrix3(matrix3: any): any;
transformByMatrix2(matrix2: any): any;
transformByQuaternion(quaternion: any): any;
radians: number;
origin?: Readonly<NumericArray>;
}): this;
transform(matrix4: Readonly<NumericArray>): this;
transformAsPoint(matrix4: Readonly<NumericArray>): this;
transformAsVector(matrix4: Readonly<NumericArray>): this;
transformByMatrix3(matrix3: Readonly<NumericArray>): this;
transformByMatrix2(matrix2: Readonly<NumericArray>): this;
transformByQuaternion(quaternion: Readonly<NumericArray>): this;
}
import Vector from "./base/vector";
//# sourceMappingURL=vector3.d.ts.map

@@ -1,38 +0,26 @@

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Vector from './base/vector';
import { config, isArray } from '../lib/common';
import { checkNumber } from '../lib/validators';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec3 from 'gl-matrix/vec3';
// eslint-disable-next-line camelcase
/* eslint-disable camelcase */
import { vec3_transformMat2, vec3_transformMat4AsVector } from '../lib/gl-matrix-extras';
const ORIGIN = [0, 0, 0];
const constants = {};
let ZERO;
/**
* Three-element vector class.
* Subclass of Array<number>
*/
export default class Vector3 extends Vector {
static get ZERO() {
return (constants.ZERO = constants.ZERO || Object.freeze(new Vector3(0, 0, 0, 0)));
if (!ZERO) {
ZERO = new Vector3(0, 0, 0);
Object.freeze(ZERO);
}
return ZERO;
}
/**
* @class
* @param {Number | [Number, Number, Number]} x
* @param {Number} y - rotation around X (latitude)
* @param {Number} z - rotation around X (latitude)
* @param x
* @param y
* @param z
*/

@@ -52,3 +40,3 @@ constructor(x = 0, y = 0, z = 0) {

}
// @ts-ignore TS2412: Property '0' of type 'number | [number, number, number]' is not assignable to numeric index type 'number'
// @ts-expect-error TS2412: Property '0' of type 'number | [number, number, number]' is not assignable to numeric index type 'number'
this[0] = x;

@@ -89,7 +77,5 @@ this[1] = y;

// Getters/setters
/* eslint-disable no-multi-spaces, brace-style, no-return-assign */
get ELEMENTS() {
return 3;
}
// x,y inherited from Vector
get z() {

@@ -101,3 +87,3 @@ return this[2];

}
/* eslint-enable no-multi-spaces, brace-style, no-return-assign */
// ACCESSORS
angle(vector) {

@@ -104,0 +90,0 @@ return vec3.angle(this, vector);

@@ -1,23 +0,41 @@

export default class Vector4 extends Vector<any> {
static get ZERO(): any;
constructor(x?: number, y?: number, z?: number, w?: number, ...args: any[]);
0: number;
1: number;
2: number;
3: number;
set(x: any, y: any, z: any, w: any): any;
copy(array: any): any;
fromObject(object: any): Vector4;
toObject(object: any): any;
set z(arg: number);
import Vector from './base/vector';
import { NumericArray } from '@math.gl/types';
import type Matrix4 from './matrix4';
/**
* Four-element vector class.
* Subclass of Array<number>
*/
export default class Vector4 extends Vector {
static get ZERO(): Vector4;
constructor(x?: number | Readonly<NumericArray>, y?: number, z?: number, w?: number);
set(x: number, y: number, z: number, w: number): this;
copy(array: Readonly<NumericArray>): this;
fromObject(object: {
x: number;
y: number;
z: number;
w: number;
}): this;
toObject(object: {
x?: number;
y?: number;
z?: number;
w?: number;
}): {
x: number;
y: number;
z: number;
w: number;
};
get ELEMENTS(): number;
get z(): number;
set w(arg: number);
set z(value: number);
get w(): number;
transform(matrix4: any): any;
transformByMatrix3(matrix3: any): any;
transformByMatrix2(matrix2: any): any;
transformByQuaternion(quaternion: any): any;
applyMatrix4(m: any): Vector4;
set w(value: number);
transform(matrix4: Readonly<NumericArray>): this;
transformByMatrix3(matrix3: Readonly<NumericArray>): this;
transformByMatrix2(matrix2: Readonly<NumericArray>): this;
transformByQuaternion(quaternion: Readonly<NumericArray>): this;
applyMatrix4(m: Matrix4): this;
}
import Vector from "./base/vector";
//# sourceMappingURL=vector4.d.ts.map
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// MIT License
import Vector from './base/vector';
import { config, isArray } from '../lib/common';
import { checkNumber } from '../lib/validators';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec4 from 'gl-matrix/vec3';
// eslint-disable-next-line camelcase
/* eslint-disable camelcase */
import { vec4_transformMat2, vec4_transformMat3 } from '../lib/gl-matrix-extras';
const constants = {};
let ZERO;
/**
* Four-element vector class.
* Subclass of Array<number>
*/
export default class Vector4 extends Vector {
static get ZERO() {
return (constants.ZERO = constants.ZERO || Object.freeze(new Vector4(0, 0, 0, 0)));
if (!ZERO) {
ZERO = new Vector4(0, 0, 0, 0);
Object.freeze(ZERO);
}
return ZERO;
}

@@ -91,3 +81,2 @@ constructor(x = 0, y = 0, z = 0, w = 0) {

}
// x,y inherited from Vector
get z() {

@@ -105,3 +94,2 @@ return this[2];

}
/* eslint-enable no-multi-spaces, brace-style, no-return-assign */
transform(matrix4) {

@@ -108,0 +96,0 @@ vec4.transformMat4(this, this, matrix4);

@@ -10,6 +10,18 @@ "use strict";

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _common = require("../../lib/common");
var _assert = _interopRequireDefault(require("../../lib/assert"));
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _extendableBuiltin(cls) {

@@ -40,242 +52,299 @@ function ExtendableBuiltin() {

class MathArray extends _extendableBuiltin(Array) {
get ELEMENTS() {
(0, _assert.default)(false);
return 0;
}
var MathArray = function (_extendableBuiltin2) {
(0, _inherits2.default)(MathArray, _extendableBuiltin2);
clone() {
return new this.constructor().copy(this);
}
var _super = _createSuper(MathArray);
from(arrayOrObject) {
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
function MathArray() {
(0, _classCallCheck2.default)(this, MathArray);
return _super.apply(this, arguments);
}
fromArray(array, offset = 0) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] = array[i + offset];
(0, _createClass2.default)(MathArray, [{
key: "clone",
value: function clone() {
return new this.constructor().copy(this);
}
}, {
key: "fromArray",
value: function fromArray(array) {
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return this.check();
}
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] = array[i + offset];
}
to(arrayOrObject) {
if (arrayOrObject === this) {
return this;
return this.check();
}
}, {
key: "toArray",
value: function toArray() {
var targetArray = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return (0, _common.isArray)(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject);
}
for (var i = 0; i < this.ELEMENTS; ++i) {
targetArray[offset + i] = this[i];
}
toTarget(target) {
return target ? this.to(target) : this;
}
toArray(array = [], offset = 0) {
for (let i = 0; i < this.ELEMENTS; ++i) {
array[offset + i] = this[i];
return targetArray;
}
}, {
key: "from",
value: function from(arrayOrObject) {
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
}
}, {
key: "to",
value: function to(arrayOrObject) {
if (arrayOrObject === this) {
return this;
}
return array;
}
toFloat32Array() {
return new Float32Array(this);
}
toString() {
return this.formatString(_common.config);
}
formatString(opts) {
let string = '';
for (let i = 0; i < this.ELEMENTS; ++i) {
string += (i > 0 ? ', ' : '') + (0, _common.formatValue)(this[i], opts);
return (0, _common.isArray)(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject);
}
}, {
key: "toTarget",
value: function toTarget(target) {
return target ? this.to(target) : this;
}
}, {
key: "toFloat32Array",
value: function toFloat32Array() {
return new Float32Array(this);
}
}, {
key: "toString",
value: function toString() {
return this.formatString(_common.config);
}
}, {
key: "formatString",
value: function formatString(opts) {
var string = '';
return "".concat(opts.printTypes ? this.constructor.name : '', "[").concat(string, "]");
}
for (var i = 0; i < this.ELEMENTS; ++i) {
string += (i > 0 ? ', ' : '') + (0, _common.formatValue)(this[i], opts);
}
equals(array) {
if (!array || this.length !== array.length) {
return false;
return "".concat(opts.printTypes ? this.constructor.name : '', "[").concat(string, "]");
}
for (let i = 0; i < this.ELEMENTS; ++i) {
if (!(0, _common.equals)(this[i], array[i])) {
}, {
key: "equals",
value: function equals(array) {
if (!array || this.length !== array.length) {
return false;
}
}
return true;
}
for (var i = 0; i < this.ELEMENTS; ++i) {
if (!(0, _common.equals)(this[i], array[i])) {
return false;
}
}
exactEquals(array) {
if (!array || this.length !== array.length) {
return false;
return true;
}
for (let i = 0; i < this.ELEMENTS; ++i) {
if (this[i] !== array[i]) {
}, {
key: "exactEquals",
value: function exactEquals(array) {
if (!array || this.length !== array.length) {
return false;
}
}
return true;
}
for (var i = 0; i < this.ELEMENTS; ++i) {
if (this[i] !== array[i]) {
return false;
}
}
negate() {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] = -this[i];
return true;
}
}, {
key: "negate",
value: function negate() {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] = -this[i];
}
return this.check();
}
lerp(a, b, t) {
if (t === undefined) {
t = b;
b = a;
a = this;
return this.check();
}
}, {
key: "lerp",
value: function lerp(a, b, t) {
if (t === undefined) {
return this.lerp(this, a, b);
}
for (let i = 0; i < this.ELEMENTS; ++i) {
const ai = a[i];
this[i] = ai + t * (b[i] - ai);
for (var i = 0; i < this.ELEMENTS; ++i) {
var ai = a[i];
this[i] = ai + t * (b[i] - ai);
}
return this.check();
}
}, {
key: "min",
value: function min(vector) {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] = Math.min(vector[i], this[i]);
}
return this.check();
}
min(vector) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] = Math.min(vector[i], this[i]);
return this.check();
}
}, {
key: "max",
value: function max(vector) {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] = Math.max(vector[i], this[i]);
}
return this.check();
}
max(vector) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] = Math.max(vector[i], this[i]);
return this.check();
}
}, {
key: "clamp",
value: function clamp(minVector, maxVector) {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] = Math.min(Math.max(this[i], minVector[i]), maxVector[i]);
}
return this.check();
}
clamp(minVector, maxVector) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] = Math.min(Math.max(this[i], minVector[i]), maxVector[i]);
return this.check();
}
}, {
key: "add",
value: function add() {
for (var _len = arguments.length, vectors = new Array(_len), _key = 0; _key < _len; _key++) {
vectors[_key] = arguments[_key];
}
return this.check();
}
for (var _i = 0, _vectors = vectors; _i < _vectors.length; _i++) {
var _vector = _vectors[_i];
add(...vectors) {
for (const vector of vectors) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] += vector[i];
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] += _vector[i];
}
}
return this.check();
}
}, {
key: "subtract",
value: function subtract() {
for (var _len2 = arguments.length, vectors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
vectors[_key2] = arguments[_key2];
}
return this.check();
}
for (var _i2 = 0, _vectors2 = vectors; _i2 < _vectors2.length; _i2++) {
var _vector2 = _vectors2[_i2];
subtract(...vectors) {
for (const vector of vectors) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] -= vector[i];
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] -= _vector2[i];
}
}
return this.check();
}
}, {
key: "scale",
value: function scale(_scale) {
if (typeof _scale === 'number') {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] *= _scale;
}
} else {
for (var _i3 = 0; _i3 < this.ELEMENTS && _i3 < _scale.length; ++_i3) {
this[_i3] *= _scale[_i3];
}
}
return this.check();
}
scale(scale) {
if (Array.isArray(scale)) {
return this.multiply(scale);
return this.check();
}
}, {
key: "multiplyByScalar",
value: function multiplyByScalar(scalar) {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] *= scalar;
}
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] *= scale;
return this.check();
}
}, {
key: "check",
value: function check() {
if (_common.config.debug && !this.validate()) {
throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
}
return this.check();
}
sub(a) {
return this.subtract(a);
}
setScalar(a) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] = a;
return this;
}
}, {
key: "validate",
value: function validate() {
var valid = this.length === this.ELEMENTS;
return this.check();
}
for (var i = 0; i < this.ELEMENTS; ++i) {
valid = valid && Number.isFinite(this[i]);
}
addScalar(a) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] += a;
return valid;
}
}, {
key: "sub",
value: function sub(a) {
return this.subtract(a);
}
}, {
key: "setScalar",
value: function setScalar(a) {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] = a;
}
return this.check();
}
subScalar(a) {
return this.addScalar(-a);
}
multiplyScalar(scalar) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] *= scalar;
return this.check();
}
}, {
key: "addScalar",
value: function addScalar(a) {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] += a;
}
return this.check();
}
divideScalar(a) {
return this.scale(1 / a);
}
clampScalar(min, max) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] = Math.min(Math.max(this[i], min), max);
return this.check();
}
}, {
key: "subScalar",
value: function subScalar(a) {
return this.addScalar(-a);
}
}, {
key: "multiplyScalar",
value: function multiplyScalar(scalar) {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] *= scalar;
}
return this.check();
}
multiplyByScalar(scalar) {
return this.scale(scalar);
}
get elements() {
return this;
}
check() {
if (_common.config.debug && !this.validate()) {
throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
return this.check();
}
}, {
key: "divideScalar",
value: function divideScalar(a) {
return this.multiplyByScalar(1 / a);
}
}, {
key: "clampScalar",
value: function clampScalar(min, max) {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] = Math.min(Math.max(this[i], min), max);
}
return this;
}
validate() {
let valid = this.length === this.ELEMENTS;
for (let i = 0; i < this.ELEMENTS; ++i) {
valid = valid && Number.isFinite(this[i]);
return this.check();
}
}, {
key: "elements",
get: function get() {
return this;
}
}]);
return MathArray;
}(_extendableBuiltin(Array));
return valid;
}
}
exports.default = MathArray;
//# sourceMappingURL=math-array.js.map

@@ -10,2 +10,12 @@ "use strict";

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _mathArray = _interopRequireDefault(require("./math-array"));

@@ -17,74 +27,84 @@

var _assert = _interopRequireDefault(require("../../lib/assert"));
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
class Matrix extends _mathArray.default {
get ELEMENTS() {
(0, _assert.default)(false);
return 0;
}
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
get RANK() {
(0, _assert.default)(false);
return 0;
var Matrix = function (_MathArray) {
(0, _inherits2.default)(Matrix, _MathArray);
var _super = _createSuper(Matrix);
function Matrix() {
(0, _classCallCheck2.default)(this, Matrix);
return _super.apply(this, arguments);
}
toString() {
let string = '[';
(0, _createClass2.default)(Matrix, [{
key: "toString",
value: function toString() {
var string = '[';
if (_common.config.printRowMajor) {
string += 'row-major:';
if (_common.config.printRowMajor) {
string += 'row-major:';
for (let row = 0; row < this.RANK; ++row) {
for (let col = 0; col < this.RANK; ++col) {
string += " ".concat(this[col * this.RANK + row]);
for (var row = 0; row < this.RANK; ++row) {
for (var col = 0; col < this.RANK; ++col) {
string += " ".concat(this[col * this.RANK + row]);
}
}
} else {
string += 'column-major:';
for (var i = 0; i < this.ELEMENTS; ++i) {
string += " ".concat(this[i]);
}
}
} else {
string += 'column-major:';
for (let i = 0; i < this.ELEMENTS; ++i) {
string += " ".concat(this[i]);
}
string += ']';
return string;
}
}, {
key: "getElementIndex",
value: function getElementIndex(row, col) {
return col * this.RANK + row;
}
}, {
key: "getElement",
value: function getElement(row, col) {
return this[col * this.RANK + row];
}
}, {
key: "setElement",
value: function setElement(row, col, value) {
this[col * this.RANK + row] = (0, _validators.checkNumber)(value);
return this;
}
}, {
key: "getColumn",
value: function getColumn(columnIndex) {
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Array(this.RANK).fill(-0);
var firstIndex = columnIndex * this.RANK;
string += ']';
return string;
}
for (var i = 0; i < this.RANK; ++i) {
result[i] = this[firstIndex + i];
}
getElementIndex(row, col) {
return col * this.RANK + row;
}
getElement(row, col) {
return this[col * this.RANK + row];
}
setElement(row, col, value) {
this[col * this.RANK + row] = (0, _validators.checkNumber)(value);
return this;
}
getColumn(columnIndex, result = new Array(this.RANK).fill(-0)) {
const firstIndex = columnIndex * this.RANK;
for (let i = 0; i < this.RANK; ++i) {
result[i] = this[firstIndex + i];
return result;
}
}, {
key: "setColumn",
value: function setColumn(columnIndex, columnVector) {
var firstIndex = columnIndex * this.RANK;
return result;
}
for (var i = 0; i < this.RANK; ++i) {
this[firstIndex + i] = columnVector[i];
}
setColumn(columnIndex, columnVector) {
const firstIndex = columnIndex * this.RANK;
for (let i = 0; i < this.RANK; ++i) {
this[firstIndex + i] = columnVector[i];
return this;
}
}]);
return Matrix;
}(_mathArray.default);
return this;
}
}
exports.default = Matrix;
//# sourceMappingURL=matrix.js.map

@@ -10,156 +10,202 @@ "use strict";

var _mathArray = _interopRequireDefault(require("./math-array"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _validators = require("../../lib/validators");
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assert = _interopRequireDefault(require("../../lib/assert"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
class Vector extends _mathArray.default {
get ELEMENTS() {
(0, _assert.default)(false);
return 0;
}
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
copy(vector) {
(0, _assert.default)(false);
return this;
}
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
get x() {
return this[0];
}
var _mathArray = _interopRequireDefault(require("./math-array"));
set x(value) {
this[0] = (0, _validators.checkNumber)(value);
}
var _validators = require("../../lib/validators");
get y() {
return this[1];
}
var _assert = _interopRequireDefault(require("../../lib/assert"));
set y(value) {
this[1] = (0, _validators.checkNumber)(value);
}
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
len() {
return Math.sqrt(this.lengthSquared());
}
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
magnitude() {
return this.len();
}
var Vector = function (_MathArray) {
(0, _inherits2.default)(Vector, _MathArray);
lengthSquared() {
let length = 0;
var _super = _createSuper(Vector);
for (let i = 0; i < this.ELEMENTS; ++i) {
length += this[i] * this[i];
}
return length;
function Vector() {
(0, _classCallCheck2.default)(this, Vector);
return _super.apply(this, arguments);
}
magnitudeSquared() {
return this.lengthSquared();
}
(0, _createClass2.default)(Vector, [{
key: "x",
get: function get() {
return this[0];
},
set: function set(value) {
this[0] = (0, _validators.checkNumber)(value);
}
}, {
key: "y",
get: function get() {
return this[1];
},
set: function set(value) {
this[1] = (0, _validators.checkNumber)(value);
}
}, {
key: "len",
value: function len() {
return Math.sqrt(this.lengthSquared());
}
}, {
key: "magnitude",
value: function magnitude() {
return this.len();
}
}, {
key: "lengthSquared",
value: function lengthSquared() {
var length = 0;
distance(mathArray) {
return Math.sqrt(this.distanceSquared(mathArray));
}
for (var i = 0; i < this.ELEMENTS; ++i) {
length += this[i] * this[i];
}
distanceSquared(mathArray) {
let length = 0;
for (let i = 0; i < this.ELEMENTS; ++i) {
const dist = this[i] - mathArray[i];
length += dist * dist;
return length;
}
}, {
key: "magnitudeSquared",
value: function magnitudeSquared() {
return this.lengthSquared();
}
}, {
key: "distance",
value: function distance(mathArray) {
return Math.sqrt(this.distanceSquared(mathArray));
}
}, {
key: "distanceSquared",
value: function distanceSquared(mathArray) {
var length = 0;
return (0, _validators.checkNumber)(length);
}
for (var i = 0; i < this.ELEMENTS; ++i) {
var dist = this[i] - mathArray[i];
length += dist * dist;
}
dot(mathArray) {
let product = 0;
for (let i = 0; i < this.ELEMENTS; ++i) {
product += this[i] * mathArray[i];
return (0, _validators.checkNumber)(length);
}
}, {
key: "dot",
value: function dot(mathArray) {
var product = 0;
return (0, _validators.checkNumber)(product);
}
for (var i = 0; i < this.ELEMENTS; ++i) {
product += this[i] * mathArray[i];
}
normalize() {
const length = this.magnitude();
return (0, _validators.checkNumber)(product);
}
}, {
key: "normalize",
value: function normalize() {
var length = this.magnitude();
if (length !== 0) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] /= length;
if (length !== 0) {
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] /= length;
}
}
return this.check();
}
}, {
key: "multiply",
value: function multiply() {
for (var _len = arguments.length, vectors = new Array(_len), _key = 0; _key < _len; _key++) {
vectors[_key] = arguments[_key];
}
return this.check();
}
for (var _i = 0, _vectors = vectors; _i < _vectors.length; _i++) {
var vector = _vectors[_i];
multiply(...vectors) {
for (const vector of vectors) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] *= vector[i];
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] *= vector[i];
}
}
return this.check();
}
}, {
key: "divide",
value: function divide() {
for (var _len2 = arguments.length, vectors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
vectors[_key2] = arguments[_key2];
}
return this.check();
}
for (var _i2 = 0, _vectors2 = vectors; _i2 < _vectors2.length; _i2++) {
var vector = _vectors2[_i2];
divide(...vectors) {
for (const vector of vectors) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] /= vector[i];
for (var i = 0; i < this.ELEMENTS; ++i) {
this[i] /= vector[i];
}
}
return this.check();
}
}, {
key: "lengthSq",
value: function lengthSq() {
return this.lengthSquared();
}
}, {
key: "distanceTo",
value: function distanceTo(vector) {
return this.distance(vector);
}
}, {
key: "distanceToSquared",
value: function distanceToSquared(vector) {
return this.distanceSquared(vector);
}
}, {
key: "getComponent",
value: function getComponent(i) {
(0, _assert.default)(i >= 0 && i < this.ELEMENTS, 'index is out of range');
return (0, _validators.checkNumber)(this[i]);
}
}, {
key: "setComponent",
value: function setComponent(i, value) {
(0, _assert.default)(i >= 0 && i < this.ELEMENTS, 'index is out of range');
this[i] = value;
return this.check();
}
}, {
key: "addVectors",
value: function addVectors(a, b) {
return this.copy(a).add(b);
}
}, {
key: "subVectors",
value: function subVectors(a, b) {
return this.copy(a).subtract(b);
}
}, {
key: "multiplyVectors",
value: function multiplyVectors(a, b) {
return this.copy(a).multiply(b);
}
}, {
key: "addScaledVector",
value: function addScaledVector(a, b) {
return this.add(new this.constructor(a).multiplyScalar(b));
}
}]);
return Vector;
}(_mathArray.default);
return this.check();
}
lengthSq() {
return this.lengthSquared();
}
distanceTo(vector) {
return this.distance(vector);
}
distanceToSquared(vector) {
return this.distanceSquared(vector);
}
getComponent(i) {
(0, _assert.default)(i >= 0 && i < this.ELEMENTS, 'index is out of range');
return (0, _validators.checkNumber)(this[i]);
}
setComponent(i, value) {
(0, _assert.default)(i >= 0 && i < this.ELEMENTS, 'index is out of range');
this[i] = value;
return this.check();
}
addVectors(a, b) {
return this.copy(a).add(b);
}
subVectors(a, b) {
return this.copy(a).subtract(b);
}
multiplyVectors(a, b) {
return this.copy(a).multiply(b);
}
addScaledVector(a, b) {
return this.add(new this.constructor(a).multiplyScalar(b));
}
}
exports.default = Vector;
//# sourceMappingURL=vector.js.map

@@ -10,551 +10,646 @@ "use strict";

var _mathArray = _interopRequireDefault(require("./base/math-array"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _common = require("../lib/common");
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _validators = require("../lib/validators");
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _quaternion = _interopRequireDefault(require("./quaternion"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
const ERR_UNKNOWN_ORDER = 'Unknown Euler angle order';
const ALMOST_ONE = 0.99999;
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
function validateOrder(value) {
return value >= 0 && value < 6;
}
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
function checkOrder(value) {
if (value < 0 && value >= 6) {
throw new Error(ERR_UNKNOWN_ORDER);
}
var _mathArray = _interopRequireDefault(require("./base/math-array"));
return value;
}
var _quaternion2 = _interopRequireDefault(require("./quaternion"));
class Euler extends _mathArray.default {
static get ZYX() {
return 0;
}
var _common = require("../lib/common");
static get YXZ() {
return 1;
}
var _validators = require("../lib/validators");
static get XZY() {
return 2;
}
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
static get ZXY() {
return 3;
}
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
static get YZX() {
return 4;
}
var ERR_UNKNOWN_ORDER = 'Unknown Euler angle order';
var ALMOST_ONE = 0.99999;
var RotationOrder;
static get XYZ() {
return 5;
}
(function (RotationOrder) {
RotationOrder[RotationOrder["ZYX"] = 0] = "ZYX";
RotationOrder[RotationOrder["YXZ"] = 1] = "YXZ";
RotationOrder[RotationOrder["XZY"] = 2] = "XZY";
RotationOrder[RotationOrder["ZXY"] = 3] = "ZXY";
RotationOrder[RotationOrder["YZX"] = 4] = "YZX";
RotationOrder[RotationOrder["XYZ"] = 5] = "XYZ";
})(RotationOrder || (RotationOrder = {}));
static get RollPitchYaw() {
return 0;
}
var Euler = function (_MathArray) {
(0, _inherits2.default)(Euler, _MathArray);
static get DefaultOrder() {
return Euler.ZYX;
}
var _super = _createSuper(Euler);
static get RotationOrders() {
return ['ZYX', 'YXZ', 'XZY', 'ZXY', 'YZX', 'XYZ'];
}
function Euler() {
var _this;
static rotationOrder(order) {
return Euler.RotationOrders[order];
}
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var order = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Euler.DefaultOrder;
(0, _classCallCheck2.default)(this, Euler);
_this = _super.call(this, -0, -0, -0, -0);
get ELEMENTS() {
return 4;
}
if (arguments.length > 0 && Array.isArray(arguments[0])) {
var _this2;
constructor(x = 0, y = 0, z = 0, order = Euler.DefaultOrder) {
super(-0, -0, -0, -0);
if (arguments.length > 0 && Array.isArray(arguments[0])) {
this.fromVector3(...arguments);
(_this2 = _this).fromVector3.apply(_this2, arguments);
} else {
this.set(x, y, z, order);
_this.set(x, y, z, order);
}
}
fromQuaternion(quaternion) {
const [x, y, z, w] = quaternion;
const ysqr = y * y;
const t0 = -2.0 * (ysqr + z * z) + 1.0;
const t1 = +2.0 * (x * y + w * z);
let t2 = -2.0 * (x * z - w * y);
const t3 = +2.0 * (y * z + w * x);
const t4 = -2.0 * (x * x + ysqr) + 1.0;
t2 = t2 > 1.0 ? 1.0 : t2;
t2 = t2 < -1.0 ? -1.0 : t2;
const roll = Math.atan2(t3, t4);
const pitch = Math.asin(t2);
const yaw = Math.atan2(t1, t0);
return new Euler(roll, pitch, yaw, Euler.RollPitchYaw);
return _this;
}
copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = Number.isFinite(array[3]) || this.order;
return this.check();
}
(0, _createClass2.default)(Euler, [{
key: "ELEMENTS",
get: function get() {
return 4;
}
}, {
key: "fromQuaternion",
value: function fromQuaternion(quaternion) {
var _quaternion = (0, _slicedToArray2.default)(quaternion, 4),
x = _quaternion[0],
y = _quaternion[1],
z = _quaternion[2],
w = _quaternion[3];
set(x = 0, y = 0, z = 0, order) {
this[0] = x;
this[1] = y;
this[2] = z;
this[3] = Number.isFinite(order) ? order : this[3];
return this.check();
}
var ysqr = y * y;
var t0 = -2 * (ysqr + z * z) + 1;
var t1 = +2 * (x * y + w * z);
var t2 = -2 * (x * z - w * y);
var t3 = +2 * (y * z + w * x);
var t4 = -2 * (x * x + ysqr) + 1;
t2 = t2 > 1 ? 1 : t2;
t2 = t2 < -1 ? -1 : t2;
var roll = Math.atan2(t3, t4);
var pitch = Math.asin(t2);
var yaw = Math.atan2(t1, t0);
return this.set(roll, pitch, yaw, Euler.RollPitchYaw);
}
}, {
key: "fromObject",
value: function fromObject(object) {
throw new Error('not implemented');
}
}, {
key: "copy",
value: function copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = Number.isFinite(array[3]) || this.order;
return this.check();
}
}, {
key: "set",
value: function set() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var order = arguments.length > 3 ? arguments[3] : undefined;
this[0] = x;
this[1] = y;
this[2] = z;
this[3] = Number.isFinite(order) ? order : this[3];
return this.check();
}
}, {
key: "validate",
value: function validate() {
return validateOrder(this[3]) && Number.isFinite(this[0]) && Number.isFinite(this[1]) && Number.isFinite(this[2]);
}
}, {
key: "toArray",
value: function toArray() {
var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
array[offset] = this[0];
array[offset + 1] = this[1];
array[offset + 2] = this[2];
return array;
}
}, {
key: "toArray4",
value: function toArray4() {
var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
array[offset] = this[0];
array[offset + 1] = this[1];
array[offset + 2] = this[2];
array[offset + 3] = this[3];
return array;
}
}, {
key: "toVector3",
value: function toVector3() {
var result = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [-0, -0, -0];
result[0] = this[0];
result[1] = this[1];
result[2] = this[2];
return result;
}
}, {
key: "x",
get: function get() {
return this[0];
},
set: function set(value) {
this[0] = (0, _validators.checkNumber)(value);
}
}, {
key: "y",
get: function get() {
return this[1];
},
set: function set(value) {
this[1] = (0, _validators.checkNumber)(value);
}
}, {
key: "z",
get: function get() {
return this[2];
},
set: function set(value) {
this[2] = (0, _validators.checkNumber)(value);
}
}, {
key: "alpha",
get: function get() {
return this[0];
},
set: function set(value) {
this[0] = (0, _validators.checkNumber)(value);
}
}, {
key: "beta",
get: function get() {
return this[1];
},
set: function set(value) {
this[1] = (0, _validators.checkNumber)(value);
}
}, {
key: "gamma",
get: function get() {
return this[2];
},
set: function set(value) {
this[2] = (0, _validators.checkNumber)(value);
}
}, {
key: "phi",
get: function get() {
return this[0];
},
set: function set(value) {
this[0] = (0, _validators.checkNumber)(value);
}
}, {
key: "theta",
get: function get() {
return this[1];
},
set: function set(value) {
this[1] = (0, _validators.checkNumber)(value);
}
}, {
key: "psi",
get: function get() {
return this[2];
},
set: function set(value) {
this[2] = (0, _validators.checkNumber)(value);
}
}, {
key: "roll",
get: function get() {
return this[0];
},
set: function set(value) {
this[0] = (0, _validators.checkNumber)(value);
}
}, {
key: "pitch",
get: function get() {
return this[1];
},
set: function set(value) {
this[1] = (0, _validators.checkNumber)(value);
}
}, {
key: "yaw",
get: function get() {
return this[2];
},
set: function set(value) {
this[2] = (0, _validators.checkNumber)(value);
}
}, {
key: "order",
get: function get() {
return this[3];
},
set: function set(value) {
this[3] = checkOrder(value);
}
}, {
key: "fromVector3",
value: function fromVector3(v, order) {
return this.set(v[0], v[1], v[2], Number.isFinite(order) ? order : this[3]);
}
}, {
key: "fromArray",
value: function fromArray(array) {
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
this[0] = array[0 + offset];
this[1] = array[1 + offset];
this[2] = array[2 + offset];
validate() {
return validateOrder(this[3]) && Number.isFinite(this[0]) && Number.isFinite(this[1]) && Number.isFinite(this[2]);
}
if (array[3] !== undefined) {
this[3] = array[3];
}
toArray(array = [], offset = 0) {
array[offset] = this[0];
array[offset + 1] = this[1];
array[offset + 2] = this[2];
return array;
}
return this.check();
}
}, {
key: "fromRollPitchYaw",
value: function fromRollPitchYaw(roll, pitch, yaw) {
return this.set(roll, pitch, yaw, RotationOrder.ZYX);
}
}, {
key: "fromRotationMatrix",
value: function fromRotationMatrix(m) {
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Euler.DefaultOrder;
toArray4(array = [], offset = 0) {
array[offset] = this[0];
array[offset + 1] = this[1];
array[offset + 2] = this[2];
array[offset + 3] = this[3];
return array;
}
this._fromRotationMatrix(m, order);
toVector3(result = [-0, -0, -0]) {
result[0] = this[0];
result[1] = this[1];
result[2] = this[2];
return result;
}
get x() {
return this[0];
}
set x(value) {
this[0] = (0, _validators.checkNumber)(value);
}
get y() {
return this[1];
}
set y(value) {
this[1] = (0, _validators.checkNumber)(value);
}
get z() {
return this[2];
}
set z(value) {
this[2] = (0, _validators.checkNumber)(value);
}
get alpha() {
return this[0];
}
set alpha(value) {
this[0] = (0, _validators.checkNumber)(value);
}
get beta() {
return this[1];
}
set beta(value) {
this[1] = (0, _validators.checkNumber)(value);
}
get gamma() {
return this[2];
}
set gamma(value) {
this[2] = (0, _validators.checkNumber)(value);
}
get phi() {
return this[0];
}
set phi(value) {
this[0] = (0, _validators.checkNumber)(value);
}
get theta() {
return this[1];
}
set theta(value) {
this[1] = (0, _validators.checkNumber)(value);
}
get psi() {
return this[2];
}
set psi(value) {
this[2] = (0, _validators.checkNumber)(value);
}
get roll() {
return this[0];
}
set roll(value) {
this[0] = (0, _validators.checkNumber)(value);
}
get pitch() {
return this[1];
}
set pitch(value) {
this[1] = (0, _validators.checkNumber)(value);
}
get yaw() {
return this[2];
}
set yaw(value) {
this[2] = (0, _validators.checkNumber)(value);
}
get order() {
return this[3];
}
set order(value) {
this[3] = checkOrder(value);
}
fromVector3(v, order) {
return this.set(v[0], v[1], v[2], Number.isFinite(order) ? order : this[3]);
}
fromArray(array, offset = 0) {
this[0] = array[0 + offset];
this[1] = array[1 + offset];
this[2] = array[2 + offset];
if (array[3] !== undefined) {
this[3] = array[3];
return this.check();
}
}, {
key: "getRotationMatrix",
value: function getRotationMatrix(m) {
return this._getRotationMatrix(m);
}
}, {
key: "getQuaternion",
value: function getQuaternion() {
var q = new _quaternion2.default();
return this.check();
}
switch (this[4]) {
case RotationOrder.XYZ:
return q.rotateX(this[0]).rotateY(this[1]).rotateZ(this[2]);
fromRollPitchYaw(roll, pitch, yaw) {
return this.set(roll, pitch, yaw, Euler.ZYX);
}
case RotationOrder.YXZ:
return q.rotateY(this[0]).rotateX(this[1]).rotateZ(this[2]);
fromRotationMatrix(m, order = Euler.DefaultOrder) {
this._fromRotationMatrix(m, order);
case RotationOrder.ZXY:
return q.rotateZ(this[0]).rotateX(this[1]).rotateY(this[2]);
return this.check();
}
case RotationOrder.ZYX:
return q.rotateZ(this[0]).rotateY(this[1]).rotateX(this[2]);
getRotationMatrix(m) {
return this._getRotationMatrix(m);
}
case RotationOrder.YZX:
return q.rotateY(this[0]).rotateZ(this[1]).rotateX(this[2]);
getQuaternion() {
const q = new _quaternion.default();
case RotationOrder.XZY:
return q.rotateX(this[0]).rotateZ(this[1]).rotateY(this[2]);
switch (this[3]) {
case Euler.XYZ:
return q.rotateX(this[0]).rotateY(this[1]).rotateZ(this[2]);
case Euler.YXZ:
return q.rotateY(this[0]).rotateX(this[1]).rotateZ(this[2]);
case Euler.ZXY:
return q.rotateZ(this[0]).rotateX(this[1]).rotateY(this[2]);
case Euler.ZYX:
return q.rotateZ(this[0]).rotateY(this[1]).rotateX(this[2]);
case Euler.YZX:
return q.rotateY(this[0]).rotateZ(this[1]).rotateX(this[2]);
case Euler.XZY:
return q.rotateX(this[0]).rotateZ(this[1]).rotateY(this[2]);
default:
throw new Error(ERR_UNKNOWN_ORDER);
default:
throw new Error(ERR_UNKNOWN_ORDER);
}
}
}
}, {
key: "_fromRotationMatrix",
value: function _fromRotationMatrix(m) {
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Euler.DefaultOrder;
var m11 = m[0],
m12 = m[4],
m13 = m[8];
var m21 = m[1],
m22 = m[5],
m23 = m[9];
var m31 = m[2],
m32 = m[6],
m33 = m[10];
order = order || this[3];
_fromRotationMatrix(m, order = Euler.DefaultOrder) {
const te = m.elements;
const m11 = te[0],
m12 = te[4],
m13 = te[8];
const m21 = te[1],
m22 = te[5],
m23 = te[9];
const m31 = te[2],
m32 = te[6],
m33 = te[10];
order = order || this[3];
switch (order) {
case Euler.XYZ:
this[1] = Math.asin((0, _common.clamp)(m13, -1, 1));
switch (order) {
case Euler.XYZ:
this[1] = Math.asin((0, _common.clamp)(m13, -1, 1));
if (Math.abs(m13) < ALMOST_ONE) {
this[0] = Math.atan2(-m23, m33);
this[2] = Math.atan2(-m12, m11);
} else {
this[0] = Math.atan2(m32, m22);
this[2] = 0;
}
if (Math.abs(m13) < ALMOST_ONE) {
this[0] = Math.atan2(-m23, m33);
this[2] = Math.atan2(-m12, m11);
} else {
this[0] = Math.atan2(m32, m22);
this[2] = 0;
}
break;
break;
case Euler.YXZ:
this[0] = Math.asin(-(0, _common.clamp)(m23, -1, 1));
case Euler.YXZ:
this[0] = Math.asin(-(0, _common.clamp)(m23, -1, 1));
if (Math.abs(m23) < ALMOST_ONE) {
this[1] = Math.atan2(m13, m33);
this[2] = Math.atan2(m21, m22);
} else {
this[1] = Math.atan2(-m31, m11);
this[2] = 0;
}
if (Math.abs(m23) < ALMOST_ONE) {
this[1] = Math.atan2(m13, m33);
this[2] = Math.atan2(m21, m22);
} else {
this[1] = Math.atan2(-m31, m11);
this[2] = 0;
}
break;
break;
case Euler.ZXY:
this[0] = Math.asin((0, _common.clamp)(m32, -1, 1));
case Euler.ZXY:
this[0] = Math.asin((0, _common.clamp)(m32, -1, 1));
if (Math.abs(m32) < ALMOST_ONE) {
this[1] = Math.atan2(-m31, m33);
this[2] = Math.atan2(-m12, m22);
} else {
this[1] = 0;
this[2] = Math.atan2(m21, m11);
}
if (Math.abs(m32) < ALMOST_ONE) {
this[1] = Math.atan2(-m31, m33);
this[2] = Math.atan2(-m12, m22);
} else {
this[1] = 0;
this[2] = Math.atan2(m21, m11);
}
break;
break;
case Euler.ZYX:
this[1] = Math.asin(-(0, _common.clamp)(m31, -1, 1));
case Euler.ZYX:
this[1] = Math.asin(-(0, _common.clamp)(m31, -1, 1));
if (Math.abs(m31) < ALMOST_ONE) {
this[0] = Math.atan2(m32, m33);
this[2] = Math.atan2(m21, m11);
} else {
this[0] = 0;
this[2] = Math.atan2(-m12, m22);
}
if (Math.abs(m31) < ALMOST_ONE) {
this[0] = Math.atan2(m32, m33);
this[2] = Math.atan2(m21, m11);
} else {
this[0] = 0;
this[2] = Math.atan2(-m12, m22);
}
break;
break;
case Euler.YZX:
this[2] = Math.asin((0, _common.clamp)(m21, -1, 1));
case Euler.YZX:
this[2] = Math.asin((0, _common.clamp)(m21, -1, 1));
if (Math.abs(m21) < ALMOST_ONE) {
this[0] = Math.atan2(-m23, m22);
this[1] = Math.atan2(-m31, m11);
} else {
this[0] = 0;
this[1] = Math.atan2(m13, m33);
}
if (Math.abs(m21) < ALMOST_ONE) {
this[0] = Math.atan2(-m23, m22);
this[1] = Math.atan2(-m31, m11);
} else {
this[0] = 0;
this[1] = Math.atan2(m13, m33);
}
break;
break;
case Euler.XZY:
this[2] = Math.asin(-(0, _common.clamp)(m12, -1, 1));
case Euler.XZY:
this[2] = Math.asin(-(0, _common.clamp)(m12, -1, 1));
if (Math.abs(m12) < ALMOST_ONE) {
this[0] = Math.atan2(m32, m22);
this[1] = Math.atan2(m13, m11);
} else {
this[0] = Math.atan2(-m23, m33);
this[1] = 0;
}
if (Math.abs(m12) < ALMOST_ONE) {
this[0] = Math.atan2(m32, m22);
this[1] = Math.atan2(m13, m11);
} else {
this[0] = Math.atan2(-m23, m33);
this[1] = 0;
}
break;
break;
default:
throw new Error(ERR_UNKNOWN_ORDER);
}
default:
throw new Error(ERR_UNKNOWN_ORDER);
this[3] = order;
return this;
}
this[3] = order;
return this;
}
_getRotationMatrix(result) {
const te = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
const x = this.x,
}, {
key: "_getRotationMatrix",
value: function _getRotationMatrix(result) {
var te = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
var x = this.x,
y = this.y,
z = this.z;
const a = Math.cos(x);
const c = Math.cos(y);
const e = Math.cos(z);
const b = Math.sin(x);
const d = Math.sin(y);
const f = Math.sin(z);
var a = Math.cos(x);
var c = Math.cos(y);
var e = Math.cos(z);
var b = Math.sin(x);
var d = Math.sin(y);
var f = Math.sin(z);
switch (this[3]) {
case Euler.XYZ:
{
const ae = a * e,
switch (this[3]) {
case Euler.XYZ:
{
var ae = a * e,
af = a * f,
be = b * e,
bf = b * f;
te[0] = c * e;
te[4] = -c * f;
te[8] = d;
te[1] = af + be * d;
te[5] = ae - bf * d;
te[9] = -b * c;
te[2] = bf - ae * d;
te[6] = be + af * d;
te[10] = a * c;
break;
}
te[0] = c * e;
te[4] = -c * f;
te[8] = d;
te[1] = af + be * d;
te[5] = ae - bf * d;
te[9] = -b * c;
te[2] = bf - ae * d;
te[6] = be + af * d;
te[10] = a * c;
break;
}
case Euler.YXZ:
{
const ce = c * e,
case Euler.YXZ:
{
var ce = c * e,
cf = c * f,
de = d * e,
df = d * f;
te[0] = ce + df * b;
te[4] = de * b - cf;
te[8] = a * d;
te[1] = a * f;
te[5] = a * e;
te[9] = -b;
te[2] = cf * b - de;
te[6] = df + ce * b;
te[10] = a * c;
break;
}
te[0] = ce + df * b;
te[4] = de * b - cf;
te[8] = a * d;
te[1] = a * f;
te[5] = a * e;
te[9] = -b;
te[2] = cf * b - de;
te[6] = df + ce * b;
te[10] = a * c;
break;
}
case Euler.ZXY:
{
const ce = c * e,
cf = c * f,
de = d * e,
df = d * f;
te[0] = ce - df * b;
te[4] = -a * f;
te[8] = de + cf * b;
te[1] = cf + de * b;
te[5] = a * e;
te[9] = df - ce * b;
te[2] = -a * d;
te[6] = b;
te[10] = a * c;
break;
}
case Euler.ZXY:
{
var _ce = c * e,
_cf = c * f,
_de = d * e,
_df = d * f;
case Euler.ZYX:
{
const ae = a * e,
af = a * f,
be = b * e,
bf = b * f;
te[0] = c * e;
te[4] = be * d - af;
te[8] = ae * d + bf;
te[1] = c * f;
te[5] = bf * d + ae;
te[9] = af * d - be;
te[2] = -d;
te[6] = b * c;
te[10] = a * c;
break;
}
te[0] = _ce - _df * b;
te[4] = -a * f;
te[8] = _de + _cf * b;
te[1] = _cf + _de * b;
te[5] = a * e;
te[9] = _df - _ce * b;
te[2] = -a * d;
te[6] = b;
te[10] = a * c;
break;
}
case Euler.YZX:
{
const ac = a * c,
ad = a * d,
bc = b * c,
bd = b * d;
te[0] = c * e;
te[4] = bd - ac * f;
te[8] = bc * f + ad;
te[1] = f;
te[5] = a * e;
te[9] = -b * e;
te[2] = -d * e;
te[6] = ad * f + bc;
te[10] = ac - bd * f;
break;
}
case Euler.ZYX:
{
var _ae = a * e,
_af = a * f,
_be = b * e,
_bf = b * f;
case Euler.XZY:
{
const ac = a * c,
te[0] = c * e;
te[4] = _be * d - _af;
te[8] = _ae * d + _bf;
te[1] = c * f;
te[5] = _bf * d + _ae;
te[9] = _af * d - _be;
te[2] = -d;
te[6] = b * c;
te[10] = a * c;
break;
}
case Euler.YZX:
{
var ac = a * c,
ad = a * d,
bc = b * c,
bd = b * d;
te[0] = c * e;
te[4] = -f;
te[8] = d * e;
te[1] = ac * f + bd;
te[5] = a * e;
te[9] = ad * f - bc;
te[2] = bc * f - ad;
te[6] = b * e;
te[10] = bd * f + ac;
break;
}
te[0] = c * e;
te[4] = bd - ac * f;
te[8] = bc * f + ad;
te[1] = f;
te[5] = a * e;
te[9] = -b * e;
te[2] = -d * e;
te[6] = ad * f + bc;
te[10] = ac - bd * f;
break;
}
default:
throw new Error(ERR_UNKNOWN_ORDER);
case Euler.XZY:
{
var _ac = a * c,
_ad = a * d,
_bc = b * c,
_bd = b * d;
te[0] = c * e;
te[4] = -f;
te[8] = d * e;
te[1] = _ac * f + _bd;
te[5] = a * e;
te[9] = _ad * f - _bc;
te[2] = _bc * f - _ad;
te[6] = b * e;
te[10] = _bd * f + _ac;
break;
}
default:
throw new Error(ERR_UNKNOWN_ORDER);
}
te[3] = 0;
te[7] = 0;
te[11] = 0;
te[12] = 0;
te[13] = 0;
te[14] = 0;
te[15] = 1;
return te;
}
}, {
key: "toQuaternion",
value: function toQuaternion() {
var cy = Math.cos(this.yaw * 0.5);
var sy = Math.sin(this.yaw * 0.5);
var cr = Math.cos(this.roll * 0.5);
var sr = Math.sin(this.roll * 0.5);
var cp = Math.cos(this.pitch * 0.5);
var sp = Math.sin(this.pitch * 0.5);
var w = cy * cr * cp + sy * sr * sp;
var x = cy * sr * cp - sy * cr * sp;
var y = cy * cr * sp + sy * sr * cp;
var z = sy * cr * cp - cy * sr * sp;
return new _quaternion2.default(x, y, z, w);
}
}], [{
key: "ZYX",
get: function get() {
return RotationOrder.ZYX;
}
}, {
key: "YXZ",
get: function get() {
return RotationOrder.YXZ;
}
}, {
key: "XZY",
get: function get() {
return RotationOrder.XZY;
}
}, {
key: "ZXY",
get: function get() {
return RotationOrder.ZXY;
}
}, {
key: "YZX",
get: function get() {
return RotationOrder.YZX;
}
}, {
key: "XYZ",
get: function get() {
return RotationOrder.XYZ;
}
}, {
key: "RollPitchYaw",
get: function get() {
return RotationOrder.ZYX;
}
}, {
key: "DefaultOrder",
get: function get() {
return RotationOrder.ZYX;
}
}, {
key: "RotationOrders",
get: function get() {
return RotationOrder;
}
}, {
key: "rotationOrder",
value: function rotationOrder(order) {
return RotationOrder[order];
}
}]);
return Euler;
}(_mathArray.default);
te[3] = 0;
te[7] = 0;
te[11] = 0;
te[12] = 0;
te[13] = 0;
te[14] = 0;
te[15] = 1;
return te;
}
exports.default = Euler;
toQuaternion() {
const cy = Math.cos(this.yaw * 0.5);
const sy = Math.sin(this.yaw * 0.5);
const cr = Math.cos(this.roll * 0.5);
const sr = Math.sin(this.roll * 0.5);
const cp = Math.cos(this.pitch * 0.5);
const sp = Math.sin(this.pitch * 0.5);
const w = cy * cr * cp + sy * sr * sp;
const x = cy * sr * cp - sy * cr * sp;
const y = cy * cr * sp + sy * sr * cp;
const z = sy * cr * cp - cy * sr * sp;
return new _quaternion.default(x, y, z, w);
function validateOrder(value) {
return value >= 0 && value < 6;
}
function checkOrder(value) {
if (value < 0 && value >= 6) {
throw new Error(ERR_UNKNOWN_ORDER);
}
return value;
}
exports.default = Euler;
//# sourceMappingURL=euler.js.map

@@ -5,2 +5,4 @@ "use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,2 +13,12 @@ value: true

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _matrix = _interopRequireDefault(require("./base/matrix"));

@@ -24,186 +36,250 @@

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const IDENTITY = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
const ZERO = Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0]);
const INDICES = Object.freeze({
COL0ROW0: 0,
COL0ROW1: 1,
COL0ROW2: 2,
COL1ROW0: 3,
COL1ROW1: 4,
COL1ROW2: 5,
COL2ROW0: 6,
COL2ROW1: 7,
COL2ROW2: 8
});
const constants = {};
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
class Matrix3 extends _matrix.default {
static get IDENTITY() {
constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix3(IDENTITY));
return constants.IDENTITY;
}
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
static get ZERO() {
constants.ZERO = constants.ZERO || Object.freeze(new Matrix3(ZERO));
return constants.ZERO;
}
var INDICES;
get ELEMENTS() {
return 9;
}
(function (INDICES) {
INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
INDICES[INDICES["COL0ROW1"] = 1] = "COL0ROW1";
INDICES[INDICES["COL0ROW2"] = 2] = "COL0ROW2";
INDICES[INDICES["COL1ROW0"] = 3] = "COL1ROW0";
INDICES[INDICES["COL1ROW1"] = 4] = "COL1ROW1";
INDICES[INDICES["COL1ROW2"] = 5] = "COL1ROW2";
INDICES[INDICES["COL2ROW0"] = 6] = "COL2ROW0";
INDICES[INDICES["COL2ROW1"] = 7] = "COL2ROW1";
INDICES[INDICES["COL2ROW2"] = 8] = "COL2ROW2";
})(INDICES || (INDICES = {}));
get RANK() {
return 3;
}
var IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
get INDICES() {
return INDICES;
}
var Matrix3 = function (_Matrix) {
(0, _inherits2.default)(Matrix3, _Matrix);
constructor(array) {
super(-0, -0, -0, -0, -0, -0, -0, -0, -0);
var _super = _createSuper(Matrix3);
function Matrix3(array) {
var _this;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
(0, _classCallCheck2.default)(this, Matrix3);
_this = _super.call(this, -0, -0, -0, -0, -0, -0, -0, -0, -0);
if (arguments.length === 1 && Array.isArray(array)) {
this.copy(array);
_this.copy(array);
} else if (args.length > 0) {
_this.copy([array].concat(args));
} else {
this.identity();
_this.identity();
}
}
copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
this[4] = array[4];
this[5] = array[5];
this[6] = array[6];
this[7] = array[7];
this[8] = array[8];
return this.check();
return _this;
}
set(m00, m10, m20, m01, m11, m21, m02, m12, m22) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m01;
this[4] = m11;
this[5] = m21;
this[6] = m02;
this[7] = m12;
this[8] = m22;
return this.check();
}
(0, _createClass2.default)(Matrix3, [{
key: "ELEMENTS",
get: function get() {
return 9;
}
}, {
key: "RANK",
get: function get() {
return 3;
}
}, {
key: "INDICES",
get: function get() {
return INDICES;
}
}, {
key: "copy",
value: function copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
this[4] = array[4];
this[5] = array[5];
this[6] = array[6];
this[7] = array[7];
this[8] = array[8];
return this.check();
}
}, {
key: "identity",
value: function identity() {
return this.copy(IDENTITY_MATRIX);
}
}, {
key: "fromObject",
value: function fromObject(object) {
return this.check();
}
}, {
key: "fromQuaternion",
value: function fromQuaternion(q) {
mat3.fromQuat(this, q);
return this.check();
}
}, {
key: "set",
value: function set(m00, m10, m20, m01, m11, m21, m02, m12, m22) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m01;
this[4] = m11;
this[5] = m21;
this[6] = m02;
this[7] = m12;
this[8] = m22;
return this.check();
}
}, {
key: "setRowMajor",
value: function setRowMajor(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m01;
this[4] = m11;
this[5] = m21;
this[6] = m02;
this[7] = m12;
this[8] = m22;
return this.check();
}
}, {
key: "determinant",
value: function determinant() {
return mat3.determinant(this);
}
}, {
key: "transpose",
value: function transpose() {
mat3.transpose(this, this);
return this.check();
}
}, {
key: "invert",
value: function invert() {
mat3.invert(this, this);
return this.check();
}
}, {
key: "multiplyLeft",
value: function multiplyLeft(a) {
mat3.multiply(this, a, this);
return this.check();
}
}, {
key: "multiplyRight",
value: function multiplyRight(a) {
mat3.multiply(this, this, a);
return this.check();
}
}, {
key: "rotate",
value: function rotate(radians) {
mat3.rotate(this, this, radians);
return this.check();
}
}, {
key: "scale",
value: function scale(factor) {
if (Array.isArray(factor)) {
mat3.scale(this, this, factor);
} else {
mat3.scale(this, this, [factor, factor]);
}
setRowMajor(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m01;
this[4] = m11;
this[5] = m21;
this[6] = m02;
this[7] = m12;
this[8] = m22;
return this.check();
}
determinant() {
return mat3.determinant(this);
}
identity() {
return this.copy(IDENTITY);
}
fromQuaternion(q) {
mat3.fromQuat(this, q);
return this.check();
}
transpose() {
mat3.transpose(this, this);
return this.check();
}
invert() {
mat3.invert(this, this);
return this.check();
}
multiplyLeft(a) {
mat3.multiply(this, a, this);
return this.check();
}
multiplyRight(a) {
mat3.multiply(this, this, a);
return this.check();
}
rotate(radians) {
mat3.rotate(this, this, radians);
return this.check();
}
scale(factor) {
if (Array.isArray(factor)) {
mat3.scale(this, this, factor);
} else {
mat3.scale(this, this, [factor, factor, factor]);
return this.check();
}
}, {
key: "translate",
value: function translate(vec) {
mat3.translate(this, this, vec);
return this.check();
}
}, {
key: "transform",
value: function transform(vector, result) {
switch (vector.length) {
case 2:
result = vec2.transformMat3(result || [-0, -0], vector, this);
break;
return this.check();
}
case 3:
result = vec3.transformMat3(result || [-0, -0, -0], vector, this);
break;
translate(vec) {
mat3.translate(this, this, vec);
return this.check();
}
case 4:
result = (0, _glMatrixExtras.vec4_transformMat3)(result || [-0, -0, -0, -0], vector, this);
break;
transform(vector, result) {
switch (vector.length) {
case 2:
result = vec2.transformMat3(result || [-0, -0], vector, this);
break;
default:
throw new Error('Illegal vector');
}
case 3:
result = vec3.transformMat3(result || [-0, -0, -0], vector, this);
break;
case 4:
result = (0, _glMatrixExtras.vec4_transformMat3)(result || [-0, -0, -0, -0], vector, this);
break;
default:
throw new Error('Illegal vector');
(0, _validators.checkVector)(result, vector.length);
return result;
}
}, {
key: "transformVector",
value: function transformVector(vector, result) {
return this.transform(vector, result);
}
}, {
key: "transformVector2",
value: function transformVector2(vector, result) {
return this.transform(vector, result);
}
}, {
key: "transformVector3",
value: function transformVector3(vector, result) {
return this.transform(vector, result);
}
}], [{
key: "IDENTITY",
get: function get() {
return getIdentityMatrix();
}
}, {
key: "ZERO",
get: function get() {
return getZeroMatrix();
}
}]);
return Matrix3;
}(_matrix.default);
(0, _validators.checkVector)(result, vector.length);
return result;
}
exports.default = Matrix3;
var ZERO_MATRIX3;
var IDENTITY_MATRIX3;
transformVector(vector, result) {
(0, _validators.deprecated)('Matrix3.transformVector');
return this.transform(vector, result);
function getZeroMatrix() {
if (!ZERO_MATRIX3) {
ZERO_MATRIX3 = new Matrix3([0, 0, 0, 0, 0, 0, 0, 0, 0]);
Object.freeze(ZERO_MATRIX3);
}
transformVector2(vector, result) {
(0, _validators.deprecated)('Matrix3.transformVector');
return this.transform(vector, result);
}
return ZERO_MATRIX3;
}
transformVector3(vector, result) {
(0, _validators.deprecated)('Matrix3.transformVector');
return this.transform(vector, result);
function getIdentityMatrix() {
if (!IDENTITY_MATRIX3) {
IDENTITY_MATRIX3 = new Matrix3();
Object.freeze(IDENTITY_MATRIX3);
}
return IDENTITY_MATRIX3;
}
exports.default = Matrix3;
//# sourceMappingURL=matrix3.js.map

@@ -5,2 +5,4 @@ "use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,6 +13,16 @@ value: true

var _validators = require("../lib/validators");
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _matrix = _interopRequireDefault(require("./base/matrix"));
var _validators = require("../lib/validators");
var _glMatrixExtras = require("../lib/gl-matrix-extras");

@@ -26,456 +38,537 @@

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const IDENTITY = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
const ZERO = Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
const INDICES = Object.freeze({
COL0ROW0: 0,
COL0ROW1: 1,
COL0ROW2: 2,
COL0ROW3: 3,
COL1ROW0: 4,
COL1ROW1: 5,
COL1ROW2: 6,
COL1ROW3: 7,
COL2ROW0: 8,
COL2ROW1: 9,
COL2ROW2: 10,
COL2ROW3: 11,
COL3ROW0: 12,
COL3ROW1: 13,
COL3ROW2: 14,
COL3ROW3: 15
});
const constants = {};
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
class Matrix4 extends _matrix.default {
static get IDENTITY() {
constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix4(IDENTITY));
return constants.IDENTITY;
}
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
static get ZERO() {
constants.ZERO = constants.ZERO || Object.freeze(new Matrix4(ZERO));
return constants.ZERO;
}
var INDICES;
get INDICES() {
return INDICES;
}
(function (INDICES) {
INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
INDICES[INDICES["COL0ROW1"] = 1] = "COL0ROW1";
INDICES[INDICES["COL0ROW2"] = 2] = "COL0ROW2";
INDICES[INDICES["COL0ROW3"] = 3] = "COL0ROW3";
INDICES[INDICES["COL1ROW0"] = 4] = "COL1ROW0";
INDICES[INDICES["COL1ROW1"] = 5] = "COL1ROW1";
INDICES[INDICES["COL1ROW2"] = 6] = "COL1ROW2";
INDICES[INDICES["COL1ROW3"] = 7] = "COL1ROW3";
INDICES[INDICES["COL2ROW0"] = 8] = "COL2ROW0";
INDICES[INDICES["COL2ROW1"] = 9] = "COL2ROW1";
INDICES[INDICES["COL2ROW2"] = 10] = "COL2ROW2";
INDICES[INDICES["COL2ROW3"] = 11] = "COL2ROW3";
INDICES[INDICES["COL3ROW0"] = 12] = "COL3ROW0";
INDICES[INDICES["COL3ROW1"] = 13] = "COL3ROW1";
INDICES[INDICES["COL3ROW2"] = 14] = "COL3ROW2";
INDICES[INDICES["COL3ROW3"] = 15] = "COL3ROW3";
})(INDICES || (INDICES = {}));
get ELEMENTS() {
return 16;
}
var DEFAULT_FOVY = 45 * Math.PI / 180;
var DEFAULT_ASPECT = 1;
var DEFAULT_NEAR = 0.1;
var DEFAULT_FAR = 500;
var IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
get RANK() {
return 4;
}
var Matrix4 = function (_Matrix) {
(0, _inherits2.default)(Matrix4, _Matrix);
constructor(array) {
super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
var _super = _createSuper(Matrix4);
if (arguments.length === 1 && Array.isArray(array)) {
this.copy(array);
} else {
this.identity();
}
}
function Matrix4(array) {
var _this;
copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
this[4] = array[4];
this[5] = array[5];
this[6] = array[6];
this[7] = array[7];
this[8] = array[8];
this[9] = array[9];
this[10] = array[10];
this[11] = array[11];
this[12] = array[12];
this[13] = array[13];
this[14] = array[14];
this[15] = array[15];
return this.check();
}
(0, _classCallCheck2.default)(this, Matrix4);
_this = _super.call(this, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m30;
this[4] = m01;
this[5] = m11;
this[6] = m21;
this[7] = m31;
this[8] = m02;
this[9] = m12;
this[10] = m22;
this[11] = m32;
this[12] = m03;
this[13] = m13;
this[14] = m23;
this[15] = m33;
return this.check();
}
setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m30;
this[4] = m01;
this[5] = m11;
this[6] = m21;
this[7] = m31;
this[8] = m02;
this[9] = m12;
this[10] = m22;
this[11] = m32;
this[12] = m03;
this[13] = m13;
this[14] = m23;
this[15] = m33;
return this.check();
}
toRowMajor(result) {
result[0] = this[0];
result[1] = this[4];
result[2] = this[8];
result[3] = this[12];
result[4] = this[1];
result[5] = this[5];
result[6] = this[9];
result[7] = this[13];
result[8] = this[2];
result[9] = this[6];
result[10] = this[10];
result[11] = this[14];
result[12] = this[3];
result[13] = this[7];
result[14] = this[11];
result[15] = this[15];
return result;
}
identity() {
return this.copy(IDENTITY);
}
fromQuaternion(q) {
mat4.fromQuat(this, q);
return this.check();
}
frustum({
left,
right,
bottom,
top,
near,
far
}) {
if (far === Infinity) {
Matrix4._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
if (arguments.length === 1 && Array.isArray(array)) {
_this.copy(array);
} else {
mat4.frustum(this, left, right, bottom, top, near, far);
_this.identity();
}
return this.check();
return _this;
}
static _computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
const column0Row0 = 2.0 * near / (right - left);
const column1Row1 = 2.0 * near / (top - bottom);
const column2Row0 = (right + left) / (right - left);
const column2Row1 = (top + bottom) / (top - bottom);
const column2Row2 = -1.0;
const column2Row3 = -1.0;
const column3Row2 = -2.0 * near;
result[0] = column0Row0;
result[1] = 0.0;
result[2] = 0.0;
result[3] = 0.0;
result[4] = 0.0;
result[5] = column1Row1;
result[6] = 0.0;
result[7] = 0.0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = column2Row3;
result[12] = 0.0;
result[13] = 0.0;
result[14] = column3Row2;
result[15] = 0.0;
return result;
}
lookAt(eye, center, up) {
if (arguments.length === 1) {
({
eye,
center,
up
} = eye);
(0, _createClass2.default)(Matrix4, [{
key: "ELEMENTS",
get: function get() {
return 16;
}
center = center || [0, 0, 0];
up = up || [0, 1, 0];
mat4.lookAt(this, eye, center, up);
return this.check();
}
ortho({
left,
right,
bottom,
top,
near = 0.1,
far = 500
}) {
mat4.ortho(this, left, right, bottom, top, near, far);
return this.check();
}
orthographic({
fovy = 45 * Math.PI / 180,
aspect = 1,
focalDistance = 1,
near = 0.1,
far = 500
}) {
if (fovy > Math.PI * 2) {
throw Error('radians');
}, {
key: "RANK",
get: function get() {
return 4;
}
const halfY = fovy / 2;
const top = focalDistance * Math.tan(halfY);
const right = top * aspect;
return new Matrix4().ortho({
left: -right,
right,
bottom: -top,
top,
near,
far
});
}
perspective({
fovy = undefined,
fov = 45 * Math.PI / 180,
aspect = 1,
near = 0.1,
far = 500
} = {}) {
fovy = fovy || fov;
if (fovy > Math.PI * 2) {
throw Error('radians');
}, {
key: "INDICES",
get: function get() {
return INDICES;
}
}, {
key: "copy",
value: function copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
this[4] = array[4];
this[5] = array[5];
this[6] = array[6];
this[7] = array[7];
this[8] = array[8];
this[9] = array[9];
this[10] = array[10];
this[11] = array[11];
this[12] = array[12];
this[13] = array[13];
this[14] = array[14];
this[15] = array[15];
return this.check();
}
}, {
key: "set",
value: function set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m30;
this[4] = m01;
this[5] = m11;
this[6] = m21;
this[7] = m31;
this[8] = m02;
this[9] = m12;
this[10] = m22;
this[11] = m32;
this[12] = m03;
this[13] = m13;
this[14] = m23;
this[15] = m33;
return this.check();
}
}, {
key: "setRowMajor",
value: function setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m30;
this[4] = m01;
this[5] = m11;
this[6] = m21;
this[7] = m31;
this[8] = m02;
this[9] = m12;
this[10] = m22;
this[11] = m32;
this[12] = m03;
this[13] = m13;
this[14] = m23;
this[15] = m33;
return this.check();
}
}, {
key: "toRowMajor",
value: function toRowMajor(result) {
result[0] = this[0];
result[1] = this[4];
result[2] = this[8];
result[3] = this[12];
result[4] = this[1];
result[5] = this[5];
result[6] = this[9];
result[7] = this[13];
result[8] = this[2];
result[9] = this[6];
result[10] = this[10];
result[11] = this[14];
result[12] = this[3];
result[13] = this[7];
result[14] = this[11];
result[15] = this[15];
return result;
}
}, {
key: "identity",
value: function identity() {
return this.copy(IDENTITY_MATRIX);
}
}, {
key: "fromObject",
value: function fromObject(object) {
return this.check();
}
}, {
key: "fromQuaternion",
value: function fromQuaternion(quaternion) {
mat4.fromQuat(this, quaternion);
return this.check();
}
}, {
key: "frustum",
value: function frustum(view) {
var left = view.left,
right = view.right,
bottom = view.bottom,
top = view.top,
_view$near = view.near,
near = _view$near === void 0 ? DEFAULT_NEAR : _view$near,
_view$far = view.far,
far = _view$far === void 0 ? DEFAULT_FAR : _view$far;
mat4.perspective(this, fovy, aspect, near, far);
return this.check();
}
if (far === Infinity) {
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
} else {
mat4.frustum(this, left, right, bottom, top, near, far);
}
determinant() {
return mat4.determinant(this);
}
getScale(result = [-0, -0, -0]) {
result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
return result;
}
getTranslation(result = [-0, -0, -0]) {
result[0] = this[12];
result[1] = this[13];
result[2] = this[14];
return result;
}
getRotation(result = [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0], scaleResult = null) {
const scale = this.getScale(scaleResult || [-0, -0, -0]);
const inverseScale0 = 1 / scale[0];
const inverseScale1 = 1 / scale[1];
const inverseScale2 = 1 / scale[2];
result[0] = this[0] * inverseScale0;
result[1] = this[1] * inverseScale1;
result[2] = this[2] * inverseScale2;
result[3] = 0;
result[4] = this[4] * inverseScale0;
result[5] = this[5] * inverseScale1;
result[6] = this[6] * inverseScale2;
result[7] = 0;
result[8] = this[8] * inverseScale0;
result[9] = this[9] * inverseScale1;
result[10] = this[10] * inverseScale2;
result[11] = 0;
result[12] = 0;
result[13] = 0;
result[14] = 0;
result[15] = 1;
return result;
}
getRotationMatrix3(result = [-0, -0, -0, -0, -0, -0, -0, -0, -0], scaleResult = null) {
const scale = this.getScale(scaleResult || [-0, -0, -0]);
const inverseScale0 = 1 / scale[0];
const inverseScale1 = 1 / scale[1];
const inverseScale2 = 1 / scale[2];
result[0] = this[0] * inverseScale0;
result[1] = this[1] * inverseScale1;
result[2] = this[2] * inverseScale2;
result[3] = this[4] * inverseScale0;
result[4] = this[5] * inverseScale1;
result[5] = this[6] * inverseScale2;
result[6] = this[8] * inverseScale0;
result[7] = this[9] * inverseScale1;
result[8] = this[10] * inverseScale2;
return result;
}
transpose() {
mat4.transpose(this, this);
return this.check();
}
invert() {
mat4.invert(this, this);
return this.check();
}
multiplyLeft(a) {
mat4.multiply(this, a, this);
return this.check();
}
multiplyRight(a) {
mat4.multiply(this, this, a);
return this.check();
}
rotateX(radians) {
mat4.rotateX(this, this, radians);
return this.check();
}
rotateY(radians) {
mat4.rotateY(this, this, radians);
return this.check();
}
rotateZ(radians) {
mat4.rotateZ(this, this, radians);
return this.check();
}
rotateXYZ([rx, ry, rz]) {
return this.rotateX(rx).rotateY(ry).rotateZ(rz);
}
rotateAxis(radians, axis) {
mat4.rotate(this, this, radians, axis);
return this.check();
}
scale(factor) {
if (Array.isArray(factor)) {
mat4.scale(this, this, factor);
} else {
mat4.scale(this, this, [factor, factor, factor]);
return this.check();
}
return this.check();
}
translate(vec) {
mat4.translate(this, this, vec);
return this.check();
}
transform(vector, result) {
if (vector.length === 4) {
result = vec4.transformMat4(result || [-0, -0, -0, -0], vector, this);
(0, _validators.checkVector)(result, 4);
}, {
key: "lookAt",
value: function lookAt(view) {
var eye = view.eye,
_view$center = view.center,
center = _view$center === void 0 ? [0, 0, 0] : _view$center,
_view$up = view.up,
up = _view$up === void 0 ? [0, 1, 0] : _view$up;
mat4.lookAt(this, eye, center, up);
return this.check();
}
}, {
key: "ortho",
value: function ortho(view) {
var left = view.left,
right = view.right,
bottom = view.bottom,
top = view.top,
_view$near2 = view.near,
near = _view$near2 === void 0 ? DEFAULT_NEAR : _view$near2,
_view$far2 = view.far,
far = _view$far2 === void 0 ? DEFAULT_FAR : _view$far2;
mat4.ortho(this, left, right, bottom, top, near, far);
return this.check();
}
}, {
key: "orthographic",
value: function orthographic(view) {
var _view$fovy = view.fovy,
fovy = _view$fovy === void 0 ? DEFAULT_FOVY : _view$fovy,
_view$aspect = view.aspect,
aspect = _view$aspect === void 0 ? DEFAULT_ASPECT : _view$aspect,
_view$focalDistance = view.focalDistance,
focalDistance = _view$focalDistance === void 0 ? 1 : _view$focalDistance,
_view$near3 = view.near,
near = _view$near3 === void 0 ? DEFAULT_NEAR : _view$near3,
_view$far3 = view.far,
far = _view$far3 === void 0 ? DEFAULT_FAR : _view$far3;
checkRadians(fovy);
var halfY = fovy / 2;
var top = focalDistance * Math.tan(halfY);
var right = top * aspect;
return this.ortho({
left: -right,
right: right,
bottom: -top,
top: top,
near: near,
far: far
});
}
}, {
key: "perspective",
value: function perspective(view) {
var _view$fovy2 = view.fovy,
fovy = _view$fovy2 === void 0 ? 45 * Math.PI / 180 : _view$fovy2,
_view$aspect2 = view.aspect,
aspect = _view$aspect2 === void 0 ? 1 : _view$aspect2,
_view$near4 = view.near,
near = _view$near4 === void 0 ? 0.1 : _view$near4,
_view$far4 = view.far,
far = _view$far4 === void 0 ? 500 : _view$far4;
checkRadians(fovy);
mat4.perspective(this, fovy, aspect, near, far);
return this.check();
}
}, {
key: "determinant",
value: function determinant() {
return mat4.determinant(this);
}
}, {
key: "getScale",
value: function getScale() {
var result = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [-0, -0, -0];
result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
return result;
}
}, {
key: "getTranslation",
value: function getTranslation() {
var result = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [-0, -0, -0];
result[0] = this[12];
result[1] = this[13];
result[2] = this[14];
return result;
}
}, {
key: "getRotation",
value: function getRotation(result, scaleResult) {
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
scaleResult = scaleResult || [-0, -0, -0];
var scale = this.getScale(scaleResult);
var inverseScale0 = 1 / scale[0];
var inverseScale1 = 1 / scale[1];
var inverseScale2 = 1 / scale[2];
result[0] = this[0] * inverseScale0;
result[1] = this[1] * inverseScale1;
result[2] = this[2] * inverseScale2;
result[3] = 0;
result[4] = this[4] * inverseScale0;
result[5] = this[5] * inverseScale1;
result[6] = this[6] * inverseScale2;
result[7] = 0;
result[8] = this[8] * inverseScale0;
result[9] = this[9] * inverseScale1;
result[10] = this[10] * inverseScale2;
result[11] = 0;
result[12] = 0;
result[13] = 0;
result[14] = 0;
result[15] = 1;
return result;
}
}, {
key: "getRotationMatrix3",
value: function getRotationMatrix3(result, scaleResult) {
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
scaleResult = scaleResult || [-0, -0, -0];
var scale = this.getScale(scaleResult);
var inverseScale0 = 1 / scale[0];
var inverseScale1 = 1 / scale[1];
var inverseScale2 = 1 / scale[2];
result[0] = this[0] * inverseScale0;
result[1] = this[1] * inverseScale1;
result[2] = this[2] * inverseScale2;
result[3] = this[4] * inverseScale0;
result[4] = this[5] * inverseScale1;
result[5] = this[6] * inverseScale2;
result[6] = this[8] * inverseScale0;
result[7] = this[9] * inverseScale1;
result[8] = this[10] * inverseScale2;
return result;
}
}, {
key: "transpose",
value: function transpose() {
mat4.transpose(this, this);
return this.check();
}
}, {
key: "invert",
value: function invert() {
mat4.invert(this, this);
return this.check();
}
}, {
key: "multiplyLeft",
value: function multiplyLeft(a) {
mat4.multiply(this, a, this);
return this.check();
}
}, {
key: "multiplyRight",
value: function multiplyRight(a) {
mat4.multiply(this, this, a);
return this.check();
}
}, {
key: "rotateX",
value: function rotateX(radians) {
mat4.rotateX(this, this, radians);
return this.check();
}
}, {
key: "rotateY",
value: function rotateY(radians) {
mat4.rotateY(this, this, radians);
return this.check();
}
}, {
key: "rotateZ",
value: function rotateZ(radians) {
mat4.rotateZ(this, this, radians);
return this.check();
}
}, {
key: "rotateXYZ",
value: function rotateXYZ(angleXYZ) {
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
}
}, {
key: "rotateAxis",
value: function rotateAxis(radians, axis) {
mat4.rotate(this, this, radians, axis);
return this.check();
}
}, {
key: "scale",
value: function scale(factor) {
mat4.scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
return this.check();
}
}, {
key: "translate",
value: function translate(vector) {
mat4.translate(this, this, vector);
return this.check();
}
}, {
key: "transform",
value: function transform(vector, result) {
if (vector.length === 4) {
result = vec4.transformMat4(result || [-0, -0, -0, -0], vector, this);
(0, _validators.checkVector)(result, 4);
return result;
}
return this.transformAsPoint(vector, result);
}
return this.transformAsPoint(vector, result);
}
}, {
key: "transformAsPoint",
value: function transformAsPoint(vector, result) {
var length = vector.length;
transformAsPoint(vector, result) {
const {
length
} = vector;
switch (length) {
case 2:
result = vec2.transformMat4(result || [-0, -0], vector, this);
break;
switch (length) {
case 2:
result = vec2.transformMat4(result || [-0, -0], vector, this);
break;
case 3:
result = vec3.transformMat4(result || [-0, -0, -0], vector, this);
break;
case 3:
result = vec3.transformMat4(result || [-0, -0, -0], vector, this);
break;
default:
throw new Error('Illegal vector');
}
default:
throw new Error('Illegal vector');
(0, _validators.checkVector)(result, vector.length);
return result;
}
}, {
key: "transformAsVector",
value: function transformAsVector(vector, result) {
switch (vector.length) {
case 2:
result = (0, _glMatrixExtras.vec2_transformMat4AsVector)(result || [-0, -0], vector, this);
break;
(0, _validators.checkVector)(result, vector.length);
return result;
}
case 3:
result = (0, _glMatrixExtras.vec3_transformMat4AsVector)(result || [-0, -0, -0], vector, this);
break;
transformAsVector(vector, result) {
switch (vector.length) {
case 2:
result = (0, _glMatrixExtras.vec2_transformMat4AsVector)(result || [-0, -0], vector, this);
break;
default:
throw new Error('Illegal vector');
}
case 3:
result = (0, _glMatrixExtras.vec3_transformMat4AsVector)(result || [-0, -0, -0], vector, this);
break;
default:
throw new Error('Illegal vector');
(0, _validators.checkVector)(result, vector.length);
return result;
}
}, {
key: "transformPoint",
value: function transformPoint(vector, result) {
return this.transformAsPoint(vector, result);
}
}, {
key: "transformVector",
value: function transformVector(vector, result) {
return this.transformAsPoint(vector, result);
}
}, {
key: "transformDirection",
value: function transformDirection(vector, result) {
return this.transformAsVector(vector, result);
}
}, {
key: "makeRotationX",
value: function makeRotationX(radians) {
return this.identity().rotateX(radians);
}
}, {
key: "makeTranslation",
value: function makeTranslation(x, y, z) {
return this.identity().translate([x, y, z]);
}
}], [{
key: "IDENTITY",
get: function get() {
return getIdentityMatrix();
}
}, {
key: "ZERO",
get: function get() {
return getZeroMatrix();
}
}]);
return Matrix4;
}(_matrix.default);
(0, _validators.checkVector)(result, vector.length);
return result;
}
exports.default = Matrix4;
var ZERO;
var IDENTITY;
makeRotationX(radians) {
return this.identity().rotateX(radians);
function getZeroMatrix() {
if (!ZERO) {
ZERO = new Matrix4([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
Object.freeze(ZERO);
}
makeTranslation(x, y, z) {
return this.identity().translate([x, y, z]);
}
return ZERO;
}
transformPoint(vector, result) {
(0, _validators.deprecated)('Matrix4.transformPoint', '3.0');
return this.transformAsPoint(vector, result);
function getIdentityMatrix() {
if (!IDENTITY) {
IDENTITY = new Matrix4();
Object.freeze(IDENTITY);
}
transformVector(vector, result) {
(0, _validators.deprecated)('Matrix4.transformVector', '3.0');
return this.transformAsPoint(vector, result);
}
return IDENTITY;
}
transformDirection(vector, result) {
(0, _validators.deprecated)('Matrix4.transformDirection', '3.0');
return this.transformAsVector(vector, result);
function checkRadians(possiblyDegrees) {
if (possiblyDegrees > Math.PI * 2) {
throw Error('expected radians');
}
}
function computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
var column0Row0 = 2 * near / (right - left);
var column1Row1 = 2 * near / (top - bottom);
var column2Row0 = (right + left) / (right - left);
var column2Row1 = (top + bottom) / (top - bottom);
var column2Row2 = -1;
var column2Row3 = -1;
var column3Row2 = -2 * near;
result[0] = column0Row0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = column1Row1;
result[6] = 0;
result[7] = 0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = column2Row3;
result[12] = 0;
result[13] = 0;
result[14] = column3Row2;
result[15] = 0;
return result;
}
exports.default = Matrix4;
//# sourceMappingURL=matrix4.js.map

@@ -10,2 +10,8 @@ "use strict";

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _matrix = _interopRequireDefault(require("./matrix4"));

@@ -17,13 +23,24 @@

class Pose {
constructor({
x = 0,
y = 0,
z = 0,
roll = 0,
pitch = 0,
yaw = 0,
position = undefined,
orientation = undefined
} = {}) {
var Pose = function () {
function Pose() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$x = _ref.x,
x = _ref$x === void 0 ? 0 : _ref$x,
_ref$y = _ref.y,
y = _ref$y === void 0 ? 0 : _ref$y,
_ref$z = _ref.z,
z = _ref$z === void 0 ? 0 : _ref$z,
_ref$roll = _ref.roll,
roll = _ref$roll === void 0 ? 0 : _ref$roll,
_ref$pitch = _ref.pitch,
pitch = _ref$pitch === void 0 ? 0 : _ref$pitch,
_ref$yaw = _ref.yaw,
yaw = _ref$yaw === void 0 ? 0 : _ref$yaw,
position = _ref.position,
orientation = _ref.orientation;
(0, _classCallCheck2.default)(this, Pose);
(0, _defineProperty2.default)(this, "position", void 0);
(0, _defineProperty2.default)(this, "orientation", void 0);
if (Array.isArray(position) && position.length === 3) {

@@ -42,96 +59,104 @@ this.position = new _vector.default(position);

get x() {
return this.position.x;
}
(0, _createClass2.default)(Pose, [{
key: "x",
get: function get() {
return this.position.x;
},
set: function set(value) {
this.position.x = value;
}
}, {
key: "y",
get: function get() {
return this.position.y;
},
set: function set(value) {
this.position.y = value;
}
}, {
key: "z",
get: function get() {
return this.position.z;
},
set: function set(value) {
this.position.z = value;
}
}, {
key: "roll",
get: function get() {
return this.orientation.roll;
},
set: function set(value) {
this.orientation.roll = value;
}
}, {
key: "pitch",
get: function get() {
return this.orientation.pitch;
},
set: function set(value) {
this.orientation.pitch = value;
}
}, {
key: "yaw",
get: function get() {
return this.orientation.yaw;
},
set: function set(value) {
this.orientation.yaw = value;
}
}, {
key: "getPosition",
value: function getPosition() {
return this.position;
}
}, {
key: "getOrientation",
value: function getOrientation() {
return this.orientation;
}
}, {
key: "equals",
value: function equals(pose) {
if (!pose) {
return false;
}
set x(value) {
this.position.x = value;
}
get y() {
return this.position.y;
}
set y(value) {
this.position.y = value;
}
get z() {
return this.position.z;
}
set z(value) {
this.position.z = value;
}
get roll() {
return this.orientation.roll;
}
set roll(value) {
this.orientation.roll = value;
}
get pitch() {
return this.orientation.pitch;
}
set pitch(value) {
this.orientation.pitch = value;
}
get yaw() {
return this.orientation.yaw;
}
set yaw(value) {
this.orientation.yaw = value;
}
getPosition() {
return this.position;
}
getOrientation() {
return this.orientation;
}
equals(pose) {
if (!pose) {
return false;
return this.position.equals(pose.position) && this.orientation.equals(pose.orientation);
}
}, {
key: "exactEquals",
value: function exactEquals(pose) {
if (!pose) {
return false;
}
return this.position.equals(pose.position) && this.orientation.equals(pose.orientation);
}
exactEquals(pose) {
if (!pose) {
return false;
return this.position.exactEquals(pose.position) && this.orientation.exactEquals(pose.orientation);
}
}, {
key: "getTransformationMatrix",
value: function getTransformationMatrix() {
var sr = Math.sin(this.roll);
var sp = Math.sin(this.pitch);
var sw = Math.sin(this.yaw);
var cr = Math.cos(this.roll);
var cp = Math.cos(this.pitch);
var cw = Math.cos(this.yaw);
return new _matrix.default().setRowMajor(cw * cp, -sw * cr + cw * sp * sr, sw * sr + cw * sp * cr, this.x, sw * cp, cw * cr + sw * sp * sr, -cw * sr + sw * sp * cr, this.y, -sp, cp * sr, cp * cr, this.z, 0, 0, 0, 1);
}
}, {
key: "getTransformationMatrixFromPose",
value: function getTransformationMatrixFromPose(pose) {
return new _matrix.default().multiplyRight(this.getTransformationMatrix()).multiplyRight(pose.getTransformationMatrix().invert());
}
}, {
key: "getTransformationMatrixToPose",
value: function getTransformationMatrixToPose(pose) {
return new _matrix.default().multiplyRight(pose.getTransformationMatrix()).multiplyRight(this.getTransformationMatrix().invert());
}
}]);
return Pose;
}();
return this.position.exactEquals(pose.position) && this.orientation.exactEquals(pose.orientation);
}
getTransformationMatrix() {
const sr = Math.sin(this.roll);
const sp = Math.sin(this.pitch);
const sw = Math.sin(this.yaw);
const cr = Math.cos(this.roll);
const cp = Math.cos(this.pitch);
const cw = Math.cos(this.yaw);
const matrix = new _matrix.default().setRowMajor(cw * cp, -sw * cr + cw * sp * sr, sw * sr + cw * sp * cr, this.x, sw * cp, cw * cr + sw * sp * sr, -cw * sr + sw * sp * cr, this.y, -sp, cp * sr, cp * cr, this.z, 0, 0, 0, 1);
return matrix;
}
getTransformationMatrixFromPose(pose) {
return new _matrix.default().multiplyRight(this.getTransformationMatrix()).multiplyRight(pose.getTransformationMatrix().invert());
}
getTransformationMatrixToPose(pose) {
return new _matrix.default().multiplyRight(pose.getTransformationMatrix()).multiplyRight(this.getTransformationMatrix().invert());
}
}
exports.default = Pose;
//# sourceMappingURL=pose.js.map

@@ -5,2 +5,4 @@ "use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,243 +13,313 @@ value: true

var _mathArray = _interopRequireDefault(require("./base/math-array"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _validators = require("../lib/validators");
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assert = _interopRequireDefault(require("../lib/assert"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var quat = _interopRequireWildcard(require("gl-matrix/quat"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var vec4 = _interopRequireWildcard(require("gl-matrix/vec4"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
var _mathArray = _interopRequireDefault(require("./base/math-array"));
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _validators = require("../lib/validators");
const IDENTITY_QUATERNION = [0, 0, 0, 1];
var _vector = _interopRequireDefault(require("./vector4"));
class Quaternion extends _mathArray.default {
constructor(x = 0, y = 0, z = 0, w = 1) {
super(-0, -0, -0, -0);
var quat = _interopRequireWildcard(require("gl-matrix/quat"));
if (Array.isArray(x) && arguments.length === 1) {
this.copy(x);
} else {
this.set(x, y, z, w);
}
}
var vec4 = _interopRequireWildcard(require("gl-matrix/vec4"));
copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
return this.check();
}
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
set(x, y, z, w) {
this[0] = x;
this[1] = y;
this[2] = z;
this[3] = w;
return this.check();
}
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
fromMatrix3(m) {
quat.fromMat3(this, m);
return this.check();
}
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
identity() {
quat.identity(this);
return this.check();
}
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
fromAxisRotation(axis, rad) {
quat.setAxisAngle(this, axis, rad);
return this.check();
}
var IDENTITY_QUATERNION = [0, 0, 0, 1];
setAxisAngle(axis, rad) {
return this.fromAxisRotation(axis, rad);
}
var Quaternion = function (_MathArray) {
(0, _inherits2.default)(Quaternion, _MathArray);
get ELEMENTS() {
return 4;
}
var _super = _createSuper(Quaternion);
get x() {
return this[0];
}
function Quaternion() {
var _this;
set x(value) {
this[0] = (0, _validators.checkNumber)(value);
}
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var w = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
(0, _classCallCheck2.default)(this, Quaternion);
_this = _super.call(this, -0, -0, -0, -0);
get y() {
return this[1];
}
if (Array.isArray(x) && arguments.length === 1) {
_this.copy(x);
} else {
_this.set(x, y, z, w);
}
set y(value) {
this[1] = (0, _validators.checkNumber)(value);
return _this;
}
get z() {
return this[2];
}
set z(value) {
this[2] = (0, _validators.checkNumber)(value);
}
get w() {
return this[3];
}
set w(value) {
this[3] = (0, _validators.checkNumber)(value);
}
len() {
return quat.length(this);
}
lengthSquared() {
return quat.squaredLength(this);
}
dot(a, b) {
if (b !== undefined) {
throw new Error('Quaternion.dot only takes one argument');
(0, _createClass2.default)(Quaternion, [{
key: "copy",
value: function copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
return this.check();
}
}, {
key: "set",
value: function set(x, y, z, w) {
this[0] = x;
this[1] = y;
this[2] = z;
this[3] = w;
return this.check();
}
}, {
key: "fromObject",
value: function fromObject(object) {
this[0] = object.x;
this[1] = object.y;
this[2] = object.z;
this[3] = object.w;
return this.check();
}
}, {
key: "fromMatrix3",
value: function fromMatrix3(m) {
quat.fromMat3(this, m);
return this.check();
}
}, {
key: "fromAxisRotation",
value: function fromAxisRotation(axis, rad) {
quat.setAxisAngle(this, axis, rad);
return this.check();
}
}, {
key: "identity",
value: function identity() {
quat.identity(this);
return this.check();
}
}, {
key: "setAxisAngle",
value: function setAxisAngle(axis, rad) {
return this.fromAxisRotation(axis, rad);
}
}, {
key: "ELEMENTS",
get: function get() {
return 4;
}
}, {
key: "x",
get: function get() {
return this[0];
},
set: function set(value) {
this[0] = (0, _validators.checkNumber)(value);
}
}, {
key: "y",
get: function get() {
return this[1];
},
set: function set(value) {
this[1] = (0, _validators.checkNumber)(value);
}
}, {
key: "z",
get: function get() {
return this[2];
},
set: function set(value) {
this[2] = (0, _validators.checkNumber)(value);
}
}, {
key: "w",
get: function get() {
return this[3];
},
set: function set(value) {
this[3] = (0, _validators.checkNumber)(value);
}
}, {
key: "len",
value: function len() {
return quat.length(this);
}
}, {
key: "lengthSquared",
value: function lengthSquared() {
return quat.squaredLength(this);
}
}, {
key: "dot",
value: function dot(a) {
return quat.dot(this, a);
}
}, {
key: "rotationTo",
value: function rotationTo(vectorA, vectorB) {
quat.rotationTo(this, vectorA, vectorB);
return this.check();
}
}, {
key: "add",
value: function add(a) {
quat.add(this, this, a);
return this.check();
}
}, {
key: "calculateW",
value: function calculateW() {
quat.calculateW(this, this);
return this.check();
}
}, {
key: "conjugate",
value: function conjugate() {
quat.conjugate(this, this);
return this.check();
}
}, {
key: "invert",
value: function invert() {
quat.invert(this, this);
return this.check();
}
}, {
key: "lerp",
value: function lerp(a, b, t) {
if (t === undefined) {
return this.lerp(this, a, b);
}
return quat.dot(this, a);
}
rotationTo(vectorA, vectorB) {
quat.rotationTo(this, vectorA, vectorB);
return this.check();
}
add(a, b) {
if (b !== undefined) {
throw new Error('Quaternion.add only takes one argument');
quat.lerp(this, a, b, t);
return this.check();
}
}, {
key: "multiplyRight",
value: function multiplyRight(a) {
quat.multiply(this, this, a);
return this.check();
}
}, {
key: "multiplyLeft",
value: function multiplyLeft(a) {
quat.multiply(this, a, this);
return this.check();
}
}, {
key: "normalize",
value: function normalize() {
var length = this.len();
var l = length > 0 ? 1 / length : 0;
this[0] = this[0] * l;
this[1] = this[1] * l;
this[2] = this[2] * l;
this[3] = this[3] * l;
quat.add(this, this, a);
return this.check();
}
if (length === 0) {
this[3] = 1;
}
calculateW() {
quat.calculateW(this, this);
return this.check();
}
conjugate() {
quat.conjugate(this, this);
return this.check();
}
invert() {
quat.invert(this, this);
return this.check();
}
lerp(a, b, t) {
quat.lerp(this, a, b, t);
return this.check();
}
multiplyRight(a, b) {
(0, _assert.default)(!b);
quat.multiply(this, this, a);
return this.check();
}
multiplyLeft(a, b) {
(0, _assert.default)(!b);
quat.multiply(this, a, this);
return this.check();
}
normalize() {
const length = this.len();
const l = length > 0 ? 1 / length : 0;
this[0] = this[0] * l;
this[1] = this[1] * l;
this[2] = this[2] * l;
this[3] = this[3] * l;
if (length === 0) {
this[3] = 1;
return this.check();
}
}, {
key: "rotateX",
value: function rotateX(rad) {
quat.rotateX(this, this, rad);
return this.check();
}
}, {
key: "rotateY",
value: function rotateY(rad) {
quat.rotateY(this, this, rad);
return this.check();
}
}, {
key: "rotateZ",
value: function rotateZ(rad) {
quat.rotateZ(this, this, rad);
return this.check();
}
}, {
key: "scale",
value: function scale(b) {
quat.scale(this, this, b);
return this.check();
}
}, {
key: "slerp",
value: function slerp(arg0, arg1, arg2) {
var start;
var target;
var ratio;
return this.check();
}
switch (arguments.length) {
case 1:
var _ref = arg0;
var _ref$start = _ref.start;
start = _ref$start === void 0 ? IDENTITY_QUATERNION : _ref$start;
target = _ref.target;
ratio = _ref.ratio;
break;
rotateX(rad) {
quat.rotateX(this, this, rad);
return this.check();
}
case 2:
start = this;
target = arg0;
ratio = arg1;
break;
rotateY(rad) {
quat.rotateY(this, this, rad);
return this.check();
}
default:
start = arg0;
target = arg1;
ratio = arg2;
}
rotateZ(rad) {
quat.rotateZ(this, this, rad);
return this.check();
}
scale(b) {
quat.scale(this, this, b);
return this.check();
}
slerp(start, target, ratio) {
switch (arguments.length) {
case 1:
({
start = IDENTITY_QUATERNION,
target,
ratio
} = arguments[0]);
break;
case 2:
[target, ratio] = arguments;
start = this;
break;
default:
quat.slerp(this, start, target, ratio);
return this.check();
}
}, {
key: "transformVector4",
value: function transformVector4(vector) {
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _vector.default();
vec4.transformQuat(result, vector, this);
return (0, _validators.checkVector)(result, 4);
}
}, {
key: "lengthSq",
value: function lengthSq() {
return this.lengthSquared();
}
}, {
key: "setFromAxisAngle",
value: function setFromAxisAngle(axis, rad) {
return this.setAxisAngle(axis, rad);
}
}, {
key: "premultiply",
value: function premultiply(a) {
return this.multiplyLeft(a);
}
}, {
key: "multiply",
value: function multiply(a) {
return this.multiplyRight(a);
}
}]);
return Quaternion;
}(_mathArray.default);
quat.slerp(this, start, target, ratio);
return this.check();
}
transformVector4(vector, result = vector) {
vec4.transformQuat(result, vector, this);
return (0, _validators.checkVector)(result, 4);
}
lengthSq() {
return this.lengthSquared();
}
setFromAxisAngle(axis, rad) {
return this.setAxisAngle(axis, rad);
}
premultiply(a, b) {
return this.multiplyLeft(a, b);
}
multiply(a, b) {
return this.multiplyRight(a, b);
}
}
exports.default = Quaternion;
//# sourceMappingURL=quaternion.js.map

@@ -5,2 +5,4 @@ "use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,25 +13,43 @@ value: true

var _common = require("../lib/common");
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _vector = _interopRequireDefault(require("./vector3"));
var _common = require("../lib/common");
var vec3 = _interopRequireWildcard(require("gl-matrix/vec3"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const EPSILON = 0.000001;
const EARTH_RADIUS_METERS = 6.371e6;
var EPSILON = 0.000001;
var EARTH_RADIUS_METERS = 6371000;
class SphericalCoordinates {
constructor({
phi = 0,
theta = 0,
radius = 1,
bearing = undefined,
pitch = undefined,
altitude = undefined,
radiusScale = EARTH_RADIUS_METERS
} = {}) {
var SphericalCoordinates = function () {
function SphericalCoordinates() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$phi = _ref.phi,
phi = _ref$phi === void 0 ? 0 : _ref$phi,
_ref$theta = _ref.theta,
theta = _ref$theta === void 0 ? 0 : _ref$theta,
_ref$radius = _ref.radius,
radius = _ref$radius === void 0 ? 1 : _ref$radius,
bearing = _ref.bearing,
pitch = _ref.pitch,
altitude = _ref.altitude,
_ref$radiusScale = _ref.radiusScale,
radiusScale = _ref$radiusScale === void 0 ? EARTH_RADIUS_METERS : _ref$radiusScale;
(0, _classCallCheck2.default)(this, SphericalCoordinates);
(0, _defineProperty2.default)(this, "phi", void 0);
(0, _defineProperty2.default)(this, "theta", void 0);
(0, _defineProperty2.default)(this, "radius", void 0);
(0, _defineProperty2.default)(this, "radiusScale", void 0);
this.phi = phi;

@@ -51,116 +71,141 @@ this.theta = theta;

toString() {
return this.formatString(_common.config);
}
(0, _createClass2.default)(SphericalCoordinates, [{
key: "toString",
value: function toString() {
return this.formatString(_common.config);
}
}, {
key: "formatString",
value: function formatString(_ref2) {
var _ref2$printTypes = _ref2.printTypes,
printTypes = _ref2$printTypes === void 0 ? false : _ref2$printTypes;
var f = _common.formatValue;
return "".concat(printTypes ? 'Spherical' : '', "[rho:").concat(f(this.radius), ",theta:").concat(f(this.theta), ",phi:").concat(f(this.phi), "]");
}
}, {
key: "equals",
value: function equals(other) {
return (0, _common.equals)(this.radius, other.radius) && (0, _common.equals)(this.theta, other.theta) && (0, _common.equals)(this.phi, other.phi);
}
}, {
key: "exactEquals",
value: function exactEquals(other) {
return this.radius === other.radius && this.theta === other.theta && this.phi === other.phi;
}
}, {
key: "bearing",
get: function get() {
return 180 - (0, _common.degrees)(this.phi);
},
set: function set(v) {
this.phi = Math.PI - (0, _common.radians)(v);
}
}, {
key: "pitch",
get: function get() {
return (0, _common.degrees)(this.theta);
},
set: function set(v) {
this.theta = (0, _common.radians)(v);
}
}, {
key: "longitude",
get: function get() {
return (0, _common.degrees)(this.phi);
}
}, {
key: "latitude",
get: function get() {
return (0, _common.degrees)(this.theta);
}
}, {
key: "lng",
get: function get() {
return (0, _common.degrees)(this.phi);
}
}, {
key: "lat",
get: function get() {
return (0, _common.degrees)(this.theta);
}
}, {
key: "z",
get: function get() {
return (this.radius - 1) * this.radiusScale;
}
}, {
key: "set",
value: function set(radius, phi, theta) {
this.radius = radius;
this.phi = phi;
this.theta = theta;
return this.check();
}
}, {
key: "clone",
value: function clone() {
return new SphericalCoordinates().copy(this);
}
}, {
key: "copy",
value: function copy(other) {
this.radius = other.radius;
this.phi = other.phi;
this.theta = other.theta;
return this.check();
}
}, {
key: "fromLngLatZ",
value: function fromLngLatZ(_ref3) {
var _ref4 = (0, _slicedToArray2.default)(_ref3, 3),
lng = _ref4[0],
lat = _ref4[1],
z = _ref4[2];
formatString({
printTypes = false
}) {
const f = _common.formatValue;
return "".concat(printTypes ? 'Spherical' : '', "[rho:").concat(f(this.radius), ",theta:").concat(f(this.theta), ",phi:").concat(f(this.phi), "]");
}
this.radius = 1 + z / this.radiusScale;
this.phi = (0, _common.radians)(lat);
this.theta = (0, _common.radians)(lng);
return this.check();
}
}, {
key: "fromVector3",
value: function fromVector3(v) {
this.radius = vec3.length(v);
equals(other) {
return (0, _common.equals)(this.radius, other.radius) && (0, _common.equals)(this.theta, other.theta) && (0, _common.equals)(this.phi, other.phi);
}
if (this.radius > 0) {
this.theta = Math.atan2(v[0], v[1]);
this.phi = Math.acos((0, _common.clamp)(v[2] / this.radius, -1, 1));
}
exactEquals(other) {
return this.radius === other.radius && this.theta === other.theta && this.phi === other.phi;
}
get bearing() {
return 180 - (0, _common.degrees)(this.phi);
}
set bearing(v) {
this.phi = Math.PI - (0, _common.radians)(v);
}
get pitch() {
return (0, _common.degrees)(this.theta);
}
set pitch(v) {
this.theta = (0, _common.radians)(v);
}
get longitude() {
return (0, _common.degrees)(this.phi);
}
get latitude() {
return (0, _common.degrees)(this.theta);
}
get lng() {
return (0, _common.degrees)(this.phi);
}
get lat() {
return (0, _common.degrees)(this.theta);
}
get z() {
return (this.radius - 1) * this.radiusScale;
}
set(radius, phi, theta) {
this.radius = radius;
this.phi = phi;
this.theta = theta;
return this.check();
}
clone() {
return new SphericalCoordinates().copy(this);
}
copy(other) {
this.radius = other.radius;
this.phi = other.phi;
this.theta = other.theta;
return this.check();
}
fromLngLatZ([lng, lat, z]) {
this.radius = 1 + z / this.radiusScale;
this.phi = (0, _common.radians)(lat);
this.theta = (0, _common.radians)(lng);
}
fromVector3(v) {
this.radius = vec3.length(v);
if (this.radius > 0) {
this.theta = Math.atan2(v[0], v[1]);
this.phi = Math.acos((0, _common.clamp)(v[2] / this.radius, -1, 1));
return this.check();
}
}, {
key: "toVector3",
value: function toVector3() {
return new _vector.default(0, 0, this.radius).rotateX({
radians: this.theta
}).rotateZ({
radians: this.phi
});
}
}, {
key: "makeSafe",
value: function makeSafe() {
this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
return this;
}
}, {
key: "check",
value: function check() {
if (!Number.isFinite(this.phi) || !Number.isFinite(this.theta) || !(this.radius > 0)) {
throw new Error('SphericalCoordinates: some fields set to invalid numbers');
}
return this.check();
}
toVector3() {
return new _vector.default(0, 0, this.radius).rotateX({
radians: this.theta
}).rotateZ({
radians: this.phi
});
}
makeSafe() {
this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
return this;
}
check() {
if (!Number.isFinite(this.phi) || !Number.isFinite(this.theta) || !(this.radius > 0)) {
throw new Error('SphericalCoordinates: some fields set to invalid numbers');
return this;
}
}]);
return SphericalCoordinates;
}();
return this;
}
}
exports.default = SphericalCoordinates;
//# sourceMappingURL=spherical-coordinates.js.map

@@ -5,2 +5,4 @@ "use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,2 +13,12 @@ value: true

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _vector = _interopRequireDefault(require("./base/vector"));

@@ -22,12 +34,25 @@

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
class Vector2 extends _vector.default {
constructor(x = 0, y = 0) {
super(2);
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
var Vector2 = function (_Vector) {
(0, _inherits2.default)(Vector2, _Vector);
var _super = _createSuper(Vector2);
function Vector2() {
var _this;
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
(0, _classCallCheck2.default)(this, Vector2);
_this = _super.call(this, 2);
if ((0, _common.isArray)(x) && arguments.length === 1) {
this.copy(x);
_this.copy(x);
} else {

@@ -39,80 +64,97 @@ if (_common.config.debug) {

this[0] = x;
this[1] = y;
_this[0] = x;
_this[1] = y;
}
}
set(x, y) {
this[0] = x;
this[1] = y;
return this.check();
return _this;
}
copy(array) {
this[0] = array[0];
this[1] = array[1];
return this.check();
}
(0, _createClass2.default)(Vector2, [{
key: "set",
value: function set(x, y) {
this[0] = x;
this[1] = y;
return this.check();
}
}, {
key: "copy",
value: function copy(array) {
this[0] = array[0];
this[1] = array[1];
return this.check();
}
}, {
key: "fromObject",
value: function fromObject(object) {
if (_common.config.debug) {
(0, _validators.checkNumber)(object.x);
(0, _validators.checkNumber)(object.y);
}
fromObject(object) {
if (_common.config.debug) {
(0, _validators.checkNumber)(object.x);
(0, _validators.checkNumber)(object.y);
this[0] = object.x;
this[1] = object.y;
return this.check();
}
}, {
key: "toObject",
value: function toObject(object) {
object.x = this[0];
object.y = this[1];
return object;
}
}, {
key: "ELEMENTS",
get: function get() {
return 2;
}
}, {
key: "horizontalAngle",
value: function horizontalAngle() {
return Math.atan2(this.y, this.x);
}
}, {
key: "verticalAngle",
value: function verticalAngle() {
return Math.atan2(this.x, this.y);
}
}, {
key: "transform",
value: function transform(matrix4) {
return this.transformAsPoint(matrix4);
}
}, {
key: "transformAsPoint",
value: function transformAsPoint(matrix4) {
vec2.transformMat4(this, this, matrix4);
return this.check();
}
}, {
key: "transformAsVector",
value: function transformAsVector(matrix4) {
(0, _glMatrixExtras.vec2_transformMat4AsVector)(this, this, matrix4);
return this.check();
}
}, {
key: "transformByMatrix3",
value: function transformByMatrix3(matrix3) {
vec2.transformMat3(this, this, matrix3);
return this.check();
}
}, {
key: "transformByMatrix2x3",
value: function transformByMatrix2x3(matrix2x3) {
vec2.transformMat2d(this, this, matrix2x3);
return this.check();
}
}, {
key: "transformByMatrix2",
value: function transformByMatrix2(matrix2) {
vec2.transformMat2(this, this, matrix2);
return this.check();
}
}]);
return Vector2;
}(_vector.default);
this[0] = object.x;
this[1] = object.y;
return this.check();
}
toObject(object) {
object.x = this[0];
object.y = this[1];
return object;
}
get ELEMENTS() {
return 2;
}
horizontalAngle() {
return Math.atan2(this.y, this.x);
}
verticalAngle() {
return Math.atan2(this.x, this.y);
}
transform(matrix4) {
return this.transformAsPoint(matrix4);
}
transformAsPoint(matrix4) {
vec2.transformMat4(this, this, matrix4);
return this.check();
}
transformAsVector(matrix4) {
(0, _glMatrixExtras.vec2_transformMat4AsVector)(this, this, matrix4);
return this.check();
}
transformByMatrix3(matrix3) {
vec2.transformMat3(this, this, matrix3);
return this.check();
}
transformByMatrix2x3(matrix2x3) {
vec2.transformMat2d(this, this, matrix2x3);
return this.check();
}
transformByMatrix2(matrix2) {
vec2.transformMat2(this, this, matrix2);
return this.check();
}
}
exports.default = Vector2;
//# sourceMappingURL=vector2.js.map

@@ -5,2 +5,4 @@ "use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,2 +13,12 @@ value: true

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _vector = _interopRequireDefault(require("./base/vector"));

@@ -22,19 +34,29 @@

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const ORIGIN = [0, 0, 0];
const constants = {};
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
class Vector3 extends _vector.default {
static get ZERO() {
return constants.ZERO = constants.ZERO || Object.freeze(new Vector3(0, 0, 0, 0));
}
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
constructor(x = 0, y = 0, z = 0) {
super(-0, -0, -0);
var ORIGIN = [0, 0, 0];
var ZERO;
var Vector3 = function (_Vector) {
(0, _inherits2.default)(Vector3, _Vector);
var _super = _createSuper(Vector3);
function Vector3() {
var _this;
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
(0, _classCallCheck2.default)(this, Vector3);
_this = _super.call(this, -0, -0, -0);
if (arguments.length === 1 && (0, _common.isArray)(x)) {
this.copy(x);
_this.copy(x);
} else {

@@ -47,119 +69,149 @@ if (_common.config.debug) {

_this[0] = x;
_this[1] = y;
_this[2] = z;
}
return _this;
}
(0, _createClass2.default)(Vector3, [{
key: "set",
value: function set(x, y, z) {
this[0] = x;
this[1] = y;
this[2] = z;
return this.check();
}
}
}, {
key: "copy",
value: function copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
return this.check();
}
}, {
key: "fromObject",
value: function fromObject(object) {
if (_common.config.debug) {
(0, _validators.checkNumber)(object.x);
(0, _validators.checkNumber)(object.y);
(0, _validators.checkNumber)(object.z);
}
set(x, y, z) {
this[0] = x;
this[1] = y;
this[2] = z;
return this.check();
}
this[0] = object.x;
this[1] = object.y;
this[2] = object.z;
return this.check();
}
}, {
key: "toObject",
value: function toObject(object) {
object.x = this[0];
object.y = this[1];
object.z = this[2];
return object;
}
}, {
key: "ELEMENTS",
get: function get() {
return 3;
}
}, {
key: "z",
get: function get() {
return this[2];
},
set: function set(value) {
this[2] = (0, _validators.checkNumber)(value);
}
}, {
key: "angle",
value: function angle(vector) {
return vec3.angle(this, vector);
}
}, {
key: "cross",
value: function cross(vector) {
vec3.cross(this, this, vector);
return this.check();
}
}, {
key: "rotateX",
value: function rotateX(_ref) {
var radians = _ref.radians,
_ref$origin = _ref.origin,
origin = _ref$origin === void 0 ? ORIGIN : _ref$origin;
vec3.rotateX(this, this, origin, radians);
return this.check();
}
}, {
key: "rotateY",
value: function rotateY(_ref2) {
var radians = _ref2.radians,
_ref2$origin = _ref2.origin,
origin = _ref2$origin === void 0 ? ORIGIN : _ref2$origin;
vec3.rotateY(this, this, origin, radians);
return this.check();
}
}, {
key: "rotateZ",
value: function rotateZ(_ref3) {
var radians = _ref3.radians,
_ref3$origin = _ref3.origin,
origin = _ref3$origin === void 0 ? ORIGIN : _ref3$origin;
vec3.rotateZ(this, this, origin, radians);
return this.check();
}
}, {
key: "transform",
value: function transform(matrix4) {
return this.transformAsPoint(matrix4);
}
}, {
key: "transformAsPoint",
value: function transformAsPoint(matrix4) {
vec3.transformMat4(this, this, matrix4);
return this.check();
}
}, {
key: "transformAsVector",
value: function transformAsVector(matrix4) {
(0, _glMatrixExtras.vec3_transformMat4AsVector)(this, this, matrix4);
return this.check();
}
}, {
key: "transformByMatrix3",
value: function transformByMatrix3(matrix3) {
vec3.transformMat3(this, this, matrix3);
return this.check();
}
}, {
key: "transformByMatrix2",
value: function transformByMatrix2(matrix2) {
(0, _glMatrixExtras.vec3_transformMat2)(this, this, matrix2);
return this.check();
}
}, {
key: "transformByQuaternion",
value: function transformByQuaternion(quaternion) {
vec3.transformQuat(this, this, quaternion);
return this.check();
}
}], [{
key: "ZERO",
get: function get() {
if (!ZERO) {
ZERO = new Vector3(0, 0, 0);
Object.freeze(ZERO);
}
copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
return this.check();
}
fromObject(object) {
if (_common.config.debug) {
(0, _validators.checkNumber)(object.x);
(0, _validators.checkNumber)(object.y);
(0, _validators.checkNumber)(object.z);
return ZERO;
}
}]);
return Vector3;
}(_vector.default);
this[0] = object.x;
this[1] = object.y;
this[2] = object.z;
return this.check();
}
toObject(object) {
object.x = this[0];
object.y = this[1];
object.z = this[2];
return object;
}
get ELEMENTS() {
return 3;
}
get z() {
return this[2];
}
set z(value) {
this[2] = (0, _validators.checkNumber)(value);
}
angle(vector) {
return vec3.angle(this, vector);
}
cross(vector) {
vec3.cross(this, this, vector);
return this.check();
}
rotateX({
radians,
origin = ORIGIN
}) {
vec3.rotateX(this, this, origin, radians);
return this.check();
}
rotateY({
radians,
origin = ORIGIN
}) {
vec3.rotateY(this, this, origin, radians);
return this.check();
}
rotateZ({
radians,
origin = ORIGIN
}) {
vec3.rotateZ(this, this, origin, radians);
return this.check();
}
transform(matrix4) {
return this.transformAsPoint(matrix4);
}
transformAsPoint(matrix4) {
vec3.transformMat4(this, this, matrix4);
return this.check();
}
transformAsVector(matrix4) {
(0, _glMatrixExtras.vec3_transformMat4AsVector)(this, this, matrix4);
return this.check();
}
transformByMatrix3(matrix3) {
vec3.transformMat3(this, this, matrix3);
return this.check();
}
transformByMatrix2(matrix2) {
(0, _glMatrixExtras.vec3_transformMat2)(this, this, matrix2);
return this.check();
}
transformByQuaternion(quaternion) {
vec3.transformQuat(this, this, quaternion);
return this.check();
}
}
exports.default = Vector3;
//# sourceMappingURL=vector3.js.map

@@ -5,2 +5,4 @@ "use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,2 +13,12 @@ value: true

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _vector = _interopRequireDefault(require("./base/vector"));

@@ -22,18 +34,29 @@

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const constants = {};
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
class Vector4 extends _vector.default {
static get ZERO() {
return constants.ZERO = constants.ZERO || Object.freeze(new Vector4(0, 0, 0, 0));
}
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
constructor(x = 0, y = 0, z = 0, w = 0) {
super(-0, -0, -0, -0);
var ZERO;
var Vector4 = function (_Vector) {
(0, _inherits2.default)(Vector4, _Vector);
var _super = _createSuper(Vector4);
function Vector4() {
var _this;
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var w = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
(0, _classCallCheck2.default)(this, Vector4);
_this = _super.call(this, -0, -0, -0, -0);
if ((0, _common.isArray)(x) && arguments.length === 1) {
this.copy(x);
_this.copy(x);
} else {

@@ -47,2 +70,14 @@ if (_common.config.debug) {

_this[0] = x;
_this[1] = y;
_this[2] = z;
_this[3] = w;
}
return _this;
}
(0, _createClass2.default)(Vector4, [{
key: "set",
value: function set(x, y, z, w) {
this[0] = x;

@@ -52,92 +87,104 @@ this[1] = y;

this[3] = w;
return this.check();
}
}
}, {
key: "copy",
value: function copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
return this.check();
}
}, {
key: "fromObject",
value: function fromObject(object) {
if (_common.config.debug) {
(0, _validators.checkNumber)(object.x);
(0, _validators.checkNumber)(object.y);
(0, _validators.checkNumber)(object.z);
(0, _validators.checkNumber)(object.w);
}
set(x, y, z, w) {
this[0] = x;
this[1] = y;
this[2] = z;
this[3] = w;
return this.check();
}
this[0] = object.x;
this[1] = object.y;
this[2] = object.z;
this[3] = object.w;
return this;
}
}, {
key: "toObject",
value: function toObject(object) {
object.x = this[0];
object.y = this[1];
object.z = this[2];
object.w = this[3];
return object;
}
}, {
key: "ELEMENTS",
get: function get() {
return 4;
}
}, {
key: "z",
get: function get() {
return this[2];
},
set: function set(value) {
this[2] = (0, _validators.checkNumber)(value);
}
}, {
key: "w",
get: function get() {
return this[3];
},
set: function set(value) {
this[3] = (0, _validators.checkNumber)(value);
}
}, {
key: "transform",
value: function transform(matrix4) {
vec4.transformMat4(this, this, matrix4);
return this.check();
}
}, {
key: "transformByMatrix3",
value: function transformByMatrix3(matrix3) {
(0, _glMatrixExtras.vec4_transformMat3)(this, this, matrix3);
return this.check();
}
}, {
key: "transformByMatrix2",
value: function transformByMatrix2(matrix2) {
(0, _glMatrixExtras.vec4_transformMat2)(this, this, matrix2);
return this.check();
}
}, {
key: "transformByQuaternion",
value: function transformByQuaternion(quaternion) {
vec4.transformQuat(this, this, quaternion);
return this.check();
}
}, {
key: "applyMatrix4",
value: function applyMatrix4(m) {
m.transform(this, this);
return this;
}
}], [{
key: "ZERO",
get: function get() {
if (!ZERO) {
ZERO = new Vector4(0, 0, 0, 0);
Object.freeze(ZERO);
}
copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
return this.check();
}
fromObject(object) {
if (_common.config.debug) {
(0, _validators.checkNumber)(object.x);
(0, _validators.checkNumber)(object.y);
(0, _validators.checkNumber)(object.z);
(0, _validators.checkNumber)(object.w);
return ZERO;
}
}]);
return Vector4;
}(_vector.default);
this[0] = object.x;
this[1] = object.y;
this[2] = object.z;
this[3] = object.w;
return this;
}
toObject(object) {
object.x = this[0];
object.y = this[1];
object.z = this[2];
object.w = this[3];
return object;
}
get ELEMENTS() {
return 4;
}
get z() {
return this[2];
}
set z(value) {
this[2] = (0, _validators.checkNumber)(value);
}
get w() {
return this[3];
}
set w(value) {
this[3] = (0, _validators.checkNumber)(value);
}
transform(matrix4) {
vec4.transformMat4(this, this, matrix4);
return this.check();
}
transformByMatrix3(matrix3) {
(0, _glMatrixExtras.vec4_transformMat3)(this, this, matrix3);
return this.check();
}
transformByMatrix2(matrix2) {
(0, _glMatrixExtras.vec4_transformMat2)(this, this, matrix2);
return this.check();
}
transformByQuaternion(quaternion) {
vec4.transformQuat(this, this, quaternion);
return this.check();
}
applyMatrix4(m) {
m.transform(this, this);
return this;
}
}
exports.default = Vector4;
//# sourceMappingURL=vector4.js.map

@@ -10,3 +10,3 @@ "use strict";

enumerable: true,
get: function () {
get: function get() {
return _vector.default;

@@ -17,3 +17,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _vector2.default;

@@ -24,3 +24,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _vector3.default;

@@ -31,3 +31,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _matrix.default;

@@ -38,3 +38,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _matrix2.default;

@@ -45,3 +45,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _quaternion.default;

@@ -52,3 +52,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _sphericalCoordinates.default;

@@ -59,3 +59,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _sphericalCoordinates.default;

@@ -66,3 +66,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _pose.default;

@@ -73,3 +73,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _pose.default;

@@ -80,3 +80,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _euler.default;

@@ -87,3 +87,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _euler.default;

@@ -94,3 +94,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _mathUtils.default;

@@ -101,3 +101,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _assert.default;

@@ -108,3 +108,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.config;

@@ -115,3 +115,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.configure;

@@ -122,3 +122,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.formatValue;

@@ -129,3 +129,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.isArray;

@@ -136,3 +136,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.clone;

@@ -143,3 +143,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.equals;

@@ -150,3 +150,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.exactEquals;

@@ -157,3 +157,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.toRadians;

@@ -164,3 +164,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.toDegrees;

@@ -171,3 +171,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.radians;

@@ -178,3 +178,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.degrees;

@@ -185,3 +185,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.sin;

@@ -192,3 +192,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.cos;

@@ -199,3 +199,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.tan;

@@ -206,3 +206,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.asin;

@@ -213,3 +213,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.acos;

@@ -220,3 +220,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.atan;

@@ -227,3 +227,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.clamp;

@@ -234,3 +234,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.lerp;

@@ -241,3 +241,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _common.withEpsilon;

@@ -244,0 +244,0 @@ }

@@ -29,7 +29,9 @@ "use strict";

var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _assert = _interopRequireDefault(require("./assert"));
const RADIANS_TO_DEGREES = 1 / Math.PI * 180;
const DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
const config = {};
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
var config = {};
exports.config = config;

@@ -43,4 +45,6 @@ config.EPSILON = 1e-12;

function configure(options = {}) {
for (const key in options) {
function configure() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
for (var key in options) {
(0, _assert.default)(key in config);

@@ -53,5 +57,7 @@ config[key] = options[key];

function formatValue(value, {
precision = config.precision || 4
} = {}) {
function formatValue(value) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$precision = _ref.precision,
precision = _ref$precision === void 0 ? config.precision || 4 : _ref$precision;
value = round(value);

@@ -66,3 +72,3 @@ return "".concat(parseFloat(value.toPrecision(precision)));

function clone(array) {
return 'clone' in array ? array.clone() : new Array(...array);
return 'clone' in array ? array.clone() : array.slice();
}

@@ -79,35 +85,53 @@

function radians(degrees, result) {
return map(degrees, degrees => degrees * DEGREES_TO_RADIANS, result);
return map(degrees, function (degrees) {
return degrees * DEGREES_TO_RADIANS;
}, result);
}
function degrees(radians, result) {
return map(radians, radians => radians * RADIANS_TO_DEGREES, result);
return map(radians, function (radians) {
return radians * RADIANS_TO_DEGREES;
}, result);
}
function sin(radians, result) {
return map(radians, angle => Math.sin(angle), result);
return map(radians, function (angle) {
return Math.sin(angle);
}, result);
}
function cos(radians, result) {
return map(radians, angle => Math.cos(angle), result);
return map(radians, function (angle) {
return Math.cos(angle);
}, result);
}
function tan(radians, result) {
return map(radians, angle => Math.tan(angle));
return map(radians, function (angle) {
return Math.tan(angle);
}, result);
}
function asin(radians) {
return map(radians, angle => Math.asin(angle));
function asin(radians, result) {
return map(radians, function (angle) {
return Math.asin(angle);
}, result);
}
function acos(radians) {
return map(radians, angle => Math.acos(angle));
function acos(radians, result) {
return map(radians, function (angle) {
return Math.acos(angle);
}, result);
}
function atan(radians) {
return map(radians, angle => Math.atan(angle));
function atan(radians, result) {
return map(radians, function (angle) {
return Math.atan(angle);
}, result);
}
function clamp(value, min, max) {
return map(value, value => Math.max(min, Math.min(max, value)));
return map(value, function (value) {
return Math.max(min, Math.min(max, value));
});
}

@@ -117,3 +141,5 @@

if (isArray(a)) {
return a.map((ai, i) => lerp(ai, b[i], t));
return a.map(function (ai, i) {
return lerp(ai, b[i], t);
});
}

@@ -125,3 +151,3 @@

function equals(a, b, epsilon) {
const oldEpsilon = config.EPSILON;
var oldEpsilon = config.EPSILON;

@@ -142,3 +168,3 @@ if (epsilon) {

for (let i = 0; i < a.length; ++i) {
for (var i = 0; i < a.length; ++i) {
if (!equals(a[i], b[i])) {

@@ -175,3 +201,3 @@ return false;

if (a && typeof a === 'object' && b && typeof b === 'object') {
if (a && (0, _typeof2.default)(a) === 'object' && b && (0, _typeof2.default)(b) === 'object') {
if (a.constructor !== b.constructor) {

@@ -191,3 +217,3 @@ return false;

for (let i = 0; i < a.length; ++i) {
for (var i = 0; i < a.length; ++i) {
if (!exactEquals(a[i], b[i])) {

@@ -205,5 +231,5 @@ return false;

function withEpsilon(epsilon, func) {
const oldPrecision = config.EPSILON;
var oldPrecision = config.EPSILON;
config.EPSILON = epsilon;
let value;
var value;

@@ -229,6 +255,6 @@ try {

if (isArray(value)) {
const array = value;
var array = value;
result = result || duplicateArray(array);
for (let i = 0; i < result.length && i < array.length; ++i) {
for (var i = 0; i < result.length && i < array.length; ++i) {
result[i] = func(value[i], i, result);

@@ -235,0 +261,0 @@ }

@@ -13,5 +13,5 @@ "use strict";

function vec2_transformMat4AsVector(out, a, m) {
const x = a[0];
const y = a[1];
const w = m[3] * x + m[7] * y || 1.0;
var x = a[0];
var y = a[1];
var w = m[3] * x + m[7] * y || 1.0;
out[0] = (m[0] * x + m[4] * y) / w;

@@ -23,6 +23,6 @@ out[1] = (m[1] * x + m[5] * y) / w;

function vec3_transformMat4AsVector(out, a, m) {
const x = a[0];
const y = a[1];
const z = a[2];
const w = m[3] * x + m[7] * y + m[11] * z || 1.0;
var x = a[0];
var y = a[1];
var z = a[2];
var w = m[3] * x + m[7] * y + m[11] * z || 1.0;
out[0] = (m[0] * x + m[4] * y + m[8] * z) / w;

@@ -35,4 +35,4 @@ out[1] = (m[1] * x + m[5] * y + m[9] * z) / w;

function vec3_transformMat2(out, a, m) {
const x = a[0];
const y = a[1];
var x = a[0];
var y = a[1];
out[0] = m[0] * x + m[2] * y;

@@ -45,4 +45,4 @@ out[1] = m[1] * x + m[3] * y;

function vec4_transformMat2(out, a, m) {
const x = a[0];
const y = a[1];
var x = a[0];
var y = a[1];
out[0] = m[0] * x + m[2] * y;

@@ -56,5 +56,5 @@ out[1] = m[1] * x + m[3] * y;

function vec4_transformMat3(out, a, m) {
const x = a[0];
const y = a[1];
const z = a[2];
var x = a[0];
var y = a[1];
var z = a[2];
out[0] = m[0] * x + m[3] * y + m[6] * z;

@@ -61,0 +61,0 @@ out[1] = m[1] * x + m[4] * y + m[7] * z;

@@ -18,3 +18,3 @@ "use strict";

for (let i = 0; i < v.length; ++i) {
for (var i = 0; i < v.length; ++i) {
if (!Number.isFinite(v[i])) {

@@ -36,3 +36,5 @@ return false;

function checkVector(v, length, callerName = '') {
function checkVector(v, length) {
var callerName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
if (_common.config.debug && !validateVector(v, length)) {

@@ -45,3 +47,3 @@ throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));

const map = {};
var map = {};

@@ -48,0 +50,0 @@ function deprecated(method, version) {

@@ -27,9 +27,3 @@ function _extendableBuiltin(cls) {

import { config, formatValue, equals, isArray } from '../../lib/common';
import assert from '../../lib/assert';
export default class MathArray extends _extendableBuiltin(Array) {
get ELEMENTS() {
assert(false);
return 0;
}
clone() {

@@ -39,6 +33,2 @@ return new this.constructor().copy(this);

from(arrayOrObject) {
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
}
fromArray(array, offset = 0) {

@@ -52,2 +42,14 @@ for (let i = 0; i < this.ELEMENTS; ++i) {

toArray(targetArray = [], offset = 0) {
for (let i = 0; i < this.ELEMENTS; ++i) {
targetArray[offset + i] = this[i];
}
return targetArray;
}
from(arrayOrObject) {
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
}
to(arrayOrObject) {

@@ -65,10 +67,2 @@ if (arrayOrObject === this) {

toArray(array = [], offset = 0) {
for (let i = 0; i < this.ELEMENTS; ++i) {
array[offset + i] = this[i];
}
return array;
}
toFloat32Array() {

@@ -130,5 +124,3 @@ return new Float32Array(this);

if (t === undefined) {
t = b;
b = a;
a = this;
return this.lerp(this, a, b);
}

@@ -189,8 +181,18 @@

scale(scale) {
if (Array.isArray(scale)) {
return this.multiply(scale);
if (typeof scale === 'number') {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] *= scale;
}
} else {
for (let i = 0; i < this.ELEMENTS && i < scale.length; ++i) {
this[i] *= scale[i];
}
}
return this.check();
}
multiplyByScalar(scalar) {
for (let i = 0; i < this.ELEMENTS; ++i) {
this[i] *= scale;
this[i] *= scalar;
}

@@ -201,2 +203,20 @@

check() {
if (config.debug && !this.validate()) {
throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
}
return this;
}
validate() {
let valid = this.length === this.ELEMENTS;
for (let i = 0; i < this.ELEMENTS; ++i) {
valid = valid && Number.isFinite(this[i]);
}
return valid;
}
sub(a) {

@@ -235,3 +255,3 @@ return this.subtract(a);

divideScalar(a) {
return this.scale(1 / a);
return this.multiplyByScalar(1 / a);
}

@@ -247,6 +267,2 @@

multiplyByScalar(scalar) {
return this.scale(scalar);
}
get elements() {

@@ -256,21 +272,3 @@ return this;

check() {
if (config.debug && !this.validate()) {
throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
}
return this;
}
validate() {
let valid = this.length === this.ELEMENTS;
for (let i = 0; i < this.ELEMENTS; ++i) {
valid = valid && Number.isFinite(this[i]);
}
return valid;
}
}
//# sourceMappingURL=math-array.js.map
import MathArray from './math-array';
import { checkNumber } from '../../lib/validators';
import { config } from '../../lib/common';
import assert from '../../lib/assert';
export default class Matrix extends MathArray {
get ELEMENTS() {
assert(false);
return 0;
}
get RANK() {
assert(false);
return 0;
}
toString() {

@@ -17,0 +6,0 @@ let string = '[';

@@ -5,12 +5,2 @@ import MathArray from './math-array';

export default class Vector extends MathArray {
get ELEMENTS() {
assert(false);
return 0;
}
copy(vector) {
assert(false);
return this;
}
get x() {

@@ -17,0 +7,0 @@ return this[0];

import MathArray from './base/math-array';
import Quaternion from './quaternion';
import { clamp } from '../lib/common';
import { checkNumber } from '../lib/validators';
import Quaternion from './quaternion';
const ERR_UNKNOWN_ORDER = 'Unknown Euler angle order';
const ALMOST_ONE = 0.99999;
var RotationOrder;
function validateOrder(value) {
return value >= 0 && value < 6;
}
(function (RotationOrder) {
RotationOrder[RotationOrder["ZYX"] = 0] = "ZYX";
RotationOrder[RotationOrder["YXZ"] = 1] = "YXZ";
RotationOrder[RotationOrder["XZY"] = 2] = "XZY";
RotationOrder[RotationOrder["ZXY"] = 3] = "ZXY";
RotationOrder[RotationOrder["YZX"] = 4] = "YZX";
RotationOrder[RotationOrder["XYZ"] = 5] = "XYZ";
})(RotationOrder || (RotationOrder = {}));
function checkOrder(value) {
if (value < 0 && value >= 6) {
throw new Error(ERR_UNKNOWN_ORDER);
}
return value;
}
export default class Euler extends MathArray {
static get ZYX() {
return 0;
return RotationOrder.ZYX;
}
static get YXZ() {
return 1;
return RotationOrder.YXZ;
}
static get XZY() {
return 2;
return RotationOrder.XZY;
}
static get ZXY() {
return 3;
return RotationOrder.ZXY;
}
static get YZX() {
return 4;
return RotationOrder.YZX;
}
static get XYZ() {
return 5;
return RotationOrder.XYZ;
}
static get RollPitchYaw() {
return 0;
return RotationOrder.ZYX;
}
static get DefaultOrder() {
return Euler.ZYX;
return RotationOrder.ZYX;
}
static get RotationOrders() {
return ['ZYX', 'YXZ', 'XZY', 'ZXY', 'YZX', 'XYZ'];
return RotationOrder;
}
static rotationOrder(order) {
return Euler.RotationOrders[order];
return RotationOrder[order];
}

@@ -78,15 +76,19 @@

const ysqr = y * y;
const t0 = -2.0 * (ysqr + z * z) + 1.0;
const t1 = +2.0 * (x * y + w * z);
let t2 = -2.0 * (x * z - w * y);
const t3 = +2.0 * (y * z + w * x);
const t4 = -2.0 * (x * x + ysqr) + 1.0;
t2 = t2 > 1.0 ? 1.0 : t2;
t2 = t2 < -1.0 ? -1.0 : t2;
const t0 = -2 * (ysqr + z * z) + 1;
const t1 = +2 * (x * y + w * z);
let t2 = -2 * (x * z - w * y);
const t3 = +2 * (y * z + w * x);
const t4 = -2 * (x * x + ysqr) + 1;
t2 = t2 > 1 ? 1 : t2;
t2 = t2 < -1 ? -1 : t2;
const roll = Math.atan2(t3, t4);
const pitch = Math.asin(t2);
const yaw = Math.atan2(t1, t0);
return new Euler(roll, pitch, yaw, Euler.RollPitchYaw);
return this.set(roll, pitch, yaw, Euler.RollPitchYaw);
}
fromObject(object) {
throw new Error('not implemented');
}
copy(array) {

@@ -255,3 +257,3 @@ this[0] = array[0];

fromRollPitchYaw(roll, pitch, yaw) {
return this.set(roll, pitch, yaw, Euler.ZYX);
return this.set(roll, pitch, yaw, RotationOrder.ZYX);
}

@@ -272,19 +274,19 @@

switch (this[3]) {
case Euler.XYZ:
switch (this[4]) {
case RotationOrder.XYZ:
return q.rotateX(this[0]).rotateY(this[1]).rotateZ(this[2]);
case Euler.YXZ:
case RotationOrder.YXZ:
return q.rotateY(this[0]).rotateX(this[1]).rotateZ(this[2]);
case Euler.ZXY:
case RotationOrder.ZXY:
return q.rotateZ(this[0]).rotateX(this[1]).rotateY(this[2]);
case Euler.ZYX:
case RotationOrder.ZYX:
return q.rotateZ(this[0]).rotateY(this[1]).rotateX(this[2]);
case Euler.YZX:
case RotationOrder.YZX:
return q.rotateY(this[0]).rotateZ(this[1]).rotateX(this[2]);
case Euler.XZY:
case RotationOrder.XZY:
return q.rotateX(this[0]).rotateZ(this[1]).rotateY(this[2]);

@@ -298,12 +300,11 @@

_fromRotationMatrix(m, order = Euler.DefaultOrder) {
const te = m.elements;
const m11 = te[0],
m12 = te[4],
m13 = te[8];
const m21 = te[1],
m22 = te[5],
m23 = te[9];
const m31 = te[2],
m32 = te[6],
m33 = te[10];
const m11 = m[0],
m12 = m[4],
m13 = m[8];
const m21 = m[1],
m22 = m[5],
m23 = m[9];
const m31 = m[2],
m32 = m[6],
m33 = m[10];
order = order || this[3];

@@ -548,2 +549,14 @@

}
function validateOrder(value) {
return value >= 0 && value < 6;
}
function checkOrder(value) {
if (value < 0 && value >= 6) {
throw new Error(ERR_UNKNOWN_ORDER);
}
return value;
}
//# sourceMappingURL=euler.js.map
import Matrix from './base/matrix';
import { checkVector, deprecated } from '../lib/validators';
import { checkVector } from '../lib/validators';
import { vec4_transformMat3 } from '../lib/gl-matrix-extras';

@@ -7,25 +7,24 @@ import * as mat3 from 'gl-matrix/mat3';

import * as vec3 from 'gl-matrix/vec3';
const IDENTITY = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
const ZERO = Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0]);
const INDICES = Object.freeze({
COL0ROW0: 0,
COL0ROW1: 1,
COL0ROW2: 2,
COL1ROW0: 3,
COL1ROW1: 4,
COL1ROW2: 5,
COL2ROW0: 6,
COL2ROW1: 7,
COL2ROW2: 8
});
const constants = {};
var INDICES;
(function (INDICES) {
INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
INDICES[INDICES["COL0ROW1"] = 1] = "COL0ROW1";
INDICES[INDICES["COL0ROW2"] = 2] = "COL0ROW2";
INDICES[INDICES["COL1ROW0"] = 3] = "COL1ROW0";
INDICES[INDICES["COL1ROW1"] = 4] = "COL1ROW1";
INDICES[INDICES["COL1ROW2"] = 5] = "COL1ROW2";
INDICES[INDICES["COL2ROW0"] = 6] = "COL2ROW0";
INDICES[INDICES["COL2ROW1"] = 7] = "COL2ROW1";
INDICES[INDICES["COL2ROW2"] = 8] = "COL2ROW2";
})(INDICES || (INDICES = {}));
const IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
export default class Matrix3 extends Matrix {
static get IDENTITY() {
constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix3(IDENTITY));
return constants.IDENTITY;
return getIdentityMatrix();
}
static get ZERO() {
constants.ZERO = constants.ZERO || Object.freeze(new Matrix3(ZERO));
return constants.ZERO;
return getZeroMatrix();
}

@@ -45,3 +44,3 @@

constructor(array) {
constructor(array, ...args) {
super(-0, -0, -0, -0, -0, -0, -0, -0, -0);

@@ -51,2 +50,4 @@

this.copy(array);
} else if (args.length > 0) {
this.copy([array, ...args]);
} else {

@@ -70,2 +71,15 @@ this.identity();

identity() {
return this.copy(IDENTITY_MATRIX);
}
fromObject(object) {
return this.check();
}
fromQuaternion(q) {
mat3.fromQuat(this, q);
return this.check();
}
set(m00, m10, m20, m01, m11, m21, m02, m12, m22) {

@@ -101,11 +115,2 @@ this[0] = m00;

identity() {
return this.copy(IDENTITY);
}
fromQuaternion(q) {
mat3.fromQuat(this, q);
return this.check();
}
transpose() {

@@ -140,3 +145,3 @@ mat3.transpose(this, this);

} else {
mat3.scale(this, this, [factor, factor, factor]);
mat3.scale(this, this, [factor, factor]);
}

@@ -175,3 +180,2 @@

transformVector(vector, result) {
deprecated('Matrix3.transformVector');
return this.transform(vector, result);

@@ -181,3 +185,2 @@ }

transformVector2(vector, result) {
deprecated('Matrix3.transformVector');
return this.transform(vector, result);

@@ -187,3 +190,2 @@ }

transformVector3(vector, result) {
deprecated('Matrix3.transformVector');
return this.transform(vector, result);

@@ -193,2 +195,22 @@ }

}
let ZERO_MATRIX3;
let IDENTITY_MATRIX3;
function getZeroMatrix() {
if (!ZERO_MATRIX3) {
ZERO_MATRIX3 = new Matrix3([0, 0, 0, 0, 0, 0, 0, 0, 0]);
Object.freeze(ZERO_MATRIX3);
}
return ZERO_MATRIX3;
}
function getIdentityMatrix() {
if (!IDENTITY_MATRIX3) {
IDENTITY_MATRIX3 = new Matrix3();
Object.freeze(IDENTITY_MATRIX3);
}
return IDENTITY_MATRIX3;
}
//# sourceMappingURL=matrix3.js.map

@@ -1,3 +0,3 @@

import { checkVector, deprecated } from '../lib/validators';
import Matrix from './base/matrix';
import { checkVector } from '../lib/validators';
import { vec2_transformMat4AsVector, vec3_transformMat4AsVector } from '../lib/gl-matrix-extras';

@@ -8,38 +8,37 @@ import * as mat4 from 'gl-matrix/mat4';

import * as vec4 from 'gl-matrix/vec4';
const IDENTITY = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
const ZERO = Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
const INDICES = Object.freeze({
COL0ROW0: 0,
COL0ROW1: 1,
COL0ROW2: 2,
COL0ROW3: 3,
COL1ROW0: 4,
COL1ROW1: 5,
COL1ROW2: 6,
COL1ROW3: 7,
COL2ROW0: 8,
COL2ROW1: 9,
COL2ROW2: 10,
COL2ROW3: 11,
COL3ROW0: 12,
COL3ROW1: 13,
COL3ROW2: 14,
COL3ROW3: 15
});
const constants = {};
var INDICES;
(function (INDICES) {
INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
INDICES[INDICES["COL0ROW1"] = 1] = "COL0ROW1";
INDICES[INDICES["COL0ROW2"] = 2] = "COL0ROW2";
INDICES[INDICES["COL0ROW3"] = 3] = "COL0ROW3";
INDICES[INDICES["COL1ROW0"] = 4] = "COL1ROW0";
INDICES[INDICES["COL1ROW1"] = 5] = "COL1ROW1";
INDICES[INDICES["COL1ROW2"] = 6] = "COL1ROW2";
INDICES[INDICES["COL1ROW3"] = 7] = "COL1ROW3";
INDICES[INDICES["COL2ROW0"] = 8] = "COL2ROW0";
INDICES[INDICES["COL2ROW1"] = 9] = "COL2ROW1";
INDICES[INDICES["COL2ROW2"] = 10] = "COL2ROW2";
INDICES[INDICES["COL2ROW3"] = 11] = "COL2ROW3";
INDICES[INDICES["COL3ROW0"] = 12] = "COL3ROW0";
INDICES[INDICES["COL3ROW1"] = 13] = "COL3ROW1";
INDICES[INDICES["COL3ROW2"] = 14] = "COL3ROW2";
INDICES[INDICES["COL3ROW3"] = 15] = "COL3ROW3";
})(INDICES || (INDICES = {}));
const DEFAULT_FOVY = 45 * Math.PI / 180;
const DEFAULT_ASPECT = 1;
const DEFAULT_NEAR = 0.1;
const DEFAULT_FAR = 500;
const IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
export default class Matrix4 extends Matrix {
static get IDENTITY() {
constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix4(IDENTITY));
return constants.IDENTITY;
return getIdentityMatrix();
}
static get ZERO() {
constants.ZERO = constants.ZERO || Object.freeze(new Matrix4(ZERO));
return constants.ZERO;
return getZeroMatrix();
}
get INDICES() {
return INDICES;
}
get ELEMENTS() {

@@ -53,2 +52,6 @@ return 16;

get INDICES() {
return INDICES;
}
constructor(array) {

@@ -145,20 +148,26 @@ super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);

identity() {
return this.copy(IDENTITY);
return this.copy(IDENTITY_MATRIX);
}
fromQuaternion(q) {
mat4.fromQuat(this, q);
fromObject(object) {
return this.check();
}
frustum({
left,
right,
bottom,
top,
near,
far
}) {
fromQuaternion(quaternion) {
mat4.fromQuat(this, quaternion);
return this.check();
}
frustum(view) {
const {
left,
right,
bottom,
top,
near = DEFAULT_NEAR,
far = DEFAULT_FAR
} = view;
if (far === Infinity) {
Matrix4._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
} else {

@@ -171,40 +180,8 @@ mat4.frustum(this, left, right, bottom, top, near, far);

static _computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
const column0Row0 = 2.0 * near / (right - left);
const column1Row1 = 2.0 * near / (top - bottom);
const column2Row0 = (right + left) / (right - left);
const column2Row1 = (top + bottom) / (top - bottom);
const column2Row2 = -1.0;
const column2Row3 = -1.0;
const column3Row2 = -2.0 * near;
result[0] = column0Row0;
result[1] = 0.0;
result[2] = 0.0;
result[3] = 0.0;
result[4] = 0.0;
result[5] = column1Row1;
result[6] = 0.0;
result[7] = 0.0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = column2Row3;
result[12] = 0.0;
result[13] = 0.0;
result[14] = column3Row2;
result[15] = 0.0;
return result;
}
lookAt(eye, center, up) {
if (arguments.length === 1) {
({
eye,
center,
up
} = eye);
}
center = center || [0, 0, 0];
up = up || [0, 1, 0];
lookAt(view) {
const {
eye,
center = [0, 0, 0],
up = [0, 1, 0]
} = view;
mat4.lookAt(this, eye, center, up);

@@ -214,10 +191,11 @@ return this.check();

ortho({
left,
right,
bottom,
top,
near = 0.1,
far = 500
}) {
ortho(view) {
const {
left,
right,
bottom,
top,
near = DEFAULT_NEAR,
far = DEFAULT_FAR
} = view;
mat4.ortho(this, left, right, bottom, top, near, far);

@@ -227,17 +205,15 @@ return this.check();

orthographic({
fovy = 45 * Math.PI / 180,
aspect = 1,
focalDistance = 1,
near = 0.1,
far = 500
}) {
if (fovy > Math.PI * 2) {
throw Error('radians');
}
orthographic(view) {
const {
fovy = DEFAULT_FOVY,
aspect = DEFAULT_ASPECT,
focalDistance = 1,
near = DEFAULT_NEAR,
far = DEFAULT_FAR
} = view;
checkRadians(fovy);
const halfY = fovy / 2;
const top = focalDistance * Math.tan(halfY);
const right = top * aspect;
return new Matrix4().ortho({
return this.ortho({
left: -right,

@@ -252,15 +228,10 @@ right,

perspective({
fovy = undefined,
fov = 45 * Math.PI / 180,
aspect = 1,
near = 0.1,
far = 500
} = {}) {
fovy = fovy || fov;
if (fovy > Math.PI * 2) {
throw Error('radians');
}
perspective(view) {
const {
fovy = 45 * Math.PI / 180,
aspect = 1,
near = 0.1,
far = 500
} = view;
checkRadians(fovy);
mat4.perspective(this, fovy, aspect, near, far);

@@ -288,4 +259,6 @@ return this.check();

getRotation(result = [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0], scaleResult = null) {
const scale = this.getScale(scaleResult || [-0, -0, -0]);
getRotation(result, scaleResult) {
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
scaleResult = scaleResult || [-0, -0, -0];
const scale = this.getScale(scaleResult);
const inverseScale0 = 1 / scale[0];

@@ -313,4 +286,6 @@ const inverseScale1 = 1 / scale[1];

getRotationMatrix3(result = [-0, -0, -0, -0, -0, -0, -0, -0, -0], scaleResult = null) {
const scale = this.getScale(scaleResult || [-0, -0, -0]);
getRotationMatrix3(result, scaleResult) {
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
scaleResult = scaleResult || [-0, -0, -0];
const scale = this.getScale(scaleResult);
const inverseScale0 = 1 / scale[0];

@@ -366,4 +341,4 @@ const inverseScale1 = 1 / scale[1];

rotateXYZ([rx, ry, rz]) {
return this.rotateX(rx).rotateY(ry).rotateZ(rz);
rotateXYZ(angleXYZ) {
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
}

@@ -377,13 +352,8 @@

scale(factor) {
if (Array.isArray(factor)) {
mat4.scale(this, this, factor);
} else {
mat4.scale(this, this, [factor, factor, factor]);
}
mat4.scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
return this.check();
}
translate(vec) {
mat4.translate(this, this, vec);
translate(vector) {
mat4.translate(this, this, vector);
return this.check();

@@ -442,2 +412,14 @@ }

transformPoint(vector, result) {
return this.transformAsPoint(vector, result);
}
transformVector(vector, result) {
return this.transformAsPoint(vector, result);
}
transformDirection(vector, result) {
return this.transformAsVector(vector, result);
}
makeRotationX(radians) {

@@ -451,18 +433,56 @@ return this.identity().rotateX(radians);

transformPoint(vector, result) {
deprecated('Matrix4.transformPoint', '3.0');
return this.transformAsPoint(vector, result);
}
let ZERO;
let IDENTITY;
function getZeroMatrix() {
if (!ZERO) {
ZERO = new Matrix4([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
Object.freeze(ZERO);
}
transformVector(vector, result) {
deprecated('Matrix4.transformVector', '3.0');
return this.transformAsPoint(vector, result);
return ZERO;
}
function getIdentityMatrix() {
if (!IDENTITY) {
IDENTITY = new Matrix4();
Object.freeze(IDENTITY);
}
transformDirection(vector, result) {
deprecated('Matrix4.transformDirection', '3.0');
return this.transformAsVector(vector, result);
return IDENTITY;
}
function checkRadians(possiblyDegrees) {
if (possiblyDegrees > Math.PI * 2) {
throw Error('expected radians');
}
}
function computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
const column0Row0 = 2 * near / (right - left);
const column1Row1 = 2 * near / (top - bottom);
const column2Row0 = (right + left) / (right - left);
const column2Row1 = (top + bottom) / (top - bottom);
const column2Row2 = -1;
const column2Row3 = -1;
const column3Row2 = -2 * near;
result[0] = column0Row0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = column1Row1;
result[6] = 0;
result[7] = 0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = column2Row3;
result[12] = 0;
result[13] = 0;
result[14] = column3Row2;
result[15] = 0;
return result;
}
//# sourceMappingURL=matrix4.js.map

@@ -0,1 +1,2 @@

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import Matrix4 from './matrix4';

@@ -12,5 +13,9 @@ import Vector3 from './vector3';

yaw = 0,
position = undefined,
orientation = undefined
position,
orientation
} = {}) {
_defineProperty(this, "position", void 0);
_defineProperty(this, "orientation", void 0);
if (Array.isArray(position) && position.length === 3) {

@@ -108,4 +113,3 @@ this.position = new Vector3(position);

const cw = Math.cos(this.yaw);
const matrix = new Matrix4().setRowMajor(cw * cp, -sw * cr + cw * sp * sr, sw * sr + cw * sp * cr, this.x, sw * cp, cw * cr + sw * sp * sr, -cw * sr + sw * sp * cr, this.y, -sp, cp * sr, cp * cr, this.z, 0, 0, 0, 1);
return matrix;
return new Matrix4().setRowMajor(cw * cp, -sw * cr + cw * sp * sr, sw * sr + cw * sp * cr, this.x, sw * cp, cw * cr + sw * sp * sr, -cw * sr + sw * sp * cr, this.y, -sp, cp * sr, cp * cr, this.z, 0, 0, 0, 1);
}

@@ -112,0 +116,0 @@

import MathArray from './base/math-array';
import { checkNumber, checkVector } from '../lib/validators';
import assert from '../lib/assert';
import Vector4 from './vector4';
import * as quat from 'gl-matrix/quat';

@@ -34,9 +34,12 @@ import * as vec4 from 'gl-matrix/vec4';

fromMatrix3(m) {
quat.fromMat3(this, m);
fromObject(object) {
this[0] = object.x;
this[1] = object.y;
this[2] = object.z;
this[3] = object.w;
return this.check();
}
identity() {
quat.identity(this);
fromMatrix3(m) {
quat.fromMat3(this, m);
return this.check();

@@ -50,2 +53,7 @@ }

identity() {
quat.identity(this);
return this.check();
}
setAxisAngle(axis, rad) {

@@ -99,7 +107,3 @@ return this.fromAxisRotation(axis, rad);

dot(a, b) {
if (b !== undefined) {
throw new Error('Quaternion.dot only takes one argument');
}
dot(a) {
return quat.dot(this, a);

@@ -113,7 +117,3 @@ }

add(a, b) {
if (b !== undefined) {
throw new Error('Quaternion.add only takes one argument');
}
add(a) {
quat.add(this, this, a);

@@ -139,2 +139,6 @@ return this.check();

lerp(a, b, t) {
if (t === undefined) {
return this.lerp(this, a, b);
}
quat.lerp(this, a, b, t);

@@ -144,4 +148,3 @@ return this.check();

multiplyRight(a, b) {
assert(!b);
multiplyRight(a) {
quat.multiply(this, this, a);

@@ -151,4 +154,3 @@ return this.check();

multiplyLeft(a, b) {
assert(!b);
multiplyLeft(a) {
quat.multiply(this, a, this);

@@ -193,3 +195,7 @@ return this.check();

slerp(start, target, ratio) {
slerp(arg0, arg1, arg2) {
let start;
let target;
let ratio;
switch (arguments.length) {

@@ -201,11 +207,15 @@ case 1:

ratio
} = arguments[0]);
} = arg0);
break;
case 2:
[target, ratio] = arguments;
start = this;
target = arg0;
ratio = arg1;
break;
default:
start = arg0;
target = arg1;
ratio = arg2;
}

@@ -217,3 +227,3 @@

transformVector4(vector, result = vector) {
transformVector4(vector, result = new Vector4()) {
vec4.transformQuat(result, vector, this);

@@ -231,8 +241,8 @@ return checkVector(result, 4);

premultiply(a, b) {
return this.multiplyLeft(a, b);
premultiply(a) {
return this.multiplyLeft(a);
}
multiply(a, b) {
return this.multiplyRight(a, b);
multiply(a) {
return this.multiplyRight(a);
}

@@ -239,0 +249,0 @@

@@ -0,7 +1,8 @@

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import Vector3 from './vector3';
import { formatValue, equals, config } from '../lib/common';
import { degrees, radians, clamp } from '../lib/common';
import Vector3 from './vector3';
import * as vec3 from 'gl-matrix/vec3';
const EPSILON = 0.000001;
const EARTH_RADIUS_METERS = 6.371e6;
const EARTH_RADIUS_METERS = 6371000;
export default class SphericalCoordinates {

@@ -12,7 +13,15 @@ constructor({

radius = 1,
bearing = undefined,
pitch = undefined,
altitude = undefined,
bearing,
pitch,
altitude,
radiusScale = EARTH_RADIUS_METERS
} = {}) {
_defineProperty(this, "phi", void 0);
_defineProperty(this, "theta", void 0);
_defineProperty(this, "radius", void 0);
_defineProperty(this, "radiusScale", void 0);
this.phi = phi;

@@ -111,2 +120,3 @@ this.theta = theta;

this.theta = radians(lng);
return this.check();
}

@@ -113,0 +123,0 @@

@@ -7,6 +7,11 @@ import Vector from './base/vector';

const ORIGIN = [0, 0, 0];
const constants = {};
let ZERO;
export default class Vector3 extends Vector {
static get ZERO() {
return constants.ZERO = constants.ZERO || Object.freeze(new Vector3(0, 0, 0, 0));
if (!ZERO) {
ZERO = new Vector3(0, 0, 0);
Object.freeze(ZERO);
}
return ZERO;
}

@@ -13,0 +18,0 @@

@@ -6,6 +6,11 @@ import Vector from './base/vector';

import { vec4_transformMat2, vec4_transformMat3 } from '../lib/gl-matrix-extras';
const constants = {};
let ZERO;
export default class Vector4 extends Vector {
static get ZERO() {
return constants.ZERO = constants.ZERO || Object.freeze(new Vector4(0, 0, 0, 0));
if (!ZERO) {
ZERO = new Vector4(0, 0, 0, 0);
Object.freeze(ZERO);
}
return ZERO;
}

@@ -12,0 +17,0 @@

@@ -29,3 +29,3 @@ import assert from './assert';

export function clone(array) {
return 'clone' in array ? array.clone() : new Array(...array);
return 'clone' in array ? array.clone() : array.slice();
}

@@ -51,12 +51,12 @@ export function toRadians(degrees) {

export function tan(radians, result) {
return map(radians, angle => Math.tan(angle));
return map(radians, angle => Math.tan(angle), result);
}
export function asin(radians) {
return map(radians, angle => Math.asin(angle));
export function asin(radians, result) {
return map(radians, angle => Math.asin(angle), result);
}
export function acos(radians) {
return map(radians, angle => Math.acos(angle));
export function acos(radians, result) {
return map(radians, angle => Math.acos(angle), result);
}
export function atan(radians) {
return map(radians, angle => Math.atan(angle));
export function atan(radians, result) {
return map(radians, angle => Math.atan(angle), result);
}

@@ -63,0 +63,0 @@ export function clamp(value, min, max) {

import { NumericArray } from '@math.gl/types';
import type MathArray from '../classes/base/math-array';
export declare type ConfigurationOptions = {

@@ -27,3 +28,3 @@ EPSILON?: number;

export declare function isArray(value: unknown): boolean;
export declare function clone(array: NumericArray): NumericArray;
export declare function clone(array: NumericArray | MathArray): NumericArray;
export declare function toRadians(degrees: number): number;

@@ -47,3 +48,3 @@ export declare function toRadians(degrees: NumericArray): NumericArray;

*/
export declare function sin(radians: any, result?: any): any;
export declare function sin(radians: number | NumericArray, result?: NumericArray): number | NumericArray;
/**

@@ -53,3 +54,3 @@ * "GLSL equivalent" of `Math.cos`: Works on single values and vectors

*/
export declare function cos(radians: number | NumericArray, result?: any): any;
export declare function cos(radians: number | NumericArray, result?: NumericArray): number | NumericArray;
/**

@@ -59,3 +60,3 @@ * "GLSL equivalent" of `Math.tan`: Works on single values and vectors

*/
export declare function tan(radians: number | NumericArray, result?: any): any;
export declare function tan(radians: number | NumericArray, result?: NumericArray): number | NumericArray;
/**

@@ -65,3 +66,3 @@ * "GLSL equivalent" of `Math.asin`: Works on single values and vectors

*/
export declare function asin(radians: number | NumericArray): any;
export declare function asin(radians: number | NumericArray, result?: NumericArray): number | NumericArray;
/**

@@ -71,3 +72,3 @@ * "GLSL equivalent" of `Math.acos`: Works on single values and vectors

*/
export declare function acos(radians: number | NumericArray): any;
export declare function acos(radians: number | NumericArray, result?: NumericArray): number | NumericArray;
/**

@@ -77,11 +78,13 @@ * "GLSL equivalent" of `Math.atan`: Works on single values and vectors

*/
export declare function atan(radians: number | NumericArray): any;
export declare function atan(radians: number | NumericArray, result?: NumericArray): number | NumericArray;
/**
* GLSL style value clamping: Works on single values and vectors
*/
export declare function clamp(value: number | NumericArray, min: number, max: number): any;
export declare function clamp(value: number, min: number, max: number): number;
export declare function clamp(value: NumericArray, min: number, max: number): NumericArray;
/**
* Interpolate between two numbers or two arrays
*/
export declare function lerp(a: any, b: any, t: number): any;
export declare function lerp(a: number, b: number, t: number): number;
export declare function lerp(a: NumericArray, b: NumericArray, t: number): NumericArray;
/**

@@ -94,5 +97,5 @@ * Compares any two math objects, using `equals` method if available.

*/
export declare function equals(a: unknown, b: unknown, epsilon?: number): boolean;
export declare function equals(a: any, b: any, epsilon?: number): boolean;
export declare function exactEquals(a: any, b: any): boolean;
export declare function withEpsilon(epsilon: number, func: Function): any;
export declare function withEpsilon(epsilon: number, func: () => any): any;
//# sourceMappingURL=common.d.ts.map

@@ -42,4 +42,3 @@ import assert from './assert';

export function clone(array) {
// @ts-expect-error We are speculatively calling clone
return 'clone' in array ? array.clone() : new Array(...array);
return 'clone' in array ? array.clone() : array.slice();
}

@@ -77,3 +76,3 @@ export function toRadians(degrees) {

export function tan(radians, result) {
return map(radians, (angle) => Math.tan(angle));
return map(radians, (angle) => Math.tan(angle), result);
}

@@ -84,4 +83,4 @@ /**

*/
export function asin(radians) {
return map(radians, (angle) => Math.asin(angle));
export function asin(radians, result) {
return map(radians, (angle) => Math.asin(angle), result);
}

@@ -92,4 +91,4 @@ /**

*/
export function acos(radians) {
return map(radians, (angle) => Math.acos(angle));
export function acos(radians, result) {
return map(radians, (angle) => Math.acos(angle), result);
}

@@ -100,14 +99,8 @@ /**

*/
export function atan(radians) {
return map(radians, (angle) => Math.atan(angle));
export function atan(radians, result) {
return map(radians, (angle) => Math.atan(angle), result);
}
/**
* GLSL style value clamping: Works on single values and vectors
*/
export function clamp(value, min, max) {
return map(value, (value) => Math.max(min, Math.min(max, value)));
}
/**
* Interpolate between two numbers or two arrays
*/
export function lerp(a, b, t) {

@@ -119,2 +112,3 @@ if (isArray(a)) {

}
/* eslint-disable */
/**

@@ -127,3 +121,2 @@ * Compares any two math objects, using `equals` method if available.

*/
// eslint-disable-next-line complexity
export function equals(a, b, epsilon) {

@@ -139,7 +132,5 @@ const oldEpsilon = config.EPSILON;

if (isArray(a) && isArray(b)) {
// @ts-expect-error isArray has checked
if (a.length !== b.length) {
return false;
}
// @ts-expect-error isArray has checked
for (let i = 0; i < a.length; ++i) {

@@ -153,10 +144,6 @@ // eslint-disable-next-line max-depth

}
// @ts-expect-error Dynamic testing
if (a && a.equals) {
// @ts-expect-error Dynamic testing
return a.equals(b);
}
// @ts-expect-error Dynamic testing
if (b && b.equals) {
// @ts-expect-error Dynamic testing
return b.equals(a);

@@ -173,3 +160,2 @@ }

}
// eslint-disable-next-line complexity
export function exactEquals(a, b) {

@@ -200,2 +186,3 @@ if (a === b) {

}
/* eslint-enable */
export function withEpsilon(epsilon, func) {

@@ -202,0 +189,0 @@ const oldPrecision = config.EPSILON;

@@ -1,6 +0,7 @@

export declare function vec2_transformMat4AsVector(out: any, a: any, m: any): any;
export declare function vec3_transformMat4AsVector(out: any, a: any, m: any): any;
export declare function vec3_transformMat2(out: any, a: any, m: any): any;
export declare function vec4_transformMat2(out: any, a: any, m: any): any;
export declare function vec4_transformMat3(out: any, a: any, m: any): any;
import { NumericArray } from '@math.gl/types';
export declare function vec2_transformMat4AsVector<T extends NumericArray>(out: T, a: Readonly<NumericArray>, m: Readonly<NumericArray>): T;
export declare function vec3_transformMat4AsVector<T extends NumericArray>(out: T, a: Readonly<NumericArray>, m: Readonly<NumericArray>): T;
export declare function vec3_transformMat2<T extends NumericArray>(out: T, a: Readonly<NumericArray>, m: Readonly<NumericArray>): T;
export declare function vec4_transformMat2<T extends NumericArray>(out: T, a: Readonly<NumericArray>, m: Readonly<NumericArray>): T;
export declare function vec4_transformMat3<T extends NumericArray>(out: T, a: Readonly<NumericArray>, m: Readonly<NumericArray>): T;
//# sourceMappingURL=gl-matrix-extras.d.ts.map

@@ -1,2 +0,1 @@

/* eslint-disable camelcase */
// vec2 additions

@@ -3,0 +2,0 @@ export function vec2_transformMat4AsVector(out, a, m) {

@@ -1,5 +0,6 @@

export declare function validateVector(v: any, length: any): boolean;
export declare function checkNumber(value: any): any;
export declare function checkVector(v: any, length: any, callerName?: string): any;
export declare function deprecated(method: any, version: any): void;
import { NumberArray } from '@math.gl/types';
export declare function validateVector(v: NumberArray, length: number): boolean;
export declare function checkNumber(value: any): number;
export declare function checkVector<T extends NumberArray>(v: T, length: number, callerName?: string): T;
export declare function deprecated(method: string, version: string): void;
//# sourceMappingURL=validators.d.ts.map

@@ -1,20 +0,1 @@

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import { config } from './common';

@@ -21,0 +2,0 @@ export function validateVector(v, length) {

@@ -8,3 +8,3 @@ {

},
"version": "3.6.0-alpha.1",
"version": "3.6.0-alpha.2",
"keywords": [

@@ -42,6 +42,6 @@ "webgl",

"@babel/runtime": "^7.12.0",
"@math.gl/types": "3.6.0-alpha.1",
"gl-matrix": "~3.3.0"
"@math.gl/types": "3.6.0-alpha.2",
"gl-matrix": "^3.4.0"
},
"gitHead": "45386981340895bf201c2ebb76257c9bbffd8ff6"
"gitHead": "ea7dc265c98b68af56218302d1d42b7d65f74ccb"
}

@@ -6,2 +6,4 @@ // Copyright (c) 2017 Uber Technologies, Inc.

import type MathArray from '../classes/base/math-array';
export type ConfigurationOptions = {

@@ -65,5 +67,4 @@ EPSILON?: number;

export function clone(array: NumericArray): NumericArray {
// @ts-expect-error We are speculatively calling clone
return 'clone' in array ? array.clone() : new Array(...array);
export function clone(array: NumericArray | MathArray): NumericArray {
return 'clone' in array ? array.clone() : array.slice();
}

@@ -74,4 +75,4 @@

export function toRadians(degrees): any {
return radians(degrees);
export function toRadians(degrees: number | NumericArray): number | NumericArray {
return radians(degrees as NumericArray);
}

@@ -82,4 +83,4 @@

export function toDegrees(radians): any {
return degrees(radians);
export function toDegrees(radians: number | NumericArray): number | NumericArray {
return degrees(radians as NumericArray);
}

@@ -95,3 +96,6 @@

export function radians(degrees, result?) {
export function radians(
degrees: number | NumericArray,
result?: NumericArray
): number | NumericArray {
return map(degrees, (degrees) => degrees * DEGREES_TO_RADIANS, result);

@@ -106,3 +110,6 @@ }

export function degrees(radians: number | NumericArray, result?) {
export function degrees(
radians: number | NumericArray,
result?: NumericArray
): number | NumericArray {
return map(radians, (radians) => radians * RADIANS_TO_DEGREES, result);

@@ -115,3 +122,3 @@ }

*/
export function sin(radians: any, result?: any): any {
export function sin(radians: number | NumericArray, result?: NumericArray): number | NumericArray {
return map(radians, (angle) => Math.sin(angle), result);

@@ -124,3 +131,3 @@ }

*/
export function cos(radians: number | NumericArray, result?) {
export function cos(radians: number | NumericArray, result?: NumericArray): number | NumericArray {
return map(radians, (angle) => Math.cos(angle), result);

@@ -133,4 +140,4 @@ }

*/
export function tan(radians: number | NumericArray, result?) {
return map(radians, (angle) => Math.tan(angle));
export function tan(radians: number | NumericArray, result?: NumericArray): number | NumericArray {
return map(radians, (angle) => Math.tan(angle), result);
}

@@ -142,4 +149,4 @@

*/
export function asin(radians: number | NumericArray) {
return map(radians, (angle) => Math.asin(angle));
export function asin(radians: number | NumericArray, result?: NumericArray): number | NumericArray {
return map(radians, (angle) => Math.asin(angle), result);
}

@@ -151,4 +158,4 @@

*/
export function acos(radians: number | NumericArray) {
return map(radians, (angle) => Math.acos(angle));
export function acos(radians: number | NumericArray, result?: NumericArray): number | NumericArray {
return map(radians, (angle) => Math.acos(angle), result);
}

@@ -160,4 +167,4 @@

*/
export function atan(radians: number | NumericArray) {
return map(radians, (angle) => Math.atan(angle));
export function atan(radians: number | NumericArray, result?: NumericArray): number | NumericArray {
return map(radians, (angle) => Math.atan(angle), result);
}

@@ -168,3 +175,10 @@

*/
export function clamp(value: number | NumericArray, min: number, max: number) {
export function clamp(value: number, min: number, max: number): number;
export function clamp(value: NumericArray, min: number, max: number): NumericArray;
export function clamp(
value: number | NumericArray,
min: number,
max: number
): number | NumericArray {
return map(value, (value) => Math.max(min, Math.min(max, value)));

@@ -176,9 +190,18 @@ }

*/
export function lerp(a, b, t: number) {
export function lerp(a: number, b: number, t: number): number;
export function lerp(a: NumericArray, b: NumericArray, t: number): NumericArray;
export function lerp(
a: number | NumericArray,
b: number | NumericArray,
t: number
): number | NumericArray {
if (isArray(a)) {
return a.map((ai, i) => lerp(ai, b[i], t));
return (a as NumericArray).map((ai: number, i: number) => lerp(ai, (b as NumericArray)[i], t));
}
return t * b + (1 - t) * a;
return t * (b as number) + (1 - t) * (a as number);
}
/* eslint-disable */
/**

@@ -191,4 +214,3 @@ * Compares any two math objects, using `equals` method if available.

*/
// eslint-disable-next-line complexity
export function equals(a: unknown, b: unknown, epsilon?: number): boolean {
export function equals(a: any, b: any, epsilon?: number): boolean {
const oldEpsilon = config.EPSILON;

@@ -203,7 +225,5 @@ if (epsilon) {

if (isArray(a) && isArray(b)) {
// @ts-expect-error isArray has checked
if (a.length !== b.length) {
return false;
}
// @ts-expect-error isArray has checked
for (let i = 0; i < a.length; ++i) {

@@ -217,10 +237,6 @@ // eslint-disable-next-line max-depth

}
// @ts-expect-error Dynamic testing
if (a && a.equals) {
// @ts-expect-error Dynamic testing
return a.equals(b);
}
// @ts-expect-error Dynamic testing
if (b && b.equals) {
// @ts-expect-error Dynamic testing
return b.equals(a);

@@ -237,4 +253,3 @@ }

// eslint-disable-next-line complexity
export function exactEquals(a, b): boolean {
export function exactEquals(a: any, b: any): boolean {
if (a === b) {

@@ -265,3 +280,5 @@ return true;

export function withEpsilon(epsilon: number, func: Function): any {
/* eslint-enable */
export function withEpsilon(epsilon: number, func: () => any): any {
const oldPrecision = config.EPSILON;

@@ -287,3 +304,3 @@ config.EPSILON = epsilon;

// @ts-expect-error We check for math.gl class methods
return array.clone ? array.clone() : new Array(array.length);
return array.clone ? array.clone() : (new Array(array.length) as number[]);
}

@@ -293,3 +310,7 @@

// otherwise applies func to the argument value
function map(value: number | NumericArray, func: Function, result?) {
function map(
value: number | NumericArray,
func: (x: number, index?: number, result?: NumericArray) => number,
result?: NumericArray
): number | NumericArray {
if (isArray(value)) {

@@ -303,3 +324,3 @@ const array = value as NumericArray;

}
return func(value);
return func(value as number);
}
/* eslint-disable camelcase */
import {NumericArray} from '@math.gl/types';
// vec2 additions
export function vec2_transformMat4AsVector(out, a, m) {
export function vec2_transformMat4AsVector<T extends NumericArray>(
out: T,
a: Readonly<NumericArray>,
m: Readonly<NumericArray>
): T {
const x = a[0];

@@ -16,3 +21,7 @@ const y = a[1];

// Transform as vector, only uses 3x3 minor matrix
export function vec3_transformMat4AsVector(out, a, m) {
export function vec3_transformMat4AsVector<T extends NumericArray>(
out: T,
a: Readonly<NumericArray>,
m: Readonly<NumericArray>
): T {
const x = a[0];

@@ -28,3 +37,7 @@ const y = a[1];

export function vec3_transformMat2(out, a, m) {
export function vec3_transformMat2<T extends NumericArray>(
out: T,
a: Readonly<NumericArray>,
m: Readonly<NumericArray>
): T {
const x = a[0];

@@ -40,3 +53,7 @@ const y = a[1];

export function vec4_transformMat2(out, a, m) {
export function vec4_transformMat2<T extends NumericArray>(
out: T,
a: Readonly<NumericArray>,
m: Readonly<NumericArray>
): T {
const x = a[0];

@@ -51,3 +68,7 @@ const y = a[1];

export function vec4_transformMat3(out, a, m) {
export function vec4_transformMat3<T extends NumericArray>(
out: T,
a: Readonly<NumericArray>,
m: Readonly<NumericArray>
): T {
const x = a[0];

@@ -54,0 +75,0 @@ const y = a[1];

@@ -20,6 +20,6 @@ // Copyright (c) 2017 Uber Technologies, Inc.

// THE SOFTWARE.
import {NumberArray} from '@math.gl/types';
import {config} from './common';
export function validateVector(v, length) {
export function validateVector(v: NumberArray, length: number): boolean {
if (v.length !== length) {

@@ -37,10 +37,14 @@ return false;

export function checkNumber(value) {
export function checkNumber(value: any): number {
if (!Number.isFinite(value)) {
throw new Error(`Invalid number ${value}`);
}
return value;
return value as number;
}
export function checkVector(v, length, callerName = '') {
export function checkVector<T extends NumberArray>(
v: T,
length: number,
callerName: string = ''
): T {
if (config.debug && !validateVector(v, length)) {

@@ -54,3 +58,3 @@ throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);

export function deprecated(method, version) {
export function deprecated(method: string, version: string): void {
if (!map[method]) {

@@ -57,0 +61,0 @@ map[method] = true;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc