API reference
API reference
Select your platform
No SDKs available
No versions available

OVRGLTFLoader Class

This is a lightweight GLTF model loader that is guaranteed to work with models loaded from the Meta Quest runtime using OVRPlugin.LoadRenderModel OVRPlugin.LoadRenderModel.
The loader only accepts GLTF files/data in the GLB format. We do not recommended using this class as a general purpose GLTF loader.

Constructors

OVRGLTFLoader ( fileName )
Creates a new GLTF loader using a file path.
Signature
OVRGLTFLoader(string fileName)
Parameters
fileName: string  Path to GLB file
OVRGLTFLoader ( data )
Creates a new GLTF loader using a binary data array.
Signature
OVRGLTFLoader(byte[] data)
Parameters
data: byte[]  GLB byte data
OVRGLTFLoader ( deferredStream )
Creates a new GLTF loader with a deferred data stream.
This should be used with OVRGLTFLoader.LoadGLBCoroutine to allow for async loading of the GLTF model. This can help prevent stalling on complex GLTF models.
Signature
OVRGLTFLoader(Func< Stream > deferredStream)
Parameters
deferredStream: Func< Stream >  GLB data as a Stream

Fields

scene : OVRGLTFScene
Signature
OVRGLTFScene scene
textureUriHandler : Func< string, Material, Texture2D >
Signature
Func<string, Material, Texture2D> textureUriHandler

Static Fields

GLTFToUnitySpace : readonly Vector3
Signature
readonly Vector3 GLTFToUnitySpace
GLTFToUnitySpace_Rotation : readonly Vector4
Signature
readonly Vector4 GLTFToUnitySpace_Rotation
GLTFToUnityTangent : readonly Vector3
Signature
readonly Vector3 GLTFToUnityTangent

Methods

LoadGLB ( supportAnimation , loadMips )
Starts the loading process for the full GLTF file into Unity.
Signature
OVRGLTFScene LoadGLB(bool supportAnimation, bool loadMips=true)
Parameters
supportAnimation: bool  Load GLTF animations.
loadMips: bool  Load GLTF textures with mip maps.
Returns
OVRGLTFScene  Full GLTF scene
LoadGLBCoroutine ( supportAnimation , loadMips )
Starts the loading process for the full GLTF file into Unity as a coroutine.
This can help prevent stalling as loading will be spread out over multiple frames.
Signature
IEnumerator LoadGLBCoroutine(bool supportAnimation, bool loadMips=true)
Parameters
supportAnimation: bool  Load GLTF animations
loadMips: bool  Load GLTF textures with mip maps.
Returns
IEnumerator  IEnumerator that can be yielded on.
SetMipMapBias ( loadedTexturesMipmapBiasing )
Sets the MipMap bias value for loading all textures in the GLTF model.
The default is 0. Only supported when MipMaps are loaded and the provided shader has a property named "_MainTexMMBias"
Signature
void SetMipMapBias(float loadedTexturesMipmapBiasing)
Parameters
loadedTexturesMipmapBiasing: float  The value for bias. Value is clamped between [-1,1]
Returns
void
SetModelAlphaBlendShader ( shader )
Sets the alpha blending shader that should be used by the GLTF loader on materials.
Signature
void SetModelAlphaBlendShader(Shader shader)
Parameters
shader: Shader  Shader to be used.
Returns
void
SetModelShader ( shader )
Sets the shader that should be used by the GLTF loader on materials.
Signature
void SetModelShader(Shader shader)
Parameters
shader: Shader  Shader to be used.
Returns
void
SetTextureQualityFiltering ( loadedTexturesQuality )
Sets the texture quality for loading all textures in the GLTF model.
The default is Bilinear. Once loaded, textures will be read-only on GPU memory.
Signature
void SetTextureQualityFiltering(OVRTextureQualityFiltering loadedTexturesQuality)
Parameters
loadedTexturesQuality: OVRTextureQualityFiltering  The quality setting.
Returns
void

Static Methods

ApplyTextureQuality ( qualityLevel , destTexture )
Applies the input Texture Quality setting into the ref Texture2D provided as input.
Texture2D must not be readonly.
Signature
static void ApplyTextureQuality(OVRTextureQualityFiltering qualityLevel, ref Texture2D destTexture)
Parameters
qualityLevel: OVRTextureQualityFiltering  The quality level to apply
destTexture: ref Texture2D  The destination Texture2D to apply quality setting to
Returns
void
DetectTextureQuality ( srcTexture )
Decodes the Texture Quality setting from the input Texture2D properties' values.
Signature
static OVRTextureQualityFiltering DetectTextureQuality(in Texture2D srcTexture)
Parameters
srcTexture: in Texture2D  The input Texture2D
Returns
OVRTextureQualityFiltering  The enum TextureQualityFiltering representing the quality.
ReadChunk ( glbStream , type )
Reads a chunk of binary data from the stream that either represents the JSON or BIN part of the GLTF file.
Signature
static byte[] ReadChunk(Stream glbStream, OVRChunkType type)
Parameters
glbStream: Stream  The binary stream of the GLTF file.
type: OVRChunkType  Type indicating which part of the GLTF file should be read.
Returns
byte[]
ValidateGLB ( glbStream )
Checks the GLB data stream to check if it is a valid GLTF file.
Signature
static bool ValidateGLB(Stream glbStream)
Parameters
glbStream: Stream  Data stream of the GLB file.
Returns
bool  If the stream is a valid GLTF file.