private Gltf InitializeGlTF() { var gltf = new Gltf(); var asset = new Asset(); asset.Version = "2.0"; asset.Generator = "hypar-gltf"; gltf.Asset = asset; var root = new Node(); // root.Matrix = new float[]{1.0f,0.0f,0.0f,0.0f, // 0.0f,0.0f,-1.0f,0.0f, // 0.0f,1.0f,0.0f,0.0f, // 0.0f,0.0f,0.0f,1.0f}; root.Translation = new[] { 0.0f, 0.0f, 0.0f }; root.Scale = new[] { 1.0f, 1.0f, 1.0f }; // Set Z up by rotating -90d around the X Axis var q = new Quaternion(new Vector3(1, 0, 0), -Math.PI / 2); root.Rotation = new[] { (float)q.X, (float)q.Y, (float)q.Z, (float)q.W }; gltf.Nodes = new[] { root }; gltf.Scene = 0; var scene = new Scene(); scene.Nodes = new[] { 0 }; gltf.Scenes = new[] { scene }; gltf.ExtensionsUsed = new[] { "KHR_materials_pbrSpecularGlossiness" }; var materials = new Dictionary <string, int>(); foreach (var kvp in this._materials) { var m = kvp.Value; var mId = gltf.AddMaterial(m.Name, m.Color.Red, m.Color.Green, m.Color.Blue, m.Color.Alpha, m.SpecularFactor, m.GlossinessFactor); materials.Add(m.Name, mId); } foreach (var kvp in this._elements) { var e = kvp.Value; GetRenderDataForElement(e, gltf, materials); } var buff = new glTFLoader.Schema.Buffer(); buff.ByteLength = _buffer.Count(); gltf.Buffers = new[] { buff }; return(gltf); }