Vicente Penades 6 years ago
parent
commit
4efcef4f89
40 changed files with 536 additions and 374 deletions
  1. 41 0
      glTF2Sharp.ruleset
  2. 2 1
      glTF2Sharp.sln
  3. 23 10
      src/glTF2Sharp.CodeGen/CodeGen/EmitCSharp.cs
  4. 1 0
      src/glTF2Sharp.DOM/Collections/ChildrenCollection.cs
  5. 1 1
      src/glTF2Sharp.DOM/Debug/DebugViews.cs
  6. 13 15
      src/glTF2Sharp.DOM/Geometry/VertexBuffer.cs
  7. 3 3
      src/glTF2Sharp.DOM/Geometry/VertexElement.cs
  8. 12 4
      src/glTF2Sharp.DOM/IO/JsonSerializable.cs
  9. 2 1
      src/glTF2Sharp.DOM/IO/Serialization.cs
  10. 15 15
      src/glTF2Sharp.DOM/Memory/Arrays.cs
  11. 28 25
      src/glTF2Sharp.DOM/Memory/FloatingArrays.cs
  12. 9 6
      src/glTF2Sharp.DOM/Memory/IntegerArrays.cs
  13. 1 1
      src/glTF2Sharp.DOM/Memory/SparseArrays.cs
  14. 15 7
      src/glTF2Sharp.DOM/ModelException.cs
  15. 12 1
      src/glTF2Sharp.DOM/Schema2/Generated/ext.Unlit.g.cs
  16. 17 6
      src/glTF2Sharp.DOM/Schema2/Generated/ext.pbrSpecularGlossiness.g.cs
  17. 179 168
      src/glTF2Sharp.DOM/Schema2/Generated/gltf.g.cs
  18. 2 1
      src/glTF2Sharp.DOM/Schema2/glb.cs
  19. 5 5
      src/glTF2Sharp.DOM/Schema2/gltf.AccessorSparse.cs
  20. 13 13
      src/glTF2Sharp.DOM/Schema2/gltf.Accessors.cs
  21. 4 6
      src/glTF2Sharp.DOM/Schema2/gltf.Animations.cs
  22. 6 6
      src/glTF2Sharp.DOM/Schema2/gltf.BufferView.cs
  23. 1 1
      src/glTF2Sharp.DOM/Schema2/gltf.Camera.cs
  24. 1 1
      src/glTF2Sharp.DOM/Schema2/gltf.Extensions.cs
  25. 2 2
      src/glTF2Sharp.DOM/Schema2/gltf.LogicalChildOfRoot.cs
  26. 10 10
      src/glTF2Sharp.DOM/Schema2/gltf.Materials.cs
  27. 2 2
      src/glTF2Sharp.DOM/Schema2/gltf.Mesh.cs
  28. 11 8
      src/glTF2Sharp.DOM/Schema2/gltf.MeshPrimitive.cs
  29. 16 6
      src/glTF2Sharp.DOM/Schema2/gltf.Property.cs
  30. 3 3
      src/glTF2Sharp.DOM/Schema2/gltf.Root.cs
  31. 9 9
      src/glTF2Sharp.DOM/Schema2/gltf.Scene.cs
  32. 15 15
      src/glTF2Sharp.DOM/Schema2/gltf.Serialization.cs
  33. 2 2
      src/glTF2Sharp.DOM/Schema2/gltf.Skin.cs
  34. 3 2
      src/glTF2Sharp.DOM/Schema2/gltf.Textures.cs
  35. 2 2
      src/glTF2Sharp.DOM/Transforms/AffineTransform.cs
  36. 1 1
      src/glTF2Sharp.DOM/Transforms/BoundingBox.cs
  37. 19 14
      src/glTF2Sharp.DOM/_Extensions.cs
  38. 18 0
      src/glTF2Sharp.DOM/glTF2Sharp.DOM.csproj
  39. 1 1
      src/glTF2Sharp.Tests/Schema2/LoadModelTests.cs
  40. 16 0
      stylecop.json

