// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Microsoft.MixedReality.Toolkit.Utilities.Gltf.Schema.Extensions; using System; using System.Collections.Generic; using UnityEngine; namespace Microsoft.MixedReality.Toolkit.Utilities.Gltf.Schema { [Serializable] public class GltfObject : GltfProperty { #region Serialized Fields /// /// Names of glTF extensions used somewhere in this asset. /// public string[] extensionsUsed; /// /// Names of glTF extensions required to properly load this asset. /// public string[] extensionsRequired; /// /// An array of accessors. An accessor is a typed view into a bufferView. /// public GltfAccessor[] accessors; /// /// An array of keyframe animations. /// public GltfAnimation[] animations; /// /// Metadata about the glTF asset. /// public GltfAssetInfo asset; /// /// An array of buffers. A buffer points to binary geometry, animation, or skins. /// public GltfBuffer[] buffers; /// /// An array of bufferViews. /// A bufferView is a view into a buffer generally representing a subset of the buffer. /// public GltfBufferView[] bufferViews; /// /// An array of cameras. A camera defines a projection matrix. /// public GltfCamera[] cameras; /// /// An array of images. An image defines data used to create a texture. /// public GltfImage[] images; /// /// An array of materials. A material defines the appearance of a primitive. /// public GltfMaterial[] materials; /// /// An array of meshes. A mesh is a set of primitives to be rendered. /// public GltfMesh[] meshes; /// /// An array of nodes. /// public GltfNode[] nodes; /// /// An array of samplers. A sampler contains properties for texture filtering and wrapping modes. /// public GltfSampler[] samplers; /// /// The index of the default scene. /// public int scene; /// /// An array of scenes. /// public GltfScene[] scenes; /// /// An array of skins. A skin is defined by joints and matrices. /// public GltfSkin[] skins; /// /// An array of textures. /// public GltfTexture[] textures; #endregion Serialized Fields /// /// The name of the gltf Object. /// public string Name { get; internal set; } /// /// The absolute path to the glTF Object on disk. /// public string Uri { get; internal set; } /// /// The GameObject reference for the gltf Object. /// public GameObject GameObjectReference { get; internal set; } /// /// The Node Id and corresponding GameObject pairs. /// public Dictionary NodeGameObjectPairs { get; internal set; } = new Dictionary(); /// /// The list of registered glTF extensions found for this object. /// public List RegisteredExtensions { get; internal set; } = new List(); /// /// Flag for setting object load behavior. /// Importers should run on the main thread; all other loading scenarios should likely use the background thread /// internal bool UseBackgroundThread { get; set; } = true; /// /// Get an accessor from an accessor index /// public GltfAccessor GetAccessor(int index) { if (index < 0) return null; var accessor = accessors[index]; accessor.BufferView = bufferViews[accessor.bufferView]; accessor.BufferView.Buffer = buffers[accessor.BufferView.buffer]; return accessor; } } }