소스 검색

Merge pull request #8310 from ycw/master

sort ev by frame in asc order
mergify[bot] 5 년 전
부모
커밋
667fe065b9
2개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 0
      dist/preview release/what's new.md
  2. 2 1
      src/Animations/animation.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -135,6 +135,7 @@
 ### Animation
 
 - Added support for Additive Animation Blending. Existing animations can be converted to additive using the new MakeAnimationAdditive method for Skeletons, AnimationGroups and Animations. Animations can be played additively using the new isAdditive input parameter to the begin animation methods. ([c-morten](https://github.com/c-morten))
+- Sort events by frame in ascending order in `Animation#addEvent()` ([ycw](https://github.com/ycw))
 
 ### Maths
 

+ 2 - 1
src/Animations/animation.ts

@@ -553,6 +553,7 @@ export class Animation {
      */
     public addEvent(event: AnimationEvent): void {
         this._events.push(event);
+        this._events.sort((a, b) => a.frame - b.frame);
     }
 
     /**
@@ -1302,4 +1303,4 @@ export class Animation {
 }
 
 _TypeStore.RegisteredTypes["BABYLON.Animation"] = Animation;
-Node._AnimationRangeFactory = (name: string, from: number, to: number) => new AnimationRange(name, from, to);
+Node._AnimationRangeFactory = (name: string, from: number, to: number) => new AnimationRange(name, from, to);