UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 915 B
import{math as t}from"../../../core/math/math.js";import{AnimBlendTree as e}from"./anim-blend-tree.js";class i extends e{constructor(t,e,i,n,s,h,r,a,o){h.sort(((t,e)=>t.point-e.point)),super(t,e,i,n,s,h,r,a,o)}calculateWeights(){if(this.updateParameterValues())return;let e=0;this._children[0].weight=0;for(let i=0;i<this._children.length;i++){const n=this._children[i];if(i!==this._children.length-1){const e=this._children[i+1];if(n.point===e.point)n.weight=.5,e.weight=.5;else if(t.between(this._parameterValues[0],n.point,e.point,!0)){const t=Math.abs(n.point-e.point),i=(t-Math.abs(n.point-this._parameterValues[0]))/t;n.weight=i,e.weight=1-i}else e.weight=0}this._syncAnimations&&(e+=n.animTrack.duration/n.absoluteSpeed*n.weight)}if(this._syncAnimations)for(let t=0;t<this._children.length;t++){const i=this._children[t];i.weightedSpeed=i.animTrack.duration/i.absoluteSpeed/e}}}export{i as AnimBlendTree1D};