Browse Source

more code refactoring:
renamed Sampler to TextureSampler to match AnimationSampler
improvements in serialization

Vicente Penades 6 years ago
parent
commit
ae6ed4fe88

+ 2 - 2
build/SharpGLTF.CodeGen/CodeGen/EmitCSharp.cs

@@ -606,13 +606,13 @@ namespace SharpGLTF.CodeGen
             yield return string.Empty;
             yield return string.Empty;
 
 
             yield return "/// <inheritdoc />".Indent(1);
             yield return "/// <inheritdoc />".Indent(1);
-            yield return "protected override void DeserializeProperty(JsonReader reader, string property)".Indent(1);
+            yield return "protected override void DeserializeProperty(string property, JsonReader reader)".Indent(1);
             yield return "{".Indent(1);
             yield return "{".Indent(1);
             yield return "switch (property)".Indent(2);
             yield return "switch (property)".Indent(2);
             yield return "{".Indent(2);
             yield return "{".Indent(2);
 
 
             foreach (var l in _DeserializerSwitchBody.Indent(3)) yield return l;
             foreach (var l in _DeserializerSwitchBody.Indent(3)) yield return l;
-            if (HasBaseClass) yield return "default: base.DeserializeProperty(reader, property); break;".Indent(3);
+            if (HasBaseClass) yield return "default: base.DeserializeProperty(property, reader); 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 - 1
build/SharpGLTF.CodeGen/Program.cs

@@ -187,7 +187,7 @@ namespace SharpGLTF
             newEmitter.SetRuntimeName("glTF Property", "ExtraProperties");
             newEmitter.SetRuntimeName("glTF Property", "ExtraProperties");
             newEmitter.SetRuntimeName("glTF Child of Root Property", "LogicalChildOfRoot");
             newEmitter.SetRuntimeName("glTF Child of Root Property", "LogicalChildOfRoot");
 
 
-            // newEmitter.SetRuntimeName("Sampler", "TextureSampler");
+            newEmitter.SetRuntimeName("Sampler", "TextureSampler");
 
 
             newEmitter.SetRuntimeName("UNSIGNED_BYTE-UNSIGNED_INT-UNSIGNED_SHORT", "IndexEncodingType");            
             newEmitter.SetRuntimeName("UNSIGNED_BYTE-UNSIGNED_INT-UNSIGNED_SHORT", "IndexEncodingType");            
             newEmitter.SetRuntimeName("BYTE-FLOAT-SHORT-UNSIGNED_BYTE-UNSIGNED_INT-UNSIGNED_SHORT", "EncodingType");            
             newEmitter.SetRuntimeName("BYTE-FLOAT-SHORT-UNSIGNED_BYTE-UNSIGNED_INT-UNSIGNED_SHORT", "EncodingType");            

+ 2 - 2
build/SharpGLTF.CodeGen/SharpGLTF.CodeGen.csproj

@@ -8,8 +8,8 @@
 
 
   <ItemGroup>
   <ItemGroup>
     <PackageReference Include="LibGit2Sharp" Version="0.26.0" />
     <PackageReference Include="LibGit2Sharp" Version="0.26.0" />
-    <PackageReference Include="NJsonSchema.CodeGeneration" Version="9.13.19" />
-    <PackageReference Include="NJsonSchema.CodeGeneration.CSharp" Version="9.13.19" />
+    <PackageReference Include="NJsonSchema.CodeGeneration" Version="9.13.23" />
+    <PackageReference Include="NJsonSchema.CodeGeneration.CSharp" Version="9.13.23" />
   </ItemGroup>
   </ItemGroup>
 
 
 </Project>
 </Project>

+ 0 - 3
src/SharpGLTF/Collections/LinqDictionary.cs

@@ -9,9 +9,6 @@ namespace SharpGLTF.Collections
     /// <summary>
     /// <summary>
     /// Wraps a standard dictionary, but performs a transform in the value
     /// Wraps a standard dictionary, but performs a transform in the value
     /// </summary>
     /// </summary>
