public void Write(string name, WriteSettings settings) { if (settings.BinaryMode) { var ex = glb.IsBinaryCompatible(this); if (ex != null) { throw ex; } for (int i = 0; i < this._buffers.Count; ++i) { var buffer = this._buffers[i]; buffer._WriteToInternal(); } } else { for (int i = 0; i < this._buffers.Count; ++i) { var buffer = this._buffers[i]; var bname = $"{name}.{i}.bin"; buffer._WriteToExternal(bname, settings.FileWriter); } } for (int i = 0; i < this._images.Count; ++i) { var image = this._images[i]; var iname = $"{name}.{i}"; if (settings.EmbedImages) { image._EmbedAssets(); } else { image._WriteExternalAssets(iname, settings.FileWriter); } } using (var m = new MemoryStream()) { if (settings.BinaryMode) { using (var w = new BinaryWriter(m)) { glb.WriteBinaryModel(w, this); } settings.FileWriter($"{name}.glb", m.ToArray()); } else { using (var w = new StreamWriter(m)) { WriteJSON(w, settings.JSonFormatting); } settings.FileWriter($"{name}.gltf", m.ToArray()); } } foreach (var b in this._buffers) { b._ClearAfterWrite(); } foreach (var i in this._images) { i._ClearAfterWrite(); } }