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

@loaders.gl/math

Package Overview
Dependencies
Maintainers
9
Versions
315
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/math - npm Package Compare versions

Comparing version 1.3.0-beta.1 to 1.3.0-beta.2

17

dist/es6/geometry/attributes/compute-bounding-box.js

@@ -1,10 +0,9 @@

export function computeBoundingBox(positions) {
var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Box3();
var min = [+Infinity, +Infinity, +Infinity];
var max = [-Infinity, -Infinity, -Infinity];
export function computeBoundingBox(positions, target = new Box3()) {
const min = [+Infinity, +Infinity, +Infinity];
const max = [-Infinity, -Infinity, -Infinity];
for (var position of attributeIterator(positions)) {
var x = position[0];
var y = position[1];
var z = position[2];
for (const position of attributeIterator(positions)) {
const x = position[0];
const y = position[1];
const z = position[2];
if (x < min[0]) min[0] = x;

@@ -18,3 +17,3 @@ if (y < min[1]) min[1] = y;

var boundingBox = {
const boundingBox = {
min,

@@ -21,0 +20,0 @@ max

import { Vector3 } from 'math.gl';
import { getPositions } from './get-attribute-from-geometry';
export function computeBoundingSphere(geometry, boundingBox) {
var positions = getPositions(geometry);
var center = getBoundingBox(center);
const positions = getPositions(geometry);
const center = getBoundingBox(center);
box.setFromBufferAttribute(position);

@@ -10,10 +10,10 @@ box.getCenter(center);

for (var _position of attributeIterator(positions)) {
vector.x = _position[0];
vector.y = _position[1];
vector.z = _position[2];
for (const position of attributeIterator(positions)) {
vector.x = position[0];
vector.y = position[1];
vector.z = position[2];
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(vector));
}
var radius = Math.sqrt(maxRadiusSq);
const radius = Math.sqrt(maxRadiusSq);
assert(Number.isFinite(radius));

@@ -20,0 +20,0 @@ return {

@@ -7,10 +7,9 @@ import { Vector3 } from 'math.gl';

import { getPositions } from './get-attribute-from-geometry';
export default function computeVertexNormals(_ref) {
var {
mode,
indices,
attributes
} = _ref;
export default function computeVertexNormals({
mode,
indices,
attributes
}) {
assert(getPrimitiveModeType(mode) === GL.TRIANGLES, 'TRIANGLES required');
var {
const {
values: positions

@@ -22,10 +21,10 @@ } = getPositions({

});
var normals = new Float32Array(positions.length);
var vectorA = new Vector3();
var vectorB = new Vector3();
var vectorC = new Vector3();
var vectorCB = new Vector3();
var vectorAB = new Vector3();
const normals = new Float32Array(positions.length);
const vectorA = new Vector3();
const vectorB = new Vector3();
const vectorC = new Vector3();
const vectorCB = new Vector3();
const vectorAB = new Vector3();
for (var primitive of primitiveIterator({
for (const primitive of primitiveIterator({
mode,

@@ -40,5 +39,5 @@ indices,

vectorAB.subVectors(vectorA, vectorB);
var normal = vectorCB.cross(vectorAB);
const normal = vectorCB.cross(vectorAB);
normal.normalize();
var {
const {
primitiveIndex

@@ -45,0 +44,0 @@ } = primitive;

@@ -1,14 +0,13 @@

export function convertBuffersToNonIndexed(_ref) {
var {
indices,
attributes
} = _ref;
var geometry2 = new BufferGeometry();
export function convertBuffersToNonIndexed({
indices,
attributes
}) {
const geometry2 = new BufferGeometry();
for (var name in attributes) {
var attribute = attributes[name];
var array = attribute.array;
var itemSize = attribute.itemSize;
var array2 = new array.constructor(indices.length * itemSize);
var index = 0,
for (const name in attributes) {
const attribute = attributes[name];
const array = attribute.array;
const itemSize = attribute.itemSize;
const array2 = new array.constructor(indices.length * itemSize);
let index = 0,
index2 = 0;

@@ -15,0 +14,0 @@

@@ -5,6 +5,6 @@ import isGeometry from '../is-geometry';

if (isGeometry(geometry)) {
var {
const {
attributes
} = geometry;
var position = attributes.POSITION || attributes.positions;
const position = attributes.POSITION || attributes.positions;
assert(position);

@@ -11,0 +11,0 @@ return position;

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

export function decodeRGB565(rgb565) {
var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
var r5 = rgb565 >> 11 & 31;
var g6 = rgb565 >> 5 & 63;
var b5 = rgb565 & 31;
export function decodeRGB565(rgb565, target = [0, 0, 0]) {
const r5 = rgb565 >> 11 & 31;
const g6 = rgb565 >> 5 & 63;
const b5 = rgb565 & 31;
target[0] = r5 << 3;

@@ -12,7 +11,7 @@ target[1] = g6 << 2;

export function encodeRGB565(rgb) {
var r5 = Math.floor(rgb[0] / 8) + 4;
var g6 = Math.floor(rgb[1] / 4) + 2;
var b5 = Math.floor(rgb[2] / 8) + 4;
const r5 = Math.floor(rgb[0] / 8) + 4;
const g6 = Math.floor(rgb[1] / 4) + 2;
const b5 = Math.floor(rgb[2] / 8) + 4;
return r5 + (g6 << 5) + (b5 << 11);
}
//# sourceMappingURL=rgb565.js.map
import { Vector2, Vector3, clamp, _MathUtils } from 'math.gl';
import assert from '../utils/assert';
var RIGHT_SHIFT = 1.0 / 256.0;
var LEFT_SHIFT = 256.0;
var scratchVector2 = new Vector2();
var scratchVector3 = new Vector3();
var scratchEncodeVector2 = new Vector2();
var octEncodeScratch = new Vector2();
var uint8ForceArray = new Uint8Array(1);
const RIGHT_SHIFT = 1.0 / 256.0;
const LEFT_SHIFT = 256.0;
const scratchVector2 = new Vector2();
const scratchVector3 = new Vector3();
const scratchEncodeVector2 = new Vector2();
const octEncodeScratch = new Vector2();
const uint8ForceArray = new Uint8Array(1);

@@ -16,9 +16,7 @@ function forceUint8(value) {

function fromSNorm(value) {
var rangeMaximum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 255;
function fromSNorm(value, rangeMaximum = 255) {
return clamp(value, 0.0, rangeMaximum) / rangeMaximum * 2.0 - 1.0;
}
function toSNorm(value) {
var rangeMaximum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 255;
function toSNorm(value, rangeMaximum = 255) {
return Math.round((clamp(value, -1.0, 1.0) * 0.5 + 0.5) * rangeMaximum);

@@ -34,3 +32,3 @@ }

assert(result);
var vector3 = scratchVector3.from(vector);
const vector3 = scratchVector3.from(vector);
assert(Math.abs(vector3.magnitudeSquared() - 1.0) <= _MathUtils.EPSILON6);

@@ -41,4 +39,4 @@ result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));

if (vector.z < 0) {
var x = result.x;
var y = result.y;
const x = result.x;
const y = result.y;
result.x = (1.0 - Math.abs(y)) * signNotZero(x);

@@ -75,3 +73,3 @@ result.y = (1.0 - Math.abs(x)) * signNotZero(y);

if (result.z < 0.0) {
var oldVX = result.x;
const oldVX = result.x;
result.x = (1.0 - Math.abs(result.y)) * signNotZero(oldVX);

@@ -89,6 +87,6 @@ result.y = (1.0 - Math.abs(oldVX)) * signNotZero(result.y);

assert(result);
var x = encoded.x;
var y = encoded.y;
var z = encoded.z;
var w = encoded.w;
const x = encoded.x;
const y = encoded.y;
const z = encoded.z;
const w = encoded.w;

@@ -99,8 +97,8 @@ if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {

var xOct16 = x * LEFT_SHIFT + y;
var yOct16 = z * LEFT_SHIFT + w;
const xOct16 = x * LEFT_SHIFT + y;
const yOct16 = z * LEFT_SHIFT + w;
return octDecodeInRange(xOct16, yOct16, 65535, result);
}
export function octPackFloat(encoded) {
var vector2 = scratchVector2.from(encoded);
const vector2 = scratchVector2.from(encoded);
return 256.0 * vector2.x + vector2.y;

@@ -114,5 +112,5 @@ }

assert(Number.isFinite(value));
var temp = value / 256.0;
var x = Math.floor(temp);
var y = (temp - x) * 256.0;
const temp = value / 256.0;
const x = Math.floor(temp);
const y = (temp - x) * 256.0;
return octDecode(x, y, result);

@@ -125,5 +123,5 @@ }

assert(result);
var encoded1 = octEncodeFloat(v1);
var encoded2 = octEncodeFloat(v2);
var encoded3 = octEncode(v3, scratchEncodeVector2);
const encoded1 = octEncodeFloat(v1);
const encoded2 = octEncodeFloat(v2);
const encoded3 = octEncode(v3, scratchEncodeVector2);
result.x = 65536.0 * encoded3.x + encoded1;

@@ -134,8 +132,8 @@ result.y = 65536.0 * encoded3.y + encoded2;

export function octUnpack(packed, v1, v2, v3) {
var temp = packed.x / 65536.0;
var x = Math.floor(temp);
var encodedFloat1 = (temp - x) * 65536.0;
let temp = packed.x / 65536.0;
const x = Math.floor(temp);
const encodedFloat1 = (temp - x) * 65536.0;
temp = packed.y / 65536.0;
var y = Math.floor(temp);
var encodedFloat2 = (temp - y) * 65536.0;
const y = Math.floor(temp);
const encodedFloat2 = (temp - y) * 65536.0;
octDecodeFloat(encodedFloat1, v1);

@@ -146,9 +144,9 @@ octDecodeFloat(encodedFloat2, v2);

export function compressTextureCoordinates(textureCoordinates) {
var x = textureCoordinates.x * 4095.0 | 0;
var y = textureCoordinates.y * 4095.0 | 0;
const x = textureCoordinates.x * 4095.0 | 0;
const y = textureCoordinates.y * 4095.0 | 0;
return 4096.0 * x + y;
}
export function decompressTextureCoordinates(compressed, result) {
var temp = compressed / 4096.0;
var xZeroTo4095 = Math.floor(temp);
const temp = compressed / 4096.0;
const xZeroTo4095 = Math.floor(temp);
result.x = xZeroTo4095 / 4095.0;

@@ -171,7 +169,7 @@ result.y = (compressed - xZeroTo4095 * 4096) / 4095;

var u = 0;
var v = 0;
var height = 0;
let u = 0;
let v = 0;
let height = 0;
for (var i = 0; i < uBuffer.length; ++i) {
for (let i = 0; i < uBuffer.length; ++i) {
u += zigZagDecode(uBuffer[i]);

@@ -178,0 +176,0 @@ v += zigZagDecode(vBuffer[i]);

@@ -7,3 +7,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

export var GL_PRIMITIVE = {
export const GL_PRIMITIVE = {
POINTS: 0x0000,

@@ -13,3 +13,3 @@ LINES: 0x0001,

};
export var GL_PRIMITIVE_MODE = {
export const GL_PRIMITIVE_MODE = {
POINTS: 0x0000,

@@ -23,3 +23,3 @@ LINES: 0x0001,

};
export var GL_TYPE = {
export const GL_TYPE = {
BYTE: 5120,

@@ -34,3 +34,3 @@ UNSIGNED_BYTE: 5121,

};
export var GL = _objectSpread({}, GL_PRIMITIVE_MODE, {}, GL_TYPE);
export const GL = _objectSpread({}, GL_PRIMITIVE_MODE, {}, GL_TYPE);
//# sourceMappingURL=constants.js.map
import { GL_TYPE as GL } from '../constants';
var GL_TYPE_TO_ARRAY_TYPE = {
const GL_TYPE_TO_ARRAY_TYPE = {
[GL.DOUBLE]: Float64Array,

@@ -12,3 +12,3 @@ [GL.FLOAT]: Float32Array,

};
var NAME_TO_GL_TYPE = {
const NAME_TO_GL_TYPE = {
DOUBLE: GL.DOUBLE,

@@ -23,3 +23,3 @@ FLOAT: GL.FLOAT,

};
var ERR_TYPE_CONVERSION = 'Failed to convert GL type';
const ERR_TYPE_CONVERSION = 'Failed to convert GL type';
export default class GLType {

@@ -29,4 +29,4 @@ static fromTypedArray(arrayOrType) {

for (var glType in GL_TYPE_TO_ARRAY_TYPE) {
var ArrayType = GL_TYPE_TO_ARRAY_TYPE[glType];
for (const glType in GL_TYPE_TO_ARRAY_TYPE) {
const ArrayType = GL_TYPE_TO_ARRAY_TYPE[glType];

@@ -42,3 +42,3 @@ if (ArrayType === arrayOrType) {

static fromName(name) {
var glType = NAME_TO_GL_TYPE[name];
const glType = NAME_TO_GL_TYPE[name];

@@ -52,5 +52,3 @@ if (!glType) {

static getArrayType(glType) {
var clamped = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
static getArrayType(glType, clamped = false) {
switch (glType) {

@@ -63,3 +61,3 @@ case GL.UNSIGNED_SHORT_5_6_5:

default:
var ArrayType = GL_TYPE_TO_ARRAY_TYPE[glType];
const ArrayType = GL_TYPE_TO_ARRAY_TYPE[glType];

@@ -75,3 +73,3 @@ if (!ArrayType) {

static getByteSize(glType) {
var ArrayType = GLType.getArrayType(glType);
const ArrayType = GLType.getArrayType(glType);
return ArrayType.BYTES_PER_ELEMENT;

@@ -84,6 +82,3 @@ }

static createTypedArray(glType, buffer) {
var byteOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var length = arguments.length > 3 ? arguments[3] : undefined;
static createTypedArray(glType, buffer, byteOffset = 0, length) {
if (length === undefined) {

@@ -93,3 +88,3 @@ length = (buffer.byteLength - byteOffset) / GLType.getByteSize(glType);

var ArrayType = GLType.getArrayType(glType);
const ArrayType = GLType.getArrayType(glType);
return new ArrayType(buffer, byteOffset, length);

@@ -96,0 +91,0 @@ }

@@ -1,11 +0,10 @@

export default function* attributeIterator(_ref) {
var {
values,
size
} = _ref;
var ArrayType = values.constructor;
var element = new ArrayType(size);
export default function* attributeIterator({
values,
size
}) {
const ArrayType = values.constructor;
const element = new ArrayType(size);
for (var i = 0; i < values.length; i += size) {
for (var j = 0; j < size; j++) {
for (let i = 0; i < values.length; i += size) {
for (let j = 0; j < size; j++) {
element[j] = element[i + j];

@@ -12,0 +11,0 @@ }

import { GL } from '../constants';
import { getPrimitiveModeType } from '../primitives/modes';
import assert from '../../utils/assert';
export default function* primitiveIterator(_ref) {
var {
indices,
attributes,
mode,
start = 0,
end
} = _ref;
export default function* primitiveIterator({
indices,
attributes,
mode,
start = 0,
end
}) {
if (indices) {

@@ -23,7 +21,7 @@ indices = indices.values || indices.value || indices;

var info = {
const info = {
attributes,
type: getPrimitiveModeType(mode)
};
var i = start;
let i = start;

@@ -30,0 +28,0 @@ while (i < end) {

export function concatTypedArrays(arrays) {
var byteLength = 0;
let byteLength = 0;
for (var i = 0; i < arrays.length; ++i) {
for (let i = 0; i < arrays.length; ++i) {
byteLength += arrays[i].byteLength;
}
var buffer = new Uint8Array(byteLength);
var byteOffset = 0;
const buffer = new Uint8Array(byteLength);
let byteOffset = 0;
for (var _i = 0; _i < arrays.length; ++_i) {
var data = new Uint8Array(arrays[_i].buffer);
for (let i = 0; i < arrays.length; ++i) {
const data = new Uint8Array(arrays[i].buffer);
byteLength = data.length;
for (var j = 0; j < byteLength; ++j) {
for (let j = 0; j < byteLength; ++j) {
buffer[byteOffset++] = data[j];

@@ -17,0 +17,0 @@ }

{
"name": "@loaders.gl/math",
"version": "1.3.0-beta.1",
"version": "1.3.0-beta.2",
"description": "Experimental math classes for loaders.gl",

@@ -34,6 +34,6 @@ "license": "MIT",

"dependencies": {
"@loaders.gl/images": "1.3.0-beta.1",
"@loaders.gl/images": "1.3.0-beta.2",
"math.gl": "^3.0.0-beta.3"
},
"gitHead": "deabcc69303bc19eeadb1bb6cf9082ee94e74f3e"
"gitHead": "ea8078ed5fda7d06dfaae4aed02a46ca1c181bd3"
}

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