UNPKG

apl-easy-gl

Version:
1 lines 29.7 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("gl-matrix"));else if("function"==typeof define&&define.amd)define(["gl-matrix"],t);else{var r="object"==typeof exports?t(require("gl-matrix")):t(e["gl-matrix"]);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=26)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.loadFile=function(e){return new Promise(function(t,r){var n=new XMLHttpRequest;n.open("GET",e),n.overrideMimeType("text/plain"),n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&200===n.status&&t(n.responseText)},n.send()})}},function(e,t,r){"use strict";var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e};Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOptions={minFilter:WebGLRenderingContext.LINEAR,magFilter:WebGLRenderingContext.LINEAR,wrapS:WebGLRenderingContext.CLAMP_TO_EDGE,wrapT:WebGLRenderingContext.CLAMP_TO_EDGE,flipY:!1,level:0,internalFormat:WebGLRenderingContext.RGBA,border:0,srcFormat:WebGLRenderingContext.RGBA,srcType:WebGLRenderingContext.UNSIGNED_BYTE,width:0,height:0,premultiplyAlpha:!0},t.createTexture=function(e,r){r=n({},t.defaultOptions,r);var a=e.createTexture();return e.bindTexture(e.TEXTURE_2D,a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY?1:0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha?1:0),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,r.wrapS),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,r.wrapT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,r.minFilter),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,r.magFilter),e.texImage2D(e.TEXTURE_2D,r.level,r.internalFormat,r.width,r.height,r.border,r.srcFormat,r.srcType,null),a}},function(t,r){t.exports=e},function(e,t,r){"use strict";var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e};Object.defineProperty(t,"__esModule",{value:!0});var a=r(5),i={minFilter:WebGLRenderingContext.LINEAR_MIPMAP_LINEAR,magFilter:WebGLRenderingContext.LINEAR,wrapS:WebGLRenderingContext.CLAMP_TO_EDGE,wrapT:WebGLRenderingContext.CLAMP_TO_EDGE,flipY:!1,anisotropy:16,width:0,height:0};t.generateMipmap=function(e,t,r){if(r=n({},i,r),e.bindTexture(e.TEXTURE_2D,t),a.isPowerOf2(r.width)&&a.isPowerOf2(r.height)){if(e.generateMipmap(e.TEXTURE_2D),r.anisotropy){var o=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");if(o){var u=Math.min(r.anisotropy,e.getParameter(o.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e.texParameterf(e.TEXTURE_2D,o.TEXTURE_MAX_ANISOTROPY_EXT,u)}}}else switch(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),r.minFilter){case e.NEAREST_MIPMAP_NEAREST:case e.LINEAR_MIPMAP_NEAREST:e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);break;case e.NEAREST_MIPMAP_LINEAR:case e.LINEAR_MIPMAP_LINEAR:e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR)}return t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.xmlToJSON=function e(t){if(t.hasChildNodes()){if(1===t.childNodes.length&&t.childNodes.item(0).nodeType===Node.TEXT_NODE){for(var r={},n=0;n<t.childNodes.length;n++)r[(c=t.childNodes.item(n)).nodeName]=c.nodeValue;return r}var a=[];for(n=0;n<t.childNodes.length;n++)(c=t.childNodes.item(n)).nodeType===Node.ELEMENT_NODE&&a.push(c);var i=!0,o=a[0].nodeName;for(n=1;n<a.length;n++)if((c=a[n]).nodeName!==o){i=!1;break}if(t.childNodes.length>1&&i){var u=[];for(n=0;n<a.length;n++){var c=a[n];u.push(e(c))}return u}var s={};for(n=0;n<a.length;n++){var f=(c=a[n]).nodeName;f in s?(Array.isArray(s[f].push)||(s[f]=[s[f]]),s[f].push(e(c))):s[f]=e(c)}return s}if(t.nodeType===Node.ELEMENT_NODE){for(s={},n=0;n<t.attributes.length;n++){var l=t.attributes.item(n);s[l.nodeName]=l.nodeValue}return s}return t.nodeValue}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPowerOf2=function(e){return 0==(e&e-1)}},function(e,t,r){"use strict";function n(e,t,r){var n=e.createShader(t);if(e.shaderSource(n,r),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)&&!e.isContextLost()){var a=1,i=r.split("\n").reduce(function(e,t){return e+"\n"+a+++". "+t},"");throw new Error(e.getShaderInfoLog(n)+i)}return n}function a(e,t,r){var n=e.getAttribLocation(t,r.name);return{set:function(t){e.bindBuffer(e.ARRAY_BUFFER,t.buffer),e.enableVertexAttribArray(n),e.vertexAttribPointer(n,t.itemSize,t.type,!1,0,0)}}}function i(e,t,r,n){var a=function(e,t,r){switch(t){case e.FLOAT:return r>1?function(t,r){return e.uniform1fv(t,r)}:function(t,r){return e.uniform1f(t,r)};case e.FLOAT_VEC2:return function(t,r){return e.uniform2fv(t,r)};case e.FLOAT_VEC3:return function(t,r){return e.uniform3fv(t,r)};case e.FLOAT_VEC4:return function(t,r){return e.uniform4fv(t,r)};case e.FLOAT_MAT2:return function(t,r,n){return e.uniformMatrix2fv(t,n,r)};case e.FLOAT_MAT3:return function(t,r,n){return e.uniformMatrix3fv(t,n,r)};case e.FLOAT_MAT4:return function(t,r,n){return e.uniformMatrix4fv(t,n,r)};default:case e.INT:return r>1?function(t,r){return e.uniform1iv(t,r)}:function(t,r){return e.uniform1i(t,r)};case e.INT_VEC2:return function(t,r){return e.uniform2iv(t,r)};case e.INT_VEC3:return function(t,r){return e.uniform3iv(t,r)};case e.INT_VEC4:return function(t,r){return e.uniform4fv(t,r)}}}(e,r.type,r.size),i=e.getUniformLocation(t,r.name);if(!i)throw new Error("Could not get uniform location for: "+r.name);return{set:r.type===e.SAMPLER_2D?function(t){e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,t),e.uniform1i(i,n)}:function(e){a(i,e)}}}Object.defineProperty(t,"__esModule",{value:!0}),t.createProgram=function(e,t,r){var o=n(e,e.VERTEX_SHADER,t),u=n(e,e.FRAGMENT_SHADER,r),c=e.createProgram();if(e.attachShader(c,o),e.attachShader(c,u),e.linkProgram(c),!e.getProgramParameter(c,e.LINK_STATUS)&&!e.isContextLost())throw new Error("Could not initialise shaders: "+e.getProgramInfoLog(c));e.useProgram(c);for(var s=e.getProgramParameter(c,e.ACTIVE_UNIFORMS),f=e.getProgramParameter(c,e.ACTIVE_ATTRIBUTES),l={},d={},v=0,p=0;p<s;p++){var m=e.getActiveUniform(c,p);d[m.name]=i(e,c,m,v),m.type===e.SAMPLER_2D&&v++}for(p=0;p<f;p++)m=e.getActiveAttrib(c,p),l[m.name]=a(e,c,m);return{program:c,uniforms:d,attributes:l,setUniforms:function(e){for(var t in e)t in d&&d[t].set(e[t])},setAttributes:function(e){for(var t in e)t in l&&l[t].set(e[t])}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dirname=function(e){return e.match(/.*\//)[0].toString()}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(a,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){e.done?a(e.value):new r(function(t){t(e.value)}).then(o,u)}c((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),o=r(0),u={newmtl:/\bnewmtl\s+(.*)\b/,ambient:/\bKa\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\b/,diffuse:/\bKd\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\b/,specular:/\bKs\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\b/,intensity:/\bNs\s+([^\s]+)\b/,transparent:/\bd\s+([^\s]+)\b/,illumination:/\billum\s+([^\s]+)\b/,ambientMap:/\bmap_Ka\s+([^\s]+)\b/,diffuseMap:/\bmap_Kd\s+([^\s]+)\b/,specularMap:/\bmap_Ks\s+([^\s]+)\b/,intensityMap:/\bmap_Ns\s+([^\s]+)\b/,alphaMap:/\bmap_d\s+([^\s]+)\b/,bumpMap:/\bmap_bump\s+([^\s]+)\b/};t.loadMtl=function(e){return n(this,void 0,void 0,function(){var t,r,n,c;return a(this,function(a){switch(a.label){case 0:return[4,o.loadFile(e)];case 1:return t=a.sent(),r=t.split("\n"),n={},c={},r.forEach(function(e){var t=e.match(u.newmtl);if(t)return c={name:t[1]},void(n[c.name]=c);["ambient","diffuse","specular"].forEach(function(t){!function(e,t,r,n){var a=e.match(t);a&&(r[n]=i.vec3.fromValues(parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3])))}(e,u[t],c,t)}),["intensity","transparent","illumination","ambientMap","diffuseMap","specularMap","intensityMap","alphaMap","bumpMap"].forEach(function(t){!function(e,t,r,n){var a=e.match(t);a&&(r[n]=a[1])}(e,u[t],c,t)})}),[2,n]}})})}},function(e,t,r){"use strict";var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e};Object.defineProperty(t,"__esModule",{value:!0});var a=r(1),i={width:0,height:0,depth:!0,stencil:!1,minFilter:WebGLRenderingContext.NEAREST,magFilter:WebGLRenderingContext.NEAREST,wrapS:WebGLRenderingContext.CLAMP_TO_EDGE,wrapT:WebGLRenderingContext.CLAMP_TO_EDGE};t.createFramebuffer=function(e,t){t=n({},i,t);var r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r);var o,u=a.createTexture(e,t);if(e.bindTexture(e.TEXTURE_2D,u),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,u,0),t.stencil||t.depth){var c=t.stencil?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.getExtension("WEBGL_depth_texture")&&(o=a.createTexture(e,{width:t.width,height:t.height,internalFormat:t.stencil?e.DEPTH_STENCIL:e.DEPTH_COMPONENT,srcFormat:t.stencil?e.DEPTH_STENCIL:e.DEPTH_COMPONENT,srcType:e.UNSIGNED_INT,minFilter:e.NEAREST,magFilter:e.NEAREST,wrapS:e.CLAMP_TO_EDGE,wrapT:e.CLAMP_TO_EDGE}),e.bindTexture(e.TEXTURE_2D,o),e.framebufferTexture2D(e.FRAMEBUFFER,c,e.TEXTURE_2D,u,0));var s=e.createRenderbuffer();e.bindRenderbuffer(e.RENDERBUFFER,s),e.renderbufferStorage(e.RENDERBUFFER,t.stencil?e.DEPTH_STENCIL:e.DEPTH_COMPONENT16,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,s)}return{width:t.width,height:t.height,framebuffer:r,texture:u,depthStencilTexture:o}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createElementBuffer=function(e,t,r,n){var a=e.createBuffer(),i=t.length/r;return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,n||e.STATIC_DRAW),{buffer:a,itemSize:r,numItems:i,draw:function(t,r){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.drawElements(t||e.TRIANGLES,i,r||e.UNSIGNED_SHORT,0)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createContext=function(e,t,r){var n,a=window.devicePixelRatio||1,i=function(){e.width=a*e.clientWidth,e.height=a*e.clientHeight};try{n=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),r&&r.forEach(function(e){n.getSupportedExtensions().indexOf(name)&&n.getExtension(e)||console.log("Could not enable extension: "+e)}),i(),window.addEventListener("resize",i)}catch(e){}if(!n)throw new Error("Could not initialise WebGL");return n}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createBuffer=function(e,t,r,n){var a=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,t,n||e.STATIC_DRAW),{type:function(e){switch(e){case"Int8Array":return WebGLRenderingContext.BYTE;case"Int16Array":return WebGLRenderingContext.SHORT;case"Uint8Array":return WebGLRenderingContext.UNSIGNED_BYTE;case"Uint16Array":return WebGLRenderingContext.UNSIGNED_SHORT;case"Float32Array":default:return WebGLRenderingContext.FLOAT}}(t.constructor.name),buffer:a,itemSize:r,numItems:t.length/r}}},function(e,t,r){"use strict";var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e};Object.defineProperty(t,"__esModule",{value:!0});var a=r(1),i=r(3),o={level:0,internalFormat:WebGLRenderingContext.RGBA,border:0,srcFormat:WebGLRenderingContext.RGBA,srcType:WebGLRenderingContext.UNSIGNED_BYTE,mipmap:!1};t.canvasToTexture=function(e,t,r){r=n({},o,r);var u=a.createTexture(e,Object.assign({width:1,height:1},r));return e.bindTexture(e.TEXTURE_2D,u),e.texImage2D(e.TEXTURE_2D,r.level,r.internalFormat,r.srcFormat,r.srcType,t),r.mipmap&&i.generateMipmap(e,u,Object.assign({width:t.width,height:t.height},r)),u}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeObjBuffers=function(e,t){if(!e)return t;var r=e.position.length/3;return{position:e.position.concat(t.position),coords:e.coords.concat(t.coords),indices:e.indices.concat(t.indices.map(function(e){return e+r}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.framebufferToImage=function(e,t,r,n){var a=new Uint8Array(r*n*4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,a);var i=document.createElement("canvas");i.width=r,i.height=n;var o=i.getContext("2d"),u=o.createImageData(r,n);return u.data.set(a),o.putImageData(u,0,0),o.globalCompositeOperation="copy",o.scale(1,-1),o.translate(0,-n),o.drawImage(i,0,0),i.toDataURL("image/png")}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertTrianglesToBufferArrays=function(e){var t=[],r=[],n=[],a=0;return e.forEach(function(e){var i=e.p1,o=e.p2,u=e.p3;t=t.concat([i[0],i[1],0,o[0],o[1],0,u[0],u[1],0]),r=e.curve?r.concat([-1,1,e.curve,0,-1,e.curve,1,1,e.curve]):r.concat([0,0,0,0,0,0,0,0,0]),n=n.concat([a,a+1,a+2]),a+=3}),{position:t,coords:r,indices:n}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.poseToMatrix=function(e,t){var r=t.orientation?t.orientation:[0,0,0,1],n=t.position?t.position:[0,0,0],a=r[0]+r[0],i=r[1]+r[1],o=r[2]+r[2],u=r[0]*a,c=r[0]*i,s=r[0]*o,f=r[1]*i,l=r[1]*o,d=r[2]*o,v=r[3]*a,p=r[3]*i,m=r[3]*o;return e[0]=1-(f+d),e[1]=c+m,e[2]=s-p,e[3]=0,e[4]=c-m,e[5]=1-(u+d),e[6]=l+v,e[7]=0,e[8]=s+p,e[9]=l-v,e[10]=1-(u+f),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);t.loadXML=function(e){return new Promise(function(t,r){var a=new XMLHttpRequest;a.open("GET",e),a.overrideMimeType("text/xml"),a.onreadystatechange=function(){a.readyState===XMLHttpRequest.DONE&&200===a.status&&t(n.xmlToJSON(a.responseXML))},a.send()})}},function(e,t,r){"use strict";var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e};Object.defineProperty(t,"__esModule",{value:!0});var a=r(1),i=r(3),o={level:0,internalFormat:WebGLRenderingContext.RGBA,border:0,srcFormat:WebGLRenderingContext.RGBA,srcType:WebGLRenderingContext.UNSIGNED_BYTE,mipmap:!1,premultiplyAlpha:!0};t.loadTexture=function(e,t,r){r=n({},o,r);var u=new Image,c=a.createTexture(e,Object.assign({width:1,height:1},r)),s={texture:c,image:u,width:0,height:0};return u.onload=function(){s.width=u.width,s.height=u.height,e.bindTexture(e.TEXTURE_2D,c),e.texImage2D(e.TEXTURE_2D,r.level,r.internalFormat,r.srcFormat,r.srcType,u),r.mipmap&&i.generateMipmap(e,c,n({width:u.width,height:u.height},r))},u.src=t,s}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(a,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){e.done?a(e.value):new r(function(t){t(e.value)}).then(o,u)}c((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),o=r(6);t.loadProgram=function(e,t,r){return n(this,void 0,void 0,function(){var n;return a(this,function(a){switch(a.label){case 0:return[4,Promise.all([i.loadFile(t),i.loadFile(r)])];case 1:return n=a.sent(),[2,o.createProgram(e,n[0],n[1])]}})})}},function(e,t,r){"use strict";var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(a,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){e.done?a(e.value):new r(function(t){t(e.value)}).then(o,u)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),u=r(7),c=r(2),s=r(8),f={group:/\bg\s+([^\s]+)\b/,vertex:/\bv\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\b/,texCoord:/\bvt\s+([^\s]+)\s+([^\s]+)\b/,normal:/\bvn\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\b/,triangle:/\bf\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\b/,mtllib:/\bmtllib\s+(.*)\b/,usemtl:/\busemtl\s+(.*)\b/},l=function(e){return parseInt(e,10)-1};t.loadObj=function(e){return a(this,void 0,void 0,function(){var t,r,d,v,p,m,h,E,b,T,_,g,y,w,x,R,A,M,P,L,O,N,F,S,C,I=this;return i(this,function(U){switch(U.label){case 0:return t=u.dirname(e),[4,o.loadFile(e)];case 1:return r=U.sent(),d=r.split("\n"),v=[],p=[],m=[],h={},E=[],b={indices:[]},T={},_={},d.forEach(function(e){return a(I,void 0,void 0,function(){var r,a,o,u,d,g,y,w,x,R,A,M,P,L,O;return i(this,function(i){switch(i.label){case 0:return(r=e.match(f.mtllib))?(a=t+r[1],o=[{},T],[4,s.loadMtl(a)]):[3,2];case 1:return T=n.apply(void 0,o.concat([i.sent()])),[2];case 2:if(r=e.match(f.usemtl))return b.material=r[1],[2];if(r=e.match(f.group))return u=r[1],b={name:u,indices:[]},h[u]=b,[2];if(r=e.match(f.vertex))return y=parseFloat(r[1]),w=parseFloat(r[2]),x=parseFloat(r[3]),E.push(c.vec3.fromValues(y,w,x)),[2];if(r=e.match(f.texCoord))return d=parseFloat(r[1]),g=parseFloat(r[2]),p.push(c.vec2.fromValues(d,g)),[2];if(r=e.match(f.normal))return y=parseFloat(r[1]),w=parseFloat(r[2]),x=parseFloat(r[3]),v.push(c.vec3.fromValues(y,w,x)),[2];if(r=e.match(f.triangle)){for(R=[],A=1,M=Math.min(4,r.length);A<M;A++)P=r[A].split("/").map(l),L=P.join("/"),O=void 0,L in _?O=_[L]:(O=m.push(P)-1,_[L]=O),R.push(O);return b.indices=b.indices.concat(R),[2]}return[2]}})})}),_=null,g=Number.MIN_VALUE,y=Number.MIN_VALUE,w=Number.MIN_VALUE,x=Number.MAX_VALUE,R=Number.MAX_VALUE,A=Number.MAX_VALUE,E.forEach(function(e){g=Math.max(g,e[0]),y=Math.max(y,e[1]),w=Math.max(w,e[2]),x=Math.min(x,e[0]),R=Math.min(R,e[1]),A=Math.min(A,e[2])}),O=(M=g-x)/2+x,N=(P=y-R)/2+R,F=(L=w-A)/2+A,E.forEach(function(e){e[0]-=O,e[1]-=N,e[2]-=F}),S=Math.max(M,Math.max(P,L)),C=1/S,E.forEach(function(e){e[0]*=C,e[1]*=C,e[2]*=C}),[2,{positions:E,normals:v,texCoords:p,vertices:m,groups:h,materials:T}]}})})}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(a,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){e.done?a(e.value):new r(function(t){t(e.value)}).then(o,u)}c((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);t.loadJSON=function(e){return n(this,void 0,void 0,function(){var t,r;return a(this,function(n){switch(n.label){case 0:return r=(t=JSON).parse,[4,i.loadFile(e)];case 1:return[2,r.apply(t,[n.sent()])]}})})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2);t.orbitControls=function(e,t){var r=n.vec3.create(),a=n.vec3.fromValues(0,1,0),i=n.vec3.fromValues(0,0,0),o=Math.PI,u=n.vec2.create(),c=n.vec2.create(),s=n.vec2.create(),f=n.vec2.fromValues(t.clientWidth,t.clientHeight),l=n.vec3.create(),d=n.vec3.create(),v=n.vec3.create(),p=n.vec3.create(),m=n.mat4.create(),h=n.vec3.create(),E=n.vec3.create(),b=n.vec3.create(),T=function(e){window.addEventListener("mousemove",_),window.addEventListener("mouseup",g),n.vec2.set(u,e.pageX,e.pageY)},_=function(t){n.vec2.set(c,t.pageX,t.pageY),n.vec2.subtract(s,c,u),n.vec2.divide(s,s,f),n.vec2.scale(s,s,o),n.vec3.copy(l,r),n.vec3.copy(d,i),n.vec3.negate(v,r),n.vec3.cross(p,v,a),n.vec3.normalize(p,p),1===t.buttons?(n.mat4.identity(m),n.mat4.rotate(m,m,-s[0],a),n.mat4.rotate(m,m,-s[1],p),n.vec3.transformMat4(l,l,m)):2===t.buttons&&(n.vec3.copy(h,p),n.vec3.scale(h,h,1*-s[0]),n.vec3.copy(E,a),n.vec3.scale(E,E,1*s[1]),n.vec3.set(b,0,0,0),n.vec3.add(b,b,h),n.vec3.add(b,b,E),n.vec3.add(l,l,b),n.vec3.add(d,d,b)),n.mat4.lookAt(e,l,d,a)},g=function(){window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",g),n.vec3.copy(r,l),n.vec3.copy(i,d)},y=function(t){n.vec3.scale(r,r,1+(t.deltaY>0?.1:-.1)),n.mat4.lookAt(e,r,i,a)},w=function(e){e.preventDefault()};return n.mat4.getTranslation(r,e),n.vec3.negate(r,r),t.addEventListener("mousedown",T),t.addEventListener("wheel",y),t.addEventListener("contextmenu",w,!1),function(){t.removeEventListener("mousedown",T),t.removeEventListener("wheel",y),t.removeEventListener("contextmenu",w),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",g)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2);t.freenavControls=function(e,t){var r,a=n.vec3.create(),i=n.vec3.create(),o=n.vec3.create(),u=n.mat4.create(),c=n.vec3.create(),s=n.vec3.create(),f=n.vec3.create(),l={x:0,y:0},d={x:0,y:0},v=n.vec3.create(),p=[{keys:[87],action:function(e){b(),n.vec3.scale(v,o,5),n.vec3.add(e,e,v)}},{keys:[83],action:function(e){b(),n.vec3.scale(v,o,-5),n.vec3.add(e,e,v)}},{keys:[65],action:function(e){b(),n.vec3.scale(v,a,5),n.vec3.add(e,e,v)}},{keys:[68],action:function(e){b(),n.vec3.scale(v,a,-5),n.vec3.add(e,e,v)}},{keys:[32],action:function(e){b(),n.vec3.scale(v,i,-5),n.vec3.add(e,e,v)}},{keys:[17,67],action:function(e){b(),n.vec3.scale(v,i,5),n.vec3.add(e,e,v)}}],m={},h=[],E={},b=function(){n.vec3.set(a,e[0],e[4],e[8]),n.vec3.set(i,e[1],e[5],e[9]),n.vec3.set(o,e[2],e[6],e[10])},T=function(t){l.x=t.pageX,l.y=t.pageY,n.mat4.invert(u,e),n.vec3.set(c,u[12],u[13],u[14]),n.vec3.negate(s,c),window.addEventListener("mousemove",g),window.addEventListener("mouseup",y)},_=function(){r=requestAnimationFrame(_),h.length&&(n.vec3.set(f,0,0,0),h.forEach(function(e){e.action(f)}),n.vec3.subtract(c,c,f),n.vec3.negate(s,c),n.mat4.translate(e,e,f))},g=function(r){d.x=(r.pageX-l.x)/t.width,d.y=(r.pageY-l.y)/t.height,b(),n.mat4.translate(e,e,c),n.mat4.rotateY(e,e,d.x*Math.PI),b(),n.mat4.rotate(e,e,d.y*Math.PI,a),n.mat4.translate(e,e,s),l.x=r.pageX,l.y=r.pageY},y=function(){window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",y)},w=function(e){!E.hasOwnProperty(e.which)&&m.hasOwnProperty(e.which)&&h.indexOf(m[e.which])<0&&(E[e.which]=!0,h.push(m[e.which]))},x=function(e){if(E.hasOwnProperty(e.which)&&m.hasOwnProperty(e.which)){delete E[e.which];var t=m[e.which],r=h.indexOf(t);r>=0&&h.splice(r,1)}};return p.forEach(function(e){e.keys.forEach(function(t){m[t]=e})}),r=requestAnimationFrame(_),t.addEventListener("mousedown",T),window.addEventListener("keydown",w),window.addEventListener("keyup",x),function(){cancelAnimationFrame(r),t.removeEventListener("mousedown",T),window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",y),window.removeEventListener("keydown",w),window.removeEventListener("keyup",x)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createRenderer=function(e,t){var r,n,a=0,i=window,o=function(e){r=i.requestAnimationFrame(o),n=e-a,a=e,t(n)};return{isPlaying:function(){return null!==r},stop:function(){i.cancelAnimationFrame(r),r=null},start:function(t){i=t||i,e(),r=i.requestAnimationFrame(o)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(25);t.createRenderer=n.createRenderer;var a=r(24);t.freenavControls=a.freenavControls;var i=r(23);t.orbitControls=i.orbitControls;var o=r(0);t.loadFile=o.loadFile;var u=r(22);t.loadJSON=u.loadJSON;var c=r(8);t.loadMtl=c.loadMtl;var s=r(21);t.loadObj=s.loadObj;var f=r(20);t.loadProgram=f.loadProgram;var l=r(19);t.loadTexture=l.loadTexture;var d=r(18);t.loadXML=d.loadXML;var v=r(17);t.poseToMatrix=v.poseToMatrix;var p=r(16);t.convertTrianglesToBufferArrays=p.convertTrianglesToBufferArrays;var m=r(7);t.dirname=m.dirname;var h=r(15);t.framebufferToImage=h.framebufferToImage;var E=r(5);t.isPowerOf2=E.isPowerOf2;var b=r(14);t.mergeObjBuffers=b.mergeObjBuffers;var T=r(4);t.xmlToJSON=T.xmlToJSON;var _=r(13);t.canvasToTexture=_.canvasToTexture;var g=r(12);t.createBuffer=g.createBuffer;var y=r(11);t.createContext=y.createContext;var w=r(10);t.createElementBuffer=w.createElementBuffer;var x=r(9);t.createFramebuffer=x.createFramebuffer;var R=r(6);t.createProgram=R.createProgram;var A=r(1);t.createTexture=A.createTexture;var M=r(3);t.generateMipmap=M.generateMipmap}])});