public ResourcesStore(Types.Gltf gltf, Glb.StoredBuffer buffer, IResourceLoader loader) { Gltf = gltf; Buffer = buffer; Loader = loader; }
public static GltfContainer ReadAsContainer(Stream s) { using (var r = new Reader(s)) { var h = r.ReadHeader(); if (h.Magic != 0x46546C67) // glTF Header { throw new NotImplementedException(); // TODO: change types } if (h.Version != 2) { throw new NotImplementedException(); // TODO: change types } Types.Gltf gltf = null; StoredBuffer buffer = null; for (var i = 0; ; ++i) { var c = r.ReadChunk(); if (c == null) { break; } switch (c.ChunkType) { case 0x4E4F534A: // JSON if (i != 0) { // JSON chunk must be the first chunk throw new NotImplementedException("Json"); // TODO: change type } if (gltf != null) { // Duplicated throw new NotImplementedException("Json"); // TODO: change type } using (var cs = new MemoryStream(c.ChunkData)) { gltf = GltfReader.Read(cs); } break; case 0x004E4942: // BIN if (i != 1) { // Binary buffer chunk must be the second chunk throw new NotImplementedException("BinaryBuffer"); // TODO: change type } if (buffer != null) { // Duplicated throw new NotImplementedException("BinaryBuffer"); // TODO: change type } buffer = new StoredBuffer { Payload = new ArraySegment <byte>(c.ChunkData), }; break; default: // Ignore continue; } } if (gltf == null) { throw new NotImplementedException("Json is empty"); // TODO: change type } return(new GltfContainer(gltf, buffer)); } }
public static GltfContainer FromGltf(Stream s, Glb.StoredBuffer buffer = null) { var gltf = GltfReader.Read(s); return(new GltfContainer(gltf, buffer)); }
public GltfContainer(Types.Gltf gltf, Glb.StoredBuffer buffer = null) { Gltf = gltf; Buffer = buffer; }