@babylonjs/viewer
Version:
The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.
3 lines (2 loc) • 4.1 kB
JavaScript
import{b as t}from"./KHR_interactivity-D4lwBSW9.esm.min.js";import{d as n,a as i,R as e}from"./declarationMapper-D_filC93.esm.min.js";import{A as o}from"./animationGroup.pure-Bb9o5BkH.esm.min.js";import{u as r}from"./index-BPURObVq.esm.min.js";import"./animationGroup-ChS5fjKZ.esm.min.js";import"./objectModelMapping-ClgDmo5Q.esm.min.js";import"./spotLight.pure-5s2DDDIt.esm.min.js";import"./bone.pure-BcPT5kCP.esm.min.js";class a extends t{constructor(t){super(t,["animationLoop","animationEnd","animationGroupLoop"]),this.config=t,this.speed=this.registerDataInput("speed",n),this.loop=this.registerDataInput("loop",i),this.from=this.registerDataInput("from",n,0),this.to=this.registerDataInput("to",n),this.currentFrame=this.registerDataOutput("currentFrame",n),this.currentTime=this.registerDataOutput("currentTime",n),this.currentAnimationGroup=this.registerDataOutput("currentAnimationGroup",e),this.animationGroup=this.registerDataInput("animationGroup",e,t?.animationGroup),this.animation=this.registerDataInput("animation",e),this.object=this.registerDataInput("object",e)}_preparePendingTasks(t){const n=this.animationGroup.getValue(t),i=this.animation.getValue(t);if(!n&&!i)return this._reportError(t,"No animation or animation group provided");{const e=this.currentAnimationGroup.getValue(t);e&&e!==n&&e.dispose();let r=n;if(i&&!r){const n=this.object.getValue(t);if(!n)return this._reportError(t,"No target object provided");const e=Array.isArray(i)?i:[i],a=e[0].name;r=new o("flowGraphAnimationGroup-"+a+"-"+n.name,t.configuration.scene);let s=!1;const u=t._getGlobalContextVariable("interpolationAnimations",[]);for(const t of e)r.addTargetedAnimation(t,n),-1!==u.indexOf(t.uniqueId)&&(s=!0);s&&this._checkInterpolationDuplications(t,e,n)}const a=this.speed.getValue(t)||1,s=this.from.getValue(t)??0,u=this.to.getValue(t)||r.to,p=!isFinite(u)||this.loop.getValue(t);this.currentAnimationGroup.setValue(r,t);const m=t._getGlobalContextVariable("currentlyRunningAnimationGroups",[]);-1!==m.indexOf(r.uniqueId)&&r.stop();try{r.start(p,a,s,u),r.onAnimationGroupEndObservable.add(()=>this._onAnimationGroupEnd(t)),r.onAnimationEndObservable.add(()=>this._eventsSignalOutputs.animationEnd._activateSignal(t)),r.onAnimationLoopObservable.add(()=>this._eventsSignalOutputs.animationLoop._activateSignal(t)),r.onAnimationGroupLoopObservable.add(()=>this._eventsSignalOutputs.animationGroupLoop._activateSignal(t)),m.push(r.uniqueId),t._setGlobalContextVariable("currentlyRunningAnimationGroups",m)}catch(n){this._reportError(t,n)}}}_reportError(t,n){super._reportError(t,n),this.currentFrame.setValue(-1,t),this.currentTime.setValue(-1,t)}_executeOnTick(t){const n=this.currentAnimationGroup.getValue(t);n&&(this.currentFrame.setValue(n.getCurrentFrame(),t),this.currentTime.setValue(n.animatables[0]?.elapsedTime??0,t))}_execute(t){this._startPendingTasks(t)}_onAnimationGroupEnd(t){this._removeFromCurrentlyRunning(t,this.currentAnimationGroup.getValue(t)),this._resetAfterCanceled(t),this.done._activateSignal(t)}_checkInterpolationDuplications(t,n,i){const e=t._getGlobalContextVariable("currentlyRunningAnimationGroups",[]);for(const o of e){const e=t.assetsContext.animationGroups.find(t=>t.uniqueId===o);if(e)for(const o of e.targetedAnimations)for(const r of n)o.animation.targetProperty===r.targetProperty&&o.target===i&&this._stopAnimationGroup(t,e)}}_stopAnimationGroup(t,n){n.stop(!0),n.name.startsWith("flowGraphAnimationGroup-")&&n.dispose(),this._removeFromCurrentlyRunning(t,n)}_removeFromCurrentlyRunning(t,n){const i=t._getGlobalContextVariable("currentlyRunningAnimationGroups",[]),e=i.indexOf(n.uniqueId);-1!==e&&(i.splice(e,1),t._setGlobalContextVariable("currentlyRunningAnimationGroups",i))}_cancelPendingTasks(t){const n=this.currentAnimationGroup.getValue(t);n&&this._stopAnimationGroup(t,n)}getClassName(){return"FlowGraphPlayAnimationBlock"}}let s=!1;function u(){s||(s=!0,r("FlowGraphPlayAnimationBlock",a))}u();export{a as FlowGraphPlayAnimationBlock,u as RegisterFlowGraphPlayAnimationBlock};
//# sourceMappingURL=flowGraphPlayAnimationBlock-Cn4f9maH.esm.min.js.map