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

@math.gl/core

Package Overview
Dependencies
Maintainers
4
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.1.3 to 3.2.0-alpha.1

src/addons/polygon.d.ts

16

dist/es5/classes/base/math-array.js

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

var _assert = _interopRequireDefault(require("../../lib/assert"));
var MathArray = function (_Array) {

@@ -289,3 +291,3 @@ (0, _inherits2["default"])(MathArray, _Array);

value: function check() {
if (_common.config.debug && !this.validate(this)) {
if (_common.config.debug && !this.validate()) {
throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));

@@ -308,2 +310,14 @@ }

}, {
key: "ELEMENTS",
get: function get() {
(0, _assert["default"])(false);
return 0;
}
}, {
key: "RANK",
get: function get() {
(0, _assert["default"])(false);
return 0;
}
}, {
key: "elements",

@@ -310,0 +324,0 @@ get: function get() {

10

dist/es5/classes/base/vector.js

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

(0, _createClass2["default"])(Vector, [{
key: "copy",
value: function copy(vector) {
(0, _assert["default"])(false);
return this;
}
}, {
key: "len",

@@ -190,3 +196,3 @@ value: function len() {

set: function set(value) {
return this[0] = (0, _validators.checkNumber)(value);
this[0] = (0, _validators.checkNumber)(value);
}

@@ -199,3 +205,3 @@ }, {

set: function set(value) {
return this[1] = (0, _validators.checkNumber)(value);
this[1] = (0, _validators.checkNumber)(value);
}

@@ -202,0 +208,0 @@ }]);

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

set: function set(value) {
return this[0] = (0, _validators.checkNumber)(value);
this[0] = (0, _validators.checkNumber)(value);
}

@@ -541,3 +541,3 @@ }, {

set: function set(value) {
return this[1] = (0, _validators.checkNumber)(value);
this[1] = (0, _validators.checkNumber)(value);
}

@@ -550,3 +550,3 @@ }, {

set: function set(value) {
return this[2] = (0, _validators.checkNumber)(value);
this[2] = (0, _validators.checkNumber)(value);
}

@@ -559,3 +559,3 @@ }, {

set: function set(value) {
return this[0] = (0, _validators.checkNumber)(value);
this[0] = (0, _validators.checkNumber)(value);
}

@@ -568,3 +568,3 @@ }, {

set: function set(value) {
return this[1] = (0, _validators.checkNumber)(value);
this[1] = (0, _validators.checkNumber)(value);
}

@@ -577,3 +577,3 @@ }, {

set: function set(value) {
return this[2] = (0, _validators.checkNumber)(value);
this[2] = (0, _validators.checkNumber)(value);
}

@@ -586,3 +586,3 @@ }, {

set: function set(value) {
return this[0] = (0, _validators.checkNumber)(value);
this[0] = (0, _validators.checkNumber)(value);
}

@@ -595,3 +595,3 @@ }, {

set: function set(value) {
return this[1] = (0, _validators.checkNumber)(value);
this[1] = (0, _validators.checkNumber)(value);
}

@@ -604,3 +604,3 @@ }, {

set: function set(value) {
return this[2] = (0, _validators.checkNumber)(value);
this[2] = (0, _validators.checkNumber)(value);
}

@@ -613,3 +613,3 @@ }, {

set: function set(value) {
return this[0] = (0, _validators.checkNumber)(value);
this[0] = (0, _validators.checkNumber)(value);
}

@@ -622,3 +622,3 @@ }, {

set: function set(value) {
return this[1] = (0, _validators.checkNumber)(value);
this[1] = (0, _validators.checkNumber)(value);
}

@@ -631,3 +631,3 @@ }, {

set: function set(value) {
return this[2] = (0, _validators.checkNumber)(value);
this[2] = (0, _validators.checkNumber)(value);
}

@@ -640,3 +640,3 @@ }, {

set: function set(value) {
return this[3] = checkOrder(value);
this[3] = checkOrder(value);
}

@@ -643,0 +643,0 @@ }]);

@@ -282,3 +282,4 @@ "use strict";

var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
fovy = _ref4.fovy,
_ref4$fovy = _ref4.fovy,
fovy = _ref4$fovy === void 0 ? undefined : _ref4$fovy,
_ref4$fov = _ref4.fov,

@@ -285,0 +286,0 @@ fov = _ref4$fov === void 0 ? 45 * Math.PI / 180 : _ref4$fov,

@@ -35,4 +35,6 @@ "use strict";

yaw = _ref$yaw === void 0 ? 0 : _ref$yaw,
position = _ref.position,
orientation = _ref.orientation;
_ref$position = _ref.position,
position = _ref$position === void 0 ? undefined : _ref$position,
_ref$orientation = _ref.orientation,
orientation = _ref$orientation === void 0 ? undefined : _ref$orientation;

@@ -110,3 +112,3 @@ (0, _classCallCheck2["default"])(this, Pose);

set: function set(value) {
return this.position.x = value;
this.position.x = value;
}

@@ -119,3 +121,3 @@ }, {

set: function set(value) {
return this.position.y = value;
this.position.y = value;
}

@@ -128,3 +130,3 @@ }, {

set: function set(value) {
return this.position.z = value;
this.position.z = value;
}

@@ -137,3 +139,3 @@ }, {

set: function set(value) {
return this.orientation.roll = value;
this.orientation.roll = value;
}

@@ -146,3 +148,3 @@ }, {

set: function set(value) {
return this.orientation.pitch = value;
this.orientation.pitch = value;
}

@@ -155,3 +157,3 @@ }, {

set: function set(value) {
return this.orientation.yaw = value;
this.orientation.yaw = value;
}

@@ -158,0 +160,0 @@ }]);

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

