Vicente Penades 6 роки тому
батько
коміт
6ead418e4a
36 змінених файлів з 306 додано та 372 видалено
  1. 1 1
      src/glTF2Sharp.CodeGen/PersistentSchema.EmitCSharp.cs
  2. 14 15
      src/glTF2Sharp.DOM/Collections/ChildrenCollection.cs
  3. 4 5
      src/glTF2Sharp.DOM/Collections/LinqDictionary.cs
  4. 3 2
      src/glTF2Sharp.DOM/Collections/ReferenceComparer.cs
  5. 5 3
      src/glTF2Sharp.DOM/Collections/SingleChild.cs
  6. 21 1
      src/glTF2Sharp.DOM/Debug/DebugViews.cs
  7. 17 20
      src/glTF2Sharp.DOM/Debug/Guard.cs
  8. 1 0
      src/glTF2Sharp.DOM/IO/JsonSerializable.cs
  9. 2 2
      src/glTF2Sharp.DOM/IO/Serialization.cs
  10. 18 11
      src/glTF2Sharp.DOM/Memory/ByteArrayAccessors.cs
  11. 1 1
      src/glTF2Sharp.DOM/ModelException.cs
  12. 1 1
      src/glTF2Sharp.DOM/Schema2/Generated/ext.Unlit.g.cs
  13. 1 1
      src/glTF2Sharp.DOM/Schema2/Generated/ext.pbrSpecularGlossiness.g.cs
  14. 29 29
      src/glTF2Sharp.DOM/Schema2/Generated/gltf.g.cs
  15. 2 2
      src/glTF2Sharp.DOM/Schema2/glb.cs
  16. 32 79
      src/glTF2Sharp.DOM/Schema2/gltf.Accessors.cs
  17. 4 4
      src/glTF2Sharp.DOM/Schema2/gltf.Animations.cs
  18. 6 6
      src/glTF2Sharp.DOM/Schema2/gltf.Buffer.cs
  19. 17 50
      src/glTF2Sharp.DOM/Schema2/gltf.BufferView.cs
  20. 28 0
      src/glTF2Sharp.DOM/Schema2/gltf.Camera.cs
  21. 2 4
      src/glTF2Sharp.DOM/Schema2/gltf.Extensions.cs
  22. 16 7
      src/glTF2Sharp.DOM/Schema2/gltf.LogicalChildOfRoot.cs
  23. 4 8
      src/glTF2Sharp.DOM/Schema2/gltf.Materials.cs
  24. 1 1
      src/glTF2Sharp.DOM/Schema2/gltf.Mesh.cs
  25. 11 15
      src/glTF2Sharp.DOM/Schema2/gltf.MeshPrimitive.cs
  26. 2 4
      src/glTF2Sharp.DOM/Schema2/gltf.Property.cs
  27. 19 41
      src/glTF2Sharp.DOM/Schema2/gltf.Root.cs
  28. 13 16
      src/glTF2Sharp.DOM/Schema2/gltf.Scene.cs
  29. 5 5
      src/glTF2Sharp.DOM/Schema2/gltf.Serialization.cs
  30. 5 7
      src/glTF2Sharp.DOM/Schema2/gltf.Skin.cs
  31. 3 5
      src/glTF2Sharp.DOM/Schema2/gltf.Textures.cs
  32. 2 2
      src/glTF2Sharp.DOM/Transforms/BoundingBox.cs
  33. 2 3
      src/glTF2Sharp.DOM/_Extensions.cs
  34. 2 2
      src/glTF2Sharp.DOM/glTF2Sharp.DOM.csproj
  35. 0 8
      src/glTF2Sharp.Tests/GitUtils.cs
  36. 12 11
      src/glTF2Sharp.Tests/Schema2/CreateModelTests.cs

+ 1 - 1
src/glTF2Sharp.CodeGen/PersistentSchema.EmitCSharp.cs

@@ -564,7 +564,7 @@ namespace Epsylon.glTF2Toolkit.CodeGen
 
 
             yield return "protected override void DeserializeProperty(JsonReader reader, string property)".Indent(1);
             yield return "protected override void DeserializeProperty(JsonReader reader, string property)".Indent(1);
             yield return "{".Indent(1);
             yield return "{".Indent(1);
-            yield return "switch(property)".Indent(2);
+            yield return "switch (property)".Indent(2);
             yield return "{".Indent(2);
             yield return "{".Indent(2);
 
 
             foreach (var l in _DeserializerSwitchBody.Indent(3)) yield return l;
             foreach (var l in _DeserializerSwitchBody.Indent(3)) yield return l;

+ 14 - 15
src/glTF2Sharp.DOM/Collections/ChildrenCollection.cs

@@ -9,9 +9,9 @@ namespace glTF2Sharp.Collections
     [System.Diagnostics.DebuggerDisplay("{Count}")]
     [System.Diagnostics.DebuggerDisplay("{Count}")]
     [System.Diagnostics.DebuggerTypeProxy(typeof(Debug._CollectionDebugView<>))]
     [System.Diagnostics.DebuggerTypeProxy(typeof(Debug._CollectionDebugView<>))]
     [Serializable]
     [Serializable]
-    sealed class ChildrenCollection<T,TParent> : IList<T> , IReadOnlyList<T>
-        where T: class, IChildOf<TParent>
-        where TParent:class
+    sealed class ChildrenCollection<T, TParent> : IList<T>, IReadOnlyList<T>
+        where T : class, IChildOf<TParent>
+        where TParent : class
     {
     {
         #region lifecycle
         #region lifecycle
 
 
@@ -38,15 +38,16 @@ namespace glTF2Sharp.Collections
         public T this[int index]
         public T this[int index]
         {
         {
             get
             get
-            {                
+            {
                 if (_Collection == null) throw new ArgumentOutOfRangeException(nameof(index));
                 if (_Collection == null) throw new ArgumentOutOfRangeException(nameof(index));
                 return _Collection[index];
                 return _Collection[index];
             }
             }
+
             set
             set
             {
             {
                 // new value must be an orphan
                 // new value must be an orphan
                 Guard.NotNull(value, nameof(value));
                 Guard.NotNull(value, nameof(value));
-                Guard.MustBeNull(value.LogicalParent, nameof(value.LogicalParent));                
+                Guard.MustBeNull(value.LogicalParent, nameof(value.LogicalParent));
 
 
                 if (_Collection == null) throw new ArgumentOutOfRangeException(nameof(index));
                 if (_Collection == null) throw new ArgumentOutOfRangeException(nameof(index));
 
 
@@ -56,11 +57,9 @@ namespace glTF2Sharp.Collections
                 if (_Collection[index] != null) { _Collection[index]._SetLogicalParent(null); }
                 if (_Collection[index] != null) { _Collection[index]._SetLogicalParent(null); }
                 _Collection[index] = null;
                 _Collection[index] = null;
 
 
-
                 // adopt the new child
                 // adopt the new child
                 _Collection[index] = value;
                 _Collection[index] = value;
                 if (_Collection[index] != null) { _Collection[index]._SetLogicalParent(_Parent); }
                 if (_Collection[index] != null) { _Collection[index]._SetLogicalParent(_Parent); }
-
             }
             }
         }
         }
 
 
@@ -82,14 +81,14 @@ namespace glTF2Sharp.Collections
 
 
             item._SetLogicalParent(_Parent);
             item._SetLogicalParent(_Parent);
 
 
-            _Collection.Add(item);            
+            _Collection.Add(item);
         }
         }
 
 
         public void Clear()
         public void Clear()
         {
         {
             if (_Collection == null) return;
             if (_Collection == null) return;
 
 
-            foreach(var item in _Collection)
+            foreach (var item in _Collection)
             {
             {
                 item._SetLogicalParent(null);
                 item._SetLogicalParent(null);
             }
             }
@@ -106,7 +105,7 @@ namespace glTF2Sharp.Collections
         {
         {
             if (_Collection == null) return;
             if (_Collection == null) return;
             _Collection.CopyTo(array, arrayIndex);
             _Collection.CopyTo(array, arrayIndex);
-        }        
+        }
 
 
         public int IndexOf(T item)
         public int IndexOf(T item)
         {
         {
@@ -132,7 +131,7 @@ namespace glTF2Sharp.Collections
 
 
             RemoveAt(idx);
             RemoveAt(idx);
 
 
-            return true;            
+            return true;
         }
         }
 
 
         public void RemoveAt(int index)
         public void RemoveAt(int index)
@@ -158,8 +157,8 @@ namespace glTF2Sharp.Collections
         }
         }
 
 
         public int Use(T item)
         public int Use(T item)
-        {            
-            Guard.NotNull(item, nameof(item));            
+        {
+            Guard.NotNull(item, nameof(item));
             // in this case we delay the LogicalParent==null check to the "Add" method below
             // in this case we delay the LogicalParent==null check to the "Add" method below
 
 
             var idx = this.IndexOf(item);
             var idx = this.IndexOf(item);
@@ -172,6 +171,6 @@ namespace glTF2Sharp.Collections
             return idx;
             return idx;
         }
         }
 
 
-        #endregion        
-    }    
+        #endregion
+    }
 }
 }

+ 4 - 5
src/glTF2Sharp.DOM/Collections/LinqDictionary.cs

@@ -16,7 +16,7 @@ namespace glTF2Sharp.Collections
     {
     {
         #region lifecycle
         #region lifecycle
 
 
-        public ReadOnlyLinqDictionary(IReadOnlyDictionary<TKey,TValueIn> dict, Func<TValueIn,TValueOut> valConverter)
+        public ReadOnlyLinqDictionary(IReadOnlyDictionary<TKey, TValueIn> dict, Func<TValueIn, TValueOut> valConverter)
         {
         {
             _Source = dict;
             _Source = dict;
             _ValueConverter = valConverter;
             _ValueConverter = valConverter;
@@ -68,7 +68,7 @@ namespace glTF2Sharp.Collections
             return _Source
             return _Source
                 .Select(item => new KeyValuePair<TKey, TValueOut>(item.Key, cvt(item.Value)))
                 .Select(item => new KeyValuePair<TKey, TValueOut>(item.Key, cvt(item.Value)))
                 .GetEnumerator();
                 .GetEnumerator();
-        }        
+        }
 
 
         IEnumerator IEnumerable.GetEnumerator()
         IEnumerator IEnumerable.GetEnumerator()
         {
         {
@@ -81,7 +81,6 @@ namespace glTF2Sharp.Collections
         #endregion
         #endregion
     }
     }
 
 
-
     struct LinqDictionary<TKey, TValueIn, TValueOut> : IDictionary<TKey, TValueOut>
     struct LinqDictionary<TKey, TValueIn, TValueOut> : IDictionary<TKey, TValueOut>
     {
     {
         #region lifecycle
         #region lifecycle
@@ -99,7 +98,7 @@ namespace glTF2Sharp.Collections
 
 
         private readonly IDictionary<TKey, TValueIn> _Source;
         private readonly IDictionary<TKey, TValueIn> _Source;
         private readonly Func<TValueOut, TValueIn> _InConverter;
         private readonly Func<TValueOut, TValueIn> _InConverter;
-        private readonly Func<TValueIn, TValueOut> _OutConverter;        
+        private readonly Func<TValueIn, TValueOut> _OutConverter;
 
 
         #endregion
         #endregion
 
 
@@ -122,7 +121,7 @@ namespace glTF2Sharp.Collections
             }
             }
         }
         }
 
 
-        public int Count => _Source.Count;        
+        public int Count => _Source.Count;
 
 
         public bool IsReadOnly => throw new NotImplementedException();
         public bool IsReadOnly => throw new NotImplementedException();
 
 

+ 3 - 2
src/glTF2Sharp.DOM/Collections/ReferenceComparer.cs

@@ -10,11 +10,12 @@ namespace glTF2Sharp.Collections
     /// bypassing any equality operator implemented by the T class.
     /// bypassing any equality operator implemented by the T class.
     /// </summary>
     /// </summary>
     /// <see cref="https://stackoverflow.com/questions/4901320/is-there-any-kind-of-referencecomparer-in-net"/>
     /// <see cref="https://stackoverflow.com/questions/4901320/is-there-any-kind-of-referencecomparer-in-net"/>
