FileFormat — Aspose.3D FOSS for Java
Methods
FileFormat dient zowel als een formatbeschrijving als een register van alle ondersteunde 3D‑bestandsformaten. Elk format wordt weergegeven als een FileFormat instance die toegankelijk is als een klasse‑attribuut of via statische fabrieksmethoden. Je geeft FileFormat instances aan Scene.save() om een specifiek format af te dwingen, of gebruik FileFormat.detect() om het format van een onbekend bestand te identificeren.
Methods: com.aspose.threed
import com.aspose.threed.FileFormat;Ondersteunde Formaatconstanten
Formaatconstanten die actief worden ondersteund (importeurs en/of exporteurs geregistreerd) in de FOSS-release worden hieronder weergegeven.
Actief Ondersteund (FOSS-release)
| Methods | Methods | Methods |
|---|---|---|
FileFormat.WAVEFRONTOBJ | .obj | Publiek statisch final veld (ObjFormat‑instance) |
FileFormat.GLTF2 | .gltf / .glb | glTF 2.0 en GLB; publiek statisch final veld (GltfFormat‑instance). Gebruik GltfSaveOptions met setContentType(FileContentType.BINARY) voor GLB‑uitvoer. |
FileFormat.FBX7400ASCII | .fbx | FBX 7.4 ASCII; alleen import (geen export) |
FileFormat.STL_BINARY | .stl | STL binair (ingesteld bij het laden van de klasse) |
FileFormat.STLASCII | .stl | STL ASCII |
Methods
FBX‑versies 6100-7700 (binair), Maya ASCII/Binary, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binary, PDF, Blender, DXF, PLY, X (binair/tekst), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binary.
Statische Methoden
| Methods | Retourtype | Methods |
|---|---|---|
FileFormat.detect(InputStream stream, String fileName) | FileFormat | Detecteert het format uit een bestandsstroom; fileName wordt gebruikt als hint |
FileFormat.getFormatByExtension(String ext) | FileFormat | Retourneert het format dat overeenkomt met een extensiestring zoals ".obj", ".glb", ".fbx", ".stl" |
Instantie‑eigenschappen
| Methods | Methods | Methods | Methods |
|---|---|---|---|
extension | String | getExtension() | Primaire bestandsextensie (zonder de voorlooppunt) |
extensions | List<String> | getExtensions() | Alle extensies die door dit formaat worden ondersteund |
contentType | String | getContentType() | MIME-type tekenreeks |
canExport | boolean | getCanExport() | Of exporteren naar dit formaat wordt ondersteund |
canImport | boolean | getCanImport() | Of importeren vanuit dit formaat wordt ondersteund |
version | String | getVersion() | Formaatversiestring |
Instantie‑methoden
| Methods | Retourtype | Methods |
|---|---|---|
createLoadOptions() | LoadOptions | Creëert de juiste format‑specifieke LoadOptions subklasse |
createSaveOptions() | SaveOptions | Creëert de juiste format‑specifieke SaveOptions subklasse |
Methods
import com.aspose.threed.Scene;
import com.aspose.threed.FileFormat;
import com.aspose.threed.*;
// Auto-detect and load
Scene scene = Scene.fromFile("model.obj");
// Save with explicit format (force GLB binary)
GltfSaveOptions opts = new GltfSaveOptions();
opts.setContentType(FileContentType.BINARY);
scene.save("output.glb", opts);
// Get format by extension
FileFormat fmt = FileFormat.getFormatByExtension(".fbx");
if (fmt != null) {
System.out.println(fmt.getCanImport()); // true
System.out.println(fmt.getCanExport()); // false (FBX export not available)
}
// Create options from a format instance
FileFormat fmtObj = FileFormat.getFormatByExtension(".obj");
LoadOptions loadOpts = fmtObj.createLoadOptions(); // ObjLoadOptions
SaveOptions saveOpts = fmtObj.createSaveOptions(); // ObjSaveOptions
// Detect format from file stream
try (FileInputStream fis = new FileInputStream("unknown_file.bin")) {
FileFormat detected = FileFormat.detect(fis, "unknown_file.bin");
if (detected != null) {
System.out.println(detected.getClass().getSimpleName());
}
}