+ 41 - 0
glTF2Sharp.ruleset

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RuleSet Name="ImageSharp" ToolsVersion="15.0">
+
+  <exclude-pattern>.*/Generated/*.cs</exclude-pattern>
+
+  <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
+    <Rule Id="AD0001" Action="None" />
+    <Rule Id="SA1008" Action="None" />
+    <Rule Id="SA1009" Action="None" />
+    <Rule Id="SA1025" Action="None" />
+    <Rule Id="SA1101" Action="None" />
+    <Rule Id="SA1107" Action="None" />
+    <Rule Id="SA1110" Action="None" />
+    <Rule Id="SA1111" Action="None" />
+    <Rule Id="SA1117" Action="None" />
+    <Rule Id="SA1121" Action="None" />
+    <Rule Id="SA1124" Action="None" />
+    <Rule Id="SA1200" Action="None" />
+    <Rule Id="SA1201" Action="None" />
+    <Rule Id="SA1205" Action="None" />
+    <Rule Id="SA1210" Action="None" />
+    <Rule Id="SA1300" Action="None" />
+    <Rule Id="SA1306" Action="None" />
+    <Rule Id="SA1309" Action="None" />
+    <Rule Id="SA1400" Action="None" />
+    <Rule Id="SA1402" Action="None" />
+    <Rule Id="SA1413" Action="None" />
+    <Rule Id="SA1500" Action="None" />
+    <Rule Id="SA1501" Action="None" />
+    <Rule Id="SA1502" Action="None" />
+    <Rule Id="SA1503" Action="None" />
+    <Rule Id="SA1512" Action="None" />
+    <Rule Id="SA1516" Action="None" />	
+    <Rule Id="SA1515" Action="None" />
+    <Rule Id="SA1625" Action="None" />
+    <Rule Id="SA1629" Action="None" />
+    <Rule Id="SA1633" Action="None" />
+    <Rule Id="SA1649" Action="None" />
+    <Rule Id="SA1652" Action="None" />
+  </Rules>
+</RuleSet>

+ 2 - 1
glTF2Sharp.sln

@@ -5,6 +5,7 @@ VisualStudioVersion = 15.0.28307.329
 MinimumVisualStudioVersion = 10.0.40219.1
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{29566B60-311D-42A0-9E8D-C48DECDD587F}"
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{29566B60-311D-42A0-9E8D-C48DECDD587F}"
 	ProjectSection(SolutionItems) = preProject
 	ProjectSection(SolutionItems) = preProject
+		glTF2Sharp.ruleset = glTF2Sharp.ruleset
 		README.md = README.md
 		README.md = README.md
 	EndProjectSection
 	EndProjectSection
 EndProject
 EndProject
@@ -20,7 +21,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "glTF2Sharp.Tests", "src\glT
 EndProject
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{D7D51F42-D08C-4DDA-88DA-AF008F10B644}"
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{D7D51F42-D08C-4DDA-88DA-AF008F10B644}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MeshBuffers", "src\MeshBuffers\MeshBuffers.csproj", "{1C93D96E-19DD-443B-8818-AAB14FEDA35D}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MeshBuffers", "src\MeshBuffers\MeshBuffers.csproj", "{1C93D96E-19DD-443B-8818-AAB14FEDA35D}"
 EndProject
 EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution

+ 23 - 10
src/glTF2Sharp.CodeGen/CodeGen/EmitCSharp.cs

@@ -310,8 +310,21 @@ namespace glTF2Sharp.CodeGen
             sb.AppendLine("//      This file has been programatically generated; DON´T EDIT!");
             sb.AppendLine("//      This file has been programatically generated; DON´T EDIT!");
             sb.AppendLine("//------------------------------------------------------------------------------------------------");
             sb.AppendLine("//------------------------------------------------------------------------------------------------");
 
 
-            sb.AppendLine();
-            sb.AppendLine();
+            sb.AppendLine();            
+            
+            sb.AppendLine("#pragma warning disable SA1001");
+            sb.AppendLine("#pragma warning disable SA1027");
+            sb.AppendLine("#pragma warning disable SA1028");
+            sb.AppendLine("#pragma warning disable SA1121");
+            sb.AppendLine("#pragma warning disable SA1205");
+            sb.AppendLine("#pragma warning disable SA1309");
+            sb.AppendLine("#pragma warning disable SA1402");
+            sb.AppendLine("#pragma warning disable SA1505");
+            sb.AppendLine("#pragma warning disable SA1507");
+            sb.AppendLine("#pragma warning disable SA1508");
+            sb.AppendLine("#pragma warning disable SA1652");
+
+            sb.AppendLine();           
 
 
             sb.AppendLine("using System;");
             sb.AppendLine("using System;");
             sb.AppendLine("using System.Collections.Generic;");
             sb.AppendLine("using System.Collections.Generic;");
@@ -500,7 +513,7 @@ namespace glTF2Sharp.CodeGen
                 {
                 {
                     // emit serializer
                     // emit serializer
                     var smethod = etype.UseIntegers ? "SerializePropertyEnumValue" : "SerializePropertyEnumSymbol";
                     var smethod = etype.UseIntegers ? "SerializePropertyEnumValue" : "SerializePropertyEnumSymbol";
-                    smethod = $"{smethod}<{trname}>(writer,\"{f.PersistentName}\",{frname}";
+                    smethod = $"{smethod}<{trname}>(writer, \"{f.PersistentName}\", {frname}";
                     if (f.DefaultValue != null) smethod += $", {frname}Default";
                     if (f.DefaultValue != null) smethod += $", {frname}Default";
                     smethod += ");";
                     smethod += ");";
                     this.AddFieldSerializerCase(smethod);
                     this.AddFieldSerializerCase(smethod);
@@ -523,19 +536,19 @@ namespace glTF2Sharp.CodeGen
 
 
             if (f.FieldType is ClassType ctype)
             if (f.FieldType is ClassType ctype)
             {
             {
-                return $"SerializePropertyObject(writer,\"{pname}\",{fname});";
+                return $"SerializePropertyObject(writer, \"{pname}\", {fname});";
             }
             }
 
 
             if (f.FieldType is ArrayType atype)
             if (f.FieldType is ArrayType atype)
             {
             {
-                if (f.MinItems > 0) return $"SerializeProperty(writer,\"{pname}\",{fname},{fname}MinItems);";
+                if (f.MinItems > 0) return $"SerializeProperty(writer, \"{pname}\", {fname}, {fname}MinItems);";
 
 
                 return $"SerializeProperty(writer,\"{pname}\",{fname});";
                 return $"SerializeProperty(writer,\"{pname}\",{fname});";
             }
             }
 
 
-            if (f.DefaultValue != null) return $"SerializeProperty(writer,\"{pname}\",{fname},{fname}Default);";
+            if (f.DefaultValue != null) return $"SerializeProperty(writer, \"{pname}\", {fname}, {fname}Default);";
 
 
-            return $"SerializeProperty(writer,\"{pname}\",{fname});";
+            return $"SerializeProperty(writer, \"{pname}\", {fname});";
         }
         }
 
 
         private string _GetJSonDeserializerMethod(FieldInfo f)
         private string _GetJSonDeserializerMethod(FieldInfo f)
@@ -545,12 +558,12 @@ namespace glTF2Sharp.CodeGen
             if (f.FieldType is ArrayType atype)
             if (f.FieldType is ArrayType atype)
             {
             {
                 var titem = _Emitter._GetRuntimeName(atype.ItemType);
                 var titem = _Emitter._GetRuntimeName(atype.ItemType);
-                return $"DeserializeList<{titem}>(reader,{fname});";
+                return $"DeserializeList<{titem}>(reader, {fname});";
             }
             }
             else if (f.FieldType is DictionaryType dtype)
             else if (f.FieldType is DictionaryType dtype)
             {
             {
                 var titem = _Emitter._GetRuntimeName(dtype.ValueType);
                 var titem = _Emitter._GetRuntimeName(dtype.ValueType);
-                return $"DeserializeDictionary<{titem}>(reader,{fname});";
+                return $"DeserializeDictionary<{titem}>(reader, {fname});";
             }
             }
 
 
             return $"{fname} = DeserializeValue<{_Emitter._GetRuntimeName(f.FieldType)}>(reader);";
             return $"{fname} = DeserializeValue<{_Emitter._GetRuntimeName(f.FieldType)}>(reader);";
@@ -588,7 +601,7 @@ namespace glTF2Sharp.CodeGen
             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;
-            if (HasBaseClass) yield return "default: base.DeserializeProperty(reader,property); break;".Indent(3);
+            if (HasBaseClass) yield return "default: base.DeserializeProperty(reader, property); break;".Indent(3);
             else yield return "default: throw new NotImplementedException();".Indent(3);
             else yield return "default: throw new NotImplementedException();".Indent(3);
 
 
             yield return "}".Indent(2);
             yield return "}".Indent(2);

+ 1 - 0
src/glTF2Sharp.DOM/Collections/ChildrenCollection.cs

@@ -159,6 +159,7 @@ 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);

+ 1 - 1
src/glTF2Sharp.DOM/Debug/DebugViews.cs

@@ -49,5 +49,5 @@ namespace glTF2Sharp.Debug
 
 
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
         public Schema2.Accessor[] Accessors => _Value.Accessors.ToArray();
         public Schema2.Accessor[] Accessors => _Value.Accessors.ToArray();
-    }    
+    }
 }
 }

+ 13 - 15
src/glTF2Sharp.DOM/Geometry/VertexBuffer.cs

@@ -4,7 +4,6 @@ using System.Text;
 using System.Linq;
 using System.Linq;
 using System.Numerics;
 using System.Numerics;
 
 
-
 namespace glTF2Sharp.Geometry
 namespace glTF2Sharp.Geometry
 {
 {
     using SCALARARRAY = Memory.IEncodedArray<Single>;
     using SCALARARRAY = Memory.IEncodedArray<Single>;
@@ -93,17 +92,16 @@ namespace glTF2Sharp.Geometry
             }
             }
         }
         }
 
 
-        public void CopyTo(IReadOnlyDictionary<string,Schema2.Accessor> vertexAccessors)
+        public void CopyTo(IReadOnlyDictionary<string, Schema2.Accessor> vertexAccessors)
         {
         {
-            foreach(var key in vertexAccessors.Keys)
+            foreach (var key in vertexAccessors.Keys)
             {
             {
                 var dim = GetDimensions(key);
                 var dim = GetDimensions(key);
                 if (dim == 1) Memory.EncodedArrayUtils.CopyTo(this.GetScalarColumn(key), vertexAccessors[key].AsScalarArray());
                 if (dim == 1) Memory.EncodedArrayUtils.CopyTo(this.GetScalarColumn(key), vertexAccessors[key].AsScalarArray());
                 if (dim == 2) Memory.EncodedArrayUtils.CopyTo(this.GetVector2Column(key), vertexAccessors[key].AsVector2Array());
                 if (dim == 2) Memory.EncodedArrayUtils.CopyTo(this.GetVector2Column(key), vertexAccessors[key].AsVector2Array());
                 if (dim == 3) Memory.EncodedArrayUtils.CopyTo(this.GetVector3Column(key), vertexAccessors[key].AsVector3Array());
                 if (dim == 3) Memory.EncodedArrayUtils.CopyTo(this.GetVector3Column(key), vertexAccessors[key].AsVector3Array());
                 if (dim == 4) Memory.EncodedArrayUtils.CopyTo(this.GetVector4Column(key), vertexAccessors[key].AsVector4Array());
                 if (dim == 4) Memory.EncodedArrayUtils.CopyTo(this.GetVector4Column(key), vertexAccessors[key].AsVector4Array());
-            }           
-            
+            }
         }
         }
 
 
         #endregion
         #endregion
@@ -120,11 +118,11 @@ namespace glTF2Sharp.Geometry
             return dstBuffer;
             return dstBuffer;
         }
         }
 
 
-        #endregion 
+        #endregion
     }
     }
 
 
     /// <summary>
     /// <summary>
-    /// Represents a fixed collection of vertices with a specific vertex attributes definition. 
+    /// Represents a fixed collection of vertices with a specific vertex attributes definition.
     /// </summary>
     /// </summary>
     public class VertexArray : VertexBuffer
     public class VertexArray : VertexBuffer
     {
     {
@@ -166,7 +164,7 @@ namespace glTF2Sharp.Geometry
 
 
         public int ByteStride => _ByteStride;
         public int ByteStride => _ByteStride;
 
 
-        public Byte[] Data => _Buffer;        
+        public Byte[] Data => _Buffer;
 
 
         #endregion
         #endregion
 
 
@@ -176,7 +174,7 @@ namespace glTF2Sharp.Geometry
 
 
         public override SCALARARRAY GetScalarColumn(String attribute, int rowStart = 0, int rowCount = int.MaxValue)
         public override SCALARARRAY GetScalarColumn(String attribute, int rowStart = 0, int rowCount = int.MaxValue)
         {
         {
-            Guard.MustBeBetweenOrEqualTo(rowStart, 0, Count - rowCount, nameof(rowStart));            
+            Guard.MustBeBetweenOrEqualTo(rowStart, 0, Count - rowCount, nameof(rowStart));
 
 
             var column = VertexElement._GetColumn(_Buffer, _Elements, attribute, rowStart, rowCount);
             var column = VertexElement._GetColumn(_Buffer, _Elements, attribute, rowStart, rowCount);
             if (column.Item3.Dimensions.DimCount() != 1) throw new ArgumentException(nameof(attribute));
             if (column.Item3.Dimensions.DimCount() != 1) throw new ArgumentException(nameof(attribute));
@@ -185,7 +183,7 @@ namespace glTF2Sharp.Geometry
 
 
         public override VECTOR2ARRAY GetVector2Column(String attribute, int rowStart = 0, int rowCount = int.MaxValue)
         public override VECTOR2ARRAY GetVector2Column(String attribute, int rowStart = 0, int rowCount = int.MaxValue)
         {
         {
-            Guard.MustBeBetweenOrEqualTo(rowStart, 0, Count - rowCount, nameof(rowStart));            
+            Guard.MustBeBetweenOrEqualTo(rowStart, 0, Count - rowCount, nameof(rowStart));
 
 
             var column = VertexElement._GetColumn(_Buffer, _Elements, attribute, rowStart, rowCount);
             var column = VertexElement._GetColumn(_Buffer, _Elements, attribute, rowStart, rowCount);
             if (column.Item3.Dimensions.DimCount() != 2) throw new ArgumentException(nameof(attribute));
             if (column.Item3.Dimensions.DimCount() != 2) throw new ArgumentException(nameof(attribute));
@@ -194,7 +192,7 @@ namespace glTF2Sharp.Geometry
 
 
         public override VECTOR3ARRAY GetVector3Column(String attribute, int rowStart = 0, int rowCount = int.MaxValue)
         public override VECTOR3ARRAY GetVector3Column(String attribute, int rowStart = 0, int rowCount = int.MaxValue)
         {
         {
-            Guard.MustBeBetweenOrEqualTo(rowStart, 0, Count - rowCount, nameof(rowStart));            
+            Guard.MustBeBetweenOrEqualTo(rowStart, 0, Count - rowCount, nameof(rowStart));
 
 
             var column = VertexElement._GetColumn(_Buffer, _Elements, attribute, rowStart, rowCount);
             var column = VertexElement._GetColumn(_Buffer, _Elements, attribute, rowStart, rowCount);
             if (column.Item3.Dimensions.DimCount() != 3) throw new ArgumentException(nameof(attribute));
             if (column.Item3.Dimensions.DimCount() != 3) throw new ArgumentException(nameof(attribute));
@@ -203,14 +201,14 @@ namespace glTF2Sharp.Geometry
 
 
         public override VECTOR4ARRAY GetVector4Column(String attribute, int rowStart = 0, int rowCount = int.MaxValue)
         public override VECTOR4ARRAY GetVector4Column(String attribute, int rowStart = 0, int rowCount = int.MaxValue)
         {
         {
-            Guard.MustBeBetweenOrEqualTo(rowStart, 0, Count - rowCount, nameof(rowStart));            
+            Guard.MustBeBetweenOrEqualTo(rowStart, 0, Count - rowCount, nameof(rowStart));
 
 
             var column = VertexElement._GetColumn(_Buffer, _Elements, attribute, rowStart, rowCount);
             var column = VertexElement._GetColumn(_Buffer, _Elements, attribute, rowStart, rowCount);
             if (column.Item3.Dimensions.DimCount() != 4) throw new ArgumentException(nameof(attribute));
             if (column.Item3.Dimensions.DimCount() != 4) throw new ArgumentException(nameof(attribute));
             return new Memory.Vector4Array(column.Item1, column.Item2, column.Item3.Encoding, column.Item3.Normalized);
             return new Memory.Vector4Array(column.Item1, column.Item2, column.Item3.Encoding, column.Item3.Normalized);
-        }                
-        
-        #endregion              
+        }
+
+        #endregion
     }
     }
 
 
     /// <summary>
     /// <summary>

+ 3 - 3
src/glTF2Sharp.DOM/Geometry/VertexElement.cs

@@ -6,7 +6,7 @@ using System.Numerics;
 
 
 namespace glTF2Sharp.Geometry
 namespace glTF2Sharp.Geometry
 {
 {
-    using Schema2;    
+    using Schema2;
 
 
     /// <summary>
     /// <summary>
     /// Defines a vertex attribute, dimensions and encoding.
     /// Defines a vertex attribute, dimensions and encoding.
@@ -110,7 +110,7 @@ namespace glTF2Sharp.Geometry
             return new Memory.Vector4Array(column.Item1, column.Item2, column.Item3.Encoding, column.Item3.Normalized);
             return new Memory.Vector4Array(column.Item1, column.Item2, column.Item3.Encoding, column.Item3.Normalized);
         }
         }
 
 
-        internal static (ArraySegment<Byte>, int, VertexElement) _GetColumn(Byte[] data, VertexElement[] elements, string attribute, int rowStart, int rowCount)
+        internal static(ArraySegment<Byte>, int, VertexElement) _GetColumn(Byte[] data, VertexElement[] elements, string attribute, int rowStart, int rowCount)
         {
         {
             var index = Array.FindIndex(elements, item => item.Attribute == attribute);
             var index = Array.FindIndex(elements, item => item.Attribute == attribute);
             if (index < 0) throw new ArgumentException(nameof(attribute));
             if (index < 0) throw new ArgumentException(nameof(attribute));
@@ -118,7 +118,7 @@ namespace glTF2Sharp.Geometry
             var element = elements[index];
             var element = elements[index];
 
 
             var byteStride = GetVertexByteSize(elements);
             var byteStride = GetVertexByteSize(elements);
-            var byteOffset = elements.Take(index).Sum(item => item.ByteSize) + rowStart * byteStride;
+            var byteOffset = elements.Take(index).Sum(item => item.ByteSize) + (rowStart * byteStride);
             var byteLength = data.Length - byteOffset;
             var byteLength = data.Length - byteOffset;
 
 
             if (rowCount < int.MaxValue) byteLength = rowCount * byteStride;
             if (rowCount < int.MaxValue) byteLength = rowCount * byteStride;

+ 12 - 4
src/glTF2Sharp.DOM/IO/JsonSerializable.cs

@@ -107,7 +107,8 @@ namespace glTF2Sharp.IO
             _Serialize(writer, value.Value);
             _Serialize(writer, value.Value);
         }
         }
 
 
-        protected static void SerializePropertyEnumValue<T>(JsonWriter writer, string name, T? value, T? defval = null) where T : struct
+        protected static void SerializePropertyEnumValue<T>(JsonWriter writer, string name, T? value, T? defval = null)
+            where T : struct
         {
         {
             if (!typeof(T).IsEnum) throw new ArgumentException(nameof(value));
             if (!typeof(T).IsEnum) throw new ArgumentException(nameof(value));
 
 
@@ -117,7 +118,8 @@ namespace glTF2Sharp.IO
             SerializeProperty(writer, name, (int)(Object)value);
             SerializeProperty(writer, name, (int)(Object)value);
         }
         }
 
 
-        protected static void SerializePropertyEnumSymbol<T>(JsonWriter writer, string name, T? value, T? defval = null) where T : struct
+        protected static void SerializePropertyEnumSymbol<T>(JsonWriter writer, string name, T? value, T? defval = null)
+            where T : struct
         {
         {
             if (!typeof(T).IsEnum) throw new ArgumentException(nameof(value));
             if (!typeof(T).IsEnum) throw new ArgumentException(nameof(value));
 
 
@@ -127,7 +129,8 @@ namespace glTF2Sharp.IO
             SerializeProperty(writer, name, Enum.GetName(typeof(T), value));
             SerializeProperty(writer, name, Enum.GetName(typeof(T), value));
         }
         }
 
 
-        protected static void SerializePropertyObject<T>(JsonWriter writer, string name, T value) where T : JsonSerializable
+        protected static void SerializePropertyObject<T>(JsonWriter writer, string name, T value)
+            where T : JsonSerializable
         {
         {
             if (value == null) return;
             if (value == null) return;
             writer.WritePropertyName(name);
             writer.WritePropertyName(name);
@@ -146,6 +149,7 @@ namespace glTF2Sharp.IO
             {
             {
                 _Serialize(writer, item);
                 _Serialize(writer, item);
             }
             }
+
             writer.WriteEndArray();
             writer.WriteEndArray();
         }
         }
 
 
@@ -163,6 +167,7 @@ namespace glTF2Sharp.IO
                 writer.WritePropertyName(item.Key);
                 writer.WritePropertyName(item.Key);
                 _Serialize(writer, item.Value);
                 _Serialize(writer, item.Value);
             }
             }
+
             writer.WriteEndObject();
             writer.WriteEndObject();
         }
         }
 
 
@@ -223,7 +228,10 @@ namespace glTF2Sharp.IO
                     var curProp = reader.Value.ToString();
                     var curProp = reader.Value.ToString();
                     DeserializeProperty(reader, curProp);
                     DeserializeProperty(reader, curProp);
                 }
                 }
-                else throw new NotImplementedException(); // skip
+                else
+                {
+                    throw new NotImplementedException(); // skip
+                }
             }
             }
         }
         }
 
 

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

@@ -21,7 +21,8 @@ namespace glTF2Sharp.IO
             return Convert.ChangeType(reader.Value, vtype, System.Globalization.CultureInfo.InvariantCulture);
             return Convert.ChangeType(reader.Value, vtype, System.Globalization.CultureInfo.InvariantCulture);
         }
         }
 
 
-        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));
         }
         }

+ 15 - 15
src/glTF2Sharp.DOM/Memory/Arrays.cs

@@ -5,10 +5,10 @@ using System.Numerics;
 using System.Text;
 using System.Text;
 
 
 namespace glTF2Sharp.Memory
 namespace glTF2Sharp.Memory
-{    
+{
     public interface IEncodedArray<T> : IReadOnlyCollection<T>
     public interface IEncodedArray<T> : IReadOnlyCollection<T>
         where T : unmanaged
         where T : unmanaged
-    {        
+    {
         T this[int index] { get; set; }
         T this[int index] { get; set; }
 
 
         void CopyTo(ArraySegment<T> dst);
         void CopyTo(ArraySegment<T> dst);
@@ -19,20 +19,19 @@ namespace glTF2Sharp.Memory
     }
     }
 
 
     struct EncodedArrayEnumerator<T> : IEnumerator<T>
     struct EncodedArrayEnumerator<T> : IEnumerator<T>
-        where T: unmanaged
+        where T : unmanaged
     {
     {
-        #region lifecycle        
+        #region lifecycle
 
 
         public EncodedArrayEnumerator(IEncodedArray<T> accessor)
         public EncodedArrayEnumerator(IEncodedArray<T> accessor)
         {
         {
             this._Accessor = accessor;
             this._Accessor = accessor;
             this._Count = accessor.Count;
             this._Count = accessor.Count;
-            this._Index = -1;            
+            this._Index = -1;
         }
         }
 
 
         public void Dispose()
         public void Dispose()
         {
         {
-
         }
         }
 
 
         #endregion
         #endregion
@@ -49,7 +48,7 @@ namespace glTF2Sharp.Memory
 
 
         public T Current => _Accessor[_Index];
         public T Current => _Accessor[_Index];
 
 
-        object IEnumerator.Current => _Accessor[_Index];        
+        object IEnumerator.Current => _Accessor[_Index];
 
 
         public bool MoveNext()
         public bool MoveNext()
         {
         {
@@ -77,24 +76,26 @@ namespace glTF2Sharp.Memory
         }
         }
 
 
         public static void CopyTo<T>(T[] src, IEncodedArray<T> dst, int dstOffset = 0)
         public static void CopyTo<T>(T[] src, IEncodedArray<T> dst, int dstOffset = 0)
-            where T: unmanaged
+            where T : unmanaged
         {
         {
-            for(int i=0; i < src.Length; ++i)
+            for (int i = 0; i < src.Length; ++i)
             {
             {
-                dst[i+ dstOffset] = src[i];
+                dst[i + dstOffset] = src[i];
             }
             }
         }
         }
 
 
-        public static void Copy<T>(IEncodedArray<T> src, T[] dst) where T : unmanaged
+        public static void Copy<T>(IEncodedArray<T> src, T[] dst)
+            where T : unmanaged
         {
         {
             Copy<T>(src, new ArraySegment<T>(dst));
             Copy<T>(src, new ArraySegment<T>(dst));
         }
         }
 
 
-        public static void Copy<T>(IEncodedArray<T> src, ArraySegment<T> dst) where T : unmanaged
+        public static void Copy<T>(IEncodedArray<T> src, ArraySegment<T> dst)
+            where T : unmanaged
         {
         {
             var c = src.Count;
             var c = src.Count;
             for (int i = 0; i < c; ++i) dst.Array[dst.Offset + i] = src[i];
             for (int i = 0; i < c; ++i) dst.Array[dst.Offset + i] = src[i];
-        }                
+        }
 
 
         public static (Single, Single) GetBounds(ScalarArray accesor)
         public static (Single, Single) GetBounds(ScalarArray accesor)
         {
         {
@@ -161,7 +162,6 @@ namespace glTF2Sharp.Memory
         }
         }
     }
     }
 
 
-
     /// <summary>
     /// <summary>
     /// Wraps a collection of Scalar values and exposes it as a collection of Vector4 values
     /// Wraps a collection of Scalar values and exposes it as a collection of Vector4 values
     /// </summary>
     /// </summary>
@@ -180,7 +180,7 @@ namespace glTF2Sharp.Memory
         {
         {
             get => new Vector4(_Accessor[index], 0, 0, 0);
             get => new Vector4(_Accessor[index], 0, 0, 0);
             set => _Accessor[index] = value.X;
             set => _Accessor[index] = value.X;
-        }        
+        }
 
 
         public void CopyTo(ArraySegment<Vector4> dst) { EncodedArrayUtils.Copy(this, dst); }
         public void CopyTo(ArraySegment<Vector4> dst) { EncodedArrayUtils.Copy(this, dst); }
 
 

+ 28 - 25
src/glTF2Sharp.DOM/Memory/FloatingArrays.cs

@@ -6,7 +6,7 @@ using System.Collections;
 using System.Linq;
 using System.Linq;
 
 
 namespace glTF2Sharp.Memory
 namespace glTF2Sharp.Memory
-{    
+{
     using BYTES = ArraySegment<Byte>;
     using BYTES = ArraySegment<Byte>;
 
 
     using ENCODING = Schema2.ComponentType;
     using ENCODING = Schema2.ComponentType;
@@ -19,7 +19,7 @@ namespace glTF2Sharp.Memory
         #region constructors
         #region constructors
 
 
         public FloatingAccessor(Byte[] data, ENCODING encoding, Boolean normalized)
         public FloatingAccessor(Byte[] data, ENCODING encoding, Boolean normalized)
-            : this(new BYTES(data), encoding, normalized) { }        
+            : this(new BYTES(data), encoding, normalized) { }
 
 
         public FloatingAccessor(BYTES data, ENCODING encoding, Boolean normalized)
         public FloatingAccessor(BYTES data, ENCODING encoding, Boolean normalized)
         {
         {
@@ -65,6 +65,7 @@ namespace glTF2Sharp.Memory
                                 this._Getter = this._GetNormalizedU16;
                                 this._Getter = this._GetNormalizedU16;
                                 break;
                                 break;
                             }
                             }
+
                         default: throw new ArgumentException(nameof(encoding));
                         default: throw new ArgumentException(nameof(encoding));
                     }
                     }
                 }
                 }
@@ -113,7 +114,7 @@ namespace glTF2Sharp.Memory
                         default: throw new ArgumentException(nameof(encoding));
                         default: throw new ArgumentException(nameof(encoding));
                     }
                     }
                 }
                 }
-            }            
+            }
         }
         }
 
 
         private Single _GetValueU8(int byteOffset, int index) { return _GetValue<Byte>(byteOffset, index); }
         private Single _GetValueU8(int byteOffset, int index) { return _GetValue<Byte>(byteOffset, index); }
@@ -143,12 +144,14 @@ namespace glTF2Sharp.Memory
         private Single _GetNormalizedS16(int byteOffset, int index) { return Math.Max(_GetValueS16(byteOffset, index) / 32767.0f, -1); }
         private Single _GetNormalizedS16(int byteOffset, int index) { return Math.Max(_GetValueS16(byteOffset, index) / 32767.0f, -1); }
         private void _SetNormalizedS16(int byteOffset, int index, Single value) { _SetValueS16(byteOffset, index, (Single)Math.Round(value * 32767.0f)); }
         private void _SetNormalizedS16(int byteOffset, int index, Single value) { _SetValueS16(byteOffset, index, (Single)Math.Round(value * 32767.0f)); }
 
 
-        private T _GetValue<T>(int byteOffset, int index) where T : unmanaged
+        private T _GetValue<T>(int byteOffset, int index)
+            where T : unmanaged
         {
         {
             return System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, T>(_Data.AsSpan(byteOffset))[index];
             return System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, T>(_Data.AsSpan(byteOffset))[index];
         }
         }
 
 
-        private void _SetValue<T>(int byteOffset, int index, T value) where T : unmanaged
+        private void _SetValue<T>(int byteOffset, int index, T value)
+            where T : unmanaged
         {
         {
             System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, T>(_Data.AsSpan(byteOffset))[index] = value;
             System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, T>(_Data.AsSpan(byteOffset))[index] = value;
         }
         }
@@ -181,7 +184,7 @@ namespace glTF2Sharp.Memory
         {
         {
             get => _Getter(byteOffset, index);
             get => _Getter(byteOffset, index);
             set => _Setter(byteOffset, index, value);
             set => _Setter(byteOffset, index, value);
-        }        
+        }
 
 
         #endregion
         #endregion
     }
     }
@@ -230,14 +233,14 @@ namespace glTF2Sharp.Memory
 
 
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
         public int Count => _ItemCount;
         public int Count => _ItemCount;
-        
+
         public Single this[int index]
         public Single this[int index]
         {
         {
             get => _Accesor[index * _ByteStride, 0];
             get => _Accesor[index * _ByteStride, 0];
             set => _Accesor[index * _ByteStride, 0] = value;
             set => _Accesor[index * _ByteStride, 0] = value;
-        }                
+        }
 
 
-        public void CopyTo(ArraySegment<Single> dst) { EncodedArrayUtils.Copy<Single>(this, dst); }        
+        public void CopyTo(ArraySegment<Single> dst) { EncodedArrayUtils.Copy<Single>(this, dst); }
 
 
         public IEnumerator<Single> GetEnumerator() { return new EncodedArrayEnumerator<Single>(this); }
         public IEnumerator<Single> GetEnumerator() { return new EncodedArrayEnumerator<Single>(this); }
 
 
@@ -245,22 +248,22 @@ namespace glTF2Sharp.Memory
 
 
         public (Single, Single) GetBounds() { return EncodedArrayUtils.GetBounds(this); }
         public (Single, Single) GetBounds() { return EncodedArrayUtils.GetBounds(this); }
 
 
-        public IEncodedArray<Vector4> AsVector4() { return new _MapScalarToVector4(this); }        
+        public IEncodedArray<Vector4> AsVector4() { return new _MapScalarToVector4(this); }
 
 
         #endregion
         #endregion
     }
     }
 
 
     /// <summary>
     /// <summary>
     /// Wraps an encoded byte array and exposes it as a collection of Vector2 values
     /// Wraps an encoded byte array and exposes it as a collection of Vector2 values
-    /// </summary>    
+    /// </summary>
     [System.Diagnostics.DebuggerDisplay("Vector2 Accessor {Count}")]
     [System.Diagnostics.DebuggerDisplay("Vector2 Accessor {Count}")]
     public struct Vector2Array : IEncodedArray<Vector2>
     public struct Vector2Array : IEncodedArray<Vector2>
     {
     {
         #region constructors
         #region constructors
 
 
         public Vector2Array(Byte[] data, int byteStride, ENCODING encoding, Boolean normalized)
         public Vector2Array(Byte[] data, int byteStride, ENCODING encoding, Boolean normalized)
-            : this(new BYTES(data),byteStride,encoding,normalized) { }
-        
+            : this(new BYTES(data), byteStride, encoding, normalized) { }
+
         public Vector2Array(BYTES data, int byteStride, ENCODING encoding, Boolean normalized)
         public Vector2Array(BYTES data, int byteStride, ENCODING encoding, Boolean normalized)
         {
         {
             var len = encoding.ByteLength() * 2;
             var len = encoding.ByteLength() * 2;
@@ -309,9 +312,9 @@ namespace glTF2Sharp.Memory
                 _Accesor[index, 0] = value.X;
                 _Accesor[index, 0] = value.X;
                 _Accesor[index, 1] = value.Y;
                 _Accesor[index, 1] = value.Y;
             }
             }
-        }        
+        }
 
 
-        public void CopyTo(ArraySegment<Vector2> dst) { EncodedArrayUtils.Copy<Vector2>(this, dst); }        
+        public void CopyTo(ArraySegment<Vector2> dst) { EncodedArrayUtils.Copy<Vector2>(this, dst); }
 
 
         public IEnumerator<Vector2> GetEnumerator() { return new EncodedArrayEnumerator<Vector2>(this); }
         public IEnumerator<Vector2> GetEnumerator() { return new EncodedArrayEnumerator<Vector2>(this); }
 
 
@@ -319,16 +322,16 @@ namespace glTF2Sharp.Memory
 
 
         public (Vector2, Vector2) GetBounds() { return EncodedArrayUtils.GetBounds(this); }
         public (Vector2, Vector2) GetBounds() { return EncodedArrayUtils.GetBounds(this); }
 
 
-        public IEncodedArray<Vector4> AsVector4() { return new _MapVector2ToVector4(this); }        
+        public IEncodedArray<Vector4> AsVector4() { return new _MapVector2ToVector4(this); }
 
 
         #endregion
         #endregion
     }
     }
 
 
     /// <summary>
     /// <summary>
     /// Wraps an encoded byte array and exposes it as a collection of Vector3 values
     /// Wraps an encoded byte array and exposes it as a collection of Vector3 values
-    /// </summary>    
+    /// </summary>
     [System.Diagnostics.DebuggerDisplay("Vector3 Accessor {Count}")]
     [System.Diagnostics.DebuggerDisplay("Vector3 Accessor {Count}")]
-    public struct Vector3Array: IEncodedArray<Vector3>
+    public struct Vector3Array : IEncodedArray<Vector3>
     {
     {
         #region constructors
         #region constructors
 
 
@@ -341,7 +344,7 @@ namespace glTF2Sharp.Memory
 
 
             _Accesor = new FloatingAccessor(data, encoding, normalized);
             _Accesor = new FloatingAccessor(data, encoding, normalized);
             _ByteStride = Math.Max(len, byteStride);
             _ByteStride = Math.Max(len, byteStride);
-            
+
             _ItemCount = _Accesor.ByteLength / _ByteStride;
             _ItemCount = _Accesor.ByteLength / _ByteStride;
             if ((_Accesor.ByteLength % _ByteStride) >= len) ++_ItemCount;
             if ((_Accesor.ByteLength % _ByteStride) >= len) ++_ItemCount;
         }
         }
@@ -384,9 +387,9 @@ namespace glTF2Sharp.Memory
                 _Accesor[index, 1] = value.Y;
                 _Accesor[index, 1] = value.Y;
                 _Accesor[index, 2] = value.Z;
                 _Accesor[index, 2] = value.Z;
             }
             }
-        }        
+        }
 
 
-        public void CopyTo(ArraySegment<Vector3> dst) { EncodedArrayUtils.Copy<Vector3>(this, dst); }        
+        public void CopyTo(ArraySegment<Vector3> dst) { EncodedArrayUtils.Copy<Vector3>(this, dst); }
 
 
         public IEnumerator<Vector3> GetEnumerator() { return new EncodedArrayEnumerator<Vector3>(this); }
         public IEnumerator<Vector3> GetEnumerator() { return new EncodedArrayEnumerator<Vector3>(this); }
 
 
@@ -403,7 +406,7 @@ namespace glTF2Sharp.Memory
     /// Wraps an encoded byte array and exposes it as a collection of Vector4 values
     /// Wraps an encoded byte array and exposes it as a collection of Vector4 values
     /// </summary>
     /// </summary>
     [System.Diagnostics.DebuggerDisplay("Vector4 Accessor {Count}")]
     [System.Diagnostics.DebuggerDisplay("Vector4 Accessor {Count}")]
-    public struct Vector4Array: IEncodedArray<Vector4>
+    public struct Vector4Array : IEncodedArray<Vector4>
     {
     {
         #region constructors
         #region constructors
 
 
@@ -460,7 +463,7 @@ namespace glTF2Sharp.Memory
                 _Accesor[index, 2] = value.Z;
                 _Accesor[index, 2] = value.Z;
                 _Accesor[index, 3] = value.W;
                 _Accesor[index, 3] = value.W;
             }
             }
-        }        
+        }
 
 
         public void CopyTo(ArraySegment<Vector4> dst) { EncodedArrayUtils.Copy<Vector4>(this, dst); }
         public void CopyTo(ArraySegment<Vector4> dst) { EncodedArrayUtils.Copy<Vector4>(this, dst); }
 
 
@@ -536,9 +539,9 @@ namespace glTF2Sharp.Memory
                 _Accesor[index, 2] = value.Z;
                 _Accesor[index, 2] = value.Z;
                 _Accesor[index, 3] = value.W;
                 _Accesor[index, 3] = value.W;
             }
             }
-        }        
+        }
 
 
-        public void CopyTo(ArraySegment<Quaternion> dst) { EncodedArrayUtils.Copy<Quaternion>(this, dst); }        
+        public void CopyTo(ArraySegment<Quaternion> dst) { EncodedArrayUtils.Copy<Quaternion>(this, dst); }
 
 
         public IEnumerator<Quaternion> GetEnumerator() { return new EncodedArrayEnumerator<Quaternion>(this); }
         public IEnumerator<Quaternion> GetEnumerator() { return new EncodedArrayEnumerator<Quaternion>(this); }
 
 

+ 9 - 6
src/glTF2Sharp.DOM/Memory/IntegerArrays.cs

@@ -5,7 +5,7 @@ using System.Collections;
 using System.Linq;
 using System.Linq;
 
 
 namespace glTF2Sharp.Memory
 namespace glTF2Sharp.Memory
-{    
+{
     using BYTES = ArraySegment<Byte>;
     using BYTES = ArraySegment<Byte>;
 
 
     using ENCODING = Schema2.IndexType;
     using ENCODING = Schema2.IndexType;
@@ -50,8 +50,9 @@ namespace glTF2Sharp.Memory
                         this._Getter = this._GetValue<UInt32>;
                         this._Getter = this._GetValue<UInt32>;
                         break;
                         break;
                     }
                     }
+
                 default: throw new ArgumentException(nameof(encoding));
                 default: throw new ArgumentException(nameof(encoding));
-            }            
+            }
         }
         }
 
 
         private UInt32 _GetValueU8(int index) { return _GetValue<Byte>(index); }
         private UInt32 _GetValueU8(int index) { return _GetValue<Byte>(index); }
@@ -60,12 +61,14 @@ namespace glTF2Sharp.Memory
         private UInt32 _GetValueU16(int index) { return _GetValue<UInt16>(index); }
         private UInt32 _GetValueU16(int index) { return _GetValue<UInt16>(index); }
         private void _SetValueU16(int index, UInt32 value) { _SetValue<UInt16>(index, (UInt16)value); }
         private void _SetValueU16(int index, UInt32 value) { _SetValue<UInt16>(index, (UInt16)value); }
 
 
-        private T _GetValue<T>(int index) where T : unmanaged
+        private T _GetValue<T>(int index)
+            where T : unmanaged
         {
         {
             return System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, T>(_Data)[index];
             return System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, T>(_Data)[index];
         }
         }
 
 
-        private void _SetValue<T>(int index, T value) where T : unmanaged
+        private void _SetValue<T>(int index, T value)
+            where T : unmanaged
         {
         {
             System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, T>(_Data)[index] = value;
             System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, T>(_Data)[index] = value;
         }
         }
@@ -104,9 +107,9 @@ namespace glTF2Sharp.Memory
         {
         {
             get => _Getter(index);
             get => _Getter(index);
             set => _Setter(index, value);
             set => _Setter(index, value);
-        }        
+        }
 
 
-        public void CopyTo(ArraySegment<UInt32> dst) { EncodedArrayUtils.Copy<UInt32>(this, dst); }        
+        public void CopyTo(ArraySegment<UInt32> dst) { EncodedArrayUtils.Copy<UInt32>(this, dst); }
 
 
         public IEnumerator<UInt32> GetEnumerator() { return new EncodedArrayEnumerator<UInt32>(this); }
         public IEnumerator<UInt32> GetEnumerator() { return new EncodedArrayEnumerator<UInt32>(this); }
 
 

+ 1 - 1
src/glTF2Sharp.DOM/Memory/SparseArrays.cs

@@ -59,7 +59,7 @@ namespace glTF2Sharp.Memory
             {
             {
                 if (_Mapping.TryGetValue(index, out int topIndex)) _TopItems[topIndex] = value;
                 if (_Mapping.TryGetValue(index, out int topIndex)) _TopItems[topIndex] = value;
             }
             }
-        }        
+        }
 
 
         public void CopyTo(ArraySegment<T> dst) { EncodedArrayUtils.Copy(this, dst); }
         public void CopyTo(ArraySegment<T> dst) { EncodedArrayUtils.Copy(this, dst); }
 
 

+ 15 - 7
src/glTF2Sharp.DOM/ModelException.cs

@@ -7,16 +7,21 @@ namespace glTF2Sharp
 {
 {
     using IO;
     using IO;
 
 
+    /// <summary>
+    /// Represents an exception produced by the serialization or validation of a gltf model
+    /// </summary>
     public class ModelException : Exception
     public class ModelException : Exception
     {
     {
         #region lifecycle
         #region lifecycle
 
 
-        internal ModelException(JsonSerializable target, String message) : base(_CreateBaseMessage(target, message))
+        internal ModelException(JsonSerializable target, String message)
+            : base(_CreateBaseMessage(target, message))
         {
         {
             _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;
@@ -58,18 +63,21 @@ namespace glTF2Sharp
         #endregion
         #endregion
     }
     }
 
 
-    public class ExtensionException : ModelException
+    /// <summary>
+    /// Represents an exception produced when a required extension is missing
+    /// </summary>
+    public class UnsupportedExtensionException : ModelException
     {
     {
         #region lifecycle
         #region lifecycle
 
 
-        internal ExtensionException(JsonSerializable target, String message) : base(target, message)
+        internal UnsupportedExtensionException(JsonSerializable target, String message)
+            : base(target, message)
         {
         {
-
         }
         }
 
 
-        internal ExtensionException(JsonSerializable target, String message, Action fix, String fixDesc) : base(target, message, fix, fixDesc)
+        internal UnsupportedExtensionException(JsonSerializable target, String message, Action fix, String fixDesc)
+            : base(target, message, fix, fixDesc)
         {
         {
-
         }
         }
 
 
         #endregion
         #endregion

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

@@ -2,6 +2,17 @@
 //      This file has been programatically generated; DON´T EDIT!
 //      This file has been programatically generated; DON´T EDIT!
 //------------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------------
 
 
+#pragma warning disable SA1001
+#pragma warning disable SA1027
+#pragma warning disable SA1028
+#pragma warning disable SA1121
+#pragma warning disable SA1205
+#pragma warning disable SA1309
+#pragma warning disable SA1402
+#pragma warning disable SA1505
+#pragma warning disable SA1507
+#pragma warning disable SA1508
+#pragma warning disable SA1652
 
 
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -27,7 +38,7 @@ namespace glTF2Sharp.Schema2
 		{
 		{
 			switch (property)
 			switch (property)
 			{
 			{
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	

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

@@ -2,6 +2,17 @@
 //      This file has been programatically generated; DON´T EDIT!
 //      This file has been programatically generated; DON´T EDIT!
 //------------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------------
 
 
+#pragma warning disable SA1001
+#pragma warning disable SA1027
+#pragma warning disable SA1028
+#pragma warning disable SA1121
+#pragma warning disable SA1205
+#pragma warning disable SA1309
+#pragma warning disable SA1402
+#pragma warning disable SA1505
+#pragma warning disable SA1507
+#pragma warning disable SA1508
+#pragma warning disable SA1652
 
 
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -36,11 +47,11 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"diffuseFactor",_diffuseFactor,_diffuseFactorDefault);
-			SerializePropertyObject(writer,"diffuseTexture",_diffuseTexture);
-			SerializeProperty(writer,"specularFactor",_specularFactor,_specularFactorDefault);
-			SerializeProperty(writer,"glossinessFactor",_glossinessFactor,_glossinessFactorDefault);
-			SerializePropertyObject(writer,"specularGlossinessTexture",_specularGlossinessTexture);
+			SerializeProperty(writer, "diffuseFactor", _diffuseFactor, _diffuseFactorDefault);
+			SerializePropertyObject(writer, "diffuseTexture", _diffuseTexture);
+			SerializeProperty(writer, "specularFactor", _specularFactor, _specularFactorDefault);
+			SerializeProperty(writer, "glossinessFactor", _glossinessFactor, _glossinessFactorDefault);
+			SerializePropertyObject(writer, "specularGlossinessTexture", _specularGlossinessTexture);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -52,7 +63,7 @@ namespace glTF2Sharp.Schema2
 				case "specularFactor": _specularFactor = DeserializeValue<Vector3?>(reader); break;
 				case "specularFactor": _specularFactor = DeserializeValue<Vector3?>(reader); break;
 				case "glossinessFactor": _glossinessFactor = DeserializeValue<Double?>(reader); break;
 				case "glossinessFactor": _glossinessFactor = DeserializeValue<Double?>(reader); break;
 				case "specularGlossinessTexture": _specularGlossinessTexture = DeserializeValue<TextureInfo>(reader); break;
 				case "specularGlossinessTexture": _specularGlossinessTexture = DeserializeValue<TextureInfo>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	

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

@@ -2,6 +2,17 @@
 //      This file has been programatically generated; DON´T EDIT!
 //      This file has been programatically generated; DON´T EDIT!
 //------------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------------
 
 
+#pragma warning disable SA1001
+#pragma warning disable SA1027
+#pragma warning disable SA1028
+#pragma warning disable SA1121
+#pragma warning disable SA1205
+#pragma warning disable SA1309
+#pragma warning disable SA1402
+#pragma warning disable SA1505
+#pragma warning disable SA1507
+#pragma warning disable SA1508
+#pragma warning disable SA1652
 
 
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -131,7 +142,7 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"name",_name);
+			SerializeProperty(writer, "name", _name);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -139,7 +150,7 @@ namespace glTF2Sharp.Schema2
 			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;
 			}
 			}
 		}
 		}
 	
 	
@@ -160,9 +171,9 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"bufferView",_bufferView);
-			SerializeProperty(writer,"byteOffset",_byteOffset,_byteOffsetDefault);
-			SerializePropertyEnumValue<IndexType>(writer,"componentType",_componentType);
+			SerializeProperty(writer, "bufferView", _bufferView);
+			SerializeProperty(writer, "byteOffset", _byteOffset, _byteOffsetDefault);
+			SerializePropertyEnumValue<IndexType>(writer, "componentType", _componentType);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -172,7 +183,7 @@ namespace glTF2Sharp.Schema2
 				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;
 				case "componentType": _componentType = DeserializeValue<IndexType>(reader); break;
 				case "componentType": _componentType = DeserializeValue<IndexType>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -191,8 +202,8 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"bufferView",_bufferView);
-			SerializeProperty(writer,"byteOffset",_byteOffset,_byteOffsetDefault);
+			SerializeProperty(writer, "bufferView", _bufferView);
+			SerializeProperty(writer, "byteOffset", _byteOffset, _byteOffsetDefault);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -201,7 +212,7 @@ namespace glTF2Sharp.Schema2
 			{
 			{
 				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;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -221,9 +232,9 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"count",_count);
-			SerializePropertyObject(writer,"indices",_indices);
-			SerializePropertyObject(writer,"values",_values);
+			SerializeProperty(writer, "count", _count);
+			SerializePropertyObject(writer, "indices", _indices);
+			SerializePropertyObject(writer, "values", _values);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -233,7 +244,7 @@ namespace glTF2Sharp.Schema2
 				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;
 				case "values": _values = DeserializeValue<AccessorSparseValues>(reader); break;
 				case "values": _values = DeserializeValue<AccessorSparseValues>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -272,15 +283,15 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"bufferView",_bufferView);
-			SerializeProperty(writer,"byteOffset",_byteOffset,_byteOffsetDefault);
-			SerializePropertyEnumValue<ComponentType>(writer,"componentType",_componentType);
-			SerializeProperty(writer,"normalized",_normalized,_normalizedDefault);
-			SerializeProperty(writer,"count",_count);
-			SerializePropertyEnumSymbol<ElementType>(writer,"type",_type);
-			SerializeProperty(writer,"max",_max,_maxMinItems);
-			SerializeProperty(writer,"min",_min,_minMinItems);
-			SerializePropertyObject(writer,"sparse",_sparse);
+			SerializeProperty(writer, "bufferView", _bufferView);
+			SerializeProperty(writer, "byteOffset", _byteOffset, _byteOffsetDefault);
+			SerializePropertyEnumValue<ComponentType>(writer, "componentType", _componentType);
+			SerializeProperty(writer, "normalized", _normalized, _normalizedDefault);
+			SerializeProperty(writer, "count", _count);
+			SerializePropertyEnumSymbol<ElementType>(writer, "type", _type);
+			SerializeProperty(writer, "max", _max, _maxMinItems);
+			SerializeProperty(writer, "min", _min, _minMinItems);
+			SerializePropertyObject(writer, "sparse", _sparse);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -293,10 +304,10 @@ namespace glTF2Sharp.Schema2
 				case "normalized": _normalized = DeserializeValue<Boolean?>(reader); break;
 				case "normalized": _normalized = DeserializeValue<Boolean?>(reader); break;
 				case "count": _count = DeserializeValue<Int32>(reader); break;
 				case "count": _count = DeserializeValue<Int32>(reader); break;
 				case "type": _type = DeserializeValue<ElementType>(reader); break;
 				case "type": _type = DeserializeValue<ElementType>(reader); break;
-				case "max": DeserializeList<Double>(reader,_max); break;
-				case "min": DeserializeList<Double>(reader,_min); break;
+				case "max": DeserializeList<Double>(reader, _max); break;
+				case "min": DeserializeList<Double>(reader, _min); break;
 				case "sparse": _sparse = DeserializeValue<AccessorSparse>(reader); break;
 				case "sparse": _sparse = DeserializeValue<AccessorSparse>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -313,8 +324,8 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"node",_node);
-			SerializePropertyEnumSymbol<PathType>(writer,"path",_path);
+			SerializeProperty(writer, "node", _node);
+			SerializePropertyEnumSymbol<PathType>(writer, "path", _path);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -323,7 +334,7 @@ namespace glTF2Sharp.Schema2
 			{
 			{
 				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;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -340,8 +351,8 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"sampler",_sampler);
-			SerializePropertyObject(writer,"target",_target);
+			SerializeProperty(writer, "sampler", _sampler);
+			SerializePropertyObject(writer, "target", _target);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -350,7 +361,7 @@ namespace glTF2Sharp.Schema2
 			{
 			{
 				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;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -370,9 +381,9 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"input",_input);
-			SerializePropertyEnumSymbol<AnimationInterpolationMode>(writer,"interpolation",_interpolation, _interpolationDefault);
-			SerializeProperty(writer,"output",_output);
+			SerializeProperty(writer, "input", _input);
+			SerializePropertyEnumSymbol<AnimationInterpolationMode>(writer, "interpolation", _interpolation, _interpolationDefault);
+			SerializeProperty(writer, "output", _output);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -382,7 +393,7 @@ namespace glTF2Sharp.Schema2
 				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;
 				case "output": _output = DeserializeValue<Int32>(reader); break;
 				case "output": _output = DeserializeValue<Int32>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -401,17 +412,17 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"channels",_channels,_channelsMinItems);
-			SerializeProperty(writer,"samplers",_samplers,_samplersMinItems);
+			SerializeProperty(writer, "channels", _channels, _channelsMinItems);
+			SerializeProperty(writer, "samplers", _samplers, _samplersMinItems);
 		}
 		}
 	
 	
 		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 "samplers": DeserializeList<AnimationSampler>(reader,_samplers); break;
-				default: base.DeserializeProperty(reader,property); break;
+				case "channels": DeserializeList<AnimationChannel>(reader, _channels); break;
+				case "samplers": DeserializeList<AnimationSampler>(reader, _samplers); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -432,10 +443,10 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"copyright",_copyright);
-			SerializeProperty(writer,"generator",_generator);
-			SerializeProperty(writer,"version",_version);
-			SerializeProperty(writer,"minVersion",_minVersion);
+			SerializeProperty(writer, "copyright", _copyright);
+			SerializeProperty(writer, "generator", _generator);
+			SerializeProperty(writer, "version", _version);
+			SerializeProperty(writer, "minVersion", _minVersion);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -446,7 +457,7 @@ namespace glTF2Sharp.Schema2
 				case "generator": _generator = DeserializeValue<String>(reader); break;
 				case "generator": _generator = DeserializeValue<String>(reader); break;
 				case "version": _version = DeserializeValue<String>(reader); break;
 				case "version": _version = DeserializeValue<String>(reader); break;
 				case "minVersion": _minVersion = DeserializeValue<String>(reader); break;
 				case "minVersion": _minVersion = DeserializeValue<String>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -464,8 +475,8 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"uri",_uri);
-			SerializeProperty(writer,"byteLength",_byteLength);
+			SerializeProperty(writer, "uri", _uri);
+			SerializeProperty(writer, "byteLength", _byteLength);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -474,7 +485,7 @@ namespace glTF2Sharp.Schema2
 			{
 			{
 				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;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -502,11 +513,11 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"buffer",_buffer);
-			SerializeProperty(writer,"byteOffset",_byteOffset,_byteOffsetDefault);
-			SerializeProperty(writer,"byteLength",_byteLength);
-			SerializeProperty(writer,"byteStride",_byteStride);
-			SerializePropertyEnumValue<BufferMode>(writer,"target",_target);
+			SerializeProperty(writer, "buffer", _buffer);
+			SerializeProperty(writer, "byteOffset", _byteOffset, _byteOffsetDefault);
+			SerializeProperty(writer, "byteLength", _byteLength);
+			SerializeProperty(writer, "byteStride", _byteStride);
+			SerializePropertyEnumValue<BufferMode>(writer, "target", _target);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -518,7 +529,7 @@ namespace glTF2Sharp.Schema2
 				case "byteLength": _byteLength = DeserializeValue<Int32>(reader); break;
 				case "byteLength": _byteLength = DeserializeValue<Int32>(reader); break;
 				case "byteStride": _byteStride = DeserializeValue<Int32?>(reader); break;
 				case "byteStride": _byteStride = DeserializeValue<Int32?>(reader); break;
 				case "target": _target = DeserializeValue<BufferMode>(reader); break;
 				case "target": _target = DeserializeValue<BufferMode>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -541,10 +552,10 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"xmag",_xmag);
-			SerializeProperty(writer,"ymag",_ymag);
-			SerializeProperty(writer,"zfar",_zfar);
-			SerializeProperty(writer,"znear",_znear);
+			SerializeProperty(writer, "xmag", _xmag);
+			SerializeProperty(writer, "ymag", _ymag);
+			SerializeProperty(writer, "zfar", _zfar);
+			SerializeProperty(writer, "znear", _znear);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -555,7 +566,7 @@ namespace glTF2Sharp.Schema2
 				case "ymag": _ymag = DeserializeValue<Double>(reader); break;
 				case "ymag": _ymag = DeserializeValue<Double>(reader); break;
 				case "zfar": _zfar = DeserializeValue<Double>(reader); break;
 				case "zfar": _zfar = DeserializeValue<Double>(reader); break;
 				case "znear": _znear = DeserializeValue<Double>(reader); break;
 				case "znear": _znear = DeserializeValue<Double>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -580,10 +591,10 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"aspectRatio",_aspectRatio);
-			SerializeProperty(writer,"yfov",_yfov);
-			SerializeProperty(writer,"zfar",_zfar);
-			SerializeProperty(writer,"znear",_znear);
+			SerializeProperty(writer, "aspectRatio", _aspectRatio);
+			SerializeProperty(writer, "yfov", _yfov);
+			SerializeProperty(writer, "zfar", _zfar);
+			SerializeProperty(writer, "znear", _znear);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -594,7 +605,7 @@ namespace glTF2Sharp.Schema2
 				case "yfov": _yfov = DeserializeValue<Double>(reader); break;
 				case "yfov": _yfov = DeserializeValue<Double>(reader); break;
 				case "zfar": _zfar = DeserializeValue<Double?>(reader); break;
 				case "zfar": _zfar = DeserializeValue<Double?>(reader); break;
 				case "znear": _znear = DeserializeValue<Double>(reader); break;
 				case "znear": _znear = DeserializeValue<Double>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -613,9 +624,9 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializePropertyObject(writer,"orthographic",_orthographic);
-			SerializePropertyObject(writer,"perspective",_perspective);
-			SerializePropertyEnumSymbol<CameraType>(writer,"type",_type);
+			SerializePropertyObject(writer, "orthographic", _orthographic);
+			SerializePropertyObject(writer, "perspective", _perspective);
+			SerializePropertyEnumSymbol<CameraType>(writer, "type", _type);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -625,7 +636,7 @@ namespace glTF2Sharp.Schema2
 				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;
 				case "type": _type = DeserializeValue<CameraType>(reader); break;
 				case "type": _type = DeserializeValue<CameraType>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -644,8 +655,8 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"index",_index);
-			SerializeProperty(writer,"texCoord",_texCoord,_texCoordDefault);
+			SerializeProperty(writer, "index", _index);
+			SerializeProperty(writer, "texCoord", _texCoord, _texCoordDefault);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -654,7 +665,7 @@ namespace glTF2Sharp.Schema2
 			{
 			{
 				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;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -684,11 +695,11 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"baseColorFactor",_baseColorFactor,_baseColorFactorDefault);
-			SerializePropertyObject(writer,"baseColorTexture",_baseColorTexture);
-			SerializeProperty(writer,"metallicFactor",_metallicFactor,_metallicFactorDefault);
-			SerializeProperty(writer,"roughnessFactor",_roughnessFactor,_roughnessFactorDefault);
-			SerializePropertyObject(writer,"metallicRoughnessTexture",_metallicRoughnessTexture);
+			SerializeProperty(writer, "baseColorFactor", _baseColorFactor, _baseColorFactorDefault);
+			SerializePropertyObject(writer, "baseColorTexture", _baseColorTexture);
+			SerializeProperty(writer, "metallicFactor", _metallicFactor, _metallicFactorDefault);
+			SerializeProperty(writer, "roughnessFactor", _roughnessFactor, _roughnessFactorDefault);
+			SerializePropertyObject(writer, "metallicRoughnessTexture", _metallicRoughnessTexture);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -700,7 +711,7 @@ namespace glTF2Sharp.Schema2
 				case "metallicFactor": _metallicFactor = DeserializeValue<Double?>(reader); break;
 				case "metallicFactor": _metallicFactor = DeserializeValue<Double?>(reader); break;
 				case "roughnessFactor": _roughnessFactor = DeserializeValue<Double?>(reader); break;
 				case "roughnessFactor": _roughnessFactor = DeserializeValue<Double?>(reader); break;
 				case "metallicRoughnessTexture": _metallicRoughnessTexture = DeserializeValue<TextureInfo>(reader); break;
 				case "metallicRoughnessTexture": _metallicRoughnessTexture = DeserializeValue<TextureInfo>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -716,7 +727,7 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"scale",_scale,_scaleDefault);
+			SerializeProperty(writer, "scale", _scale, _scaleDefault);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -724,7 +735,7 @@ namespace glTF2Sharp.Schema2
 			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;
 			}
 			}
 		}
 		}
 	
 	
@@ -742,7 +753,7 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"strength",_strength,_strengthDefault);
+			SerializeProperty(writer, "strength", _strength, _strengthDefault);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -750,7 +761,7 @@ namespace glTF2Sharp.Schema2
 			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;
 			}
 			}
 		}
 		}
 	
 	
@@ -784,14 +795,14 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializePropertyObject(writer,"pbrMetallicRoughness",_pbrMetallicRoughness);
-			SerializePropertyObject(writer,"normalTexture",_normalTexture);
-			SerializePropertyObject(writer,"occlusionTexture",_occlusionTexture);
-			SerializePropertyObject(writer,"emissiveTexture",_emissiveTexture);
-			SerializeProperty(writer,"emissiveFactor",_emissiveFactor,_emissiveFactorDefault);
-			SerializePropertyEnumSymbol<AlphaMode>(writer,"alphaMode",_alphaMode, _alphaModeDefault);
-			SerializeProperty(writer,"alphaCutoff",_alphaCutoff,_alphaCutoffDefault);
-			SerializeProperty(writer,"doubleSided",_doubleSided,_doubleSidedDefault);
+			SerializePropertyObject(writer, "pbrMetallicRoughness", _pbrMetallicRoughness);
+			SerializePropertyObject(writer, "normalTexture", _normalTexture);
+			SerializePropertyObject(writer, "occlusionTexture", _occlusionTexture);
+			SerializePropertyObject(writer, "emissiveTexture", _emissiveTexture);
+			SerializeProperty(writer, "emissiveFactor", _emissiveFactor, _emissiveFactorDefault);
+			SerializePropertyEnumSymbol<AlphaMode>(writer, "alphaMode", _alphaMode, _alphaModeDefault);
+			SerializeProperty(writer, "alphaCutoff", _alphaCutoff, _alphaCutoffDefault);
+			SerializeProperty(writer, "doubleSided", _doubleSided, _doubleSidedDefault);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -806,7 +817,7 @@ namespace glTF2Sharp.Schema2
 				case "alphaMode": _alphaMode = DeserializeValue<AlphaMode>(reader); break;
 				case "alphaMode": _alphaMode = DeserializeValue<AlphaMode>(reader); break;
 				case "alphaCutoff": _alphaCutoff = DeserializeValue<Double?>(reader); break;
 				case "alphaCutoff": _alphaCutoff = DeserializeValue<Double?>(reader); break;
 				case "doubleSided": _doubleSided = DeserializeValue<Boolean?>(reader); break;
 				case "doubleSided": _doubleSided = DeserializeValue<Boolean?>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -831,23 +842,23 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"attributes",_attributes);
-			SerializeProperty(writer,"indices",_indices);
-			SerializeProperty(writer,"material",_material);
-			SerializePropertyEnumValue<PrimitiveType>(writer,"mode",_mode, _modeDefault);
-			SerializeProperty(writer,"targets",_targets,_targetsMinItems);
+			SerializeProperty(writer, "attributes", _attributes);
+			SerializeProperty(writer, "indices", _indices);
+			SerializeProperty(writer, "material", _material);
+			SerializePropertyEnumValue<PrimitiveType>(writer, "mode", _mode, _modeDefault);
+			SerializeProperty(writer, "targets", _targets, _targetsMinItems);
 		}
 		}
 	
 	
 		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;
 				case "material": _material = DeserializeValue<Int32?>(reader); break;
 				case "material": _material = DeserializeValue<Int32?>(reader); break;
 				case "mode": _mode = DeserializeValue<PrimitiveType>(reader); break;
 				case "mode": _mode = DeserializeValue<PrimitiveType>(reader); break;
-				case "targets": DeserializeList<Dictionary<String,Int32>>(reader,_targets); break;
-				default: base.DeserializeProperty(reader,property); break;
+				case "targets": DeserializeList<Dictionary<String,Int32>>(reader, _targets); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -866,17 +877,17 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"primitives",_primitives,_primitivesMinItems);
-			SerializeProperty(writer,"weights",_weights,_weightsMinItems);
+			SerializeProperty(writer, "primitives", _primitives, _primitivesMinItems);
+			SerializeProperty(writer, "weights", _weights, _weightsMinItems);
 		}
 		}
 	
 	
 		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 "weights": DeserializeList<Double>(reader,_weights); break;
-				default: base.DeserializeProperty(reader,property); break;
+				case "primitives": DeserializeList<MeshPrimitive>(reader, _primitives); break;
+				case "weights": DeserializeList<Double>(reader, _weights); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -909,15 +920,15 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"camera",_camera);
-			SerializeProperty(writer,"children",_children,_childrenMinItems);
-			SerializeProperty(writer,"skin",_skin);
-			SerializeProperty(writer,"matrix",_matrix);
-			SerializeProperty(writer,"mesh",_mesh);
-			SerializeProperty(writer,"rotation",_rotation);
-			SerializeProperty(writer,"scale",_scale);
-			SerializeProperty(writer,"translation",_translation);
-			SerializeProperty(writer,"weights",_weights,_weightsMinItems);
+			SerializeProperty(writer, "camera", _camera);
+			SerializeProperty(writer, "children", _children, _childrenMinItems);
+			SerializeProperty(writer, "skin", _skin);
+			SerializeProperty(writer, "matrix", _matrix);
+			SerializeProperty(writer, "mesh", _mesh);
+			SerializeProperty(writer, "rotation", _rotation);
+			SerializeProperty(writer, "scale", _scale);
+			SerializeProperty(writer, "translation", _translation);
+			SerializeProperty(writer, "weights", _weights, _weightsMinItems);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -925,15 +936,15 @@ namespace glTF2Sharp.Schema2
 			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;
 				case "skin": _skin = DeserializeValue<Int32?>(reader); break;
 				case "skin": _skin = DeserializeValue<Int32?>(reader); break;
 				case "matrix": _matrix = DeserializeValue<Matrix4x4?>(reader); break;
 				case "matrix": _matrix = DeserializeValue<Matrix4x4?>(reader); break;
 				case "mesh": _mesh = DeserializeValue<Int32?>(reader); break;
 				case "mesh": _mesh = DeserializeValue<Int32?>(reader); break;
 				case "rotation": _rotation = DeserializeValue<Quaternion?>(reader); break;
 				case "rotation": _rotation = DeserializeValue<Quaternion?>(reader); break;
 				case "scale": _scale = DeserializeValue<Vector3?>(reader); break;
 				case "scale": _scale = DeserializeValue<Vector3?>(reader); break;
 				case "translation": _translation = DeserializeValue<Vector3?>(reader); break;
 				case "translation": _translation = DeserializeValue<Vector3?>(reader); break;
-				case "weights": DeserializeList<Double>(reader,_weights); break;
-				default: base.DeserializeProperty(reader,property); break;
+				case "weights": DeserializeList<Double>(reader, _weights); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -956,10 +967,10 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializePropertyEnumValue<TextureInterpolationMode>(writer,"magFilter",_magFilter);
-			SerializePropertyEnumValue<TextureMipMapMode>(writer,"minFilter",_minFilter);
-			SerializePropertyEnumValue<TextureWrapMode>(writer,"wrapS",_wrapS, _wrapSDefault);
-			SerializePropertyEnumValue<TextureWrapMode>(writer,"wrapT",_wrapT, _wrapTDefault);
+			SerializePropertyEnumValue<TextureInterpolationMode>(writer, "magFilter", _magFilter);
+			SerializePropertyEnumValue<TextureMipMapMode>(writer, "minFilter", _minFilter);
+			SerializePropertyEnumValue<TextureWrapMode>(writer, "wrapS", _wrapS, _wrapSDefault);
+			SerializePropertyEnumValue<TextureWrapMode>(writer, "wrapT", _wrapT, _wrapTDefault);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -970,7 +981,7 @@ namespace glTF2Sharp.Schema2
 				case "minFilter": _minFilter = DeserializeValue<TextureMipMapMode>(reader); break;
 				case "minFilter": _minFilter = DeserializeValue<TextureMipMapMode>(reader); break;
 				case "wrapS": _wrapS = DeserializeValue<TextureWrapMode>(reader); break;
 				case "wrapS": _wrapS = DeserializeValue<TextureWrapMode>(reader); break;
 				case "wrapT": _wrapT = DeserializeValue<TextureWrapMode>(reader); break;
 				case "wrapT": _wrapT = DeserializeValue<TextureWrapMode>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -986,15 +997,15 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"nodes",_nodes,_nodesMinItems);
+			SerializeProperty(writer, "nodes", _nodes, _nodesMinItems);
 		}
 		}
 	
 	
 		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;
-				default: base.DeserializeProperty(reader,property); break;
+				case "nodes": DeserializeList<Int32>(reader, _nodes); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -1014,9 +1025,9 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"inverseBindMatrices",_inverseBindMatrices);
-			SerializeProperty(writer,"skeleton",_skeleton);
-			SerializeProperty(writer,"joints",_joints,_jointsMinItems);
+			SerializeProperty(writer, "inverseBindMatrices", _inverseBindMatrices);
+			SerializeProperty(writer, "skeleton", _skeleton);
+			SerializeProperty(writer, "joints", _joints, _jointsMinItems);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -1025,8 +1036,8 @@ namespace glTF2Sharp.Schema2
 			{
 			{
 				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;
-				case "joints": DeserializeList<Int32>(reader,_joints); break;
-				default: base.DeserializeProperty(reader,property); break;
+				case "joints": DeserializeList<Int32>(reader, _joints); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -1043,8 +1054,8 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"sampler",_sampler);
-			SerializeProperty(writer,"source",_source);
+			SerializeProperty(writer, "sampler", _sampler);
+			SerializeProperty(writer, "source", _source);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -1053,7 +1064,7 @@ namespace glTF2Sharp.Schema2
 			{
 			{
 				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;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -1115,47 +1126,47 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"extensionsUsed",_extensionsUsed,_extensionsUsedMinItems);
-			SerializeProperty(writer,"extensionsRequired",_extensionsRequired,_extensionsRequiredMinItems);
-			SerializeProperty(writer,"accessors",_accessors,_accessorsMinItems);
-			SerializeProperty(writer,"animations",_animations,_animationsMinItems);
-			SerializePropertyObject(writer,"asset",_asset);
-			SerializeProperty(writer,"buffers",_buffers,_buffersMinItems);
-			SerializeProperty(writer,"bufferViews",_bufferViews,_bufferViewsMinItems);
-			SerializeProperty(writer,"cameras",_cameras,_camerasMinItems);
-			SerializeProperty(writer,"images",_images,_imagesMinItems);
-			SerializeProperty(writer,"materials",_materials,_materialsMinItems);
-			SerializeProperty(writer,"meshes",_meshes,_meshesMinItems);
-			SerializeProperty(writer,"nodes",_nodes,_nodesMinItems);
-			SerializeProperty(writer,"samplers",_samplers,_samplersMinItems);
-			SerializeProperty(writer,"scene",_scene);
-			SerializeProperty(writer,"scenes",_scenes,_scenesMinItems);
-			SerializeProperty(writer,"skins",_skins,_skinsMinItems);
-			SerializeProperty(writer,"textures",_textures,_texturesMinItems);
+			SerializeProperty(writer, "extensionsUsed", _extensionsUsed, _extensionsUsedMinItems);
+			SerializeProperty(writer, "extensionsRequired", _extensionsRequired, _extensionsRequiredMinItems);
+			SerializeProperty(writer, "accessors", _accessors, _accessorsMinItems);
+			SerializeProperty(writer, "animations", _animations, _animationsMinItems);
+			SerializePropertyObject(writer, "asset", _asset);
+			SerializeProperty(writer, "buffers", _buffers, _buffersMinItems);
+			SerializeProperty(writer, "bufferViews", _bufferViews, _bufferViewsMinItems);
+			SerializeProperty(writer, "cameras", _cameras, _camerasMinItems);
+			SerializeProperty(writer, "images", _images, _imagesMinItems);
+			SerializeProperty(writer, "materials", _materials, _materialsMinItems);
+			SerializeProperty(writer, "meshes", _meshes, _meshesMinItems);
+			SerializeProperty(writer, "nodes", _nodes, _nodesMinItems);
+			SerializeProperty(writer, "samplers", _samplers, _samplersMinItems);
+			SerializeProperty(writer, "scene", _scene);
+			SerializeProperty(writer, "scenes", _scenes, _scenesMinItems);
+			SerializeProperty(writer, "skins", _skins, _skinsMinItems);
+			SerializeProperty(writer, "textures", _textures, _texturesMinItems);
 		}
 		}
 	
 	
 		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 "extensionsRequired": DeserializeList<String>(reader,_extensionsRequired); break;
-				case "accessors": DeserializeList<Accessor>(reader,_accessors); break;
-				case "animations": DeserializeList<Animation>(reader,_animations); break;
+				case "extensionsUsed": DeserializeList<String>(reader, _extensionsUsed); break;
+				case "extensionsRequired": DeserializeList<String>(reader, _extensionsRequired); break;
+				case "accessors": DeserializeList<Accessor>(reader, _accessors); break;
+				case "animations": DeserializeList<Animation>(reader, _animations); break;
 				case "asset": _asset = DeserializeValue<Asset>(reader); break;
 				case "asset": _asset = DeserializeValue<Asset>(reader); break;
-				case "buffers": DeserializeList<Buffer>(reader,_buffers); break;
-				case "bufferViews": DeserializeList<BufferView>(reader,_bufferViews); break;
-				case "cameras": DeserializeList<Camera>(reader,_cameras); break;
-				case "images": DeserializeList<Image>(reader,_images); break;
-				case "materials": DeserializeList<Material>(reader,_materials); break;
-				case "meshes": DeserializeList<Mesh>(reader,_meshes); break;
-				case "nodes": DeserializeList<Node>(reader,_nodes); break;
-				case "samplers": DeserializeList<Sampler>(reader,_samplers); break;
+				case "buffers": DeserializeList<Buffer>(reader, _buffers); break;
+				case "bufferViews": DeserializeList<BufferView>(reader, _bufferViews); break;
+				case "cameras": DeserializeList<Camera>(reader, _cameras); break;
+				case "images": DeserializeList<Image>(reader, _images); break;
+				case "materials": DeserializeList<Material>(reader, _materials); break;
+				case "meshes": DeserializeList<Mesh>(reader, _meshes); break;
+				case "nodes": DeserializeList<Node>(reader, _nodes); break;
+				case "samplers": DeserializeList<Sampler>(reader, _samplers); break;
 				case "scene": _scene = DeserializeValue<Int32?>(reader); break;
 				case "scene": _scene = DeserializeValue<Int32?>(reader); break;
-				case "scenes": DeserializeList<Scene>(reader,_scenes); break;
-				case "skins": DeserializeList<Skin>(reader,_skins); break;
-				case "textures": DeserializeList<Texture>(reader,_textures); break;
-				default: base.DeserializeProperty(reader,property); break;
+				case "scenes": DeserializeList<Scene>(reader, _scenes); break;
+				case "skins": DeserializeList<Skin>(reader, _skins); break;
+				case "textures": DeserializeList<Texture>(reader, _textures); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	
@@ -1174,9 +1185,9 @@ namespace glTF2Sharp.Schema2
 		protected override void SerializeProperties(JsonWriter writer)
 		protected override void SerializeProperties(JsonWriter writer)
 		{
 		{
 			base.SerializeProperties(writer);
 			base.SerializeProperties(writer);
-			SerializeProperty(writer,"uri",_uri);
-			SerializeProperty(writer,"mimeType",_mimeType);
-			SerializeProperty(writer,"bufferView",_bufferView);
+			SerializeProperty(writer, "uri", _uri);
+			SerializeProperty(writer, "mimeType", _mimeType);
+			SerializeProperty(writer, "bufferView", _bufferView);
 		}
 		}
 	
 	
 		protected override void DeserializeProperty(JsonReader reader, string property)
 		protected override void DeserializeProperty(JsonReader reader, string property)
@@ -1186,7 +1197,7 @@ namespace glTF2Sharp.Schema2
 				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;
 				case "bufferView": _bufferView = DeserializeValue<Int32?>(reader); break;
 				case "bufferView": _bufferView = DeserializeValue<Int32?>(reader); break;
-				default: base.DeserializeProperty(reader,property); break;
+				default: base.DeserializeProperty(reader, property); break;
 			}
 			}
 		}
 		}
 	
 	

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

@@ -53,7 +53,8 @@ namespace glTF2Sharp.Schema2
 
 
                 var chunks = new Dictionary<uint, Byte[]>();
                 var chunks = new Dictionary<uint, Byte[]>();
 
 
-                while (true) // keep reading until EndOfFile exception
+                // keep reading until EndOfFile exception
+                while (true)
                 {
                 {
                     if (binaryReader.PeekChar() < 0) break;
                     if (binaryReader.PeekChar() < 0) break;
 
 

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

@@ -27,14 +27,14 @@ namespace glTF2Sharp.Schema2
         {
         {
             Guard.NotNull(indices, nameof(indices));
             Guard.NotNull(indices, nameof(indices));
             Guard.NotNull(values, nameof(values));
             Guard.NotNull(values, nameof(values));
-            Guard.MustBeGreaterThanOrEqualTo(count, _countMinimum,nameof(count));
+            Guard.MustBeGreaterThanOrEqualTo(count, _countMinimum, nameof(count));
 
 
             this._count = count;
             this._count = count;
             this._indices = new AccessorSparseIndices(indices, indicesOffset, indicesEncoding);
             this._indices = new AccessorSparseIndices(indices, indicesOffset, indicesEncoding);
             this._values = new AccessorSparseValues(values, valuesOffset);
             this._values = new AccessorSparseValues(values, valuesOffset);
         }
         }
 
 
-        public int Count => _count; // what is this!?? TODO: check with specs        
+        public int Count => _count; // what is this!?? TODO: check with specs
 
 
         public Memory.SparseArray<Single> GetScalarArray(Accessor baseAccessor)
         public Memory.SparseArray<Single> GetScalarArray(Accessor baseAccessor)
         {
         {
@@ -79,7 +79,7 @@ namespace glTF2Sharp.Schema2
 
 
         internal AccessorSparseIndices(BufferView bv, int byteOffset, IndexType encoding)
         internal AccessorSparseIndices(BufferView bv, int byteOffset, IndexType encoding)
         {
         {
-            Guard.NotNull(bv,nameof(bv));
+            Guard.NotNull(bv, nameof(bv));
             Guard.MustBeGreaterThanOrEqualTo(byteOffset, _byteOffsetMinimum, nameof(byteOffset));
             Guard.MustBeGreaterThanOrEqualTo(byteOffset, _byteOffsetMinimum, nameof(byteOffset));
 
 
             this._bufferView = bv.LogicalIndex;
             this._bufferView = bv.LogicalIndex;
@@ -91,7 +91,7 @@ namespace glTF2Sharp.Schema2
         {
         {
             var srcBuffer = root.LogicalBufferViews[this._bufferView];
             var srcBuffer = root.LogicalBufferViews[this._bufferView];
             return srcBuffer.CreateIndicesArray(this._byteOffset ?? 0, this._componentType);
             return srcBuffer.CreateIndicesArray(this._byteOffset ?? 0, this._componentType);
-        }        
+        }
     }
     }
 
 
     public partial class AccessorSparseValues
     public partial class AccessorSparseValues
@@ -104,7 +104,7 @@ namespace glTF2Sharp.Schema2
             Guard.MustBeGreaterThanOrEqualTo(byteOffset, _byteOffsetMinimum, nameof(byteOffset));
             Guard.MustBeGreaterThanOrEqualTo(byteOffset, _byteOffsetMinimum, nameof(byteOffset));
 
 
             this._bufferView = bv.LogicalIndex;
             this._bufferView = bv.LogicalIndex;
-            this._byteOffset = byteOffset.AsNullable(_byteOffsetDefault);            
+            this._byteOffset = byteOffset.AsNullable(_byteOffsetDefault);
         }
         }
 
 
         public Memory.ScalarArray GetScalarArray(ROOT root, int count, ComponentType encoding, Boolean normalized)
         public Memory.ScalarArray GetScalarArray(ROOT root, int count, ComponentType encoding, Boolean normalized)

+ 13 - 13
src/glTF2Sharp.DOM/Schema2/gltf.Accessors.cs

@@ -35,7 +35,7 @@ namespace glTF2Sharp.Schema2
         #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.AsValue(-1);
         internal int _LogicalBufferViewIndex    => this._bufferView.AsValue(-1);
 
 
         public BufferView SourceBufferView      => this._bufferView.HasValue ? this.LogicalParent.LogicalBufferViews[this._bufferView.Value] : null;
         public BufferView SourceBufferView      => this._bufferView.HasValue ? this.LogicalParent.LogicalBufferViews[this._bufferView.Value] : null;
@@ -52,7 +52,7 @@ namespace glTF2Sharp.Schema2
 
 
         public Boolean IsSparse                 => this._sparse != null;
         public Boolean IsSparse                 => this._sparse != null;
 
 
-        public int ItemByteSize                 => Encoding.ByteLength() * Dimensions.DimCount();        
+        public int ItemByteSize                 => Encoding.ByteLength() * Dimensions.DimCount();
 
 
         public BoundingBox3? LocalBounds3
         public BoundingBox3? LocalBounds3
         {
         {
@@ -83,7 +83,7 @@ namespace glTF2Sharp.Schema2
 
 
             this._type = dimensions;
             this._type = dimensions;
             this._componentType = encoding;
             this._componentType = encoding;
-            this._normalized = normalized.AsNullable(false);            
+            this._normalized = normalized.AsNullable(false);
 
 
             _UpdateBounds();
             _UpdateBounds();
         }
         }
@@ -102,8 +102,8 @@ namespace glTF2Sharp.Schema2
 
 
         public void SetIndexData(BufferView buffer, int byteOffset, IndexType encoding, int count)
         public void SetIndexData(BufferView buffer, int byteOffset, IndexType encoding, int count)
         {
         {
-            Guard.NotNull(buffer,nameof(buffer));
-            Guard.MustShareLogicalParent(this, buffer,nameof(buffer));
+            Guard.NotNull(buffer, nameof(buffer));
+            Guard.MustShareLogicalParent(this, buffer, nameof(buffer));
             if (buffer.DeviceBufferTarget.HasValue) Guard.IsTrue(buffer.DeviceBufferTarget.Value == BufferMode.ELEMENT_ARRAY_BUFFER, nameof(buffer));
             if (buffer.DeviceBufferTarget.HasValue) Guard.IsTrue(buffer.DeviceBufferTarget.Value == BufferMode.ELEMENT_ARRAY_BUFFER, nameof(buffer));
 
 
             Guard.MustBeGreaterThanOrEqualTo(byteOffset, 0, nameof(byteOffset));
             Guard.MustBeGreaterThanOrEqualTo(byteOffset, 0, nameof(byteOffset));
@@ -114,8 +114,8 @@ namespace glTF2Sharp.Schema2
             this._count = count;
             this._count = count;
 
 
             this._type = ElementType.SCALAR;
             this._type = ElementType.SCALAR;
-            this._componentType = encoding.ToComponent();            
-            this._normalized = null;            
+            this._componentType = encoding.ToComponent();
+            this._normalized = null;
 
 
             _UpdateBounds();
             _UpdateBounds();
         }
         }
@@ -126,14 +126,14 @@ namespace glTF2Sharp.Schema2
             Guard.IsTrue(this.Dimensions == ElementType.SCALAR, nameof(Dimensions));
             Guard.IsTrue(this.Dimensions == ElementType.SCALAR, nameof(Dimensions));
             return SourceBufferView.CreateIndicesArray(this.ByteOffset, this.Encoding.ToIndex());
             return SourceBufferView.CreateIndicesArray(this.ByteOffset, this.Encoding.ToIndex());
         }
         }
-        
+
         #endregion
         #endregion
 
 
         #region Vertex Buffer API
         #region Vertex Buffer API
 
 
         public void SetVertexData(BufferView buffer, int byteOffset, ElementType dimensions, ComponentType encoding, Boolean normalized, int count)
         public void SetVertexData(BufferView buffer, int byteOffset, ElementType dimensions, ComponentType encoding, Boolean 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));
             if (buffer.DeviceBufferTarget.HasValue) Guard.IsTrue(buffer.DeviceBufferTarget.Value == BufferMode.ARRAY_BUFFER, nameof(buffer));
             if (buffer.DeviceBufferTarget.HasValue) Guard.IsTrue(buffer.DeviceBufferTarget.Value == BufferMode.ARRAY_BUFFER, nameof(buffer));
 
 
@@ -151,13 +151,13 @@ namespace glTF2Sharp.Schema2
             _UpdateBounds();
             _UpdateBounds();
         }
         }
 
 
-        public Memory.IEncodedArray<Single> AsScalarArray(bool useSparse=true)
+        public Memory.IEncodedArray<Single> AsScalarArray(bool useSparse = true)
         {
         {
             Guard.IsTrue(this.Dimensions == ElementType.SCALAR, nameof(Dimensions));
             Guard.IsTrue(this.Dimensions == ElementType.SCALAR, nameof(Dimensions));
 
 
             if (this._sparse != null && useSparse) return this._sparse.GetScalarArray(this);
             if (this._sparse != null && useSparse) return this._sparse.GetScalarArray(this);
 
 
-            return SourceBufferView.CreateScalarArray(this.ByteOffset, this.Count, this.Encoding, this.Normalized);            
+            return SourceBufferView.CreateScalarArray(this.ByteOffset, this.Count, this.Encoding, this.Normalized);
         }
         }
 
 
         public Memory.IEncodedArray<Vector2> AsVector2Array(bool useSparse = true)
         public Memory.IEncodedArray<Vector2> AsVector2Array(bool useSparse = true)
@@ -195,7 +195,7 @@ namespace glTF2Sharp.Schema2
             var byteStride = Math.Max(byteSize, SourceBufferView.ByteStride);
             var byteStride = Math.Max(byteSize, SourceBufferView.ByteStride);
             var byteOffset = vertexIdx * byteStride;
             var byteOffset = vertexIdx * byteStride;
 
 
-            return SourceBufferView.Data.GetSegment(this.ByteOffset + vertexIdx * byteStride, byteSize);
+            return SourceBufferView.Data.Slice(this.ByteOffset + (vertexIdx * byteStride), byteSize);
         }
         }
 
 
         internal void _UpdateBounds()
         internal void _UpdateBounds()
@@ -303,7 +303,7 @@ namespace glTF2Sharp.Schema2
         }
         }
 
 
         #endregion
         #endregion
-    }   
+    }
 
 
     public partial class ModelRoot
     public partial class ModelRoot
     {
     {

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

@@ -56,7 +56,7 @@ namespace glTF2Sharp.Schema2
         public AnimationSampler CreateSampler(IReadOnlyList<Single> input, IReadOnlyList<System.Numerics.Vector3> output, AnimationInterpolationMode interpolation)
         public AnimationSampler CreateSampler(IReadOnlyList<Single> input, IReadOnlyList<System.Numerics.Vector3> output, AnimationInterpolationMode interpolation)
         {
         {
             var inputData = input.ToArray().ToByteArray();
             var inputData = input.ToArray().ToByteArray();
-            var outputData = output.ToArray().ToByteArray();            
+            var outputData = output.ToArray().ToByteArray();
 
 
             var inputAccessor = LogicalParent._CreateDataAccessor(inputData, Runtime.Encoding.DimensionType.Scalar, input.Count);
             var inputAccessor = LogicalParent._CreateDataAccessor(inputData, Runtime.Encoding.DimensionType.Scalar, input.Count);
             var outputAccesor = LogicalParent._CreateDataAccessor(outputData, Runtime.Encoding.DimensionType.Vector3, output.Count);
             var outputAccesor = LogicalParent._CreateDataAccessor(outputData, Runtime.Encoding.DimensionType.Vector3, output.Count);
@@ -102,6 +102,7 @@ namespace glTF2Sharp.Schema2
         #region data
         #region data
 
 
         internal int? _NodeId => this._node;
         internal int? _NodeId => this._node;
+
         internal PathType _NodePath => this._path;
         internal PathType _NodePath => this._path;
 
 
         #endregion
         #endregion
@@ -203,9 +204,6 @@ namespace glTF2Sharp.Schema2
             _animations.Add(anim);
             _animations.Add(anim);
 
 
             return anim;
             return anim;
-        }        
+        }
     }
     }
-}
-
-
-
+}

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

@@ -47,7 +47,7 @@ namespace glTF2Sharp.Schema2
             this._target = target;
             this._target = target;
         }
         }
 
 
-        #endregion        
+        #endregion
 
 
         #region properties
         #region properties
 
 
@@ -104,16 +104,16 @@ namespace glTF2Sharp.Schema2
 
 
         public Memory.IntegerArray CreateIndicesArray(int byteOffset, IndexType encoding)
         public Memory.IntegerArray CreateIndicesArray(int byteOffset, IndexType encoding)
         {
         {
-            Guard.IsTrue(this.ByteStride == 0,null, "bytestride must be zero");
+            Guard.IsTrue(this.ByteStride == 0, null, "bytestride must be zero");
 
 
             return new Memory.IntegerArray(this.Data.Slice(byteOffset), encoding);
             return new Memory.IntegerArray(this.Data.Slice(byteOffset), encoding);
-        }        
+        }
 
 
         public Memory.ScalarArray CreateScalarArray(int byteOffset, int count, ENCODING encoding, Boolean normalized)
         public Memory.ScalarArray CreateScalarArray(int byteOffset, int count, ENCODING encoding, Boolean normalized)
         {
         {
             var data = this.Data.Slice(byteOffset, count * this.ByteStride);
             var data = this.Data.Slice(byteOffset, count * this.ByteStride);
 
 
-            return new Memory.ScalarArray(data, this.ByteStride, encoding, normalized);            
+            return new Memory.ScalarArray(data, this.ByteStride, encoding, normalized);
         }
         }
 
 
         public Memory.Vector2Array CreateVector2Array(int byteOffset, int count, ENCODING encoding, Boolean normalized)
         public Memory.Vector2Array CreateVector2Array(int byteOffset, int count, ENCODING encoding, Boolean normalized)
@@ -191,7 +191,7 @@ namespace glTF2Sharp.Schema2
             var buffer = CreateBuffer(data);
             var buffer = CreateBuffer(data);
 
 
             return CreateBufferView(buffer, data.Length, null, byteStride, BufferMode.ARRAY_BUFFER);
             return CreateBufferView(buffer, data.Length, null, byteStride, BufferMode.ARRAY_BUFFER);
-        }        
+        }
     }
     }
 
 
     /// <summary>
     /// <summary>
@@ -200,7 +200,7 @@ namespace glTF2Sharp.Schema2
     sealed class _StaticBufferBuilder
     sealed class _StaticBufferBuilder
     {
     {
         #region lifecycle
         #region lifecycle
-        
+
         public _StaticBufferBuilder(int bufferIndex)
         public _StaticBufferBuilder(int bufferIndex)
         {
         {
             _BufferIndex = bufferIndex;
             _BufferIndex = bufferIndex;

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

@@ -23,7 +23,7 @@ namespace glTF2Sharp.Schema2
             set => this._type = value;
             set => this._type = value;
         }
         }
 
 
-        #endregion        
+        #endregion
     }
     }
 
 
     public partial class ModelRoot
     public partial class ModelRoot

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

@@ -14,7 +14,7 @@ namespace glTF2Sharp.Schema2
         {
         {
             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());
-        }        
+        }
 
 
         #endregion
         #endregion
 
 

+ 2 - 2
src/glTF2Sharp.DOM/Schema2/gltf.LogicalChildOfRoot.cs

@@ -4,7 +4,7 @@ using System.Linq;
 
 
 namespace glTF2Sharp.Schema2
 namespace glTF2Sharp.Schema2
 {
 {
-    using Collections;    
+    using Collections;
 
 
     /// <summary>
     /// <summary>
     /// All gltf elements stored in ModelRoot must inherit from this class.
     /// All gltf elements stored in ModelRoot must inherit from this class.
@@ -27,7 +27,7 @@ namespace glTF2Sharp.Schema2
 
 
         void IChildOf<ModelRoot>._SetLogicalParent(ModelRoot parent) { LogicalParent = parent; }
         void IChildOf<ModelRoot>._SetLogicalParent(ModelRoot parent) { LogicalParent = parent; }
 
 
-        #endregion        
+        #endregion
 
 
         #region validation
         #region validation
 
 

+ 10 - 10
src/glTF2Sharp.DOM/Schema2/gltf.Materials.cs

@@ -94,8 +94,8 @@ namespace glTF2Sharp.Schema2
                     this,
                     this,
                     "Normal",
                     "Normal",
                     _GetNormalTexture,
                     _GetNormalTexture,
-                    () => _GetNormalTexture(false) == null ? Vector4.Zero : new Vector4((float)(_GetNormalTexture(false).Scale)),
-                    value => _GetNormalTexture(true).Scale = ((double)value.X)
+                    () => _GetNormalTexture(false) == null ? Vector4.Zero : new Vector4((float)_GetNormalTexture(false).Scale),
+                    value => _GetNormalTexture(true).Scale = (double)value.X
                     );
                     );
 
 
                 yield return new MaterialChannelView
                 yield return new MaterialChannelView
@@ -103,8 +103,8 @@ namespace glTF2Sharp.Schema2
                     this,
                     this,
                     "Occlusion",
                     "Occlusion",
                     _GetOcclusionTexture,
                     _GetOcclusionTexture,
-                    () => _GetOcclusionTexture(false) == null ? Vector4.Zero : new Vector4((float)(_GetOcclusionTexture(false).Strength)),
-                    value => _GetOcclusionTexture(true).Strength = ((double)value.X)
+                    () => _GetOcclusionTexture(false) == null ? Vector4.Zero : new Vector4((float)_GetOcclusionTexture(false).Strength),
+                    value => _GetOcclusionTexture(true).Strength = (double)value.X
                     );
                     );
 
 
                 yield return new MaterialChannelView
                 yield return new MaterialChannelView
@@ -146,16 +146,16 @@ namespace glTF2Sharp.Schema2
     [System.Diagnostics.DebuggerDisplay("Channel {_Semantic}")]
     [System.Diagnostics.DebuggerDisplay("Channel {_Semantic}")]
     public struct MaterialChannelView
     public struct MaterialChannelView
     {
     {
-        #region lifecycle        
+        #region lifecycle
 
 
-        internal MaterialChannelView(Material m, string semantic, Func<Boolean,TextureInfo> texInfo, Func<Vector4> fg, Action<Vector4> fs)
+        internal MaterialChannelView(Material m, string semantic, Func<Boolean, TextureInfo> texInfo, Func<Vector4> fg, Action<Vector4> fs)
         {
         {
             _Semantic = semantic;
             _Semantic = semantic;
             _Material = m;
             _Material = m;
             _TextureInfoGetter = texInfo;
             _TextureInfoGetter = texInfo;
             _FactorGetter = fg;
             _FactorGetter = fg;
             _FactorSetter = fs;
             _FactorSetter = fs;
-        }        
+        }
 
 
         #endregion
         #endregion
 
 
@@ -241,7 +241,7 @@ namespace glTF2Sharp.Schema2
                 material,
                 material,
                 "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)
                 );
                 );
 
 
@@ -296,10 +296,10 @@ namespace glTF2Sharp.Schema2
                 "Specular",
                 "Specular",
                 null,
                 null,
                 () => { var rgb = _specularFactor.AsValue(_specularFactorDefault); return new Vector4(rgb, 1); },
                 () => { var rgb = _specularFactor.AsValue(_specularFactorDefault); return new Vector4(rgb, 1); },
-                value => _specularFactor = new Vector3(value.X,value.Y,value.Z).AsNullable(_specularFactorDefault)
+                value => _specularFactor = new Vector3(value.X, value.Y, value.Z).AsNullable(_specularFactorDefault)
                 );
                 );
         }
         }
-    }    
+    }
 
 
     public partial class ModelRoot
     public partial class ModelRoot
     {
     {

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

@@ -21,7 +21,7 @@ namespace glTF2Sharp.Schema2
 
 
         #endregion
         #endregion
 
 
-        #region properties        
+        #region properties
 
 
         public int LogicalIndex => this.LogicalParent.LogicalMeshes.IndexOfReference(this);
         public int LogicalIndex => this.LogicalParent.LogicalMeshes.IndexOfReference(this);
 
 
@@ -35,7 +35,7 @@ namespace glTF2Sharp.Schema2
 
 
         #endregion
         #endregion
 
 
-        #region API        
+        #region API
 
 
         public MeshPrimitive CreatePrimitive()
         public MeshPrimitive CreatePrimitive()
         {
         {

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

@@ -28,7 +28,7 @@ namespace glTF2Sharp.Schema2
         {
         {
             _attributes = new Dictionary<string, int>();
             _attributes = new Dictionary<string, int>();
             _targets = new List<Dictionary<string, int>>();
             _targets = new List<Dictionary<string, int>>();
-        }        
+        }
 
 
         #endregion
         #endregion
 
 
@@ -74,10 +74,13 @@ namespace glTF2Sharp.Schema2
 
 
             set
             set
             {
             {
-                if (value == null) this._indices = null;
+                if (value == null)
+                {
+                    this._indices = null;
+                }
                 else
                 else
                 {
                 {
-                    Guard.MustShareLogicalParent(this.LogicalParent.LogicalParent, value,nameof(value));
+                    Guard.MustShareLogicalParent(this.LogicalParent.LogicalParent, value, nameof(value));
                     this._indices = value.LogicalIndex;
                     this._indices = value.LogicalIndex;
                 }
                 }
             }
             }
@@ -139,25 +142,25 @@ namespace glTF2Sharp.Schema2
             if (accessor != null)
             if (accessor != null)
             {
             {
                 Guard.MustShareLogicalParent(this.LogicalParent.LogicalParent, accessor, nameof(accessor));
                 Guard.MustShareLogicalParent(this.LogicalParent.LogicalParent, accessor, nameof(accessor));
-                _attributes[attributeKey] = accessor.LogicalIndex;                
+                _attributes[attributeKey] = accessor.LogicalIndex;
             }
             }
             else
             else
             {
             {
                 _attributes.Remove(attributeKey);
                 _attributes.Remove(attributeKey);
             }
             }
-        }        
+        }
 
 
         public void SetVertexAccessors(BufferView buffer, int byteOffset, int vertexCount, IEnumerable<Geometry.VertexElement> elements)
         public void SetVertexAccessors(BufferView buffer, int byteOffset, int vertexCount, IEnumerable<Geometry.VertexElement> elements)
         {
         {
             int count = 0;
             int count = 0;
-            foreach(var e in elements)
+            foreach (var e in elements)
             {
             {
                 var accessor = this.LogicalParent.LogicalParent.CreateAccessor(e.Attribute);
                 var accessor = this.LogicalParent.LogicalParent.CreateAccessor(e.Attribute);
                 accessor.SetVertexData(buffer, byteOffset + count, e.Dimensions, e.Encoding, e.Normalized, vertexCount);
                 accessor.SetVertexData(buffer, byteOffset + count, e.Dimensions, e.Encoding, e.Normalized, vertexCount);
                 count += e.ByteSize;
                 count += e.ByteSize;
 
 
                 SetVertexAccessor(e.Attribute, accessor);
                 SetVertexAccessor(e.Attribute, accessor);
-            }            
+            }
         }
         }
 
 
         public IReadOnlyDictionary<String, Accessor> GetMorphTargetAccessors(int idx)
         public IReadOnlyDictionary<String, Accessor> GetMorphTargetAccessors(int idx)
@@ -183,7 +186,7 @@ namespace glTF2Sharp.Schema2
             {
             {
                 target[kvp.Key] = kvp.Value.LogicalIndex;
                 target[kvp.Key] = kvp.Value.LogicalIndex;
             }
             }
-        }        
+        }
 
 
         public IReadOnlyList<KeyValuePair<String, Accessor>> GetVertexAccessorsByBuffer(BufferView vb)
         public IReadOnlyList<KeyValuePair<String, Accessor>> GetVertexAccessorsByBuffer(BufferView vb)
         {
         {

+ 16 - 6
src/glTF2Sharp.DOM/Schema2/gltf.Property.cs

@@ -11,18 +11,23 @@ namespace glTF2Sharp.Schema2
     public abstract class glTFProperty : JsonSerializable
     public abstract class glTFProperty : JsonSerializable
     {
     {
         #region data
         #region data
-        
+
         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        
 
 
-        public T GetExtension<T>() where T : JsonSerializable { return _extensions.OfType<T>().FirstOrDefault(); }
+        #region API
+
+        public T GetExtension<T>()
+            where T : JsonSerializable
+        {
+            return _extensions.OfType<T>().FirstOrDefault();
+        }
 
 
-        public void SetExtension<T>(T value) where T : JsonSerializable
+        public void SetExtension<T>(T value)
+            where T : JsonSerializable
         {
         {
             var idx = _extensions.IndexOf(item => item.GetType() == typeof(T));
             var idx = _extensions.IndexOf(item => item.GetType() == typeof(T));
 
 
@@ -39,6 +44,7 @@ namespace glTF2Sharp.Schema2
         protected override void SerializeProperties(JsonWriter writer)
         protected override void SerializeProperties(JsonWriter writer)
         {
         {
             SerializeProperty(writer, "extensions", _extensions);
             SerializeProperty(writer, "extensions", _extensions);
+
             // SerializeProperty(writer, "extras", _extras);
             // SerializeProperty(writer, "extras", _extras);
         }
         }
 
 
@@ -48,6 +54,7 @@ namespace glTF2Sharp.Schema2
             {
             {
                 case "extras": reader.Skip(); break;
                 case "extras": reader.Skip(); break;
                 case "extensions": _DeserializeExtensions(reader, _extensions); break;
                 case "extensions": _DeserializeExtensions(reader, _extensions); break;
+
                 // case "extras": _extras = DeserializeValue<Object>(reader); break;
                 // case "extras": _extras = DeserializeValue<Object>(reader); break;
 
 
                 default: reader.Skip(); break;
                 default: reader.Skip(); break;
@@ -82,7 +89,10 @@ namespace glTF2Sharp.Schema2
 
 
                 var val = ExtensionsFactory.Create(key);
                 var val = ExtensionsFactory.Create(key);
 
 
-                if (val == null) reader.Skip();
+                if (val == null)
+                {
+                    reader.Skip();
+                }
                 else
                 else
                 {
                 {
                     val.DeserializeObject(reader);
                     val.DeserializeObject(reader);

+ 3 - 3
src/glTF2Sharp.DOM/Schema2/gltf.Root.cs

@@ -36,7 +36,7 @@ namespace glTF2Sharp.Schema2
             _samplers = new ChildrenCollection<Sampler, ModelRoot>(this);
             _samplers = new ChildrenCollection<Sampler, ModelRoot>(this);
             _scenes = new ChildrenCollection<Scene, ModelRoot>(this);
             _scenes = new ChildrenCollection<Scene, ModelRoot>(this);
             _skins = new ChildrenCollection<Skin, ModelRoot>(this);
             _skins = new ChildrenCollection<Skin, ModelRoot>(this);
-            _textures = new ChildrenCollection<Texture, ModelRoot>(this);            
+            _textures = new ChildrenCollection<Texture, ModelRoot>(this);
         }
         }
 
 
         #endregion
         #endregion
@@ -64,7 +64,7 @@ namespace glTF2Sharp.Schema2
 
 
         public IReadOnlyList<Mesh>          LogicalMeshes       => _meshes;
         public IReadOnlyList<Mesh>          LogicalMeshes       => _meshes;
         public IReadOnlyList<Skin>          LogicalSkins        => _skins;
         public IReadOnlyList<Skin>          LogicalSkins        => _skins;
-        public IReadOnlyList<Camera>        LogicalCameras      => _cameras;        
+        public IReadOnlyList<Camera>        LogicalCameras      => _cameras;
 
 
         public IReadOnlyList<Node>          LogicalNodes        => _nodes;
         public IReadOnlyList<Node>          LogicalNodes        => _nodes;
         public IReadOnlyList<Scene>         LogicalScenes       => _scenes;
         public IReadOnlyList<Scene>         LogicalScenes       => _scenes;
@@ -95,7 +95,7 @@ namespace glTF2Sharp.Schema2
 
 
             foreach (var iex in this.IncompatibleExtensions)
             foreach (var iex in this.IncompatibleExtensions)
             {
             {
-                exx.Add(new ExtensionException(this, $"Incompatible Extension found: {iex}")); // fix: attempt to remove given extension
+                exx.Add(new UnsupportedExtensionException(this, iex)); // fix: attempt to remove given extension
             }
             }
 
 
             if (exx.Count > 0) return exx;
             if (exx.Count > 0) return exx;

+ 9 - 9
src/glTF2Sharp.DOM/Schema2/gltf.Scene.cs

@@ -32,9 +32,9 @@ namespace glTF2Sharp.Schema2
 
 
         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);
 
 
-        public IEnumerable<Node> VisualChildren => GetVisualChildren(0);        
+        public IEnumerable<Node> VisualChildren => GetVisualChildren(0);
 
 
         public Boolean IsSkinJoint => Skin.GetSkinsUsing(this).Any();
         public Boolean IsSkinJoint => Skin.GetSkinsUsing(this).Any();
 
 
@@ -132,7 +132,7 @@ namespace glTF2Sharp.Schema2
 
 
         #endregion
         #endregion
 
 
-        #region API        
+        #region API
 
 
         internal bool _ContainsVisualNode(Node node, bool recursive)
         internal bool _ContainsVisualNode(Node node, bool recursive)
         {
         {
@@ -153,7 +153,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;
         }
         }
@@ -167,7 +167,7 @@ namespace glTF2Sharp.Schema2
 
 
         public void AddNode(Node node)
         public void AddNode(Node node)
         {
         {
-            Guard.NotNull(node,nameof(node));
+            Guard.NotNull(node, nameof(node));
             Guard.MustShareLogicalParent(this, node, nameof(node));
             Guard.MustShareLogicalParent(this, node, nameof(node));
 
 
             var idx = this.LogicalParent._UseLogicaNode(node);
             var idx = this.LogicalParent._UseLogicaNode(node);
@@ -193,7 +193,7 @@ namespace glTF2Sharp.Schema2
 
 
                 foreach (var ccc in cc) yield return ccc;
                 foreach (var ccc in cc) yield return ccc;
             }
             }
-        }        
+        }
 
 
         public static IEnumerable<Node> GetNodesUsingMesh(Mesh mesh)
         public static IEnumerable<Node> GetNodesUsingMesh(Mesh mesh)
         {
         {
@@ -247,7 +247,7 @@ namespace glTF2Sharp.Schema2
             }
             }
 
 
             // check Transforms (out or range, NaN, etc)
             // check Transforms (out or range, NaN, etc)
-            
+
             // check morph weights
             // check morph weights
         }
         }
 
 
@@ -282,7 +282,7 @@ namespace glTF2Sharp.Schema2
 
 
         internal bool _ContainsVisualNode(Node node, bool recursive)
         internal bool _ContainsVisualNode(Node node, bool recursive)
         {
         {
-            Guard.NotNull(node,nameof(node));
+            Guard.NotNull(node, nameof(node));
             Guard.MustShareLogicalParent(this, node, nameof(node));
             Guard.MustShareLogicalParent(this, node, nameof(node));
 
 
             if (_nodes.Contains(node.LogicalIndex)) return true;
             if (_nodes.Contains(node.LogicalIndex)) return true;
@@ -324,7 +324,7 @@ 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
     }
     }

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

@@ -1,10 +1,11 @@
-using Newtonsoft.Json;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 
 
+using Newtonsoft.Json;
+
 namespace glTF2Sharp.Schema2
 namespace glTF2Sharp.Schema2
 {
 {
     using ROOT = ModelRoot;
     using ROOT = ModelRoot;
@@ -17,7 +18,6 @@ namespace glTF2Sharp.Schema2
     {
     {
         public ReadSettings()
         public ReadSettings()
         {
         {
-
         }
         }
 
 
         internal ReadSettings(string filePath)
         internal ReadSettings(string filePath)
@@ -64,7 +64,7 @@ namespace glTF2Sharp.Schema2
             BinaryMode = true;
             BinaryMode = true;
             EmbedImages = true;
             EmbedImages = true;
 
 
-            this.FileWriter = (fn, d) => memory.Write(d,0,d.Length);
+            this.FileWriter = (fn, d) => memory.Write(d, 0, d.Length);
         }
         }
 
 
         #endregion
         #endregion
@@ -131,7 +131,7 @@ namespace glTF2Sharp.Schema2
             using (var streamReader = new StreamReader(stream))
             using (var streamReader = new StreamReader(stream))
             {
             {
                 content = streamReader.ReadToEnd();
                 content = streamReader.ReadToEnd();
-            }            
+            }
 
 
             return Parse(content, settings);
             return Parse(content, settings);
         }
         }
@@ -151,7 +151,7 @@ namespace glTF2Sharp.Schema2
             }
             }
 
 
             return Parse(dom, settings);
             return Parse(dom, settings);
-        }        
+        }
 
 
         public static ROOT Parse(String jsonContent, ReadSettings settings)
         public static ROOT Parse(String jsonContent, ReadSettings settings)
         {
         {
@@ -189,7 +189,7 @@ namespace glTF2Sharp.Schema2
 
 
                 return root;
                 return root;
             }
             }
-        }        
+        }
 
 
         #endregion
         #endregion
 
 
@@ -202,7 +202,7 @@ namespace glTF2Sharp.Schema2
 
 
         public void SaveGLB(string filePath)
         public void SaveGLB(string filePath)
         {
         {
-            Guard.FilePathMustBeValid(filePath,nameof(filePath));
+            Guard.FilePathMustBeValid(filePath, nameof(filePath));
 
 
             var settings = new WriteSettings(filePath)
             var settings = new WriteSettings(filePath)
             {
             {
@@ -213,7 +213,7 @@ namespace glTF2Sharp.Schema2
             var name = Path.GetFileNameWithoutExtension(filePath);
             var name = Path.GetFileNameWithoutExtension(filePath);
 
 
             Write(name, settings);
             Write(name, settings);
-        }        
+        }
 
 
         public void SaveGLTF(string filePath, Formatting fmt = Formatting.None)
         public void SaveGLTF(string filePath, Formatting fmt = Formatting.None)
         {
         {
@@ -227,8 +227,8 @@ namespace glTF2Sharp.Schema2
 
 
             var name = Path.GetFileNameWithoutExtension(filePath);
             var name = Path.GetFileNameWithoutExtension(filePath);
 
 
-            Write(name, settings);            
-        }        
+            Write(name, settings);
+        }
 
 
         public void Write(string name, WriteSettings settings)
         public void Write(string name, WriteSettings settings)
         {
         {
@@ -280,7 +280,7 @@ namespace glTF2Sharp.Schema2
 
 
                     settings.FileWriter($"{name}.gltf", m.ToArray());
                     settings.FileWriter($"{name}.gltf", m.ToArray());
                 }
                 }
-            }            
+            }
 
 
             foreach (var b in this._buffers) b._ClearAfterWrite();
             foreach (var b in this._buffers) b._ClearAfterWrite();
             foreach (var i in this._images) i._ClearAfterWrite();
             foreach (var i in this._images) i._ClearAfterWrite();
@@ -309,14 +309,14 @@ namespace glTF2Sharp.Schema2
         {
         {
             using (var m = new MemoryStream())
             using (var m = new MemoryStream())
             {
             {
-                var settings = new WriteSettings(m);                
+                var settings = new WriteSettings(m);
 
 
                 Write("model", settings);
                 Write("model", settings);
 
 
                 return m.ToArray();
                 return m.ToArray();
-            }                        
+            }
         }
         }
 
 
-        #endregion        
+        #endregion
     }
     }
 }
 }

+ 2 - 2
src/glTF2Sharp.DOM/Schema2/gltf.Skin.cs

@@ -93,7 +93,7 @@ namespace glTF2Sharp.Schema2
 
 
                 var invXform = j.Value;
                 var invXform = j.Value;
 
 
-                if (invXform.M44 != 1) exx.Add(new ModelException(this, $"Joint {i} has invalid inverse matrix"));                
+                if (invXform.M44 != 1) exx.Add(new ModelException(this, $"Joint {i} has invalid inverse matrix"));
             }*/
             }*/
 
 
             return exx;
             return exx;
