Fix crash when reading texture transform bind without scale

This commit is contained in:
Aaron Franke 2026-01-05 01:16:15 -08:00
parent 3b99078d26
commit ad46c324e7
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF

View File

@ -60,7 +60,15 @@ namespace UniVRM10
var binding = default(UniVRM10.MaterialUVBinding?);
if (material != null)
{
var (scale, offset) = UniGLTF.TextureTransform.VerticalFlipScaleOffset(new Vector2(bind.Scale[0], bind.Scale[1]), new Vector2(bind.Offset[0], bind.Offset[1]));
// Default values: scale [1, 1], offset [0, 0]
Vector2 scaleVec = bind.Scale != null && bind.Scale.Length >= 2
? new Vector2(bind.Scale[0], bind.Scale[1])
: new Vector2(1.0f, 1.0f);
Vector2 offsetVec = bind.Offset != null && bind.Offset.Length >= 2
? new Vector2(bind.Offset[0], bind.Offset[1])
: new Vector2(0.0f, 0.0f);
var (scale, offset) = UniGLTF.TextureTransform.VerticalFlipScaleOffset(scaleVec, offsetVec);
try
{