Skip to content

Commit

Permalink
AnimBlendTree fix (#5401)
Browse files Browse the repository at this point in the history
* make the fineParameter and comsumeTrigger functions anonymous
  • Loading branch information
ellthompson authored and Martin Valigursky committed Jun 16, 2023
1 parent eace356 commit 4ed67a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/framework/anim/controller/anim-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,9 @@ class AnimController {
this._animEvaluator.update(dt, this.activeState.hasAnimations);
}

findParameter(name) {
findParameter = (name) => {
return this._findParameter(name);
}
};
}

export { AnimController };
27 changes: 21 additions & 6 deletions src/framework/components/anim/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ class AnimComponent extends Component {
transitions,
this._activate,
this,
this.findParameter.bind(this),
this.consumeTrigger.bind(this)
this.findParameter,
this.consumeTrigger
);
this._layers.push(new AnimComponentLayer(name, controller, this, weight, blendType));
this._layerIndices[name] = layerIndex;
Expand Down Expand Up @@ -631,13 +631,28 @@ class AnimComponent extends Component {
Debug.log(`Cannot set parameter value. No parameter found in anim controller named "${name}" of type "${type}"`);
}

findParameter(name) {
/**
* Returns the parameter object for the specified parameter name. This function is anonymous so that it can be passed to the AnimController
* while still being called in the scope of the AnimComponent.
*
* @param {string} name - The name of the parameter to return the value of.
* @returns {object} The parameter object.
* @private
*/
findParameter = (name) => {
return this._parameters[name];
}
};

consumeTrigger(name) {
/**
* Sets a trigger parameter as having been used by a transition. This function is anonymous so that it can be passed to the AnimController
* while still being called in the scope of the AnimComponent.
*
* @param {string} name - The name of the trigger to set as consumed.
* @private
*/
consumeTrigger = (name) => {
this._consumedTriggers.add(name);
}
};

/**
* Returns a float parameter value by name.
Expand Down

0 comments on commit 4ed67a1

Please sign in to comment.