@@ -126,7 +126,7 @@ namespace glTF2Sharp.Schema2
 
 
             var indexer = new Runtime.Encoding.Matrix4x4Indexer(data, 16 * 4, 0, Runtime.Encoding.PackedType.F32);
             var indexer = new Runtime.Encoding.Matrix4x4Indexer(data, 16 * 4, 0, Runtime.Encoding.PackedType.F32);
 
 
-            for(int i=0; i < joints.Length; ++i) { indexer[i] = joints[i].Value; }            
+            for(int i=0; i < joints.Length; ++i) { indexer[i] = joints[i].Value; }
 
 
             var accessor = LogicalParent._CreateDataAccessor(data, Runtime.Encoding.DimensionType.Matrix4x4, joints.Length);
             var accessor = LogicalParent._CreateDataAccessor(data, Runtime.Encoding.DimensionType.Matrix4x4, joints.Length);
             this._inverseBindMatrices = accessor.LogicalIndex;
             this._inverseBindMatrices = accessor.LogicalIndex;

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

@@ -123,7 +123,7 @@ namespace glTF2Sharp.Schema2
 
 
         #endregion
         #endregion
 
 
-        #region data        
+        #region data
 
 
         // this is the actual compressed image in PNG or JPEG, -NOT- the pixels data.
         // this is the actual compressed image in PNG or JPEG, -NOT- the pixels data.
         private Byte[] _ExternalImageContent;
         private Byte[] _ExternalImageContent;
