FileFormat — Aspose.3D FOSS for Java
Methods
FileFormat fungerar både som en formatbeskrivning och ett register över alla stödda 3D‑filformat. Varje format representeras som en FileFormat instans som är tillgänglig som ett klassattribut eller via statiska fabriksmetoder. Du skickar FileFormat instanser till Scene.save() för att tvinga ett specifikt format, eller använd FileFormat.detect() för att identifiera ett okänt fils format.
Methods: com.aspose.threed
import com.aspose.threed.FileFormat;Stödda formatkonstanter
Formatkonstanter som aktivt stöds (importörer och/eller exportörer registrerade) i FOSS‑utgåvan visas nedan.
Aktivt stödda (FOSS‑utgåva)
| Methods | Methods | Methods |
|---|---|---|
FileFormat.WAVEFRONTOBJ | .obj | Publikt statiskt finalfält (ObjFormat-instans) |
FileFormat.GLTF2 | .gltf / .glb | glTF 2.0 och GLB; publikt statiskt finalfält (GltfFormat-instans). Använd GltfSaveOptions med setContentType(FileContentType.BINARY) för GLB-utdata. |
FileFormat.FBX7400ASCII | .fbx | FBX 7.4 ASCII; endast import (ingen export) |
FileFormat.STL_BINARY | .stl | STL binär (sätts vid klassladdning) |
FileFormat.STLASCII | .stl | STL ASCII |
Methods
FBX versioner 6100-7700 (binary), Maya ASCII/Binary, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binary, PDF, Blender, DXF, PLY, X (binary/text), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binary.
Statiska metoder
| Methods | Returtyp | Methods |
|---|---|---|
FileFormat.detect(InputStream stream, String fileName) | FileFormat | Detekterar formatet från en filström; fileName används som en ledtråd |
FileFormat.getFormatByExtension(String ext) | FileFormat | Returnerar formatet som matchar en filändelse-sträng såsom ".obj", ".glb", ".fbx", ".stl" |
Instansegenskaper
| Methods | Methods | Methods | Methods |
|---|---|---|---|
extension | String | getExtension() | Primär filändelse (utan inledande punkt) |
extensions | List<String> | getExtensions() | Alla filändelser som stöds av detta format |
contentType | String | getContentType() | MIME-typsträng |
canExport | boolean | getCanExport() | Om export till detta format stöds |
canImport | boolean | getCanImport() | Om import från detta format stöds |
version | String | getVersion() | Formatversionssträng |
Instansmetoder
| Methods | Returtyp | Methods |
|---|---|---|
createLoadOptions() | LoadOptions | Skapar den lämpliga format‑specifika LoadOptions subklass |
createSaveOptions() | SaveOptions | Skapar den lämpliga format‑specifika SaveOptions subklass |
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());
}
}