// SPDX-FileCopyrightText: 2023 Unity Technologies and the glTFast authors // SPDX-License-Identifier: Apache-2.0 using System; using Unity.Collections; namespace GLTFast { enum ImageFormat { Unknown, PNG, Jpeg, Ktx } enum ChunkFormat : uint { Json = 0x4e4f534a, Binary = 0x004e4942 } /// /// Generic glTF constants and utility methods. /// public static class GltfGlobals { /// /// glTF-Binary file extension /// public const string GlbExt = ".glb"; /// /// glTF file extension /// public const string GltfExt = ".gltf"; /// /// glTF package name /// public const string GltfPackageName = "com.unity.cloud.gltfast"; /// /// First four bytes of a glTF-Binary file are made up of this signature /// Represents glTF in ASCII /// public const uint GltfBinaryMagic = 0x46546c67; /// /// Figures out if a byte array contains data of a glTF-Binary /// /// data buffer /// True if the data is a glTF-Binary, false otherwise public static bool IsGltfBinary(byte[] data) { var magic = BitConverter.ToUInt32(data, 0); return magic == GltfBinaryMagic; } /// /// Figures out if a byte array contains data of a glTF-Binary /// /// data buffer /// True if the data is a glTF-Binary, false otherwise public static bool IsGltfBinary(NativeArray.ReadOnly data) { var magic = data[0] | (uint)data[1] << 8 | (uint)data[2] << 16 | (uint)data[3] << 24; return magic == GltfBinaryMagic; } } }