@@ -325,7 +325,8 @@ 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;

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

@@ -56,14 +56,14 @@ namespace glTF2Sharp
 
 
         public static Matrix4x4 LocalToWorld(Matrix4x4 parentWorld, Matrix4x4 childLocal)
         public static Matrix4x4 LocalToWorld(Matrix4x4 parentWorld, Matrix4x4 childLocal)
         {
         {
-            return childLocal * parentWorld;            
+            return childLocal * parentWorld;
         }
         }
 
 
         public static Matrix4x4 WorldToLocal(Matrix4x4 parentWorld, Matrix4x4 childWorld)
         public static Matrix4x4 WorldToLocal(Matrix4x4 parentWorld, Matrix4x4 childWorld)
         {
         {
             Matrix4x4.Invert(parentWorld, out Matrix4x4 invWorld);
             Matrix4x4.Invert(parentWorld, out Matrix4x4 invWorld);
 
 
-            return childWorld * invWorld;            
+            return childWorld * invWorld;
         }
         }
 
 
         public static Matrix4x4 CreateFromRows(Vector4 x, Vector4 y, Vector4 z, Vector4 w)
         public static Matrix4x4 CreateFromRows(Vector4 x, Vector4 y, Vector4 z, Vector4 w)

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

@@ -106,7 +106,7 @@ namespace glTF2Sharp
 
 
         public Vector3 Center => (Min + Max) * 0.5f;
         public Vector3 Center => (Min + Max) * 0.5f;
 
 
