!(function(e,t){var n=[],r=e.BABYLON||this.BABYLON;"object"==typeof exports&&"object"==typeof module?(r=r||require("babylonjs"),module.exports=t(r)):"function"==typeof define&&define.amd?(n.push("babylonjs"),define("babylonjs-loaders",n,t)):"object"==typeof exports?(r=r||require("babylonjs"),exports["babylonjs-loaders"]=t(r)):e.BABYLON=t(r)})(this,(function(e){e=e||this.BABYLON;this&&this.__decorate;var r,y,t,n,o,a,i,s,l,u,c,d,f,W,h,p,m,_,A,g,v,b,T,E,L,x,O,M,w,S,N,F,P,C,I,R,D,B,G,V,U,k,j,H,K,Z,Q,Y,J,q,X,z,$,ee,te,ne,re,oe,ae,ie,se,le,ue,ce,de,fe,he,pe,me,ye,_e,Ae,ge,ve,be,Te,Ee,Le,xe,Oe,Me,we,Se,Ne,Fe=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});return y=e||(e={}),t=(function(){function e(){this.solidPattern=/solid (\S*)([\S\s]*)endsolid[ ]*(\S*)/g,this.facetsPattern=/facet([\s\S]*?)endfacet/g,this.normalPattern=/normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g,this.vertexPattern=/vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g,this.name="stl",this.extensions={".stl":{isBinary:!0}}}return e.prototype.importMesh=function(e,t,n,r,o,a,i){var s;if("string"!=typeof n){if(this.isBinary(n)){var l=new y.Mesh("stlmesh",t);return this.parseBinary(l,n),o&&o.push(l),!0}for(var u=new Uint8Array(n),c="",d=0;dt.major?1:e.majort.minor?1:e.minor=this._maxPos},e})(),V=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],U=["world","view","projection","worldView","worldViewProjection","mBones"],w=["translation","rotation","scale"],S=["position","rotationQuaternion","scaling"],o=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},N=function(e){if(e)for(var t=0;ta.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(n+=a.byteOffset,o){case p.EComponentType.BYTE:return new Int8Array(i,n,r);case p.EComponentType.UNSIGNED_BYTE:return new Uint8Array(i,n,r);case p.EComponentType.SHORT:return new Int16Array(i,n,r);case p.EComponentType.UNSIGNED_SHORT:return new Uint16Array(i,n,r);default:return new Float32Array(i,n,r)}},o.GetBufferFromAccessor=function(e,t){var n=e.bufferViews[t.bufferView],r=t.count*o.GetByteStrideFromType(t);return o.GetBufferFromBufferView(e,n,t.byteOffset,r,t.componentType)},o.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r "+O.GLTFLoaderState[O.GLTFLoaderState.READY],t=O.GLTFLoaderState[O.GLTFLoaderState.LOADING]+" => "+O.GLTFLoaderState[O.GLTFLoaderState.COMPLETE];s._parent._startPerformanceCounter(e),s._parent._startPerformanceCounter(t),s._setState(O.GLTFLoaderState.LOADING),s._extensionsOnLoading();var n=new Array;if(a)n.push(s.loadSceneAsync("#/nodes",{nodes:a,index:-1}));else{var r=v.Get("#/scene",s.gltf.scenes,s.gltf.scene||0);n.push(s.loadSceneAsync("#/scenes/"+r.index,r))}s._parent.compileMaterials&&n.push(s._compileMaterialsAsync()),s._parent.compileShadowGenerators&&n.push(s._compileShadowGeneratorsAsync());var o=Promise.all(n).then((function(){return s._setState(O.GLTFLoaderState.READY),s._extensionsOnReady(),s._startAnimations(),i()}));return o.then((function(){s._parent._endPerformanceCounter(e),O.Tools.SetImmediate((function(){s._disposed||Promise.all(s._completePromises).then((function(){s._parent._endPerformanceCounter(t),s._setState(O.GLTFLoaderState.COMPLETE),s._parent.onCompleteObservable.notifyObservers(void 0),s._parent.onCompleteObservable.clear(),s.dispose()}),(function(e){s._parent.onErrorObservable.notifyObservers(e),s._parent.onErrorObservable.clear(),s.dispose()}))}))})),o}),(function(e){throw s._disposed||(s._parent.onErrorObservable.notifyObservers(e),s._parent.onErrorObservable.clear(),s.dispose()),e}))},p.prototype._loadData=function(e){if(this.gltf=e.json,this._setupData(),e.bin){var t=this.gltf.buffers;if(t&&t[0]&&!t[0].uri){var n=t[0];(n.byteLengthe.bin.byteLength)&&O.Tools.Warn("Binary buffer length ("+n.byteLength+") from JSON does not match chunk length ("+e.bin.byteLength+")"),n._data=Promise.resolve(e.bin)}else O.Tools.Warn("Unexpected BIN chunk")}},p.prototype._setupData=function(){if(v.Assign(this.gltf.accessors),v.Assign(this.gltf.animations),v.Assign(this.gltf.buffers),v.Assign(this.gltf.bufferViews),v.Assign(this.gltf.cameras),v.Assign(this.gltf.images),v.Assign(this.gltf.materials),v.Assign(this.gltf.meshes),v.Assign(this.gltf.nodes),v.Assign(this.gltf.samplers),v.Assign(this.gltf.scenes),v.Assign(this.gltf.skins),v.Assign(this.gltf.textures),this.gltf.nodes){for(var e={},t=0,n=this.gltf.nodes;t