var BABYLON;!(function(e){!(function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"})(e.EComponentType||(e.EComponentType={}));!(function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"})(e.EShaderType||(e.EShaderType={}));!(function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"})(e.EParameterType||(e.EParameterType={}));!(function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"})(e.ETextureWrapMode||(e.ETextureWrapMode={}));!(function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"})(e.ETextureFilterType||(e.ETextureFilterType={}));!(function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"})(e.ETextureFormat||(e.ETextureFormat={}));!(function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"})(e.ECullingType||(e.ECullingType={}));!(function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"})(e.EBlendingFunction||(e.EBlendingFunction={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var n;!(function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"})(n||(n={}));var r=(function(){function e(e){this._pos=0,this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}return e.prototype.getNextToken=function(){if(this.isEnd())return n.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=n.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=n.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||"_"===this.currentString);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken},e.prototype.peek=function(){return this._toParse[this._pos]},e.prototype.read=function(){return this._toParse[this._pos++]},e.prototype.forward=function(){this._pos++},e.prototype.isEnd=function(){return this._pos>=this._maxPos},e})(),t=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],i=["world","view","projection","worldView","worldViewProjection","mBones"],o=["translation","rotation","scale"],a=["position","rotationQuaternion","scaling"],s=function(e,n){for(var r in e){var t=e[r];n.buffers[r]=t,n.buffersCount++}},u=function(e,n){for(var r in e){var t=e[r];n.shaders[r]=t,n.shaderscount++}},l=function(e,n,r){for(var t in e){var i=e[t];r[n][t]=i}},c=function(e){if(e)for(var n=0;n0&&(y=T(s,o))&&u.indexOf(y)===-1&&u.push(y);new e.Bone(f.jointName,i,y,v).id=o}}else e.Tools.Warn("Joint named "+r.jointNames[l]+" does not exist")}var _=i.bones;i.bones=[];for(var l=0;l0&&n.importMeshesNames.indexOf(r.name)===-1)return null;if(r.skin){if(r.meshes){var a=n.skins[r.skin],s=N(n,r,r.meshes,t,r.babylonNode);s.skeleton=n.scene.getLastSkeletonByID(r.skin),null===s.skeleton&&(s.skeleton=y(n,a,0,a.babylonSkeleton,r.skin),a.babylonSkeleton||(a.babylonSkeleton=s.skeleton)),o=s}}else if(r.meshes){var s=N(n,r,r.mesh?[r.mesh]:r.meshes,t,r.babylonNode);o=s}else if(!r.light||r.babylonNode||n.importOnlyMeshes){if(r.camera&&!r.babylonNode&&!n.importOnlyMeshes){var u=n.cameras[r.camera];if(u)if("orthographic"===u.type){var l=(u[u.type],new e.FreeCamera(r.camera,e.Vector3.Zero(),n.scene));l.name=r.name,l.mode=e.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(n.scene.getEngine().getRenderingCanvas()),o=l}else if("perspective"===u.type){var c=u[u.type],f=new e.FreeCamera(r.camera,e.Vector3.Zero(),n.scene);f.name=r.name,f.attachControl(n.scene.getEngine().getRenderingCanvas()),c.aspectRatio||(c.aspectRatio=n.scene.getEngine().getRenderWidth()/n.scene.getEngine().getRenderHeight()),c.znear&&c.zfar&&(f.maxZ=c.zfar,f.minZ=c.znear),o=f}}}else{var d=n.lights[r.light];if(d)if("ambient"===d.type){var m=d[d.type],E=new e.HemisphericLight(r.light,e.Vector3.Zero(),n.scene);E.name=r.name,m.color&&(E.diffuse=e.Color3.FromArray(m.color)),o=E}else if("directional"===d.type){var T=d[d.type],A=new e.DirectionalLight(r.light,e.Vector3.Zero(),n.scene);A.name=r.name,T.color&&(A.diffuse=e.Color3.FromArray(T.color)),o=A}else if("point"===d.type){var p=d[d.type],h=new e.PointLight(r.light,e.Vector3.Zero(),n.scene);h.name=r.name,p.color&&(h.diffuse=e.Color3.FromArray(p.color)),o=h}else if("spot"===d.type){var O=d[d.type],v=new e.SpotLight(r.light,e.Vector3.Zero(),e.Vector3.Zero(),0,0,n.scene);v.name=r.name,O.color&&(v.diffuse=e.Color3.FromArray(O.color)),O.fallOfAngle&&(v.angle=O.fallOfAngle),O.fallOffExponent&&(v.exponent=O.fallOffExponent),o=v}}if(!r.jointName){if(r.babylonNode)return r.babylonNode;if(null===o){var _=new e.Mesh(r.name,n.scene);r.babylonNode=_,o=_}}if(null!==o){if(r.matrix&&o instanceof e.Mesh)g(o,r);else{var F=r.translation||[0,0,0],S=r.rotation||[0,0,0,1],M=r.scale||[1,1,1];L(o,e.Vector3.FromArray(F),e.Quaternion.FromArray(S),e.Vector3.FromArray(M))}o.updateCache(!0),r.babylonNode=o}return o},v=function(e,n,r,t){var i=e.nodes[n],o=null;if(t=!(e.importOnlyMeshes&&!t)||(e.importMeshesNames.indexOf(i.name)!==-1||0===e.importMeshesNames.length),!i.jointName&&t&&null!==(o=O(e,i,n))&&(o.id=n,o.parent=r),i.children)for(var a=0;aa.byteLength)throw new Error("Buffer access is out of range");var s=a.buffer;switch(t+=a.byteOffset,o){case e.EComponentType.BYTE:return new Int8Array(s,t,i);case e.EComponentType.UNSIGNED_BYTE:return new Uint8Array(s,t,i);case e.EComponentType.SHORT:return new Int16Array(s,t,i);case e.EComponentType.UNSIGNED_SHORT:return new Uint16Array(s,t,i);default:return new Float32Array(s,t,i)}},n.GetBufferFromAccessor=function(e,r){var t=e.bufferViews[r.bufferView],i=r.count*n.GetByteStrideFromType(r);return n.GetBufferFromBufferView(e,t,r.byteOffset,i,r.componentType)},n.DecodeBufferToText=function(e){for(var n="",r=e.byteLength,t=0;t