mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-13 06:20:01 -05:00
Define TransformState
This commit is contained in:
42
Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs
Normal file
42
Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public readonly struct TransformState
|
||||
{
|
||||
public Vector3 Position { get; }
|
||||
public Vector3 LocalPosition { get; }
|
||||
public Quaternion Rotation { get; }
|
||||
public Quaternion LocalRotation { get; }
|
||||
public Vector3 LocalScale { get; }
|
||||
|
||||
public TransformState(Vector3 position, Vector3 localPosition, Quaternion rotation, Quaternion localRotation, Vector3 localScale)
|
||||
{
|
||||
Position = position;
|
||||
LocalPosition = localPosition;
|
||||
Rotation = rotation;
|
||||
LocalRotation = localRotation;
|
||||
LocalScale = localScale;
|
||||
}
|
||||
|
||||
public TransformState(Transform tf)
|
||||
{
|
||||
if (tf == null)
|
||||
{
|
||||
Position = Vector3.zero;
|
||||
LocalPosition = Vector3.zero;
|
||||
Rotation = Quaternion.identity;
|
||||
LocalRotation = Quaternion.identity;
|
||||
LocalScale = Vector3.one;
|
||||
}
|
||||
else
|
||||
{
|
||||
Position = tf.position;
|
||||
LocalPosition = tf.localPosition;
|
||||
Rotation = tf.rotation;
|
||||
LocalRotation = tf.localRotation;
|
||||
LocalScale = tf.localScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 172d698f753e4e59bf65a75014016221
|
||||
timeCreated: 1657022395
|
||||
Reference in New Issue
Block a user