-    sealed class ReferenceComparer<T> : IEqualityComparer<T> where T : class
+    sealed class ReferenceComparer<T> : IEqualityComparer<T>
+        where T : class
     {
     {
         private ReferenceComparer() { }
         private ReferenceComparer() { }
 
 
-        public static readonly ReferenceComparer<T> Instance = new ReferenceComparer<T>();        
+        public static readonly ReferenceComparer<T> Instance = new ReferenceComparer<T>();
 
 
         public bool Equals(T x, T y)
         public bool Equals(T x, T y)
         {
         {

+ 5 - 3
src/glTF2Sharp.DOM/Collections/SingleChild.cs

@@ -32,16 +32,18 @@ namespace glTF2Sharp.Collections
 
 
         public T Value
         public T Value
         {
         {
-            get => _Child;
+            get => this._Child;
             set
             set
             {
             {
-                if (Value == this._Child) return;
+                if (this.Value == this._Child)
+                {
+                    return;
+                }
 
 
                 // orphan the current child
                 // orphan the current child
                 if (this._Child != null) { this._Child._SetLogicalParent(null); }
                 if (this._Child != null) { this._Child._SetLogicalParent(null); }
                 this._Child = null;
                 this._Child = null;
 
 
-
                 // adopt the new child
                 // adopt the new child
                 this._Child = value;
                 this._Child = value;
                 if (this._Child != null) { this._Child._SetLogicalParent(_Parent); }
                 if (this._Child != null) { this._Child._SetLogicalParent(_Parent); }

+ 21 - 1
src/glTF2Sharp.DOM/Debug/CollectionDebugView.cs → src/glTF2Sharp.DOM/Debug/DebugViews.cs

@@ -1,12 +1,13 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Linq;
 using System.Text;
 using System.Text;
 
 
 namespace glTF2Sharp.Debug
 namespace glTF2Sharp.Debug
 {
 {
     /// <summary>
     /// <summary>
     /// class to visualize collection items during debug
     /// class to visualize collection items during debug
-    /// </summary>        
+    /// </summary>
     internal sealed class _CollectionDebugView<T>
     internal sealed class _CollectionDebugView<T>
     {
     {
         // https://referencesource.microsoft.com/#mscorlib/system/collections/generic/debugview.cs,29
         // https://referencesource.microsoft.com/#mscorlib/system/collections/generic/debugview.cs,29
@@ -29,4 +30,23 @@ namespace glTF2Sharp.Debug
             }
             }
         }
         }
     }
     }
+
+    [System.Diagnostics.DebuggerDisplay("BufferView[{_Value.LogicalIndex}] {_Value.Name} {_Value._target} Bytes:{_Value.Buffer1.Count}")]
+    internal sealed class _BufferDebugView
+    {
+        public _BufferDebugView(Schema2.BufferView value) { _Value = value; }
+
+        public int LogicalIndex => _Value.LogicalParent.LogicalBufferViews.IndexOfReference(_Value);
+
+        private readonly Schema2.BufferView _Value;
+
+        public int ByteStride => _Value.ByteStride;
+
+        public int ByteLength => _Value.Data.Count;
+
+        public Schema2.BufferMode? DeviceBufferTarget => _Value.DeviceBufferTarget;
+
+        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
+        public Schema2.Accessor[] Accessors => _Value.Accessors.ToArray();
+    }
 }
 }

+ 17 - 20
src/glTF2Sharp.DOM/Debug/Guard.cs

@@ -28,7 +28,7 @@ namespace glTF2Sharp
             // 2.- Relies on GetFullPath() for path checking
             // 2.- Relies on GetFullPath() for path checking
             // 3.- checks if it is a directory
             // 3.- checks if it is a directory
 
 
-            Guard.NotNullOrEmpty(filePath,parameterName,message);
+            Guard.NotNullOrEmpty(filePath, parameterName, message);
 
 
             filePath = System.IO.Path.GetFullPath(filePath);
             filePath = System.IO.Path.GetFullPath(filePath);
 
 
@@ -57,9 +57,9 @@ namespace glTF2Sharp
 
 
         public static void NotNull(object target, string parameterName, string message = "")
         public static void NotNull(object target, string parameterName, string message = "")
         {
         {
-            if (target != null) return;            
+            if (target != null) return;
             if (string.IsNullOrWhiteSpace(message)) throw new ArgumentNullException(parameterName);
             if (string.IsNullOrWhiteSpace(message)) throw new ArgumentNullException(parameterName);
-            throw new ArgumentNullException(parameterName, message);            
+            throw new ArgumentNullException(parameterName, message);
         }
         }
 
 
         public static void MustBeNull(object target, string parameterName, string message = "")
         public static void MustBeNull(object target, string parameterName, string message = "")
@@ -78,12 +78,12 @@ namespace glTF2Sharp
             NotNull(target, parameterName, message);
             NotNull(target, parameterName, message);
 
 
             if (target.Any()) return;
             if (target.Any()) return;
-            
+
             if (string.IsNullOrWhiteSpace(message)) message = $"{parameterName} cannot be empty.";
             if (string.IsNullOrWhiteSpace(message)) message = $"{parameterName} cannot be empty.";
-            throw new ArgumentException(message, parameterName);            
+            throw new ArgumentException(message, parameterName);
         }
         }
 
 
-        #endregion        
+        #endregion
 
 
         #region comparison
         #region comparison
 
 
@@ -106,9 +106,8 @@ namespace glTF2Sharp
                     where TValue : IComparable<TValue>
                     where TValue : IComparable<TValue>
         {
         {
             if (value.CompareTo(max) < 0) return;
             if (value.CompareTo(max) < 0) return;
-            
+
             throw new ArgumentOutOfRangeException(parameterName, $"{parameterName} {value} must be less than {max}.");
             throw new ArgumentOutOfRangeException(parameterName, $"{parameterName} {value} must be less than {max}.");
-            
         }
         }
 
 
         public static void MustBeLessThanOrEqualTo<TValue>(TValue value, TValue max, string parameterName)
         public static void MustBeLessThanOrEqualTo<TValue>(TValue value, TValue max, string parameterName)
@@ -124,25 +123,24 @@ namespace glTF2Sharp
             where TValue : IComparable<TValue>
             where TValue : IComparable<TValue>
         {
         {
             if (value.CompareTo(min) > 0) return;
             if (value.CompareTo(min) > 0) return;
-            
-            throw new ArgumentOutOfRangeException(parameterName,$"Value {value} must be greater than {min}.");            
+
+            throw new ArgumentOutOfRangeException(parameterName, $"Value {value} must be greater than {min}.");
         }
         }
 
 
         public static void MustBeGreaterThanOrEqualTo<TValue>(TValue value, TValue min, string parameterName)
         public static void MustBeGreaterThanOrEqualTo<TValue>(TValue value, TValue min, string parameterName)
             where TValue : IComparable<TValue>
             where TValue : IComparable<TValue>
         {
         {
             if (value.CompareTo(min) >= 0) return;
             if (value.CompareTo(min) >= 0) return;
-            
-            throw new ArgumentOutOfRangeException(parameterName, $"{parameterName} {value} must be greater than or equal to {min}.");            
+
+            throw new ArgumentOutOfRangeException(parameterName, $"{parameterName} {value} must be greater than or equal to {min}.");
         }
         }
 
 
         public static void MustBeBetweenOrEqualTo<TValue>(TValue value, TValue minInclusive, TValue maxInclusive, string parameterName)
         public static void MustBeBetweenOrEqualTo<TValue>(TValue value, TValue minInclusive, TValue maxInclusive, string parameterName)
             where TValue : IComparable<TValue>
             where TValue : IComparable<TValue>
         {
         {
             if (value.CompareTo(minInclusive) >= 0 || value.CompareTo(maxInclusive) <= 0) return;
             if (value.CompareTo(minInclusive) >= 0 || value.CompareTo(maxInclusive) <= 0) return;
-            
+
             throw new ArgumentOutOfRangeException(parameterName, $"{parameterName} {value} must be greater than or equal to {minInclusive} and less than or equal to {maxInclusive}.");
             throw new ArgumentOutOfRangeException(parameterName, $"{parameterName} {value} must be greater than or equal to {minInclusive} and less than or equal to {maxInclusive}.");
-            
         }
         }
 
 
         #endregion
         #endregion
@@ -152,16 +150,15 @@ namespace glTF2Sharp
         public static void IsTrue(bool target, string parameterName, string message = "")
         public static void IsTrue(bool target, string parameterName, string message = "")
         {
         {
             if (target) return;
             if (target) return;
-            
+
             throw new ArgumentException(message, parameterName);
             throw new ArgumentException(message, parameterName);
-            
         }
         }
 
 
-        public static void IsFalse(bool target, string parameterName, string message ="")
+        public static void IsFalse(bool target, string parameterName, string message = "")
         {
         {
             if (!target) return;
             if (!target) return;
-            
-            throw new ArgumentException(message, parameterName);            
+
+            throw new ArgumentException(message, parameterName);
         }
         }
 
 
         #endregion
         #endregion
@@ -179,7 +176,7 @@ namespace glTF2Sharp
             if (b is null) throw new ArgumentNullException(parameterName);
             if (b is null) throw new ArgumentNullException(parameterName);
 
 
             if (a != b.LogicalParent) throw new ArgumentException("LogicalParent mismatch", parameterName);
             if (a != b.LogicalParent) throw new ArgumentException("LogicalParent mismatch", parameterName);
-        }        
+        }
 
 
         #endregion
         #endregion
     }
     }

+ 1 - 0
src/glTF2Sharp.DOM/IO/JsonSerializable.cs

@@ -196,6 +196,7 @@ namespace glTF2Sharp.IO
                     writer.WritePropertyName(item.Key);
                     writer.WritePropertyName(item.Key);
                     _Serialize(writer, item.Value);
                     _Serialize(writer, item.Value);
                 }
                 }
+
                 writer.WriteEndObject();
                 writer.WriteEndObject();
 
 
                 return;
                 return;

+ 2 - 2
src/glTF2Sharp.DOM/IO/Serialization.cs

@@ -24,13 +24,13 @@ namespace glTF2Sharp.IO
         public static T GetValueAs<T>(this JsonReader reader) where T : struct
         public static T GetValueAs<T>(this JsonReader reader) where T : struct
         {
         {
             return (T)reader.GetValueAs(typeof(T));
             return (T)reader.GetValueAs(typeof(T));
-        }        
+        }
 
 
         public static void WriteVector2(this JsonWriter writer, System.Numerics.Vector2 v)
         public static void WriteVector2(this JsonWriter writer, System.Numerics.Vector2 v)
         {
         {
             writer.WriteStartArray();
             writer.WriteStartArray();
             writer.WriteValue(v.X);
             writer.WriteValue(v.X);
-            writer.WriteValue(v.Y);            
+            writer.WriteValue(v.Y);
             writer.WriteEndArray();
             writer.WriteEndArray();
         }
         }
 
 

+ 18 - 11
src/glTF2Sharp.DOM/Memory/ByteArrayAccessors.cs

@@ -31,7 +31,7 @@ namespace glTF2Sharp.Memory
 
 
             if (normalized)
             if (normalized)
             {
             {
-                switch(type)
+                switch (type)
                 {
                 {
                     case Schema2.ComponentType.BYTE:
                     case Schema2.ComponentType.BYTE:
                         {
                         {
@@ -59,12 +59,12 @@ namespace glTF2Sharp.Memory
                             accessor._Setter = accessor._SetNormalizedU16;
                             accessor._Setter = accessor._SetNormalizedU16;
                             accessor._Getter = accessor._GetNormalizedU16;
                             accessor._Getter = accessor._GetNormalizedU16;
                             return accessor;
                             return accessor;
-                        }                    
+                        }
                 }
                 }
             }
             }
             else
             else
             {
             {
-                switch(type)
+                switch (type)
                 {
                 {
                     case Schema2.ComponentType.BYTE:
                     case Schema2.ComponentType.BYTE:
                         {
                         {
@@ -100,6 +100,9 @@ namespace glTF2Sharp.Memory
                             accessor._Getter = accessor._GetValueU32;
                             accessor._Getter = accessor._GetValueU32;
                             return accessor;
                             return accessor;
                         }
                         }
+
+                    case Schema2.ComponentType.FLOAT:
+                        break;
                 }
                 }
             }
             }
 
 
@@ -124,7 +127,7 @@ namespace glTF2Sharp.Memory
         private Single _GetNormalizedU8(int byteOffset, int index) { return _GetValueU8(byteOffset, index) / 255.0f; }
         private Single _GetNormalizedU8(int byteOffset, int index) { return _GetValueU8(byteOffset, index) / 255.0f; }
         private void _SetNormalizedU8(int byteOffset, int index, Single value) { _SetValueU8(byteOffset, index, value * 255.0f); }
         private void _SetNormalizedU8(int byteOffset, int index, Single value) { _SetValueU8(byteOffset, index, value * 255.0f); }
 
 
-        private Single _GetNormalizedS8(int byteOffset, int index) { return Math.Max(_GetValueS8(byteOffset, index) / 127.0f,-1); }
+        private Single _GetNormalizedS8(int byteOffset, int index) { return Math.Max(_GetValueS8(byteOffset, index) / 127.0f, -1); }
         private void _SetNormalizedS8(int byteOffset, int index, Single value) { _SetValueS8(byteOffset, index, (Single)Math.Round(value * 127.0f)); }
         private void _SetNormalizedS8(int byteOffset, int index, Single value) { _SetValueS8(byteOffset, index, (Single)Math.Round(value * 127.0f)); }
 
 
         private Single _GetNormalizedU16(int byteOffset, int index) { return _GetValueU16(byteOffset, index) / 65535.0f; }
         private Single _GetNormalizedU16(int byteOffset, int index) { return _GetValueU16(byteOffset, index) / 65535.0f; }
@@ -148,6 +151,7 @@ namespace glTF2Sharp.Memory
         #region data
         #region data
 
 
         delegate Single _GetterCallback(int byteOffset, int index);
         delegate Single _GetterCallback(int byteOffset, int index);
+
         delegate void _SetterCallback(int byteOffset, int index, Single value);
         delegate void _SetterCallback(int byteOffset, int index, Single value);
 
 
         private BYTES _Data;
         private BYTES _Data;
@@ -183,11 +187,11 @@ namespace glTF2Sharp.Memory
         public static IntegerAccessor Create(Byte[] data, Schema2.IndexType type)
         public static IntegerAccessor Create(Byte[] data, Schema2.IndexType type)
         {
         {
             return Create(new BYTES(data), type);
             return Create(new BYTES(data), type);
-        }        
+        }
 
 
         public static IntegerAccessor Create(BYTES data, Schema2.IndexType type)
         public static IntegerAccessor Create(BYTES data, Schema2.IndexType type)
         {
         {
-            var accessor = new IntegerAccessor { _Data = data };            
+            var accessor = new IntegerAccessor { _Data = data };
 
 
             switch (type)
             switch (type)
             {
             {
@@ -237,6 +241,7 @@ namespace glTF2Sharp.Memory
         #region data
         #region data
 
 
         delegate UInt32 _GetterCallback(int index);
         delegate UInt32 _GetterCallback(int index);
+
         delegate void _SetterCallback(int index, UInt32 value);
         delegate void _SetterCallback(int index, UInt32 value);
 
 
         private BYTES _Data;
         private BYTES _Data;
@@ -255,7 +260,6 @@ namespace glTF2Sharp.Memory
 
 
         #endregion
         #endregion
     }
     }
-   
 
 
     public interface IWordAccessor
     public interface IWordAccessor
     {
     {
@@ -281,7 +285,7 @@ namespace glTF2Sharp.Memory
             set => _Accesor[index * _ByteStride, 0] = value;
             set => _Accesor[index * _ByteStride, 0] = value;
         }
         }
 
 
-        public System.Numerics.Vector4 GetWord(int index) => new System.Numerics.Vector4(this[index],0,0,0);
+        public System.Numerics.Vector4 GetWord(int index) => new System.Numerics.Vector4(this[index], 0, 0, 0);
 
 
         public void SetWord(int index, in System.Numerics.Vector4 word) => this[index] = word.X;
         public void SetWord(int index, in System.Numerics.Vector4 word) => this[index] = word.X;
     }
     }
@@ -304,6 +308,7 @@ namespace glTF2Sharp.Memory
                 index *= _ByteStride;
                 index *= _ByteStride;
                 return new System.Numerics.Vector2(_Accesor[index, 0], _Accesor[index, 1]);
                 return new System.Numerics.Vector2(_Accesor[index, 0], _Accesor[index, 1]);
             }
             }
+
             set
             set
             {
             {
                 index *= _ByteStride;
                 index *= _ByteStride;
@@ -335,6 +340,7 @@ namespace glTF2Sharp.Memory
                 index *= _ByteStride;
                 index *= _ByteStride;
                 return new System.Numerics.Vector3(_Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2]);
                 return new System.Numerics.Vector3(_Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2]);
             }
             }
