mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-07-19 16:51:55 -05:00
Implement data: uri dispatch
This commit is contained in:
parent
fecbf3f0de
commit
4f7043ffdd
|
|
@ -107,13 +107,28 @@ namespace UniGLTF
|
|||
);
|
||||
}
|
||||
|
||||
Dictionary<string, ArraySegment<byte>> _dataCache = new Dictionary<string, ArraySegment<byte>>();
|
||||
|
||||
public ArraySegment<Byte> GetBytesFromUri(string uri)
|
||||
{
|
||||
if (string.IsNullOrEmpty(uri))
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
return _storage.Get(uri);
|
||||
if (uri.StartsWith("data:", StringComparison.Ordinal))
|
||||
{
|
||||
if (_dataCache.TryGetValue(uri, out ArraySegment<byte> data))
|
||||
{
|
||||
return data;
|
||||
}
|
||||
data = new ArraySegment<byte>(UriByteBuffer.ReadEmbedded(uri));
|
||||
_dataCache.Add(uri, data);
|
||||
return data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _storage.Get(uri);
|
||||
}
|
||||
}
|
||||
|
||||
public ArraySegment<Byte> GetBytes(int bufferIndex)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user