babylon.glTF1FileLoader.min.js 42 KB

12
  1. var BABYLON;!(function(e){var r;!(function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"})(r=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}));var n;!(function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"})(n=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={}));var t=(function(){function t(){this.onParsedObservable=new e.Observable,this.coordinateSystemMode=r.AUTO,this.animationStartMode=n.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.onMeshLoadedObservable=new e.Observable,this.onTextureLoadedObservable=new e.Observable,this.onMaterialLoadedObservable=new e.Observable,this.onCompleteObservable=new e.Observable,this.onDisposeObservable=new e.Observable,this._loader=null,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}}}return Object.defineProperty(t.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null),this.onParsedObservable.clear(),this.onMeshLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.importMeshAsync=function(r,n,t,o,i,a,s){try{var u=this._parse(t);this._loader=this._getLoader(u),this._loader.importMeshAsync(r,n,u,o,i,a,s)}catch(r){s?s(r.message,r):e.Tools.Error(r.message)}},t.prototype.loadAsync=function(r,n,t,o,i,a){try{var s=this._parse(n);this._loader=this._getLoader(s),this._loader.loadAsync(r,s,t,o,i,a)}catch(r){a?a(r.message,r):e.Tools.Error(r.message)}},t.prototype.loadAssetsAsync=function(r,n,t,o,i,a){try{var s=this._parse(n);this._loader=this._getLoader(s),this._loader.importMeshAsync(null,r,s,t,(function(n,t,i){var a=new e.AssetContainer(r);Array.prototype.push.apply(a.meshes,n),Array.prototype.push.apply(a.particleSystems,t),Array.prototype.push.apply(a.skeletons,i),a.removeAllFromScene(),o(a)}),i,a)}catch(r){a?a(r.message,r):e.Tools.Error(r.message)}},t.prototype.canDirectLoad=function(e){return-1!==e.indexOf("scene")&&-1!==e.indexOf("node")},t.prototype.createPlugin=function(){return new t},t.prototype._parse=function(e){var r;return r=e instanceof ArrayBuffer?t._parseBinary(e):{json:JSON.parse(e),bin:null},this.onParsedObservable.notifyObservers(r),r},t.prototype._getLoader=function(e){var r=this,n={major:2,minor:0},o=e.json.asset||{},i=t._parseVersion(o.version);if(!i)throw new Error("Invalid version: "+o.version);if(void 0!==o.minVersion){var a=t._parseVersion(o.minVersion);if(!a)throw new Error("Invalid minimum version: "+o.minVersion);if(t._compareVersion(a,n)>0)throw new Error("Incompatible minimum version: "+o.minVersion)}var s={1:t.CreateGLTFLoaderV1,2:t.CreateGLTFLoaderV2},u=s[i.major];if(!u)throw new Error("Unsupported version: "+o.version);var l=u();return l.coordinateSystemMode=this.coordinateSystemMode,l.animationStartMode=this.animationStartMode,l.compileMaterials=this.compileMaterials,l.useClipPlane=this.useClipPlane,l.compileShadowGenerators=this.compileShadowGenerators,l.onMeshLoadedObservable.add((function(e){return r.onMeshLoadedObservable.notifyObservers(e)})),l.onTextureLoadedObservable.add((function(e){return r.onTextureLoadedObservable.notifyObservers(e)})),l.onMaterialLoadedObservable.add((function(e){return r.onMaterialLoadedObservable.notifyObservers(e)})),l.onCompleteObservable.add((function(){return r.onCompleteObservable.notifyObservers(r)})),l},t._parseBinary=function(e){var r={Magic:1179937895},n=new o(e),i=n.readUint32();if(i!==r.Magic)throw new Error("Unexpected magic: "+i);var a=n.readUint32();switch(a){case 1:return t._parseV1(n);case 2:return t._parseV2(n)}throw new Error("Unsupported version: "+a)},t._parseV1=function(e){var r={JSON:0},n=e.readUint32();if(n!=e.getLength())throw new Error("Length in header does not match actual data length: "+n+" != "+e.getLength());var o,i=e.readUint32(),a=e.readUint32();switch(a){case r.JSON:o=JSON.parse(t._decodeBufferToText(e.readUint8Array(i)));break;default:throw new Error("Unexpected content format: "+a)}var s=e.getLength()-e.getPosition();return{json:o,bin:e.readUint8Array(s)}},t._parseV2=function(e){var r={JSON:1313821514,BIN:5130562},n=e.readUint32();if(n!==e.getLength())throw new Error("Length in header does not match actual data length: "+n+" != "+e.getLength());var o=e.readUint32();if(e.readUint32()!==r.JSON)throw new Error("First chunk format is not JSON");for(var i=JSON.parse(t._decodeBufferToText(e.readUint8Array(o))),a=null;e.getPosition()<e.getLength();){var s=e.readUint32();switch(e.readUint32()){case r.JSON:throw new Error("Unexpected JSON chunk");case r.BIN:a=e.readUint8Array(s);break;default:e.skipBytes(s)}}return{json:i,bin:a}},t._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var r=(e+"").match(/^(\d+)\.(\d+)/);return r?{major:parseInt(r[1]),minor:parseInt(r[2])}:null},t._compareVersion=function(e,r){return e.major>r.major?1:e.major<r.major?-1:e.minor>r.minor?1:e.minor<r.minor?-1:0},t._decodeBufferToText=function(e){for(var r="",n=e.byteLength,t=0;t<n;t++)r+=String.fromCharCode(e[t]);return r},t.IncrementalLoading=!0,t.HomogeneousCoordinates=!1,t})();e.GLTFFileLoader=t;var o=(function(){function e(e){this._arrayBuffer=e,this._dataView=new DataView(e),this._byteOffset=0}return e.prototype.getPosition=function(){return this._byteOffset},e.prototype.getLength=function(){return this._arrayBuffer.byteLength},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._byteOffset,!0);return this._byteOffset+=4,e},e.prototype.readUint8Array=function(e){var r=new Uint8Array(this._arrayBuffer,this._byteOffset,e);return this._byteOffset+=e,r},e.prototype.skipBytes=function(e){this._byteOffset+=e},e})();e.SceneLoader&&e.SceneLoader.RegisterPlugin(new t)})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(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={}))})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(r){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 t=(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})(),o=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],i=["world","view","projection","worldView","worldViewProjection","mBones"],a=["translation","rotation","scale"],s=["position","rotationQuaternion","scaling"],u=function(e,r){for(var n in e){var t=e[n];r.buffers[n]=t,r.buffersCount++}},l=function(e,r){for(var n in e){var t=e[n];r.shaders[n]=t,r.shaderscount++}},c=function(e,r,n){for(var t in e){var o=e[t];n[r][t]=o}},f=function(e){if(e)for(var r=0;r<e.length/2;r++)e[2*r+1]=1-e[2*r+1]},d=function(e){if("NORMAL"===e.semantic)return"normal";if("POSITION"===e.semantic)return"position";if("JOINT"===e.semantic)return"matricesIndices";if("WEIGHT"===e.semantic)return"matricesWeights";if("COLOR"===e.semantic)return"color";if(e.semantic&&-1!==e.semantic.indexOf("TEXCOORD_")){var r=Number(e.semantic.split("_")[1]);return"uv"+(0===r?"":r+1)}return null},m=function(n){for(var t in n.animations){var o=n.animations[t];if(o.channels&&o.samplers)for(var i=null,u=0;u<o.channels.length;u++){var l=o.channels[u],c=o.samplers[l.sampler];if(c){var f=null,d=null;o.parameters?(f=o.parameters[c.input],d=o.parameters[c.output]):(f=c.input,d=c.output);var m=r.GLTFUtils.GetBufferFromAccessor(n,n.accessors[f]),h=r.GLTFUtils.GetBufferFromAccessor(n,n.accessors[d]),p=l.target.id,T=n.scene.getNodeByID(p);if(null===T&&(T=n.scene.getNodeByName(p)),null!==T){var E=T instanceof e.Bone,A=l.target.path,v=a.indexOf(A);-1!==v&&(A=s[v]);var L=e.Animation.ANIMATIONTYPE_MATRIX;E||("rotationQuaternion"===A?(L=e.Animation.ANIMATIONTYPE_QUATERNION,T.rotationQuaternion=new e.Quaternion):L=e.Animation.ANIMATIONTYPE_VECTOR3);var O=null,y=[],_=0,b=!1;E&&i&&i.getKeys().length===m.length&&(O=i,b=!0),b||(O=new e.Animation(t,E?"_matrix":A,1,L,e.Animation.ANIMATIONLOOPMODE_CYCLE));for(var g=0;g<m.length;g++){var N=null;if("rotationQuaternion"===A?(N=e.Quaternion.FromArray([h[_],h[_+1],h[_+2],h[_+3]]),_+=4):(N=e.Vector3.FromArray([h[_],h[_+1],h[_+2]]),_+=3),E){var M=T,S=e.Vector3.Zero(),F=new e.Quaternion,x=e.Vector3.Zero(),R=M.getBaseMatrix();b&&i&&(R=i.getKeys()[g].value),R.decompose(x,F,S),"position"===A?S=N:"rotationQuaternion"===A?F=N:x=N,N=e.Matrix.Compose(x,F,S)}b?i&&(i.getKeys()[g].value=N):y.push({frame:m[g],value:N})}!b&&O&&(O.setKeys(y),T.animations.push(O)),i=O,n.scene.stopAnimation(T),n.scene.beginAnimation(T,0,m[m.length-1],!0,1)}else e.Tools.Warn("Creating animation named "+t+". But cannot find node named "+p+" to attach to")}}}},h=function(r){var n=null;if(r.translation||r.rotation||r.scale){var t=e.Vector3.FromArray(r.scale||[1,1,1]),o=e.Quaternion.FromArray(r.rotation||[0,0,0,1]),i=e.Vector3.FromArray(r.translation||[0,0,0]);n=e.Matrix.Compose(t,o,i)}else n=e.Matrix.FromArray(r.matrix);return n},p=function(r,n,t,o){for(var i=0;i<o.bones.length;i++)if(o.bones[i].name===t)return o.bones[i];var a=r.nodes;for(var s in a){var u=a[s];if(u.jointName)for(var l=u.children,i=0;i<l.length;i++){var c=r.nodes[l[i]];if(c.jointName&&c.jointName===t){var f=h(u),d=new e.Bone(u.name||"",o,p(r,n,u.jointName,o),f);return d.id=s,d}}}return null},T=function(e,r){for(var n=0;n<e.length;n++)for(var t=e[n],o=0;o<t.node.children.length;o++){var i=t.node.children[o];if(i===r)return t.bone}return null},E=function(e,r){var n=e.nodes,t=n[r];if(t)return{node:t,id:r};for(var o in n)if(t=n[o],t.jointName===r)return{node:t,id:o};return null},A=function(e,r){for(var n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===r)return!0;return!1},v=function(r,n,t,o){for(var i in r.nodes){var a=r.nodes[i],s=i;if(a.jointName&&!A(t,a.jointName)){var u=h(a),l=new e.Bone(a.name||"",n,null,u);l.id=s,o.push({bone:l,node:a,id:s})}}for(var c=0;c<o.length;c++)for(var f=o[c],d=f.node.children,m=0;m<d.length;m++){for(var p=null,T=0;T<o.length;T++)if(o[T].id===d[m]){p=o[T];break}p&&(p.bone._parent=f.bone,f.bone.children.push(p.bone))}},L=function(r,n,t,o,i){if(o||(o=new e.Skeleton(n.name||"","",r.scene)),!n.babylonSkeleton)return o;var a=[],s=[];v(r,o,n,a),o.bones=[];for(var u=0;u<n.jointNames.length;u++){var l=E(r,n.jointNames[u]);if(l){var c=l.node;if(c){var i=l.id,f=r.scene.getBoneByID(i);if(f)o.bones.push(f);else{for(var d=!1,m=null,A=0;A<u;A++){var L=E(r,n.jointNames[A]);if(L){var O=L.node;if(O){var y=O.children;if(y){d=!1;for(var _=0;_<y.length;_++)if(y[_]===i){m=p(r,n,n.jointNames[A],o),d=!0;break}if(d)break}}else e.Tools.Warn("Joint named "+n.jointNames[A]+" does not exist when looking for parent")}}var b=h(c);!m&&a.length>0&&(m=T(a,i))&&-1===s.indexOf(m)&&s.push(m);new e.Bone(c.jointName||"",o,m,b).id=i}}else e.Tools.Warn("Joint named "+n.jointNames[u]+" does not exist")}}var g=o.bones;o.bones=[];for(var u=0;u<n.jointNames.length;u++){var l=E(r,n.jointNames[u]);if(l)for(var A=0;A<g.length;A++)if(g[A].id===l.id){o.bones.push(g[A]);break}}o.prepare();for(var u=0;u<s.length;u++)o.bones.push(s[u]);return o},O=function(n,t,o,i,a){if(a||(a=new e.Mesh(t.name||"",n.scene),a.id=i),!t.babylonNode)return a;for(var s=[],u=new e.VertexData,l=new e.Geometry(i,n.scene,u,!1,a),c=new Array,d=new Array,m=new Array,h=new Array,p=0;p<o.length;p++){var T=o[p],E=n.meshes[T];if(E)for(var A=0;A<E.primitives.length;A++){var v=new e.VertexData,L=E.primitives[A];L.mode;var O=L.attributes,y=null,_=null;for(var b in O)if(y=n.accessors[O[b]],_=r.GLTFUtils.GetBufferFromAccessor(n,y),"NORMAL"===b)v.normals=new Float32Array(_.length),v.normals.set(_);else if("POSITION"===b){if(e.GLTFFileLoader.HomogeneousCoordinates){v.positions=new Float32Array(_.length-_.length/4);for(var g=0;g<_.length;g+=4)v.positions[g]=_[g],v.positions[g+1]=_[g+1],v.positions[g+2]=_[g+2]}else v.positions=new Float32Array(_.length),v.positions.set(_);d.push(v.positions.length)}else if(-1!==b.indexOf("TEXCOORD_")){var N=Number(b.split("_")[1]),M=e.VertexBuffer.UVKind+(0===N?"":N+1),S=new Float32Array(_.length);S.set(_),f(S),v.set(S,M)}else"JOINT"===b?(v.matricesIndices=new Float32Array(_.length),v.matricesIndices.set(_)):"WEIGHT"===b?(v.matricesWeights=new Float32Array(_.length),v.matricesWeights.set(_)):"COLOR"===b&&(v.colors=new Float32Array(_.length),v.colors.set(_));if(y=n.accessors[L.indices])_=r.GLTFUtils.GetBufferFromAccessor(n,y),v.indices=new Int32Array(_.length),v.indices.set(_),h.push(v.indices.length);else{for(var F=[],g=0;g<v.positions.length/3;g++)F.push(g);v.indices=new Int32Array(F),h.push(v.indices.length)}u.merge(v);var x=n.scene.getMaterialByID(L.material);s.push(null===x?r.GLTFUtils.GetDefaultMaterial(n.scene):x),c.push(0===c.length?0:c[c.length-1]+d[d.length-2]),m.push(0===m.length?0:m[m.length-1]+h[h.length-2])}}var R;s.length>1?(R=new e.MultiMaterial("multimat"+i,n.scene),R.subMaterials=s):R=new e.StandardMaterial("multimat"+i,n.scene),1===s.length&&(R=s[0]),a.material||(a.material=R),l.setAllVerticesData(u,!1),a.computeWorldMatrix(!0),a.subMeshes=[];for(var B=0,p=0;p<o.length;p++){var T=o[p],E=n.meshes[T];if(E)for(var A=0;A<E.primitives.length;A++)E.primitives[A].mode,e.SubMesh.AddToMesh(B,c[B],d[B],m[B],h[B],a,a,!0),B++}return a},y=function(e,r,n,t){e.position&&(e.position=r),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=t)},_=function(r,n,t){if(n.matrix){var o=new e.Vector3(0,0,0),i=new e.Quaternion,a=new e.Vector3(0,0,0);e.Matrix.FromArray(n.matrix).decompose(a,i,o),y(r,o,i,a)}else n.translation&&n.rotation&&n.scale&&y(r,e.Vector3.FromArray(n.translation),e.Quaternion.FromArray(n.rotation),e.Vector3.FromArray(n.scale));r.computeWorldMatrix(!0)},b=function(r,n,t,o){var i=null;if(r.importOnlyMeshes&&(n.skin||n.meshes)&&r.importMeshesNames&&r.importMeshesNames.length>0&&-1===r.importMeshesNames.indexOf(n.name||""))return null;if(n.skin){if(n.meshes){var a=r.skins[n.skin],s=O(r,n,n.meshes,t,n.babylonNode);s.skeleton=r.scene.getLastSkeletonByID(n.skin),null===s.skeleton&&(s.skeleton=L(r,a,0,a.babylonSkeleton,n.skin),a.babylonSkeleton||(a.babylonSkeleton=s.skeleton)),i=s}}else if(n.meshes){var s=O(r,n,n.mesh?[n.mesh]:n.meshes,t,n.babylonNode);i=s}else if(!n.light||n.babylonNode||r.importOnlyMeshes){if(n.camera&&!n.babylonNode&&!r.importOnlyMeshes){var u=r.cameras[n.camera];if(u)if("orthographic"===u.type){var l=new e.FreeCamera(n.camera,e.Vector3.Zero(),r.scene);l.name=n.name||"",l.mode=e.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(r.scene.getEngine().getRenderingCanvas()),i=l}else if("perspective"===u.type){var c=u[u.type],f=new e.FreeCamera(n.camera,e.Vector3.Zero(),r.scene);f.name=n.name||"",f.attachControl(r.scene.getEngine().getRenderingCanvas()),c.aspectRatio||(c.aspectRatio=r.scene.getEngine().getRenderWidth()/r.scene.getEngine().getRenderHeight()),c.znear&&c.zfar&&(f.maxZ=c.zfar,f.minZ=c.znear),i=f}}}else{var d=r.lights[n.light];if(d)if("ambient"===d.type){var m=d[d.type],h=new e.HemisphericLight(n.light,e.Vector3.Zero(),r.scene);h.name=n.name||"",m.color&&(h.diffuse=e.Color3.FromArray(m.color)),i=h}else if("directional"===d.type){var p=d[d.type],T=new e.DirectionalLight(n.light,e.Vector3.Zero(),r.scene);T.name=n.name||"",p.color&&(T.diffuse=e.Color3.FromArray(p.color)),i=T}else if("point"===d.type){var E=d[d.type],A=new e.PointLight(n.light,e.Vector3.Zero(),r.scene);A.name=n.name||"",E.color&&(A.diffuse=e.Color3.FromArray(E.color)),i=A}else if("spot"===d.type){var v=d[d.type],b=new e.SpotLight(n.light,e.Vector3.Zero(),e.Vector3.Zero(),0,0,r.scene);b.name=n.name||"",v.color&&(b.diffuse=e.Color3.FromArray(v.color)),v.fallOfAngle&&(b.angle=v.fallOfAngle),v.fallOffExponent&&(b.exponent=v.fallOffExponent),i=b}}if(!n.jointName){if(n.babylonNode)return n.babylonNode;if(null===i){var g=new e.Mesh(n.name||"",r.scene);n.babylonNode=g,i=g}}if(null!==i){if(n.matrix&&i instanceof e.Mesh)_(i,n);else{var N=n.translation||[0,0,0],M=n.rotation||[0,0,0,1],S=n.scale||[1,1,1];y(i,e.Vector3.FromArray(N),e.Quaternion.FromArray(M),e.Vector3.FromArray(S))}i.updateCache(!0),n.babylonNode=i}return i},g=function(e,r,n,t){void 0===t&&(t=!1);var o=e.nodes[r],i=null;if(t=!(e.importOnlyMeshes&&!t&&e.importMeshesNames)||(-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length),!o.jointName&&t&&null!==(i=b(e,o,r))&&(i.id=r,i.parent=n),o.children)for(var a=0;a<o.children.length;a++)g(e,o.children[a],i,t)},N=function(e){var r=e.currentScene;if(r)for(var n=0;n<r.nodes.length;n++)g(e,r.nodes[n],null);else for(var t in e.scenes){r=e.scenes[t];for(var n=0;n<r.nodes.length;n++)g(e,r.nodes[n],null)}m(e);for(var n=0;n<e.scene.skeletons.length;n++){var o=e.scene.skeletons[n];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},M=function(e,n,t,o,i,a,s){var u=a.values||i.parameters;for(var l in t){var c=t[l],f=c.type;if(f===r.EParameterType.FLOAT_MAT2||f===r.EParameterType.FLOAT_MAT3||f===r.EParameterType.FLOAT_MAT4)if(!c.semantic||c.source||c.node){if(c.semantic&&(c.source||c.node)){var d=n.scene.getNodeByName(c.source||c.node||"");if(null===d&&(d=n.scene.getNodeByID(c.source||c.node||"")),null===d)continue;r.GLTFUtils.SetMatrix(n.scene,d,c,l,o.getEffect())}}else r.GLTFUtils.SetMatrix(n.scene,e,c,l,o.getEffect());else{var m=u[i.uniforms[l]];if(!m)continue;if(f===r.EParameterType.SAMPLER_2D){var h=n.textures[a.values?m:c.value].babylonTexture;if(null===h||void 0===h)continue;o.getEffect().setTexture(l,h)}else r.GLTFUtils.SetUniform(o.getEffect(),l,m,f)}}s(o)},S=function(e,n,t,o,i){var a=o.values||t.parameters,s=t.uniforms;for(var u in i){var l=i[u],c=l.type,f=a[s[u]];if(void 0===f&&(f=l.value),f){var d=function(e){return function(r){l.value&&e&&(n.setTexture(e,r),delete i[e])}};c===r.EParameterType.SAMPLER_2D?r.GLTFLoaderExtension.LoadTextureAsync(e,o.values?f:l.value,d(u),(function(){return d(null)})):l.value&&r.GLTFUtils.SetUniform(n,u,o.values?f:l.value,c)&&delete i[u]}}},F=function(e,r,n){return function(t,o){r.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}},x=function(e,r,n,t,o,i){return function(a){S(e,r,n,t,o),r.onBind=function(a){M(a,e,o,r,n,t,i)}}},R=function(e,r,n){for(var t in r.uniforms){var a=r.uniforms[t],s=r.parameters[a];if(e.currentIdentifier===t&&s.semantic&&!s.source&&!s.node){var u=o.indexOf(s.semantic);if(-1!==u)return delete n[t],i[u]}}return e.currentIdentifier},B=function(e){for(var n in e.materials)r.GLTFLoaderExtension.LoadMaterialAsync(e,n,(function(e){}),(function(){}))},C=(function(){function a(){}return a.CreateRuntime=function(e,r,n){var t={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:r,rootUrl:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[]};return e.extensions&&c(e.extensions,"extensions",t),e.extensionsUsed&&c(e.extensionsUsed,"extensionsUsed",t),e.buffers&&u(e.buffers,t),e.bufferViews&&c(e.bufferViews,"bufferViews",t),e.accessors&&c(e.accessors,"accessors",t),e.meshes&&c(e.meshes,"meshes",t),e.lights&&c(e.lights,"lights",t),e.cameras&&c(e.cameras,"cameras",t),e.nodes&&c(e.nodes,"nodes",t),e.images&&c(e.images,"images",t),e.textures&&c(e.textures,"textures",t),e.shaders&&l(e.shaders,t),e.programs&&c(e.programs,"programs",t),e.samplers&&c(e.samplers,"samplers",t),e.techniques&&c(e.techniques,"techniques",t),e.materials&&c(e.materials,"materials",t),e.animations&&c(e.animations,"animations",t),e.skins&&c(e.skins,"skins",t),e.scenes&&(t.scenes=e.scenes),e.scene&&e.scenes&&(t.currentScene=e.scenes[e.scene]),t},a.LoadBufferAsync=function(n,t,o,i,a){var s=n.buffers[t];r.GLTFUtils.IsBase64(s.uri)?setTimeout((function(){return o(new Uint8Array(r.GLTFUtils.DecodeBase64(s.uri)))})):e.Tools.LoadFile(n.rootUrl+s.uri,(function(e){return o(new Uint8Array(e))}),a,void 0,!0,(function(e){e&&i(e.status+" "+e.statusText)}))},a.LoadTextureBufferAsync=function(n,t,o,i){var a=n.textures[t];if(!a||!a.source)return void i("");if(a.babylonTexture)return void o(null);var s=n.images[a.source];r.GLTFUtils.IsBase64(s.uri)?setTimeout((function(){return o(new Uint8Array(r.GLTFUtils.DecodeBase64(s.uri)))})):e.Tools.LoadFile(n.rootUrl+s.uri,(function(e){return o(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&i(e.status+" "+e.statusText)}))},a.CreateTextureAsync=function(n,t,o,i,a){var s=n.textures[t];if(s.babylonTexture)return void i(s.babylonTexture);var u=n.samplers[s.sampler],l=u.minFilter===r.ETextureFilterType.NEAREST_MIPMAP_NEAREST||u.minFilter===r.ETextureFilterType.NEAREST_MIPMAP_LINEAR||u.minFilter===r.ETextureFilterType.LINEAR_MIPMAP_NEAREST||u.minFilter===r.ETextureFilterType.LINEAR_MIPMAP_LINEAR,c=e.Texture.BILINEAR_SAMPLINGMODE,f=new Blob([o]),d=URL.createObjectURL(f),m=function(){return URL.revokeObjectURL(d)},h=new e.Texture(d,n.scene,!l,!0,c,m,m);void 0!==u.wrapS&&(h.wrapU=r.GLTFUtils.GetWrapMode(u.wrapS)),void 0!==u.wrapT&&(h.wrapV=r.GLTFUtils.GetWrapMode(u.wrapT)),h.name=t,s.babylonTexture=h,i(h)},a.LoadShaderStringAsync=function(n,t,o,i){var a=n.shaders[t];if(r.GLTFUtils.IsBase64(a.uri)){o(atob(a.uri.split(",")[1]))}else e.Tools.LoadFile(n.rootUrl+a.uri,o,void 0,void 0,!1,(function(e){e&&i(e.status+" "+e.statusText)}))},a.LoadMaterialAsync=function(a,s,u,l){var c=a.materials[s];if(!c.technique)return void(l&&l("No technique found."));var f=a.techniques[c.technique];if(!f){var m=new e.StandardMaterial(s,a.scene);return m.diffuseColor=new e.Color3(.5,.5,.5),m.sideOrientation=e.Material.CounterClockWiseSideOrientation,void u(m)}var h=a.programs[f.program],p=f.states,T=e.Effect.ShadersStore[h.vertexShader+"VertexShader"],E=e.Effect.ShadersStore[h.fragmentShader+"PixelShader"],A="",v="",L=new t(T),O=new t(E),y={},_=[],b=[],g=[];for(var N in f.uniforms){var M=f.uniforms[N],S=f.parameters[M];if(y[N]=S,!S.semantic||S.node||S.source)S.type===r.EParameterType.SAMPLER_2D?g.push(N):_.push(N);else{var B=o.indexOf(S.semantic);-1!==B?(_.push(i[B]),delete y[N]):_.push(N)}}for(var C in f.attributes){var I=f.attributes[C],w=f.parameters[I];w.semantic&&b.push(d(w))}for(;!L.isEnd()&&L.getNextToken();){var P=L.currentToken;if(P===n.IDENTIFIER){var G=!1;for(var C in f.attributes){var I=f.attributes[C],w=f.parameters[I];if(L.currentIdentifier===C&&w.semantic){A+=d(w),G=!0;break}}G||(A+=R(L,f,y))}else A+=L.currentString}for(;!O.isEnd()&&O.getNextToken();){var P=O.currentToken;P===n.IDENTIFIER?v+=R(O,f,y):v+=O.currentString}var V={vertex:h.vertexShader+s,fragment:h.fragmentShader+s},D={attributes:b,uniforms:_,samplers:g,needAlphaBlending:p&&p.enable&&-1!==p.enable.indexOf(3042)};e.Effect.ShadersStore[h.vertexShader+s+"VertexShader"]=A,e.Effect.ShadersStore[h.fragmentShader+s+"PixelShader"]=v;var U=new e.ShaderMaterial(s,a.scene,V,D);if(U.onError=F(h,U,l),U.onCompiled=x(a,U,f,c,y,u),U.sideOrientation=e.Material.CounterClockWiseSideOrientation,p&&p.functions){var k=p.functions;k.cullFace&&k.cullFace[0]!==r.ECullingType.BACK&&(U.backFaceCulling=!1);var j=k.blendFuncSeparate;j&&(j[0]===r.EBlendingFunction.SRC_ALPHA&&j[1]===r.EBlendingFunction.ONE_MINUS_SRC_ALPHA&&j[2]===r.EBlendingFunction.ONE&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_COMBINE:j[0]===r.EBlendingFunction.ONE&&j[1]===r.EBlendingFunction.ONE&&j[2]===r.EBlendingFunction.ZERO&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_ONEONE:j[0]===r.EBlendingFunction.SRC_ALPHA&&j[1]===r.EBlendingFunction.ONE&&j[2]===r.EBlendingFunction.ZERO&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_ADD:j[0]===r.EBlendingFunction.ZERO&&j[1]===r.EBlendingFunction.ONE_MINUS_SRC_COLOR&&j[2]===r.EBlendingFunction.ONE&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_SUBTRACT:j[0]===r.EBlendingFunction.DST_COLOR&&j[1]===r.EBlendingFunction.ZERO&&j[2]===r.EBlendingFunction.ONE&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_MULTIPLY:j[0]===r.EBlendingFunction.SRC_ALPHA&&j[1]===r.EBlendingFunction.ONE_MINUS_SRC_COLOR&&j[2]===r.EBlendingFunction.ONE&&j[3]===r.EBlendingFunction.ONE&&(U.alphaMode=e.Engine.ALPHA_MAXIMIZED))}},a})();r.GLTFLoaderBase=C;var I=(function(){function n(){this.coordinateSystemMode=e.GLTFLoaderCoordinateSystemMode.AUTO,this.animationStartMode=e.GLTFLoaderAnimationStartMode.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.onDisposeObservable=new e.Observable,this.onMeshLoadedObservable=new e.Observable,this.onTextureLoadedObservable=new e.Observable,this.onMaterialLoadedObservable=new e.Observable,this.onCompleteObservable=new e.Observable}return n.RegisterExtension=function(r){if(n.Extensions[r.name])return void e.Tools.Error('Tool with the same name "'+r.name+'" already exists');n.Extensions[r.name]=r},n.prototype.dispose=function(){},n.prototype.importMeshAsync=function(n,t,o,i,a,s,u){var l=this;return t.useRightHandedSystem=!0,r.GLTFLoaderExtension.LoadRuntimeAsync(t,o,i,(function(r){r.importOnlyMeshes=!0,""===n?r.importMeshesNames=[]:"string"==typeof n?r.importMeshesNames=[n]:!n||n instanceof Array?(r.importMeshesNames=[],e.Tools.Warn("Argument meshesNames must be of type string or string[]")):r.importMeshesNames=[n],l._createNodes(r);var t=new Array,o=new Array;for(var i in r.nodes){var u=r.nodes[i];u.babylonNode instanceof e.AbstractMesh&&t.push(u.babylonNode)}for(var c in r.skins){var f=r.skins[c];f.babylonSkeleton instanceof e.Skeleton&&o.push(f.babylonSkeleton)}l._loadBuffersAsync(r,(function(){l._loadShadersAsync(r,(function(){B(r),N(r),!e.GLTFFileLoader.IncrementalLoading&&a&&a(t,[],o)}))}),s),e.GLTFFileLoader.IncrementalLoading&&a&&a(t,[],o)}),u),!0},n.prototype.loadAsync=function(n,t,o,i,a,s){var u=this;n.useRightHandedSystem=!0,r.GLTFLoaderExtension.LoadRuntimeAsync(n,t,o,(function(n){r.GLTFLoaderExtension.LoadRuntimeExtensionsAsync(n,(function(){u._createNodes(n),u._loadBuffersAsync(n,(function(){u._loadShadersAsync(n,(function(){B(n),N(n),e.GLTFFileLoader.IncrementalLoading||i()}))})),e.GLTFFileLoader.IncrementalLoading&&i()}),s)}),s)},n.prototype._loadShadersAsync=function(n,t){var o=!1,i=function(o,i){r.GLTFLoaderExtension.LoadShaderStringAsync(n,o,(function(a){n.loadedShaderCount++,a&&(e.Effect.ShadersStore[o+(i.type===r.EShaderType.VERTEX?"VertexShader":"PixelShader")]=a),n.loadedShaderCount===n.shaderscount&&t()}),(function(){e.Tools.Error("Error when loading shader program named "+o+" located at "+i.uri)}))};for(var a in n.shaders){o=!0;var s=n.shaders[a];s?i.bind(this,a,s)():e.Tools.Error("No shader named: "+a)}o||t()},n.prototype._loadBuffersAsync=function(n,t,o){var i=!1,a=function(o,i){r.GLTFLoaderExtension.LoadBufferAsync(n,o,(function(r){n.loadedBufferCount++,r&&(r.byteLength!=n.buffers[o].byteLength&&e.Tools.Error("Buffer named "+o+" is length "+r.byteLength+". Expected: "+i.byteLength),n.loadedBufferViews[o]=r),n.loadedBufferCount===n.buffersCount&&t()}),(function(){e.Tools.Error("Error when loading buffer named "+o+" located at "+i.uri)}))};for(var s in n.buffers){i=!0;var u=n.buffers[s];u?a.bind(this,s,u)():e.Tools.Error("No buffer named: "+s)}i||t()},n.prototype._createNodes=function(e){var r=e.currentScene;if(r)for(var n=0;n<r.nodes.length;n++)g(e,r.nodes[n],null);else for(var t in e.scenes){
  2. r=e.scenes[t];for(var n=0;n<r.nodes.length;n++)g(e,r.nodes[n],null)}},n.Extensions={},n})();r.GLTFLoader=I,e.GLTFFileLoader.CreateGLTFLoaderV1=function(){return new I}})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(r){var n=(function(){function n(){}return n.SetMatrix=function(n,t,o,i,a){var s=null;if("MODEL"===o.semantic?s=t.getWorldMatrix():"PROJECTION"===o.semantic?s=n.getProjectionMatrix():"VIEW"===o.semantic?s=n.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===o.semantic?s=e.Matrix.Transpose(t.getWorldMatrix().multiply(n.getViewMatrix()).invert()):"MODELVIEW"===o.semantic?s=t.getWorldMatrix().multiply(n.getViewMatrix()):"MODELVIEWPROJECTION"===o.semantic?s=t.getWorldMatrix().multiply(n.getTransformMatrix()):"MODELINVERSE"===o.semantic?s=t.getWorldMatrix().invert():"VIEWINVERSE"===o.semantic?s=n.getViewMatrix().invert():"PROJECTIONINVERSE"===o.semantic?s=n.getProjectionMatrix().invert():"MODELVIEWINVERSE"===o.semantic?s=t.getWorldMatrix().multiply(n.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===o.semantic?s=t.getWorldMatrix().multiply(n.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===o.semantic&&(s=e.Matrix.Transpose(t.getWorldMatrix().invert())),s)switch(o.type){case r.EParameterType.FLOAT_MAT2:a.setMatrix2x2(i,e.Matrix.GetAsMatrix2x2(s));break;case r.EParameterType.FLOAT_MAT3:a.setMatrix3x3(i,e.Matrix.GetAsMatrix3x3(s));break;case r.EParameterType.FLOAT_MAT4:a.setMatrix(i,s)}},n.SetUniform=function(n,t,o,i){switch(i){case r.EParameterType.FLOAT:return n.setFloat(t,o),!0;case r.EParameterType.FLOAT_VEC2:return n.setVector2(t,e.Vector2.FromArray(o)),!0;case r.EParameterType.FLOAT_VEC3:return n.setVector3(t,e.Vector3.FromArray(o)),!0;case r.EParameterType.FLOAT_VEC4:return n.setVector4(t,e.Vector4.FromArray(o)),!0;default:return!1}},n.IsBase64=function(e){return!(e.length<5)&&"data:"===e.substr(0,5)},n.DecodeBase64=function(e){for(var r=atob(e.split(",")[1]),n=r.length,t=new Uint8Array(new ArrayBuffer(n)),o=0;o<n;o++)t[o]=r.charCodeAt(o);return t.buffer},n.GetWrapMode=function(n){switch(n){case r.ETextureWrapMode.CLAMP_TO_EDGE:return e.Texture.CLAMP_ADDRESSMODE;case r.ETextureWrapMode.MIRRORED_REPEAT:return e.Texture.MIRROR_ADDRESSMODE;case r.ETextureWrapMode.REPEAT:default:return e.Texture.WRAP_ADDRESSMODE}},n.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},n.GetTextureFilterMode=function(n){switch(n){case r.ETextureFilterType.LINEAR:case r.ETextureFilterType.LINEAR_MIPMAP_NEAREST:case r.ETextureFilterType.LINEAR_MIPMAP_LINEAR:return e.Texture.TRILINEAR_SAMPLINGMODE;case r.ETextureFilterType.NEAREST:case r.ETextureFilterType.NEAREST_MIPMAP_NEAREST:return e.Texture.NEAREST_SAMPLINGMODE;default:return e.Texture.BILINEAR_SAMPLINGMODE}},n.GetBufferFromBufferView=function(e,n,t,o,i){var t=n.byteOffset+t,a=e.loadedBufferViews[n.buffer];if(t+o>a.byteLength)throw new Error("Buffer access is out of range");var s=a.buffer;switch(t+=a.byteOffset,i){case r.EComponentType.BYTE:return new Int8Array(s,t,o);case r.EComponentType.UNSIGNED_BYTE:return new Uint8Array(s,t,o);case r.EComponentType.SHORT:return new Int16Array(s,t,o);case r.EComponentType.UNSIGNED_SHORT:return new Uint16Array(s,t,o);default:return new Float32Array(s,t,o)}},n.GetBufferFromAccessor=function(e,r){var t=e.bufferViews[r.bufferView],o=r.count*n.GetByteStrideFromType(r);return n.GetBufferFromBufferView(e,t,r.byteOffset,o,r.componentType)},n.DecodeBufferToText=function(e){for(var r="",n=e.byteLength,t=0;t<n;++t)r+=String.fromCharCode(e[t]);return r},n.GetDefaultMaterial=function(r){if(!n._DefaultMaterial){e.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{"," gl_Position = projection * worldView * vec4(position, 1.0);","}"].join("\n"),e.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var t={vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},o={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};n._DefaultMaterial=new e.ShaderMaterial("GLTFDefaultMaterial",r,t,o),n._DefaultMaterial.setColor4("u_emission",new e.Color4(.5,.5,.5,1))}return n._DefaultMaterial},n._DefaultMaterial=null,n})();r.GLTFUtils=n})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var r=(function(){function r(e){this._name=e}return Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.loadRuntimeAsync=function(e,r,n,t,o){return!1},r.prototype.loadRuntimeExtensionsAsync=function(e,r,n){return!1},r.prototype.loadBufferAsync=function(e,r,n,t,o){return!1},r.prototype.loadTextureBufferAsync=function(e,r,n,t){return!1},r.prototype.createTextureAsync=function(e,r,n,t,o){return!1},r.prototype.loadShaderStringAsync=function(e,r,n,t){return!1},r.prototype.loadMaterialAsync=function(e,r,n,t){return!1},r.LoadRuntimeAsync=function(n,t,o,i,a){r.ApplyExtensions((function(e){return e.loadRuntimeAsync(n,t,o,i,a)}),(function(){setTimeout((function(){i(e.GLTFLoaderBase.CreateRuntime(t.json,n,o))}))}))},r.LoadRuntimeExtensionsAsync=function(e,n,t){r.ApplyExtensions((function(r){return r.loadRuntimeExtensionsAsync(e,n,t)}),(function(){setTimeout((function(){n()}))}))},r.LoadBufferAsync=function(n,t,o,i,a){r.ApplyExtensions((function(e){return e.loadBufferAsync(n,t,o,i,a)}),(function(){e.GLTFLoaderBase.LoadBufferAsync(n,t,o,i,a)}))},r.LoadTextureAsync=function(e,n,t,o){r.LoadTextureBufferAsync(e,n,(function(i){return r.CreateTextureAsync(e,n,i,t,o)}),o)},r.LoadShaderStringAsync=function(n,t,o,i){r.ApplyExtensions((function(e){return e.loadShaderStringAsync(n,t,o,i)}),(function(){e.GLTFLoaderBase.LoadShaderStringAsync(n,t,o,i)}))},r.LoadMaterialAsync=function(n,t,o,i){r.ApplyExtensions((function(e){return e.loadMaterialAsync(n,t,o,i)}),(function(){e.GLTFLoaderBase.LoadMaterialAsync(n,t,o,i)}))},r.LoadTextureBufferAsync=function(n,t,o,i){r.ApplyExtensions((function(e){return e.loadTextureBufferAsync(n,t,o,i)}),(function(){e.GLTFLoaderBase.LoadTextureBufferAsync(n,t,o,i)}))},r.CreateTextureAsync=function(n,t,o,i,a){r.ApplyExtensions((function(e){return e.createTextureAsync(n,t,o,i,a)}),(function(){e.GLTFLoaderBase.CreateTextureAsync(n,t,o,i,a)}))},r.ApplyExtensions=function(r,n){for(var t in e.GLTFLoader.Extensions){if(r(e.GLTFLoader.Extensions[t]))return}n()},r})();e.GLTFLoaderExtension=r})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])};return function(r,n){function t(){this.constructor=r}e(r,n),r.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}})(),BABYLON;!(function(e){!(function(e){var r=(function(r){function n(){return r.call(this,"KHR_binary_glTF")||this}return __extends(n,r),n.prototype.loadRuntimeAsync=function(r,n,t,o,i){var a=n.json.extensionsUsed;return!(!a||-1===a.indexOf(this.name)||!n.bin)&&(this._bin=n.bin,o(e.GLTFLoaderBase.CreateRuntime(n.json,r,t)),!0)},n.prototype.loadBufferAsync=function(e,r,n,t){return-1!==e.extensionsUsed.indexOf(this.name)&&("binary_glTF"===r&&(n(this._bin),!0))},n.prototype.loadTextureBufferAsync=function(r,n,t,o){var i=r.textures[n],a=r.images[i.source];if(!(a.extensions&&this.name in a.extensions))return!1;var s=a.extensions[this.name],u=r.bufferViews[s.bufferView];return t(e.GLTFUtils.GetBufferFromBufferView(r,u,0,u.byteLength,e.EComponentType.UNSIGNED_BYTE)),!0},n.prototype.loadShaderStringAsync=function(r,n,t,o){var i=r.shaders[n];if(!(i.extensions&&this.name in i.extensions))return!1;var a=i.extensions[this.name],s=r.bufferViews[a.bufferView],u=e.GLTFUtils.GetBufferFromBufferView(r,s,0,s.byteLength,e.EComponentType.UNSIGNED_BYTE);return setTimeout((function(){var r=e.GLTFUtils.DecodeBufferToText(u);t(r)})),!0},n})(e.GLTFLoaderExtension);e.GLTFBinaryExtension=r,e.GLTFLoader.RegisterExtension(new r)})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])};return function(r,n){function t(){this.constructor=r}e(r,n),r.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}})(),BABYLON;!(function(e){!(function(r){var n=(function(n){function t(){return n.call(this,"KHR_materials_common")||this}return __extends(t,n),t.prototype.loadRuntimeExtensionsAsync=function(r,n,t){if(!r.extensions)return!1;var o=r.extensions[this.name];if(!o)return!1;var i=o.lights;if(i)for(var a in i){var s=i[a];switch(s.type){case"ambient":var u=new e.HemisphericLight(s.name,new e.Vector3(0,1,0),r.scene),l=s.ambient;l&&(u.diffuse=e.Color3.FromArray(l.color||[1,1,1]));break;case"point":var c=new e.PointLight(s.name,new e.Vector3(10,10,10),r.scene),f=s.point;f&&(c.diffuse=e.Color3.FromArray(f.color||[1,1,1]));break;case"directional":var d=new e.DirectionalLight(s.name,new e.Vector3(0,-1,0),r.scene),m=s.directional;m&&(d.diffuse=e.Color3.FromArray(m.color||[1,1,1]));break;case"spot":var h=s.spot;if(h){var p=new e.SpotLight(s.name,new e.Vector3(0,10,0),new e.Vector3(0,-1,0),h.fallOffAngle||Math.PI,h.fallOffExponent||0,r.scene);p.diffuse=e.Color3.FromArray(h.color||[1,1,1])}break;default:e.Tools.Warn('GLTF Material Common extension: light type "'+s.type+"” not supported")}}return!1},t.prototype.loadMaterialAsync=function(r,n,t,o){var i=r.materials[n];if(!i||!i.extensions)return!1;var a=i.extensions[this.name];if(!a)return!1;var s=new e.StandardMaterial(n,r.scene);return s.sideOrientation=e.Material.CounterClockWiseSideOrientation,"CONSTANT"===a.technique&&(s.disableLighting=!0),s.backFaceCulling=void 0!==a.doubleSided&&!a.doubleSided,s.alpha=void 0===a.values.transparency?1:a.values.transparency,s.specularPower=void 0===a.values.shininess?0:a.values.shininess,"string"==typeof a.values.ambient?this._loadTexture(r,a.values.ambient,s,"ambientTexture",o):s.ambientColor=e.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(r,a.values.diffuse,s,"diffuseTexture",o):s.diffuseColor=e.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(r,a.values.emission,s,"emissiveTexture",o):s.emissiveColor=e.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(r,a.values.specular,s,"specularTexture",o):s.specularColor=e.Color3.FromArray(a.values.specular||[0,0,0]),!0},t.prototype._loadTexture=function(e,n,t,o,i){r.GLTFLoaderBase.LoadTextureBufferAsync(e,n,(function(a){r.GLTFLoaderBase.CreateTextureAsync(e,n,a,(function(e){return t[o]=e}),i)}),i)},t})(r.GLTFLoaderExtension);r.GLTFMaterialsCommonExtension=n,r.GLTFLoader.RegisterExtension(new n)})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));