|
|
@@ -233,7 +233,6 @@ namespace SharpGLTF.Schema2
|
|
|
var regex = "^[a-zA-Z_][a-zA-Z0-9_]*$";
|
|
|
Guard.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(Schema.Id, regex), nameof(Schema.Id));
|
|
|
|
|
|
-
|
|
|
foreach (var _class in Schema.Classes)
|
|
|
{
|
|
|
Guard.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(_class.Key, regex), nameof(_class.Key));
|
|
|
@@ -244,6 +243,17 @@ namespace SharpGLTF.Schema2
|
|
|
{
|
|
|
Guard.MustBeGreaterThanOrEqualTo(property.Value.Count.Value, 2, nameof(property.Value.Count));
|
|
|
}
|
|
|
+
|
|
|
+ if (property.Value.Required)
|
|
|
+ {
|
|
|
+ Guard.IsTrue(property.Value.NoData == null, nameof(property.Value.NoData), $"The property '{property.Key}' defines a 'noData' value, but is 'required'");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(property.Value.Type == ELEMENTTYPE.SCALAR)
|
|
|
+ {
|
|
|
+ // check The 'componentType' must be defined for a property with type 'SCALAR'
|
|
|
+ Guard.IsTrue(property.Value.ComponentType.HasValue, nameof(property.Value.ComponentType), $"The 'componentType' must be defined for a property '{property.Key}' with type 'SCALAR'");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -843,13 +853,13 @@ namespace SharpGLTF.Schema2
|
|
|
|
|
|
private void CheckScalarTypes<T>(DATATYPE? componentType)
|
|
|
{
|
|
|
- if (componentType == DATATYPE.INT8)
|
|
|
+ if (componentType == DATATYPE.UINT8)
|
|
|
{
|
|
|
- Guard.IsTrue(typeof(T) == typeof(sbyte), nameof(T), $"Scalar value type of property {LogicalKey} must be sbyte");
|
|
|
+ Guard.IsTrue(typeof(T) == typeof(byte), nameof(T), $"Scalar value type of property {LogicalKey} must be byte");
|
|
|
}
|
|
|
- else if (componentType == DATATYPE.UINT8)
|
|
|
+ else if (componentType == DATATYPE.INT8)
|
|
|
{
|
|
|
- Guard.IsTrue(typeof(T) == typeof(byte), nameof(T), $"Scalar value type of property {LogicalKey} must be byte");
|
|
|
+ Guard.IsTrue(typeof(T) == typeof(sbyte), nameof(T), $"Scalar value type of property {LogicalKey} must be sbyte");
|
|
|
}
|
|
|
else if (componentType == DATATYPE.INT16)
|
|
|
{
|
|
|
@@ -1227,6 +1237,7 @@ namespace SharpGLTF.Schema2
|
|
|
#endregion
|
|
|
|
|
|
#region properties
|
|
|
+
|
|
|
public string Name
|
|
|
{
|
|
|
get => _name;
|
|
|
@@ -1263,6 +1274,11 @@ namespace SharpGLTF.Schema2
|
|
|
set => _required = value.AsNullable(_requiredDefault);
|
|
|
}
|
|
|
|
|
|
+ public JsonNode NoData
|
|
|
+ {
|
|
|
+ get => _noData;
|
|
|
+ }
|
|
|
+
|
|
|
public bool Normalized
|
|
|
{
|
|
|
get => _normalized ?? _normalizedDefault;
|
|
|
@@ -1325,9 +1341,10 @@ namespace SharpGLTF.Schema2
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithStringType()
|
|
|
+ public StructuralMetadataClassProperty WithStringType(string noData = null)
|
|
|
{
|
|
|
Type = ElementType.STRING;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
@@ -1337,73 +1354,83 @@ namespace SharpGLTF.Schema2
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithUInt8Type()
|
|
|
+ public StructuralMetadataClassProperty WithUInt8Type(byte? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.UINT8;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithInt8Type()
|
|
|
+ public StructuralMetadataClassProperty WithInt8Type(sbyte? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.INT8;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithUInt16Type()
|
|
|
+ public StructuralMetadataClassProperty WithUInt16Type(ushort? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.UINT16;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithInt16Type()
|
|
|
+ public StructuralMetadataClassProperty WithInt16Type(short? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.INT16;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithUInt32Type()
|
|
|
+ public StructuralMetadataClassProperty WithUInt32Type(uint? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.UINT32;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithInt32Type()
|
|
|
+ public StructuralMetadataClassProperty WithInt32Type(int? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.INT32;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithUInt64Type()
|
|
|
+ public StructuralMetadataClassProperty WithUInt64Type(ulong? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.UINT64;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithInt64Type()
|
|
|
+ public StructuralMetadataClassProperty WithInt64Type(long? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.INT64;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithFloat32Type()
|
|
|
+ public StructuralMetadataClassProperty WithFloat32Type(float? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.FLOAT32;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithFloat64Type()
|
|
|
+ public StructuralMetadataClassProperty WithFloat64Type(double? noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.SCALAR;
|
|
|
ComponentType = DATATYPE.FLOAT64;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
@@ -1429,16 +1456,95 @@ namespace SharpGLTF.Schema2
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ public StructuralMetadataClassProperty WithBooleanArrayType(int? count = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.BOOLEAN, null, count);
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+
|
|
|
+ public StructuralMetadataClassProperty WithUInt8ArrayType(int? count = null, byte? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.UINT8, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
|
|
|
- //public StructuralMetadataClassProperty WithValueType(ELEMENTTYPE etype, DATATYPE? ctype = null)
|
|
|
- //{
|
|
|
- // Type = etype;
|
|
|
- // ComponentType = ctype;
|
|
|
- // Array = false;
|
|
|
- // return this;
|
|
|
- //}
|
|
|
+ public StructuralMetadataClassProperty WithInt8ArrayType(int? count = null, sbyte? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.INT8, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+
|
|
|
+ public StructuralMetadataClassProperty WithInt16ArrayType(int? count = null, short? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.INT16, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+
|
|
|
+ public StructuralMetadataClassProperty WithUInt16ArrayType(int? count = null, ushort? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.UINT16, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+ public StructuralMetadataClassProperty WithInt32ArrayType(int? count = null, int? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.INT32, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+ public StructuralMetadataClassProperty WithUInt32ArrayType(int? count = null, uint? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.UINT32, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+ public StructuralMetadataClassProperty WithInt64ArrayType(int? count = null, long? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.INT64, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+ public StructuralMetadataClassProperty WithUInt64ArrayType(int? count = null, ulong? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.UINT64, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+ public StructuralMetadataClassProperty WithFloat32ArrayType(int? count = null, float? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.FLOAT32, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+ public StructuralMetadataClassProperty WithFloat64ArrayType(int? count = null, double? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.SCALAR, DATATYPE.FLOAT64, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+
|
|
|
+ public StructuralMetadataClassProperty WithVector3ArrayType(int? count = null, Vector3? noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.VEC3, DATATYPE.FLOAT32, count);
|
|
|
+ // todo: how to set noData for vector3?
|
|
|
+ return property;
|
|
|
+ }
|
|
|
+ public StructuralMetadataClassProperty WithMatrix4x4ArrayType(int? count = null)
|
|
|
+ {
|
|
|
+ return WithArrayType(ELEMENTTYPE.MAT4, DATATYPE.FLOAT32, count);
|
|
|
+ }
|
|
|
+
|
|
|
+ public StructuralMetadataClassProperty WithStringArrayType(int? count = null, string noData = null)
|
|
|
+ {
|
|
|
+ var property = WithArrayType(ELEMENTTYPE.STRING, null, count);
|
|
|
+ if (noData != null) property._noData = noData;
|
|
|
+ return property;
|
|
|
+ }
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithArrayType(ELEMENTTYPE etype, DATATYPE? ctype = null, int? count = null)
|
|
|
+ private StructuralMetadataClassProperty WithArrayType(ELEMENTTYPE etype, DATATYPE? ctype = null, int? count = null)
|
|
|
{
|
|
|
Type = etype;
|
|
|
ComponentType = ctype;
|
|
|
@@ -1447,19 +1553,21 @@ namespace SharpGLTF.Schema2
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithEnumArrayType(StructuralMetadataEnum enumeration, int? count = null)
|
|
|
+ public StructuralMetadataClassProperty WithEnumArrayType(StructuralMetadataEnum enumeration, int? count = null, string noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.ENUM;
|
|
|
_enumType = enumeration.LogicalKey;
|
|
|
Array = true;
|
|
|
Count = count;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public StructuralMetadataClassProperty WithEnumeration(StructuralMetadataEnum enumeration)
|
|
|
+ public StructuralMetadataClassProperty WithEnumeration(StructuralMetadataEnum enumeration, string noData = null)
|
|
|
{
|
|
|
Type = ELEMENTTYPE.ENUM;
|
|
|
_enumType = enumeration.LogicalKey;
|
|
|
+ if (noData != null) _noData = noData;
|
|
|
return this;
|
|
|
}
|
|
|
|