mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-26 21:04:14 -05:00
rename IStorage to IUrlGetter
This commit is contained in:
@@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public interface IStorage
|
||||
public interface IUrlGetter
|
||||
{
|
||||
ArraySegment<Byte> Get(string url = default);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e3316b83a7396047839d12538e5db52
|
||||
guid: aed87db763d65564e96f23fc8bebd382
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -9,9 +9,9 @@ namespace UniGLTF
|
||||
IBytesBuffer m_buffer;
|
||||
public IBytesBuffer Buffer => m_buffer;
|
||||
|
||||
public void OpenStorage(IStorage storage)
|
||||
public void OpenStorage(IUrlGetter urlGetter)
|
||||
{
|
||||
m_buffer = new ArraySegmentByteBuffer(storage.Get(uri));
|
||||
m_buffer = new ArraySegmentByteBuffer(urlGetter.Get(uri));
|
||||
}
|
||||
|
||||
public glTFBuffer()
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.IO;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public class SimpleStorage : IStorage
|
||||
public class SimpleStorage : IUrlGetter
|
||||
{
|
||||
ArraySegment<Byte> m_bytes;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace UniGLTF
|
||||
}
|
||||
}
|
||||
|
||||
public class FileSystemStorage : IStorage
|
||||
public class FileSystemStorage : IUrlGetter
|
||||
{
|
||||
string m_root;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace UniGLTF
|
||||
}
|
||||
}
|
||||
|
||||
public class GltfStorage : IStorage
|
||||
public class GltfStorage : IUrlGetter
|
||||
{
|
||||
glTF _gltf;
|
||||
|
||||
|
||||
@@ -50,40 +50,40 @@ namespace UniGLTF
|
||||
/// <summary>
|
||||
/// URI access
|
||||
/// </summary>
|
||||
IStorage _storage;
|
||||
IUrlGetter _urlGetter;
|
||||
|
||||
/// <summary>
|
||||
/// Migration Flags used by ImporterContext
|
||||
/// </summary>
|
||||
public MigrationFlags MigrationFlags { get; }
|
||||
|
||||
public GltfData(string targetPath, string json, glTF gltf, IReadOnlyList<GlbChunk> chunks, IStorage storage, MigrationFlags migrationFlags)
|
||||
public GltfData(string targetPath, string json, glTF gltf, IReadOnlyList<GlbChunk> chunks, IUrlGetter urlGetter, MigrationFlags migrationFlags)
|
||||
{
|
||||
TargetPath = targetPath;
|
||||
Json = json;
|
||||
GLTF = gltf;
|
||||
Chunks = chunks;
|
||||
_storage = storage;
|
||||
_urlGetter = urlGetter;
|
||||
MigrationFlags = migrationFlags;
|
||||
}
|
||||
|
||||
public static GltfData CreateFromGltfDataForTest(glTF gltf, ArraySegment<byte> bytes = default)
|
||||
{
|
||||
IStorage storage = null;
|
||||
IUrlGetter urlGetter = null;
|
||||
if (bytes.Array != null)
|
||||
{
|
||||
storage = new SimpleStorage(bytes);
|
||||
urlGetter = new SimpleStorage(bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
storage = new GltfStorage(gltf);
|
||||
urlGetter = new GltfStorage(gltf);
|
||||
}
|
||||
return new GltfData(
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
gltf,
|
||||
new List<GlbChunk>(),
|
||||
storage,
|
||||
urlGetter,
|
||||
new MigrationFlags()
|
||||
);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ namespace UniGLTF
|
||||
{
|
||||
// TODO:
|
||||
var buffer = GLTF.buffers[bufferIndex];
|
||||
return _storage.Get(buffer.uri);
|
||||
return _urlGetter.Get(buffer.uri);
|
||||
}
|
||||
|
||||
public ArraySegment<Byte> GetViewBytes(int bufferView)
|
||||
@@ -266,7 +266,7 @@ namespace UniGLTF
|
||||
}
|
||||
else
|
||||
{
|
||||
return _storage.Get(image.uri);
|
||||
return _urlGetter.Get(image.uri);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace UniGLTF
|
||||
return chunks;
|
||||
}
|
||||
|
||||
public static GltfData ParseGltf(string path, string json, IReadOnlyList<GlbChunk> chunks, IStorage storage, MigrationFlags migrationFlags)
|
||||
public static GltfData ParseGltf(string path, string json, IReadOnlyList<GlbChunk> chunks, IUrlGetter urlGetter, MigrationFlags migrationFlags)
|
||||
{
|
||||
var GLTF = GltfDeserializer.Deserialize(json.ParseAsJson());
|
||||
if (GLTF.asset.version != "2.0")
|
||||
@@ -96,10 +96,10 @@ namespace UniGLTF
|
||||
//GLTF.baseDir = System.IO.Path.GetDirectoryName(Path);
|
||||
foreach (var buffer in GLTF.buffers)
|
||||
{
|
||||
buffer.OpenStorage(storage);
|
||||
buffer.OpenStorage(urlGetter);
|
||||
}
|
||||
|
||||
return new GltfData(path, json, GLTF, chunks, storage, migrationFlags);
|
||||
return new GltfData(path, json, GLTF, chunks, urlGetter, migrationFlags);
|
||||
}
|
||||
|
||||
private static void FixMeshNameUnique(glTF GLTF)
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace UniGLTF
|
||||
public sealed class JsonWithStorageParser
|
||||
{
|
||||
private readonly string _json;
|
||||
private readonly IStorage _storage;
|
||||
|
||||
public JsonWithStorageParser(string json, IStorage storage = null)
|
||||
private readonly IUrlGetter _storage;
|
||||
|
||||
public JsonWithStorageParser(string json, IUrlGetter urlGetter = null)
|
||||
{
|
||||
_json = json;
|
||||
_storage = storage ?? new SimpleStorage(new ArraySegment<byte>());
|
||||
_storage = urlGetter ?? new SimpleStorage(new ArraySegment<byte>());
|
||||
}
|
||||
|
||||
public GltfData Parse()
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace UniGLTF.Zip
|
||||
}
|
||||
}
|
||||
|
||||
class ZipArchiveStorage : IStorage
|
||||
class ZipArchiveStorage : IUrlGetter
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user