Introduction
Aspose.3D FOSS for TypeScript (@aspose/3d) is an open-source, MIT-licensed 3D file format library for Node.js and modern browser environments. Developers building 3D model viewers, format converters, geometry processing tools, or server-side 3D pipelines can install it with a single npm install @aspose/3d command and immediately start loading, constructing, and exporting 3D content.
The library supports the major interchange formats (OBJ, glTF 2.0 / GLB, FBX, STL, 3MF, and COLLADA), all as both import and export targets. 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, FBX, STL (binary and ASCII), 3MF, and COLLADA from both file paths and in-memoryBufferobjects - 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.entity.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
Install from npm. Node.js 16 or later is required; TypeScript 5.0+ is recommended.
npm install @aspose/3d
Load 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`);
}
}
Export to glTF
Save any loaded or constructed scene to glTF 2.0 binary (GLB):
import { Scene } from '@aspose/3d';
import { ObjLoadOptions } from '@aspose/3d/formats/obj';
const scene = new Scene();
scene.open('input.obj', new ObjLoadOptions());
scene.save('output.glb');
console.log('Exported to output.glb');
The library auto-detects the output format from the file extension. Pass a GltfSaveOptions instance for control over PBR material embedding, textures, and binary vs. JSON encoding.
Scene Construction
Build a scene programmatically and export it:
import { Scene, Node } from '@aspose/3d';
import { Mesh } from '@aspose/3d/entities';
const scene = new Scene();
const mesh = new Mesh();
// ... populate mesh.controlPoints and polygons ...
const node = new Node('myMesh');
node.entity = mesh;
scene.rootNode.addChildNode(node);
scene.save('programmatic.glb');