var BABYLON=BABYLON||"undefined"!=typeof require&&require("babylonjs"),__decorate=this&&this.__decorate||function(e,t,r,n){var a,o=arguments.length,i=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(i=(o<3?a(i):o>3?a(t,r,i):a(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}})(),BABYLON;!(function(e){var t=(function(){function t(){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 t.prototype.importMesh=function(t,r,n,a,o,i,s){var u;if(this.isBinary(n)){var l=new e.Mesh("stlmesh",r);return this.parseBinary(l,n),o&&o.push(l),!0}for(var c=new Uint8Array(n),f="",d=0;d127)return!0;return!1},t.prototype.parseBinary=function(t,r){for(var n=new DataView(r),a=n.getUint32(80,!0),o=0,i=new Float32Array(3*a*3),s=new Float32Array(3*a*3),u=new Uint32Array(3*a),l=0,c=0;c=0?l.substring(0,c):l;f=f.toLowerCase();var d=c>=0?l.substring(c+1).trim():"";"newmtl"===f?(i&&this.materials.push(i),i=new e.StandardMaterial(d,r)):"kd"===f?(o=d.split(/\s+/,3).map(parseFloat),i.diffuseColor=e.Color3.FromArray(o)):"ka"===f?(o=d.split(/\s+/,3).map(parseFloat),i.ambientColor=e.Color3.FromArray(o)):"ks"===f?(o=d.split(/\s+/,3).map(parseFloat),i.specularColor=e.Color3.FromArray(o)):"ke"===f?(o=d.split(/\s+/,3).map(parseFloat),i.emissiveColor=e.Color3.FromArray(o)):"ns"===f?i.specularPower=parseFloat(d):"d"===f?i.alpha=parseFloat(d):"map_ka"===f?i.ambientTexture=t._getTexture(a,d,r):"map_kd"===f?i.diffuseTexture=t._getTexture(a,d,r):"map_ks"===f?i.specularTexture=t._getTexture(a,d,r):"map_ns"===f||("map_bump"===f?i.bumpTexture=t._getTexture(a,d,r):"map_d"===f&&(i.opacityTexture=t._getTexture(a,d,r)))}}this.materials.push(i)}}return t._getTexture=function(t,r,n){if(!r)return null;var a=t;if("file:"===t){var o=r.lastIndexOf("\\");-1===o&&(o=r.lastIndexOf("/")),a+=o>-1?r.substr(o+1):r}else a+=r;return new e.Texture(a,n)},t})();e.MTLFileLoader=t;var r=(function(){function r(){this.name="obj",this.extensions=".obj",this.obj=/^o/,this.group=/^g/,this.mtllib=/^mtllib /,this.usemtl=/^usemtl /,this.smooth=/^s /,this.vertexPattern=/v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.normalPattern=/vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.uvPattern=/vt( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.facePattern1=/f\s+(([\d]{1,}[\s]?){3,})+/,this.facePattern2=/f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern3=/f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern4=/f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/}return r.prototype._loadMTL=function(t,r,n){var a=e.Tools.BaseUrl+r+t;e.Tools.LoadFile(a,n,null,null,!1,(function(){console.warn("Error - Unable to load "+a)}))},r.prototype.importMesh=function(e,t,r,n,a,o,i){var s=this._parseSolid(e,t,r,n);return a&&s.forEach((function(e){a.push(e)})),!0},r.prototype.load=function(e,t,r){return this.importMesh(null,e,t,r,null,null,null)},r.prototype._parseSolid=function(n,a,o,i){for(var s,u=[],l=[],c=[],f=[],d=[],h=[],p=[],m=[],_=[],T=0,A=!1,E=[],y=[],g=[],v=[],L="",N="",b=new t,x=1,M=!0,O=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var r=e[t[0]].normals.indexOf(t[1]);return-1===r?-1:e[t[0]].idx[r]},S=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var r=e[t[0]].normals.indexOf(t[1]);return 1!=r&&t[2]==e[t[0]].uv[r]?e[t[0]].idx[r]:-1},I=function(e,t,n,a,o,i){var s;s=r.OPTIMIZE_WITH_UV?S(_,[e,n,t]):O(_,[e,n]),-1==s?(d.push(h.length),h.push(a),p.push(o),m.push(i),_[e].normals.push(n),_[e].idx.push(T++),r.OPTIMIZE_WITH_UV&&_[e].uv.push(t)):d.push(s)},R=function(){for(var e=0;e0&&(s=f[f.length-1],R(),d.reverse(),s.indices=d.slice(),s.positions=E.slice(),s.normals=y.slice(),s.uvs=g.slice(),d=[],E=[],y=[],g=[])},P=o.split("\n"),C=0;C-1;)o.push(r),n=r+1;if(-1==r&&0==o.length)b.materials[t].dispose();else for(var s=0;s0)return r("Incompatible minimum version: "+a.minVersion),null}var s={1:e.CreateGLTFLoaderV1,2:e.CreateGLTFLoaderV2},u=s[o.major];return u?u(this):(r("Unsupported version: "+a.version),null)},e._parseBinary=function(t,r){var a={Magic:1179937895},o=new n(t),i=o.readUint32();if(i!==a.Magic)return r("Unexpected magic: "+i),null;var s=o.readUint32();switch(s){case 1:return e._parseV1(o,r);case 2:return e._parseV2(o,r)}return r("Unsupported version: "+s),null},e._parseV1=function(t,r){var n={JSON:0},a=t.readUint32();if(a!=t.getLength())return r("Length in header does not match actual data length: "+a+" != "+t.getLength()),null;var o,i=t.readUint32(),s=t.readUint32();switch(s){case n.JSON:o=JSON.parse(e._decodeBufferToText(t.readUint8Array(i)));break;default:return r("Unexpected content format: "+s),null}var u=t.getLength()-t.getPosition();return{json:o,bin:t.readUint8Array(u)}},e._parseV2=function(t,r){var n={JSON:1313821514,BIN:5130562},a=t.readUint32();if(a!==t.getLength())return r("Length in header does not match actual data length: "+a+" != "+t.getLength()),null;var o=t.readUint32(),i=t.readUint32();if(i!==n.JSON)return r("First chunk format is not JSON"),null;for(var s=JSON.parse(e._decodeBufferToText(t.readUint8Array(o))),u=null;t.getPosition()t.major?1:e.majort.minor?1:e.minor=this._maxPos},e})(),a=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],o=["world","view","projection","worldView","worldViewProjection","mBones"],i=["translation","rotation","scale"],s=["position","rotationQuaternion","scaling"],u=function(e,t){for(var r in e){var n=e[r];t.buffers[r]=n,t.buffersCount++}},l=function(e,t){for(var r in e){var n=e[r];t.shaders[r]=n,t.shaderscount++}},c=function(e,t,r){for(var n in e){var a=e[n];r[t][n]=a}},f=function(e){if(e)for(var t=0;t0&&(y=_(u,i))&&-1===l.indexOf(y)&&l.push(y);new e.Bone(d.jointName,o,y,b).id=i}}else e.Tools.Warn("Joint named "+n.jointNames[c]+" does not exist")}var x=o.bones;o.bones=[];for(var c=0;c0&&-1===t.importMeshesNames.indexOf(r.name))return null;if(r.skin){if(r.meshes){var i=t.skins[r.skin],s=g(t,r,r.meshes,n,r.babylonNode);s.skeleton=t.scene.getLastSkeletonByID(r.skin),null===s.skeleton&&(s.skeleton=y(t,i,0,i.babylonSkeleton,r.skin),i.babylonSkeleton||(i.babylonSkeleton=s.skeleton)),o=s}}else if(r.meshes){var s=g(t,r,r.mesh?[r.mesh]:r.meshes,n,r.babylonNode);o=s}else if(!r.light||r.babylonNode||t.importOnlyMeshes){if(r.camera&&!r.babylonNode&&!t.importOnlyMeshes){var u=t.cameras[r.camera];if(u)if("orthographic"===u.type){var l=(u[u.type],new e.FreeCamera(r.camera,e.Vector3.Zero(),t.scene));l.name=r.name,l.mode=e.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(t.scene.getEngine().getRenderingCanvas()),o=l}else if("perspective"===u.type){var c=u[u.type],f=new e.FreeCamera(r.camera,e.Vector3.Zero(),t.scene);f.name=r.name,f.attachControl(t.scene.getEngine().getRenderingCanvas()),c.aspectRatio||(c.aspectRatio=t.scene.getEngine().getRenderWidth()/t.scene.getEngine().getRenderHeight()),c.znear&&c.zfar&&(f.maxZ=c.zfar,f.minZ=c.znear),o=f}}}else{var d=t.lights[r.light];if(d)if("ambient"===d.type){var h=d[d.type],p=new e.HemisphericLight(r.light,e.Vector3.Zero(),t.scene);p.name=r.name,h.color&&(p.diffuse=e.Color3.FromArray(h.color)),o=p}else if("directional"===d.type){var m=d[d.type],_=new e.DirectionalLight(r.light,e.Vector3.Zero(),t.scene);_.name=r.name,m.color&&(_.diffuse=e.Color3.FromArray(m.color)),o=_}else if("point"===d.type){var T=d[d.type],A=new e.PointLight(r.light,e.Vector3.Zero(),t.scene);A.name=r.name,T.color&&(A.diffuse=e.Color3.FromArray(T.color)),o=A}else if("spot"===d.type){var E=d[d.type],N=new e.SpotLight(r.light,e.Vector3.Zero(),e.Vector3.Zero(),0,0,t.scene);N.name=r.name,E.color&&(N.diffuse=e.Color3.FromArray(E.color)),E.fallOfAngle&&(N.angle=E.fallOfAngle),E.fallOffExponent&&(N.exponent=E.fallOffExponent),o=N}}if(!r.jointName){if(r.babylonNode)return r.babylonNode;if(null===o){var b=new e.Mesh(r.name,t.scene);r.babylonNode=b,o=b}}if(null!==o){if(r.matrix&&o instanceof e.Mesh)L(o,r);else{var x=r.translation||[0,0,0],M=r.rotation||[0,0,0,1],O=r.scale||[1,1,1];v(o,e.Vector3.FromArray(x),e.Quaternion.FromArray(M),e.Vector3.FromArray(O))}o.updateCache(!0),r.babylonNode=o}return o},b=function(e,t,r,n){var a=e.nodes[t],o=null;if(n=!(e.importOnlyMeshes&&!n)||(-1!==e.importMeshesNames.indexOf(a.name)||0===e.importMeshesNames.length),!a.jointName&&n&&null!==(o=N(e,a,t))&&(o.id=t,o.parent=r),a.children)for(var i=0;ii.byteLength)throw new Error("Buffer access is out of range");var s=i.buffer;switch(n+=i.byteOffset,o){case t.EComponentType.BYTE:return new Int8Array(s,n,a);case t.EComponentType.UNSIGNED_BYTE:return new Uint8Array(s,n,a);case t.EComponentType.SHORT:return new Int16Array(s,n,a);case t.EComponentType.UNSIGNED_SHORT:return new Uint16Array(s,n,a);default:return new Float32Array(s,n,a)}},r.GetBufferFromAccessor=function(e,t){var n=e.bufferViews[t.bufferView],a=t.count*r.GetByteStrideFromType(t);return r.GetBufferFromBufferView(e,n,t.byteOffset,a,t.componentType)},r.DecodeBufferToText=function(e){for(var t="",r=e.byteLength,n=0;nu.byteLength)return void s._onError("Buffer access is out of range");var l=u.buffer;r+=u.byteOffset;var c;switch(o){case t.EComponentType.BYTE:c=s._buildInt8ArrayBuffer(l,r,n,e.byteStride,a);break;case t.EComponentType.UNSIGNED_BYTE:c=s._buildUint8ArrayBuffer(l,r,n,e.byteStride,a);break;case t.EComponentType.SHORT:c=s._buildInt16ArrayBuffer(l,r,n,e.byteStride,a);break;case t.EComponentType.UNSIGNED_SHORT:c=s._buildUint16ArrayBuffer(l,r,n,e.byteStride,a);break;case t.EComponentType.UNSIGNED_INT:c=s._buildUint32ArrayBuffer(l,r,n,e.byteStride,a);break;case t.EComponentType.FLOAT:c=s._buildFloat32ArrayBuffer(l,r,n,e.byteStride,a);break;default:return void s._onError("Invalid component type ("+o+")")}i(c)}))},n.prototype._loadAccessorAsync=function(e,t){var r=this._getArrayItem(this._gltf.bufferViews,e.bufferView,"Buffer view");if(r){var n=e.byteOffset||0,a=this._getByteStrideFromType(e),o=e.count*a;this._loadBufferViewAsync(r,n,o,a,e.componentType,t)}},n.prototype._getByteStrideFromType=function(e){switch(e.type){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return this._onError("Invalid accessor type ("+e.type+")"),0}},n.prototype._addPendingData=function(e){this._renderReady||this._renderPendingCount++,this._addLoaderPendingData(e)},n.prototype._removePendingData=function(e){this._renderReady||0==--this._renderPendingCount&&(this._renderReady=!0,this._onRenderReady()),this._removeLoaderPendingData(e)},n.prototype._addLoaderPendingData=function(e){this._loaderPendingCount++,this._loaderTrackers.forEach((function(t){return t._addPendingData(e)}))},n.prototype._removeLoaderPendingData=function(e){this._loaderTrackers.forEach((function(t){return t._removePendingData(e)})),0==--this._loaderPendingCount&&this._onComplete()},n.prototype._whenAction=function(e,t){var n=this,a=new r(function(){n._loaderTrackers.splice(n._loaderTrackers.indexOf(a)),t()});this._loaderTrackers.push(a),this._addLoaderPendingData(a),e(),this._removeLoaderPendingData(a)},n.prototype._getDefaultMaterial=function(){if(!this._defaultMaterial){var t="__gltf_default",r=this._babylonScene.getMaterialByName(t);r||(r=new e.PBRMaterial(t,this._babylonScene),r.sideOrientation=e.Material.CounterClockWiseSideOrientation,r.metallic=1,r.roughness=1),this._defaultMaterial=r}return this._defaultMaterial},n.prototype._loadMaterialMetallicRoughnessProperties=function(t){var r=t.babylonMaterial;r.metallic=1,r.roughness=1;var n=t.pbrMetallicRoughness;n&&(r.albedoColor=n.baseColorFactor?e.Color3.FromArray(n.baseColorFactor):new e.Color3(1,1,1),r.metallic=null==n.metallicFactor?1:n.metallicFactor,r.roughness=null==n.roughnessFactor?1:n.roughnessFactor,n.baseColorTexture&&(r.albedoTexture=this._loadTexture(n.baseColorTexture)),n.metallicRoughnessTexture&&(r.metallicTexture=this._loadTexture(n.metallicRoughnessTexture),r.useMetallnessFromMetallicTextureBlue=!0,r.useRoughnessFromMetallicTextureGreen=!0,r.useRoughnessFromMetallicTextureAlpha=!1),this._loadMaterialAlphaProperties(t,n.baseColorFactor))},n.prototype._loadMaterial=function(e,r){if(e.babylonMaterial)return void r(e.babylonMaterial,!1);t.GLTFLoaderExtension.LoadMaterial(this,e,r)||(this._createPbrMaterial(e),this._loadMaterialBaseProperties(e),this._loadMaterialMetallicRoughnessProperties(e),r(e.babylonMaterial,!0))},n.prototype._createPbrMaterial=function(t){var r=new e.PBRMaterial(t.name||"mat"+t.index,this._babylonScene);r.sideOrientation=e.Material.CounterClockWiseSideOrientation,t.babylonMaterial=r},n.prototype._loadMaterialBaseProperties=function(t){var r=t.babylonMaterial;r.emissiveColor=t.emissiveFactor?e.Color3.FromArray(t.emissiveFactor):new e.Color3(0,0,0),t.doubleSided&&(r.backFaceCulling=!1,r.twoSidedLighting=!0),t.normalTexture&&(r.bumpTexture=this._loadTexture(t.normalTexture),r.invertNormalMapX=!this._babylonScene.useRightHandedSystem,r.invertNormalMapY=this._babylonScene.useRightHandedSystem,void 0!==t.normalTexture.scale&&(r.bumpTexture.level=t.normalTexture.scale)),t.occlusionTexture&&(r.ambientTexture=this._loadTexture(t.occlusionTexture),r.useAmbientInGrayScale=!0,void 0!==t.occlusionTexture.strength&&(r.ambientTextureStrength=t.occlusionTexture.strength)),t.emissiveTexture&&(r.emissiveTexture=this._loadTexture(t.emissiveTexture))},n.prototype._loadMaterialAlphaProperties=function(e,t){var r=e.babylonMaterial;switch(e.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":r.alphaCutOff=null==e.alphaCutoff?.5:e.alphaCutoff,t&&(0==t[3]?r.alphaCutOff=1:r.alphaCutOff/=t[3]),r.albedoTexture&&(r.albedoTexture.hasAlpha=!0);break;case"BLEND":t&&(r.alpha=t[3]),r.albedoTexture&&(r.albedoTexture.hasAlpha=!0,r.useAlphaFromAlbedoTexture=!0);break;default:return void this._onError("Invalid alpha mode '"+e.alphaMode+"'")}},n.prototype._loadTexture=function(r){var n=this,a=this._getArrayItem(this._gltf.textures,r.index,"Texture");if(!a)return null;var o=r.texCoord||0,i=this._getArrayItem(this._gltf.images,a.source,"Texture ("+r.index+") source");if(!i)return null;var s=null==a.sampler?{}:this._getArrayItem(this._gltf.samplers,a.sampler,"Texture ("+r.index+") sampler");if(s){var u=s.minFilter===t.ETextureMinFilter.NEAREST||s.minFilter===t.ETextureMinFilter.LINEAR,l=t.GLTFUtils.GetTextureSamplingMode(s.magFilter,s.minFilter);this._addPendingData(a);var c=new e.Texture(null,this._babylonScene,u,!1,l,function(){n._disposed||n._removePendingData(a)},function(){n._disposed||(n._onError("Failed to load texture '"+i.uri+"'"),n._removePendingData(a))});if(a.url)c.updateURL(a.url);else if(a.dataReadyObservable)a.dataReadyObservable.add((function(e){c.updateURL(e.url)}));else{a.dataReadyObservable=new e.Observable,a.dataReadyObservable.add((function(e){c.updateURL(e.url)}));var f=function(e){a.url=URL.createObjectURL(new Blob([e],{type:i.mimeType})),a.dataReadyObservable.notifyObservers(a)};if(i.uri)t.GLTFUtils.IsBase64(i.uri)?f(new Uint8Array(t.GLTFUtils.DecodeBase64(i.uri))):e.Tools.LoadFile(this._rootUrl+i.uri,f,(function(e){n._onProgress(e)}),this._babylonScene.database,!0,(function(e){n._onError("Failed to load file '"+i.uri+"': "+e.status+" "+e.statusText)}));else{var d=this._getArrayItem(this._gltf.bufferViews,i.bufferView,"Texture ("+r.index+") source ("+a.source+") buffer view");if(!d)return;this._loadBufferViewAsync(d,0,d.byteLength,1,t.EComponentType.UNSIGNED_BYTE,f)}}return c.coordinatesIndex=o,c.wrapU=t.GLTFUtils.GetTextureWrapMode(s.wrapS),c.wrapV=t.GLTFUtils.GetTextureWrapMode(s.wrapT),c.name=a.name||"texture"+r.index,this._parent.onTextureLoaded&&this._parent.onTextureLoaded(c),c}},n.prototype._getArrayItem=function(e,t,r){return e&&e[t]?e[t]:(this._onError(r+" index ("+t+") was not found"),null)},n})();n.Extensions={},t.GLTFLoader=n,e.GLTFFileLoader.CreateGLTFLoaderV2=function(e){return new n(e)}})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function r(){}return r.IsBase64=function(e){return!(e.length<5)&&"data:"===e.substr(0,5)},r.DecodeBase64=function(e){for(var t=atob(e.split(",")[1]),r=t.length,n=new Uint8Array(new ArrayBuffer(r)),a=0;a=0;i--)e._traverseNode(a.ids[i],r,n);e._traverseNode(t,r,n),o()}))},r.prototype._loadNode=function(e,t){var r=this;return this._loadExtension(t,(function(n,a){var o=[t.index].concat(n.ids).map((function(t){return e._gltf.nodes[t]}));e._addLoaderPendingData(t),r._loadNodeLOD(e,o,o.length-1,(function(){e._removeLoaderPendingData(t),a()}))}))},r.prototype._loadNodeLOD=function(e,t,n,a){var o=this;e._whenAction((function(){e._loadNode(t[n])}),(function(){if(n!==t.length-1){t[n+1].babylonMesh.setEnabled(!1)}if(0===n)return void a();setTimeout((function(){o._loadNodeLOD(e,t,n-1,a)}),r.MinimalLODDelay)}))},r.prototype._loadMaterial=function(e,t,r){var n=this;return this._loadExtension(t,(function(a,o){var i=[t.index].concat(a.ids).map((function(t){return e._gltf.materials[t]}));e._addLoaderPendingData(t),n._loadMaterialLOD(e,i,i.length-1,r,(function(){t.extensions[n.name]=a,e._removeLoaderPendingData(t),o()}))}))},r.prototype._loadMaterialLOD=function(t,n,a,o,i){var s=this;t._loadMaterial(n[a],(function(u,l){if(o(u,l),0===a)return void i();t._executeWhenRenderReady((function(){e.BaseTexture.WhenAllReady(u.getActiveTextures(),(function(){setTimeout((function(){s._loadMaterialLOD(t,n,a-1,o,i)}),r.MinimalLODDelay)}))}))}))},r})(t.GLTFLoaderExtension);n.MinimalLODDelay=250,r.MSFTLOD=n,t.GLTFLoader.RegisterExtension(new n)})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){!(function(r){var n=(function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return __extends(r,t),Object.defineProperty(r.prototype,"name",{get:function(){return"KHR_materials_pbrSpecularGlossiness"},enumerable:!0,configurable:!0}),r.prototype._loadMaterial=function(e,t,r){var n=this;return this._loadExtension(t,(function(a,o){e._createPbrMaterial(t),e._loadMaterialBaseProperties(t),n._loadSpecularGlossinessProperties(e,t,a),r(t.babylonMaterial,!0)}))},r.prototype._loadSpecularGlossinessProperties=function(t,r,n){var a=r.babylonMaterial;a.albedoColor=n.diffuseFactor?e.Color3.FromArray(n.diffuseFactor):new e.Color3(1,1,1),a.reflectivityColor=n.specularFactor?e.Color3.FromArray(n.specularFactor):new e.Color3(1,1,1),a.microSurface=void 0===n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&(a.albedoTexture=t._loadTexture(n.diffuseTexture)),n.specularGlossinessTexture&&(a.reflectivityTexture=t._loadTexture(n.specularGlossinessTexture),a.reflectivityTexture.hasAlpha=!0,a.useMicroSurfaceFromReflectivityMapAlpha=!0),t._loadMaterialAlphaProperties(r,n.diffuseFactor)},r})(t.GLTFLoaderExtension);r.KHRMaterialsPbrSpecularGlossiness=n,t.GLTFLoader.RegisterExtension(new n)})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={})),(function(e,t){e&&e.BABYLON||("object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BJSLoaders=t():e.BABYLON=t())})(this,(function(){return BABYLON}));