+
             set
             set
             {
             {
                 index *= _ByteStride;
                 index *= _ByteStride;
@@ -346,7 +352,7 @@ namespace glTF2Sharp.Memory
 
 
         public System.Numerics.Vector4 GetWord(int index) { var v = this[index]; return new System.Numerics.Vector4(v.X, v.Y, v.Z, 0); }
         public System.Numerics.Vector4 GetWord(int index) { var v = this[index]; return new System.Numerics.Vector4(v.X, v.Y, v.Z, 0); }
 
 
-        public void SetWord(int index, in System.Numerics.Vector4 word) => this[index] = new System.Numerics.Vector3(word.X, word.Y,word.Z);
+        public void SetWord(int index, in System.Numerics.Vector4 word) => this[index] = new System.Numerics.Vector3(word.X, word.Y, word.Z);
     }
     }
 
 
     public struct Vector4Accessor: IWordAccessor
     public struct Vector4Accessor: IWordAccessor
@@ -367,6 +373,7 @@ namespace glTF2Sharp.Memory
                 index *= _ByteStride;
                 index *= _ByteStride;
                 return new System.Numerics.Vector4(_Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2], _Accesor[index, 3]);
                 return new System.Numerics.Vector4(_Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2], _Accesor[index, 3]);
             }
             }
+
             set
             set
             {
             {
                 index *= _ByteStride;
                 index *= _ByteStride;
@@ -400,6 +407,7 @@ namespace glTF2Sharp.Memory
                 index *= _ByteStride;
                 index *= _ByteStride;
                 return new System.Numerics.Quaternion(_Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2], _Accesor[index, 3]);
                 return new System.Numerics.Quaternion(_Accesor[index, 0], _Accesor[index, 1], _Accesor[index, 2], _Accesor[index, 3]);
             }
             }
+
             set
             set
             {
             {
                 index *= _ByteStride;
                 index *= _ByteStride;
@@ -439,6 +447,7 @@ namespace glTF2Sharp.Memory
                     _Accesor[index, 12], _Accesor[index, 13], _Accesor[index, 14], _Accesor[index, 15]
                     _Accesor[index, 12], _Accesor[index, 13], _Accesor[index, 14], _Accesor[index, 15]
                     );
                     );
             }
             }
+
             set
             set
             {
             {
                 index *= _ByteStride;
                 index *= _ByteStride;
@@ -461,6 +470,4 @@ namespace glTF2Sharp.Memory
             }
             }
         }
         }
     }
     }
-
-
 }
 }

+ 1 - 1
src/glTF2Sharp.DOM/ModelException.cs

@@ -16,7 +16,7 @@ namespace glTF2Sharp
             _Target = target;
             _Target = target;
         }
         }
 
 
-        internal ModelException(JsonSerializable target, String message,Action fix, String fixDesc) : base(message)
+        internal ModelException(JsonSerializable target, String message, Action fix, String fixDesc) : base(message)
         {
         {
             _Target = target;
             _Target = target;
             _ProposedFix = fix;
             _ProposedFix = fix;

+ 1 - 1
src/glTF2Sharp.DOM/Schema2/Generated/ext.Unlit.g.cs

@@ -25,7 +25,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				default: base.DeserializeProperty(reader,property); break;
 				default: base.DeserializeProperty(reader,property); break;
 			}
 			}

+ 1 - 1
src/glTF2Sharp.DOM/Schema2/Generated/ext.pbrSpecularGlossiness.g.cs

@@ -45,7 +45,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "diffuseFactor": _diffuseFactor = DeserializeValue<Vector4?>(reader); break;
 				case "diffuseFactor": _diffuseFactor = DeserializeValue<Vector4?>(reader); break;
 				case "diffuseTexture": _diffuseTexture = DeserializeValue<TextureInfo>(reader); break;
 				case "diffuseTexture": _diffuseTexture = DeserializeValue<TextureInfo>(reader); break;

+ 29 - 29
src/glTF2Sharp.DOM/Schema2/Generated/gltf.g.cs

@@ -136,7 +136,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "name": _name = DeserializeValue<String>(reader); break;
 				case "name": _name = DeserializeValue<String>(reader); break;
 				default: base.DeserializeProperty(reader,property); break;
 				default: base.DeserializeProperty(reader,property); break;
@@ -167,7 +167,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "bufferView": _bufferView = DeserializeValue<Int32>(reader); break;
 				case "bufferView": _bufferView = DeserializeValue<Int32>(reader); break;
 				case "byteOffset": _byteOffset = DeserializeValue<Int32?>(reader); break;
 				case "byteOffset": _byteOffset = DeserializeValue<Int32?>(reader); break;
@@ -197,7 +197,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "bufferView": _bufferView = DeserializeValue<Int32>(reader); break;
 				case "bufferView": _bufferView = DeserializeValue<Int32>(reader); break;
 				case "byteOffset": _byteOffset = DeserializeValue<Int32?>(reader); break;
 				case "byteOffset": _byteOffset = DeserializeValue<Int32?>(reader); break;
@@ -228,7 +228,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "count": _count = DeserializeValue<Int32>(reader); break;
 				case "count": _count = DeserializeValue<Int32>(reader); break;
 				case "indices": _indices = DeserializeValue<AccessorSparseIndices>(reader); break;
 				case "indices": _indices = DeserializeValue<AccessorSparseIndices>(reader); break;
@@ -285,7 +285,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "bufferView": _bufferView = DeserializeValue<Int32?>(reader); break;
 				case "bufferView": _bufferView = DeserializeValue<Int32?>(reader); break;
 				case "byteOffset": _byteOffset = DeserializeValue<Int32?>(reader); break;
 				case "byteOffset": _byteOffset = DeserializeValue<Int32?>(reader); break;
@@ -319,7 +319,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "node": _node = DeserializeValue<Int32?>(reader); break;
 				case "node": _node = DeserializeValue<Int32?>(reader); break;
 				case "path": _path = DeserializeValue<PathType>(reader); break;
 				case "path": _path = DeserializeValue<PathType>(reader); break;
@@ -346,7 +346,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "sampler": _sampler = DeserializeValue<Int32>(reader); break;
 				case "sampler": _sampler = DeserializeValue<Int32>(reader); break;
 				case "target": _target = DeserializeValue<AnimationChannelTarget>(reader); break;
 				case "target": _target = DeserializeValue<AnimationChannelTarget>(reader); break;
@@ -377,7 +377,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "input": _input = DeserializeValue<Int32>(reader); break;
 				case "input": _input = DeserializeValue<Int32>(reader); break;
 				case "interpolation": _interpolation = DeserializeValue<AnimationInterpolationMode>(reader); break;
 				case "interpolation": _interpolation = DeserializeValue<AnimationInterpolationMode>(reader); break;
@@ -407,7 +407,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "channels": DeserializeList<AnimationChannel>(reader,_channels); break;
 				case "channels": DeserializeList<AnimationChannel>(reader,_channels); break;
 				case "samplers": DeserializeList<AnimationSampler>(reader,_samplers); break;
 				case "samplers": DeserializeList<AnimationSampler>(reader,_samplers); break;
@@ -440,7 +440,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "copyright": _copyright = DeserializeValue<String>(reader); break;
 				case "copyright": _copyright = DeserializeValue<String>(reader); break;
 				case "generator": _generator = DeserializeValue<String>(reader); break;
 				case "generator": _generator = DeserializeValue<String>(reader); break;
@@ -470,7 +470,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "uri": _uri = DeserializeValue<String>(reader); break;
 				case "uri": _uri = DeserializeValue<String>(reader); break;
 				case "byteLength": _byteLength = DeserializeValue<Int32>(reader); break;
 				case "byteLength": _byteLength = DeserializeValue<Int32>(reader); break;
@@ -511,7 +511,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "buffer": _buffer = DeserializeValue<Int32>(reader); break;
 				case "buffer": _buffer = DeserializeValue<Int32>(reader); break;
 				case "byteOffset": _byteOffset = DeserializeValue<Int32?>(reader); break;
 				case "byteOffset": _byteOffset = DeserializeValue<Int32?>(reader); break;
@@ -549,7 +549,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "xmag": _xmag = DeserializeValue<Double>(reader); break;
 				case "xmag": _xmag = DeserializeValue<Double>(reader); break;
 				case "ymag": _ymag = DeserializeValue<Double>(reader); break;
 				case "ymag": _ymag = DeserializeValue<Double>(reader); break;
@@ -588,7 +588,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "aspectRatio": _aspectRatio = DeserializeValue<Double?>(reader); break;
 				case "aspectRatio": _aspectRatio = DeserializeValue<Double?>(reader); break;
 				case "yfov": _yfov = DeserializeValue<Double>(reader); break;
 				case "yfov": _yfov = DeserializeValue<Double>(reader); break;
@@ -620,7 +620,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "orthographic": _orthographic = DeserializeValue<CameraOrthographic>(reader); break;
 				case "orthographic": _orthographic = DeserializeValue<CameraOrthographic>(reader); break;
 				case "perspective": _perspective = DeserializeValue<CameraPerspective>(reader); break;
 				case "perspective": _perspective = DeserializeValue<CameraPerspective>(reader); break;
@@ -650,7 +650,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "index": _index = DeserializeValue<Int32>(reader); break;
 				case "index": _index = DeserializeValue<Int32>(reader); break;
 				case "texCoord": _texCoord = DeserializeValue<Int32?>(reader); break;
 				case "texCoord": _texCoord = DeserializeValue<Int32?>(reader); break;
@@ -693,7 +693,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "baseColorFactor": _baseColorFactor = DeserializeValue<Vector4?>(reader); break;
 				case "baseColorFactor": _baseColorFactor = DeserializeValue<Vector4?>(reader); break;
 				case "baseColorTexture": _baseColorTexture = DeserializeValue<TextureInfo>(reader); break;
 				case "baseColorTexture": _baseColorTexture = DeserializeValue<TextureInfo>(reader); break;
@@ -721,7 +721,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "scale": _scale = DeserializeValue<Double?>(reader); break;
 				case "scale": _scale = DeserializeValue<Double?>(reader); break;
 				default: base.DeserializeProperty(reader,property); break;
 				default: base.DeserializeProperty(reader,property); break;
@@ -747,7 +747,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "strength": _strength = DeserializeValue<Double?>(reader); break;
 				case "strength": _strength = DeserializeValue<Double?>(reader); break;
 				default: base.DeserializeProperty(reader,property); break;
 				default: base.DeserializeProperty(reader,property); break;
@@ -796,7 +796,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "pbrMetallicRoughness": _pbrMetallicRoughness = DeserializeValue<MaterialPBRMetallicRoughness>(reader); break;
 				case "pbrMetallicRoughness": _pbrMetallicRoughness = DeserializeValue<MaterialPBRMetallicRoughness>(reader); break;
 				case "normalTexture": _normalTexture = DeserializeValue<MaterialNormalTextureInfo>(reader); break;
 				case "normalTexture": _normalTexture = DeserializeValue<MaterialNormalTextureInfo>(reader); break;
@@ -840,7 +840,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "attributes": DeserializeDictionary<Int32>(reader,_attributes); break;
 				case "attributes": DeserializeDictionary<Int32>(reader,_attributes); break;
 				case "indices": _indices = DeserializeValue<Int32?>(reader); break;
 				case "indices": _indices = DeserializeValue<Int32?>(reader); break;
@@ -872,7 +872,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "primitives": DeserializeList<MeshPrimitive>(reader,_primitives); break;
 				case "primitives": DeserializeList<MeshPrimitive>(reader,_primitives); break;
 				case "weights": DeserializeList<Double>(reader,_weights); break;
 				case "weights": DeserializeList<Double>(reader,_weights); break;
@@ -922,7 +922,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "camera": _camera = DeserializeValue<Int32?>(reader); break;
 				case "camera": _camera = DeserializeValue<Int32?>(reader); break;
 				case "children": DeserializeList<Int32>(reader,_children); break;
 				case "children": DeserializeList<Int32>(reader,_children); break;
@@ -964,7 +964,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "magFilter": _magFilter = DeserializeValue<TextureInterpolationMode>(reader); break;
 				case "magFilter": _magFilter = DeserializeValue<TextureInterpolationMode>(reader); break;
 				case "minFilter": _minFilter = DeserializeValue<TextureMipMapMode>(reader); break;
 				case "minFilter": _minFilter = DeserializeValue<TextureMipMapMode>(reader); break;
@@ -991,7 +991,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "nodes": DeserializeList<Int32>(reader,_nodes); break;
 				case "nodes": DeserializeList<Int32>(reader,_nodes); break;
 				default: base.DeserializeProperty(reader,property); break;
 				default: base.DeserializeProperty(reader,property); break;
@@ -1021,7 +1021,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "inverseBindMatrices": _inverseBindMatrices = DeserializeValue<Int32?>(reader); break;
 				case "inverseBindMatrices": _inverseBindMatrices = DeserializeValue<Int32?>(reader); break;
 				case "skeleton": _skeleton = DeserializeValue<Int32?>(reader); break;
 				case "skeleton": _skeleton = DeserializeValue<Int32?>(reader); break;
@@ -1049,7 +1049,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "sampler": _sampler = DeserializeValue<Int32?>(reader); break;
 				case "sampler": _sampler = DeserializeValue<Int32?>(reader); break;
 				case "source": _source = DeserializeValue<Int32?>(reader); break;
 				case "source": _source = DeserializeValue<Int32?>(reader); break;
@@ -1136,7 +1136,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "extensionsUsed": DeserializeList<String>(reader,_extensionsUsed); break;
 				case "extensionsUsed": DeserializeList<String>(reader,_extensionsUsed); break;
 				case "extensionsRequired": DeserializeList<String>(reader,_extensionsRequired); break;
 				case "extensionsRequired": DeserializeList<String>(reader,_extensionsRequired); break;
