mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-12 05:48:47 -05:00
fix api ussage. remove dataChunk arguments
This commit is contained in:
@@ -61,7 +61,7 @@ public class VRMTest
|
||||
// import
|
||||
context.Json = gltf.ToJson();
|
||||
Debug.LogFormat("{0}", context.Json);
|
||||
gltfImporter.Import<glTF>(context, new ArraySegment<byte>());
|
||||
gltfImporter.Import<glTF>(context);
|
||||
|
||||
AssertAreEqual(go.transform, context.Root.transform);
|
||||
}
|
||||
|
||||
@@ -18,30 +18,30 @@ namespace VRM
|
||||
public static GameObject LoadFromPath(string path)
|
||||
{
|
||||
var context = new VRMImporterContext(path);
|
||||
var dataChunk = context.ParseVrm(File.ReadAllBytes(path));
|
||||
LoadFromBytes(context, dataChunk);
|
||||
context.ParseVrm(File.ReadAllBytes(path));
|
||||
LoadFromBytes(context);
|
||||
return context.Root;
|
||||
}
|
||||
|
||||
public static GameObject LoadFromBytes(Byte[] bytes)
|
||||
{
|
||||
var context = new VRMImporterContext();
|
||||
var dataChunk = context.ParseVrm(bytes);
|
||||
LoadFromBytes(context, dataChunk);
|
||||
context.ParseVrm(bytes);
|
||||
LoadFromBytes(context);
|
||||
return context.Root;
|
||||
}
|
||||
|
||||
public static void LoadFromPath(VRMImporterContext context)
|
||||
{
|
||||
var dataChunk = context.ParseVrm(File.ReadAllBytes(context.Path));
|
||||
LoadFromBytes(context, dataChunk);
|
||||
context.ParseVrm(File.ReadAllBytes(context.Path));
|
||||
LoadFromBytes(context);
|
||||
}
|
||||
|
||||
public static void LoadFromBytes(VRMImporterContext context, ArraySegment<byte> dataChunk)
|
||||
public static void LoadFromBytes(VRMImporterContext context)
|
||||
{
|
||||
context.CreateMaterial = VRMImporter.GetMaterialFunc(glTF_VRM_Material.Parse(context.Json));
|
||||
|
||||
gltfImporter.Import<glTF_VRM>(context, dataChunk);
|
||||
gltfImporter.Import<glTF_VRM>(context);
|
||||
if (string.IsNullOrEmpty(context.Path))
|
||||
{
|
||||
if (string.IsNullOrEmpty(context.VRM.extensions.VRM.meta.title))
|
||||
@@ -526,18 +526,18 @@ namespace VRM
|
||||
public static void LoadVrmAsync(string path, Action<GameObject> onLoaded)
|
||||
{
|
||||
var context = new VRMImporterContext(path);
|
||||
var dataChunk = context.ParseVrm(File.ReadAllBytes(path));
|
||||
LoadVrmAsync(context, dataChunk, onLoaded);
|
||||
context.ParseVrm(File.ReadAllBytes(path));
|
||||
LoadVrmAsync(context, onLoaded);
|
||||
}
|
||||
|
||||
public static void LoadVrmAsync(Byte[] bytes, Action<GameObject> onLoaded)
|
||||
{
|
||||
var context = new VRMImporterContext();
|
||||
var dataChunk = context.ParseVrm(bytes);
|
||||
LoadVrmAsync(context, dataChunk, onLoaded);
|
||||
context.ParseVrm(bytes);
|
||||
LoadVrmAsync(context, onLoaded);
|
||||
}
|
||||
|
||||
public static void LoadVrmAsync(VRMImporterContext ctx, ArraySegment<Byte> chunkData, Action<GameObject> onLoaded)
|
||||
public static void LoadVrmAsync(VRMImporterContext ctx, Action<GameObject> onLoaded)
|
||||
{
|
||||
var schedulable = Schedulable.Create();
|
||||
|
||||
@@ -545,10 +545,6 @@ namespace VRM
|
||||
.AddTask(Scheduler.ThreadPool, () =>
|
||||
{
|
||||
ctx.GLTF.baseDir = Path.GetDirectoryName(ctx.Path);
|
||||
foreach (var buffer in ctx.GLTF.buffers)
|
||||
{
|
||||
buffer.OpenStorage(ctx.GLTF.baseDir, chunkData);
|
||||
}
|
||||
return Unit.Default;
|
||||
})
|
||||
.ContinueWith(Scheduler.ThreadPool, _ =>
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace VRM
|
||||
}
|
||||
}
|
||||
|
||||
public System.ArraySegment<byte> ParseVrm(byte[] bytes)
|
||||
public void ParseVrm(byte[] bytes)
|
||||
{
|
||||
return ParseGlb<glTF_VRM>(bytes);
|
||||
ParseGlb<glTF_VRM>(bytes);
|
||||
}
|
||||
|
||||
public VRMMetaObject ReadMeta()
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace VRM
|
||||
var context = new VRMImporterContext(path);
|
||||
|
||||
// GLB形式でJSONを取得しParseします
|
||||
var dataChunk = context.ParseVrm(bytes);
|
||||
context.ParseVrm(bytes);
|
||||
|
||||
|
||||
// metaを取得(todo: thumbnailテクスチャのロード)
|
||||
@@ -99,11 +99,11 @@ namespace VRM
|
||||
// ParseしたJSONをシーンオブジェクトに変換していく
|
||||
if (m_loadAsync)
|
||||
{
|
||||
LoadAsync(context, dataChunk);
|
||||
LoadAsync(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
VRMImporter.LoadFromBytes(context, dataChunk);
|
||||
VRMImporter.LoadFromBytes(context);
|
||||
OnLoaded(context.Root);
|
||||
}
|
||||
}
|
||||
@@ -154,11 +154,11 @@ namespace VRM
|
||||
}
|
||||
|
||||
|
||||
void LoadAsync(VRMImporterContext context, ArraySegment<byte> dataChunk)
|
||||
void LoadAsync(VRMImporterContext context)
|
||||
{
|
||||
#if true
|
||||
var now = Time.time;
|
||||
VRMImporter.LoadVrmAsync(context, dataChunk, go=> {
|
||||
VRMImporter.LoadVrmAsync(context, go=> {
|
||||
var delta = Time.time - now;
|
||||
Debug.LogFormat("LoadVrmAsync {0:0.0} seconds", delta);
|
||||
OnLoaded(go);
|
||||
|
||||
Reference in New Issue
Block a user