-    /// <typeparam name="TKey"></typeparam>
-    /// <typeparam name="TValueIn"></typeparam>
-    /// <typeparam name="TValueOut"></typeparam>
     struct ReadOnlyLinqDictionary<TKey, TValueIn, TValueOut> : IReadOnlyDictionary<TKey, TValueOut>
     struct ReadOnlyLinqDictionary<TKey, TValueIn, TValueOut> : IReadOnlyDictionary<TKey, TValueOut>
     {
     {
         #region lifecycle
         #region lifecycle

+ 1 - 1
src/SharpGLTF/Collections/ReferenceComparer.cs

@@ -9,7 +9,7 @@ namespace SharpGLTF.Collections
     /// this class is used to compare two T class references,
     /// this class is used to compare two T class references,
     /// bypassing any equality operator implemented by the T class.
     /// bypassing any equality operator implemented by the T class.
     /// </summary>
     /// </summary>
-    /// <see cref="https://stackoverflow.com/questions/4901320/is-there-any-kind-of-referencecomparer-in-net"/>
+    /// <see href="https://stackoverflow.com/questions/4901320/is-there-any-kind-of-referencecomparer-in-net"/>
     sealed class ReferenceComparer<T> : IEqualityComparer<T>
     sealed class ReferenceComparer<T> : IEqualityComparer<T>
         where T : class
         where T : class
     {
     {

+ 1 - 1
src/SharpGLTF/Debug/DebugViews.cs

@@ -5,7 +5,7 @@ using System.Numerics;
 using System.Text;
 using System.Text;
 
 
 namespace SharpGLTF.Debug
 namespace SharpGLTF.Debug
-{    
+{
     internal sealed class _CollectionDebugProxy<T>
     internal sealed class _CollectionDebugProxy<T>
     {
     {
         // https://referencesource.microsoft.com/#mscorlib/system/collections/generic/debugview.cs,29
         // https://referencesource.microsoft.com/#mscorlib/system/collections/generic/debugview.cs,29

+ 3 - 3
src/SharpGLTF/Schema2/Generated/ext.ModelLightsPunctual.g.cs

@@ -49,7 +49,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "innerConeAngle": _innerConeAngle = DeserializePropertyValue<Double?>(reader); break;
 				case "innerConeAngle": _innerConeAngle = DeserializePropertyValue<Double?>(reader); break;
@@ -94,7 +94,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "color": _color = DeserializePropertyValue<Vector3?>(reader); break;
 				case "color": _color = DeserializePropertyValue<Vector3?>(reader); break;
@@ -124,7 +124,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "lights": DeserializePropertyList<PunctualLight>(reader, _lights); break;
 				case "lights": DeserializePropertyList<PunctualLight>(reader, _lights); break;

+ 1 - 1
src/SharpGLTF/Schema2/Generated/ext.NodeLightsPunctual.g.cs

@@ -40,7 +40,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "light": _light = DeserializePropertyValue<Int32>(reader); break;
 				case "light": _light = DeserializePropertyValue<Int32>(reader); break;

+ 1 - 1
src/SharpGLTF/Schema2/Generated/ext.TextureTransform.g.cs

@@ -56,7 +56,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "offset": _offset = DeserializePropertyValue<Vector2?>(reader); break;
 				case "offset": _offset = DeserializePropertyValue<Vector2?>(reader); break;

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

@@ -40,7 +40,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				default: base.DeserializeProperty(property, reader); break;
 				default: base.DeserializeProperty(property, reader); break;

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

@@ -60,7 +60,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "diffuseFactor": _diffuseFactor = DeserializePropertyValue<Vector4?>(reader); break;
 				case "diffuseFactor": _diffuseFactor = DeserializePropertyValue<Vector4?>(reader); break;

+ 32 - 32
src/SharpGLTF/Schema2/Generated/gltf.g.cs

@@ -184,7 +184,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "name": _name = DeserializePropertyValue<String>(reader); break;
 				case "name": _name = DeserializePropertyValue<String>(reader); break;
@@ -220,7 +220,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "bufferView": _bufferView = DeserializePropertyValue<Int32>(reader); break;
 				case "bufferView": _bufferView = DeserializePropertyValue<Int32>(reader); break;
@@ -255,7 +255,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "bufferView": _bufferView = DeserializePropertyValue<Int32>(reader); break;
 				case "bufferView": _bufferView = DeserializePropertyValue<Int32>(reader); break;
@@ -291,7 +291,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "count": _count = DeserializePropertyValue<Int32>(reader); break;
 				case "count": _count = DeserializePropertyValue<Int32>(reader); break;
@@ -355,7 +355,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "bufferView": _bufferView = DeserializePropertyValue<Int32?>(reader); break;
 				case "bufferView": _bufferView = DeserializePropertyValue<Int32?>(reader); break;
@@ -394,7 +394,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "node": _node = DeserializePropertyValue<Int32?>(reader); break;
 				case "node": _node = DeserializePropertyValue<Int32?>(reader); break;
@@ -426,7 +426,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "sampler": _sampler = DeserializePropertyValue<Int32>(reader); break;
 				case "sampler": _sampler = DeserializePropertyValue<Int32>(reader); break;
@@ -462,7 +462,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "input": _input = DeserializePropertyValue<Int32>(reader); break;
 				case "input": _input = DeserializePropertyValue<Int32>(reader); break;
@@ -497,7 +497,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "channels": DeserializePropertyList<AnimationChannel>(reader, _channels); break;
 				case "channels": DeserializePropertyList<AnimationChannel>(reader, _channels); break;
@@ -535,7 +535,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "copyright": _copyright = DeserializePropertyValue<String>(reader); break;
 				case "copyright": _copyright = DeserializePropertyValue<String>(reader); break;
@@ -570,7 +570,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "byteLength": _byteLength = DeserializePropertyValue<Int32>(reader); break;
 				case "byteLength": _byteLength = DeserializePropertyValue<Int32>(reader); break;
@@ -616,7 +616,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "buffer": _buffer = DeserializePropertyValue<Int32>(reader); break;
 				case "buffer": _buffer = DeserializePropertyValue<Int32>(reader); break;
@@ -659,7 +659,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "xmag": _xmag = DeserializePropertyValue<Double>(reader); break;
 				case "xmag": _xmag = DeserializePropertyValue<Double>(reader); break;
@@ -703,7 +703,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "aspectRatio": _aspectRatio = DeserializePropertyValue<Double?>(reader); break;
 				case "aspectRatio": _aspectRatio = DeserializePropertyValue<Double?>(reader); break;
@@ -741,7 +741,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "orthographic": _orthographic = DeserializePropertyValue<CameraOrthographic>(reader); break;
 				case "orthographic": _orthographic = DeserializePropertyValue<CameraOrthographic>(reader); break;
@@ -776,7 +776,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "index": _index = DeserializePropertyValue<Int32>(reader); break;
 				case "index": _index = DeserializePropertyValue<Int32>(reader); break;
@@ -824,7 +824,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "baseColorFactor": _baseColorFactor = DeserializePropertyValue<Vector4?>(reader); break;
 				case "baseColorFactor": _baseColorFactor = DeserializePropertyValue<Vector4?>(reader); break;
@@ -854,7 +854,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "scale": _scale = DeserializePropertyValue<Double?>(reader); break;
 				case "scale": _scale = DeserializePropertyValue<Double?>(reader); break;
@@ -882,7 +882,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "strength": _strength = DeserializePropertyValue<Double?>(reader); break;
 				case "strength": _strength = DeserializePropertyValue<Double?>(reader); break;
@@ -936,7 +936,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "alphaCutoff": _alphaCutoff = DeserializePropertyValue<Double?>(reader); break;
 				case "alphaCutoff": _alphaCutoff = DeserializePropertyValue<Double?>(reader); break;
@@ -985,7 +985,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "attributes": DeserializePropertyDictionary<Int32>(reader, _attributes); break;
 				case "attributes": DeserializePropertyDictionary<Int32>(reader, _attributes); break;
@@ -1024,7 +1024,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "primitives": DeserializePropertyList<MeshPrimitive>(reader, _primitives); break;
 				case "primitives": DeserializePropertyList<MeshPrimitive>(reader, _primitives); break;
@@ -1081,7 +1081,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "camera": _camera = DeserializePropertyValue<Int32?>(reader); break;
 				case "camera": _camera = DeserializePropertyValue<Int32?>(reader); break;
@@ -1102,7 +1102,7 @@ namespace SharpGLTF.Schema2
 	/// <summary>
 	/// <summary>
 	/// Texture sampler properties for filtering and wrapping modes.
 	/// Texture sampler properties for filtering and wrapping modes.
 	/// </summary>
 	/// </summary>
-	partial class Sampler : LogicalChildOfRoot
+	partial class TextureSampler : LogicalChildOfRoot
 	{
 	{
 	
 	
 		private TextureInterpolationMode? _magFilter;
 		private TextureInterpolationMode? _magFilter;
@@ -1128,7 +1128,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "magFilter": _magFilter = DeserializePropertyValue<TextureInterpolationMode>(reader); break;
 				case "magFilter": _magFilter = DeserializePropertyValue<TextureInterpolationMode>(reader); break;
@@ -1160,7 +1160,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "nodes": DeserializePropertyList<Int32>(reader, _nodes); break;
 				case "nodes": DeserializePropertyList<Int32>(reader, _nodes); break;
@@ -1195,7 +1195,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "inverseBindMatrices": _inverseBindMatrices = DeserializePropertyValue<Int32?>(reader); break;
 				case "inverseBindMatrices": _inverseBindMatrices = DeserializePropertyValue<Int32?>(reader); break;
@@ -1228,7 +1228,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "sampler": _sampler = DeserializePropertyValue<Int32?>(reader); break;
 				case "sampler": _sampler = DeserializePropertyValue<Int32?>(reader); break;
@@ -1281,7 +1281,7 @@ namespace SharpGLTF.Schema2
 		private ChildrenCollection<Node,ModelRoot> _nodes;
 		private ChildrenCollection<Node,ModelRoot> _nodes;
 		
 		
 		private const int _samplersMinItems = 1;
 		private const int _samplersMinItems = 1;
-		private ChildrenCollection<Sampler,ModelRoot> _samplers;
+		private ChildrenCollection<TextureSampler,ModelRoot> _samplers;
 		
 		
 		private Int32? _scene;
 		private Int32? _scene;
 		
 		
@@ -1320,7 +1320,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "asset": _asset = DeserializePropertyValue<Asset>(reader); break;
 				case "asset": _asset = DeserializePropertyValue<Asset>(reader); break;
@@ -1335,7 +1335,7 @@ namespace SharpGLTF.Schema2
 				case "materials": DeserializePropertyList<Material>(reader, _materials); break;
 				case "materials": DeserializePropertyList<Material>(reader, _materials); break;
 				case "meshes": DeserializePropertyList<Mesh>(reader, _meshes); break;
 				case "meshes": DeserializePropertyList<Mesh>(reader, _meshes); break;
 				case "nodes": DeserializePropertyList<Node>(reader, _nodes); break;
 				case "nodes": DeserializePropertyList<Node>(reader, _nodes); break;
-				case "samplers": DeserializePropertyList<Sampler>(reader, _samplers); break;
+				case "samplers": DeserializePropertyList<TextureSampler>(reader, _samplers); break;
 				case "scene": _scene = DeserializePropertyValue<Int32?>(reader); break;
 				case "scene": _scene = DeserializePropertyValue<Int32?>(reader); break;
 				case "scenes": DeserializePropertyList<Scene>(reader, _scenes); break;
 				case "scenes": DeserializePropertyList<Scene>(reader, _scenes); break;
 				case "skins": DeserializePropertyList<Skin>(reader, _skins); break;
 				case "skins": DeserializePropertyList<Skin>(reader, _skins); break;
@@ -1370,7 +1370,7 @@ namespace SharpGLTF.Schema2
 	
 	
 		/// <inheritdoc />
 		/// <inheritdoc />
 		protected override void DeserializeProperty(string property, JsonReader reader)
 		protected override void DeserializeProperty(string property, JsonReader reader)
-        {
+		{
 			switch (property)
 			switch (property)
 			{
 			{
 				case "bufferView": _bufferView = DeserializePropertyValue<Int32?>(reader); break;
 				case "bufferView": _bufferView = DeserializePropertyValue<Int32?>(reader); break;

+ 0 - 1
src/SharpGLTF/Schema2/glb.Images.cs

@@ -242,7 +242,6 @@ namespace SharpGLTF.Schema2
             }
             }
 
 
             throw new NotImplementedException();
             throw new NotImplementedException();
-
         }
         }
 
 
         private void _WriteAsBufferView()
         private void _WriteAsBufferView()

+ 1 - 1
src/SharpGLTF/Schema2/gltf.Animations.cs

@@ -350,7 +350,7 @@ namespace SharpGLTF.Schema2
             return (keys, vals);
             return (keys, vals);
         }
         }
 
 
-        private static (Single[], TValue[]) _Split<TValue>(IReadOnlyDictionary<Single, (TValue,TValue,TValue)> keyframes)
+        private static (Single[], TValue[]) _Split<TValue>(IReadOnlyDictionary<Single, (TValue, TValue, TValue)> keyframes)
         {
         {
             var sorted = keyframes.OrderBy(item => item.Key).ToList();
             var sorted = keyframes.OrderBy(item => item.Key).ToList();
 
 

+ 9 - 13
src/SharpGLTF/Schema2/gltf.ExtraProperties.cs

@@ -14,7 +14,7 @@ namespace SharpGLTF.Schema2
 
 
         private readonly List<JsonSerializable> _extensions = new List<JsonSerializable>();
         private readonly List<JsonSerializable> _extensions = new List<JsonSerializable>();
 
 
-        private readonly List<JsonSerializable> _extras = new List<JsonSerializable>();
+        private Object _extras;
 
 
         #endregion
         #endregion
 
 
@@ -26,9 +26,9 @@ namespace SharpGLTF.Schema2
         public IReadOnlyCollection<JsonSerializable> Extensions => _extensions;
         public IReadOnlyCollection<JsonSerializable> Extensions => _extensions;
 
 
         /// <summary>
         /// <summary>
-        /// Gets a collection of extra dynamic properties.
+        /// Gets the extras object
         /// </summary>
         /// </summary>
-        public IReadOnlyCollection<JsonSerializable> Extras => _extras;
+        public Object Extras => _extras;
 
 
         #endregion
         #endregion
 
 
@@ -103,8 +103,7 @@ namespace SharpGLTF.Schema2
 
 
             if (_extras != null)
             if (_extras != null)
             {
             {
-                var dict = _ToDictionary(this, _extras);
-                SerializeProperty(writer, "extras", dict);
+                SerializeProperty(writer, "extras", _extras);
             }
             }
         }
         }
 
 
@@ -139,7 +138,7 @@ namespace SharpGLTF.Schema2
             {
             {
                 case "extensions": _DeserializeExtensions(this, reader, _extensions); break;
                 case "extensions": _DeserializeExtensions(this, reader, _extensions); break;
 
 
-                case "extras": _DeserializeExtensions(this, reader, _extras); break;
+                case "extras": _extras = DeserializeObject(reader); break;
 
 
                 default: reader.Skip(); break;
                 default: reader.Skip(); break;
             }
             }
@@ -157,14 +156,11 @@ namespace SharpGLTF.Schema2
 
 
                     var val = ExtensionsFactory.Create(parent, key);
                     var val = ExtensionsFactory.Create(parent, key);
 
 
-                    if (val != null)
-                    {
-                        val.Deserialize(reader);
-                        extensions.Add(val);
-                        continue;
-                    }
+                    if (val == null) val = new Unknown(key);
 
 
-                    DeserializeObject(reader);
+                    val.Deserialize(reader);
+                    extensions.Add(val);
+                    continue;
                 }
                 }
             }
             }
 
 

+ 1 - 1
src/SharpGLTF/Schema2/gltf.Materials.cs

@@ -138,7 +138,7 @@ namespace SharpGLTF.Schema2
 
 
         public Image Image => Texture?.Source;
         public Image Image => Texture?.Source;
 
 
-        public Sampler Sampler => Texture?.Sampler;
+        public TextureSampler Sampler => Texture?.Sampler;
 
 
         public Vector4 Factor => _FactorGetter();
         public Vector4 Factor => _FactorGetter();
 
 

+ 21 - 17
src/SharpGLTF/Schema2/gltf.Root.cs

@@ -37,7 +37,7 @@ namespace SharpGLTF.Schema2
             _materials = new ChildrenCollection<Material, ModelRoot>(this);
             _materials = new ChildrenCollection<Material, ModelRoot>(this);
             _meshes = new ChildrenCollection<Mesh, ModelRoot>(this);
             _meshes = new ChildrenCollection<Mesh, ModelRoot>(this);
             _nodes = new ChildrenCollection<Node, ModelRoot>(this);
             _nodes = new ChildrenCollection<Node, ModelRoot>(this);
-            _samplers = new ChildrenCollection<Sampler, ModelRoot>(this);
+            _samplers = new ChildrenCollection<TextureSampler, 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);
@@ -53,8 +53,12 @@ namespace SharpGLTF.Schema2
         /// </remarks>
         /// </remarks>
         public ModelRoot DeepClone()
         public ModelRoot DeepClone()
         {
         {
-            var dictionary = this.WriteToDictionary("deepclone");
-            return ModelRoot.ReadFromDictionary(dictionary, "deepclone.gltf");
+            var dict = new Dictionary<string, ArraySegment<Byte>>();
+            var settings = WriteSettings.ForDeepClone(dict);
+
+            this.Write(settings, "deepclone");
+
+            return ModelRoot.ReadFromDictionary(dict, "deepclone.gltf");
         }
         }
 
 
         #endregion
         #endregion
@@ -73,22 +77,22 @@ namespace SharpGLTF.Schema2
 
 
         #region Logical resouces
         #region Logical resouces
 
 
-        public IReadOnlyList<Material>      LogicalMaterials    => _materials;
-        public IReadOnlyList<Texture>       LogicalTextures     => _textures;
-        public IReadOnlyList<Sampler>       LogicalSamplers     => _samplers;
-        public IReadOnlyList<Image>         LogicalImages       => _images;
+        public IReadOnlyList<Material>          LogicalMaterials        => _materials;
+        public IReadOnlyList<Texture>           LogicalTextures         => _textures;
+        public IReadOnlyList<TextureSampler>    LogicalTextureSamplers  => _samplers;
+        public IReadOnlyList<Image>             LogicalImages           => _images;
 
 
-        public IReadOnlyList<Buffer>        LogicalBuffers      => _buffers;
-        public IReadOnlyList<BufferView>    LogicalBufferViews  => _bufferViews;
-        public IReadOnlyList<Accessor>      LogicalAccessors    => _accessors;
+        public IReadOnlyList<Buffer>            LogicalBuffers          => _buffers;
+        public IReadOnlyList<BufferView>        LogicalBufferViews      => _bufferViews;
+        public IReadOnlyList<Accessor>          LogicalAccessors        => _accessors;
 
 
-        public IReadOnlyList<Mesh>          LogicalMeshes       => _meshes;
-        public IReadOnlyList<Skin>          LogicalSkins        => _skins;
-        public IReadOnlyList<Camera>        LogicalCameras      => _cameras;
+        public IReadOnlyList<Mesh>              LogicalMeshes           => _meshes;
+        public IReadOnlyList<Skin>              LogicalSkins            => _skins;
+        public IReadOnlyList<Camera>            LogicalCameras          => _cameras;
 
 
-        public IReadOnlyList<Node>          LogicalNodes        => _nodes;
-        public IReadOnlyList<Scene>         LogicalScenes       => _scenes;
-        public IReadOnlyList<Animation>     LogicalAnimations   => _animations;
+        public IReadOnlyList<Node>              LogicalNodes            => _nodes;
+        public IReadOnlyList<Scene>             LogicalScenes           => _scenes;
+        public IReadOnlyList<Animation>         LogicalAnimations       => _animations;
 
 
         /// <inheritdoc />
         /// <inheritdoc />
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()
@@ -105,7 +109,7 @@ namespace SharpGLTF.Schema2
             containers = containers.Concat(this.LogicalMaterials);
             containers = containers.Concat(this.LogicalMaterials);
             containers = containers.Concat(this.LogicalMeshes);
             containers = containers.Concat(this.LogicalMeshes);
             containers = containers.Concat(this.LogicalNodes);
             containers = containers.Concat(this.LogicalNodes);
-            containers = containers.Concat(this.LogicalSamplers);
+            containers = containers.Concat(this.LogicalTextureSamplers);
             containers = containers.Concat(this.LogicalScenes);
             containers = containers.Concat(this.LogicalScenes);
             containers = containers.Concat(this.LogicalSkins);
             containers = containers.Concat(this.LogicalSkins);
             containers = containers.Concat(this.LogicalTextures);
             containers = containers.Concat(this.LogicalTextures);

+ 37 - 2
src/SharpGLTF/Schema2/gltf.Serialization.cs

@@ -54,10 +54,24 @@ namespace SharpGLTF.Schema2
         public AssetReader FileReader { get; set; }
         public AssetReader FileReader { get; set; }
     }
     }
 
 
+    /// <summary>
+    /// Determines the way in which <see cref="Image"/> instances are stored.
+    /// </summary>
     public enum ImageWriteMode
     public enum ImageWriteMode
     {
     {
+        /// <summary>
+        /// Images will be stored as external satellite files.
+        /// </summary>
         SatelliteFile,
         SatelliteFile,
+
+        /// <summary>
+        /// Images will be stored as internal binary buffers.
+        /// </summary>
         BufferView,
         BufferView,
+
+        /// <summary>
+        /// Images will be embedded into the JSON encoded in MIME64.
+        /// </summary>
         Embedded
         Embedded
     }
     }
 
 
@@ -68,6 +82,27 @@ namespace SharpGLTF.Schema2
     {
     {
         #region lifecycle
         #region lifecycle
 
 
+        /// <summary>
+        /// These settings are used exclusively by <see cref="MODEL.DeepClone"/>.
+        /// </summary>
+        /// <param name="dict">The dictionary where the model will be stored</param>
+        /// <returns>The settings to use with <see cref="MODEL.Write(WriteSettings, string)"/></returns>
+        internal static WriteSettings ForDeepClone(Dictionary<string, BYTES> dict)
+        {
+            var settings = new WriteSettings()
+            {
+                BinaryMode = false,
+                ImageWriting = ImageWriteMode.SatelliteFile,
+                MergeBuffers = false,
+                JsonFormatting = Formatting.None,
+                _NoCloneWatchdog = true,
+
+                FileWriter = (fn, buff) => dict[fn] = buff
+            };
+
+            return settings;
+        }
+
         internal static WriteSettings ForText(string filePath)
         internal static WriteSettings ForText(string filePath)
         {
         {
             Guard.FilePathMustBeValid(filePath, nameof(filePath));
             Guard.FilePathMustBeValid(filePath, nameof(filePath));
@@ -183,7 +218,7 @@ namespace SharpGLTF.Schema2
         /// <returns>The source <see cref="MODEL"/> instance, or a cloned and modified instance if current settings required it.</returns>
         /// <returns>The source <see cref="MODEL"/> instance, or a cloned and modified instance if current settings required it.</returns>
         internal MODEL FilterModel(MODEL model)
         internal MODEL FilterModel(MODEL model)
         {
         {
-            Guard.NotNull(model,nameof(model));
+            Guard.NotNull(model, nameof(model));
 
 
             var needsMergeBuffers = (this.MergeBuffers | this.BinaryMode) && model.LogicalBuffers.Count > 1;
             var needsMergeBuffers = (this.MergeBuffers | this.BinaryMode) && model.LogicalBuffers.Count > 1;
 
 
@@ -494,7 +529,7 @@ namespace SharpGLTF.Schema2
         {
         {
             Guard.NotNull(settings, nameof(settings));
             Guard.NotNull(settings, nameof(settings));
             Guard.NotNullOrEmpty(baseName, nameof(baseName));
             Guard.NotNullOrEmpty(baseName, nameof(baseName));
-            Guard.NotNull(model,nameof(model));
+            Guard.NotNull(model, nameof(model));
 
 
             model = settings.FilterModel(model);
             model = settings.FilterModel(model);
 
 

+ 16 - 16
src/SharpGLTF/Schema2/gltf.Textures.cs

@@ -81,9 +81,9 @@ namespace SharpGLTF.Schema2
         /// </summary>
         /// </summary>
         public int LogicalIndex => this.LogicalParent.LogicalTextures.IndexOfReference(this);
         public int LogicalIndex => this.LogicalParent.LogicalTextures.IndexOfReference(this);
 
 
-        public Sampler Sampler
+        public TextureSampler Sampler
         {
         {
-            get => _sampler.HasValue ? LogicalParent.LogicalSamplers[_sampler.Value] : null;
+            get => _sampler.HasValue ? LogicalParent.LogicalTextureSamplers[_sampler.Value] : null;
             set
             set
             {
             {
                 if (value != null) Guard.MustShareLogicalParent(this, value, nameof(value));
                 if (value != null) Guard.MustShareLogicalParent(this, value, nameof(value));
@@ -104,14 +104,14 @@ namespace SharpGLTF.Schema2
         #endregion
         #endregion
     }
     }
 
 
-    [System.Diagnostics.DebuggerDisplay("Sampler[{LogicalIndex}] {Name}")]
-    public sealed partial class Sampler
+    [System.Diagnostics.DebuggerDisplay("TextureSampler[{LogicalIndex}] {Name}")]
+    public sealed partial class TextureSampler
     {
     {
         #region lifecycle
         #region lifecycle
 
 
-        internal Sampler() { }
+        internal TextureSampler() { }
 
 
-        internal Sampler(TextureInterpolationMode mag, TextureMipMapMode min, TextureWrapMode ws, TextureWrapMode wt)
+        internal TextureSampler(TextureInterpolationMode mag, TextureMipMapMode min, TextureWrapMode ws, TextureWrapMode wt)
         {
         {
             _magFilter = mag;
             _magFilter = mag;
             _minFilter = min;
             _minFilter = min;
@@ -124,9 +124,9 @@ namespace SharpGLTF.Schema2
         #region properties
         #region properties
 
 
         /// <summary>
         /// <summary>
-        /// Gets the zero-based index of this <see cref="Sampler"/> at <see cref="ModelRoot.LogicalSamplers"/>
+        /// Gets the zero-based index of this <see cref="TextureSampler"/> at <see cref="ModelRoot.LogicalTextureSamplers"/>
         /// </summary>
         /// </summary>
-        public int LogicalIndex => this.LogicalParent.LogicalSamplers.IndexOfReference(this);
+        public int LogicalIndex => this.LogicalParent.LogicalTextureSamplers.IndexOfReference(this);
 
 
         public TextureInterpolationMode MagFilter => _magFilter ?? TextureInterpolationMode.LINEAR;
         public TextureInterpolationMode MagFilter => _magFilter ?? TextureInterpolationMode.LINEAR;
 
 
@@ -171,22 +171,22 @@ namespace SharpGLTF.Schema2
     public partial class ModelRoot
     public partial class ModelRoot
     {
     {
         /// <summary>
         /// <summary>
-        /// Creates or reuses a <see cref="Sampler"/> instance
-        /// at <see cref="ModelRoot.LogicalSamplers"/>.
+        /// Creates or reuses a <see cref="TextureSampler"/> instance
+        /// at <see cref="ModelRoot.LogicalTextureSamplers"/>.
         /// </summary>
         /// </summary>
         /// <param name="mag">A value of <see cref="TextureInterpolationMode"/>.</param>
         /// <param name="mag">A value of <see cref="TextureInterpolationMode"/>.</param>
         /// <param name="min">A value of <see cref="TextureMipMapMode"/>.</param>
         /// <param name="min">A value of <see cref="TextureMipMapMode"/>.</param>
         /// <param name="ws">The <see cref="TextureWrapMode"/> in the S axis.</param>
         /// <param name="ws">The <see cref="TextureWrapMode"/> in the S axis.</param>
         /// <param name="wt">The <see cref="TextureWrapMode"/> in the T axis.</param>
         /// <param name="wt">The <see cref="TextureWrapMode"/> in the T axis.</param>
-        /// <returns>A <see cref="Sampler"/> instance.</returns>
-        public Sampler UseSampler(TextureInterpolationMode mag, TextureMipMapMode min, TextureWrapMode ws, TextureWrapMode wt)
+        /// <returns>A <see cref="TextureSampler"/> instance.</returns>
+        public TextureSampler UseSampler(TextureInterpolationMode mag, TextureMipMapMode min, TextureWrapMode ws, TextureWrapMode wt)
         {
         {
             foreach (var s in this._samplers)
             foreach (var s in this._samplers)
             {
             {
                 if (s.MagFilter == mag && s.MinFilter == min && s.WrapS == ws && s.WrapT == wt) return s;
                 if (s.MagFilter == mag && s.MinFilter == min && s.WrapS == ws && s.WrapT == wt) return s;
             }
             }
 
 
-            var ss = new Sampler(mag, min, ws, wt);
+            var ss = new TextureSampler(mag, min, ws, wt);
 
 
             this._samplers.Add(ss);
             this._samplers.Add(ss);
 
 
@@ -198,9 +198,9 @@ namespace SharpGLTF.Schema2
         /// at <see cref="ModelRoot.LogicalTextures"/>.
         /// at <see cref="ModelRoot.LogicalTextures"/>.
         /// </summary>
         /// </summary>
         /// <param name="image">The source <see cref="Image"/>.</param>
         /// <param name="image">The source <see cref="Image"/>.</param>
-        /// <param name="sampler">The source <see cref="Sampler"/>.</param>
+        /// <param name="sampler">The source <see cref="TextureSampler"/>.</param>
         /// <returns>A <see cref="Texture"/> instance.</returns>
         /// <returns>A <see cref="Texture"/> instance.</returns>
-        public Texture UseTexture(Image image, Sampler sampler)
+        public Texture UseTexture(Image image, TextureSampler sampler)
         {
         {
             if (image == null) return null;
             if (image == null) return null;
 
 
@@ -219,7 +219,7 @@ namespace SharpGLTF.Schema2
             return tex;
             return tex;
         }
         }
 
 
-        internal T _UseTextureInfo<T>(Image image, Sampler sampler, int textureSet)
+        internal T _UseTextureInfo<T>(Image image, TextureSampler sampler, int textureSet)
             where T : TextureInfo, new()
             where T : TextureInfo, new()
         {
         {
             var tex = UseTexture(image, sampler);
             var tex = UseTexture(image, sampler);

+ 3 - 3
src/SharpGLTF/Schema2/khr.lights.cs

@@ -37,7 +37,7 @@ namespace SharpGLTF.Schema2
     public enum PunctualLightType { Directional, Point, Spot }
     public enum PunctualLightType { Directional, Point, Spot }
 
 
     /// <remarks>
     /// <remarks>
-    /// This is part of <see cref="https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual"/> extension.
+    /// This is part of <see href="https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual"/> extension.
     /// </remarks>
     /// </remarks>
     [System.Diagnostics.DebuggerDisplay("{LightType} {Color} {Intensity} {Range}")]
     [System.Diagnostics.DebuggerDisplay("{LightType} {Color} {Intensity} {Range}")]
     public partial class PunctualLight
     public partial class PunctualLight
@@ -107,10 +107,10 @@ namespace SharpGLTF.Schema2
     partial class ModelRoot
     partial class ModelRoot
     {
     {
         /// <summary>
         /// <summary>
-        /// A collection of <see cref="PunctualLight"/> instances.
+        /// Gets A collection of <see cref="PunctualLight"/> instances.
         /// </summary>
         /// </summary>
         /// <remarks>
         /// <remarks>
-        /// This is part of <see cref="https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual">KHR_lights_punctual</see> extension.
+        /// This is part of <see href="https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual">KHR_lights_punctual</see> extension.
         /// </remarks>
         /// </remarks>
         public IReadOnlyList<PunctualLight> LogicalPunctualLights
         public IReadOnlyList<PunctualLight> LogicalPunctualLights
         {
         {

+ 35 - 5
src/SharpGLTF/Transforms/AffineTransform.cs

@@ -5,6 +5,9 @@ using System.Text;
 
 
 namespace SharpGLTF.Transforms
 namespace SharpGLTF.Transforms
 {
 {
+    /// <summary>
+    /// Represents an affine transform in 3D space, defined by a <see cref="Quaternion"/> rotation, a <see cref="Vector3"/> scale and a <see cref="Vector3"/> translation.
+    /// </summary>
     public struct AffineTransform
     public struct AffineTransform
     {
     {
         #region lifecycle
         #region lifecycle
@@ -27,19 +30,38 @@ namespace SharpGLTF.Transforms
 
 
         #region data
         #region data
 
 
+        /// <summary>
+        /// Rotation
+        /// </summary>
         public Quaternion Rotation;
         public Quaternion Rotation;
+
+        /// <summary>
+        /// Scale
+        /// </summary>
         public Vector3 Scale;
         public Vector3 Scale;
-        public Vector3 Translation; // Origin
+
+        /// <summary>
+        /// Translation
+        /// </summary>
+        public Vector3 Translation;
 
 
         #endregion
         #endregion
 
 
         #region properties
         #region properties
 
 
+        /// <summary>
+        /// Gets the <see cref="Matrix"/> transform of the current <see cref="AffineTransform"/>
+        /// </summary>
         public Matrix4x4 Matrix
         public Matrix4x4 Matrix
         {
         {
             get
             get
             {
             {
-                return Matrix4x4.CreateScale(Scale) * Matrix4x4.CreateFromQuaternion(Rotation) * Matrix4x4.CreateTranslation(Translation);
+                return
+                    Matrix4x4.CreateScale(Scale)
+                    *
+                    Matrix4x4.CreateFromQuaternion(Rotation)
+                    *
+                    Matrix4x4.CreateTranslation(Translation);
             }
             }
         }
         }
 
 
@@ -47,11 +69,19 @@ namespace SharpGLTF.Transforms
 
 
         #region API
         #region API
 
 
-        public static Matrix4x4 Evaluate(Matrix4x4? m, Vector3? s, Quaternion? r, Vector3? t)
+        /// <summary>
+        /// Evaluates a <see cref="Matrix4x4"/> transform based on the available parameters.
+        /// </summary>
+        /// <param name="transform">A <see cref="Matrix4x4"/> instance, or null.</param>
+        /// <param name="scale">A <see cref="Vector3"/> instance, or null.</param>
+        /// <param name="rotation">A <see cref="Quaternion"/> instance, or null.</param>
+        /// <param name="translation">A <see cref="Vector3"/> instance, or null.</param>
+        /// <returns>A <see cref="Matrix4x4"/> transform.</returns>
+        public static Matrix4x4 Evaluate(Matrix4x4? transform, Vector3? scale, Quaternion? rotation, Vector3? translation)
         {
         {
-            if (m.HasValue) return m.Value;
+            if (transform.HasValue) return transform.Value;
 
 
-            return new AffineTransform(null, s, r, t).Matrix;
+            return new AffineTransform(null, scale, rotation, translation).Matrix;
         }
         }
 
 
         public static Matrix4x4 LocalToWorld(Matrix4x4 parentWorld, Matrix4x4 childLocal)
         public static Matrix4x4 LocalToWorld(Matrix4x4 parentWorld, Matrix4x4 childLocal)

+ 1 - 1
src/SharpGLTF/_Extensions.cs

@@ -2,11 +2,11 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 using System.Numerics;
 using System.Numerics;
+using System.Linq;
 
 
 namespace SharpGLTF
 namespace SharpGLTF
 {
 {
     using Schema2;
     using Schema2;
-    using System.Linq;
 
 
     /// <summary>
     /// <summary>
     /// Extensions used internally.
     /// Extensions used internally.

+ 14 - 2
tests/SharpGLTF.Tests/Geometry/LoadMeshTests.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Linq;
 using System.Text;
 using System.Text;
 
 
 using NUnit.Framework;
 using NUnit.Framework;
@@ -26,9 +27,20 @@ namespace SharpGLTF.Geometry
             {
             {
                 var root = GltfUtils.LoadModel(f);
                 var root = GltfUtils.LoadModel(f);
                 Assert.NotNull(root);
                 Assert.NotNull(root);
-
-                var meshes = Mesh.Create(root.LogicalMeshes);                
             }
             }
         }
         }
+
+        [Test]
+        public void LoadBrokenFile()
+        {
+            var f = TestFiles.GetSampleFilePaths().First(item => item.EndsWith(".gltf"));
+
+            var json = System.IO.File.ReadAllText(f);
+
+            // break the file
+            json = json.Substring(0, json.Length - 40);
+
+            Assert.Throws<Newtonsoft.Json.JsonReaderException>(() => Schema2.ModelRoot.ParseGLTF(json, new Schema2.ReadSettings()));
+        }
     }
     }
 }
 }

+ 1 - 1
tests/SharpGLTF.Tests/SharpGLTF.Tests.csproj

@@ -12,7 +12,7 @@
     <PackageReference Include="LibGit2Sharp" Version="0.26.0" />
     <PackageReference Include="LibGit2Sharp" Version="0.26.0" />
     <PackageReference Include="nunit" Version="3.11.0" />
     <PackageReference Include="nunit" Version="3.11.0" />
     <PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
     <PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
-    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0" />    
+    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />    
   </ItemGroup>
   </ItemGroup>
 
 
   <ItemGroup>
   <ItemGroup>