@@ -1181,7 +1181,7 @@ namespace glTF2Sharp.Schema2
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		{
 		{
-			switch(property)
+			switch (property)
 			{
 			{
 				case "uri": _uri = DeserializeValue<String>(reader); break;
 				case "uri": _uri = DeserializeValue<String>(reader); break;
 				case "mimeType": _mimeType = DeserializeValue<String>(reader); break;
 				case "mimeType": _mimeType = DeserializeValue<String>(reader); break;

+ 2 - 2
src/glTF2Sharp.DOM/Schema2/glb.cs

@@ -110,7 +110,7 @@ namespace glTF2Sharp.Schema2
             try
             try
             {
             {
                 Guard.NotNull(model, nameof(model));
                 Guard.NotNull(model, nameof(model));
-                Guard.IsTrue(model._LogicalBuffers.Count <= 1, nameof(model), $"{nameof(model)} GLB only supports one binary buffer, {model._LogicalBuffers.Count} found.");
+                Guard.IsTrue(model.LogicalBuffers.Count <= 1, nameof(model), $"{nameof(model)} GLB only supports one binary buffer, {model.LogicalBuffers.Count} found.");
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -136,7 +136,7 @@ namespace glTF2Sharp.Schema2
             var jsonChunk = Encoding.UTF8.GetBytes(jsonText);
             var jsonChunk = Encoding.UTF8.GetBytes(jsonText);
             var jsonPadding = jsonChunk.Length & 3; if (jsonPadding != 0) jsonPadding = 4 - jsonPadding;
             var jsonPadding = jsonChunk.Length & 3; if (jsonPadding != 0) jsonPadding = 4 - jsonPadding;
 
 
-            var buffer = model._LogicalBuffers.Count > 0 ? model._LogicalBuffers[0]._Data : null;
+            var buffer = model.LogicalBuffers.Count > 0 ? model.LogicalBuffers[0]._Data : null;
             if (buffer != null && buffer.Length == 0) buffer = null;
             if (buffer != null && buffer.Length == 0) buffer = null;
 
 
             var binPadding = buffer == null ? 0 : buffer.Length & 3; if (binPadding != 0) binPadding = 4 - binPadding;
             var binPadding = buffer == null ? 0 : buffer.Length & 3; if (binPadding != 0) binPadding = 4 - binPadding;

+ 32 - 79
src/glTF2Sharp.DOM/Schema2/gltf.Accessors.cs

@@ -28,13 +28,13 @@ namespace glTF2Sharp.Schema2
         {
         {
             _min = new List<double>();
             _min = new List<double>();
             _max = new List<double>();
             _max = new List<double>();
-        }        
+        }
 
 
         #endregion
         #endregion
 
 
         #region properties
         #region properties
 
 
-        public int LogicalIndex => this.LogicalParent._LogicalAccessors.IndexOfReference(this);
+        public int LogicalIndex => this.LogicalParent.LogicalAccessors.IndexOfReference(this);
 
 
         internal int _LogicalBufferViewIndex => this._bufferView ?? -1; // todo: clarify behaviour when BufferView is not define.
         internal int _LogicalBufferViewIndex => this._bufferView ?? -1; // todo: clarify behaviour when BufferView is not define.
 
 
@@ -42,13 +42,13 @@ namespace glTF2Sharp.Schema2
 
 
         public int Count => this._count;
         public int Count => this._count;
 
 
-        public int ByteOffset => _byteOffset ?? 0;        
+        public int ByteOffset => _byteOffset ?? 0;
 
 
-        public ElementType Element => this._type;        
+        public ElementType Element => this._type;
 
 
         public ComponentType Component => this._componentType;
         public ComponentType Component => this._componentType;
 
 
-        public Boolean Normalized => this._normalized ?? false;        
+        public Boolean Normalized => this._normalized ?? false;
 
 
         public int ItemByteSize => Component.ByteLength() * Element.Length();
         public int ItemByteSize => Component.ByteLength() * Element.Length();
 
 
@@ -69,7 +69,7 @@ namespace glTF2Sharp.Schema2
 
 
         #region API
         #region API
 
 
-        internal void SetDataBuffer(BufferView buffer, int byteOffset, ComponentType ct, ElementType et, int count)
+        internal void SetData(BufferView buffer, int byteOffset, ComponentType encoding, ElementType dimensions, int count)
         {
         {
             Guard.NotNull(buffer, nameof(buffer));
             Guard.NotNull(buffer, nameof(buffer));
             Guard.MustShareLogicalParent(this, buffer, nameof(buffer));
             Guard.MustShareLogicalParent(this, buffer, nameof(buffer));
@@ -78,16 +78,16 @@ namespace glTF2Sharp.Schema2
             Guard.MustBeGreaterThan(count, 0, nameof(count));
             Guard.MustBeGreaterThan(count, 0, nameof(count));
 
 
             this._bufferView = buffer.LogicalIndex;
             this._bufferView = buffer.LogicalIndex;
-            this._componentType = ct;
+            this._componentType = encoding;
             this._normalized = false;
             this._normalized = false;
-            this._type = et;
+            this._type = dimensions;
             this._byteOffset = byteOffset;
             this._byteOffset = byteOffset;
             this._count = count;
             this._count = count;
 
 
             _UpdateBounds(this._type.Length());
             _UpdateBounds(this._type.Length());
         }
         }
 
 
-        public void SetIndexData(BufferView buffer, IndexType type, int byteOffset, int count)
+        public void SetIndexData(BufferView buffer, int byteOffset, IndexType encoding, int count)
         {
         {
             Guard.NotNull(buffer,nameof(buffer));
             Guard.NotNull(buffer,nameof(buffer));
             Guard.MustShareLogicalParent(this, buffer,nameof(buffer));
             Guard.MustShareLogicalParent(this, buffer,nameof(buffer));
@@ -95,10 +95,9 @@ namespace glTF2Sharp.Schema2
 
 
             Guard.MustBeGreaterThanOrEqualTo(byteOffset, 0, nameof(byteOffset));
             Guard.MustBeGreaterThanOrEqualTo(byteOffset, 0, nameof(byteOffset));
             Guard.MustBeGreaterThan(count, 0, nameof(count));
             Guard.MustBeGreaterThan(count, 0, nameof(count));
-            
 
 
             this._bufferView = buffer.LogicalIndex;
             this._bufferView = buffer.LogicalIndex;
-            this._componentType = type.ToComponent();
+            this._componentType = encoding.ToComponent();
             this._type = ElementType.SCALAR;
             this._type = ElementType.SCALAR;
             this._normalized = null;
             this._normalized = null;
             this._byteOffset = byteOffset;
             this._byteOffset = byteOffset;
@@ -107,7 +106,7 @@ namespace glTF2Sharp.Schema2
             _UpdateBounds(1);
             _UpdateBounds(1);
         }
         }
 
 
-        public void SetVertexData(BufferView buffer, ComponentType ctype, ElementType etype, bool? normalized, int byteOffset, int count)
+        public void SetVertexData(BufferView buffer, int byteOffset, ComponentType encoding, ElementType dimensions, bool normalized, int count)
         {
         {
             Guard.NotNull(buffer,nameof(buffer));
             Guard.NotNull(buffer,nameof(buffer));
             Guard.MustShareLogicalParent(this, buffer, nameof(buffer));
             Guard.MustShareLogicalParent(this, buffer, nameof(buffer));
@@ -117,14 +116,14 @@ namespace glTF2Sharp.Schema2
             Guard.MustBeGreaterThan(count, 0, nameof(count));
             Guard.MustBeGreaterThan(count, 0, nameof(count));
 
 
             this._bufferView = buffer.LogicalIndex;
             this._bufferView = buffer.LogicalIndex;
-            this._componentType = ctype;
-            this._normalized = normalized;
-            this._type = etype;            
+            this._componentType = encoding;
+            this._normalized = normalized.AsNullable(false);
+            this._type = dimensions;
             this._byteOffset = byteOffset;
             this._byteOffset = byteOffset;
             this._count = count;
             this._count = count;
 
 
             _UpdateBounds(this._type.Length());
             _UpdateBounds(this._type.Length());
-        }        
+        }
 
 
         public ArraySegment<Byte> GetVertexBytes(int vertexIdx)
         public ArraySegment<Byte> GetVertexBytes(int vertexIdx)
         {
         {
@@ -148,7 +147,7 @@ namespace glTF2Sharp.Schema2
         public Byte[] GetColumnBytes()
         public Byte[] GetColumnBytes()
         {
         {
             var dstStride = Component.ByteLength() * Element.Length();
             var dstStride = Component.ByteLength() * Element.Length();
-            var srcStride = Math.Max(dstStride, Buffer.ByteStride);                
+            var srcStride = Math.Max(dstStride, Buffer.ByteStride);
 
 
             var srcData = Buffer.Data.GetSegment(this.ByteOffset, srcStride * Count);
             var srcData = Buffer.Data.GetSegment(this.ByteOffset, srcStride * Count);
             var dstData = new Byte[dstStride * Count];
             var dstData = new Byte[dstStride * Count];
@@ -172,13 +171,12 @@ namespace glTF2Sharp.Schema2
 
 
             var decoder = Buffer.CreateIndexDecoder(this.Component.ToIndex(), this.ByteOffset);
             var decoder = Buffer.CreateIndexDecoder(this.Component.ToIndex(), this.ByteOffset);
 
 
-            return _TryGetColumn<int>(decoder);            
+            return _TryGetColumn<int>(decoder);
         }
         }
 
 
-        
-        public T[] TryGetAttribute<T>() where T:struct
+        public T[] TryGetAttribute<T>() where T : struct
         {
         {
-            switch(this._type)
+            switch (this._type)
             {
             {
                 case ElementType.SCALAR:
                 case ElementType.SCALAR:
                     {
                     {
@@ -222,8 +220,8 @@ namespace glTF2Sharp.Schema2
             }
             }
         }
         }
 
 
-        
-        private T[] _TryGetColumn<T>(Func<int, T> decoder) where T:struct
+        private T[] _TryGetColumn<T>(Func<int, T> decoder)
+            where T : struct
         {
         {
             var dstBuff = new T[_count];
             var dstBuff = new T[_count];
 
 
@@ -231,7 +229,7 @@ namespace glTF2Sharp.Schema2
             {
             {
                 dstBuff[i] = decoder.Invoke(i);
                 dstBuff[i] = decoder.Invoke(i);
             }
             }
-            
+
             if (this._sparse != null)
             if (this._sparse != null)
             {
             {
                 this._sparse.CopyTo(this, dstBuff);
                 this._sparse.CopyTo(this, dstBuff);
@@ -258,9 +256,9 @@ namespace glTF2Sharp.Schema2
                 for (int i = 0; i < Count; ++i)
                 for (int i = 0; i < Count; ++i)
                 {
                 {
                     var scalar = decoder.Invoke(i);
                     var scalar = decoder.Invoke(i);
-                    
+
                     if (scalar < this._min[0]) this._min[0] = scalar;
                     if (scalar < this._min[0]) this._min[0] = scalar;
-                    if (scalar > this._max[0]) this._max[0] = scalar;                    
+                    if (scalar > this._max[0]) this._max[0] = scalar;
                 }
                 }
             }
             }
 
 
@@ -348,7 +346,7 @@ namespace glTF2Sharp.Schema2
 
 
             if (_min.Count != _max.Count) { exxx.Add(new ModelException(this, "min and max length mismatch")); return exxx; }
             if (_min.Count != _max.Count) { exxx.Add(new ModelException(this, "min and max length mismatch")); return exxx; }
 
 
-            for(int i=0; i < _min.Count; ++i)
+            for (int i = 0; i < _min.Count; ++i)
             {
             {
                 if (_min[i] > _max[i]) exxx.Add(new ModelException(this, $"min[{i}] is larger than max[{i}]"));
                 if (_min[i] > _max[i]) exxx.Add(new ModelException(this, $"min[{i}] is larger than max[{i}]"));
             }
             }
@@ -361,7 +359,6 @@ namespace glTF2Sharp.Schema2
 
 
     public partial class AccessorSparse
     public partial class AccessorSparse
     {
     {
-        
         public void CopyTo(Accessor srcAccessor, Byte[] dstBuffer, int dstStride)
         public void CopyTo(Accessor srcAccessor, Byte[] dstBuffer, int dstStride)
         {
         {
             if (this._count == 0) return;
             if (this._count == 0) return;
@@ -373,11 +370,11 @@ namespace glTF2Sharp.Schema2
             {
             {
                 var key = idxDecoder.Invoke(i);
                 var key = idxDecoder.Invoke(i);
 
 
-                valCopier(i, dstBuffer, dstStride, key);                
+                valCopier(i, dstBuffer, dstStride, key);
             }
             }
         }
         }
 
 
-        public void CopyTo<T>(Accessor srcAccessor, T[] dstBuffer) where T:struct
+        public void CopyTo<T>(Accessor srcAccessor, T[] dstBuffer) where T : struct
         {
         {
             if (this._count == 0) return;
             if (this._count == 0) return;
 
 
@@ -395,7 +392,6 @@ namespace glTF2Sharp.Schema2
 
 
     public partial class AccessorSparseIndices
     public partial class AccessorSparseIndices
     {
     {
-        
         public Func<int, int> GetDecoder(ROOT root)
         public Func<int, int> GetDecoder(ROOT root)
         {
         {
             var srcBuffer = root.LogicalBufferViews[this._bufferView];
             var srcBuffer = root.LogicalBufferViews[this._bufferView];
@@ -409,7 +405,7 @@ namespace glTF2Sharp.Schema2
 
 
             var indices = new int[count];
             var indices = new int[count];
 
 
-            for(int i=0; i < indices.Length; ++i)
+            for (int i = 0; i < indices.Length; ++i)
             {
             {
                 indices[i] = srcDecoder(i);
                 indices[i] = srcDecoder(i);
             }
             }
@@ -420,8 +416,8 @@ namespace glTF2Sharp.Schema2
 
 
     public partial class AccessorSparseValues
     public partial class AccessorSparseValues
     {
     {
-        
-        public Func<int, T> GetDecoder<T>(ROOT root, ElementType et, ComponentType ct, bool normalized) where T:struct
+        public Func<int, T> GetDecoder<T>(ROOT root, ElementType et, ComponentType ct, bool normalized)
+            where T : struct
         {
         {
             var srcBuffer = root.LogicalBufferViews[this._bufferView];
             var srcBuffer = root.LogicalBufferViews[this._bufferView];
 
 
@@ -430,7 +426,7 @@ namespace glTF2Sharp.Schema2
             return idx => (T)decoder(idx);
             return idx => (T)decoder(idx);
         }
         }
 
 
-        public Action<int,IList<Byte>,int, int> CopyTo(ROOT root, ElementType et, ComponentType ct)
+        public Action<int, IList<Byte>, int, int> CopyTo(ROOT root, ElementType et, ComponentType ct)
         {
         {
             var srcBuffer = root.LogicalBufferViews[this._bufferView];
             var srcBuffer = root.LogicalBufferViews[this._bufferView];
 
 
@@ -438,14 +434,12 @@ namespace glTF2Sharp.Schema2
             var srcStride = Math.Max(srcBuffer.ByteStride, itemLen);
             var srcStride = Math.Max(srcBuffer.ByteStride, itemLen);
 
 
             return (srcIdx, dstBuff, dstStride, dstIdx) =>
             return (srcIdx, dstBuff, dstStride, dstIdx) =>
-            {                
+            {
                 srcBuffer.Data.CopyTo(srcStride * srcIdx, dstBuff, dstStride * dstIdx, itemLen);
                 srcBuffer.Data.CopyTo(srcStride * srcIdx, dstBuff, dstStride * dstIdx, itemLen);
             };
             };
-            
         }
         }
     }
     }
 
 
-    
     public partial class ModelRoot
     public partial class ModelRoot
     {
     {
         public Accessor CreateAccessor()
         public Accessor CreateAccessor()
@@ -456,46 +450,5 @@ namespace glTF2Sharp.Schema2
 
 
             return accessor;
             return accessor;
         }
         }
-
-        internal Accessor _CreateVertexAccessor(BufferView buffer, ComponentType ctype, ElementType etype, bool? normalized, int extraByteOffset, int count)
-        {
-            var accessor = new Accessor();
-
-            _accessors.Add(accessor);
-
-            accessor.SetVertexData(buffer, ctype, etype, normalized, extraByteOffset, count);
-
-            return accessor;
-        }        
-
-        internal Accessor _CreateIndexAccessor(BufferView buffer, IndexType encoding, int extraByteOffset, int count)
-        {
-            var accessor = new Accessor();
-
-            _accessors.Add(accessor);
-
-            accessor.SetIndexData(buffer, encoding, extraByteOffset, count);
-
-            return accessor;
-        }
-
-        /*
-        internal Accessor _CreateDataAccessor(Byte[] data, Runtime.Encoding.DimensionType dtype, int count)
-        {
-            var buffer = new Buffer(data);
-            _buffers.Add(buffer);
-
-            var bufferView = CreateBufferView(buffer, data.Length, null, null, null);
-
-            var accessor = new Accessor();
-
-            _accessors.Add(accessor);
-
-            accessor.SetDataBuffer(bufferView, 0, ComponentType.FLOAT, dtype.ToSchema2(), count);
-
-            return accessor;
-        }*/
     }
     }
-
-   
 }
 }

+ 4 - 4
src/glTF2Sharp.DOM/Schema2/gltf.Animations.cs

@@ -5,7 +5,7 @@ using System.Linq;
 
 
 namespace glTF2Sharp.Schema2
 namespace glTF2Sharp.Schema2
 {
 {
-    using Collections;    
+    using Collections;
 
 
     [System.Diagnostics.DebuggerDisplay("Animation[{LogicalIndex}] {Name}")]
     [System.Diagnostics.DebuggerDisplay("Animation[{LogicalIndex}] {Name}")]
     public partial class Animation
     public partial class Animation
@@ -135,7 +135,7 @@ namespace glTF2Sharp.Schema2
             {
             {
                 var idx = this._target?._NodeId ?? -1;
                 var idx = this._target?._NodeId ?? -1;
                 if (idx < 0) return null;
                 if (idx < 0) return null;
-                return this.LogicalParent.LogicalParent._LogicalNodes[idx];
+                return this.LogicalParent.LogicalParent.LogicalNodes[idx];
             }
             }
         }
         }
 
 
@@ -184,9 +184,9 @@ namespace glTF2Sharp.Schema2
 
 
         public AnimationInterpolationMode Mode => _interpolation ?? _interpolationDefault;
         public AnimationInterpolationMode Mode => _interpolation ?? _interpolationDefault;
 
 
-        public Accessor Input => this.LogicalParent.LogicalParent._LogicalAccessors[this._input];
+        public Accessor Input => this.LogicalParent.LogicalParent.LogicalAccessors[this._input];
 
 
-        public Accessor Output => this.LogicalParent.LogicalParent._LogicalAccessors[this._output];
+        public Accessor Output => this.LogicalParent.LogicalParent.LogicalAccessors[this._output];
 
 
         #endregion
         #endregion
     }
     }

+ 6 - 6
src/glTF2Sharp.DOM/Schema2/gltf.Buffer.cs

@@ -16,14 +16,14 @@ namespace glTF2Sharp.Schema2
 
 
         internal Buffer(int byteCount)
         internal Buffer(int byteCount)
         {
         {
-            Guard.MustBeGreaterThan(byteCount, 0, nameof(byteCount));            
+            Guard.MustBeGreaterThan(byteCount, 0, nameof(byteCount));
 
 
             _Data = new byte[byteCount];
             _Data = new byte[byteCount];
         }
         }
 
 
         internal Buffer(IReadOnlyList<Byte> data)
         internal Buffer(IReadOnlyList<Byte> data)
         {
         {
-            Guard.NotNullOrEmpty(data,nameof(data));
+            Guard.NotNullOrEmpty(data, nameof(data));
 
 
             _Data = data.ToArray();
             _Data = data.ToArray();
         }
         }
@@ -48,7 +48,7 @@ namespace glTF2Sharp.Schema2
 
 
         #region properties
         #region properties
 
 
-        public int LogicalIndex => this.LogicalParent._LogicalBuffers.IndexOfReference(this);
+        public int LogicalIndex => this.LogicalParent.LogicalBuffers.IndexOfReference(this);
 
 
         #endregion
         #endregion
 
 
@@ -69,7 +69,7 @@ namespace glTF2Sharp.Schema2
             return uri._TryParseBase64Unchecked(EMBEDDEDGLTFBUFFER)
             return uri._TryParseBase64Unchecked(EMBEDDEDGLTFBUFFER)
                 ?? uri._TryParseBase64Unchecked(EMBEDDEDOCTETSTREAM)
                 ?? uri._TryParseBase64Unchecked(EMBEDDEDOCTETSTREAM)
                 ?? externalReferenceSolver?.Invoke(uri);
                 ?? externalReferenceSolver?.Invoke(uri);
-        }        
+        }
 
 
         #endregion
         #endregion
 
 
@@ -86,7 +86,7 @@ namespace glTF2Sharp.Schema2
         internal void _WriteToInternal()
         internal void _WriteToInternal()
         {
         {
             this._uri = null;
             this._uri = null;
-            this._byteLength = _Data.Length;            
+            this._byteLength = _Data.Length;
         }
         }
 
 
         internal void _ClearAfterWrite()
         internal void _ClearAfterWrite()
@@ -138,7 +138,7 @@ namespace glTF2Sharp.Schema2
 
 
             var accessor = new Memory.Vector3Accessor(new ArraySegment<byte>(buffer._Data), 0, ComponentType.FLOAT, false);
             var accessor = new Memory.Vector3Accessor(new ArraySegment<byte>(buffer._Data), 0, ComponentType.FLOAT, false);
 
 
-            for(int i=0; i < vectors.Length; ++i)
+            for (int i = 0; i < vectors.Length; ++i)
             {
             {
                 accessor[i] = vectors[i];
                 accessor[i] = vectors[i];
             }
             }

+ 17 - 50
src/glTF2Sharp.DOM/Schema2/gltf.BufferView.cs

@@ -6,7 +6,9 @@ using System.Text;
 
 
 namespace glTF2Sharp.Schema2
 namespace glTF2Sharp.Schema2
 {
 {
-    [System.Diagnostics.DebuggerTypeProxy(typeof(BufferView._DebugView))]
+    using BYTES = ArraySegment<Byte>;
+
+    [System.Diagnostics.DebuggerTypeProxy(typeof(Debug._BufferDebugView))]
     public partial class BufferView
     public partial class BufferView
     {
     {
         #region lifecycle
         #region lifecycle
@@ -53,12 +55,12 @@ namespace glTF2Sharp.Schema2
 
 
         public int ByteStride => this._byteStride ?? 0;
         public int ByteStride => this._byteStride ?? 0;
 
 
-        public ArraySegment<Byte> Data
+        public BYTES Data
         {
         {
             get
             get
             {
             {
-                var buffer = this.LogicalParent._LogicalBuffers[this._buffer];
-                return new ArraySegment<byte>(buffer._Data, this._byteOffset ?? 0, this._byteLength);
+                var buffer = this.LogicalParent.LogicalBuffers[this._buffer];
+                return new BYTES(buffer._Data, this._byteOffset ?? 0, this._byteLength);
             }
             }
         }
         }
 
 
@@ -69,19 +71,19 @@ namespace glTF2Sharp.Schema2
                 var idx = LogicalIndex;
                 var idx = LogicalIndex;
 
 
                 return this.LogicalParent
                 return this.LogicalParent
-                    ._LogicalAccessors
+                    .LogicalAccessors
                     .Where(accessor => accessor._LogicalBufferViewIndex == idx);
                     .Where(accessor => accessor._LogicalBufferViewIndex == idx);
             }
             }
         }
         }
 
 
         #endregion
         #endregion
 
 
-        #region API        
+        #region API
 
 
         internal void _ConvertToStaticBuffer(_StaticBufferBuilder targetBuffer)
         internal void _ConvertToStaticBuffer(_StaticBufferBuilder targetBuffer)
         {
         {
             // retrieve old buffer
             // retrieve old buffer
-            var srcBuf = this.LogicalParent._LogicalBuffers[this._buffer]._Data;
+            var srcBuf = this.LogicalParent.LogicalBuffers[this._buffer]._Data;
             var data = new Byte[this._byteLength];
             var data = new Byte[this._byteLength];
             Array.Copy(srcBuf, this._byteOffset ?? 0, data, 0, this._byteLength);
             Array.Copy(srcBuf, this._byteOffset ?? 0, data, 0, this._byteLength);
 
 
@@ -97,16 +99,16 @@ namespace glTF2Sharp.Schema2
 
 
             return String.Join(" ", accessors.Select(item => item._DebuggerDisplay_TryIdentifyContent()));
             return String.Join(" ", accessors.Select(item => item._DebuggerDisplay_TryIdentifyContent()));
         }
         }
-        
+
         public Func<int, int> CreateIndexDecoder(IndexType it, int byteOffset)
         public Func<int, int> CreateIndexDecoder(IndexType it, int byteOffset)
         {
         {
-            Guard.IsTrue(this.ByteStride == 0,null,"bytestride must be zero");            
+            Guard.IsTrue(this.ByteStride == 0,null, "bytestride must be zero");
 
 
             var reader = Memory.IntegerAccessor.Create(this.Data.Slice(byteOffset), it);
             var reader = Memory.IntegerAccessor.Create(this.Data.Slice(byteOffset), it);
 
 
-            return idx => (int)reader[idx];            
+            return idx => (int)reader[idx];
         }
         }
-        
+
         public Func<int, Object> CreateValueDecoder(ElementType et, ComponentType ct, bool normalized, int offset)
         public Func<int, Object> CreateValueDecoder(ElementType et, ComponentType ct, bool normalized, int offset)
         {
         {
             switch (et)
             switch (et)
@@ -119,20 +121,16 @@ namespace glTF2Sharp.Schema2
                 default: throw new NotImplementedException();
                 default: throw new NotImplementedException();
             }
             }
         }
         }
-        
-        public Func<int,Single> CreateScalarDecoder(ComponentType ct, int offset)
-        {
-            // var reader = new ScalarIndexer(this.Data, this.ByteStride, offset, ct.ToDevice(false));
 
 
+        public Func<int, Single> CreateScalarDecoder(ComponentType ct, int offset)
+        {
             var reader = new Memory.ScalarAccessor(this.Data.Slice(offset), this.ByteStride, ct, false);
             var reader = new Memory.ScalarAccessor(this.Data.Slice(offset), this.ByteStride, ct, false);
 
 
-            return idx => reader[idx];          
+            return idx => reader[idx];
         }
         }
-        
+
         public Func<int,Vector2> CreateVector2Decoder(ComponentType ct,bool normalized, int offset)
         public Func<int,Vector2> CreateVector2Decoder(ComponentType ct,bool normalized, int offset)
         {
         {
-            // var reader = new Vector2Reader(this.Data, this.ByteStride, offset, ct.ToDevice(normalized));
-
             var reader = new Memory.Vector2Accessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
             var reader = new Memory.Vector2Accessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
 
 
             return idx => reader[idx];
             return idx => reader[idx];
@@ -140,8 +138,6 @@ namespace glTF2Sharp.Schema2
 
 
         public Func<int, Vector3> CreateVector3Decoder(ComponentType ct, bool normalized, int offset)
         public Func<int, Vector3> CreateVector3Decoder(ComponentType ct, bool normalized, int offset)
         {
         {
-            // var reader = new Vector3Indexer(this.Data, this.ByteStride, offset, ct.ToDevice(normalized));
-
             var reader = new Memory.Vector3Accessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
             var reader = new Memory.Vector3Accessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
 
 
             return idx => reader[idx];
             return idx => reader[idx];
@@ -149,8 +145,6 @@ namespace glTF2Sharp.Schema2
 
 
         public Func<int, Vector4> CreateVector4Decoder(ComponentType ct, bool normalized, int offset)
         public Func<int, Vector4> CreateVector4Decoder(ComponentType ct, bool normalized, int offset)
         {
         {
-            // var reader = new Vector4Indexer(this.Data, this.ByteStride, offset, ct.ToDevice(normalized));
-
             var reader = new Memory.Vector4Accessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
             var reader = new Memory.Vector4Accessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
 
 
             return idx => reader[idx];
             return idx => reader[idx];
@@ -158,8 +152,6 @@ namespace glTF2Sharp.Schema2
 
 
         public Func<int, Quaternion> CreateQuaternionDecoder(ComponentType ct, bool normalized, int offset)
         public Func<int, Quaternion> CreateQuaternionDecoder(ComponentType ct, bool normalized, int offset)
         {
         {
-            // var reader = new QuaternionIndexer(this.Data, this.ByteStride, offset, ct.ToDevice(normalized));
-
             var reader = new Memory.QuaternionAccessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
             var reader = new Memory.QuaternionAccessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
 
 
             return idx => reader[idx];
             return idx => reader[idx];
@@ -167,8 +159,6 @@ namespace glTF2Sharp.Schema2
 
 
         public Func<int, Matrix4x4> CreateMatrix4x4Decoder(ComponentType ct, bool normalized, int offset)
         public Func<int, Matrix4x4> CreateMatrix4x4Decoder(ComponentType ct, bool normalized, int offset)
         {
         {
-            // var reader = new Matrix4x4Indexer(this.Data, this.ByteStride, offset, ct.ToDevice(normalized));
-
             var reader = new Memory.Matrix4x4Accessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
             var reader = new Memory.Matrix4x4Accessor(this.Data.Slice(offset), this.ByteStride, ct, normalized);
 
 
             return idx => reader[idx];
             return idx => reader[idx];
@@ -189,29 +179,6 @@ namespace glTF2Sharp.Schema2
                 .All(o => o < this.ByteStride);
                 .All(o => o < this.ByteStride);
         }
         }
 
 
-        #endregion       
-
-        #region debug        
-
-        [System.Diagnostics.DebuggerDisplay("BufferView[{_Value.LogicalIndex}] {_Value.Name} {_Value._target} Bytes:{_Value.Buffer1.Count}")]
-        internal sealed class _DebugView
-        {
-            public _DebugView(BufferView value) { _Value = value; }
-
-            public int LogicalIndex => _Value.LogicalParent.LogicalBufferViews.IndexOfReference(_Value);
-
-            private readonly BufferView _Value;
-
-            public int ByteStride => _Value._byteStride ?? 0;
-
-            public int ByteLength => _Value._byteLength;
-
-            public BufferMode? BufferMode => _Value._target;
-
-            [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
-            public Accessor[] Accessors => _Value.Accessors.ToArray();
-        }
-
         #endregion
         #endregion
     }
     }
 
 

+ 28 - 0
src/glTF2Sharp.DOM/Schema2/gltf.Camera.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace glTF2Sharp.Schema2
+{
+    [System.Diagnostics.DebuggerDisplay("Camera[{LogicalIndex}] {Name}")]
+    public partial class Camera
+    {
+        #region lifecycle
+
+        internal Camera() { }
+
+        #endregion
+
+        #region properties
+
+        public int LogicalIndex => this.LogicalParent.LogicalCameras.IndexOfReference(this);
+
+        public CameraType Type
+        {
+            get => this._type;
+            set => this._type = value;
+        }
+
+        #endregion        
+    }
+}

+ 2 - 4
src/glTF2Sharp.DOM/Schema2/gltf.Extensions.cs

@@ -10,10 +10,8 @@ namespace glTF2Sharp.Schema2
     {
     {
         static ExtensionsFactory()
         static ExtensionsFactory()
         {
         {
-            RegisterExtension("KHR_materials_pbrSpecularGlossiness", ()=> new MaterialPBRSpecularGlossiness_KHR());
+            RegisterExtension("KHR_materials_pbrSpecularGlossiness", () => new MaterialPBRSpecularGlossiness_KHR());
             RegisterExtension("KHR_materials_unlit", () => new MaterialUnlit_KHR());
             RegisterExtension("KHR_materials_unlit", () => new MaterialUnlit_KHR());
-            // RegisterExtension("MSFT_lod", () => new MSFT_lodglTFextension());
-            // RegisterExtension("KHR_draco_mesh_compression", () => new KHR_draco_mesh_compressionextension());
         }
         }
 
 
         private static readonly Dictionary<string, Func<JsonSerializable>> _Extensions = new Dictionary<string, Func<JsonSerializable>>();
         private static readonly Dictionary<string, Func<JsonSerializable>> _Extensions = new Dictionary<string, Func<JsonSerializable>>();
@@ -23,7 +21,7 @@ namespace glTF2Sharp.Schema2
         public static void RegisterExtension(string persistentName, Func<JsonSerializable> activator)
         public static void RegisterExtension(string persistentName, Func<JsonSerializable> activator)
         {
         {
             _Extensions[persistentName] = activator;
             _Extensions[persistentName] = activator;
-        }        
+        }
 
 
         public static JsonSerializable Create(string key)
         public static JsonSerializable Create(string key)
         {
         {

+ 16 - 7
src/glTF2Sharp.DOM/Schema2/gltf.LogicalChildOfRoot.cs

@@ -4,15 +4,14 @@ using System.Linq;
 
 
 namespace glTF2Sharp.Schema2
 namespace glTF2Sharp.Schema2
 {
 {
-    using Collections;
+    using Collections;    
 
 
-    using ROOT = ModelRoot;
-
-    public abstract partial class LogicalChildOfRoot : IChildOf<ROOT>
+    /// <summary>
+    /// All gltf elements stored in ModelRoot must inherit from this class.
+    /// </summary>
+    public abstract partial class LogicalChildOfRoot : IChildOf<ModelRoot>
     {
     {
-        public ROOT LogicalParent { get; private set; }
-
-        void IChildOf<ROOT>._SetLogicalParent(ROOT parent) { LogicalParent = parent; }
+        #region properties
 
 
         public String Name
         public String Name
         {
         {
@@ -20,6 +19,16 @@ namespace glTF2Sharp.Schema2
             internal set => _name = value;
             internal set => _name = value;
         }
         }
 
 
+        #endregion
+
+        #region IChildOf<ROOT>
+
+        public ModelRoot LogicalParent { get; private set; }
+
+        void IChildOf<ModelRoot>._SetLogicalParent(ModelRoot parent) { LogicalParent = parent; }
+
+        #endregion        
+
         #region validation
         #region validation
 
 
         protected bool SharesLogicalParent(params LogicalChildOfRoot[] items)
         protected bool SharesLogicalParent(params LogicalChildOfRoot[] items)

+ 4 - 8
src/glTF2Sharp.DOM/Schema2/gltf.Materials.cs

@@ -50,7 +50,7 @@ namespace glTF2Sharp.Schema2
 
 
         #region properties
         #region properties
 
 
-        public int LogicalIndex => this.LogicalParent._LogicalMaterials.IndexOfReference(this);                     
+        public int LogicalIndex => this.LogicalParent._LogicalMaterials.IndexOfReference(this);
 
 
         public AlphaMode Alpha
         public AlphaMode Alpha
         {
         {
@@ -118,7 +118,6 @@ namespace glTF2Sharp.Schema2
                     () => { var rgb = _emissiveFactor.AsValue(_emissiveFactorDefault); return new Vector4(rgb, 1); },
                     () => { var rgb = _emissiveFactor.AsValue(_emissiveFactorDefault); return new Vector4(rgb, 1); },
                     value => _emissiveFactor = new Vector3(value.X, value.Y, value.Z).AsNullable(_emissiveFactorDefault)
                     value => _emissiveFactor = new Vector3(value.X, value.Y, value.Z).AsNullable(_emissiveFactorDefault)
                     );
                     );
-
             }
             }
         }
         }
 
 
@@ -246,7 +245,7 @@ namespace glTF2Sharp.Schema2
                 "Metallic",
                 "Metallic",
                 _GetMetallicTexture,
                 _GetMetallicTexture,
                 () => new Vector4( (float) (_metallicFactor ?? _metallicFactorDefault)),
                 () => new Vector4( (float) (_metallicFactor ?? _metallicFactorDefault)),
-                value => _metallicFactor = ((double)value.X).AsNullable(_metallicFactorDefault,_metallicFactorMaximum,_metallicFactorMaximum)
+                value => _metallicFactor = ((double)value.X).AsNullable(_metallicFactorDefault, _metallicFactorMaximum, _metallicFactorMaximum)
                 );
                 );
 
 
             yield return new MaterialChannelView
             yield return new MaterialChannelView
@@ -255,7 +254,7 @@ namespace glTF2Sharp.Schema2
                 "Roughness",
                 "Roughness",
                 null,
                 null,
                 () => new Vector4((float)(_roughnessFactor ?? _roughnessFactorDefault)),
                 () => new Vector4((float)(_roughnessFactor ?? _roughnessFactorDefault)),
-                value => _roughnessFactor = ((double)value.X).AsNullable(_roughnessFactorDefault,_roughnessFactorMinimum,_roughnessFactorMaximum)
+                value => _roughnessFactor = ((double)value.X).AsNullable(_roughnessFactorDefault, _roughnessFactorMinimum, _roughnessFactorMaximum)
                 );
                 );
         }
         }
     }
     }
@@ -291,7 +290,7 @@ namespace glTF2Sharp.Schema2
                 "Glossiness",
                 "Glossiness",
                 _GetGlossinessTexture,
                 _GetGlossinessTexture,
                 () => new Vector4((float)(_glossinessFactor ?? _glossinessFactorDefault)),
                 () => new Vector4((float)(_glossinessFactor ?? _glossinessFactorDefault)),
-                value => _glossinessFactor = ((double)value.X).AsNullable(_glossinessFactorDefault,_glossinessFactorMinimum,_glossinessFactorMaximum)
+                value => _glossinessFactor = ((double)value.X).AsNullable(_glossinessFactorDefault, _glossinessFactorMinimum, _glossinessFactorMaximum)
                 );
                 );
 
 
             yield return new MaterialChannelView
             yield return new MaterialChannelView
@@ -340,7 +339,4 @@ namespace glTF2Sharp.Schema2
             return mat;
             return mat;
         }
         }
     }
     }
-
-
-
 }
 }

+ 1 - 1
src/glTF2Sharp.DOM/Schema2/gltf.Mesh.cs

@@ -6,7 +6,7 @@ using System.Text;
 
 
 namespace glTF2Sharp.Schema2
 namespace glTF2Sharp.Schema2
 {
 {
-    using Collections;    
+    using Collections;
 
 
     [System.Diagnostics.DebuggerDisplay("Mesh[{LogicalIndex}] {Name}")]
     [System.Diagnostics.DebuggerDisplay("Mesh[{LogicalIndex}] {Name}")]
     public partial class Mesh
     public partial class Mesh

+ 11 - 15
src/glTF2Sharp.DOM/Schema2/gltf.MeshPrimitive.cs

@@ -52,7 +52,7 @@ namespace glTF2Sharp.Schema2
 
 
         public BoundingBox3? LocalBounds3 => VertexAccessors["POSITION"]?.LocalBounds3;
         public BoundingBox3? LocalBounds3 => VertexAccessors["POSITION"]?.LocalBounds3;
 
 
-        public IReadOnlyDictionary<String, Accessor> VertexAccessors => new ReadOnlyLinqDictionary<String, int, Accessor>(_attributes, alidx => this.LogicalParent.LogicalParent._LogicalAccessors[alidx]);
+        public IReadOnlyDictionary<String, Accessor> VertexAccessors => new ReadOnlyLinqDictionary<String, int, Accessor>(_attributes, alidx => this.LogicalParent.LogicalParent.LogicalAccessors[alidx]);
 
 
         public Accessor IndexAccessor
         public Accessor IndexAccessor
         {
         {
@@ -60,8 +60,9 @@ namespace glTF2Sharp.Schema2
             {
             {
                 if (!this._indices.HasValue) return null;
                 if (!this._indices.HasValue) return null;
 
 
-                return this.LogicalParent.LogicalParent._LogicalAccessors[this._indices.Value];
+                return this.LogicalParent.LogicalParent.LogicalAccessors[this._indices.Value];
             }
             }
+
             set
             set
             {
             {
                 if (value == null) this._indices = null;
                 if (value == null) this._indices = null;
@@ -83,7 +84,7 @@ namespace glTF2Sharp.Schema2
 
 
             if (!_attributes.TryGetValue(attributeKey, out int idx)) return null;
             if (!_attributes.TryGetValue(attributeKey, out int idx)) return null;
 
 
-            return this.LogicalParent.LogicalParent._LogicalAccessors[idx];
+            return this.LogicalParent.LogicalParent.LogicalAccessors[idx];
         }
         }
 
 
         public void SetVertexAccessor(string attributeKey, Accessor accessor)
         public void SetVertexAccessor(string attributeKey, Accessor accessor)
@@ -103,7 +104,7 @@ namespace glTF2Sharp.Schema2
 
 
         public IReadOnlyDictionary<String, Accessor> GetMorphTargetAccessors(int idx)
         public IReadOnlyDictionary<String, Accessor> GetMorphTargetAccessors(int idx)
         {
         {
-            return new ReadOnlyLinqDictionary<String, int, Accessor>(_targets[idx], alidx => this.LogicalParent.LogicalParent._LogicalAccessors[alidx]);
+            return new ReadOnlyLinqDictionary<String, int, Accessor>(_targets[idx], alidx => this.LogicalParent.LogicalParent.LogicalAccessors[alidx]);
         }
         }
 
 
         public void SetMorphTargetAccessors(int idx, IReadOnlyDictionary<String, Accessor> accessors)
         public void SetMorphTargetAccessors(int idx, IReadOnlyDictionary<String, Accessor> accessors)
@@ -146,11 +147,11 @@ namespace glTF2Sharp.Schema2
             {
             {
                 for (int i = 0; i < MorpthTargets; ++i)
                 for (int i = 0; i < MorpthTargets; ++i)
                 {
                 {
-                    foreach(var key in attributes)
+                    foreach (var key in attributes)
                     {
                     {
                         var morpthAccessors = GetMorphTargetAccessors(i);
                         var morpthAccessors = GetMorphTargetAccessors(i);
                         if (morpthAccessors.TryGetValue(key, out Accessor accessor)) accessors.Add(accessor);
                         if (morpthAccessors.TryGetValue(key, out Accessor accessor)) accessors.Add(accessor);
-                    }                    
+                    }
                 }
                 }
             }
             }
 
 
@@ -177,7 +178,7 @@ namespace glTF2Sharp.Schema2
         {
         {
             if (!attributes.TryGetValue(attribute, out int idx)) return null;
             if (!attributes.TryGetValue(attribute, out int idx)) return null;
 
 
-            return this.LogicalParent.LogicalParent._LogicalAccessors[idx];
+            return this.LogicalParent.LogicalParent.LogicalAccessors[idx];
         }
         }
 
 
         private String _DebuggerDisplay_TryIdentifyContent()
         private String _DebuggerDisplay_TryIdentifyContent()
@@ -193,18 +194,13 @@ namespace glTF2Sharp.Schema2
         {
         {
             var exx = base.Validate().ToList();
             var exx = base.Validate().ToList();
 
 
-            // Number of vertices or indices(1) is not compatible with used drawing mode('TRIANGLES').
-
-            var idxAccessor = IndexAccessor;
-
-            if (idxAccessor != null)
+            if (IndexAccessor != null)
             {
             {
                 switch (DrawPrimitiveType)
                 switch (DrawPrimitiveType)
                 {
                 {
                     case PrimitiveType.TRIANGLES:
                     case PrimitiveType.TRIANGLES:
-                        if ((idxAccessor.Count % 3) != 0) exx.Add(new ModelException(this, $"Indices count {idxAccessor.Count} incompatible with Primitive.{DrawPrimitiveType}"));
+                        if ((IndexAccessor.Count % 3) != 0) exx.Add(new ModelException(this, $"Indices count {IndexAccessor.Count} incompatible with Primitive.{DrawPrimitiveType}"));
                         break;
                         break;
-
                 }
                 }
             }
             }
 
 
@@ -212,5 +208,5 @@ namespace glTF2Sharp.Schema2
         }
         }
 
 
         #endregion
         #endregion
-    }    
+    }
 }
 }

+ 2 - 4
src/glTF2Sharp.DOM/Schema2/gltf.Property.cs

@@ -11,14 +11,13 @@ namespace glTF2Sharp.Schema2
     public abstract class glTFProperty : JsonSerializable
     public abstract class glTFProperty : JsonSerializable
     {
     {
         #region data
         #region data
-
-        // should be a hashset where the comparer is the Type
+        
         private readonly List<JsonSerializable> _extensions = new List<JsonSerializable>();
         private readonly List<JsonSerializable> _extensions = new List<JsonSerializable>();
 
 
         private Object _extras;
         private Object _extras;
 
 
         #endregion
         #endregion
-
+        
         #region API        
         #region API        
 
 
         public T GetExtension<T>() where T : JsonSerializable { return _extensions.OfType<T>().FirstOrDefault(); }
         public T GetExtension<T>() where T : JsonSerializable { return _extensions.OfType<T>().FirstOrDefault(); }
@@ -55,7 +54,6 @@ namespace glTF2Sharp.Schema2
             }
             }
         }
         }
 
 
-
         private static void _DeserializeExtensions(JsonReader reader, IList<JsonSerializable> extensions)
         private static void _DeserializeExtensions(JsonReader reader, IList<JsonSerializable> extensions)
         {
         {
             while (true)
             while (true)

+ 19 - 41
src/glTF2Sharp.DOM/Schema2/gltf.Root.cs

@@ -3,8 +3,8 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 
 
 namespace glTF2Sharp.Schema2
 namespace glTF2Sharp.Schema2
-{    
-    using Collections;    
+{
+    using Collections;
 
 
     [System.Diagnostics.DebuggerDisplay("Model Root")]
     [System.Diagnostics.DebuggerDisplay("Model Root")]
     public partial class ModelRoot
     public partial class ModelRoot
@@ -14,7 +14,7 @@ namespace glTF2Sharp.Schema2
         public static ModelRoot CreateNew()
         public static ModelRoot CreateNew()
         {
         {
             var root = new ModelRoot();
             var root = new ModelRoot();
-            root._asset = Asset.CreateDefault("");
+            root._asset = Asset.CreateDefault(string.Empty);
 
 
             return root;
             return root;
         }
         }
@@ -41,57 +41,35 @@ namespace glTF2Sharp.Schema2
 
 
         #endregion
         #endregion
 
 
-        #region internal API        
-
-        internal Mesh _AddLogicalMesh()
-        {
-            var mesh = new Mesh();
-
-            _meshes.Add(mesh);
-
-            return mesh;
-        }
-
-        internal Skin _AddLogicalSkin()
-        {
-            var skin = new Skin();
-
-            _skins.Add(skin);
-
-            return skin;
-        }        
-
-        #endregion
-
         #region properties
         #region properties
 
 
         public Asset Asset => _asset;
         public Asset Asset => _asset;
 
 
-        public IEnumerable<String> ExtensionsRequired           => this._extensionsRequired;
+        public IEnumerable<String> ExtensionsRequired           => _extensionsRequired;
 
 
-        public IEnumerable<String> IncompatibleExtensions       => this._extensionsRequired.Except(ExtensionsFactory.SupportedExtensions);
+        public IEnumerable<String> IncompatibleExtensions       => _extensionsRequired.Except(ExtensionsFactory.SupportedExtensions);
         
         
         internal IReadOnlyList<Material>    _LogicalMaterials   => _materials;
         internal IReadOnlyList<Material>    _LogicalMaterials   => _materials;
         internal IReadOnlyList<Texture>     _LogicalTextures    => _textures;
         internal IReadOnlyList<Texture>     _LogicalTextures    => _textures;
         internal IReadOnlyList<Sampler>     _LogicalSamplers    => _samplers;
         internal IReadOnlyList<Sampler>     _LogicalSamplers    => _samplers;
         internal IReadOnlyList<Image>       _LogicalImages      => _images;
         internal IReadOnlyList<Image>       _LogicalImages      => _images;
 
 
-        public IReadOnlyList<Mesh>          LogicalMeshes      => _meshes;
-        internal IReadOnlyList<Skin>        _LogicalSkins       => _skins;
-        internal IReadOnlyList<Camera>      _LogicalCameras     => _cameras;
+        public IReadOnlyList<Mesh>          LogicalMeshes       => _meshes;
+        public IReadOnlyList<Skin>          LogicalSkins        => _skins;
+        public IReadOnlyList<Camera>        LogicalCameras      => _cameras;
 
 
-        internal IReadOnlyList<Buffer>      _LogicalBuffers     => _buffers;
-        public IReadOnlyList<BufferView>    LogicalBufferViews => _bufferViews;
-        internal IReadOnlyList<Accessor>    _LogicalAccessors => _accessors;
+        public IReadOnlyList<Buffer>        LogicalBuffers      => _buffers;
+        public IReadOnlyList<BufferView>    LogicalBufferViews  => _bufferViews;
+        public IReadOnlyList<Accessor>      LogicalAccessors    => _accessors;
 
 
-        internal IReadOnlyList<Node>        _LogicalNodes       => _nodes;
+        public IReadOnlyList<Node>          LogicalNodes        => _nodes;
 
 
-        public IReadOnlyList<Scene>       LogicalScenes   => _scenes;
-        public IReadOnlyList<Animation>   Animations      => _animations;
+        public IReadOnlyList<Scene>         LogicalScenes       => _scenes;
+        public IReadOnlyList<Animation>     Animations          => _animations;
 
 
-        public Scene DefaultScene =>        _scenes.Count == 0 ? null : _scenes[_scene ?? 0];
+        public Scene                        DefaultScene        => _scenes.Count == 0 ? null : _scenes[_scene ?? 0];
 
 
-        #endregion                
+        #endregion
 
 
         #region validation
         #region validation
 
 
@@ -101,12 +79,12 @@ namespace glTF2Sharp.Schema2
 
 
             // 1st check version number
             // 1st check version number
 
 
-            if (Asset == null) exx.Add(new ModelException(this, "missing Asset object, can't check glTF version")); // fix: create a default Asset                
+            if (Asset == null) exx.Add(new ModelException(this, "missing Asset object, can't check glTF version")); // fix: create a default Asset
             else exx.AddRange(Asset.Validate());
             else exx.AddRange(Asset.Validate());
 
 
             if (exx.Count > 0) return exx;
             if (exx.Count > 0) return exx;
 
 
-            // 2nd check incompatible extensions            
+            // 2nd check incompatible extensions
 
 
             foreach (var iex in this.IncompatibleExtensions)
             foreach (var iex in this.IncompatibleExtensions)
             {
             {
@@ -129,6 +107,6 @@ namespace glTF2Sharp.Schema2
             return exx;
             return exx;
         }
         }
 
 
-        #endregion        
+        #endregion
     }
     }
 }
 }

+ 13 - 16
src/glTF2Sharp.DOM/Schema2/gltf.Scene.cs

@@ -15,7 +15,7 @@ namespace glTF2Sharp.Schema2
 
 
     [System.Diagnostics.DebuggerDisplay("Node[{LogicalIndex}] {Name} SkinJoint:{IsSkinJoint} T:{LocalTransform.Translation.X} {LocalTransform.Translation.Y} {LocalTransform.Translation.Z}")]
     [System.Diagnostics.DebuggerDisplay("Node[{LogicalIndex}] {Name} SkinJoint:{IsSkinJoint} T:{LocalTransform.Translation.X} {LocalTransform.Translation.Y} {LocalTransform.Translation.Z}")]
     public partial class Node : IVisualNodeContainer
     public partial class Node : IVisualNodeContainer
-    {        
+    {
         #region lifecycle
         #region lifecycle
 
 
         public Node()
         public Node()
@@ -28,7 +28,7 @@ namespace glTF2Sharp.Schema2
 
 
         #region properties - hierarchy
         #region properties - hierarchy
 
 
-        public int LogicalIndex => this.LogicalParent._LogicalNodes.IndexOfReference(this);
+        public int LogicalIndex => this.LogicalParent.LogicalNodes.IndexOfReference(this);
 
 
         public Node VisualParent => this.LogicalParent._GetVisualParentNode(this);        
         public Node VisualParent => this.LogicalParent._GetVisualParentNode(this);        
 
 
@@ -115,16 +115,15 @@ namespace glTF2Sharp.Schema2
 
 
         public Skin Skin
         public Skin Skin
         {
         {
-            get => this._skin.HasValue ? this.LogicalParent._LogicalSkins[this._skin.Value] : null;
+            get => this._skin.HasValue ? this.LogicalParent.LogicalSkins[this._skin.Value] : null;
             set
             set
             {
             {
                 Guard.MustShareLogicalParent(this.LogicalParent, value, nameof(value));
                 Guard.MustShareLogicalParent(this.LogicalParent, value, nameof(value));
-                var idx = this.LogicalParent._LogicalSkins.IndexOfReference(value);
+                var idx = this.LogicalParent.LogicalSkins.IndexOfReference(value);
                 this._skin = idx < 0 ? (int?)null : idx;
                 this._skin = idx < 0 ? (int?)null : idx;
             }
             }
         }
         }
 
 
-
         public IReadOnlyList<float> MorphWeights => _weights == null ? Mesh?.MorphWeights : _weights.Select(item => (float)item).ToArray();
         public IReadOnlyList<float> MorphWeights => _weights == null ? Mesh?.MorphWeights : _weights.Select(item => (float)item).ToArray();
 
 
         public BoundingBox3? WorldBounds3 => BoundingBox3.Create(this);
         public BoundingBox3? WorldBounds3 => BoundingBox3.Create(this);
@@ -152,7 +151,7 @@ namespace glTF2Sharp.Schema2
             // a class declared in the extension... but then, it makes edition horribly complicated.
             // a class declared in the extension... but then, it makes edition horribly complicated.
             // maybe it's better to have a non serializable _LodLevel that is applied when serializing.
             // maybe it's better to have a non serializable _LodLevel that is applied when serializing.
 
 
-            var allChildren = _children.Select(idx => LogicalParent._LogicalNodes[idx]);            
+            var allChildren = _children.Select(idx => LogicalParent.LogicalNodes[idx]);            
 
 
             return allChildren;
             return allChildren;
         }
         }
@@ -189,7 +188,7 @@ namespace glTF2Sharp.Schema2
             var meshIdx = mesh.LogicalIndex;
             var meshIdx = mesh.LogicalIndex;
 
 
             return mesh.LogicalParent
             return mesh.LogicalParent
-                ._LogicalNodes
+                .LogicalNodes
                 .Where(item => item._mesh.HasValue && item._mesh.Value == meshIdx);
                 .Where(item => item._mesh.HasValue && item._mesh.Value == meshIdx);
         }
         }
 
 
@@ -198,7 +197,7 @@ namespace glTF2Sharp.Schema2
             var meshIdx = skin.LogicalIndex;
             var meshIdx = skin.LogicalIndex;
 
 
             return skin.LogicalParent
             return skin.LogicalParent
-                ._LogicalNodes
+                .LogicalNodes
                 .Where(item => item._skin.HasValue && item._skin.Value == meshIdx);
                 .Where(item => item._skin.HasValue && item._skin.Value == meshIdx);
         }
         }
 
 