-        public Vector3 Size => IsEmpty ? Vector3.Zero : Max - Min;        
+        public Vector3 Size => IsEmpty ? Vector3.Zero : Max - Min;
 
 
         public bool IsEmpty => (Min.X > Max.X) | (Min.Y > Max.Y) | (Min.Z > Max.Z);
         public bool IsEmpty => (Min.X > Max.X) | (Min.Y > Max.Y) | (Min.Z > Max.Z);
 
 

+ 19 - 14
src/glTF2Sharp.DOM/_Extensions.cs

@@ -24,6 +24,11 @@ namespace glTF2Sharp
             return !(float.IsNaN(value) | float.IsInfinity(value));
             return !(float.IsNaN(value) | float.IsInfinity(value));
         }
         }
 
 
+        internal static bool _IsReal(this Vector2 v)
+        {
+            return v.X._IsReal() & v.Y._IsReal();
+        }
+
         internal static bool _IsReal(this Vector3 v)
         internal static bool _IsReal(this Vector3 v)
         {
         {
             return v.X._IsReal() & v.Y._IsReal() & v.Z._IsReal();
             return v.X._IsReal() & v.Y._IsReal() & v.Z._IsReal();
@@ -42,7 +47,7 @@ namespace glTF2Sharp
         internal static Quaternion AsQuaternion(this Vector4 v)
         internal static Quaternion AsQuaternion(this Vector4 v)
         {
         {
             return new Quaternion(v.X, v.Y, v.Z, v.W);
             return new Quaternion(v.X, v.Y, v.Z, v.W);
-        }        
+        }
 
 
         #endregion
         #endregion
 
 
@@ -57,7 +62,7 @@ namespace glTF2Sharp
             return Convert.FromBase64String(content);
             return Convert.FromBase64String(content);
         }
         }
 
 
