TriLib allows accessing files native data (metadata) depending on a file-format basis.
The following article contains some classes not available on the current
This article won’t focus on every native class, it will introduce the methods to access the top-level native classes from some file formats.
FBX
To access the FBXDocument class containing the FBX file data, use the following code:
using TriLibCore.Fbx; ... var fbxDocument = assetLoaderContext.RootModel as FBXDocument; if (fbxDocument != null) { var globalSettings = fbxDocument.FBXGlobalSettings; var unitScaleFactor = globalSettings.UnitScaleFactor; Debug.Log("FBX Unit Scale Factor: " + unitScaleFactor); }
glTF 2
glTF 2 loading uses glTFCSharpLoader internally. To access the Gltf class containing the glTF file data, use the following code:
using TriLibCore.Gltf; ... var gltfRootModel = assetLoaderContext.RootModel as GltfRootModel; if (gltfRootModel != null) { var gltf = gltfRootModel.Gltf; var scenes = gltf.Scenes; if (scenes != null) { Debug.Log("glTF file has: " + scenes.Length + " scenes"); } }
3MF
3MF loading uses IxMilia.ThreeMf internally. To access the ThreeMfFile class containing the 3MF file data, use the following code:
using TriLibCore.ThreeMf; ... var threeMfRootModel = assetLoaderContext.RootModel as ThreeMfRootModel; if (threeMfRootModel != null) { var file = threeMfRootModel.File; var models = file.Models; if (models != null) { Debug.Log("3MF file has: " + models.Length + " models"); } }
OBJ, PLY, STL
OBJ, PLY, and STL files don’t store metadata at the moment.
Important: some external classes have methods to save/export files, but these haven’t been implemented using TriLib internal classes and aren’t intended to be used. TriLib is not a model exporter.