Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
@loaders.gl/math
Advanced tools
Package description
@loaders.gl/math is a library that provides a collection of mathematical utilities and data structures for handling 3D graphics and geospatial data. It includes functions for vector and matrix operations, geometric transformations, and other mathematical computations commonly used in computer graphics and geospatial applications.
Vector Operations
This feature allows you to perform vector operations such as addition, subtraction, and normalization. The code sample demonstrates how to create two vectors and add them together.
const { Vector3 } = require('@loaders.gl/math');
const v1 = new Vector3(1, 2, 3);
const v2 = new Vector3(4, 5, 6);
const v3 = v1.add(v2);
console.log(v3); // Vector3 { x: 5, y: 7, z: 9 }
Matrix Operations
This feature provides matrix operations such as multiplication, inversion, and transformation. The code sample shows how to create an identity matrix, apply a translation, and multiply two matrices.
const { Matrix4 } = require('@loaders.gl/math');
const m1 = new Matrix4().identity();
const m2 = new Matrix4().translate([1, 2, 3]);
const m3 = m1.multiplyRight(m2);
console.log(m3); // Matrix4 { elements: [1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1] }
Geometric Transformations
This feature allows you to apply geometric transformations such as rotation, scaling, and translation to points and vectors. The code sample demonstrates how to rotate a point around the X-axis.
const { Vector3, Matrix4 } = require('@loaders.gl/math');
const point = new Vector3(1, 1, 1);
const transform = new Matrix4().rotateX(Math.PI / 4);
const transformedPoint = point.transform(transform);
console.log(transformedPoint); // Vector3 { x: 1, y: 0, z: 1.4142135623730951 }
gl-matrix is a high-performance library for matrix and vector operations, designed for WebGL applications. It provides similar functionalities to @loaders.gl/math, including vector and matrix operations, but is more focused on performance and lower-level operations.
Three.js is a popular 3D library that includes a wide range of features for 3D graphics, including vector and matrix operations, geometric transformations, and rendering. While it offers similar mathematical utilities, it is more comprehensive and includes rendering capabilities.
mathjs is a comprehensive math library for JavaScript that includes a wide range of mathematical functions, including vector and matrix operations. It is more general-purpose compared to @loaders.gl/math, which is specifically tailored for 3D graphics and geospatial data.
Changelog
v4.2.0-alpha.1
Readme
loaders.gl is a collection of framework-independent 3D and geospatial parsers and encoders.
This module contains math utilities for the @loaders.gl3d-tiles
module. As they mature, these will likely be moved to a math framework (e.g. math.gl).
This code is a fork of a subset of the Cesium math library whcih is Apache 2 licensed.
For documentation please visit the website.
FAQs
Experimental math classes for loaders.gl
The npm package @loaders.gl/math receives a total of 154,219 weekly downloads. As such, @loaders.gl/math popularity was classified as popular.
We found that @loaders.gl/math demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.