API Overview — @aspose/3d for TypeScript

Package: @aspose/3d (v24.12.0) · Language: TypeScript / Node.js 18+ · License: MIT

@aspose/3d is an MIT-licensed library for reading, building, and exporting 3D scenes in Node.js. It ships with full TypeScript type definitions, a single runtime dependency (xmldom), and supports seven major 3D file formats. All I/O is synchronous. No native modules are required.

npm install @aspose/3d@24.12.0

tsconfig.json settings for correct subpath resolution:

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "strict": true
  }
}

Core Classes

Scene

The root container of a 3D scene. All content — nodes, geometry, materials, and animations — is stored in a tree rooted at scene.rootNode. Use open() / openFromBuffer() to load a file and save() / saveToBuffer() to export.

MemberTypeDescription
rootNodeNodeRoot of the scene graph
assetInfoAssetInfoFile metadata (creator, units, coordinate system)
animationClipsAnimationClip[]All animation clips in the scene
open(path, opts?)(string, LoadOptions?) → voidLoad a file from disk
openFromBuffer(buf, opts?)(Buffer, LoadOptions?) → voidLoad from in-memory buffer
save(path, opts?)(string, SaveOptions?) → voidSave to disk (format inferred from extension)
saveToBuffer(ext, opts?)(string, SaveOptions?) → BufferSave to in-memory buffer
createAnimationClip(name)(string) → AnimationClipCreate and register a new animation clip

Node

A named tree node in the scene graph. Nodes carry an optional Entity (mesh, camera, light) and a Transform that positions the node relative to its parent.

MemberTypeDescription
namestringNode name
childNodesNode[]Direct child nodes
entityEntity | nullAttached geometry, camera, or light
transformTransformLocal translation, rotation, scale
materialsMaterial[]Materials assigned to this node
createChildNode(name)(string) → NodeAdd a child node
getChildNode(name)(string) → Node | nullFind a child by name

Mesh

Polygon mesh; the primary geometry type. Extends Geometry.

MemberTypeDescription
controlPointsVector4[]Vertex positions (w=1 for positions)
polygonCountnumberNumber of polygons
createPolygon(indices)(number[]) → voidAdd a polygon (triangle or quad)
getElement(type)(VertexElementType) → VertexElement | nullGet a vertex element by semantic
createElement(type)(VertexElementType) → VertexElementCreate a vertex element

Transform

Local transformation applied to a node.

MemberTypeDescription
translationVector3Local position
eulerAnglesVector3Euler rotation in degrees (XYZ order)
rotationQuaternionQuaternion rotation
scalingVector3Local scale

Material Classes

ClassDescriptionKey Properties
LambertMaterialDiffuse + ambient shadingdiffuseColor, ambientColor, transparency
PhongMaterialAdds specular + emissive to LambertspecularColor, shininess, emissiveColor
PbrMaterialPhysics-based for glTF 2.0albedo, metallicFactor, roughnessFactor, emissiveColor

Math Classes

ClassDescription
Vector33-component double-precision vector (x, y, z)
Vector44-component vector for homogeneous math (x, y, z, w)
FVector3Single-precision variant used in vertex data
Matrix44×4 transformation matrix; multiply, invert, decompose
QuaternionRotation quaternion; fromEulerAngle, toEulerAngles, slerp
BoundingBoxAxis-aligned bounding box; minimum, maximum, center, size, merge

Animation Classes

ClassDescription
AnimationClipNamed clip; contains AnimationNode list; accessed via scene.animationClips
AnimationNodeBinds a clip to a named scene node; contains AnimationChannel list
AnimationChannelTargets a single property (e.g. translation X); holds a KeyframeSequence
KeyframeSequenceOrdered list of KeyFrame objects with interpolation and extrapolation
KeyFrameSingle time/value pair

Enumerations

EnumValuesDescription
VertexElementTypeNORMAL, UV, VERTEX_COLOR, BINORMAL, TANGENTVertex element semantic
MappingModeCONTROL_POINT, POLYGON_VERTEX, POLYGON, ALL_SAMEHow data maps to geometry
ReferenceModeDIRECT, INDEX, INDEX_TO_DIRECTVertex element data indexing strategy
InterpolationCONSTANT, LINEAR, BEZIERKeyframe interpolation
ExtrapolationCONSTANT, GRADIENT, CYCLE, CYCLE_RELATIVE, OSCILLATEBehavior outside keyframe range

Format Modules

Format-specific option classes are exported from subpath modules. Import them separately:

import { ObjLoadOptions } from '@aspose/3d/formats/obj';
import { GltfSaveOptions, GltfFormat } from '@aspose/3d/formats/gltf';
import { StlLoadOptions, StlSaveOptions } from '@aspose/3d/formats/stl';
import { FbxLoadOptions, FbxSaveOptions } from '@aspose/3d/formats/fbx';
import { ColladaLoadOptions } from '@aspose/3d/formats/collada';
import { ThreeMfSaveOptions } from '@aspose/3d/formats/3mf';

OBJ Module (@aspose/3d/formats/obj)

ClassKey Options
ObjLoadOptionsenableMaterials, flipCoordinateSystem, scale, normalizeNormal

glTF/GLB Module (@aspose/3d/formats/gltf)

ClassKey Options
GltfSaveOptionsbinaryMode (true → .glb), flipTexCoordV
GltfFormatGltfFormat.getInstance(): format instance for scene.save()

STL Module (@aspose/3d/formats/stl)

ClassKey Options
StlLoadOptionsN/A
StlSaveOptionsbinaryMode (false → ASCII, true → binary)

FBX Module (@aspose/3d/formats/fbx)

ClassKey Options
FbxLoadOptionsN/A
FbxSaveOptionsembedTextures

Supported Formats

FormatExtensionLoadSave
Wavefront OBJ.objYesYes
glTF 2.0.gltfYesYes
GLB (binary glTF).glbYesYes
STL.stlYesYes
FBX.fbxNoNo
COLLADA.daeYesYes
3MF.3mfYesYes

Quick Reference Example

import { Scene } from '@aspose/3d';
import { ObjLoadOptions } from '@aspose/3d/formats/obj';
import { GltfSaveOptions } from '@aspose/3d/formats/gltf';

// Load OBJ with materials
const scene = new Scene();
const loadOpts = new ObjLoadOptions();
loadOpts.enableMaterials = true;
scene.open('input.obj', loadOpts);

// Inspect root nodes
for (const node of scene.rootNode.childNodes) {
    console.log(`Node: ${node.name}, entity: ${node.entity?.constructor.name}`);
}

// Export as GLB (binary glTF)
const saveOpts = new GltfSaveOptions();
saveOpts.binaryMode = true;
scene.save('output.glb', saveOpts);

See Also

Related Resources