/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // (c) Dean McNamee , 2012. // // https://github.com/deanm/css-color-parser-js // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. /** * Grapher.js * * Copyright (c) 2015, Grapher.js * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ (function(e){typeof define!="undefined"&&define.amd?define(["exports"],e):e(window.grapher={})})(function(e){var t,n,r;(function(e){function d(e,t){return h.call(e,t)}function v(e,t){var n,r,i,s,o,u,a,f,c,h,p=t&&t.split("/"),d=l.map,v=d&&d["*"]||{};if(e&&e.charAt(0)===".")if(t){p=p.slice(0,p.length-1),e=p.concat(e.split("/"));for(f=0;f0&&(e.splice(f-1,2),f-=2)}}e=e.join("/")}else e.indexOf("./")===0&&(e=e.substring(2));if((p||v)&&d){n=e.split("/");for(f=n.length;f>0;f-=1){r=n.slice(0,f).join("/");if(p)for(c=p.length;c>0;c-=1){i=d[p.slice(0,c).join("/")];if(i){i=i[r];if(i){s=i,o=f;break}}}if(s)break;!u&&v&&v[r]&&(u=v[r],a=f)}!s&&u&&(s=u,o=a),s&&(n.splice(0,o,s),e=n.join("/"))}return e}function m(t,n){return function(){return s.apply(e,p.call(arguments,0).concat([t,n]))}}function g(e){return function(t){return v(t,e)}}function y(e){return function(t){a[e]=t}}function b(t){if(d(f,t)){var n=f[t];delete f[t],c[t]=!0,i.apply(e,n)}if(!d(a,t)&&!d(c,t))throw new Error("No "+t);return a[t]}function w(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function E(e){return function(){return l&&l.config&&l.config[e]||{}}}var i,s,o,u,a={},f={},l={},c={},h=Object.prototype.hasOwnProperty,p=[].slice;o=function(e,t){var n,r=w(e),i=r[0];return e=r[1],i&&(i=v(i,t),n=b(i)),i?n&&n.normalize?e=n.normalize(e,g(t)):e=v(e,t):(e=v(e,t),r=w(e),i=r[0],e=r[1],i&&(n=b(i))),{f:i?i+"!"+e:e,n:e,pr:i,p:n}},u={require:function(e){return m(e)},exports:function(e){var t=a[e];return typeof t!="undefined"?t:a[e]={}},module:function(e){return{id:e,uri:"",exports:a[e],config:E(e)}}},i=function(t,n,r,i){var s,l,h,p,v,g=[],w;i=i||t;if(typeof r=="function"){n=!n.length&&r.length?["require","exports","module"]:n;for(v=0;v0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},o.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},o.cross=function(e,t,n){var r=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=r,e},o.lerp=function(e,t,n,r){var i=t[0],s=t[1];return e[0]=i+r*(n[0]-i),e[1]=s+r*(n[1]-s),e},o.random=function(e,t){t=t||1;var n=r()*2*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},o.transformMat2=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e},o.transformMat2d=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e},o.transformMat3=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[3]*i+n[6],e[1]=n[1]*r+n[4]*i+n[7],e},o.transformMat4=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e},o.forEach=function(){var e=o.create();return function(t,n,r,i,s,o){var u,a;n||(n=2),r||(r=0),i?a=Math.min(i*n+r,t.length):a=t.length;for(u=r;u0&&(s=1/Math.sqrt(s),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s),e},u.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},u.cross=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=n[0],u=n[1],a=n[2];return e[0]=i*a-s*u,e[1]=s*o-r*a,e[2]=r*u-i*o,e},u.lerp=function(e,t,n,r){var i=t[0],s=t[1],o=t[2];return e[0]=i+r*(n[0]-i),e[1]=s+r*(n[1]-s),e[2]=o+r*(n[2]-o),e},u.random=function(e,t){t=t||1;var n=r()*2*Math.PI,i=r()*2-1,s=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(n)*s,e[1]=Math.sin(n)*s,e[2]=i*t,e},u.transformMat4=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=n[3]*r+n[7]*i+n[11]*s+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*i+n[8]*s+n[12])/o,e[1]=(n[1]*r+n[5]*i+n[9]*s+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*s+n[14])/o,e},u.transformMat3=function(e,t,n){var r=t[0],i=t[1],s=t[2];return e[0]=r*n[0]+i*n[3]+s*n[6],e[1]=r*n[1]+i*n[4]+s*n[7],e[2]=r*n[2]+i*n[5]+s*n[8],e},u.transformQuat=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=n[0],u=n[1],a=n[2],f=n[3],l=f*r+u*s-a*i,c=f*i+a*r-o*s,h=f*s+o*i-u*r,p=-o*r-u*i-a*s;return e[0]=l*f+p*-o+c*-a-h*-u,e[1]=c*f+p*-u+h*-o-l*-a,e[2]=h*f+p*-a+l*-u-c*-o,e},u.rotateX=function(e,t,n,r){var i=[],s=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],s[0]=i[0],s[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),s[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=s[0]+n[0],e[1]=s[1]+n[1],e[2]=s[2]+n[2],e},u.rotateY=function(e,t,n,r){var i=[],s=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],s[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),s[1]=i[1],s[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=s[0]+n[0],e[1]=s[1]+n[1],e[2]=s[2]+n[2],e},u.rotateZ=function(e,t,n,r){var i=[],s=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],s[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),s[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),s[2]=i[2],e[0]=s[0]+n[0],e[1]=s[1]+n[1],e[2]=s[2]+n[2],e},u.forEach=function(){var e=u.create();return function(t,n,r,i,s,o){var u,a;n||(n=3),r||(r=0),i?a=Math.min(i*n+r,t.length):a=t.length;for(u=r;u1?0:Math.acos(i)},u.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},typeof e!="undefined"&&(e.vec3=u);var a={};a.create=function(){var e=new n(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},a.clone=function(e){var t=new n(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},a.fromValues=function(e,t,r,i){var s=new n(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s},a.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},a.set=function(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e},a.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},a.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e},a.sub=a.subtract,a.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},a.mul=a.multiply,a.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e},a.div=a.divide,a.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e},a.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e},a.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},a.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e},a.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],s=t[3]-e[3];return Math.sqrt(n*n+r*r+i*i+s*s)},a.dist=a.distance,a.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],s=t[3]-e[3];return n*n+r*r+i*i+s*s},a.sqrDist=a.squaredDistance,a.length=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return Math.sqrt(t*t+n*n+r*r+i*i)},a.len=a.length,a.squaredLength=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i},a.sqrLen=a.squaredLength,a.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},a.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},a.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=n*n+r*r+i*i+s*s;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3]*o),e},a.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},a.lerp=function(e,t,n,r){var i=t[0],s=t[1],o=t[2],u=t[3];return e[0]=i+r*(n[0]-i),e[1]=s+r*(n[1]-s),e[2]=o+r*(n[2]-o),e[3]=u+r*(n[3]-u),e},a.random=function(e,t){return t=t||1,e[0]=r(),e[1]=r(),e[2]=r(),e[3]=r(),a.normalize(e,e),a.scale(e,e,t),e},a.transformMat4=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*s+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*s+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*s+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*s+n[15]*o,e},a.transformQuat=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=n[0],u=n[1],a=n[2],f=n[3],l=f*r+u*s-a*i,c=f*i+a*r-o*s,h=f*s+o*i-u*r,p=-o*r-u*i-a*s;return e[0]=l*f+p*-o+c*-a-h*-u,e[1]=c*f+p*-u+h*-o-l*-a,e[2]=h*f+p*-a+l*-u-c*-o,e},a.forEach=function(){var e=a.create();return function(t,n,r,i,s,o){var u,a;n||(n=4),r||(r=0),i?a=Math.min(i*n+r,t.length):a=t.length;for(u=r;u.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(u.cross(e,i,s),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,p.normalize(r,r))}}(),p.setAxes=function(){var e=c.create();return function(t,n,r,i){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],p.normalize(t,p.fromMat3(t,e))}}(),p.clone=a.clone,p.fromValues=a.fromValues,p.copy=a.copy,p.set=a.set,p.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},p.setAxisAngle=function(e,t,n){n*=.5;var r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e},p.add=a.add,p.multiply=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=n[0],a=n[1],f=n[2],l=n[3];return e[0]=r*l+o*u+i*f-s*a,e[1]=i*l+o*a+s*u-r*f,e[2]=s*l+o*f+r*a-i*u,e[3]=o*l-r*u-i*a-s*f,e},p.mul=p.multiply,p.scale=a.scale,p.rotateX=function(e,t,n){n*=.5;var r=t[0],i=t[1],s=t[2],o=t[3],u=Math.sin(n),a=Math.cos(n);return e[0]=r*a+o*u,e[1]=i*a+s*u,e[2]=s*a-i*u,e[3]=o*a-r*u,e},p.rotateY=function(e,t,n){n*=.5;var r=t[0],i=t[1],s=t[2],o=t[3],u=Math.sin(n),a=Math.cos(n);return e[0]=r*a-s*u,e[1]=i*a+o*u,e[2]=s*a+r*u,e[3]=o*a-i*u,e},p.rotateZ=function(e,t,n){n*=.5;var r=t[0],i=t[1],s=t[2],o=t[3],u=Math.sin(n),a=Math.cos(n);return e[0]=r*a+i*u,e[1]=i*a-r*u,e[2]=s*a+o*u,e[3]=o*a-s*u,e},p.calculateW=function(e,t){var n=t[0],r=t[1],i=t[2];return e[0]=n,e[1]=r,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),e},p.dot=a.dot,p.lerp=a.lerp,p.slerp=function(e,t,n,r){var i=t[0],s=t[1],o=t[2],u=t[3],a=n[0],f=n[1],l=n[2],c=n[3],h,p,d,v,m;return p=i*a+s*f+o*l+u*c,p<0&&(p=-p,a=-a,f=-f,l=-l,c=-c),1-p>1e-6?(h=Math.acos(p),d=Math.sin(h),v=Math.sin((1-r)*h)/d,m=Math.sin(r*h)/d):(v=1-r,m=r),e[0]=v*i+m*a,e[1]=v*s+m*f,e[2]=v*o+m*l,e[3]=v*u+m*c,e},p.invert=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=n*n+r*r+i*i+s*s,u=o?1/o:0;return e[0]=-n*u,e[1]=-r*u,e[2]=-i*u,e[3]=s*u,e},p.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},p.length=a.length,p.len=p.length,p.squaredLength=a.squaredLength,p.sqrLen=p.squaredLength,p.normalize=a.normalize,p.fromMat3=function(e,t){var n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[i*3+i]&&(i=2);var s=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[i*3+i]-t[s*3+s]-t[o*3+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[s*3+o]-t[o*3+s])*r,e[s]=(t[s*3+i]+t[i*3+s])*r,e[o]=(t[o*3+i]+t[i*3+o])*r}return e},p.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},typeof e!="undefined"&&(e.quat=p)}(t.exports)}(this),r("qtek/Geometry",["require","./core/Base","./core/glenum","./core/Cache","./core/vendor","./dep/glmatrix"],function(e){function h(e,t,n,r,i){this.name=e,this.type=t,this.size=n,r&&(this.semantic=r),i?(this._isDynamic=!0,this.value=[]):(this._isDynamic=!1,this.value=null);switch(n){case 1:this.get=function(e){return this.value[e]},this.set=function(e,t){this.value[e]=t};break;case 2:i?(this.get=function(e,t){var n=this.value[e];return n&&c(t,n),t},this.set=function(e,t){var n=this.value[e];n||(n=this.value[e]=o.create()),c(n,t)}):(this.get=function(e,t){var n=this.value;return t[0]=n[e*2],t[1]=n[e*2+1],t},this.set=function(e,t){var n=this.value;n[e*2]=t[0],n[e*2+1]=t[1]});break;case 3:i?(this.get=function(e,t){var n=this.value[e];return n&&l(t,n),t},this.set=function(e,t){var n=this.value[e];n||(n=this.value[e]=u.create()),l(n,t)}):(this.get=function(e,t){var n=e*3,r=this.value;return t[0]=r[n++],t[1]=r[n++],t[2]=r[n++],t},this.set=function(e,t){var n=e*3,r=this.value;r[n++]=t[0],r[n++]=t[1],r[n++]=t[2]});break;case 4:i?(this.get=function(e,t){var n=this.value[e];return n&&f(t,n),t},this.set=function(e,t){var n=this.value[e];n||(n=this.value[e]=a.create()),f(n,t)}):(this.get=function(e,t){var n=this.value,r=e*4;return t[0]=n[r++],t[1]=n[r++],t[2]=n[r++],t[3]=n[r++],t},this.set=function(e,t){var n=this.value,r=e*4;n[r++]=t[0],n[r++]=t[1],n[r++]=t[2],n[r++]=t[3]})}}function p(e,t,n,r,i){this.name=e,this.type=t,this.buffer=n,this.size=r,this.semantic=i,this.symbol=""}function d(e){this.buffer=e,this.count=0}function v(){console.warn("Geometry doesn't implement this method, use DynamicGeometry or StaticGeometry instead")}var t=e("./core/Base"),n=e("./core/glenum"),r=e("./core/Cache"),i=e("./core/vendor"),s=e("./dep/glmatrix"),o=s.vec2,u=s.vec3,a=s.vec4,f=a.copy,l=u.copy,c=o.copy;h.prototype.init=function(e){if(!this._isDynamic){if(!this.value||this.value.length!=e*this.size){var t;switch(this.type){case"byte":t=i.Int8Array;break;case"ubyte":t=i.Uint8Array;break;case"short":t=i.Int16Array;break;case"ushort":t=i.Uint16Array;break;default:t=i.Float32Array}this.value=new t(e*this.size)}}else console.warn("Dynamic geometry not support init method")},h.prototype.clone=function(e){var t=new h(this.name,this.type,this.size,this.semantic,this._isDynamic);return e&&console.warn("todo"),t};var m=t.derive({boundingBox:null,attributes:{},faces:null,dynamic:!1,useFace:!0},function(){this._cache=new r,this._attributeList=Object.keys(this.attributes)},{pickByRay:null,mainAttribute:"position",dirty:v,createAttribute:v,removeAttribute:v,getVertexNumber:v,getFaceNumber:v,getFace:v,isUseFace:v,getEnabledAttributes:v,getBufferChunks:v,generateVertexNormals:v,generateFaceNormals:v,isUniqueVertex:v,generateUniqueVertex:v,generateTangents:v,generateBarycentric:v,applyTransform:v,dispose:v});return m.STATIC_DRAW=n.STATIC_DRAW,m.DYNAMIC_DRAW=n.DYNAMIC_DRAW,m.STREAM_DRAW=n.STREAM_DRAW,m.AttributeBuffer=p,m.IndicesBuffer=d,m.Attribute=h,m}),r("qtek/math/Vector3",["require","../dep/glmatrix"],function(e){function a(e,t,n){return en?n:e}var t=e("../dep/glmatrix"),n=t.vec3,r="_array",i="_dirty",s=function(e,t,s){e=e||0,t=t||0,s=s||0,this[r]=n.fromValues(e,t,s),this[i]=!0};s.prototype={constructor:s,add:function(e){return n.add(this[r],this[r],e[r]),this[i]=!0,this},set:function(e,t,n){return this[r][0]=e,this[r][1]=t,this[r][2]=n,this[i]=!0,this},setArray:function(e){return this[r][0]=e[0],this[r][1]=e[1],this[r][2]=e[2],this[i]=!0,this},clone:function(){return new s(this.x,this.y,this.z)},copy:function(e){return n.copy(this[r],e[r]),this[i]=!0,this},cross:function(e,t){return n.cross(this[r],e[r],t[r]),this[i]=!0,this},dist:function(e){return n.dist(this[r],e[r])},distance:function(e){return n.distance(this[r],e[r])},div:function(e){return n.div(this[r],this[r],e[r]),this[i]=!0,this},divide:function(e){return n.divide(this[r],this[r],e[r]),this[i]=!0,this},dot:function(e){return n.dot(this[r],e[r])},len:function(){return n.len(this[r])},length:function(){return n.length(this[r])},lerp:function(e,t,s){return n.lerp(this[r],e[r],t[r],s),this[i]=!0,this},min:function(e){return n.min(this[r],this[r],e[r]),this[i]=!0,this},max:function(e){return n.max(this[r],this[r],e[r]),this[i]=!0,this},mul:function(e){return n.mul(this[r],this[r],e[r]),this[i]=!0,this},multiply:function(e){return n.multiply(this[r],this[r],e[r]),this[i]=!0,this},negate:function(){return n.negate(this[r],this[r]),this[i]=!0,this},normalize:function(){return n.normalize(this[r],this[r]),this[i]=!0,this},random:function(e){return n.random(this[r],e),this[i]=!0,this},scale:function(e){return n.scale(this[r],this[r],e),this[i]=!0,this},scaleAndAdd:function(e,t){return n.scaleAndAdd(this[r],this[r],e[r],t),this[i]=!0,this},sqrDist:function(e){return n.sqrDist(this[r],e[r])},squaredDistance:function(e){return n.squaredDistance(this[r],e[r])},sqrLen:function(){return n.sqrLen(this[r])},squaredLength:function(){return n.squaredLength(this[r])},sub:function(e){return n.sub(this[r],this[r],e[r]),this[i]=!0,this},subtract:function(e){return n.subtract(this[r],this[r],e[r]),this[i]=!0,this},transformMat3:function(e){return n.transformMat3(this[r],this[r],e[r]),this[i]=!0,this},transformMat4:function(e){return n.transformMat4(this[r],this[r],e[r]),this[i]=!0,this},transformQuat:function(e){return n.transformQuat(this[r],this[r],e[r]),this[i]=!0,this},applyProjection:function(e){var t=this[r];e=e[r];if(e[15]===0){var n=-1/t[2];t[0]=e[0]*t[0]*n,t[1]=e[5]*t[1]*n,t[2]=(e[10]*t[2]+e[14])*n}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this[i]=!0,this},eulerFromQuaternion:function(e,t){s.eulerFromQuaternion(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this[r],",")+"]"}};var o=Object.defineProperty;if(o){var u=s.prototype;o(u,"x",{get:function(){return this[r][0]},set:function(e){this[r][0]=e,this[i]=!0}}),o(u,"y",{get:function(){return this[r][1]},set:function(e){this[r][1]=e,this[i]=!0}}),o(u,"z",{get:function(){return this[r][2]},set:function(e){this[r][2]=e,this[i]=!0}})}return s.add=function(e,t,s){return n.add(e[r],t[r],s[r]),e[i]=!0,e},s.set=function(e,t,s,o){n.set(e[r],t,s,o),e[i]=!0},s.copy=function(e,t){return n.copy(e[r],t[r]),e[i]=!0,e},s.cross=function(e,t,s){return n.cross(e[r],t[r],s[r]),e[i]=!0,e},s.dist=function(e,t){return n.distance(e[r],t[r])},s.distance=s.dist,s.div=function(e,t,s){return n.divide(e[r],t[r],s[r]),e[i]=!0,e},s.divide=s.div,s.dot=function(e,t){return n.dot(e[r],t[r])},s.len=function(e){return n.length(e[r])},s.lerp=function(e,t,s,o){return n.lerp(e[r],t[r],s[r],o),e[i]=!0,e},s.min=function(e,t,s){return n.min(e[r],t[r],s[r]),e[i]=!0,e},s.max=function(e,t,s){return n.max(e[r],t[r],s[r]),e[i]=!0,e},s.mul=function(e,t,s){return n.multiply(e[r],t[r],s[r]),e[i]=!0,e},s.multiply=s.mul,s.negate=function(e,t){return n.negate(e[r],t[r]),e[i]=!0,e},s.normalize=function(e,t){return n.normalize(e[r],t[r]),e[i]=!0,e},s.random=function(e,t){return n.random(e[r],t),e[i]=!0,e},s.scale=function(e,t,s){return n.scale(e[r],t[r],s),e[i]=!0,e},s.scaleAndAdd=function(e,t,s,o){return n.scaleAndAdd(e[r],t[r],s[r],o),e[i]=!0,e},s.sqrDist=function(e,t){return n.sqrDist(e[r],t[r])},s.squaredDistance=s.sqrDist,s.sqrLen=function(e){return n.sqrLen(e[r])},s.squaredLength=s.sqrLen,s.sub=function(e,t,s){return n.subtract(e[r],t[r],s[r]),e[i]=!0,e},s.subtract=s.sub,s.transformMat3=function(e,t,s){return n.transformMat3(e[r],t[r],s[r]),e[i]=!0,e},s.transformMat4=function(e,t,s){return n.transformMat4(e[r],t[r],s[r]),e[i]=!0,e},s.transformQuat=function(e,t,s){return n.transformQuat(e[r],t[r],s[r]),e[i]=!0,e},s.eulerFromQuaternion=function(e,t,n){e=e[r],t=t[r];var s=t[0],o=t[1],u=t[2],f=t[3],l=s*s,c=o*o,h=u*u,p=f*f,d=Math.atan2,v=Math.asin;switch(n&&n.toUpperCase()){case"YXZ":e[0]=v(a(2*(s*f-o*u),-1,1)),e[1]=d(2*(s*u+o*f),p-l-c+h),e[2]=d(2*(s*o+u*f),p-l+c-h);break;case"ZXY":e[0]=v(a(2*(s*f+o*u),-1,1)),e[1]=d(2*(o*f-u*s),p-l-c+h),e[2]=d(2*(u*f-s*o),p-l+c-h);break;case"ZYX":e[0]=d(2*(s*f+u*o),p-l-c+h),e[1]=v(a(2*(o*f-s*u),-1,1)),e[2]=d(2*(s*o+u*f),p+l-c-h);break;case"YZX":e[0]=d(2*(s*f-u*o),p-l+c-h),e[1]=d(2*(o*f-s*u),p+l-c-h),e[2]=v(a(2*(s*o+u*f),-1,1));break;case"XZY":e[0]=d(2*(s*f+o*u),p-l+c-h),e[1]=d(2*(s*u+o*f),p+l-c-h),e[2]=v(a(2*(u*f-s*o),-1,1));break;case"XYZ":default:e[0]=d(2*(s*f-o*u),p-l-c+h),e[1]=v(a(2*(s*u+o*f),-1,1)),e[2]=d(2*(u*f-s*o),p+l-c-h)}return e[i]=!0,e},s.POSITIVE_X=new s(1,0,0),s.NEGATIVE_X=new s(-1,0,0),s.POSITIVE_Y=new s(0,1,0),s.NEGATIVE_Y=new s(0,-1,0),s.POSITIVE_Z=new s(0,0,1),s.NEGATIVE_Z=new s(0,0,-1),s.UP=new s(0,1,0),s.ZERO=new s(0,0,0),s}),r("qtek/math/BoundingBox",["require","./Vector3","../dep/glmatrix"],function(e){var t=e("./Vector3"),n=e("../dep/glmatrix"),r=n.vec3,i=r.transformMat4,s=r.copy,o=r.set,u=function(e,n){this.min=e||new t(Infinity,Infinity,Infinity),this.max=n||new t(-Infinity,-Infinity,-Infinity);var i=[];for(var s=0;s<8;s++)i[s]=r.fromValues(0,0,0);this.vertices=i};return u.prototype={constructor:u,updateFromVertices:function(e){if(e.length>0){var t=this.min,n=this.max,r=t._array,i=n._array;s(r,e[0]),s(i,e[0]);for(var o=1;oi[0]&&(i[0]=u[0]),u[1]>i[1]&&(i[1]=u[1]),u[2]>i[2]&&(i[2]=u[2])}t._dirty=!0,n._dirty=!0}},union:function(e){var t=this.min,n=this.max;r.min(t._array,t._array,e.min._array),r.max(n._array,n._array,e.max._array),t._dirty=!0,n._dirty=!0},intersectBoundingBox:function(e){var t=this.min._array,n=this.max._array,r=e.min._array,i=e.max._array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||n[0]u[0]&&(u[0]=f[0]),f[1]>u[1]&&(u[1]=f[1]),f[2]>u[2]&&(u[2]=f[2]);t._dirty=!0,n._dirty=!0},applyProjection:function(e){var t=this.min,n=this.max;(t._dirty||n._dirty)&&this.updateVertices();var r=e._array,i=this.vertices,s=i[0],o=i[3],u=i[7],a=t._array,f=n._array;if(r[15]===1)a[0]=r[0]*s[0]+r[12],a[1]=r[5]*s[1]+r[13],f[2]=r[10]*s[2]+r[14],f[0]=r[0]*u[0]+r[12],f[1]=r[5]*u[1]+r[13],a[2]=r[10]*u[2]+r[14];else{var l=-1/s[2];a[0]=r[0]*s[0]*l,a[1]=r[5]*s[1]*l,f[2]=(r[10]*s[2]+r[14])*l,l=-1/o[2],f[0]=r[0]*o[0]*l,f[1]=r[5]*o[1]*l,l=-1/u[2],a[2]=(r[10]*u[2]+r[14])*l}t._dirty=!0,n._dirty=!0},updateVertices:function(){var e=this.min._array,t=this.max._array,n=this.vertices;o(n[0],e[0],e[1],e[2]),o(n[1],e[0],t[1],e[2]),o(n[2],t[0],e[1],e[2]),o(n[3],t[0],t[1],e[2]),o(n[4],e[0],e[1],t[2]),o(n[5],e[0],t[1],t[2]),o(n[6],t[0],e[1],t[2]),o(n[7],t[0],t[1],t[2])},copy:function(e){var t=this.min,n=this.max;s(t._array,e.min._array),s(n._array,e.max._array),t._dirty=!0,n._dirty=!0},clone:function(){var e=new u;return e.copy(this),e}},u}),r("qtek/core/glinfo",[],function(){var e=["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","OES_standard_derivatives","OES_vertex_array_object","OES_element_index_uint","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","EXT_texture_filter_anisotropic","EXT_shader_texture_lod","WEBGL_draw_buffers"],t=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"],n={},r={},i={initialize:function(i){var s=i.__GLID__;if(n[s])return;n[s]={},r[s]={};for(var o=0;o=0)return t||(t=u.create()),u.copy(t,this.faces[e]),t},isUseFace:function(){return this.useFace&&this.faces.length>0},isSplitted:function(){return this.getVertexNumber()>65535},createAttribute:function(e,t,n,r){var i=new h(e,t,n,r,!0);return this.attributes[e]=i,this._attributeList.push(e),i},removeAttribute:function(e){var t=this._attributeList,n=t.indexOf(e);return n>=0?(t.splice(n,1),delete this.attributes[e],!0):!1},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;var n={},r=this.getVertexNumber();for(var i=0;i65535&&this.isUseFace()&&!n){var h=0,p,d=[0],v=[];for(g=0;g65535&&(h++,d[h]=g,m=0,p=l(h));for(var w=0;w<3;w++){var E=y[w],S=o[E]===-1;for(var x=0;x65535?Uint32Array:Uint16Array;P=A.indicesArray=new B(this.faces.length*3)}var D=0;for(var g=0;g=0;o--)if(f[o].name===m){E=f[o],v=o;break}}var S;E?S=E.buffer:S=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,S),e.bufferData(e.ARRAY_BUFFER,h[m],this.hint),f[d++]=new t.AttributeBuffer(m,y,S,w,b)}f.length=d,r&&(l||(l=new t.IndicesBuffer(e.createBuffer()),a.indicesBuffer=l),l.count=p.length,e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l.buffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,p,this.hint))}},generateVertexNormals:function(){var e=this.faces,t=e.length,n=this.attributes,r=n.position.value,i=n.normal.value,s=l(),o=l(),a=l();for(var c=0;c0){for(var f=0;f1)console.warn("Large geometry will discard chunks when convert to StaticGeometry");else if(this._arrayChunks.length===0)return e;var r=this._arrayChunks[0],i=this.getEnabledAttributes();for(var s in i){var o=i[s],u=e.attributes[s];u||(u=e.attributes[s]={type:o.type,size:o.size,value:null},o.semantic&&(u.semantic=o.semantic)),u.value=r.attributeArrays[s]}return e.faces=r.indicesArray,this.boundingBox&&(e.boundingBox=new n,e.boundingBox.min.copy(this.boundingBox.min),e.boundingBox.max.copy(this.boundingBox.max)),e},applyTransform:function(e){var t=this.attributes,n=t.position.value,r=t.normal.value,i=t.tangent.value,s=u.transformMat4;e=e._array;for(var o=0;o255?255:e}function n(e){return e<0?0:e>1?1:e}function r(e){return e[e.length-1]==="%"?t(parseFloat(e)/100*255):t(parseInt(e))}function i(e){return e[e.length-1]==="%"?n(parseFloat(e)/100):n(parseFloat(e))}function s(e,t,n){return n<0?n+=1:n>1&&(n-=1),n*6<1?e+(t-e)*n*6:n*2<1?t:n*3<2?e+(t-e)*(2/3-n)*6:e}function o(n){var o=n.replace(/ /g,"").toLowerCase();if(o in e)return e[o].slice();if(o[0]==="#"){if(o.length===4){var u=parseInt(o.substr(1),16);return u>=0&&u<=4095?[(u&3840)>>4|(u&3840)>>8,u&240|(u&240)>>4,u&15|(u&15)<<4,1]:null}if(o.length===7){var u=parseInt(o.substr(1),16);return u>=0&&u<=16777215?[(u&16711680)>>16,(u&65280)>>8,u&255,1]:null}return null}var a=o.indexOf("("),f=o.indexOf(")");if(a!==-1&&f+1===o.length){var l=o.substr(0,a),c=o.substr(a+1,f-(a+1)).split(","),h=1;switch(l){case"rgba":if(c.length!==4)return null;h=i(c.pop());case"rgb":if(c.length!==3)return null;return[r(c[0]),r(c[1]),r(c[2]),h];case"hsla":if(c.length!==4)return null;h=i(c.pop());case"hsl":if(c.length!==3)return null;var p=(parseFloat(c[0])%360+360)%360/360,d=i(c[1]),v=i(c[2]),m=v<=.5?v*(d+1):v+d-v*d,g=v*2-m;return[t(s(g,m,p+1/3)*255),t(s(g,m,p)*255),t(s(g,m,p-1/3)*255),h];default:return null}}return null}var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};return{parse:function(e){var t=o(e);return t[0]/=255,t[1]/=255,t[2]/=255,t}}}),r("qtek/math/Quaternion",["require","../dep/glmatrix"],function(e){var t=e("../dep/glmatrix"),n=t.quat,r="_array",i="_dirty",s=function(e,t,s,o){e=e||0,t=t||0,s=s||0,o=o===undefined?1:o,this[r]=n.fromValues(e,t,s,o),this[i]=!0};s.prototype={constructor:s,add:function(e){return n.add(this[r],this[r],e[r]),this[i]=!0,this},calculateW:function(){return n.calculateW(this[r],this[r]),this[i]=!0,this},set:function(e,t,n,s){return this[r][0]=e,this[r][1]=t,this[r][2]=n,this[r][3]=s,this[i]=!0,this},setArray:function(e){return this[r][0]=e[0],this[r][1]=e[1],this[r][2]=e[2],this[r][3]=e[3],this[i]=!0,this},clone:function(){return new s(this.x,this.y,this.z,this.w)},conjugate:function(){return n.conjugate(this[r],this[r]),this[i]=!0,this},copy:function(e){return n.copy(this[r],e[r]),this[i]=!0,this},dot:function(e){return n.dot(this[r],e[r])},fromMat3:function(e){return n.fromMat3(this[r],e[r]),this[i]=!0,this},fromMat4:function(){var e=t.mat3,s=e.create();return function(t){return e.fromMat4(s,t[r]),e.transpose(s,s),n.fromMat3(this[r],s),this[i]=!0,this}}(),identity:function(){return n.identity(this[r]),this[i]=!0,this},invert:function(){return n.invert(this[r],this[r]),this[i]=!0,this},len:function(){return n.len(this[r])},length:function(){return n.length(this[r])},lerp:function(e,t,s){return n.lerp(this[r],e[r],t[r],s),this[i]=!0,this},mul:function(e){return n.mul(this[r],this[r],e[r]),this[i]=!0,this},mulLeft:function(e){return n.multiply(this[r],e[r],this[r]),this[i]=!0,this},multiply:function(e){return n.multiply(this[r],this[r],e[r]),this[i]=!0,this},multiplyLeft:function(e){return n.multiply(this[r],e[r],this[r]),this[i]=!0,this},normalize:function(){return n.normalize(this[r],this[r]),this[i]=!0,this},rotateX:function(e){return n.rotateX(this[r],this[r],e),this[i]=!0,this},rotateY:function(e){return n.rotateY(this[r],this[r],e),this[i]=!0,this},rotateZ:function(e){return n.rotateZ(this[r],this[r],e),this[i]=!0,this},rotationTo:function(e,t){return n.rotationTo(this[r],e[r],t[r]),this[i]=!0,this},setAxes:function(e,t,s){return n.setAxes(this[r],e[r],t[r],s[r]),this[i]=!0,this},setAxisAngle:function(e,t){return n.setAxisAngle(this[r],e[r],t),this[i]=!0,this},slerp:function(e,t,s){return n.slerp(this[r],e[r],t[r],s),this[i]=!0,this},sqrLen:function(){return n.sqrLen(this[r])},squaredLength:function(){return n.squaredLength(this[r])},setFromEuler:function(e){},toString:function(){return"["+Array.prototype.join.call(this[r],",")+"]"}};var o=Object.defineProperty;if(o){var u=s.prototype;o(u,"x",{get:function(){return this[r][0]},set:function(e){this[r][0]=e,this[i]=!0}}),o(u,"y",{get:function(){return this[r][1]},set:function(e){this[r][1]=e,this[i]=!0}}),o(u,"z",{get:function(){return this[r][2]},set:function(e){this[r][2]=e,this[i]=!0}}),o(u,"w",{get:function(){return this[r][3]},set:function(e){this[r][3]=e,this[i]=!0}})}return s.add=function(e,t,s){return n.add(e[r],t[r],s[r]),e[i]=!0,e},s.set=function(e,t,s,o,u){n.set(e[r],t,s,o,u),e[i]=!0},s.copy=function(e,t){return n.copy(e[r],t[r]),e[i]=!0,e},s.calculateW=function(e,t){return n.calculateW(e[r],t[r]),e[i]=!0,e},s.conjugate=function(e,t){return n.conjugate(e[r],t[r]),e[i]=!0,e},s.identity=function(e){return n.identity(e[r]),e[i]=!0,e},s.invert=function(e,t){return n.invert(e[r],t[r]),e[i]=!0,e},s.dot=function(e,t){return n.dot(e[r],t[r])},s.len=function(e){return n.length(e[r])},s.lerp=function(e,t,s,o){return n.lerp(e[r],t[r],s[r],o),e[i]=!0,e},s.slerp=function(e,t,s,o){return n.slerp(e[r],t[r],s[r],o),e[i]=!0,e},s.mul=function(e,t,s){return n.multiply(e[r],t[r],s[r]),e[i]=!0,e},s.multiply=s.mul,s.rotateX=function(e,t,s){return n.rotateX(e[r],t[r],s),e[i]=!0,e},s.rotateY=function(e,t,s){return n.rotateY(e[r],t[r],s),e[i]=!0,e},s.rotateZ=function(e,t,s){return n.rotateZ(e[r],t[r],s),e[i]=!0,e},s.setAxisAngle=function(e,t,s){return n.setAxisAngle(e[r],t[r],s),e[i]=!0,e},s.normalize=function(e,t){return n.normalize(e[r],t[r]),e[i]=!0,e},s.sqrLen=function(e){return n.sqrLen(e[r])},s.squaredLength=s.sqrLen,s.fromMat3=function(e,t){return n.fromMat3(e[r],t[r]),e[i]=!0,e},s.setAxes=function(e,t,s,o){return n.setAxes(e[r],t[r],s[r],o[r]),e[i]=!0,e},s.rotationTo=function(e,t,s){return n.rotationTo(e[r],t[r],s[r]),e[i]=!0,e},s}),r("qtek/math/Matrix4",["require","../dep/glmatrix","./Vector3"],function(e){var t=e("../dep/glmatrix"),n=e("./Vector3"),r=t.mat4,i=t.vec3,s=t.mat3,o=t.quat,u="_array",a="_dirty",f=function(){this._axisX=new n,this._axisY=new n,this._axisZ=new n,this[u]=r.create(),this[a]=!0};f.prototype={constructor:f,adjoint:function(){return r.adjoint(this[u],this[u]),this[a]=!0,this},clone:function(){return(new f).copy(this)},copy:function(e){return r.copy(this[u],e[u]),this[a]=!0,this},determinant:function(){return r.determinant(this[u])},fromQuat:function(e){return r.fromQuat(this[u],e[u]),this[a]=!0,this},fromRotationTranslation:function(e,t){return r.fromRotationTranslation(this[u],e[u],t[u]),this[a]=!0,this},fromMat2d:function(e){return f.fromMat2d(this,e),this},frustum:function(e,t,n,i,s,o){return r.frustum(this[u],e,t,n,i,s,o),this[a]=!0,this},identity:function(){return r.identity(this[u]),this[a]=!0,this},invert:function(){return r.invert(this[u],this[u]),this[a]=!0,this},lookAt:function(e,t,n){return r.lookAt(this[u],e[u],t[u],n[u]),this[a]=!0,this},mul:function(e){return r.mul(this[u],this[u],e[u]),this[a]=!0,this},mulLeft:function(e){return r.mul(this[u],e[u],this[u]),this[a]=!0,this},multiply:function(e){return r.multiply(this[u],this[u],e[u]),this[a]=!0,this},multiplyLeft:function(e){return r.multiply(this[u],e[u],this[u]),this[a]=!0,this},ortho:function(e,t,n,i,s,o){return r.ortho(this[u],e,t,n,i,s,o),this[a]=!0,this},perspective:function(e,t,n,i){return r.perspective(this[u],e,t,n,i),this[a]=!0,this},rotate:function(e,t){return r.rotate(this[u],this[u],e,t[u]),this[a]=!0,this},rotateX:function(e){return r.rotateX(this[u],this[u],e),this[a]=!0,this},rotateY:function(e){return r.rotateY(this[u],this[u],e),this[a]=!0,this},rotateZ:function(e){return r.rotateZ(this[u],this[u],e),this[a]=!0,this},scale:function(e){return r.scale(this[u],this[u],e[u]),this[a]=!0,this},translate:function(e){return r.translate(this[u],this[u],e[u]),this[a]=!0,this},transpose:function(){return r.transpose(this[u],this[u]),this[a]=!0,this},decomposeMatrix:function(){var e=i.create(),t=i.create(),n=i.create(),r=s.create();return function(f,l,c){var h=this[u];i.set(e,h[0],h[1],h[2]),i.set(t,h[4],h[5],h[6]),i.set(n,h[8],h[9],h[10]);var p=i.length(e),d=i.length(t),v=i.length(n);f&&(f.x=p,f.y=d,f.z=v,f[a]=!0),c.set(h[12],h[13],h[14]),s.fromMat4(r,h),r[0]/=p,r[1]/=p,r[2]/=p,r[3]/=d,r[4]/=d,r[5]/=d,r[6]/=v,r[7]/=v,r[8]/=v,o.fromMat3(l[u],r),o.normalize(l[u],l[u]),l[a]=!0,c[a]=!0}}(),toString:function(){return"["+Array.prototype.join.call(this[u],",")+"]"}};var l=Object.defineProperty;if(l){var c=f.prototype;l(c,"z",{get:function(){var e=this[u];return this._axisZ.set(e[8],e[9],e[10]),this._axisZ},set:function(e){var t=this[u];e=e[u],t[8]=e[0],t[9]=e[1],t[10]=e[2],this[a]=!0}}),l(c,"y",{get:function(){var e=this[u];return this._axisY.set(e[4],e[5],e[6]),this._axisY},set:function(e){var t=this[u];e=e[u],t[4]=e[0],t[5]=e[1],t[6]=e[2],this[a]=!0}}),l(c,"x",{get:function(){var e=this[u];return this._axisX.set(e[0],e[1],e[2]),this._axisX},set:function(e){var t=this[u];e=e[u],t[0]=e[0],t[1]=e[1],t[2]=e[2],this[a]=!0}})}return f.adjoint=function(e,t){return r.adjoint(e[u],t[u]),e[a]=!0,e},f.copy=function(e,t){return r.copy(e[u],t[u]),e[a]=!0,e},f.determinant=function(e){return r.determinant(e[u])},f.identity=function(e){return r.identity(e[u]),e[a]=!0,e},f.ortho=function(e,t,n,i,s,o,f){return r.ortho(e[u],t,n,i,s,o,f),e[a]=!0,e},f.perspective=function(e,t,n,i,s){return r.perspective(e[u],t,n,i,s),e[a]=!0,e},f.lookAt=function(e,t,n,i){return r.lookAt(e[u],t[u],n[u],i[u]),e[a]=!0,e},f.invert=function(e,t){return r.invert(e[u],t[u]),e[a]=!0,e},f.mul=function(e,t,n){return r.mul(e[u],t[u],n[u]),e[a]=!0,e},f.multiply=f.mul,f.fromQuat=function(e,t){return r.fromQuat(e[u],t[u]),e[a]=!0,e},f.fromRotationTranslation=function(e,t,n){return r.fromRotationTranslation(e[u],t[u],n[u]),e[a]=!0,e},f.fromMat2d=function(e,t){e[a]=!0;var t=t[u],e=e[u];return e[0]=t[0],e[4]=t[2],e[12]=t[4],e[1]=t[1],e[5]=t[3],e[13]=t[5],e},f.rotate=function(e,t,n,i){return r.rotate(e[u],t[u],n,i[u]),e[a]=!0,e},f.rotateX=function(e,t,n){return r.rotateX(e[u],t[u],n),e[a]=!0,e},f.rotateY=function(e,t,n){return r.rotateY(e[u],t[u],n),e[a]=!0,e},f.rotateZ=function(e,t,n){return r.rotateZ(e[u],t[u],n),e[a]=!0,e},f.scale=function(e,t,n){return r.scale(e[u],t[u],n[u]),e[a]=!0,e},f.transpose=function(e,t){return r.transpose(e[u],t[u]),e[a]=!0,e},f.translate=function(e,t,n){return r.translate(e[u],t[u],n[u]),e[a]=!0,e},f}),r("qtek/Node",["require","./core/Base","./math/Vector3","./math/Quaternion","./math/Matrix4","./dep/glmatrix"],function(e){var t=e("./core/Base"),n=e("./math/Vector3"),r=e("./math/Quaternion"),i=e("./math/Matrix4"),s=e("./dep/glmatrix"),o=s.mat4,u=0,a=t.derive({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},function(){this.name||(this.name="NODE_"+u++),this.position||(this.position=new n),this.rotation||(this.rotation=new r),this.scale||(this.scale=new n(1,1,1)),this.worldTransform=new i,this.localTransform=new i,this._children=[]},{visible:!0,isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var n=t._nodeRepository;delete n[this.name],n[e]=this}this.name=e},add:function(e){this._inIterating&&console.warn("Add operation can cause unpredictable error when in iterating");var t=e._parent;if(t===this)return;t&&t.remove(e),e._parent=this,this._children.push(e);var n=this._scene;n&&n!==e.scene&&e.traverse(this._addSelfToScene,this)},remove:function(e){this._inIterating&&console.warn("Remove operation can cause unpredictable error when in iterating");var t=this._children,n=t.indexOf(e);if(n<0)return;t.splice(n,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this)},getScene:function(){return this._scene},getParent:function(){return this._parent},_removeSelfFromScene:function(e){e._scene.removeFromScene(e),e._scene=null},_addSelfToScene:function(e){this._scene.addToScene(e),e._scene=this._scene},isAncestor:function(e){var t=e._parent;while(t){if(t===this)return!0;t=t._parent}return!1},children:function(){return this._children.slice()},childAt:function(e){return this._children[e]},getChildByName:function(e){var t=this._children;for(var n=0;n65535,y=g?e.UNSIGNED_INT:e.UNSIGNED_SHORT,b=r.getExtension(e,"OES_vertex_array_object"),w=!h.dynamic,E=this._renderInfo;E.vertexNumber=d,E.faceNumber=0,E.drawCallNumber=0;var S=!1;a=e.__GLID__+"-"+h.__GUID__+"-"+c.__GUID__;if(a!==s)S=!0;else if(h instanceof i&&d>65535&&!m&&v||b&&w||h._cache.isDirty())S=!0;s=a;if(!S)u?(e.drawElements(p,o.count,y,0),E.faceNumber=o.count/3):e.drawArrays(p,0,d),E.drawCallNumber=1;else{var x=this._drawCache[a];if(!x){var T=h.getBufferChunks(e);if(!T)return;x=[];for(var N=0;N0,l=t.color;t.depth=0,f&&o.set(l,0,0,0,0);var c=!0,h=1/r;for(var p=0;p-y&&v-y&&m-y&&g0){var b=v[0],k=(b[0]+1)*o,L=(-b[1]+1)*u;t.fillStyle=y,N==="rectangle"?t.fillRect(k-C,L-C,T,T):N==="circle"&&(t.beginPath(),t.arc(k,L,C,0,Math.PI*2),t.fill())}}}t.restore()},dispose:function(){this._triangles.clear(),this._lines.clear(),this._points.clear(),this._primitives=[],this.ctx=null,this.canvas=null}});return E}),r("qtek/canvas/Material",["require","../core/Base"],function(e){var t=e("../core/Base"),n=t.derive({color:[1,1,1,1],opacity:1,pointSize:0,pointShape:"rectangle"});return n}),r("qtek/Texture",["require","./core/Base","./core/glenum","./core/Cache"],function(e){var t=e("./core/Base"),n=e("./core/glenum"),r=e("./core/Cache"),i=t.derive({width:512,height:512,type:n.UNSIGNED_BYTE,format:n.RGBA,wrapS:n.CLAMP_TO_EDGE,wrapT:n.CLAMP_TO_EDGE,minFilter:n.LINEAR_MIPMAP_LINEAR,magFilter:n.LINEAR,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1},function(){this._cache=new r},{getWebGLTexture:function(e){var t=this._cache;return t.use(e.__GLID__),t.miss("webgl_texture")&&t.put("webgl_texture",e.createTexture()),this.dynamic?this.update(e):t.isDirty()&&(this.update(e),t.fresh()),t.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache.dirtyAll()},update:function(e){},beforeUpdate:function(e){e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,this.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,this.unpackAlignment),this.fallBack()},fallBack:function(){var e=this.isPowerOfTwo();this.format===n.DEPTH_COMPONENT&&(this.useMipmap=!1);if(!e||!this.useMipmap){this.NPOT=!0,this._minFilterOriginal=this.minFilter,this._magFilterOriginal=this.magFilter,this._wrapSOriginal=this.wrapS,this._wrapTOriginal=this.wrapT;if(this.minFilter==n.NEAREST_MIPMAP_NEAREST||this.minFilter==n.NEAREST_MIPMAP_LINEAR)this.minFilter=n.NEAREST;else if(this.minFilter==n.LINEAR_MIPMAP_LINEAR||this.minFilter==n.LINEAR_MIPMAP_NEAREST)this.minFilter=n.LINEAR;this.wrapS=n.CLAMP_TO_EDGE,this.wrapT=n.CLAMP_TO_EDGE}else this.NPOT=!1,this._minFilterOriginal&&(this.minFilter=this._minFilterOriginal),this._magFilterOriginal&&(this.magFilter=this._magFilterOriginal),this._wrapSOriginal&&(this.wrapS=this._wrapSOriginal),this._wrapTOriginal&&(this.wrapT=this._wrapTOriginal)},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__GLID__);var n=t.get("webgl_texture");n&&e.deleteTexture(n),t.deleteContext(e.__GLID__)},isRenderable:function(){},isPowerOfTwo:function(){}});return i.BYTE=n.BYTE,i.UNSIGNED_BYTE=n.UNSIGNED_BYTE,i.SHORT=n.SHORT,i.UNSIGNED_SHORT=n.UNSIGNED_SHORT,i.INT=n.INT,i.UNSIGNED_INT=n.UNSIGNED_INT,i.FLOAT=n.FLOAT,i.HALF_FLOAT=36193,i.DEPTH_COMPONENT=n.DEPTH_COMPONENT,i.ALPHA=n.ALPHA,i.RGB=n.RGB,i.RGBA=n.RGBA,i.LUMINANCE=n.LUMINANCE,i.LUMINANCE_ALPHA=n.LUMINANCE_ALPHA,i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,i.NEAREST=n.NEAREST,i.LINEAR=n.LINEAR,i.NEAREST_MIPMAP_NEAREST=n.NEAREST_MIPMAP_NEAREST,i.LINEAR_MIPMAP_NEAREST=n.LINEAR_MIPMAP_NEAREST,i.NEAREST_MIPMAP_LINEAR=n.NEAREST_MIPMAP_LINEAR,i.LINEAR_MIPMAP_LINEAR=n.LINEAR_MIPMAP_LINEAR,i.TEXTURE_MAG_FILTER=n.TEXTURE_MAG_FILTER,i.TEXTURE_MIN_FILTER=n.TEXTURE_MIN_FILTER,i.REPEAT=n.REPEAT,i.CLAMP_TO_EDGE=n.CLAMP_TO_EDGE,i.MIRRORED_REPEAT=n.MIRRORED_REPEAT,i}),r("qtek/Shader",["require","./core/Base","./core/util","./core/Cache","./core/vendor","./dep/glmatrix"],function(e){function E(){return{locations:{},attriblocations:{}}}function S(e,t,n){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),x(n)].join("\n")}function x(e){var t=e.split("\n");for(var n=0,r=t.length;n0&&n.push("#define "+r.toUpperCase()+"_NUMBER "+i)}for(var s in t){var o=t[s];o.enabled&&n.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in this.vertexDefines){var u=this.vertexDefines[s];u===null?n.push("#define "+s):n.push("#define "+s+" "+u.toString())}this._vertexProcessed=n.join("\n")+"\n"+this._vertexProcessedNoDefine,n=[];for(var r in e){var i=e[r];i>0&&n.push("#define "+r.toUpperCase()+"_NUMBER "+i)}for(var s in t){var o=t[s];o.enabled&&n.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in this.fragmentDefines){var u=this.fragmentDefines[s];u===null?n.push("#define "+s):n.push("#define "+s+" "+u.toString())}var a=n.join("\n")+"\n"+this._fragmentProcessedNoDefine;this._fragmentProcessed=["precision",this.precision,"float"].join(" ")+";\n"+a},_parseUniforms:function(){function r(r,i,s,o,u,a){if(i&&s){var f=h[i],l=!0,c;if(f){t._uniformList.push(s);if(i==="sampler2D"||i==="samplerCube")t._textureStatus[s]={enabled:!1,shaderType:n};o&&(f+="v");if(a)if(d.indexOf(a)>=0)t.attribSemantics[a]={symbol:s,type:f},l=!1;else if(v.indexOf(a)>=0){var m=!1,g=a;a.match(/TRANSPOSE$/)&&(m=!0,g=a.slice(0,-9)),t.matrixSemantics[a]={symbol:s,type:f,isTranspose:m,semanticNoTranspose:g},l=!1}else if(a==="unconfigurable")l=!1;else{c=t._parseDefaultValue(i,a);if(!c)throw new Error('Unkown semantic "'+a+'"');a=""}l&&(e[s]={type:f,value:o?p.array:c||p[i],semantic:a||null})}return["uniform",i,s,o].join(" ")+";\n"}}var e={},t=this,n="vertex";this._uniformList=[],this._vertexProcessedNoDefine=this._vertexProcessedNoDefine.replace(f,r),n="fragment",this._fragmentProcessedNoDefine=this._fragmentProcessedNoDefine.replace(f,r),t.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=e},_parseDefaultValue:function(e,t){var n=/\[\s*(.*)\s*\]/;if(e==="vec2"||e==="vec3"||e==="vec4"){var r=n.exec(t)[1];if(r){var s=r.split(/\s*,\s*/);return function(){return new i.Float32Array(s)}}return}if(e==="bool")return function(){return t.toLowerCase()==="true"?!0:!1};if(e==="float")return function(){return parseFloat(t)}},createUniforms:function(){var e={};for(var t in this.uniformTemplates){var n=this.uniformTemplates[t];e[t]={type:n.type,value:n.value()}}return e},attached:function(){this._attacheMaterialNumber++},detached:function(){this._attacheMaterialNumber--},isAttachedToAny:function(){return this._attacheMaterialNumber!==0},_parseAttributes:function(){function n(n,r,i,s,o){if(r&&i){var u=1;switch(r){case"vec4":u=4;break;case"vec3":u=3;break;case"vec2":u=2;break;case"float":u=1}e[i]={type:"float",size:u,semantic:o||null};if(o){if(d.indexOf(o)<0)throw new Error('Unkown semantic "'+o+'"');t.attribSemantics[o]={symbol:i,type:r}}}return["attribute",r,i].join(" ")+";\n"}var e={},t=this;this._vertexProcessedNoDefine=this._vertexProcessedNoDefine.replace(l,n),this.attributeTemplates=e},_parseDefines:function(){function n(n,r,i){var s=t==="vertex"?e.vertexDefines:e.fragmentDefines;return s[r]||(i=="false"?s[r]=!1:i=="true"?s[r]=!0:s[r]=i?parseFloat(i):null),""}var e=this,t="vertex";this._vertexProcessedNoDefine=this._vertexProcessedNoDefine.replace(c,n),t="fragment",this._fragmentProcessedNoDefine=this._fragmentProcessedNoDefine.replace(c,n)},_buildProgram:function(e,t,n){var r=this._cache;r.get("program")&&e.deleteProgram(r.get("program"));var i=e.createProgram(),s=e.createShader(e.VERTEX_SHADER);e.shaderSource(s,t),e.compileShader(s);var o=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(o,n),e.compileShader(o);var u=S(e,s,t);if(u)return u;u=S(e,o,n);if(u)return u;e.attachShader(i,s),e.attachShader(i,o);if(this.attribSemantics.POSITION)e.bindAttribLocation(i,0,this.attribSemantics.POSITION.symbol);else{var a=Object.keys(this.attributeTemplates);e.bindAttribLocation(i,0,a[0])}e.linkProgram(i);if(!e.getProgramParameter(i,e.LINK_STATUS))return"Could not link program\nVALIDATE_STATUS: "+e.getProgramParameter(i,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]";for(var f=0;f=0&&this._enabledUniforms.splice(t,1)},isUniformEnabled:function(e){return this._enabledUniforms.indexOf(e)>=0},set:function(e,t){if(typeof e=="object")for(var n in e){var r=e[n];this.set(n,r)}else{var i=this.uniforms[e];i&&(i.value=t)}},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){this.shader&&this.shader.detached();var n=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var r=this.uniforms;this._enabledUniforms=Object.keys(r);if(t)for(var i in n)r[i]&&(r[i].value=n[i].value);e.attached()},detachShader:function(){this.shader.detached(),this.shader=null,this.uniforms={}},clone:function(){var e=new r({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e},dispose:function(e,t){if(t)for(var r in this.uniforms){var i=this.uniforms[r].value;if(!i)continue;if(i instanceof n)i.dispose(e);else if(i instanceof Array)for(var s=0;s0&&this.setViewport(this._viewportSettings.pop())},saveClear:function(){this._clearSettings.push(this.clear)},restoreClear:function(){this._clearSettings.length>0&&(this.clear=this._clearSettings.pop())},render:function(e,t,n,r){var i=this.gl;this._sceneRendering=e;var s=this.color;this.clear&&(i.colorMask(!0,!0,!0,!0),i.depthMask(!0),i.clearColor(s[0],s[1],s[2],s[3]),i.clear(this.clear)),n||e.update(!1),t.getScene()||t.update(!0);var o=e.opaqueQueue,u=e.transparentQueue,a=e.material;e.trigger("beforerender",this,e,t);if(u.length>0){var f=p(),l=h.create();for(var d=0;d0&&e.min._array[2]<0&&(e.max._array[2]=-1e-20),e.applyProjection(t);var u=e.min._array,a=e.max._array;if(a[0]<-1||u[0]>1||a[1]<-1||u[1]>1||a[2]<-1||u[2]>1)return!0}return!1}}(),disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,n){var r={},i=this.gl;e.getParent()&&e.getParent().remove(e),e.traverse(function(e){e.geometry&&t&&e.geometry.dispose(i),e.material&&(r[e.material.__GUID__]=e.material),e.dispose&&e.dispose(i)});for(var s in r){var o=r[s];o.dispose(i,n)}},disposeShader:function(e){e.dispose(this.gl)},disposeGeometry:function(e){e.dispose(this.gl)},disposeTexture:function(e){e.dispose(this.gl)},disposeFrameBuffer:function(e){e.dispose(this.gl)},dispose:function(){r.dispose(this.gl)},screenToNdc:function(e,t,n){n||(n=new f),t=this._height-t;var r=this.viewport,i=n._array;return i[0]=(e-r.x)/r.width,i[0]=i[0]*2-1,i[1]=(t-r.y)/r.height,i[1]=i[1]*2-1,n}});m.opaqueSortFunc=function(e,t){return e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__},m.transparentSortFunc=function(e,t){if(e.__depth===t.__depth)return e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__;return e.__depth-t.__depth};var g={WORLD:p(),VIEW:p(),PROJECTION:p(),WORLDVIEW:p(),VIEWPROJECTION:p(),WORLDVIEWPROJECTION:p(),WORLDINVERSE:p(),VIEWINVERSE:p(),PROJECTIONINVERSE:p(),WORLDVIEWINVERSE:p(),VIEWPROJECTIONINVERSE:p(),WORLDVIEWPROJECTIONINVERSE:p(),WORLDTRANSPOSE:p(),VIEWTRANSPOSE:p(),PROJECTIONTRANSPOSE:p(),WORLDVIEWTRANSPOSE:p(),VIEWPROJECTIONTRANSPOSE:p(),WORLDVIEWPROJECTIONTRANSPOSE:p(),WORLDINVERSETRANSPOSE:p(),VIEWINVERSETRANSPOSE:p(),PROJECTIONINVERSETRANSPOSE:p(),WORLDVIEWINVERSETRANSPOSE:p(),VIEWPROJECTIONINVERSETRANSPOSE:p(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:p()};return m.COLOR_BUFFER_BIT=i.COLOR_BUFFER_BIT,m.DEPTH_BUFFER_BIT=i.DEPTH_BUFFER_BIT,m.STENCIL_BUFFER_BIT=i.STENCIL_BUFFER_BIT,m}),r("text",{load:function(e){throw new Error("Dynamic load not allowed: "+e)}}),r("text!grapher/shader/color.essl",[],function(){return"@export grapher.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n\n #ifdef VERTEX_COLOR\n v_Color = a_Color;\n #endif\n}\n\n@end\n\n@export grapher.color.fragment\n\nuniform sampler2D diffuseMap;\nuniform vec3 color: [1.0, 1.0, 1.0];\nuniform float alpha: 1.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha);\n \n #ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n}\n@end"}),r("grapher/core/App3D",["require","qtek/core/vendor","qtek/canvas/Renderer","qtek/canvas/Material","qtek/Renderer","qtek/Material","qtek/Shader","qtek/core/util","qtek/core/mixin/notifier","text!../shader/color.essl"],function(e){var t=e("qtek/core/vendor"),n=t.supportWebGL(),r=e("qtek/canvas/Renderer"),i=e("qtek/canvas/Material"),s=n&&e("qtek/Renderer"),o=n&&e("qtek/Material"),u=n&&e("qtek/Shader"),a=e("qtek/core/util"),f=e("qtek/core/mixin/notifier"),l="canvas",c="webgl",h=window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){setTimeout(e,16)};n&&u["import"](e("text!../shader/color.essl"));var p=function(e,t){function u(){h(u);var e=(new Date).getTime(),t=e-i._time;i._time=e,i._frame(t)}var i=this;t=t||{};var o=!n||t.renderer===l;this._isCanvas=o,this._canvas=e,this._renderer=new(o?r:s)({canvas:e}),this._needsUpdate=!1,this._time=(new Date).getTime(),h(u)};return p.prototype={constructor:p,getRenderer:function(){return this._renderer},getCanvas:function(){return this._canvas},resize:function(e,t){if(e==null){var n=this._canvas;e=n.clientWidth,t=n.clientHeight}this._renderer.resize(e,t),this._needsUpdate=!0},getWidth:function(){return this._renderer.getWidth()},getHeight:function(){return this._renderer.getHeight()},isCanvasRenderer:function(){return this._isCanvas},renderNextFrame:function(){this._needsUpdate=!0},createColorMaterial:function(e,t,n){if(this._isCanvas)return new i({color:e,opacity:t});var r=new o({shader:new u({vertex:u.source("grapher.color.vertex"),fragment:u.source("grapher.color.fragment")})});return n&&r.shader.define("both","VERTEX_COLOR"),r.set("color",e.slice(0,3)),r.set("alpha",(t==null?1:t)*(e[3]==null)?1:e[3]),r},_frame:function(e){this.trigger("frame",e),this._needsUpdate&&(this.trigger("render",this._renderer),this._needsUpdate=!1)}},a.extend(p.prototype,f),p}),r("grapher/generator/Sequence",[],function(){var e=function(e,t,n){this._start=e||0,this._end=t,this._step=n,this._length=Math.floor((t-e)/n)+1,this._mapFuncs=[],this._hasMap=!1};return e.prototype={constructor:e,at:function(e){if(e>=0&&e0&&this._updateRenderQueue(i)}},_updateLightUniforms:function(){var e=this.lights;e.sort(i);var t=this._lightUniforms;for(var n in t)t[n].value.length=0;for(var r=0;rthis.distance;for(var s=1;s<8;s++)if(r.dot(t[s]._array,n)>this.distance!=i)return!0},intersectLine:function(){var e=r.create();return function(n,i,s){var o=this.distanceToPoint(n),u=this.distanceToPoint(i);if(o>0&&u>0||o<0&&u<0)return null;var a=this.normal._array,f=this.distance,l=n._array;r.sub(e,i._array,n._array),r.normalize(e,e);var c=r.dot(a,e);if(c===0)return null;s||(s=new t);var h=(r.dot(a,l)-f)/c;return r.scaleAndAdd(s._array,l,e,-h),s._dirty=!0,s}}(),applyTransform:function(){var e=i.create(),t=s.create(),n=s.create();return n[3]=1,function(o){o=o._array,r.scale(n,this.normal._array,this.distance),s.transformMat4(n,n,o),this.distance=r.dot(n,this.normal._array),i.invert(e,o),i.transpose(e,e),t[3]=0,r.copy(t,this.normal._array),s.transformMat4(t,t,e),r.copy(this.normal._array,t)}}(),copy:function(e){r.copy(this.normal._array,e.normal._array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new o;return e.copy(this),e}},o}),r("qtek/math/Frustum",["require","./Vector3","./BoundingBox","./Plane","../dep/glmatrix"],function(e){var t=e("./Vector3"),n=e("./BoundingBox"),r=e("./Plane"),i=e("../dep/glmatrix"),s=i.vec3,o=s.set,u=s.copy,a=s.transformMat4,f=Math.min,l=Math.max,c=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new r);this.boundingBox=new n,this.vertices=[];for(var e=0;e<8;e++)this.vertices[e]=s.fromValues(0,0,0)};return c.prototype={setFromProjection:function(e){var t=this.planes,n=e._array,r=n[0],i=n[1],s=n[2],a=n[3],f=n[4],l=n[5],c=n[6],h=n[7],p=n[8],d=n[9],v=n[10],m=n[11],g=n[12],y=n[13],b=n[14],w=n[15];o(t[0].normal._array,a-r,h-f,m-p),t[0].distance=-(w-g),t[0].normalize(),o(t[1].normal._array,a+r,h+f,m+p),t[1].distance=-(w+g),t[1].normalize(),o(t[2].normal._array,a+i,h+l,m+d),t[2].distance=-(w+y),t[2].normalize(),o(t[3].normal._array,a-i,h-l,m-d),t[3].distance=-(w-y),t[3].normalize(),o(t[4].normal._array,a-s,h-c,m-v),t[4].distance=-(w-b),t[4].normalize(),o(t[5].normal._array,a+s,h+c,m+v),t[5].distance=-(w+b),t[5].normalize();var E=this.boundingBox;if(w===0){var S=l/r,x=-b/(v-1),T=-b/(v+1),N=-T/l,C=-x/l;E.min.set(-N*S,-N,T),E.max.set(N*S,N,x);var k=this.vertices;o(k[0],-N*S,-N,T),o(k[1],-N*S,N,T),o(k[2],N*S,-N,T),o(k[3],N*S,N,T),o(k[4],-C*S,-C,x),o(k[5],-C*S,C,x),o(k[6],C*S,-C,x),o(k[7],C*S,C,x)}else{var L=(-1-g)/r,A=(1-g)/r,O=(1-y)/l,M=(-1-y)/l,_=(-1-b)/v,D=(1-b)/v;E.min.set(L,M,D),E.max.set(A,O,_);for(var P=0;P<8;P++)u(this.vertices[P],this.boundingBox.vertices[P])}},getTransformedBoundingBox:function(){var e=s.create();return function(t,n){var r=this.vertices,i=n._array,s=t.min,o=t.max,c=s._array,h=o._array,p=r[0];a(e,p,i),u(c,e),u(h,e);for(var d=1;d<8;d++)p=r[d],a(e,p,i),c[0]=f(e[0],c[0]),c[1]=f(e[1],c[1]),c[2]=f(e[2],c[2]),h[0]=l(e[0],h[0]),h[1]=l(e[1],h[1]),h[2]=l(e[2],h[2]);return s._dirty=!0,o._dirty=!0,t}}()},c}),r("qtek/math/Ray",["require","./Vector3","../dep/glmatrix"],function(e){var t=e("./Vector3"),n=e("../dep/glmatrix"),r=n.vec3,i=1e-5,s=function(e,n){this.origin=e||new t,this.direction=n||new t};return s.prototype={constructor:s,intersectPlane:function(e,n){var i=e.normal._array,s=e.distance,o=this.origin._array,u=this.direction._array,a=r.dot(i,u);if(a===0)return null;n||(n=new t);var f=(r.dot(i,o)-s)/a;return r.scaleAndAdd(n._array,o,u,-f),n._dirty=!0,n},mirrorAgainstPlane:function(e){var t=r.dot(e.normal._array,this.direction._array);r.scaleAndAdd(this.direction._array,this.direction._array,e.normal._array,-t*2),this.direction._dirty=!0},distanceToPoint:function(){var e=r.create();return function(t){r.sub(e,t,this.origin._array);var n=r.dot(e,this.direction._array);if(n<0)return r.distance(this.origin._array,t);var i=r.lenSquared(e);return Math.sqrt(i-n*n)}}(),intersectSphere:function(){var e=r.create();return function(n,i,s){var o=this.origin._array,u=this.direction._array;n=n._array,r.sub(e,n,o);var a=r.dot(e,u),f=r.squaredLength(e),l=f-a*a,c=i*i;if(l>c)return;var h=Math.sqrt(c-l),p=a-h,d=a+h;return s||(s=new t),p<0?d<0?null:(r.scaleAndAdd(s._array,o,u,d),s):(r.scaleAndAdd(s._array,o,u,p),s)}}(),intersectBoundingBox:function(e,n){var i=this.direction._array,s=this.origin._array,o=e.min._array,u=e.max._array,a=1/i[0],f=1/i[1],l=1/i[2],c,h,p,d,v,m;a>=0?(c=(o[0]-s[0])*a,h=(u[0]-s[0])*a):(h=(o[0]-s[0])*a,c=(u[0]-s[0])*a),f>=0?(p=(o[1]-s[1])*f,d=(u[1]-s[1])*f):(d=(o[1]-s[1])*f,p=(u[1]-s[1])*f);if(c>d||p>h)return null;if(p>c||c!==c)c=p;if(d=0?(v=(o[2]-s[2])*l,m=(u[2]-s[2])*l):(m=(o[2]-s[2])*l,v=(u[2]-s[2])*l);if(c>m||v>h)return null;if(v>c||c!==c)c=v;if(m=0?c:h;return n||(n=new t),r.scaleAndAdd(n._array,s,i,g),n},intersectTriangle:function(){var e=r.create(),n=r.create(),s=r.create(),o=r.create();return function(u,a,f,l,c,h){var p=this.direction._array,d=this.origin._array;u=u._array,a=a._array,f=f._array,r.sub(e,a,u),r.sub(n,f,u),r.cross(o,n,p);var v=r.dot(e,o);if(l){if(v>-i)return null}else if(v>-i&&v1)return null;r.cross(o,e,s);var g=r.dot(p,o)/v;if(g<0||g>1||m+g>1)return null;r.cross(o,e,n);var y=-r.dot(s,o)/v;return y<0?null:(c||(c=new t),h&&t.set(h,1-m-g,m,g),r.scaleAndAdd(c._array,d,p,y),c)}}(),applyTransform:function(e){t.add(this.direction,this.direction,this.origin),t.transformMat4(this.origin,this.origin,e),t.transformMat4(this.direction,this.direction,e),t.sub(this.direction,this.direction,this.origin),t.normalize(this.direction,this.direction)},copy:function(e){t.copy(this.origin,e.origin),t.copy(this.direction,e.direction)},clone:function(){var e=new s;return e.copy(this),e}},s}),r("qtek/Camera",["require","./Node","./math/Matrix4","./math/Frustum","./math/BoundingBox","./math/Ray","./dep/glmatrix"],function(e){var t=e("./Node"),n=e("./math/Matrix4"),r=e("./math/Frustum"),i=e("./math/BoundingBox"),s=e("./math/Ray"),o=e("./dep/glmatrix"),u=o.mat4,a=o.vec3,f=o.vec4,l=t.derive(function(){return{projectionMatrix:new n,invProjectionMatrix:new n,viewMatrix:new n,frustum:new r,sceneBoundingBoxLastFrame:new i}},function(){this.update(!0)},{update:function(e){t.prototype.update.call(this,e),u.invert(this.viewMatrix._array,this.worldTransform._array),this.updateProjectionMatrix(),u.invert(this.invProjectionMatrix._array,this.projectionMatrix._array),this.frustum.setFromProjection(this.projectionMatrix)},updateProjectionMatrix:function(){},castRay:function(){var e=f.create();return function(t,n){var r=n!==undefined?n:new s,i=t._array[0],o=t._array[1];return f.set(e,i,o,-1,1),f.transformMat4(e,e,this.invProjectionMatrix._array),f.transformMat4(e,e,this.worldTransform._array),a.scale(r.origin._array,e,1/e[3]),f.set(e,i,o,1,1),f.transformMat4(e,e,this.invProjectionMatrix._array),f.transformMat4(e,e,this.worldTransform._array),a.scale(e,e,1/e[3]),a.sub(r.direction._array,e,r.origin._array),a.normalize(r.direction._array,r.direction._array),r.direction._dirty=!0,r.origin._dirty=!0,r}}()});return l}),r("qtek/camera/Perspective",["require","../Camera"],function(e){var t=e("../Camera"),n=t.derive({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},clone:function(){var e=t.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}});return n}),r("qtek/camera/Orthographic",["require","../Camera"],function(e){var t=e("../Camera"),n=t.derive({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},clone:function(){var e=t.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});return n}),r("grapher/graph/component/OrbitControl",["require","qtek/math/Vector2","qtek/math/Vector3","qtek/math/Quaternion"],function(e){function i(e,t,n){e.addEventListener(t,n)}function s(e,t,n){e.removeEventListener(t,n)}var t=e("qtek/math/Vector2"),n=e("qtek/math/Vector3"),r=e("qtek/math/Quaternion"),o=function(e,r){r=r||{},this._app3d=e,this.target=r.target,this.autoRotate=r.autoRotate||!1,this._rotateY=0,this._rotateX=0,this._mouseX=0,this._mouseY=0,this._rotateVelocity=new t,this._panVelocity=new t,this._cameraStartPos=new n,this.init()};return o.prototype={constructor:o,init:function(){var e=this._app3d.getCanvas();this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),i(e,"mousedown",this._mouseDownHandler),i(e,"touchstart",this._mouseDownHandler),this._decomposeRotation()},dispose:function(){var e=this._app3d.getCanvas();s(e,"mousedown",this._mouseDownHandler),s(document.body,"mousemove",this._mouseMoveHandler),s(document.body,"mouseup",this._mouseUpHandler),s(e,"touchstart",this._mouseDownHandler),s(document.body,"touchmove",this._mouseMoveHandler),s(document.body,"touchend",this._mouseUpHandler)},update:function(e){if(this._animating)return;this._updateRotate(e)},_updateRotate:function(e){var t=this._app3d,n=this._rotateVelocity;this._rotateY=(n.y+this._rotateY)%(Math.PI*2),this._rotateX=(n.x+this._rotateX)%(Math.PI*2),this._rotateX=Math.max(Math.min(this._rotateX,Math.PI/2),-Math.PI/2),this.target.rotation.identity().rotateX(this._rotateX).rotateY(this._rotateY),this._vectorDamping(n,.8),this.autoRotate?(this._rotateY+=e*3e-4,t.renderNextFrame()):n.len()>0&&t.renderNextFrame()},_vectorDamping:function(e,t){var n=e.len();n*=t,n<1e-4&&(n=0),e.normalize().scale(n)},_mouseDownHandler:function(e){var t=this._app3d.getCanvas();i(document.body,"mousemove",this._mouseMoveHandler),i(document.body,"mouseup",this._mouseUpHandler),i(document.body,"touchmove",this._mouseMoveHandler),i(document.body,"touchend",this._mouseUpHandler),this._rotateVelocity.set(0,0);var n=e.pageX,r=e.pageY;if(e.targetTouches){var s=e.targetTouches[0];n=s.clientX,r=s.clientY}this._mouseX=n,this._mouseY=r,this.autoRotate=!1},_mouseMoveHandler:function(e){var t=e.pageX,n=e.pageY;if(e.targetTouches){var r=e.targetTouches[0];t=r.clientX,n=r.clientY,e.preventDefault()}var i=this._rotateVelocity;i.y=(t-this._mouseX)/500,i.x=(n-this._mouseY)/500,this._mouseX=t,this._mouseY=n},_mouseUpHandler:function(){var e=this._app3d.getCanvas();s(document.body,"mousemove",this._mouseMoveHandler),s(document.body,"mouseup",this._mouseUpHandler),s(document.body,"touchmove",this._mouseMoveHandler),s(document.body,"touchend",this._mouseUpHandler)},_decomposeRotation:function(){var e=new n;e.eulerFromQuaternion(this.target.rotation.normalize(),"ZXY"),this._rotateX=e.x,this._rotateY=e.y}},o}),r("grapher/graph/Surface",["require","./component/Cartesian3D","../core/App3D","../core/number","../core/color","qtek/core/vendor","qtek/DynamicGeometry","qtek/Scene","qtek/camera/Perspective","qtek/camera/Orthographic","qtek/core/util","qtek/Renderable","qtek/Node","qtek/dep/glmatrix","./component/OrbitControl","../generator/Sequence"],function(e){function E(e,t){this._init(e,t)}var t=e("./component/Cartesian3D"),n=e("../core/App3D"),r=e("../core/number"),i=e("../core/color"),s=e("qtek/core/vendor"),o=e("qtek/DynamicGeometry"),u=e("qtek/Scene"),a=e("qtek/camera/Perspective"),f=e("qtek/camera/Orthographic"),l=e("qtek/core/util"),c=e("qtek/Renderable"),h=e("qtek/Node"),p=e("qtek/dep/glmatrix"),d=p.vec4,v=e("./component/OrbitControl"),m=e("../generator/Sequence"),g=r.rangeOfData,y=[0,0,0,1],b={axisLineWidth:3,axisWireframeLineWidth:1,axisWireframeLineColor:"grey",showWireframe:!0,wireframeLineColor:"#111",wireframeLineWidth:1,projection:"orthographic",renderer:"auto",autoRotate:!0,parametric:!1,color:["red","green"],parameters:{u:new m(0,1,.05),v:new m(0,1,.05)}},w=100;return E.prototype={constructor:E,resize:function(e,t){this._app3d.resize(e,t);var n=this._camera,r=this._app3d.getRenderer().getViewportAspect();n instanceof f?(n.left=-w*r,n.right=w*r):n.aspect=r},_init:function(e,r){r=l.extend({},r),l.defaults(r,b);var i=new n(e,{renderer:r.renderer});this._app3d=i;var s=this._convertData(r),o=s.data,c=r.xAxis.range||g(o.map(function(e){return e.x})),p=r.yAxis.range||g(o.map(function(e){return e.y})),d=r.zAxis.range||g(o.map(function(e){return e.z})),m=new t(i,{xAxis:l.extend({range:c},r.xAxis),yAxis:l.extend({range:p},r.yAxis),zAxis:l.extend({range:d},r.zAxis),renderer:r.renderer,axisLineWidth:r.axisLineWidth,axisWireframeLineWidth:r.axisWireframeLineWidth,axisWireframeLineColor:r.axisWireframeLineColor,size:w});this._cartesian=m;var y=new u,E=new h;E.rotation.rotateX(Math.PI/5).rotateY(-Math.PI/4);var S=new v(i,{target:E,autoRotate:r.autoRotate});this._orbitControl=S;var x=new h;x.add(m.root),E.add(x),y.add(E),x.rotation.rotateX(-Math.PI/2),x.position.set(-w/2,-w/2,w/2);var T=i.getRenderer().getViewportAspect(),N=r.projection.toLowerCase()==="orthographic"?new f({left:-w*T,right:w*T,bottom:-w,top:w,near:0,far:w*10}):new a({aspect:T,far:w*10,fov:50});N.position.set(0,0,w*2.5),N.lookAt(y.position),this._scene=y,this._camera=N,this._root=x,this._constructSurface(s,r),i.on("render",this._doRender,this),i.on("frame",this._frameUpdate,this),this.resize()},_doRender:function(e){e.render(this._scene,this._camera)},_frameUpdate:function(e){this._orbitControl.update(e)},_convertData:function(e){var t=e.xAxis.data,n=e.yAxis.data,i=e.zAxis.data,s=typeof t=="function",o=typeof n=="function",u=typeof i=="function",a=e.parametric,f=[],l,c;if(a)if(s&&o&&u){var h=e.parameters,p=h.u,d=h.v;if(!(p instanceof m&&d instanceof m)){console.warn("Parameters u, v must be grapher.generator.Sequence");return}l=p.length(),c=d.length();for(var v=0;v