-        #endregion                
+        #endregion
 
 
         #region linq
         #region linq
 
 
@@ -121,7 +126,8 @@ namespace glTF2Sharp
             return -1;
             return -1;
         }
         }
 
 
-        internal static int IndexOfReference<T>(this IReadOnlyList<T> collection, T value) where T : class
+        internal static int IndexOfReference<T>(this IReadOnlyList<T> collection, T value)
+            where T : class
         {
         {
             var l = collection.Count;
             var l = collection.Count;
 
 
@@ -133,7 +139,8 @@ namespace glTF2Sharp
             return -1;
             return -1;
         }
         }
 
 
-        internal static int IndexOf<T>(this IReadOnlyList<T> collection, T[] subset) where T : IEquatable<T>
+        internal static int IndexOf<T>(this IReadOnlyList<T> collection, T[] subset)
+            where T : IEquatable<T>
         {
         {
             var l = collection.Count - subset.Length;
             var l = collection.Count - subset.Length;
 
 
@@ -153,11 +160,6 @@ namespace glTF2Sharp
             return -1;
             return -1;
         }
         }
 
 
-        internal static ArraySegment<T> GetSegment<T>(this ArraySegment<T> array, int offset, int 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);
@@ -179,17 +181,20 @@ namespace glTF2Sharp
             }
             }
         }
         }
 
 
