mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-21 02:07:58 -05:00
35 lines
872 B
C#
35 lines
872 B
C#
using System;
|
|
using UniGLTF;
|
|
using UniJSON;
|
|
|
|
namespace UniVRM10
|
|
{
|
|
public class Vrm10ExportData : ExportingGltfData
|
|
{
|
|
public void Reserve(int bytesLength)
|
|
{
|
|
_buffer.ExtendCapacity(bytesLength);
|
|
}
|
|
|
|
public int AppendToBuffer(ArraySegment<byte> segment)
|
|
{
|
|
var gltfBufferView = _buffer.Extend(segment);
|
|
var viewIndex = GLTF.bufferViews.Count;
|
|
GLTF.bufferViews.Add(gltfBufferView);
|
|
return viewIndex;
|
|
}
|
|
|
|
public byte[] ToBytes()
|
|
{
|
|
GLTF.buffers[0].byteLength = _buffer.Bytes.Count;
|
|
|
|
var f = new JsonFormatter();
|
|
UniGLTF.GltfSerializer.Serialize(f, GLTF);
|
|
var json = f.GetStoreBytes();
|
|
|
|
var glb = UniGLTF.Glb.Create(json, _buffer.Bytes);
|
|
return glb.ToBytes();
|
|
}
|
|
}
|
|
}
|