Introduction
Aspose.3D FOSS for TypeScript (@aspose/3d) is an open-source, MIT-licensed 3D file format library primarily designed for Node.js. Developers building 3D model viewers, format converters, geometry processing tools, or server-side 3D pipelines can install it with a single command (see the Installation guide) and immediately start loading, constructing, and exporting 3D content. The library uses require('fs') and Buffer from Node.js; browser usage requires appropriate shims for those APIs and is not officially supported.
The library supports the major interchange formats — OBJ, glTF 2.0 / GLB, STL, 3MF, and COLLADA for both import and export. FBX importer/exporter classes exist but are not yet wired into format auto-detection. The scene graph API mirrors the model familiar from 3D authoring tools: a Scene holds a rootNode, each Node can carry child nodes and entity objects (Mesh, Camera, Light), and the transform hierarchy is fully accessible for reading and writing.
Key Features
- Multi-format I/O: Import and export OBJ (with
.mtlmaterials), glTF 2.0 / GLB, STL (binary and ASCII), 3MF, and COLLADA from both file paths and in-memoryBufferobjects. FBX support is not yet wired into auto-detection. - Scene graph API:
Scene,Node,Mesh,Camera,Lighthierarchy with full parent/child management; traverse nodes recursively vianode.childNodes - PBR material system: Lambert, Phong, and PBR (metallic/roughness) materials accessible via
node.material - Mesh operations: Access raw vertex data via
mesh.controlPoints(array ofVector4), polygon indices viamesh.polygonCount, and vertex element channels viamesh.getElement() - Math utilities:
Vector2,Vector3,Vector4,Matrix4,Quaternion, and bounding box types for spatial calculations - Animation system: Keyframe animation with
AnimationClip,AnimationChannel, and interpolation curves (linear, Bezier, TCB spline) - Format-specific options: Per-format
LoadOptions/SaveOptionsclasses control coordinate flipping, scale, material loading, and more
Getting Started
Build the package from source. Node.js 18 or later is required; TypeScript 5.0+ is recommended.
git clone https://github.com/aspose-3d-foss/Aspose.3D-FOSS-for-TypeScript.git
cd Aspose.3D-FOSS-for-TypeScript
npm install
npm run buildLoad an OBJ file and inspect the scene:
import { Scene } from '@aspose/3d';
import { ObjLoadOptions } from '@aspose/3d/formats/obj';
const scene = new Scene();
const options = new ObjLoadOptions();
options.enableMaterials = true;
scene.open('model.obj', options);
for (const node of scene.rootNode.childNodes) {
if (node.entity && 'controlPoints' in node.entity) {
const mesh = node.entity as any;
console.log(`Mesh "${node.name}": ${mesh.controlPoints.length} vertices`);
}
}
Scene Graph API
Every scene is a tree of Node objects rooted at scene.rootNode. Build the hierarchy with
addChildNode(), attach entities such as Camera or Light to a node via its entity
property, and read each node’s local or world-space transform through transform and
globalTransform.
import { Scene, Node, Camera, Light } from '@aspose/3d';
const scene = new Scene();
const cameraNode = new Node('MainCamera');
cameraNode.entity = new Camera('MainCamera');
scene.rootNode.addChildNode(cameraNode);
const lightNode = new Node('KeyLight');
lightNode.entity = new Light('KeyLight');
scene.rootNode.addChildNode(lightNode);
for (const child of scene.rootNode.childNodes) {
console.log(`${child.name}: ${child.entity?.constructor.name}`);
}
Math Utilities
Vector3, Vector4, Matrix4, and Quaternion back every geometric operation in the
library. Vector3 and Vector4 expose x/y/z(/w) components plus length, dot(),
and cross(); Matrix4 is a 4×4 grid accessed through m00–m33 with transpose() and
concatenate(); Quaternion provides normalize(), conjugate(), inverse(), and dot()
for rotation math.
import { Vector3, Quaternion, Matrix4 } from '@aspose/3d/utilities';
const position = new Vector3(1.0, 2.0, 3.0);
const rotation = new Quaternion(1.0, 0.0, 0.0, 0.0);
const transform = new Matrix4();
console.log(`length=${position.length} determinant=${transform.determinant}`);
console.log(`rotation w=${rotation.w} x=${rotation.x} y=${rotation.y} z=${rotation.z}`);