Ejemplo n.º 1
0
        public void InverseSwizzleVector3_ReversesSwizzleVector3([Values] Vector3Swizzle swizzle)
        {
            var     original = new Vector3(Random.value, Random.value, Random.value);
            Vector3 result;

            result = original.Swizzle(swizzle).InverseSwizzle(swizzle);
            Assert.AreEqual(original, result);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Swaps the component values of a <see cref="Vector3" /> from XYZ
 ///     to the given format
 /// </summary>
 public static Vector3 Swizzle(this Vector3 vector3, Vector3Swizzle swizzle)
 {
     return(swizzle switch
     {
         Vector3Swizzle.XYZ => vector3,
         Vector3Swizzle.XZY => new Vector3(vector3.x, vector3.z, vector3.y),
         Vector3Swizzle.YXZ => new Vector3(vector3.y, vector3.x, vector3.z),
         Vector3Swizzle.YZX => new Vector3(vector3.y, vector3.z, vector3.x),
         Vector3Swizzle.ZXY => new Vector3(vector3.z, vector3.x, vector3.y),
         Vector3Swizzle.ZYX => new Vector3(vector3.z, vector3.y, vector3.x),
         _ => throw ExceptionUtility.NotSupportedEnumValue(swizzle),
     });