@@ -209,7 +208,7 @@ namespace glTF2Sharp.Schema2
             // check out of range indices
             // check out of range indices
             foreach (var idx in this._children)
             foreach (var idx in this._children)
             {
             {
-                if (idx < 0 || idx >= this.LogicalParent._LogicalNodes.Count) yield return new ModelException(this, $"references invalid Node[{idx}]");
+                if (idx < 0 || idx >= this.LogicalParent.LogicalNodes.Count) yield return new ModelException(this, $"references invalid Node[{idx}]");
             }
             }
 
 
             // check duplicated indices
             // check duplicated indices
@@ -220,7 +219,7 @@ namespace glTF2Sharp.Schema2
 
 
             // check circular references
             // check circular references
             var p = this;
             var p = this;
-            while(true)
+            while (true)
             {
             {
                 p = p.VisualParent;
                 p = p.VisualParent;
                 if (p == null) break;
                 if (p == null) break;
@@ -257,7 +256,7 @@ namespace glTF2Sharp.Schema2
 
 
         internal IReadOnlyList<int> _VisualChildrenIndices => _nodes;
         internal IReadOnlyList<int> _VisualChildrenIndices => _nodes;
 
 
-        public IEnumerable<Node> VisualChildren => _nodes.Select(idx => LogicalParent._LogicalNodes[idx]);
+        public IEnumerable<Node> VisualChildren => _nodes.Select(idx => LogicalParent.LogicalNodes[idx]);
 
 
         public BoundingBox3? WorldBounds3 => BoundingBox3.Create(this);
         public BoundingBox3? WorldBounds3 => BoundingBox3.Create(this);
 
 
@@ -294,9 +293,9 @@ namespace glTF2Sharp.Schema2
             foreach (var ex in base.Validate()) yield return ex;
             foreach (var ex in base.Validate()) yield return ex;
 
 
             // check out of range indices
             // check out of range indices
-            foreach(var idx in this._nodes)
+            foreach (var idx in this._nodes)
             {
             {
-                if (idx < 0 || idx >= this.LogicalParent._LogicalNodes.Count) yield return new ModelException(this, $"references invalid Node[{idx}]");
+                if (idx < 0 || idx >= this.LogicalParent.LogicalNodes.Count) yield return new ModelException(this, $"references invalid Node[{idx}]");
             }
             }
 
 
             // check duplicated indices
             // check duplicated indices
@@ -306,8 +305,6 @@ namespace glTF2Sharp.Schema2
         // TODO: AddVisualChild must return a "NodeBuilder"
         // TODO: AddVisualChild must return a "NodeBuilder"
         // public Node AddVisualChild() { return LogicalParent._AddLogicalNode(_nodes); }        
         // public Node AddVisualChild() { return LogicalParent._AddLogicalNode(_nodes); }        
 
 
-        
-
         #endregion
         #endregion
     }
     }
 
 
