mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-23 11:26:15 -05:00
Merge pull request #1014 from ousttrue/feature/remove_IAnimationImporter
IAnimationImporter を廃止
This commit is contained in:
commit
084a8eaa5a
|
|
@ -1,11 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using VRMShaders;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public interface IAnimationImporter
|
||||
{
|
||||
AnimationClip Import(glTF gltf, int i, Axes invertAxis);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4f950ba9271cbff4cbc4345f5a23a5d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public sealed class RootAnimationImporter : IAnimationImporter
|
||||
{
|
||||
public AnimationClip Import(glTF gltf, int i, Axes invertAxis)
|
||||
{
|
||||
return AnimationImporterUtil.ConvertAnimationClip(gltf, gltf.animations[i], invertAxis.Create());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27640e6274339664ea492827be5a2217
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -12,26 +12,6 @@ namespace UniGLTF
|
|||
/// </summary>
|
||||
public class ImporterContext : IDisposable
|
||||
{
|
||||
#region Animation
|
||||
protected IAnimationImporter m_animationImporter;
|
||||
public void SetAnimationImporter(IAnimationImporter animationImporter)
|
||||
{
|
||||
m_animationImporter = animationImporter;
|
||||
}
|
||||
public IAnimationImporter AnimationImporter
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_animationImporter == null)
|
||||
{
|
||||
m_animationImporter = new RootAnimationImporter();
|
||||
}
|
||||
return m_animationImporter;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public ITextureDescriptorGenerator TextureDescriptorGenerator { get; protected set; }
|
||||
public IMaterialDescriptorGenerator MaterialDescriptorGenerator { get; protected set; }
|
||||
public TextureFactory TextureFactory { get; }
|
||||
|
|
@ -123,35 +103,63 @@ namespace UniGLTF
|
|||
|
||||
using (MeasureTime("AnimationImporter"))
|
||||
{
|
||||
if (GLTF.animations != null && GLTF.animations.Any())
|
||||
{
|
||||
var animation = Root.AddComponent<Animation>();
|
||||
for (int i = 0; i < GLTF.animations.Count; ++i)
|
||||
{
|
||||
var gltfAnimation = GLTF.animations[i];
|
||||
AnimationClip clip = default;
|
||||
if (_externalObjectMap.TryGetValue(new SubAssetKey(typeof(AnimationClip), gltfAnimation.name), out UnityEngine.Object value))
|
||||
{
|
||||
clip = value as AnimationClip;
|
||||
}
|
||||
else
|
||||
{
|
||||
clip = AnimationImporter.Import(GLTF, i, InvertAxis);
|
||||
AnimationClips.Add(clip);
|
||||
}
|
||||
|
||||
animation.AddClip(clip, clip.name);
|
||||
if (i == 0)
|
||||
{
|
||||
animation.clip = clip;
|
||||
}
|
||||
}
|
||||
}
|
||||
await LoadAnimationAsync(awaitCaller);
|
||||
await SetupAnimationsAsync(awaitCaller);
|
||||
}
|
||||
|
||||
await OnLoadHierarchy(awaitCaller, MeasureTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ImporterContext.AnimationClips に AnimationClip を読み込むところまでが責務
|
||||
/// </summary>
|
||||
/// <param name="awaitCaller"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual async Task LoadAnimationAsync(IAwaitCaller awaitCaller)
|
||||
{
|
||||
if (GLTF.animations != null && GLTF.animations.Any())
|
||||
{
|
||||
for (int i = 0; i < GLTF.animations.Count; ++i)
|
||||
{
|
||||
var gltfAnimation = GLTF.animations[i];
|
||||
AnimationClip clip = default;
|
||||
if (_externalObjectMap.TryGetValue(new SubAssetKey(typeof(AnimationClip), gltfAnimation.name), out UnityEngine.Object value))
|
||||
{
|
||||
clip = value as AnimationClip;
|
||||
}
|
||||
else
|
||||
{
|
||||
clip = AnimationImporterUtil.ConvertAnimationClip(GLTF, GLTF.animations[i], InvertAxis.Create());
|
||||
AnimationClips.Add(clip);
|
||||
}
|
||||
}
|
||||
|
||||
await awaitCaller.NextFrame();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AnimationClips を AnimationComponent に載せる
|
||||
/// </summary>
|
||||
protected virtual async Task SetupAnimationsAsync(IAwaitCaller awaitCaller)
|
||||
{
|
||||
if (AnimationClips.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var animation = Root.AddComponent<Animation>();
|
||||
for (int i = 0; i < AnimationClips.Count; ++i)
|
||||
{
|
||||
var clip = AnimationClips[i];
|
||||
animation.AddClip(clip, clip.name);
|
||||
if (i == 0)
|
||||
{
|
||||
animation.clip = clip;
|
||||
}
|
||||
}
|
||||
await awaitCaller.NextFrame();
|
||||
}
|
||||
|
||||
protected virtual async Task LoadGeometryAsync(IAwaitCaller awaitCaller, Func<string, IDisposable> MeasureTime)
|
||||
{
|
||||
var inverter = InvertAxis.Create();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace UniVRM10
|
|||
[SerializeField, Range(0, 0.5f), Header("Collision")]
|
||||
public float m_jointRadius = 0.02f;
|
||||
|
||||
SpringBoneLogic m_logic;
|
||||
SpringBoneLogic m_logic = null;
|
||||
|
||||
public void DrawGizmo(Transform center, Color color)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ namespace UniVRM10
|
|||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
dst = null;
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user