Skip to content

Commit

Permalink
Make enableBlending and blendingSpeed properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Popov72 committed Aug 30, 2023
1 parent 2c4ee29 commit 7277abd
Showing 1 changed file with 43 additions and 10 deletions.
53 changes: 43 additions & 10 deletions packages/dev/core/src/Animations/animationGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export class AnimationGroup implements IDisposable {
private _isAdditive = false;
private _weight = -1;
private _playOrder = 0;
private _enableBlending: Nullable<boolean> = null;
private _blendingSpeed: Nullable<number> = null;

/** @internal */
public _parentContainer: Nullable<AbstractScene> = null;
Expand Down Expand Up @@ -320,22 +322,45 @@ export class AnimationGroup implements IDisposable {

/**
* Allows the animations of the animation group to blend with current running animations
* Note: this method should be called after all targeted animations have been added to the group
* @param blendingSpeed defines the blending speed to use
* Note that a null value means that each animation will use their own existing blending configuration (Animation.enableBlending)
*/
public enableBlending(blendingSpeed: number) {
for (let i = 0; i < this._targetedAnimations.length; ++i) {
this._targetedAnimations[i].animation.enableBlending = true;
this._targetedAnimations[i].animation.blendingSpeed = blendingSpeed;
public get enableBlending() {
return this._enableBlending;
}

public set enableBlending(value: Nullable<boolean>) {
if (this._enableBlending === value) {
return;
}

this._enableBlending = value;

if (value !== null) {
for (let i = 0; i < this._targetedAnimations.length; ++i) {
this._targetedAnimations[i].animation.enableBlending = value;
}
}
}

/**
* Disable animation blending
* Gets or sets the animation blending speed
* Note that a null value means that each animation will use their own existing blending configuration (Animation.blendingSpeed)
*/
public disableBlending() {
for (let i = 0; i < this._targetedAnimations.length; ++i) {
this._targetedAnimations[i].animation.enableBlending = false;
public get blendingSpeed() {
return this._blendingSpeed;
}

public set blendingSpeed(value: Nullable<number>) {
if (this._blendingSpeed === value) {
return;
}

this._blendingSpeed = value;

if (value !== null) {
for (let i = 0; i < this._targetedAnimations.length; ++i) {
this._targetedAnimations[i].animation.blendingSpeed = value;
}
}
}

Expand Down Expand Up @@ -432,6 +457,14 @@ export class AnimationGroup implements IDisposable {
this._to = keys[keys.length - 1].frame;
}

if (this._enableBlending !== null) {
animation.enableBlending = this._enableBlending;
}

if (this._blendingSpeed !== null) {
animation.blendingSpeed = this._blendingSpeed;
}

this._targetedAnimations.push(targetedAnimation);

return targetedAnimation;
Expand Down

0 comments on commit 7277abd

Please sign in to comment.