@@ -317,7 +314,7 @@ namespace glTF2Sharp.Schema2
         {
         {
             Guard.MustBeGreaterThanOrEqualTo(index, 0, nameof(index));
             Guard.MustBeGreaterThanOrEqualTo(index, 0, nameof(index));
 
 
-            while(index >= _scenes.Count)
+            while (index >= _scenes.Count)
             {
             {
                 _scenes.Add(new Scene());
                 _scenes.Add(new Scene());
             }
             }

+ 5 - 5
src/glTF2Sharp.DOM/Schema2/gltf.Serialization.cs

@@ -11,13 +11,13 @@ namespace glTF2Sharp.Schema2
 
 
     public delegate Byte[] AssetReader(String assetName);
     public delegate Byte[] AssetReader(String assetName);
 
 
-    public delegate void AssetWriter(String assetName, Byte[] assetData);    
+    public delegate void AssetWriter(String assetName, Byte[] assetData);
 
 
     public class ReadSettings
     public class ReadSettings
     {
     {
         public ReadSettings()
         public ReadSettings()
         {
         {
-            
+
         }
         }
 
 
         internal ReadSettings(string filePath)
         internal ReadSettings(string filePath)
@@ -26,10 +26,10 @@ namespace glTF2Sharp.Schema2
 
 
             var dir = Path.GetDirectoryName(filePath);
             var dir = Path.GetDirectoryName(filePath);
 
 
-            FileReader = asset => File.ReadAllBytes(Path.Combine(dir, asset));            
+            FileReader = asset => File.ReadAllBytes(Path.Combine(dir, asset));
         }
         }
 
 
-        public AssetReader FileReader { get; set; }        
+        public AssetReader FileReader { get; set; }
     }
     }
 
 
     public class WriteSettings
     public class WriteSettings