-        internal static T AsValue<T>(this T? value, T defval) where T : struct
+        internal static T AsValue<T>(this T? value, T defval)
+            where T : struct
         {
         {
             return value ?? defval;
             return value ?? defval;
         }
         }
 
 
-        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>
         {
         {
             if (value.Equals(defval)) return null;
             if (value.Equals(defval)) return null;
 
 
@@ -212,7 +217,7 @@ namespace glTF2Sharp
         internal static String AsName(this string name)
         internal static String AsName(this string name)
         {
         {
             return string.IsNullOrWhiteSpace(name) ? null : name;
             return string.IsNullOrWhiteSpace(name) ? null : name;
-        }        
+        }
 
 
         #endregion
         #endregion
 
 
@@ -268,7 +273,7 @@ namespace glTF2Sharp
 
 
                 default: throw new NotImplementedException();
                 default: throw new NotImplementedException();
             }
             }
-        }           
+        }
 
 
         public static int DimCount(this ElementType dimension)
         public static int DimCount(this ElementType dimension)
         {
         {

+ 18 - 0
src/glTF2Sharp.DOM/glTF2Sharp.DOM.csproj

@@ -22,10 +22,28 @@
     </AssemblyAttribute>    
     </AssemblyAttribute>    
   </ItemGroup>
   </ItemGroup>
 
 
+  <ItemGroup>
+    <None Include="Schema2\Generated\*.cs">
+      <ExcludeFromStyleCop>true</ExcludeFromStyleCop>
+    </None>
+  </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" />
+    <PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
+    </PackageReference>
+  </ItemGroup>
+
+  <PropertyGroup>
+    <CodeAnalysisRuleSet>..\..\glTF2Sharp.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <AdditionalFiles Include="..\..\stylecop.json" />
   </ItemGroup>
   </ItemGroup>
 
 
 </Project>
 </Project>

+ 1 - 1
src/glTF2Sharp.Tests/Schema2/LoadModelTests.cs

@@ -142,7 +142,7 @@ namespace glTF2Sharp.Schema2
 
 
                 return ModelRoot.Load(filePath);
                 return ModelRoot.Load(filePath);
             }
             }
-            catch(ExtensionException eex)            
+            catch(UnsupportedExtensionException eex)            
             {
             {
                 TestContext.WriteLine($"{filePath} ERROR: {eex.Message}");
                 TestContext.WriteLine($"{filePath} ERROR: {eex.Message}");
 
 

+ 16 - 0
stylecop.json

@@ -0,0 +1,16 @@
+{
+  "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
+  "settings": {
+    "orderingRules": {
+      "usingDirectivesPlacement": "outsideNamespace",
+      "elementOrder": [
+        "kind"
+      ]
+    },
+    "documentationRules": {
+      "xmlHeader": false,
+      "documentInternalElements": false,
+      "copyrightText": "Copyright (c) Six Labors and contributors.\nLicensed under the Apache License, Version 2.0."
+    }
+  }
+}