Skip to content

Commit efad557

Browse files
takahiroxmrdoob
authored andcommitted
Skip the last keyframe operation of KeyframeTrackPrototype.optimize() if times.length <= 1 (mrdoob#9691)
1 parent c7a6813 commit efad557

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/animation/KeyframeTrackPrototype.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,17 @@ KeyframeTrackPrototype = {
336336

337337
// flush last keyframe (compaction looks ahead)
338338

339-
times[ writeIndex ] = times[ lastIndex ];
339+
if ( lastIndex > 0 ) {
340340

341-
for ( var readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++ j )
341+
times[ writeIndex ] = times[ lastIndex ];
342342

343-
values[ writeOffset + j ] = values[ readOffset + j ];
343+
for ( var readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++ j )
344344

345-
++ writeIndex;
345+
values[ writeOffset + j ] = values[ readOffset + j ];
346+
347+
++ writeIndex;
348+
349+
}
346350

347351
if ( writeIndex !== times.length ) {
348352

0 commit comments

Comments
 (0)