Quick Start
Quick Start
This guide shows the fastest path from installation to loading and saving a 3D file using Aspose.3D FOSS for Java. The library is MIT-licensed, pure Java, and requires no native binaries or external dependencies beyond the Maven artifact.
Prerequisites
| Requirement | Detail |
|---|---|
| Java | 21 or later |
| Build tool | Maven 3.6+ or Gradle |
| OS | Windows, macOS, Linux, Docker |
| Package | com.aspose:aspose-3d-foss:26.1.0 |
Install
Add the Maven dependency to your pom.xml. The library detects 3D file formats
automatically from file extensions, so no explicit format constants are needed for
basic use:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-3d-foss</artifactId>
<version>26.1.0</version>
</dependency>Load a 3D File
Call Scene.fromFile() with a path to load any supported format. Access the scene
hierarchy through scene.getRootNode():
import com.aspose.threed.Scene;
Scene scene = Scene.fromFile("model.obj");
System.out.println("Root node: " + scene.getRootNode().getName());Traverse the Scene Graph
A loaded scene is a tree of Node objects rooted at scene.getRootNode(). Use
a recursive walk to process each node and its children:
import com.aspose.threed.Node;
import com.aspose.threed.Scene;
void walk(Node node, int depth) {
String indent = " ".repeat(depth * 2);
System.out.println(indent + "Node: " + node.getName());
for (Node child : node.getChildNodes()) {
walk(child, depth + 1);
}
}
Scene scene = Scene.fromFile("model.glb");
walk(scene.getRootNode(), 0);Save to a Different Format
The library detects the output format from the file extension. Pass the output path
to Scene.save() to convert between formats:
import com.aspose.threed.Scene;
Scene scene = Scene.fromFile("model.obj");
scene.save("output.glb");
System.out.println("Converted to GLB.");Create a New Scene and Save
Construct a Scene with no arguments to start empty, add child nodes to
scene.getRootNode(), then call scene.save() to write the file:
import com.aspose.threed.Scene;
import com.aspose.threed.Node;
Scene scene = new Scene();
Node box = scene.getRootNode().createChildNode("box");
scene.save("new_scene.obj");