// SPDX-FileCopyrightText: 2025 Unity Technologies and the glTFast authors // SPDX-License-Identifier: Apache-2.0 using System; using System.Runtime.CompilerServices; using Unity.Mathematics; namespace GLTFast { /// A 3 component vector of unsigned bytes. struct byte3 { /// x component of the vector. public byte x; /// y component of the vector. public byte y; /// z component of the vector. public byte z; /// Constructs a byte3 vector from three byte values. /// The constructed vector's x component will be set to this value. /// The constructed vector's y component will be set to this value. /// The constructed vector's z component will be set to this value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public byte3(byte x, byte y, byte z) { this.x = x; this.y = y; this.z = z; } /// /// Converts 3 component vector from unsigned byte in glTF space to /// float in Unity space. /// /// 3 component vector in Unity space. [MethodImpl(MethodImplOptions.AggressiveInlining)] public float3 GltfToUnityFloat3() { return new float3(-x, y, z); } /// /// Converts 3 component vector from unsigned byte in glTF space to /// normalized float vector in Unity space. /// /// Normalized 3 component vector in Unity space. [MethodImpl(MethodImplOptions.AggressiveInlining)] public float3 GltfToUnityNormalizedFloat3() { return new float3( -(x / 255f), y / 255f, z / 255f ); } /// /// Converts triangle indices from unsigned byte in glTF space to /// signed int indices in Unity space. /// /// Triangle indices vector in Unity space. [MethodImpl(MethodImplOptions.AggressiveInlining)] public int3 GltfToUnityTriangleIndies() { return new int3(x, z, y); } } }