Skip to content

Commit d8e0fab

Browse files
authored
Merge pull request #18469 from donmccurdy/keyframetrack-optimize-safe
KeyframeTrack: Don't overwrite times/values in optimize()
2 parents d28bd8f + 845b2ae commit d8e0fab

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/animation/KeyframeTrack.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,9 @@ Object.assign( KeyframeTrack.prototype, {
347347
// (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)
348348
optimize: function () {
349349

350-
var times = this.times,
351-
values = this.values,
350+
// times or values may be shared with other tracks, so overwriting is unsafe
351+
var times = AnimationUtils.arraySlice( this.times ),
352+
values = AnimationUtils.arraySlice( this.values ),
352353
stride = this.getValueSize(),
353354

354355
smoothInterpolation = this.getInterpolation() === InterpolateSmooth,
@@ -443,6 +444,11 @@ Object.assign( KeyframeTrack.prototype, {
443444
this.times = AnimationUtils.arraySlice( times, 0, writeIndex );
444445
this.values = AnimationUtils.arraySlice( values, 0, writeIndex * stride );
445446

447+
} else {
448+
449+
this.times = times;
450+
this.values = values;
451+
446452
}
447453

448454
return this;

0 commit comments

Comments
 (0)