Skip to content

Commit

Permalink
Fixing animation appending instead of commenting out.
Browse files Browse the repository at this point in the history
It looks like the code is meant for x,y,z with a stride, but our GLB has only x.
  • Loading branch information
Erica Smith and Robert Wallis committed Nov 26, 2018
1 parent ae4aef8 commit 3a07244
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions Source/Common/GLTFUnarchiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1293,22 +1293,34 @@ public class GLTFUnarchiver {
group.animations = animations
group.repeatCount = .infinity

let step = animations.count
let dataLength = values.count / step
// guard dataLength == keyTimes.count else {
// throw GLTFUnarchiveError.DataInconsistent("loadWeightAnimationsSampler: data count mismatch: \(dataLength) != \(keyTimes.count)")
// }
for i in 0..<animations.count {
var valueIndex = i
var v = [NSNumber]()
v.reserveCapacity(dataLength)
for _ in 0..<dataLength {
v.append(values[valueIndex])
valueIndex += step
if keyTimes.count == values.count {
for i in 0..<animations.count {
var v = [NSNumber]()
v.reserveCapacity(values.count)
for j in 0..<values.count {
v.append(values[j])
}
animations[i].values = v
}
} else {
let step = animations.count
let dataLength = values.count / step
// Comment out to fix animations
guard dataLength == keyTimes.count else {
throw GLTFUnarchiveError.DataInconsistent("loadWeightAnimationsSampler: data count mismatch: \(dataLength) != \(keyTimes.count)")
}
for i in 0..<animations.count {
var valueIndex = i
var v = [NSNumber]()
v.reserveCapacity(dataLength)
for _ in 0..<dataLength {
v.append(values[valueIndex])
valueIndex += step
}
animations[i].values = v
}
animations[i].values = v
}
return group
}

Expand Down

0 comments on commit 3a07244

Please sign in to comment.