public ModelRoot LoadModel(string gltfFile, ReadSettings settings = null) { var context = ReadContext .Create(_ReadAsset) .WithSettingsFrom(settings); return(context.ReadSchema2(gltfFile)); }
private (SCHEMA2 Model, Validation.ValidationResult Validation) _ReadGLB(Stream stream) { Guard.NotNull(stream, nameof(stream)); var chunks = BinarySerialization.ReadBinaryFile(stream); var context = this; if (chunks.ContainsKey(BinarySerialization.CHUNKBIN)) { context = new ReadContext(context); // clone instance context._BinaryChunk = chunks[BinarySerialization.CHUNKBIN]; } var jsonChunk = chunks[BinarySerialization.CHUNKJSON]; return(context._Read(new BYTES(jsonChunk))); }
private ModelRoot _LoadGltf2(string gltfFile, ReadSettings settings = null) { var context = ReadContext .Create(_ReadAsset) .WithSettingsFrom(settings); using (var m = new System.IO.MemoryStream()) { using (var s = _Archive.GetEntry(gltfFile).Open()) { s.CopyTo(m); } m.Position = 0; return(context.ReadSchema2(m)); } }
private (SCHEMA2 Model, Validation.ValidationResult Validation) _ReadGLB(Stream stream) { Guard.NotNull(stream, nameof(stream)); var chunks = glb.ReadBinaryFile(stream); var dom = Encoding.UTF8.GetString(chunks[glb.CHUNKJSON]); var context = this; if (chunks.ContainsKey(glb.CHUNKBIN)) { context = new ReadContext(context); // clone instance context._BinaryChunk = chunks[glb.CHUNKBIN]; } return(context._ParseGLTF(dom)); }
private (SCHEMA2 Model, Validation.ValidationResult Validation) _ReadGLB(Stream stream) { Guard.NotNull(stream, nameof(stream)); IReadOnlyDictionary <uint, byte[]> chunks; try { chunks = BinarySerialization.ReadBinaryFile(stream); } catch (System.IO.EndOfStreamException ex) { var vr = new Validation.ValidationResult(null, this.Validation); vr.SetError(new Validation.SchemaException(null, ex.Message)); return(null, vr); } catch (Validation.SchemaException ex) { var vr = new Validation.ValidationResult(null, this.Validation); vr.SetError(ex); return(null, vr); } var context = this; if (chunks.ContainsKey(BinarySerialization.CHUNKBIN)) { // clone self var binChunk = chunks[BinarySerialization.CHUNKBIN]; context = new ReadContext(context); context._BinaryChunk = binChunk; } var jsonChunk = chunks[BinarySerialization.CHUNKJSON]; return(context._Read(jsonChunk)); }
internal ReadContext(ReadContext other) : base(other) { this._FileReader = other._FileReader; this.ImageDecoder = other.ImageDecoder; }