@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) • 2.59 kB
JavaScript
import{O as t}from"./index-yNtOWHHe.esm.min.js";import{A as s}from"./abstractSoundSource-BEzGJJiV.esm.min.js";import{e}from"./audioEngine-vi2zlmHT.esm.min.js";class n extends s{constructor(s,e){super(s,e,3),this._newestInstance=null,this._privateInstances=new Set,this._state=1,this._instances=this._privateInstances,this.onEndedObservable=new t,this._onInstanceEnded=t=>{this._newestInstance===t&&(this._newestInstance=null),this._privateInstances.delete(t),0===this._instances.size&&(this._state=1,this.onEndedObservable.notifyObservers(this))}}get autoplay(){return this._options.autoplay}get currentTime(){const t=this._getNewestInstance();return t?t.currentTime:0}set currentTime(t){this.startOffset=t;const s=this._getNewestInstance();s&&(s.currentTime=t)}get loop(){return this._options.loop}set loop(t){this._options.loop=t}get maxInstances(){return this._options.maxInstances}set maxInstances(t){this._options.maxInstances=t}get startOffset(){return this._options.startOffset}set startOffset(t){this._options.startOffset=t}get state(){return this._state}dispose(){super.dispose(),this.stop(),this._newestInstance=null,this._privateInstances.clear(),this.onEndedObservable.clear()}pause(){const t=this._instances.values();for(let s=t.next();!s.done;s=t.next())s.value.pause();this._state=5}resume(){if(5!==this._state)return;const t=this._instances.values();for(let s=t.next();!s.done;s=t.next())s.value.resume();this._state=3}_beforePlay(t){5===this.state&&this._instances.size>0?this.resume():(t.onEndedObservable.addOnce(this._onInstanceEnded),this._privateInstances.add(t),this._newestInstance=t)}_afterPlay(t){this._state=t.state}_getNewestInstance(){if(0===this._instances.size)return null;if(!this._newestInstance){const t=this._instances.values();for(let s=t.next();!s.done;s=t.next())this._newestInstance=s.value}return this._newestInstance}_setState(t){this._state=t}_stopExcessInstances(){if(this.maxInstances<1/0){const t=Array.from(this._instances).filter((t=>3===t.state)).length-this.maxInstances,s=this._instances.values();for(let e=0;e<t;e++){s.next().value.stop()}}}}class a extends e{constructor(s){super(s.engine,2),this._state=1,this.onEndedObservable=new t,this.onErrorObservable=new t,this.onStateChangedObservable=new t,this._sound=s}get state(){return this._state}dispose(){super.dispose(),this.stop(),this.onEndedObservable.clear(),this.onStateChangedObservable.clear()}_setState(t){this._state!==t&&(this._state=t,this.onStateChangedObservable.notifyObservers(this))}}export{n as A,a as _};
//# sourceMappingURL=abstractSoundInstance-_QBiLbnZ.esm.min.js.map