@@ -38,7 +38,7 @@ namespace glTF2Sharp.Schema2
 
 
         internal WriteSettings(string filePath)
         internal WriteSettings(string filePath)
         {
         {
-            Guard.FilePathMustBeValid(filePath,nameof(filePath));
+            Guard.FilePathMustBeValid(filePath, nameof(filePath));
 
 
             var dir = Path.GetDirectoryName(filePath);
             var dir = Path.GetDirectoryName(filePath);
 
 

+ 5 - 7
src/glTF2Sharp.DOM/Schema2/gltf.Skin.cs

@@ -32,7 +32,7 @@ namespace glTF2Sharp.Schema2
 
 
         #region properties
         #region properties
 
 
-        public int LogicalIndex => this.LogicalParent._LogicalSkins.IndexOfReference(this);
+        public int LogicalIndex => this.LogicalParent.LogicalSkins.IndexOfReference(this);
 
 
         public IEnumerable<Node> VisualParents => Node.GetNodesUsingSkin(this);
         public IEnumerable<Node> VisualParents => Node.GetNodesUsingSkin(this);
 
 
@@ -41,7 +41,7 @@ namespace glTF2Sharp.Schema2
         // Skeleton property points to the node that is the root of a joints hierarchy.
         // Skeleton property points to the node that is the root of a joints hierarchy.
         public Node Skeleton
         public Node Skeleton
         {
         {
-            get => this._skeleton.HasValue ? this.LogicalParent._LogicalNodes[this._skeleton.Value] : null;
+            get => this._skeleton.HasValue ? this.LogicalParent.LogicalNodes[this._skeleton.Value] : null;
             set
             set
             {
             {
                 if (value != null) Guard.MustShareLogicalParent(this.LogicalParent, value, nameof(value));
                 if (value != null) Guard.MustShareLogicalParent(this.LogicalParent, value, nameof(value));
@@ -57,7 +57,7 @@ namespace glTF2Sharp.Schema2
         {
         {
             var idx = n.LogicalIndex;
             var idx = n.LogicalIndex;
 
 
-            return n.LogicalParent._LogicalSkins.Where(s => s._ContainsNode(idx));
+            return n.LogicalParent.LogicalSkins.Where(s => s._ContainsNode(idx));
         }
         }
 
 
         internal bool _ContainsNode(int nodeIdx) { return _joints.Contains(nodeIdx); }
         internal bool _ContainsNode(int nodeIdx) { return _joints.Contains(nodeIdx); }
@@ -66,14 +66,14 @@ namespace glTF2Sharp.Schema2
         {
         {
             if (!this._inverseBindMatrices.HasValue) return null;
             if (!this._inverseBindMatrices.HasValue) return null;
 
 
-            return this.LogicalParent._LogicalAccessors[this._inverseBindMatrices.Value];
+            return this.LogicalParent.LogicalAccessors[this._inverseBindMatrices.Value];
         }
         }
 
 
         public KeyValuePair<Node, Matrix4x4> GetJoint(int idx)
         public KeyValuePair<Node, Matrix4x4> GetJoint(int idx)
         {
         {
             var nodeIdx = _joints[idx];
             var nodeIdx = _joints[idx];
 
 
-            var node = this.LogicalParent._LogicalNodes[nodeIdx];
+            var node = this.LogicalParent.LogicalNodes[nodeIdx];
 
 
             var matrix = (Matrix4x4)GetInverseBindMatricesAccessor().TryGetAttribute<Matrix4x4>()[idx];
             var matrix = (Matrix4x4)GetInverseBindMatricesAccessor().TryGetAttribute<Matrix4x4>()[idx];
 
 
@@ -140,6 +140,4 @@ namespace glTF2Sharp.Schema2
 
 
         #endregion
         #endregion
     }
     }
-
-
 }
 }

+ 3 - 5
src/glTF2Sharp.DOM/Schema2/gltf.Textures.cs

@@ -89,7 +89,6 @@ namespace glTF2Sharp.Schema2
             _minFilter = min;
             _minFilter = min;
             _wrapS = ws;
             _wrapS = ws;
             _wrapT = wt;
             _wrapT = wt;
-
         }
         }
 
 
         #endregion
         #endregion
@@ -292,7 +291,7 @@ namespace glTF2Sharp.Schema2
 
 
             return img;
             return img;
         }
         }
