diff --git a/Scripts/Format/VRMImporterContext.cs b/Scripts/Format/VRMImporterContext.cs index b4db38236..4e60595bf 100644 --- a/Scripts/Format/VRMImporterContext.cs +++ b/Scripts/Format/VRMImporterContext.cs @@ -1,11 +1,11 @@ -using DepthFirstScheduler; -using System; +using System; using System.Linq; using System.Collections.Generic; using UniGLTF; using UnityEngine; using System.IO; + namespace VRM { public class VRMImporterContext : ImporterContext @@ -32,109 +32,14 @@ namespace VRM } } - public override void Load() + public override void ParseJson(string json, IStorage storage) { + base.ParseJson(json, storage); SetMaterialImporter(new VRMMaterialImporter(this, glTF_VRM_Material.Parse(Json))); - base.Load(); - OnLoadModel(); - } - - protected override Schedulable LoadAsync() - { - return Schedulable.Create() - .AddTask(Scheduler.ThreadPool, () => - { - using (MeasureTime("glTF_VRM_Material.Parse")) - { - return glTF_VRM_Material.Parse(Json); - } - }) - .ContinueWith(Scheduler.MainThread, gltfMaterials => - { - using (MeasureTime("new VRMMaterialImporter")) - { - SetMaterialImporter(new VRMMaterialImporter(this, gltfMaterials)); - } - }) - .OnExecute(Scheduler.ThreadPool, parent => - { - // textures - for (int i = 0; i < GLTF.textures.Count; ++i) - { - var index = i; - parent.AddTask(Scheduler.MainThread, - () => - { - using (MeasureTime("texture.Process")) - { - var texture = new TextureItem(index); - texture.Process(GLTF, Storage); - return texture; - } - }) - .ContinueWith(Scheduler.ThreadPool, x => AddTexture(x)); - } - }) - .ContinueWithCoroutine(Scheduler.MainThread, () => LoadMaterials()) - .OnExecute(Scheduler.ThreadPool, parent => - { - // meshes - var meshImporter = new MeshImporter(); - for (int i = 0; i < GLTF.meshes.Count; ++i) - { - var index = i; - parent.AddTask(Scheduler.ThreadPool, - () => - { - using (MeasureTime("ReadMesh")) - { - return meshImporter.ReadMesh(this, index); - } - }) - .ContinueWith(Scheduler.MainThread, x => - { - using (MeasureTime("BuildMesh")) - { - return MeshImporter.BuildMesh(this, x); - } - }) - .ContinueWith(Scheduler.ThreadPool, x => Meshes.Add(x)) - ; - } - }) - .ContinueWithCoroutine(Scheduler.MainThread, () => - { - using (MeasureTime("LoadNodes")) - { - return LoadNodes(); - } - }) - .ContinueWithCoroutine(Scheduler.MainThread, () => - { - using (MeasureTime("BuildHierarchy")) - { - return BuildHierarchy(); - } - }) - .ContinueWith(Scheduler.CurrentThread, _ => - { - //using (MeasureTime("OnLoadModel")) - { - OnLoadModel(); - return Unit.Default; - } - }) - .ContinueWith(Scheduler.CurrentThread, - _ => - { - Root.name = "VRM"; - Debug.Log(GetSpeedLog()); - return Unit.Default; - }); } #region OnLoad - void OnLoadModel() + protected override void OnLoadModel() { using (MeasureTime("VRM LoadMeta")) { @@ -159,6 +64,9 @@ namespace VRM { LoadFirstPerson(); } + + Root.name = "VRM"; + Debug.Log(GetSpeedLog()); } void LoadMeta() diff --git a/UniGLTF b/UniGLTF index 1f5c39ac5..e5456784e 160000 --- a/UniGLTF +++ b/UniGLTF @@ -1 +1 @@ -Subproject commit 1f5c39ac527d8250af2b9d8c05eacdd33a77388f +Subproject commit e5456784e5bd11974f49f927d8b47d4787eddcaf