key: "lengthSquared",
value: function lengthSquared(a) {
value: function lengthSquared() {
return quat.squaredLength(this);

@@ -275,3 +275,3 @@ }

set: function set(value) {
return this[0] = (0, _validators.checkNumber)(value);
this[0] = (0, _validators.checkNumber)(value);
}

@@ -284,3 +284,3 @@ }, {

set: function set(value) {
return this[1] = (0, _validators.checkNumber)(value);
this[1] = (0, _validators.checkNumber)(value);
}

@@ -293,3 +293,3 @@ }, {

set: function set(value) {
return this[2] = (0, _validators.checkNumber)(value);
this[2] = (0, _validators.checkNumber)(value);
}

@@ -302,3 +302,3 @@ }, {

set: function set(value) {
return this[3] = (0, _validators.checkNumber)(value);
this[3] = (0, _validators.checkNumber)(value);
}

@@ -305,0 +305,0 @@ }]);

@@ -30,8 +30,14 @@ "use strict";

var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
phi = _ref.phi,
theta = _ref.theta,
radius = _ref.radius,
bearing = _ref.bearing,
pitch = _ref.pitch,
altitude = _ref.altitude,
_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,
_ref$bearing = _ref.bearing,
bearing = _ref$bearing === void 0 ? undefined : _ref$bearing,
_ref$pitch = _ref.pitch,
pitch = _ref$pitch === void 0 ? undefined : _ref$pitch,
_ref$altitude = _ref.altitude,
altitude = _ref$altitude === void 0 ? undefined : _ref$altitude,
_ref$radiusScale = _ref.radiusScale,

@@ -41,17 +47,15 @@ radiusScale = _ref$radiusScale === void 0 ? EARTH_RADIUS_METERS : _ref$radiusScale;

(0, _classCallCheck2["default"])(this, SphericalCoordinates);
this.phi = phi;
this.theta = theta;
this.radius = radius || altitude || 1;
this.radiusScale = radiusScale || 1;
if (arguments.length === 0) {
this.phi = 0;
this.theta = 0;
this.radius = 1;
} else if (Number.isFinite(phi) || Number.isFinite(theta)) {
this.phi = phi || 0;
this.theta = theta || 0;
} else if (Number.isFinite(bearing) || Number.isFinite(pitch)) {
this.bearing = bearing || 0;
this.pitch = pitch || 0;
if (bearing !== undefined) {
this.bearing = bearing;
}
this.radius = radius || 1;
this.radiusScale = radiusScale || 1;
if (pitch !== undefined) {
this.pitch = pitch;
}
this.check();

@@ -68,4 +72,4 @@ }

value: function formatString(_ref2) {
var printTypes = _ref2.printTypes,
printDegrees = _ref2.printDegrees;
var _ref2$printTypes = _ref2.printTypes,
printTypes = _ref2$printTypes === void 0 ? false : _ref2$printTypes;
var f = _common.formatValue;

@@ -95,3 +99,3 @@ return "".concat(printTypes ? 'Spherical' : '', "[rho:").concat(f(this.radius), ",theta:").concat(f(this.theta), ",phi:").concat(f(this.phi), "]");

value: function clone() {
return new this.constructor().copy(this);
return new SphericalCoordinates().copy(this);
}

@@ -143,2 +147,3 @@ }, {

this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
return this;
}

