// SPDX-FileCopyrightText: 2025 Unity Technologies and the glTFast authors // SPDX-License-Identifier: Apache-2.0 using System.Runtime.CompilerServices; using Unity.Mathematics; namespace GLTFast { /// A 3 component vector of unsigned 16-bit integers. struct ushort3 { /// x component of the vector. public ushort x; /// y component of the vector. public ushort y; /// z component of the vector. public ushort z; /// /// Converts 3 component vector from unsigned short in glTF space to /// float3 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 short 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 / (float)ushort.MaxValue), y / (float)ushort.MaxValue, z / (float)ushort.MaxValue ); } /// /// Converts triangle indices from unsigned short 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); } } }