-        
+
         public Sampler UseLogicalSampler(TextureInterpolationMode mag, TextureMipMapMode min, TextureWrapMode ws, TextureWrapMode wt)
         public Sampler UseLogicalSampler(TextureInterpolationMode mag, TextureMipMapMode min, TextureWrapMode ws, TextureWrapMode wt)
         {
         {
             foreach (var s in this._samplers)
             foreach (var s in this._samplers)
@@ -311,7 +310,7 @@ namespace glTF2Sharp.Schema2
         {
         {
             if (image == null) return null;
             if (image == null) return null;
 
 
-            if (image != null) Guard.MustShareLogicalParent(this, image,nameof(image));
+            if (image != null) Guard.MustShareLogicalParent(this, image, nameof(image));
             if (sampler != null) Guard.MustShareLogicalParent(this, sampler, nameof(sampler));
             if (sampler != null) Guard.MustShareLogicalParent(this, sampler, nameof(sampler));
 
 
             var tex = _textures.FirstOrDefault(item => item.Source == image && item.Sampler == sampler);
             var tex = _textures.FirstOrDefault(item => item.Source == image && item.Sampler == sampler);
@@ -326,7 +325,7 @@ namespace glTF2Sharp.Schema2
             return tex;
             return tex;
         }
         }
 
 
-        internal T UseTextureInfo<T>(Image image, Sampler sampler, int textureSet) where T:TextureInfo, new()
+        internal T UseTextureInfo<T>(Image image, Sampler sampler, int textureSet) where T : TextureInfo, new()
         {
         {
             var tex = UseLogicalTexture(image, sampler);
             var tex = UseLogicalTexture(image, sampler);
             if (tex == null) return null;
             if (tex == null) return null;
@@ -338,5 +337,4 @@ namespace glTF2Sharp.Schema2
             };
             };
         }
         }
     }
     }
-
 }
 }

+ 2 - 2
src/glTF2Sharp.DOM/Transforms/BoundingBox.cs

@@ -8,13 +8,13 @@ namespace glTF2Sharp
 {
 {
     public struct BoundingBox3
     public struct BoundingBox3
     {
     {
-        #region constructors        
+        #region constructors
 
 
         public static BoundingBox3? UnionOf(IEnumerable<BoundingBox3?> bounds)
         public static BoundingBox3? UnionOf(IEnumerable<BoundingBox3?> bounds)
         {
         {
             var final = Empty;
             var final = Empty;
 
 
-            foreach(var b in bounds.Where(item => item.HasValue))
+            foreach (var b in bounds.Where(item => item.HasValue))
             {
             {
                 final = final.IsEmpty ? b.Value : new BoundingBox3(final, b.Value);
                 final = final.IsEmpty ? b.Value : new BoundingBox3(final, b.Value);
             }
             }

+ 2 - 3
src/glTF2Sharp.DOM/_Extensions.cs

@@ -5,7 +5,7 @@ using System.Numerics;
 
 
 namespace glTF2Sharp
 namespace glTF2Sharp
 {
 {
-    using Schema2;    
+    using Schema2;
 
 
     /// <summary>
     /// <summary>
     /// Extensions used internally.
     /// Extensions used internally.
@@ -158,7 +158,6 @@ namespace glTF2Sharp
             return new ArraySegment<T>(array.Array, array.Offset + offset, count);
             return new ArraySegment<T>(array.Array, array.Offset + offset, count);
         }
         }
 
 
-
         internal static void CopyTo<T>(this T[] src, int srcOffset, IList<T> dst, int dstOffset, int count)
         internal static void CopyTo<T>(this T[] src, int srcOffset, IList<T> dst, int dstOffset, int count)
         {
         {
             var srcArray = new ArraySegment<T>(src);
             var srcArray = new ArraySegment<T>(src);
@@ -188,7 +187,7 @@ namespace glTF2Sharp
         internal static T? AsNullable<T>(this T value, T defval) where T : struct
         internal static T? AsNullable<T>(this T value, T defval) where T : struct
         {
         {
             return value.Equals(defval) ? (T?)null : value;
             return value.Equals(defval) ? (T?)null : value;
-        }        
+        }
 
 
         internal static T? AsNullable<T>(this T value, T defval, T minval, T maxval) where T : struct, IEquatable<T>, IComparable<T>
         internal static T? AsNullable<T>(this T value, T defval, T minval, T maxval) where T : struct, IEquatable<T>, IComparable<T>
         {
         {

+ 2 - 2
src/glTF2Sharp.DOM/glTF2Sharp.DOM.csproj

@@ -14,7 +14,7 @@
     <PackageTags>glTF 3D</PackageTags>
     <PackageTags>glTF 3D</PackageTags>
     <Version>1.0.0-alpha0001</Version>
     <Version>1.0.0-alpha0001</Version>
     <LangVersion>latest</LangVersion>
     <LangVersion>latest</LangVersion>
-  </PropertyGroup>
+  </PropertyGroup>  
 
 
   <ItemGroup>
   <ItemGroup>
     <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
     <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
@@ -23,7 +23,7 @@
   </ItemGroup>
   </ItemGroup>
 
 
   <ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
+    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />    
     <PackageReference Include="System.Memory" Version="4.5.2" />
     <PackageReference Include="System.Memory" Version="4.5.2" />
     <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
     <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
   </ItemGroup>
   </ItemGroup>

+ 0 - 8
src/glTF2Sharp.Tests/GitUtils.cs

@@ -1,8 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace glTF2Sharp
-{
-    
-}

+ 12 - 11
src/glTF2Sharp.Tests/Schema2/CreateModelTests.cs

@@ -9,24 +9,23 @@ namespace glTF2Sharp.Schema2
     [TestFixture]
     [TestFixture]
     public class CreateModelTests
     public class CreateModelTests
     {
     {
-        [Test]
+        [Test(Description = "Creates an empty model")]
         public void CreateEmptyScene()
         public void CreateEmptyScene()
         {
         {
             var root = ModelRoot.CreateNew();
             var root = ModelRoot.CreateNew();
 
 
             var scene = root.UseScene("Empty Scene");
             var scene = root.UseScene("Empty Scene");
 
 
-            Assert.NotNull(scene);
-            Assert.AreEqual("Empty Scene", scene.Name);
+            Assert.NotNull(scene);            
             Assert.AreEqual("Empty Scene", root.DefaultScene.Name);            
             Assert.AreEqual("Empty Scene", root.DefaultScene.Name);            
         }
         }
 
 
-        [Test]
+        [Test(Description ="Creates a model with a triangle mesh")]
         public void CreateTriangleScene()
         public void CreateTriangleScene()
         {
         {
-            var root = ModelRoot.CreateNew();            
+            // Notice!! Although this is a valid way of creating a gltf mesh, it will be extremely GPU inefficient.
 
 
-            // create a mesh with a triangle
+            var root = ModelRoot.CreateNew();            
 
 
             var mesh = root.CreateMesh();
             var mesh = root.CreateMesh();
 
 
@@ -40,16 +39,16 @@ namespace glTF2Sharp.Schema2
                 new System.Numerics.Vector3(10, -10, 0)
                 new System.Numerics.Vector3(10, -10, 0)
                 );
                 );
 
 
-            var indices = root.CreateIndexBuffer(0, 1, 2);
+            var indices = root.CreateIndexBuffer( 0, 1, 2 );
 
 
             var positionsView = root.CreateBufferView(positions,null,null,null, BufferMode.ARRAY_BUFFER);
             var positionsView = root.CreateBufferView(positions,null,null,null, BufferMode.ARRAY_BUFFER);
             var indicesView =   root.CreateBufferView(indices, null, null, null, BufferMode.ELEMENT_ARRAY_BUFFER);
             var indicesView =   root.CreateBufferView(indices, null, null, null, BufferMode.ELEMENT_ARRAY_BUFFER);
 
 
             var positionsAccessor = root.CreateAccessor();
             var positionsAccessor = root.CreateAccessor();
-            positionsAccessor.SetVertexData(positionsView, ComponentType.FLOAT, ElementType.VEC3, false, 0, 3);
+            positionsAccessor.SetVertexData(positionsView, 0, ComponentType.FLOAT, ElementType.VEC3, false, 3);
 
 
             var indicesAccessor = root.CreateAccessor();
             var indicesAccessor = root.CreateAccessor();
-            indicesAccessor.SetIndexData(indicesView, IndexType.UNSIGNED_INT, 0, 3);
+            indicesAccessor.SetIndexData(indicesView, 0, IndexType.UNSIGNED_INT, 3);
 
 
             primitive.SetVertexAccessor("POSITION", positionsAccessor);
             primitive.SetVertexAccessor("POSITION", positionsAccessor);
             primitive.IndexAccessor = indicesAccessor;
             primitive.IndexAccessor = indicesAccessor;
@@ -58,9 +57,11 @@ namespace glTF2Sharp.Schema2
 
 
             var scene = root.UseScene("Empty Scene");
             var scene = root.UseScene("Empty Scene");
 
 
-            var triangleNode = scene.AddNode("Triangle");
+            var node = scene.AddNode("Triangle");
+
+            // assign the mesh we previously created
 
 
-            triangleNode.Mesh = mesh;
+            node.Mesh = mesh;
 
 
             // save
             // save