Introduction

Working with 3D content in Java typically requires choosing between heavyweight game engines and bare-bones math libraries. The aspose-3d-foss package offers a middle ground: a focused scene-graph API that handles file I/O, node hierarchies, mesh construction, and coordinate transforms without pulling in a rendering pipeline or a native dependency chain.

Aspose.3D FOSS for Java is an open-source library distributed under the MIT license. It provides 80 classes spanning scene management, geometry, materials, and format conversion. The library reads FBX, glTF/GLB, Wavefront OBJ, and STL, and writes glTF/GLB, OBJ, and STL (FBX export is not implemented), making it practical for server-side 3D processing, build-tool integrations, and data-conversion pipelines that run on Java 21 or later.

This post walks through the scene-management capabilities in the library: how to build a scene from scratch, populate it with geometry and transforms, and export the result to disk.


What’s Included

Scene Graph Basics

The Scene class is the root container for every 3D document. It holds a root Node, asset metadata, animation clips, and sub-scenes. You can create an empty scene and then populate it, or load an existing file with Scene.fromFile.

import com.aspose.threed.Scene;
import com.aspose.threed.Node;

Scene scene = new Scene();
Node root = scene.getRootNode();

// Add named child nodes to build a hierarchy
Node chassis = root.createChildNode("Chassis");
Node wheel = chassis.createChildNode("FrontLeftWheel");

Every Node can hold an Entity (such as a Mesh or Camera), a Transform, a list of materials, and further child nodes. The tree structure mirrors the scene-graph pattern used by most 3D authoring tools.

Mesh Construction

The Mesh class lets you define geometry from control points and polygon indices. You add vertices with addControlPoint, then connect them into faces with createPolygon.

import com.aspose.threed.Mesh;

Mesh box = new Mesh("Box");

// Define eight corners of a cube
box.addControlPoint(0, 0, 0);
box.addControlPoint(1, 0, 0);
box.addControlPoint(1, 1, 0);
box.addControlPoint(0, 1, 0);
box.addControlPoint(0, 0, 1);
box.addControlPoint(1, 0, 1);
box.addControlPoint(1, 1, 1);
box.addControlPoint(0, 1, 1);

// Create quad faces
box.createPolygon(0, 1, 2, 3); // back
box.createPolygon(4, 5, 6, 7); // front
box.createPolygon(0, 4, 7, 3); // left
box.createPolygon(1, 5, 6, 2); // right
box.createPolygon(3, 2, 6, 7); // top
box.createPolygon(0, 1, 5, 4); // bottom

scene.getRootNode().createChildNode("Box", box);

The mesh API includes triangulate(), optimize(removeVertices), and Boolean operations (union, difference, intersect), but these methods are stubs in the current release — they return a clone of the input mesh without performing the named operation.

Transforms and Positioning

Each Node carries a Transform that controls its local translation, rotation, and scale. These compose through the hierarchy so that moving a parent node moves all its children.

import com.aspose.threed.Transform;
import com.aspose.threed.Node;

Node node = scene.getRootNode().createChildNode("Shifted");
Transform t = node.getTransform();
t.setTranslation(5.0, 0.0, -3.0);
t.setScale(2.0, 2.0, 2.0);
t.setEulerAngles(0, 45.0, 0);

For absolute positioning queries, call node.getGlobalTransform() to retrieve the composed GlobalTransform, or node.evaluateGlobalTransform(true) to get a Matrix4 that includes geometric offsets.

PBR Materials

The PbrMaterial class provides physically-based rendering properties: albedo color, metallic factor, roughness, emissive color, and transparency. Assign a material to a node when creating the child.

import com.aspose.threed.PbrMaterial;
import com.aspose.threed.Vector4;
import com.aspose.threed.Vector3;

PbrMaterial mat = new PbrMaterial("RedMetal");
mat.setAlbedo(new Vector4(0.9, 0.1, 0.1, 1.0));
mat.setMetallicFactor(0.8);
mat.setRoughnessFactor(0.3);
mat.setEmissiveColor(new Vector3(0, 0, 0));

scene.getRootNode().createChildNode("Part", box, mat);

Format Detection

The FileFormat class provides static lookup and detection utilities. You can resolve a format by file extension or probe a stream to identify unknown files.

import com.aspose.threed.FileFormat;

FileFormat fmt = FileFormat.getFormatByExtension("model.glb");
boolean canRead  = fmt.getCanImport();
boolean canWrite = fmt.getCanExport();

Coordinate-System Conversion

AxisSystem lets you define the up-axis, front-axis, and handedness of a coordinate system, then compute a Matrix4 to transform geometry between conventions (for example, from a Z-up right-handed system to a Y-up left-handed one).

import com.aspose.threed.AxisSystem;
import com.aspose.threed.Axis;
import com.aspose.threed.CoordinateSystem;
import com.aspose.threed.Matrix4;

AxisSystem source = new AxisSystem(
    CoordinateSystem.RIGHT_HANDED, Axis.Z_AXIS, Axis.Y_AXIS);
AxisSystem target = new AxisSystem(
    CoordinateSystem.LEFT_HANDED, Axis.Y_AXIS, Axis.Z_AXIS);
Matrix4 conversion = source.transformTo(target);

Quick Start

Add the Maven dependency:

<dependency>
  <groupId>com.aspose</groupId>
  <artifactId>aspose-3d-foss</artifactId>
  <version>26.1.0</version>
</dependency>

Build a simple scene and export it:

import com.aspose.threed.Scene;
import com.aspose.threed.Mesh;
import com.aspose.threed.Node;
import com.aspose.threed.StlSaveOptions;
import com.aspose.threed.FileContentType;

Scene scene = new Scene();
Mesh mesh = new Mesh("Triangle");
mesh.addControlPoint(0, 0, 0);
mesh.addControlPoint(1, 0, 0);
mesh.addControlPoint(0, 1, 0);
mesh.createPolygon(0, 1, 2);

scene.getRootNode().createChildNode("Shape", mesh);

StlSaveOptions opts = new StlSaveOptions();
opts.setContentType(FileContentType.BINARY);
scene.save("output.stl", opts);

Supported Formats

FormatExtensionReadWrite
FBX (ASCII and Binary, 6.x-7.x).fbxYesNo
glTF 1.0 / 2.0.gltfYesYes
glTF Binary.glbYesYes
Wavefront OBJ.objYesYes
STL (ASCII and Binary).stlYesYes

Each format has dedicated LoadOptions and SaveOptions subclasses (for example, FbxLoadOptions, GltfSaveOptions, StlSaveOptions) that expose format-specific settings such as coordinate-system flipping and content type selection.


Open Source & Licensing

Aspose.3D FOSS for Java is released under the MIT license. The source code is available on GitHub at Aspose.3D-FOSS-for-Java. You can use, modify, and redistribute the library in commercial and non-commercial projects without restriction.


Getting Started