Merge pull request #2763 from aaronfranke/fix-tex-bind-crash

Fix crash when reading texture transform bind without scale
This commit is contained in:
ousttrue 2026-01-16 15:28:32 +09:00 committed by GitHub
commit 5f5b3be5d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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
{