@@ -145,0 +150,0 @@ }, {

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

key: "set",
value: function set(x, y, z) {
value: function set(x, y) {
this[0] = x;

@@ -63,0 +63,0 @@ this[1] = y;

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

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

@@ -21,2 +19,4 @@

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

@@ -35,5 +35,12 @@

var ORIGIN = [0, 0, 0];
var constants = {};
var Vector3 = function (_Vector) {
(0, _inherits2["default"])(Vector3, _Vector);
(0, _createClass2["default"])(Vector3, null, [{
key: "ZERO",
get: function get() {
return constants.ZERO = constants.ZERO || Object.freeze(new Vector3(0, 0, 0, 0));
}
}]);

@@ -188,3 +195,3 @@ function Vector3() {

set: function set(value) {
return this[2] = (0, _validators.checkNumber)(value);
this[2] = (0, _validators.checkNumber)(value);
}

@@ -191,0 +198,0 @@ }]);

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

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

@@ -21,2 +19,4 @@

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

@@ -34,4 +34,12 @@

var constants = {};
var Vector4 = function (_Vector) {
(0, _inherits2["default"])(Vector4, _Vector);
(0, _createClass2["default"])(Vector4, null, [{
key: "ZERO",
get: function get() {
return constants.ZERO = constants.ZERO || Object.freeze(new Vector4(0, 0, 0, 0));
}
}]);

@@ -151,3 +159,3 @@ function Vector4() {

set: function set(value) {
return this[2] = (0, _validators.checkNumber)(value);
this[2] = (0, _validators.checkNumber)(value);
}

@@ -160,3 +168,3 @@ }, {

set: function set(value) {
return this[3] = (0, _validators.checkNumber)(value);
this[3] = (0, _validators.checkNumber)(value);
}

@@ -163,0 +171,0 @@ }]);

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

});
Object.defineProperty(exports, "Vector2", {
enumerable: true,
get: function get() {
return _vector["default"];
}
});
Object.defineProperty(exports, "Vector3", {
enumerable: true,
get: function get() {
return _vector2["default"];
}
});
Object.defineProperty(exports, "Vector4", {
enumerable: true,
get: function get() {
return _vector3["default"];
}
});
Object.defineProperty(exports, "Matrix3", {
enumerable: true,
get: function get() {
return _matrix["default"];
}
});
Object.defineProperty(exports, "Matrix4", {
enumerable: true,
get: function get() {
return _matrix2["default"];
}
});
Object.defineProperty(exports, "Quaternion", {
enumerable: true,
get: function get() {
return _quaternion["default"];
}
});
Object.defineProperty(exports, "config", {

@@ -159,3 +123,3 @@ enumerable: true,

});
Object.defineProperty(exports, "_withEpsilon", {
Object.defineProperty(exports, "withEpsilon", {
enumerable: true,

@@ -166,2 +130,38 @@ get: function get() {

});
Object.defineProperty(exports, "Vector2", {
enumerable: true,
get: function get() {
return _vector["default"];
}
});
Object.defineProperty(exports, "Vector3", {
enumerable: true,
get: function get() {
return _vector2["default"];
}
});
Object.defineProperty(exports, "Vector4", {
enumerable: true,
get: function get() {
return _vector3["default"];
}
});
Object.defineProperty(exports, "Matrix3", {
enumerable: true,
get: function get() {
return _matrix["default"];
}
});
Object.defineProperty(exports, "Matrix4", {
enumerable: true,
get: function get() {
return _matrix2["default"];
}
});
Object.defineProperty(exports, "Quaternion", {
enumerable: true,
get: function get() {
return _quaternion["default"];
}
});
Object.defineProperty(exports, "checkNumber", {

@@ -210,3 +210,3 @@ enumerable: true,

var _math = require("math.gl");
var _common = require("./lib/common");

@@ -225,4 +225,2 @@ var _vector = _interopRequireDefault(require("./classes/vector2"));

var _common = require("./lib/common");
var _validators = require("./lib/validators");

@@ -249,4 +247,4 @@

global_.mathgl = {
config: _math.config
config: _common.config
};
//# sourceMappingURL=index.js.map

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

function isArray(value) {
return Array.isArray(value) || ArrayBuffer.isView(value) && value.length !== undefined;
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
}

@@ -76,0 +76,0 @@

@@ -35,5 +35,7 @@ "use strict";

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)) {
throw new Error("math.gl: ".concat(callerName | '', " some fields set to invalid numbers'"));
throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
}

@@ -40,0 +42,0 @@

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

@@ -217,3 +228,3 @@ return new this.constructor().copy(this);

check() {
if (config.debug && !this.validate(this)) {
if (config.debug && !this.validate()) {
throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));

@@ -220,0 +231,0 @@ }

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

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

@@ -11,3 +16,3 @@ return this[0];

set x(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -20,3 +25,3 @@

set y(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -23,0 +28,0 @@

@@ -138,3 +138,3 @@ import MathArray from './base/math-array';

set x(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -147,3 +147,3 @@

set y(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -156,3 +156,3 @@

set z(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -165,3 +165,3 @@

set alpha(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -174,3 +174,3 @@

set beta(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -183,3 +183,3 @@

set gamma(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

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

set phi(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -201,3 +201,3 @@

set theta(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -210,3 +210,3 @@

set psi(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -219,3 +219,3 @@

set roll(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -228,3 +228,3 @@

set pitch(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -237,3 +237,3 @@

set yaw(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -246,3 +246,3 @@

set order(value) {
return this[3] = checkOrder(value);
this[3] = checkOrder(value);
}

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

@@ -247,3 +247,3 @@ import { checkVector, deprecated } from '../lib/validators';

perspective({
fovy,
fovy = undefined,
fov = 45 * Math.PI / 180,

@@ -250,0 +250,0 @@ aspect = 1,

@@ -12,4 +12,4 @@ import Matrix4 from './matrix4';

yaw = 0,
position,
orientation
position = undefined,
orientation = undefined
} = {}) {

@@ -34,3 +34,3 @@ if (Array.isArray(position) && position.length === 3) {

set x(value) {
return this.position.x = value;
this.position.x = value;
}

@@ -43,3 +43,3 @@

set y(value) {
return this.position.y = value;
this.position.y = value;
}

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

set z(value) {
return this.position.z = value;
this.position.z = value;
}

@@ -61,3 +61,3 @@

set roll(value) {
return this.orientation.roll = value;
this.orientation.roll = value;
}

@@ -70,3 +70,3 @@

set pitch(value) {
return this.orientation.pitch = value;
this.orientation.pitch = value;
}

@@ -79,3 +79,3 @@

set yaw(value) {
return this.orientation.yaw = value;
this.orientation.yaw = value;
}

@@ -82,0 +82,0 @@

@@ -62,3 +62,3 @@ import MathArray from './base/math-array';

set x(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -71,3 +71,3 @@

set y(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

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

set z(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -89,3 +89,3 @@

set w(value) {
return this[3] = checkNumber(value);
this[3] = checkNumber(value);
}

@@ -97,3 +97,3 @@

lengthSquared(a) {
lengthSquared() {
return quat.squaredLength(this);

@@ -100,0 +100,0 @@ }

@@ -9,24 +9,23 @@ import { formatValue, equals, config } from '../lib/common';

constructor({
phi,
theta,
radius,
bearing,
pitch,
altitude,
phi = 0,
theta = 0,
radius = 1,
bearing = undefined,
pitch = undefined,
altitude = undefined,
radiusScale = EARTH_RADIUS_METERS
} = {}) {
if (arguments.length === 0) {
this.phi = 0;
this.theta = 0;
this.radius = 1;
} else if (Number.isFinite(phi) || Number.isFinite(theta)) {
this.phi = phi || 0;
this.theta = theta || 0;
} else if (Number.isFinite(bearing) || Number.isFinite(pitch)) {
this.bearing = bearing || 0;
this.pitch = pitch || 0;
this.phi = phi;
this.theta = theta;
this.radius = radius || altitude || 1;
this.radiusScale = radiusScale || 1;
if (bearing !== undefined) {
this.bearing = bearing;
}
this.radius = radius || 1;
this.radiusScale = radiusScale || 1;
if (pitch !== undefined) {
this.pitch = pitch;
}
this.check();

@@ -40,4 +39,3 @@ }

formatString({
printTypes,
printDegrees
printTypes = false
}) {

@@ -100,3 +98,3 @@ const f = formatValue;

clone() {
return new this.constructor().copy(this);
return new SphericalCoordinates().copy(this);
}

@@ -138,2 +136,3 @@

this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
return this;
}

@@ -140,0 +139,0 @@

@@ -23,3 +23,3 @@ import Vector from './base/vector';

set(x, y, z) {
set(x, y) {
this[0] = x;

@@ -26,0 +26,0 @@ this[1] = y;

@@ -7,3 +7,8 @@ import Vector from './base/vector';

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

@@ -70,3 +75,3 @@ super(-0, -0, -0);

set z(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -73,0 +78,0 @@

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

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

@@ -76,3 +81,3 @@ super(-0, -0, -0, -0);

set z(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -85,3 +90,3 @@

set w(value) {
return this[3] = checkNumber(value);
this[3] = checkNumber(value);
}

@@ -88,0 +93,0 @@

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

import { config } from 'math.gl';
import { config } from './lib/common';
export { default as Vector2 } from './classes/vector2';

@@ -8,3 +8,3 @@ export { default as Vector3 } from './classes/vector3';

export { default as Quaternion } from './classes/quaternion';
export { config, configure, formatValue, isArray, clone, equals, exactEquals, toRadians, toDegrees, radians, degrees, sin, cos, tan, asin, acos, atan, clamp, lerp, withEpsilon as _withEpsilon } from './lib/common';
export { config, configure, formatValue, isArray, clone, equals, exactEquals, toRadians, toDegrees, radians, degrees, sin, cos, tan, asin, acos, atan, clamp, lerp, withEpsilon } from './lib/common';
export { checkNumber } from './lib/validators';

@@ -11,0 +11,0 @@ export { default as _MathUtils } from './lib/math-utils';

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

export function isArray(value) {
return Array.isArray(value) || ArrayBuffer.isView(value) && value.length !== undefined;
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
}

@@ -35,0 +35,0 @@

@@ -22,5 +22,5 @@ import { config } from './common';

}
export function checkVector(v, length, callerName) {
export function checkVector(v, length, callerName = '') {
if (config.debug && !validateVector(v, length)) {
throw new Error("math.gl: ".concat(callerName | '', " some fields set to invalid numbers'"));
throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
}

@@ -27,0 +27,0 @@

@@ -8,2 +8,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

import { config, formatValue, equals as _equals, isArray } from '../../lib/common';
import assert from '../../lib/assert';

@@ -275,3 +276,3 @@ var MathArray = function (_Array) {

value: function check() {
if (config.debug && !this.validate(this)) {
if (config.debug && !this.validate()) {
throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));

@@ -294,2 +295,14 @@ }

}, {
key: "ELEMENTS",
get: function get() {
assert(false);
return 0;
}
}, {
key: "RANK",
get: function get() {
assert(false);
return 0;
}
}, {
key: "elements",

@@ -296,0 +309,0 @@ get: function get() {

@@ -20,2 +20,8 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

_createClass(Vector, [{
key: "copy",
value: function copy(vector) {
assert(false);
return this;
}
}, {
key: "len",

@@ -175,3 +181,3 @@ value: function len() {

set: function set(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -184,3 +190,3 @@ }, {

set: function set(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -187,0 +193,0 @@ }]);

@@ -516,3 +516,3 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

set: function set(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -525,3 +525,3 @@ }, {

set: function set(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -534,3 +534,3 @@ }, {

set: function set(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -543,3 +543,3 @@ }, {

set: function set(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -552,3 +552,3 @@ }, {

set: function set(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -561,3 +561,3 @@ }, {

set: function set(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -570,3 +570,3 @@ }, {

set: function set(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -579,3 +579,3 @@ }, {

set: function set(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -588,3 +588,3 @@ }, {

set: function set(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -597,3 +597,3 @@ }, {

set: function set(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -606,3 +606,3 @@ }, {

set: function set(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -615,3 +615,3 @@ }, {

set: function set(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -624,3 +624,3 @@ }, {

set: function set(value) {
return this[3] = checkOrder(value);
this[3] = checkOrder(value);
}

@@ -627,0 +627,0 @@ }]);

@@ -260,3 +260,4 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
fovy = _ref4.fovy,
_ref4$fovy = _ref4.fovy,
fovy = _ref4$fovy === void 0 ? undefined : _ref4$fovy,
_ref4$fov = _ref4.fov,

@@ -263,0 +264,0 @@ fov = _ref4$fov === void 0 ? 45 * Math.PI / 180 : _ref4$fov,

@@ -22,4 +22,6 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

yaw = _ref$yaw === void 0 ? 0 : _ref$yaw,
position = _ref.position,
orientation = _ref.orientation;
_ref$position = _ref.position,
position = _ref$position === void 0 ? undefined : _ref$position,
_ref$orientation = _ref.orientation,
orientation = _ref$orientation === void 0 ? undefined : _ref$orientation;

@@ -97,3 +99,3 @@ _classCallCheck(this, Pose);

set: function set(value) {
return this.position.x = value;
this.position.x = value;
}

@@ -106,3 +108,3 @@ }, {

set: function set(value) {
return this.position.y = value;
this.position.y = value;
}

@@ -115,3 +117,3 @@ }, {

set: function set(value) {
return this.position.z = value;
this.position.z = value;
}

@@ -124,3 +126,3 @@ }, {

set: function set(value) {
return this.orientation.roll = value;
this.orientation.roll = value;
}

@@ -133,3 +135,3 @@ }, {

set: function set(value) {
return this.orientation.pitch = value;
this.orientation.pitch = value;
}

@@ -142,3 +144,3 @@ }, {

set: function set(value) {
return this.orientation.yaw = value;
this.orientation.yaw = value;
}

@@ -145,0 +147,0 @@ }]);

@@ -85,3 +85,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

key: "lengthSquared",
value: function lengthSquared(a) {
value: function lengthSquared() {
return quat.squaredLength(this);

@@ -256,3 +256,3 @@ }

set: function set(value) {
return this[0] = checkNumber(value);
this[0] = checkNumber(value);
}

@@ -265,3 +265,3 @@ }, {

set: function set(value) {
return this[1] = checkNumber(value);
this[1] = checkNumber(value);
}

@@ -274,3 +274,3 @@ }, {

set: function set(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -283,3 +283,3 @@ }, {

set: function set(value) {
return this[3] = checkNumber(value);
this[3] = checkNumber(value);
}

@@ -286,0 +286,0 @@ }]);

@@ -14,8 +14,14 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
phi = _ref.phi,
theta = _ref.theta,
radius = _ref.radius,
bearing = _ref.bearing,
pitch = _ref.pitch,
altitude = _ref.altitude,
_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,
_ref$bearing = _ref.bearing,
bearing = _ref$bearing === void 0 ? undefined : _ref$bearing,
_ref$pitch = _ref.pitch,
pitch = _ref$pitch === void 0 ? undefined : _ref$pitch,
_ref$altitude = _ref.altitude,
altitude = _ref$altitude === void 0 ? undefined : _ref$altitude,
_ref$radiusScale = _ref.radiusScale,

@@ -26,16 +32,15 @@ radiusScale = _ref$radiusScale === void 0 ? EARTH_RADIUS_METERS : _ref$radiusScale;

if (arguments.length === 0) {
this.phi = 0;
this.theta = 0;
this.radius = 1;
} else if (Number.isFinite(phi) || Number.isFinite(theta)) {
this.phi = phi || 0;
this.theta = theta || 0;
} else if (Number.isFinite(bearing) || Number.isFinite(pitch)) {
this.bearing = bearing || 0;
this.pitch = pitch || 0;
this.phi = phi;
this.theta = theta;
this.radius = radius || altitude || 1;
this.radiusScale = radiusScale || 1;
if (bearing !== undefined) {
this.bearing = bearing;
}
this.radius = radius || 1;
this.radiusScale = radiusScale || 1;
if (pitch !== undefined) {
this.pitch = pitch;
}
this.check();

@@ -52,4 +57,4 @@ }

value: function formatString(_ref2) {
var printTypes = _ref2.printTypes,
printDegrees = _ref2.printDegrees;
var _ref2$printTypes = _ref2.printTypes,
printTypes = _ref2$printTypes === void 0 ? false : _ref2$printTypes;
var f = formatValue;

@@ -79,3 +84,3 @@ return "".concat(printTypes ? 'Spherical' : '', "[rho:").concat(f(this.radius), ",theta:").concat(f(this.theta), ",phi:").concat(f(this.phi), "]");

value: function clone() {
return new this.constructor().copy(this);
return new SphericalCoordinates().copy(this);
}

@@ -127,2 +132,3 @@ }, {

this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
return this;
}

@@ -129,0 +135,0 @@ }, {

@@ -42,3 +42,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

key: "set",
value: function set(x, y, z) {
value: function set(x, y) {
this[0] = x;

@@ -45,0 +45,0 @@ this[1] = y;

import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";

@@ -12,2 +12,3 @@ import Vector from './base/vector';

var ORIGIN = [0, 0, 0];
var constants = {};

@@ -17,2 +18,9 @@ var Vector3 = function (_Vector) {

_createClass(Vector3, null, [{
key: "ZERO",
get: function get() {
return constants.ZERO = constants.ZERO || Object.freeze(new Vector3(0, 0, 0, 0));
}
}]);
function Vector3() {

@@ -168,3 +176,3 @@ var _this;

set: function set(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -171,0 +179,0 @@ }]);

import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";

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

import { vec4_transformMat2, vec4_transformMat3 } from '../lib/gl-matrix-extras';
var constants = {};

@@ -16,2 +17,9 @@ var Vector4 = function (_Vector) {

_createClass(Vector4, null, [{
key: "ZERO",
get: function get() {
return constants.ZERO = constants.ZERO || Object.freeze(new Vector4(0, 0, 0, 0));
}
}]);
function Vector4() {

@@ -132,3 +140,3 @@ var _this;

set: function set(value) {
return this[2] = checkNumber(value);
this[2] = checkNumber(value);
}

@@ -141,3 +149,3 @@ }, {

set: function set(value) {
return this[3] = checkNumber(value);
this[3] = checkNumber(value);
}

@@ -144,0 +152,0 @@ }]);

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

import { config } from 'math.gl';
import { config } from './lib/common';
export { default as Vector2 } from './classes/vector2';

@@ -8,3 +8,3 @@ export { default as Vector3 } from './classes/vector3';

export { default as Quaternion } from './classes/quaternion';
export { config, configure, formatValue, isArray, clone, equals, exactEquals, toRadians, toDegrees, radians, degrees, sin, cos, tan, asin, acos, atan, clamp, lerp, withEpsilon as _withEpsilon } from './lib/common';
export { config, configure, formatValue, isArray, clone, equals, exactEquals, toRadians, toDegrees, radians, degrees, sin, cos, tan, asin, acos, atan, clamp, lerp, withEpsilon } from './lib/common';
export { checkNumber } from './lib/validators';

@@ -11,0 +11,0 @@ export { default as _MathUtils } from './lib/math-utils';

@@ -39,3 +39,3 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";

export function isArray(value) {
return Array.isArray(value) || ArrayBuffer.isView(value) && value.length !== undefined;
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
}

@@ -42,0 +42,0 @@

@@ -22,5 +22,7 @@ import { config } from './common';

}
export function checkVector(v, length, callerName) {
export function checkVector(v, length) {
var callerName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
if (config.debug && !validateVector(v, length)) {
throw new Error("math.gl: ".concat(callerName | '', " some fields set to invalid numbers'"));
throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
}

@@ -27,0 +29,0 @@

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

},
"version": "3.1.3",
"version": "3.2.0-alpha.1",
"keywords": [

@@ -30,2 +30,3 @@ "webgl",

},
"types": "src/index.d.ts",
"main": "dist/es5/index.js",

@@ -45,3 +46,3 @@ "module": "dist/esm/index.js",

},
"gitHead": "51993e1f66ea6ccff5977f2d1466e636917061c9"
"gitHead": "f342933ca13fa606bd60ac82bb24bb2959b13b32"
}

@@ -22,5 +22,19 @@ // Copyright (c) 2017 Uber Technologies, Inc.

import {config, formatValue, equals, isArray} from '../../lib/common';
import assert from '../../lib/assert';
export default class MathArray extends Array {
// Defined by derived class
get ELEMENTS() {
assert(false);
return 0;
}
// Defined by derived class
get RANK() {
assert(false);
return 0;
}
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);

@@ -30,2 +44,3 @@ }

from(arrayOrObject) {
// @ts-ignore error TS2339: Property 'copy' does not exist on type 'MathArray'.
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);

@@ -45,2 +60,3 @@ }

}
// @ts-ignore error TS2339: Property 'toObject' does not exist on type 'MathArray'.
return isArray(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject);

@@ -163,2 +179,3 @@ }

if (Array.isArray(scale)) {
// @ts-ignore error TS2339: Property 'multiply' does not exist on type 'MathArray'.
return this.multiply(scale);

@@ -230,3 +247,3 @@ }

check() {
if (config.debug && !this.validate(this)) {
if (config.debug && !this.validate()) {
throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);

@@ -233,0 +250,0 @@ }

@@ -6,2 +6,8 @@ import MathArray from './math-array';

export default class Vector extends MathArray {
// VIRTUAL METHODS
copy(vector) {
assert(false);
return this;
}
// ACCESSORS

@@ -13,3 +19,3 @@

set x(value) {
return (this[0] = checkNumber(value));
this[0] = checkNumber(value);
}

@@ -21,3 +27,3 @@

set y(value) {
return (this[1] = checkNumber(value));
this[1] = checkNumber(value);
}

@@ -149,4 +155,5 @@

addScaledVector(a, b) {
// @ts-ignore 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));
}
}

@@ -99,4 +99,8 @@ // Copyright (c) 2017 Uber Technologies, Inc.

/*
* Number|Number[], Number, Number, Number
/**
* @class
* @param {Number | Number[]} x
* @param {Number=} [y]
* @param {Number=} [z]
* @param {Number=} [order]
*/

@@ -106,5 +110,8 @@ constructor(x = 0, y = 0, z = 0, order = Euler.DefaultOrder) {

super(-0, -0, -0, -0);
// eslint-disable-next-line prefer-rest-params
if (arguments.length > 0 && Array.isArray(arguments[0])) {
// eslint-disable-next-line prefer-rest-params
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);

@@ -193,2 +200,3 @@ }

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

@@ -199,5 +207,6 @@ return this[0];

set x(value) {
return (this[0] = checkNumber(value));
this[0] = checkNumber(value);
}
/** @type {number} */
get y() {

@@ -208,5 +217,6 @@ return this[1];

set y(value) {
return (this[1] = checkNumber(value));
this[1] = checkNumber(value);
}
/** @type {number} */
get z() {

@@ -217,3 +227,3 @@ return this[2];

set z(value) {
return (this[2] = checkNumber(value));
this[2] = checkNumber(value);
}

@@ -227,3 +237,3 @@

set alpha(value) {
return (this[0] = checkNumber(value));
this[0] = checkNumber(value);
}

@@ -236,3 +246,3 @@

set beta(value) {
return (this[1] = checkNumber(value));
this[1] = checkNumber(value);
}

@@ -245,3 +255,3 @@

set gamma(value) {
return (this[2] = checkNumber(value));
this[2] = checkNumber(value);
}

@@ -255,3 +265,3 @@

set phi(value) {
return (this[0] = checkNumber(value));
this[0] = checkNumber(value);
}

@@ -264,3 +274,3 @@

set theta(value) {
return (this[1] = checkNumber(value));
this[1] = checkNumber(value);
}

@@ -273,6 +283,7 @@

set psi(value) {
return (this[2] = checkNumber(value));
this[2] = checkNumber(value);
}
// roll, pitch, yaw angle notation
/** @type {number} */
get roll() {

@@ -283,5 +294,6 @@ return this[0];

set roll(value) {
return (this[0] = checkNumber(value));
this[0] = checkNumber(value);
}
/** @type {number} */
get pitch() {

@@ -292,5 +304,6 @@ return this[1];

set pitch(value) {
return (this[1] = checkNumber(value));
this[1] = checkNumber(value);
}
/** @type {number} */
get yaw() {

@@ -301,3 +314,3 @@ return this[2];

set yaw(value) {
return (this[2] = checkNumber(value));
this[2] = checkNumber(value);
}

@@ -311,3 +324,3 @@

set order(value) {
return (this[3] = checkOrder(value));
this[3] = checkOrder(value);
}

@@ -314,0 +327,0 @@

@@ -25,4 +25,7 @@ // Copyright (c) 2017 Uber Technologies, Inc.

// @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';

@@ -222,4 +225,2 @@

}
// Deprecations in v3.0
}

@@ -26,5 +26,9 @@ // Copyright (c) 2017 Uber Technologies, Inc.

// @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';

@@ -298,3 +302,3 @@

perspective({
fovy,
fovy = undefined,
fov = (45 * Math.PI) / 180, // DEPRECATED

@@ -301,0 +305,0 @@ aspect = 1,

@@ -25,11 +25,13 @@ // Copyright (c) 2017 Uber Technologies, Inc.

export default class Pose {
/**
* A pose contains both rotation and rotations.
* Note that every single pose defines its own coordinate system
* (with the position of the pose in the origin, and zero rotations).
* These "pose relative" coordinate will be centered on the defining
* pose's position and with with the defining pose's orientation
* aligned with axis.
*/
constructor({x = 0, y = 0, z = 0, roll = 0, pitch = 0, yaw = 0, position, orientation} = {}) {
// @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
} = {}) {
if (Array.isArray(position) && position.length === 3) {

@@ -47,3 +49,2 @@ this.position = new Vector3(position);

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

@@ -53,3 +54,3 @@ return this.position.x;

set x(value) {
return (this.position.x = value);
this.position.x = value;
}

@@ -60,3 +61,3 @@ get y() {

set y(value) {
return (this.position.y = value);
this.position.y = value;
}

@@ -67,3 +68,3 @@ get z() {

set z(value) {
return (this.position.z = value);
this.position.z = value;
}

@@ -74,3 +75,3 @@ get roll() {

set roll(value) {
return (this.orientation.roll = value);
this.orientation.roll = value;
}

@@ -81,3 +82,3 @@ get pitch() {

set pitch(value) {
return (this.orientation.pitch = value);
this.orientation.pitch = value;
}

@@ -88,5 +89,4 @@ get yaw() {

set yaw(value) {
return (this.orientation.yaw = value);
this.orientation.yaw = value;
}
/* eslint-enable no-multi-spaces, brace-style, no-return-assign */

@@ -117,9 +117,2 @@ getPosition() {

/*
* Returns a 4x4 matrix that transforms a coordinates (in the same
* coordinate system as this pose) into the "pose-relative" coordinate
* system defined by this pose.
* The pose relative coordinates with have origin in the position of this
* pose, and axis will be aligned with the rotation of this pose.
*/
getTransformationMatrix() {

@@ -160,7 +153,2 @@ // setup precomputations for the sin/cos of the angles

/*
* Given a second pose that represent the same object in a second coordinate
* system, this method returns a 4x4 matrix that transforms coordinates in the
* second coordinate system into the coordinate system of this pose.
*/
getTransformationMatrixFromPose(pose) {

@@ -172,10 +160,2 @@ return new Matrix4()

/*
* Given a second pose that represent the same object in a second coordinate
* system, this method returns a 4x4 matrix that transforms coordinates in the
* coordinate system of this pose into the coordinate system of the second pose.
*
* Note: This method returns the inverse of that returned by
* this.getTransformationMatrixFromPose(pose)
*/
getTransformationMatrixToPose(pose) {

@@ -182,0 +162,0 @@ return new Matrix4()

@@ -25,3 +25,5 @@ // Copyright (c) 2017 Uber Technologies, Inc.

// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as quat from 'gl-matrix/quat';
// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec4 from 'gl-matrix/vec4';

@@ -32,7 +34,6 @@

export default class Quaternion extends MathArray {
// Creates a new identity quaternion
// w^2 + x^2 + y^2 + z^2 = 1
constructor(x = 0, y = 0, z = 0, w = 1) {
// PERF NOTE: initialize elements as double precision numbers
super(-0, -0, -0, -0);
// eslint-disable-next-line prefer-rest-params
if (Array.isArray(x) && arguments.length === 1) {

@@ -102,3 +103,3 @@ this.copy(x);

set x(value) {
return (this[0] = checkNumber(value));
this[0] = checkNumber(value);
}

@@ -111,3 +112,3 @@

set y(value) {
return (this[1] = checkNumber(value));
this[1] = checkNumber(value);
}

@@ -120,3 +121,3 @@

set z(value) {
return (this[2] = checkNumber(value));
this[2] = checkNumber(value);
}

@@ -129,3 +130,3 @@

set w(value) {
return (this[3] = checkNumber(value));
this[3] = checkNumber(value);
}

@@ -141,3 +142,3 @@

// Calculates the squared length of a quat
lengthSquared(a) {
lengthSquared() {
return quat.squaredLength(this);

@@ -280,7 +281,10 @@ }

slerp(start, target, ratio) {
// eslint-disable-next-line prefer-rest-params
switch (arguments.length) {
case 1: // Deprecated signature ({start, target, ratio})
// eslint-disable-next-line prefer-rest-params
({start = IDENTITY_QUATERNION, target, ratio} = arguments[0]);
break;
case 2: // THREE.js compatibility signature (target, ration)
// eslint-disable-next-line prefer-rest-params
[target, ratio] = arguments;

@@ -316,12 +320,2 @@ start = this; // eslint-disable-line

}
// DEPRECATED
// fromValues(x, y, z, w) {
// return this.set(x, y, z, w);
// }
// squaredLength() {
// return this.lengthSquared();
// }
}

@@ -26,2 +26,3 @@ // Copyright (c) 2017 Uber Technologies, Inc.

// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec3 from 'gl-matrix/vec3';

@@ -36,37 +37,27 @@

export default class SphericalCoordinates {
/**
* Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system
* The poles (phi) are at the positive and negative y axis.
* The equator starts at positive z.
* @class
* @param {Number} phi=0 - rotation around X (latitude)
* @param {Number} theta=0 - rotation around Y (longitude)
* @param {Number} radius=1 - Distance from center
*/
/* eslint-disable complexity */
// @ts-ignore TS2740: Type '{}' is missing the following properties from type
// eslint-disable-next-line complexity
constructor({
phi,
theta,
radius,
bearing,
pitch,
altitude,
phi = 0,
theta = 0,
radius = 1,
bearing = undefined,
pitch = undefined,
altitude = undefined,
radiusScale = EARTH_RADIUS_METERS
} = {}) {
if (arguments.length === 0) {
this.phi = 0;
this.theta = 0;
this.radius = 1;
} else if (Number.isFinite(phi) || Number.isFinite(theta)) {
this.phi = phi || 0; // up / down towards top and bottom pole
this.theta = theta || 0; // around the equator of the sphere
} else if (Number.isFinite(bearing) || Number.isFinite(pitch)) {
this.bearing = bearing || 0; // up / down towards top and bottom pole
this.pitch = pitch || 0; // around the equator of the sphere
this.phi = phi;
this.theta = theta;
// TODO - silently accepts illegal 0
this.radius = radius || altitude || 1; // radial distance from center
this.radiusScale = radiusScale || 1; // Used by lngLatZ
if (bearing !== undefined) {
this.bearing = bearing; // up / down towards top and bottom pole
}
this.radius = radius || 1; // radial distance from center
this.radiusScale = radiusScale || 1; // Used by lngLatZ
if (pitch !== undefined) {
this.pitch = pitch; // around the equator of the sphere
}
this.check();
}
/* eslint-enable complexity */

@@ -77,3 +68,3 @@ toString() {

formatString({printTypes, printDegrees}) {
formatString({printTypes = false}) {
const f = formatValue;

@@ -140,3 +131,3 @@ return `${printTypes ? 'Spherical' : ''}\

clone() {
return new this.constructor().copy(this);
return new SphericalCoordinates().copy(this);
}

@@ -175,2 +166,3 @@

this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
return this;
}

@@ -177,0 +169,0 @@

@@ -25,2 +25,3 @@ // Copyright (c) 2017 Uber Technologies, Inc.

// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec2 from 'gl-matrix/vec2';

@@ -46,3 +47,3 @@ import {vec2_transformMat4AsVector} from '../lib/gl-matrix-extras';

set(x, y, z) {
set(x, y) {
this[0] = x;

@@ -49,0 +50,0 @@ this[1] = y;

@@ -25,2 +25,3 @@ // Copyright (c) 2017 Uber Technologies, Inc.

// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec3 from 'gl-matrix/vec3';

@@ -30,4 +31,15 @@ import {vec3_transformMat2, vec3_transformMat4AsVector} from '../lib/gl-matrix-extras';

const ORIGIN = [0, 0, 0];
const constants = {};
export default class Vector3 extends Vector {
static get ZERO() {
return (constants.ZERO = constants.ZERO || Object.freeze(new Vector3(0, 0, 0, 0)));
}
/**
* @class
* @param {Number | [Number, Number, Number]} x
* @param {Number} y - rotation around X (latitude)
* @param {Number} z - rotation around X (latitude)
*/
constructor(x = 0, y = 0, z = 0) {

@@ -45,2 +57,3 @@ // PERF NOTE: initialize elements as double precision numbers

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

@@ -97,3 +110,3 @@ this[1] = y;

set z(value) {
return (this[2] = checkNumber(value));
this[2] = checkNumber(value);
}

@@ -100,0 +113,0 @@ /* eslint-enable no-multi-spaces, brace-style, no-return-assign */

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

// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
import * as vec4 from 'gl-matrix/vec3';
import {vec4_transformMat2, vec4_transformMat3} from '../lib/gl-matrix-extras';
const constants = {};
export default class Vector4 extends Vector {
static get ZERO() {
return (constants.ZERO = constants.ZERO || Object.freeze(new Vector4(0, 0, 0, 0)));
}
constructor(x = 0, y = 0, z = 0, w = 0) {

@@ -101,3 +108,3 @@ // PERF NOTE: initialize elements as double precision numbers

set z(value) {
return (this[2] = checkNumber(value));
this[2] = checkNumber(value);
}

@@ -110,3 +117,3 @@

set w(value) {
return (this[3] = checkNumber(value));
this[3] = checkNumber(value);
}

@@ -113,0 +120,0 @@ /* eslint-enable no-multi-spaces, brace-style, no-return-assign */

@@ -21,3 +21,3 @@ // Copyright (c) 2017 Uber Technologies, Inc.

import {config} from 'math.gl';
import {config} from './lib/common';

@@ -54,4 +54,3 @@ // math.gl classes

lerp,
// experimental
withEpsilon as _withEpsilon
withEpsilon
} from './lib/common';

@@ -82,4 +81,6 @@

// TODO - integrate with probe.gl (as soft dependency) to persist across reloades
// @ts-ignore error TS2339: Property 'mathgl' does not exist on type 'Window | Global
global_.mathgl = {
config
};

@@ -60,3 +60,3 @@ // Copyright (c) 2017 Uber Technologies, Inc.

export function isArray(value) {
return Array.isArray(value) || (ArrayBuffer.isView(value) && value.length !== undefined);
return Array.isArray(value) || (ArrayBuffer.isView(value) && !(value instanceof DataView));
}

@@ -63,0 +63,0 @@

@@ -43,5 +43,5 @@ // Copyright (c) 2017 Uber Technologies, Inc.

export function checkVector(v, length, callerName) {
export function checkVector(v, length, callerName = '') {
if (config.debug && !validateVector(v, length)) {
throw new Error(`math.gl: ${callerName | ''} some fields set to invalid numbers'`);
throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
}

@@ -48,0 +48,0 @@ return v;

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