Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@math.gl/core
Advanced tools
@math.gl/core is a JavaScript library that provides a suite of mathematical utilities for 3D graphics and geospatial applications. It includes functions for vector and matrix operations, quaternion calculations, 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 vectors and add them together.
const { Vector3 } = require('@math.gl/core');
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 functions for matrix operations such as multiplication, inversion, and transformation. The code sample shows how to create identity and translation matrices and multiply them.
const { Matrix4 } = require('@math.gl/core');
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] }
Quaternion Calculations
This feature allows you to perform quaternion calculations such as creating quaternions from axis rotations and multiplying quaternions. The code sample demonstrates how to create and multiply quaternions.
const { Quaternion } = require('@math.gl/core');
const q1 = new Quaternion().fromAxisRotation([0, 1, 0], Math.PI / 2);
const q2 = new Quaternion().fromAxisRotation([1, 0, 0], Math.PI / 2);
const q3 = q1.multiply(q2);
console.log(q3); // Quaternion { x: 0.5, y: 0.5, z: 0.5, w: 0.5 }
gl-matrix is a high-performance library for matrix and vector operations in WebGL. It provides similar functionalities to @math.gl/core, including vector, matrix, and quaternion operations. However, gl-matrix is more focused on performance and is widely used in WebGL applications.
three.js is a popular 3D library that includes a comprehensive set of mathematical utilities for 3D graphics, such as vectors, matrices, and quaternions. While three.js is primarily a 3D rendering library, its math utilities are comparable to those in @math.gl/core.
mathjs is a versatile mathematics library for JavaScript that supports a wide range of mathematical operations, including matrix and vector calculations. While it is not specifically designed for 3D graphics, it provides a broad set of mathematical tools that can be used in various applications.
FAQs
Array-based 3D Math Classes optimized for WebGL applications
We found that @math.gl/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.