Format Load and Save Options
Package: @aspose/3d (v24.12.0)
Format option classes control how @aspose/3d reads and writes specific 3D file formats. Pass an options instance as the second argument to scene.open() (load options) or scene.save() (save options). All option classes extend either LoadOptions or SaveOptions.
// Load with options
import { Scene } from '@aspose/3d';
import { ObjLoadOptions } from '@aspose/3d/formats/obj';
const opts = new ObjLoadOptions();
opts.enableMaterials = false;
scene.open('mesh.obj', opts);
// Save with options
import { GltfSaveOptions } from '@aspose/3d/formats/gltf';
const saveOpts = new GltfSaveOptions();
saveOpts.binaryMode = true;
scene.save('output.glb', saveOpts);GltfSaveOptions
Save options for glTF 2.0 JSON (.gltf) and binary GLB (.glb) output.
import { GltfSaveOptions } from '@aspose/3d/formats/gltf';
// or
import { GltfSaveOptions } from '@aspose/3d';Properties
| Property | Type | Default | Description |
|---|---|---|---|
binaryMode | boolean | false | When true, the exporter writes a self-contained binary GLB file. When false, it writes a JSON .gltf file with a companion .bin buffer. |
flipTexCoordV | boolean | true | When true, UV V coordinates are flipped (v = 1 - v). The glTF 2.0 specification uses a top-left UV origin, so this flag is true by default to match most DCC tool conventions. |
Examples
Export a scene as a binary GLB with UV coordinates preserved as-is.
import { Scene } from '@aspose/3d';
import { GltfSaveOptions } from '@aspose/3d/formats/gltf';
const scene = new Scene();
scene.open('model.obj');
const opts = new GltfSaveOptions();
opts.binaryMode = true;
opts.flipTexCoordV = false;
scene.save('output.glb', opts);
console.log('Saved as binary GLB without UV flip.');GltfLoadOptions
Load options for glTF 2.0 JSON (.gltf) and binary GLB (.glb) files.
import { GltfLoadOptions } from '@aspose/3d/formats/gltf';GltfLoadOptions extends LoadOptions. It does not expose additional user-facing properties in the current version; pass a default instance to use recommended defaults.
Examples
import { Scene } from '@aspose/3d';
import { GltfLoadOptions } from '@aspose/3d/formats/gltf';
const scene = new Scene();
scene.open('model.glb', new GltfLoadOptions());ObjLoadOptions
Load options for Wavefront OBJ (.obj) files.
import { ObjLoadOptions } from '@aspose/3d/formats/obj';
// or
import { ObjLoadOptions } from '@aspose/3d';Properties
| Property | Type | Default | Description |
|---|---|---|---|
enableMaterials | boolean | true | When true, the importer reads the .mtl material library referenced by the mtllib directive and populates material properties on the mesh nodes. Set to false to skip material loading. |
flipCoordinateSystem | boolean | false | When true, the Y and Z axes are swapped during import to convert between Y-up and Z-up coordinate systems. |
normalizeNormal | boolean | true | When true, vertex normals read from the file are normalized to unit length during import. |
scale | number | 1.0 | Uniform scale factor applied to all geometry during import. |
Examples
Load an OBJ file without resolving its material library.
import { Scene } from '@aspose/3d';
import { ObjLoadOptions } from '@aspose/3d/formats/obj';
const opts = new ObjLoadOptions();
opts.enableMaterials = false;
const scene = new Scene();
scene.open('mesh.obj', opts);
console.log(`Root children: ${scene.rootNode.childNodes.length}`);ObjSaveOptions
Save options for Wavefront OBJ (.obj) output.
import { ObjSaveOptions } from '@aspose/3d/formats/obj';Note: OBJ export (
canExport: false) is not fully supported in this version of the library. Attempting to save to OBJ may throw an unsupported-operation error.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
enableMaterials | boolean | true | When true, a companion .mtl material library file is written alongside the .obj output. |
pointCloud | boolean | false | When true, geometry is exported as a point cloud (vertices only, no face definitions). |
verbose | boolean | false | When true, additional diagnostic comments are included in the OBJ output. |
serializeW | boolean | false | When true, the W component of homogeneous vertex coordinates is written to the file. |
flipCoordinateSystem | boolean | false | When true, the Y and Z axes are swapped during export. |
applyUnitScale | boolean | false | When true, the scene’s unit scale is applied to all geometry coordinates during export. |
StlSaveOptions
Save options for STL (.stl) output.
import { StlSaveOptions } from '@aspose/3d/formats/stl';
// or
import { StlSaveOptions } from '@aspose/3d';Properties
| Property | Type | Default | Description |
|---|---|---|---|
binaryMode | boolean | false | When true, the output is written as binary STL (compact, not human-readable). When false, ASCII STL is written. |
flipCoordinateSystem | boolean | false | When true, the Y and Z axes are swapped during export. |
scale | number | 1.0 | Uniform scale factor applied to all geometry during export. |
Examples
Save a mesh as binary STL.
import { Scene } from '@aspose/3d';
import { StlSaveOptions } from '@aspose/3d/formats/stl';
const scene = new Scene();
scene.open('model.obj');
const opts = new StlSaveOptions();
opts.binaryMode = true;
scene.save('output.stl', opts);
console.log('Saved binary STL.');StlLoadOptions
Load options for STL (.stl) files. Both ASCII and binary STL are supported automatically; no property controls the detection.
import { StlLoadOptions } from '@aspose/3d/formats/stl';StlLoadOptions extends LoadOptions and does not expose additional user-facing properties in the current version.
FbxSaveOptions
Save options for FBX (.fbx) output.
import { FbxSaveOptions } from '@aspose/3d/formats/fbx';
// or
import { FbxSaveOptions } from '@aspose/3d';Properties
| Property | Type | Default | Description |
|---|---|---|---|
embedTextures | boolean | false | When true, referenced texture images are embedded inside the FBX binary archive. When false, texture paths are written as external references. |
Examples
Export an FBX file with all textures embedded.
import { Scene } from '@aspose/3d';
import { FbxSaveOptions } from '@aspose/3d/formats/fbx';
const scene = new Scene();
scene.open('character.gltf');
const opts = new FbxSaveOptions();
opts.embedTextures = true;
scene.save('character-embedded.fbx', opts);
console.log('Saved FBX with embedded textures.');FbxLoadOptions
Load options for FBX (.fbx) files. Supports both binary and ASCII FBX.
import { FbxLoadOptions } from '@aspose/3d/formats/fbx';FbxLoadOptions extends LoadOptions and does not expose additional user-facing properties in the current version.
Base Classes
LoadOptions
Base class for all load option objects.
import { LoadOptions } from '@aspose/3d';Pass a LoadOptions subclass instance to scene.open(filePath, options) or scene.openFromBuffer(buffer, options).
SaveOptions
Base class for all save option objects.
import { SaveOptions } from '@aspose/3d';Pass a SaveOptions subclass instance to scene.save(filePath, options).