Does UnityGLTF support rendering nodes that encompass points and not triangles?
I am working with a glTF model that contains a node with a mesh that consists of a line with 2 vertices (full file added as attachment).
3d viewer can render the model, but UnityGltf throws an exception "Index was outside the bounds of the array".
The reason being that AsUnits array only contains two elements (0, 1) thus the index +2 is out of bounds:
public static void FlipFaces(ref AttributeAccessor attributeAccessor)
{
for (int i = 0; i < attributeAccessor.AccessorContent.AsTriangles.Length; i += 3)
{
uint temp = attributeAccessor.AccessorContent.AsUInts[i];
// this line causes OutOfBoundsException
attributeAccessor.AccessorContent.AsUInts[i] = attributeAccessor.AccessorContent.AsUInts[i + 2];
attributeAccessor.AccessorContent.AsUInts[i + 2] = temp;
}
}
The method calling this function (TransfromAttributes) checks, if the INDICES attribute is present and then runs the FlipFaces method. I noticed that the SemanticProperties class doesn't contain the MODE value and that there is no check for the MODE attribute
public static class SemanticProperties
{
public static readonly string POSITION;
public static readonly string NORMAL;
public static readonly string JOINT;
public static readonly string WEIGHT;
public static readonly string TANGENT;
public static readonly string INDICES;
// methods omitted
}
I think it is necessary to add a check for the MODE property. Since a line doesn't have faces, they can't be flipped.
if (attributeAccessors.ContainsKey(SemanticProperties.POSITION))
{
AttributeAccessor attributeAccessor = attributeAccessors[SemanticProperties.POSITION];
SchemaExtensions.ConvertVector3CoordinateSpace(ref attributeAccessor, SchemaExtensions.CoordinateSpaceConversionScale);
}
if (attributeAccessors.ContainsKey(SemanticProperties.INDICES))
{
AttributeAccessor attributeAccessor = attributeAccessors[SemanticProperties.INDICES];
// only flip flaces, if the mode type is triangles
SchemaExtensions.FlipFaces(ref attributeAccessor);
}
Does UnityGLTF support rendering nodes that encompass points and not triangles? I am working with a glTF model that contains a node with a mesh that consists of a line with 2 vertices (full file added as attachment). 3d viewer can render the model, but UnityGltf throws an exception "Index was outside the bounds of the array".![image](https://user-images.githubusercontent.com/1467464/74167242-3df39d80-4c28-11ea-9ffb-682622c676ea.png)
The reason being that AsUnits array only contains two elements (0, 1) thus the index +2 is out of bounds:
The method calling this function (TransfromAttributes) checks, if the INDICES attribute is present and then runs the FlipFaces method. I noticed that the SemanticProperties class doesn't contain the MODE value and that there is no check for the MODE attribute
Does UnityGltf support different mode types lik LINE as defined in [primitivemodes]https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#primitivemode)?
I think it is necessary to add a check for the MODE property. Since a line doesn't have faces, they can't be flipped.
Model: line.txt