@@ -1293,22 +1293,34 @@ public class GLTFUnarchiver {
12931293 group. animations = animations
12941294 group. repeatCount = . infinity
12951295
1296- let step = animations. count
1297- let dataLength = values. count / step
1298- // guard dataLength == keyTimes.count else {
1299- // throw GLTFUnarchiveError.DataInconsistent("loadWeightAnimationsSampler: data count mismatch: \(dataLength) != \(keyTimes.count)")
1300- // }
1301- for i in 0 ..< animations. count {
1302- var valueIndex = i
1303- var v = [ NSNumber] ( )
1304- v. reserveCapacity ( dataLength)
1305- for _ in 0 ..< dataLength {
1306- v. append ( values [ valueIndex] )
1307- valueIndex += step
1296+ if keyTimes. count == values. count {
1297+ for i in 0 ..< animations. count {
1298+ var v = [ NSNumber] ( )
1299+ v. reserveCapacity ( values. count)
1300+ for j in 0 ..< values. count {
1301+ v. append ( values [ j] )
1302+ }
1303+ animations [ i] . values = v
1304+ }
1305+ } else {
1306+ let step = animations. count
1307+ let dataLength = values. count / step
1308+ // Comment out to fix animations
1309+ guard dataLength == keyTimes. count else {
1310+ throw GLTFUnarchiveError . DataInconsistent ( " loadWeightAnimationsSampler: data count mismatch: \( dataLength) != \( keyTimes. count) " )
1311+ }
1312+ for i in 0 ..< animations. count {
1313+ var valueIndex = i
1314+ var v = [ NSNumber] ( )
1315+ v. reserveCapacity ( dataLength)
1316+ for _ in 0 ..< dataLength {
1317+ v. append ( values [ valueIndex] )
1318+ valueIndex += step
1319+ }
1320+ animations [ i] . values = v
13081321 }
1309- animations [ i] . values = v
13101322 }
1311-
1323+
13121324 return group
13131325 }
13141326
0 commit comments