blob: 1bc66f97d8ee66238ffe7f22a2fa0105e6dcec8c [file] [log] [blame]
/* 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 <dean@gmail.com>, 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;f<e.length;f+=1){h=e[f];if(h===".")e.splice(f,1),f-=1;else if(h===".."){if(f===1&&(e[2]===".."||e[0]===".."))break;f>0&&(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;v<n.length;v+=1){p=o(n[v],i),l=p.f;if(l==="require")g[v]=u.require(t);else if(l==="exports")g[v]=u.exports(t),w=!0;else if(l==="module")s=g[v]=u.module(t);else if(d(a,l)||d(f,l)||d(c,l))g[v]=b(l);else{if(!p.p)throw new Error(t+" missing "+l);p.p.load(p.n,m(i,!0),y(l),{}),g[v]=a[l]}}h=r.apply(a[t],g);if(t)if(s&&s.exports!==e&&s.exports!==a[t])a[t]=s.exports;else if(h!==e||!w)a[t]=h}else t&&(a[t]=r)},t=n=s=function(t,n,r,a,f){return typeof t=="string"?u[t]?u[t](n):b(o(t,n).f):(t.splice||(l=t,n.splice?(t=n,n=r,r=null):t=e),n=n||function(){},typeof r=="function"&&(r=a,a=f),a?i(e,t,n,r):setTimeout(function(){i(e,t,n,r)},4),s)},s.config=function(e){return l=e,l.deps&&s(l.deps,l.callback),s},r=function(e,t,n){t.splice||(n=t,t=[]),!d(a,e)&&!d(f,e)&&(f[e]=[e,t,n])},r.amd={jQuery:!0}})(),r("grapher/coordinate/Axis",["require"],function(e){var t=function(e,t,n){this.dim=e,this.dataRange=t,this.spaceRange=n};return t.prototype={contructor:t,valueToCoord:function(e){var t=this.spaceRange,n=this.dataRange,r=n[1]-n[0];if(r===0)return(t[1]+t[0])/2;var i=(t[1]-t[0])/r;return(e-n[0])*i+t[0]},coordToValue:function(e){var t=this.spaceRange,n=this.dataRange,r=(n[1]-n[0])/(t[1]-t[0]);return(value-t[0])*r+n[0]}},t}),r("grapher/coordinate/Cartesian",["require","./Axis"],function(e){var t=e("./Axis"),n=function(e){this._size=e,this._axis={},this._dimList=[]};return n.prototype={constructor:n,getAxis:function(e){return this._axis[e]},addAxis:function(e,n){var r=new t(e,n,[0,this._size]);return this._axis[e]=r,this._dimList.push(e),r},valueToCoord:function(e){return this._valueCoordConvert(e,"valueToCoord")},coordToValue:function(){return this._valueCoordConversion(val,"coordToValue")},_valueCoordConvert:function(e,t){var n=this._dimList,r=e instanceof Array?[]:{};for(var i=0;i<n.length;i++){var s=n[i],o=this._axis[s];r[s]=o[t](e[s])}return r}},n}),r("qtek/core/mixin/derive",["require"],function(e){function t(e,t,i){typeof t=="object"&&(i=t,t=null);var s=this,o;if(!(e instanceof Function)){o=[];for(var u in e)e.hasOwnProperty(u)&&o.push(u)}var a=function(t){s.apply(this,arguments),e instanceof Function?n(this,e.call(this)):r(this,e,o);if(this.constructor===a){var i=a.__initializers__;for(var u=0;u<i.length;u++)i[u].apply(this,arguments)}};a.__super__=s,s.__initializers__?a.__initializers__=s.__initializers__.slice():a.__initializers__=[],t&&a.__initializers__.push(t);var f=function(){};return f.prototype=s.prototype,a.prototype=new f,a.prototype.constructor=a,n(a.prototype,i),a.derive=s.derive,a}function n(e,t){if(!t)return;for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function r(e,t,n){for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}}return{derive:t}}),r("qtek/core/mixin/notifier",[],function(){function e(e,t){this.action=e,this.context=t}var t={trigger:function(e){if(!this.hasOwnProperty("__handlers__"))return;if(!this.__handlers__.hasOwnProperty(e))return;var t=this.__handlers__[e],n=t.length,r=-1,i=arguments;switch(i.length){case 1:while(++r<n)t[r].action.call(t[r].context);return;case 2:while(++r<n)t[r].action.call(t[r].context,i[1]);return;case 3:while(++r<n)t[r].action.call(t[r].context,i[1],i[2]);return;case 4:while(++r<n)t[r].action.call(t[r].context,i[1],i[2],i[3]);return;case 5:while(++r<n)t[r].action.call(t[r].context,i[1],i[2],i[3],i[4]);return;default:while(++r<n)t[r].action.apply(t[r].context,Array.prototype.slice.call(i,1));return}},on:function(t,n,r){if(!t||!n)return;var i=this.__handlers__||(this.__handlers__={});if(!i[t])i[t]=[];else if(this.has(t,n))return;var s=new e(n,r||this);return i[t].push(s),this},once:function(e,t,n){function i(){r.off(e,i),t.apply(this,arguments)}if(!e||!t)return;var r=this;return this.on(e,i,n)},before:function(e,t,n){if(!e||!t)return;return e="before"+e,this.on(e,t,n)},after:function(e,t,n){if(!e||!t)return;return e="after"+e,this.on(e,t,n)},success:function(e,t){return this.once("success",e,t)},error:function(e,t){return this.once("error",e,t)},off:function(e,t){var n=this.__handlers__||(this.__handlers__={});if(!t){n[e]=[];return}if(n[e]){var r=n[e],i=[];for(var s=0;s<r.length;s++)t&&r[s].action!==t&&i.push(r[s]);n[e]=i}return this},has:function(e,t){var n=this.__handlers__;if(!n||!n[e])return!1;var r=n[e];for(var i=0;i<r.length;i++)if(r[i].action===t)return!0}};return t}),r("qtek/core/util",["require"],function(e){var t=0,n={genGUID:function(){return++t},relative2absolute:function(e,t){if(!t||e.match(/^\//))return e;var n=e.split("/"),r=t.split("/"),i=n[0];while(i==="."||i==="..")i===".."&&r.pop(),n.shift(),i=n[0];return r.join("/")+"/"+n.join("/")},extend:function(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},defaults:function(e,t){if(t)for(var n in t)e[n]===undefined&&(e[n]=t[n]);return e},extendWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}return e},defaultsWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];e[i]===undefined&&(e[i]=t[i])}return e},each:function(e,t,n){if(!e||!t)return;if(e.forEach)e.forEach(t,n);else if(e.length===+e.length)for(var r=0,i=e.length;r<i;r++)t.call(n,e[r],r,e);else for(var s in e)e.hasOwnProperty(s)&&t.call(n,e[s],s,e)},isObject:function(e){return e===Object(e)},isArray:function(e){return e instanceof Array},isArrayLike:function(e){return e?e.length===+e.length:!1},clone:function(e){if(!n.isObject(e))return e;if(n.isArray(e))return e.slice();if(n.isArrayLike(e)){var t=new e.constructor(e.length);for(var r=0;r<e.length;r++)t[r]=e[r];return t}return n.extend({},e)}};return n}),r("qtek/core/Base",["require","./mixin/derive","./mixin/notifier","./util"],function(e){var t=e("./mixin/derive"),n=e("./mixin/notifier"),r=e("./util"),i=function(){this.__GUID__=r.genGUID()};return i.__initializers__=[function(e){r.extend(this,e)}],r.extend(i,t),r.extend(i.prototype,n),i}),r("qtek/core/glenum",[],function(){return{DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444}}),r("qtek/core/Cache",[],function(){var e="__dirty__",t=function(){this._contextId=0,this._caches=[],this._context={}};return t.prototype={use:function(e,t){var n=this._caches;n[e]||(n[e]={},t&&(n[e]=t())),this._contextId=e,this._context=n[e]},put:function(e,t){this._context[e]=t},get:function(e){return this._context[e]},dirty:function(t){t=t||"";var n=e+t;this.put(n,!0)},dirtyAll:function(t){t=t||"";var n=e+t,r=this._caches;for(var i=0;i<r.length;i++)r[i]&&(r[i][n]=!0)},fresh:function(t){t=t||"";var n=e+t;this.put(n,!1)},freshAll:function(t){t=t||"";var n=e+t,r=this._caches;for(var i=0;i<r.length;i++)r[i]&&(r[i][n]=!1)},isDirty:function(t){t=t||"";var n=e+t,r=this._context;return!r.hasOwnProperty(n)||r[n]===!0},deleteContext:function(e){delete this._caches[e],this._context={}},"delete":function(e){delete this._context[e]},clearAll:function(){this._caches={}},getContext:function(){return this._context},miss:function(e){return!this._context.hasOwnProperty(e)}},t.prototype.constructor=t,t}),r("qtek/core/vendor",["require"],function(e){var t=!0;try{var n=document.createElement("canvas"),r=n.getContext("webgl")||n.getContext("experimental-webgl");if(!r)throw new Error}catch(i){t=!1}var s={};s.supportWebGL=function(){return t};var o="undefined";return s.Int8Array=typeof Int8Array==o?Array:Int8Array,s.Uint8Array=typeof Uint8Array==o?Array:Uint8Array,s.Uint16Array=typeof Uint16Array==o?Array:Uint16Array,s.Int16Array=typeof Int16Array==o?Array:Int16Array,s.Float32Array=typeof Float32Array==o?Array:Float32Array,s}),function(e){var t={};typeof exports=="undefined"?typeof r=="function"&&typeof r.amd=="object"&&r.amd?(t.exports={},r("qtek/dep/glmatrix",[],function(){return t.exports})):t.exports=typeof window!="undefined"?window:e:t.exports=exports,function(e){if(!t)var t=1e-6;if(!n)var n=typeof Float32Array!="undefined"?Float32Array:Array;if(!r)var r=Math.random;var i={};i.setMatrixArrayType=function(e){n=e},typeof e!="undefined"&&(e.glMatrix=i);var s=Math.PI/180;i.toRadian=function(e){return e*s};var o={};o.create=function(){var e=new n(2);return e[0]=0,e[1]=0,e},o.clone=function(e){var t=new n(2);return t[0]=e[0],t[1]=e[1],t},o.fromValues=function(e,t){var r=new n(2);return r[0]=e,r[1]=t,r},o.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},o.set=function(e,t,n){return e[0]=t,e[1]=n,e},o.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},o.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},o.sub=o.subtract,o.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e},o.mul=o.multiply,o.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e},o.div=o.divide,o.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e},o.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e},o.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},o.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},o.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},o.dist=o.distance,o.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r},o.sqrDist=o.squaredDistance,o.length=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},o.len=o.length,o.squaredLength=function(e){var t=e[0],n=e[1];return t*t+n*n},o.sqrLen=o.squaredLength,o.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},o.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},o.normalize=function(e,t){var n=t[0],r=t[1],i=n*n+r*r;return i>0&&(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;u<a;u+=n)e[0]=t[u],e[1]=t[u+1],s(e,e,o),t[u]=e[0],t[u+1]=e[1];return t}}(),o.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},typeof e!="undefined"&&(e.vec2=o);var u={};u.create=function(){var e=new n(3);return e[0]=0,e[1]=0,e[2]=0,e},u.clone=function(e){var t=new n(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},u.fromValues=function(e,t,r){var i=new n(3);return i[0]=e,i[1]=t,i[2]=r,i},u.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},u.set=function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},u.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},u.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},u.sub=u.subtract,u.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},u.mul=u.multiply,u.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},u.div=u.divide,u.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},u.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},u.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e},u.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},u.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)},u.dist=u.distance,u.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i},u.sqrDist=u.squaredDistance,u.length=function(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)},u.len=u.length,u.squaredLength=function(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},u.sqrLen=u.squaredLength,u.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},u.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},u.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],s=n*n+r*r+i*i;return s>0&&(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;u<a;u+=n)e[0]=t[u],e[1]=t[u+1],e[2]=t[u+2],s(e,e,o),t[u]=e[0],t[u+1]=e[1],t[u+2]=e[2];return t}}(),u.angle=function(e,t){var n=u.fromValues(e[0],e[1],e[2]),r=u.fromValues(t[0],t[1],t[2]);u.normalize(n,n),u.normalize(r,r);var i=u.dot(n,r);return i>1?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<a;u+=n)e[0]=t[u],e[1]=t[u+1],e[2]=t[u+2],e[3]=t[u+3],s(e,e,o),t[u]=e[0],t[u+1]=e[1],t[u+2]=e[2],t[u+3]=e[3];return t}}(),a.str=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},typeof e!="undefined"&&(e.vec4=a);var f={};f.create=function(){var e=new n(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},f.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},f.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},f.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},f.transpose=function(e,t){if(e===t){var n=t[1];e[1]=t[2],e[2]=n}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},f.invert=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=n*s-i*r;return o?(o=1/o,e[0]=s*o,e[1]=-r*o,e[2]=-i*o,e[3]=n*o,e):null},f.adjoint=function(e,t){var n=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=n,e},f.determinant=function(e){return e[0]*e[3]-e[2]*e[1]},f.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*u+s*a,e[1]=i*u+o*a,e[2]=r*f+s*l,e[3]=i*f+o*l,e},f.mul=f.multiply,f.rotate=function(e,t,n){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]=r*-u+s*a,e[3]=i*-u+o*a,e},f.scale=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=n[0],a=n[1];return e[0]=r*u,e[1]=i*u,e[2]=s*a,e[3]=o*a,e},f.str=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},f.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2))},f.LDU=function(e,t,n,r){return e[2]=r[2]/r[0],n[0]=r[0],n[1]=r[1],n[3]=r[3]-e[2]*n[1],[e,t,n]},typeof e!="undefined"&&(e.mat2=f);var l={};l.create=function(){var e=new n(6);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},l.clone=function(e){var t=new n(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},l.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},l.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},l.invert=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],u=t[5],a=n*s-r*i;return a?(a=1/a,e[0]=s*a,e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e[4]=(i*u-s*o)*a,e[5]=(r*o-n*u)*a,e):null},l.determinant=function(e){return e[0]*e[3]-e[1]*e[2]},l.multiply=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=n[0],l=n[1],c=n[2],h=n[3],p=n[4],d=n[5];return e[0]=r*f+s*l,e[1]=i*f+o*l,e[2]=r*c+s*h,e[3]=i*c+o*h,e[4]=r*p+s*d+u,e[5]=i*p+o*d+a,e},l.mul=l.multiply,l.rotate=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=Math.sin(n),l=Math.cos(n);return e[0]=r*l+s*f,e[1]=i*l+o*f,e[2]=r*-f+s*l,e[3]=i*-f+o*l,e[4]=u,e[5]=a,e},l.scale=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=n[0],l=n[1];return e[0]=r*f,e[1]=i*f,e[2]=s*l,e[3]=o*l,e[4]=u,e[5]=a,e},l.translate=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=n[0],l=n[1];return e[0]=r,e[1]=i,e[2]=s,e[3]=o,e[4]=r*f+s*l+u,e[5]=i*f+o*l+a,e},l.str=function(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},l.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+1)},typeof e!="undefined"&&(e.mat2d=l);var c={};c.create=function(){var e=new n(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},c.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},c.clone=function(e){var t=new n(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},c.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},c.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},c.transpose=function(e,t){if(e===t){var n=t[1],r=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=i}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},c.invert=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],u=t[5],a=t[6],f=t[7],l=t[8],c=l*o-u*f,h=-l*s+u*a,p=f*s-o*a,d=n*c+r*h+i*p;return d?(d=1/d,e[0]=c*d,e[1]=(-l*r+i*f)*d,e[2]=(u*r-i*o)*d,e[3]=h*d,e[4]=(l*n-i*a)*d,e[5]=(-u*n+i*s)*d,e[6]=p*d,e[7]=(-f*n+r*a)*d,e[8]=(o*n-r*s)*d,e):null},c.adjoint=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],u=t[5],a=t[6],f=t[7],l=t[8];return e[0]=o*l-u*f,e[1]=i*f-r*l,e[2]=r*u-i*o,e[3]=u*a-s*l,e[4]=n*l-i*a,e[5]=i*s-n*u,e[6]=s*f-o*a,e[7]=r*a-n*f,e[8]=n*o-r*s,e},c.determinant=function(e){var t=e[0],n=e[1],r=e[2],i=e[3],s=e[4],o=e[5],u=e[6],a=e[7],f=e[8];return t*(f*s-o*a)+n*(-f*i+o*u)+r*(a*i-s*u)},c.multiply=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=t[6],l=t[7],c=t[8],h=n[0],p=n[1],d=n[2],v=n[3],m=n[4],g=n[5],y=n[6],b=n[7],w=n[8];return e[0]=h*r+p*o+d*f,e[1]=h*i+p*u+d*l,e[2]=h*s+p*a+d*c,e[3]=v*r+m*o+g*f,e[4]=v*i+m*u+g*l,e[5]=v*s+m*a+g*c,e[6]=y*r+b*o+w*f,e[7]=y*i+b*u+w*l,e[8]=y*s+b*a+w*c,e},c.mul=c.multiply,c.translate=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=t[6],l=t[7],c=t[8],h=n[0],p=n[1];return e[0]=r,e[1]=i,e[2]=s,e[3]=o,e[4]=u,e[5]=a,e[6]=h*r+p*o+f,e[7]=h*i+p*u+l,e[8]=h*s+p*a+c,e},c.rotate=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=t[6],l=t[7],c=t[8],h=Math.sin(n),p=Math.cos(n);return e[0]=p*r+h*o,e[1]=p*i+h*u,e[2]=p*s+h*a,e[3]=p*o-h*r,e[4]=p*u-h*i,e[5]=p*a-h*s,e[6]=f,e[7]=l,e[8]=c,e},c.scale=function(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},c.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},c.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=n+n,u=r+r,a=i+i,f=n*o,l=r*o,c=r*u,h=i*o,p=i*u,d=i*a,v=s*o,m=s*u,g=s*a;return e[0]=1-c-d,e[3]=l-g,e[6]=h+m,e[1]=l+g,e[4]=1-f-d,e[7]=p-v,e[2]=h-m,e[5]=p+v,e[8]=1-f-c,e},c.normalFromMat4=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],u=t[5],a=t[6],f=t[7],l=t[8],c=t[9],h=t[10],p=t[11],d=t[12],v=t[13],m=t[14],g=t[15],y=n*u-r*o,b=n*a-i*o,w=n*f-s*o,E=r*a-i*u,S=r*f-s*u,x=i*f-s*a,T=l*v-c*d,N=l*m-h*d,C=l*g-p*d,k=c*m-h*v,L=c*g-p*v,A=h*g-p*m,O=y*A-b*L+w*k+E*C-S*N+x*T;return O?(O=1/O,e[0]=(u*A-a*L+f*k)*O,e[1]=(a*C-o*A-f*N)*O,e[2]=(o*L-u*C+f*T)*O,e[3]=(i*L-r*A-s*k)*O,e[4]=(n*A-i*C+s*N)*O,e[5]=(r*C-n*L-s*T)*O,e[6]=(v*x-m*S+g*E)*O,e[7]=(m*w-d*x-g*b)*O,e[8]=(d*S-v*w+g*y)*O,e):null},c.str=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},c.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2))},typeof e!="undefined"&&(e.mat3=c);var h={};h.create=function(){var e=new n(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},h.clone=function(e){var t=new n(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},h.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},h.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},h.transpose=function(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],s=t[6],o=t[7],u=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=s,e[11]=t[14],e[12]=i,e[13]=o,e[14]=u}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},h.invert=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],u=t[5],a=t[6],f=t[7],l=t[8],c=t[9],h=t[10],p=t[11],d=t[12],v=t[13],m=t[14],g=t[15],y=n*u-r*o,b=n*a-i*o,w=n*f-s*o,E=r*a-i*u,S=r*f-s*u,x=i*f-s*a,T=l*v-c*d,N=l*m-h*d,C=l*g-p*d,k=c*m-h*v,L=c*g-p*v,A=h*g-p*m,O=y*A-b*L+w*k+E*C-S*N+x*T;return O?(O=1/O,e[0]=(u*A-a*L+f*k)*O,e[1]=(i*L-r*A-s*k)*O,e[2]=(v*x-m*S+g*E)*O,e[3]=(h*S-c*x-p*E)*O,e[4]=(a*C-o*A-f*N)*O,e[5]=(n*A-i*C+s*N)*O,e[6]=(m*w-d*x-g*b)*O,e[7]=(l*x-h*w+p*b)*O,e[8]=(o*L-u*C+f*T)*O,e[9]=(r*C-n*L-s*T)*O,e[10]=(d*S-v*w+g*y)*O,e[11]=(c*w-l*S-p*y)*O,e[12]=(u*N-o*k-a*T)*O,e[13]=(n*k-r*N+i*T)*O,e[14]=(v*b-d*E-m*y)*O,e[15]=(l*E-c*b+h*y)*O,e):null},h.adjoint=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],u=t[5],a=t[6],f=t[7],l=t[8],c=t[9],h=t[10],p=t[11],d=t[12],v=t[13],m=t[14],g=t[15];return e[0]=u*(h*g-p*m)-c*(a*g-f*m)+v*(a*p-f*h),e[1]=-(r*(h*g-p*m)-c*(i*g-s*m)+v*(i*p-s*h)),e[2]=r*(a*g-f*m)-u*(i*g-s*m)+v*(i*f-s*a),e[3]=-(r*(a*p-f*h)-u*(i*p-s*h)+c*(i*f-s*a)),e[4]=-(o*(h*g-p*m)-l*(a*g-f*m)+d*(a*p-f*h)),e[5]=n*(h*g-p*m)-l*(i*g-s*m)+d*(i*p-s*h),e[6]=-(n*(a*g-f*m)-o*(i*g-s*m)+d*(i*f-s*a)),e[7]=n*(a*p-f*h)-o*(i*p-s*h)+l*(i*f-s*a),e[8]=o*(c*g-p*v)-l*(u*g-f*v)+d*(u*p-f*c),e[9]=-(n*(c*g-p*v)-l*(r*g-s*v)+d*(r*p-s*c)),e[10]=n*(u*g-f*v)-o*(r*g-s*v)+d*(r*f-s*u),e[11]=-(n*(u*p-f*c)-o*(r*p-s*c)+l*(r*f-s*u)),e[12]=-(o*(c*m-h*v)-l*(u*m-a*v)+d*(u*h-a*c)),e[13]=n*(c*m-h*v)-l*(r*m-i*v)+d*(r*h-i*c),e[14]=-(n*(u*m-a*v)-o*(r*m-i*v)+d*(r*a-i*u)),e[15]=n*(u*h-a*c)-o*(r*h-i*c)+l*(r*a-i*u),e},h.determinant=function(e){var t=e[0],n=e[1],r=e[2],i=e[3],s=e[4],o=e[5],u=e[6],a=e[7],f=e[8],l=e[9],c=e[10],h=e[11],p=e[12],d=e[13],v=e[14],m=e[15],g=t*o-n*s,y=t*u-r*s,b=t*a-i*s,w=n*u-r*o,E=n*a-i*o,S=r*a-i*u,x=f*d-l*p,T=f*v-c*p,N=f*m-h*p,C=l*v-c*d,k=l*m-h*d,L=c*m-h*v;return g*L-y*k+b*C+w*N-E*T+S*x},h.multiply=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=t[6],l=t[7],c=t[8],h=t[9],p=t[10],d=t[11],v=t[12],m=t[13],g=t[14],y=t[15],b=n[0],w=n[1],E=n[2],S=n[3];return e[0]=b*r+w*u+E*c+S*v,e[1]=b*i+w*a+E*h+S*m,e[2]=b*s+w*f+E*p+S*g,e[3]=b*o+w*l+E*d+S*y,b=n[4],w=n[5],E=n[6],S=n[7],e[4]=b*r+w*u+E*c+S*v,e[5]=b*i+w*a+E*h+S*m,e[6]=b*s+w*f+E*p+S*g,e[7]=b*o+w*l+E*d+S*y,b=n[8],w=n[9],E=n[10],S=n[11],e[8]=b*r+w*u+E*c+S*v,e[9]=b*i+w*a+E*h+S*m,e[10]=b*s+w*f+E*p+S*g,e[11]=b*o+w*l+E*d+S*y,b=n[12],w=n[13],E=n[14],S=n[15],e[12]=b*r+w*u+E*c+S*v,e[13]=b*i+w*a+E*h+S*m,e[14]=b*s+w*f+E*p+S*g,e[15]=b*o+w*l+E*d+S*y,e},h.mul=h.multiply,h.translate=function(e,t,n){var r=n[0],i=n[1],s=n[2],o,u,a,f,l,c,h,p,d,v,m,g;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*s+t[12],e[13]=t[1]*r+t[5]*i+t[9]*s+t[13],e[14]=t[2]*r+t[6]*i+t[10]*s+t[14],e[15]=t[3]*r+t[7]*i+t[11]*s+t[15]):(o=t[0],u=t[1],a=t[2],f=t[3],l=t[4],c=t[5],h=t[6],p=t[7],d=t[8],v=t[9],m=t[10],g=t[11],e[0]=o,e[1]=u,e[2]=a,e[3]=f,e[4]=l,e[5]=c,e[6]=h,e[7]=p,e[8]=d,e[9]=v,e[10]=m,e[11]=g,e[12]=o*r+l*i+d*s+t[12],e[13]=u*r+c*i+v*s+t[13],e[14]=a*r+h*i+m*s+t[14],e[15]=f*r+p*i+g*s+t[15]),e},h.scale=function(e,t,n){var r=n[0],i=n[1],s=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},h.rotate=function(e,n,r,i){var s=i[0],o=i[1],u=i[2],a=Math.sqrt(s*s+o*o+u*u),f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_;return Math.abs(a)<t?null:(a=1/a,s*=a,o*=a,u*=a,f=Math.sin(r),l=Math.cos(r),c=1-l,h=n[0],p=n[1],d=n[2],v=n[3],m=n[4],g=n[5],y=n[6],b=n[7],w=n[8],E=n[9],S=n[10],x=n[11],T=s*s*c+l,N=o*s*c+u*f,C=u*s*c-o*f,k=s*o*c-u*f,L=o*o*c+l,A=u*o*c+s*f,O=s*u*c+o*f,M=o*u*c-s*f,_=u*u*c+l,e[0]=h*T+m*N+w*C,e[1]=p*T+g*N+E*C,e[2]=d*T+y*N+S*C,e[3]=v*T+b*N+x*C,e[4]=h*k+m*L+w*A,e[5]=p*k+g*L+E*A,e[6]=d*k+y*L+S*A,e[7]=v*k+b*L+x*A,e[8]=h*O+m*M+w*_,e[9]=p*O+g*M+E*_,e[10]=d*O+y*M+S*_,e[11]=v*O+b*M+x*_,n!==e&&(e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15]),e)},h.rotateX=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),s=t[4],o=t[5],u=t[6],a=t[7],f=t[8],l=t[9],c=t[10],h=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+f*r,e[5]=o*i+l*r,e[6]=u*i+c*r,e[7]=a*i+h*r,e[8]=f*i-s*r,e[9]=l*i-o*r,e[10]=c*i-u*r,e[11]=h*i-a*r,e},h.rotateY=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),s=t[0],o=t[1],u=t[2],a=t[3],f=t[8],l=t[9],c=t[10],h=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-f*r,e[1]=o*i-l*r,e[2]=u*i-c*r,e[3]=a*i-h*r,e[8]=s*r+f*i,e[9]=o*r+l*i,e[10]=u*r+c*i,e[11]=a*r+h*i,e},h.rotateZ=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),s=t[0],o=t[1],u=t[2],a=t[3],f=t[4],l=t[5],c=t[6],h=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i+f*r,e[1]=o*i+l*r,e[2]=u*i+c*r,e[3]=a*i+h*r,e[4]=f*i-s*r,e[5]=l*i-o*r,e[6]=c*i-u*r,e[7]=h*i-a*r,e},h.fromRotationTranslation=function(e,t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=r+r,a=i+i,f=s+s,l=r*u,c=r*a,h=r*f,p=i*a,d=i*f,v=s*f,m=o*u,g=o*a,y=o*f;return e[0]=1-(p+v),e[1]=c+y,e[2]=h-g,e[3]=0,e[4]=c-y,e[5]=1-(l+v),e[6]=d+m,e[7]=0,e[8]=h+g,e[9]=d-m,e[10]=1-(l+p),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},h.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],s=t[3],o=n+n,u=r+r,a=i+i,f=n*o,l=r*o,c=r*u,h=i*o,p=i*u,d=i*a,v=s*o,m=s*u,g=s*a;return e[0]=1-c-d,e[1]=l+g,e[2]=h-m,e[3]=0,e[4]=l-g,e[5]=1-f-d,e[6]=p+v,e[7]=0,e[8]=h+m,e[9]=p-v,e[10]=1-f-c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},h.frustum=function(e,t,n,r,i,s,o){var u=1/(n-t),a=1/(i-r),f=1/(s-o);return e[0]=s*2*u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*u,e[9]=(i+r)*a,e[10]=(o+s)*f,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*s*2*f,e[15]=0,e},h.perspective=function(e,t,n,r,i){var s=1/Math.tan(t/2),o=1/(r-i);return e[0]=s/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+r)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*r*o,e[15]=0,e},h.ortho=function(e,t,n,r,i,s,o){var u=1/(t-n),a=1/(r-i),f=1/(s-o);return e[0]=-2*u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*f,e[11]=0,e[12]=(t+n)*u,e[13]=(i+r)*a,e[14]=(o+s)*f,e[15]=1,e},h.lookAt=function(e,n,r,i){var s,o,u,a,f,l,c,p,d,v,m=n[0],g=n[1],y=n[2],b=i[0],w=i[1],E=i[2],S=r[0],x=r[1],T=r[2];return Math.abs(m-S)<t&&Math.abs(g-x)<t&&Math.abs(y-T)<t?h.identity(e):(c=m-S,p=g-x,d=y-T,v=1/Math.sqrt(c*c+p*p+d*d),c*=v,p*=v,d*=v,s=w*d-E*p,o=E*c-b*d,u=b*p-w*c,v=Math.sqrt(s*s+o*o+u*u),v?(v=1/v,s*=v,o*=v,u*=v):(s=0,o=0,u=0),a=p*u-d*o,f=d*s-c*u,l=c*o-p*s,v=Math.sqrt(a*a+f*f+l*l),v?(v=1/v,a*=v,f*=v,l*=v):(a=0,f=0,l=0),e[0]=s,e[1]=a,e[2]=c,e[3]=0,e[4]=o,e[5]=f,e[6]=p,e[7]=0,e[8]=u,e[9]=l,e[10]=d,e[11]=0,e[12]=-(s*m+o*g+u*y),e[13]=-(a*m+f*g+l*y),e[14]=-(c*m+p*g+d*y),e[15]=1,e)},h.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},h.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))},typeof e!="undefined"&&(e.mat4=h);var p={};p.create=function(){var e=new n(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},p.rotationTo=function(){var e=u.create(),t=u.fromValues(1,0,0),n=u.fromValues(0,1,0);return function(r,i,s){var o=u.dot(i,s);return o<-0.999999?(u.cross(e,t,i),u.length(e)<1e-6&&u.cross(e,n,i),u.normalize(e,e),p.setAxisAngle(r,e,Math.PI),r):o>.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 e<t?t:e>n?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;o<e.length;o++){var u=e[o];u[0]<r[0]&&(r[0]=u[0]),u[1]<r[1]&&(r[1]=u[1]),u[2]<r[2]&&(r[2]=u[2]),u[0]>i[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]<r[0]||n[1]<r[1]||n[2]<r[2])},applyTransform:function(e){var t=this.min,n=this.max;(t._dirty||n._dirty)&&this.updateVertices();var r=e._array,o=t._array,u=n._array,a=this.vertices,f=a[0];i(f,f,r),s(o,f),s(u,f);for(var l=1;l<8;l++)f=a[l],i(f,f,r),f[0]<o[0]&&(o[0]=f[0]),f[1]<o[1]&&(o[1]=f[1]),f[2]<o[2]&&(o[2]=f[2]),f[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<e.length;o++){var u=e[o];this._createExtension(i,u)}for(var o=0;o<t.length;o++){var a=t[o];r[s][a]=i.getParameter(i[a])}},getExtension:function(e,t){var r=e.__GLID__;if(n[r])return typeof n[r][t]=="undefined"&&this._createExtension(e,t),n[r][t]},getParameter:function(e,t){var n=e.__GLID__;if(r[n])return r[n][t]},dispose:function(e){delete n[e.__GLID__],delete r[e.__GLID__]},_createExtension:function(e,t){var r=e.getExtension(t);r||(r=e.getExtension("MOZ_"+t)),r||(r=e.getExtension("WEBKIT_"+t)),n[e.__GLID__][t]=r}};return i}),r("qtek/DynamicGeometry",["require","./Geometry","./math/BoundingBox","./core/glenum","./core/glinfo","./core/vendor","./dep/glmatrix"],function(e){var t=e("./Geometry"),n=e("./math/BoundingBox"),r=e("./core/glenum"),i=e("./core/glinfo"),s=e("./core/vendor"),o=e("./dep/glmatrix"),u=o.vec3,a=o.mat4,f=u.add,l=u.create,c=Array.prototype.slice,h=t.Attribute,p=t.derive(function(){return{attributes:{position:new h("position","float",3,"POSITION",!0),texcoord0:new h("texcoord0","float",2,"TEXCOORD_0",!0),texcoord1:new h("texcoord1","float",2,"TEXCOORD_1",!0),normal:new h("normal","float",3,"NORMAL",!0),tangent:new h("tangent","float",4,"TANGENT",!0),color:new h("color","float",4,"COLOR",!0),weight:new h("weight","float",3,"WEIGHT",!0),joint:new h("joint","float",4,"JOINT",!0),barycentric:new h("barycentric","float",3,null,!0)},dynamic:!0,hint:r.DYNAMIC_DRAW,faces:[],_enabledAttributes:null,_arrayChunks:[]}},{updateBoundingBox:function(){var e=this.boundingBox;e||(e=this.boundingBox=new n),e.updateFromVertices(this.attributes.position.value)},dirty:function(e){if(!e){this.dirty("indices");for(var t in this.attributes)this.dirty(t);return}this._cache.dirtyAll(e),this._cache.dirtyAll(),this._enabledAttributes=null},getVertexNumber:function(){var e=this.attributes[this.mainAttribute];return!e||!e.value?0:e.value.length},getFaceNumber:function(){return this.faces.length},getFace:function(e,t){if(e<this.getFaceNumber()&&e>=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;i<t.length;i++){var s=t[i],o=this.attributes[s];o.value.length&&o.value.length===r&&(n[s]=o)}return this._enabledAttributes=n,n},_getDirtyAttributes:function(){var e=this.getEnabledAttributes(),t=this._cache;if(t.miss("chunks"))return e;var n={},r=!0;for(var i in e)t.isDirty(i)&&(n[i]=e[i],r=!1);if(!r)return n},getChunkNumber:function(){return this._arrayChunks.length},getBufferChunks:function(e){var t=this._cache;t.use(e.__GLID__);if(t.isDirty()){var n=this._getDirtyAttributes(),r=t.isDirty("indices");r=r&&this.isUseFace();if(n){this._updateAttributesAndIndicesArrays(n,r,i.getExtension(e,"OES_element_index_uint")!=null),this._updateBuffer(e,n,r);for(var s in n)t.fresh(s);t.fresh("indices"),t.fresh()}}return t.get("chunks")},_updateAttributesAndIndicesArrays:function(e,t,n){var r=this,i=this.getVertexNumber(),o=[],u=[],a={};for(var f in e)switch(j){case"byte":a[f]=s.Int8Array;break;case"ubyte":a[f]=s.Uint8Array;break;case"short":a[f]=s.Int16Array;break;case"ushort":a[f]=s.Uint16Array;break;default:a[f]=s.Float32Array}var l=function(t){if(r._arrayChunks[t])return r._arrayChunks[t];var n={attributeArrays:{},indicesArray:null};for(var s in e)n.attributeArrays[s]=null;for(var u=0;u<i;u++)o[u]=-1;return r._arrayChunks.push(n),n},c=Object.keys(e);if(i>65535&&this.isUseFace()&&!n){var h=0,p,d=[0],v=[];for(g=0;g<i;g++)v[g]=-1,o[g]=-1;if(t)for(g=0;g<this.faces.length;g++)u[g]=[0,0,0];p=l(h);var m=0;for(var g=0;g<this.faces.length;g++){var y=this.faces[g],b=u[g];m+3>65535&&(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;x<c.length;x++){var f=c[x],T=p.attributeArrays[f],N=e[f].value,C=e[f].size;T||(T=p.attributeArrays[f]=[]);if(S){C===1&&(T[m]=N[E]);for(var k=0;k<C;k++)T[m*C+k]=N[E][k]}}S?(o[E]=m,b[w]=m,m++):b[w]=o[E]}}for(var L=0;L<this._arrayChunks.length;L++){var A=this._arrayChunks[L];for(var f in A.attributeArrays){var O=A.attributeArrays[f];O instanceof Array&&(A.attributeArrays[f]=new a[f](O))}}if(t){var M,_,D,A;for(var L=0;L<this._arrayChunks.length;L++){M=d[L],_=d[L+1]||this.faces.length,D=0,A=this._arrayChunks[L];var P=A.indicesArray;P||(P=A.indicesArray=new Uint16Array((_-M)*3));for(var g=M;g<_;g++)P[D++]=u[g][0],P[D++]=u[g][1],P[D++]=u[g][2]}}}else{var A=l(0);if(t){var P=A.indicesArray,H=this.faces.length;if(!P||H*3!==P.length){var B=i>65535?Uint32Array:Uint16Array;P=A.indicesArray=new B(this.faces.length*3)}var D=0;for(var g=0;g<H;g++)P[D++]=this.faces[g][0],P[D++]=this.faces[g][1],P[D++]=this.faces[g][2]}for(var f in e){var N=e[f].value,j=e[f].type,C=e[f].size,T=A.attributeArrays[f],F=i*C;if(!T||T.length!==F)T=new a[f](F),A.attributeArrays[f]=T;if(C===1)for(var g=0;g<N.length;g++)T[g]=N[g];else{var D=0;for(var g=0;g<N.length;g++)for(var k=0;k<C;k++)T[D++]=N[g][k]}}}},_updateBuffer:function(e,n,r){var i=this._cache.get("chunks"),s=!1;if(!i){i=[];for(var o=0;o<this._arrayChunks.length;o++)i[o]={attributeBuffers:[],indicesBuffer:null};this._cache.put("chunks",i),s=!0}for(var u=0;u<this._arrayChunks.length;u++){var a=i[u];a||(a=i[u]={attributeBuffers:[],indicesBuffer:null});var f=a.attributeBuffers,l=a.indicesBuffer,c=this._arrayChunks[u],h=c.attributeArrays,p=c.indicesArray,d=0,v=0;for(var m in n){var g=n[m],y=g.type,b=g.semantic,w=g.size,E;if(!s){for(var o=v;o<f.length;o++)if(f[o].name===m){E=f[o],v=o+1;break}if(!E)for(var o=v-1;o>=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;c<i.length;c++)u.set(i[c],0,0,0);for(var c=i.length;c<r.length;c++)i[c]=[0,0,0];for(var h=0;h<t;h++){var p=e[h],d=p[0],v=p[1],m=p[2],g=r[d],y=r[v],b=r[m];u.sub(o,g,y),u.sub(a,y,b),u.cross(s,o,a),f(i[d],i[d],s),f(i[v],i[v],s),f(i[m],i[m],s)}for(var c=0;c<i.length;c++)u.normalize(i[c],i[c])},generateFaceNormals:function(){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.faces,t=e.length,n=this.attributes,r=n.position.value,i=n.normal.value,s=l(),o=l(),a=l(),f=i.length===r.length;for(var h=0;h<t;h++){var p=e[h],d=p[0],v=p[1],m=p[2],g=r[d],y=r[v],b=r[m];u.sub(o,g,y),u.sub(a,y,b),u.cross(s,o,a),f?(u.copy(i[d],s),u.copy(i[v],s),u.copy(i[m],s)):i[d]=i[v]=i[m]=c.call(s)}},generateTangents:function(){var e=this.attributes,t=e.texcoord0.value,n=e.position.value,r=e.tangent.value,i=e.normal.value,s=[],o=[],a=this.getVertexNumber();for(var l=0;l<a;l++)s[l]=[0,0,0],o[l]=[0,0,0];var c=[0,0,0],h=[0,0,0];for(var l=0;l<this.faces.length;l++){var p=this.faces[l],d=p[0],v=p[1],m=p[2],g=t[d],y=t[v],b=t[m],w=n[d],E=n[v],S=n[m],x=E[0]-w[0],T=S[0]-w[0],N=E[1]-w[1],C=S[1]-w[1],k=E[2]-w[2],L=S[2]-w[2],A=y[0]-g[0],O=b[0]-g[0],M=y[1]-g[1],_=b[1]-g[1],D=1/(A*_-M*O);c[0]=(_*x-M*T)*D,c[1]=(_*N-M*C)*D,c[2]=(_*k-M*L)*D,h[0]=(A*T-O*x)*D,h[1]=(A*C-O*N)*D,h[2]=(A*L-O*k)*D,f(s[d],s[d],c),f(s[v],s[v],c),f(s[m],s[m],c),f(o[d],o[d],h),f(o[v],o[v],h),f(o[m],o[m],h)}var P=[0,0,0,0],H=[0,0,0];for(var l=0;l<a;l++){var B=i[l],j=s[l];u.scale(P,B,u.dot(B,j)),u.sub(P,j,P),u.normalize(P,P),u.cross(H,B,j),P[3]=u.dot(H,o[l])<0?-1:1,r[l]=P.slice()}},isUniqueVertex:function(){return this.isUseFace()?this.getVertexNumber()===this.faces.length*3:!0},generateUniqueVertex:function(){var e=[];for(var t=0;t<this.getVertexNumber();t++)e[t]=0;var n=this.getVertexNumber(),r=this.getEnabledAttributes(),i=this.faces,s=Object.keys(r);for(var t=0;t<i.length;t++){var o=i[t];for(var u=0;u<3;u++){var a=o[u];if(e[a]>0){for(var f=0;f<s.length;f++){var l=s[f],h=r[l].value,p=r[l].size;p===1?h.push(h[a]):h.push(c.call(h[a]))}o[u]=n,n++}e[a]++}}this.dirty()},generateBarycentric:function(){var e=[1,0,0],t=[0,0,1],n=[0,1,0];return function(){this.isUniqueVertex()||this.generateUniqueVertex();var r=this.attributes.barycentric.value;if(r.length==this.faces.length*3)return;var i,s,o,u;for(var a=0;a<this.faces.length;a++)u=this.faces[a],i=u[0],s=u[1],o=u[2],r[i]=e,r[s]=t,r[o]=n}}(),convertToStatic:function(e,t){this._updateAttributesAndIndicesArrays(this.getEnabledAttributes(),!0,t);if(this._arrayChunks.length>1)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;o<n.length;o++)s(n[o],n[o],e);var f=a.create();a.invert(f,e),a.transpose(f,f);for(var o=0;o<r.length;o++)s(r[o],r[o],f);for(var o=0;o<i.length;o++)s(i[o],i[o],f);this.boundingBox&&this.updateBoundingBox()},dispose:function(e){var t=this._cache;t.use(e.__GLID__);var n=t.get("chunks");if(n)for(var r=0;r<n.length;r++){var i=n[r];for(var s=0;s<i.attributeBuffers.length;s++){var o=i.attributeBuffers[s];e.deleteBuffer(o.buffer)}}t.deleteContext(e.__GLID__)}});return p}),r("grapher/geometry/Lines",["require","qtek/DynamicGeometry","qtek/Geometry"],function(e){var t=e("qtek/DynamicGeometry"),n=e("qtek/Geometry").Attribute,r=t.derive(function(){return{attributes:{position:new n("position","float",3,"POSITION",!0),color:new n("color","float",4,"COLOR",!0)}}},{addLine:function(e,t,n){var r=this.attributes;r.position.value.push(e,t),n&&r.color.value.push(n,n)}});return r}),r("grapher/core/color",[],function(){function t(e){return e=Math.round(e),e<0?0:e>255?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;n<t.length;n++)if(t[n].name===e)return t[n]},getDescendantByName:function(e){var t=this._children;for(var n=0;n<t.length;n++){var r=t[n];if(r.name===e)return r;var i=r.getDescendantByName(e);if(i)return i}},queryNode:function(e){if(!e)return;var t=e.split("/"),n=this;for(var r=0;r<t.length;r++){var i=t[r];if(!i)continue;var s=!1,o=n._children;for(var u=0;u<o.length;u++){var a=o[u];if(a.name===i){n=a,s=!0;break}}if(!s)return}return n},getPath:function(e){if(!this._parent)return"/";var t=this._parent,n=this.name;while(t._parent){n=t.name+"/"+n;if(t._parent==e)break;t=t._parent}return!t._parent&&e?null:n},traverse:function(e,t,n){this._inIterating=!0,(n===undefined||this.constructor===n)&&e.call(t,this);var r=this._children;for(var i=0,s=r.length;i<s;i++)r[i].traverse(e,t,n);this._inIterating=!1},setLocalTransform:function(e){o.copy(this.localTransform._array,e._array),this.decomposeLocalTransform()},decomposeLocalTransform:function(e){var t=e?null:this.scale;this.localTransform.decomposeMatrix(t,this.rotation,this.position)},setWorldTransform:function(e){o.copy(this.worldTransform._array,e._array),this.decomposeWorldTransform()},decomposeWorldTransform:function(){var e=o.create();return function(t){var n=this.localTransform,r=this.worldTransform;this._parent?(o.invert(e,this._parent.worldTransform._array),o.multiply(n._array,e,r._array)):o.copy(n._array,r._array);var i=t?null:this.scale;n.decomposeMatrix(i,this.rotation,this.position)}}(),updateLocalTransform:function(){var e=this.position,t=this.rotation,n=this.scale;if(e._dirty||n._dirty||t._dirty){var r=this.localTransform._array;o.fromRotationTranslation(r,t._array,e._array),o.scale(r,r,n._array),t._dirty=!1,n._dirty=!1,e._dirty=!1,this._needsUpdateWorldTransform=!0}},updateWorldTransform:function(){var e=this.localTransform._array,t=this.worldTransform._array;this._parent?o.multiply(t,this._parent.worldTransform._array,e):o.copy(t,e)},update:function(e){this.autoUpdateLocalTransform?this.updateLocalTransform():e=!0;if(e||this._needsUpdateWorldTransform)this.updateWorldTransform(),e=!0,this._needsUpdateWorldTransform=!1;var t=this._children;for(var n=0,r=t.length;n<r;n++)t[n].update(e)},getWorldPosition:function(e){var t=this.worldTransform._array;if(e){var r=e._array;return r[0]=t[12],r[1]=t[13],r[2]=t[14],e}return new n(t[12],t[13],t[14])},clone:function(){var e=new this.constructor,t=this._children;e.setName(this.name),e.position.copy(this.position),e.rotation.copy(this.rotation),e.scale.copy(this.scale);for(var n=0;n<t.length;n++)e.add(t[n].clone());return e},rotateAround:function(){var e=new n,t=new i;return function(n,r,i){e.copy(this.position).subtract(n);var s=this.localTransform;s.identity(),s.translate(n),s.rotate(i,r),t.fromRotationTranslation(this.rotation,e),s.multiply(t),s.scale(this.scale),this.decomposeLocalTransform(),this._needsUpdateWorldTransform=!0}}(),lookAt:function(){var e=new i;return function(t,n){e.lookAt(this.position,t,n||this.localTransform.y).invert(),e.decomposeMatrix(null,this.rotation,this.position)}}()});return a}),r("qtek/Renderable",["require","./Node","./core/glenum","./core/glinfo","./DynamicGeometry"],function(e){function l(e,t,n){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=n,this.vao=null}var t=e("./Node"),n=e("./core/glenum"),r=e("./core/glinfo"),i=e("./DynamicGeometry"),s=0,o=null,u=!0,a,f=function(){this.faceNumber=0,this.vertexNumber=0,this.drawCallNumber=0},c=t.derive({material:null,geometry:null,mode:n.TRIANGLES,_drawCache:null,_renderInfo:null},function(){this._drawCache={},this._renderInfo=new f},{lineWidth:1,culling:!0,cullFace:n.BACK,frontFace:n.CCW,frustumCulling:!0,receiveShadow:!0,castShadow:!0,ignorePicking:!1,isRenderable:function(){return this.geometry&&this.material&&this.visible},render:function(e,t){var f=t||this.material,c=f.shader,h=this.geometry,p=this.mode,d=h.getVertexNumber(),v=h.isUseFace(),m=r.getExtension(e,"OES_element_index_uint"),g=m&&d>65535,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;N<T.length;N++){var C=T[N],k=C.attributeBuffers,L=C.indicesBuffer,A=[],O=[];for(var M=0;M<k.length;M++){var _=k[M],D=_.name,P=_.semantic,H;if(P){var B=c.attribSemantics[P];H=B&&B.symbol}else H=D;H&&c.attributeTemplates[H]&&(A.push(_),O.push(H))}var j=new l(A,O,L);x.push(j)}w&&(this._drawCache[a]=x)}for(var F=0;F<x.length;F++){var j=x[F],I=!0;b&&w&&(j.vao==null?j.vao=b.createVertexArrayOES():I=!1,b.bindVertexArrayOES(j.vao));var A=j.availableAttributes,L=j.indicesBuffer;if(I){var q=c.enableAttributes(e,j.availableAttributeSymbols,b&&w&&j.vao);for(var M=0;M<A.length;M++){var R=q[M];if(R===-1)continue;var _=A[M],U=_.buffer,z=_.size,W;switch(_.type){case"float":W=e.FLOAT;break;case"byte":W=e.BYTE;break;case"ubyte":W=e.UNSIGNED_BYTE;break;case"short":W=e.SHORT;break;case"ushort":W=e.UNSIGNED_SHORT;break;default:W=e.FLOAT}e.bindBuffer(e.ARRAY_BUFFER,U),e.vertexAttribPointer(R,z,W,!1,0,0)}}(p==n.LINES||p==n.LINE_STRIP||p==n.LINE_LOOP)&&e.lineWidth(this.lineWidth),o=L,u=h.isUseFace(),u?(I&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,L.buffer),e.drawElements(p,L.count,y,0),E.faceNumber+=L.count/3):e.drawArrays(p,0,d),b&&w&&b.bindVertexArrayOES(null),E.drawCallNumber++}}return E},clone:function(){var e=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling"];return function(){var n=t.prototype.clone.call(this);n.geometry=this.geometry,n.material=this.material;for(var r=0;r<e.length;r++){var i=e[r];n[i]!==this[i]&&(n[i]=this[i])}return n}}()});return c.beforeFrame=function(){s=0},c.POINTS=n.POINTS,c.LINES=n.LINES,c.LINE_LOOP=n.LINE_LOOP,c.LINE_STRIP=n.LINE_STRIP,c.TRIANGLES=n.TRIANGLES,c.TRIANGLE_STRIP=n.TRIANGLE_STRIP,c.TRIANGLE_FAN=n.TRIANGLE_FAN,c.BACK=n.BACK,c.FRONT=n.FRONT,c.FRONT_AND_BACK=n.FRONT_AND_BACK,c.CW=n.CW,c.CCW=n.CCW,c.RenderInfo=f,c}),r("grapher/graph/component/Cartesian3D",["require","../../coordinate/Cartesian","../../geometry/Lines","../../core/color","qtek/Node","qtek/Renderable","qtek/core/util","qtek/math/Vector3"],function(e){var t=e("../../coordinate/Cartesian"),n=e("../../geometry/Lines"),r=e("../../core/color"),i=e("qtek/Node"),s=e("qtek/Renderable"),o=e("qtek/core/util"),u=e("qtek/math/Vector3"),a=["x","y","z"],f={xAxis:{lineColor:"#f00"},yAxis:{lineColor:"#0f0"},zAxis:{lineColor:"#00f"}},l=function(e,n){n=n||{};var r=n.size||100,s=new t(r),o=new i({name:"cartesian"});o.scale.set(r,r,r),this.root=o,this._cartesian=s,this._app3d=e,this._initAxes(n)};return l.prototype={constructor:l,valueToCoord:function(e){return this._cartesian.valueToCoord(e)},coordToValue:function(e){return this._cartesian.coordToValue(e)},_initAxes:function(e){var t=this,i=this._app3d,u=new s({geometry:new n,material:i.createColorMaterial([1,1,1],1,!0),mode:s.LINES,lineWidth:e.axisLineWidth}),l=new s({geometry:new n,material:i.createColorMaterial(r.parse(e.axisWireframeLineColor),1,!1),mode:s.LINES,lineWidth:e.axisWireframeLineWidth});this.root.add(u),this.root.add(l);var c=[0,0,0],h={x:[1,0,0],y:[0,1,0],z:[0,0,1]};a.forEach(function(n,i){var s=n+"Axis",a=o.extend({},e[s]);o.defaults(a,f[s]),t._cartesian.addAxis(n,a.range),u.geometry.addLine(c,h[n],r.parse(a.lineColor))});var p=[[0,1,0],[0,1,1],[0,1,0],[1,1,0],[1,1,0],[1,1,1],[0,1,1],[1,1,1],[0,0,1],[1,0,1],[1,0,0],[1,0,1],[0,1,1],[0,0,1],[1,1,1],[1,0,1],[1,1,0],[1,0,0]];for(var d=0;d<p.length;)l.geometry.addLine(p[d++],p[d++])}},l.DEFAULTS=f,l}),r("qtek/canvas/Renderer",["require","../core/Base","../dep/glmatrix","../core/glenum"],function(e){function d(e){this.ctor=e,this._data=[],this._size=0}function v(){this.vertices=[f(),f(),f()],this.color=f(),this.depth=0}function m(){this.vertices=[f()],this.color=f(),this.depth=0}function g(){this.vertices=[f(),f()],this.color=f(),this.depth=0,this.lineWidth=1}function y(e,t){return t.depth-e.depth}function b(e){return"rgb("+l(e[0]*255)+","+l(e[1]*255)+","+l(e[2]*255)+")"}function w(e){return"rgba("+l(e[0]*255)+","+l(e[1]*255)+","+l(e[2]*255)+","+e[3]+")"}var t=e("../core/Base"),n=e("../dep/glmatrix"),r=e("../core/glenum"),i=n.mat4,s=n.vec3,o=n.vec4,u=s.set,a=s.create,f=o.create,l=Math.round,c=1,h=2,p=3;d.prototype={pick:function(){var e=this._data,t=this._size,n=e[t];return n||(n=new this.ctor,e[t]=n),this._size++,n},reset:function(){this._size=0},shrink:function(){this._data.length=this._size},clear:function(){this._data=[],this._size=0}},v.prototype.type=c,m.prototype.type=p,g.prototype.type=h;var E=t.derive({canvas:null,_width:100,_height:100,devicePixelRatio:window.devicePixelRatio||1,color:[0,0,0,0],clear:!0,ctx:null,_primitives:[],_triangles:new d(v),_lines:new d(g),_points:new d(m)},function(){this.canvas||(this.canvas=document.createElement("canvas"));var e=this.canvas;try{this.ctx=e.getContext("2d");var t=this.ctx;if(!t)throw new Error}catch(n){throw"Error creating WebGL Context "+n}this.resize()},{resize:function(e,t){var n=this.devicePixelRatio,r=this.canvas;e!=null?(r.style.width=e+"px",r.style.height=t+"px",r.width=e*n,r.height=t*n,this._width=e,this._height=t):(this._width=r.width/n,this._height=r.height/n)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){return this._width/this._height},render:function(e,t){if(this.clear){var n=this.color,r=this.ctx,i=this.devicePixelRatio,s=this._width*i,o=this._height*i;n&&n[3]===0?r.clearRect(0,0,s,o):(n[3]<1&&r.clearRect(0,0,s,o),r.fillStyle=n.length===4?w(n):b(n),r.fillRect(0,0,s,o))}e.update(),t.update();var u=e.opaqueQueue,a=e.transparentQueue,f=e.material,l=u.concat(a);this.renderQueue(l,t)},renderQueue:function(e,t){var n=i.create();i.multiply(n,t.projectionMatrix._array,t.viewMatrix._array);var u=i.create(),a=s.create(),f=this._primitives,l=this._triangles,c=this._lines,h=this._points;l.reset(),c.reset(),h.reset();var p=0,d=[0,0,0],v=[];for(var m=0;m<e.length;m++){var g=e[m];i.multiply(u,n,g.worldTransform._array);var b=g.geometry,w=g.material,E=b.attributes;w.color.length==3?(s.copy(v,w.color),v[3]=1):o.copy(v,w.color);var S=b.getVertexNumber();switch(g.mode){case r.TRIANGLES:if(b.isUseFace()){var x=b.getFaceNumber();for(var T=0;T<x;T++){b.getFace(T,d);var N=l.pick();N.material=w;var C=this._setPrimitive(N,d,3,E,u,v);C||(f[p++]=N)}}else for(var T=0;T<S;){d[0]=T++,d[1]=T++,d[2]=T++;var N=l.pick();N.material=w;var C=this._setPrimitive(N,d,3,E,u,v);C||(f[p++]=N)}break;case r.LINES:for(var T=0;T<S;){d[0]=T++,d[1]=T++;var k=c.pick();k.material=w,k.lineWidth=g.lineWidth;var C=this._setPrimitive(k,d,2,E,u,v);C||(f[p++]=k)}break;case r.POINTS:for(var T=0;T<S;T++){d[0]=T;var L=h.pick();L.material=w;var C=this._setPrimitive(L,d,1,E,u,v);C||(f[p++]=L)}}}l.shrink(),c.shrink(),h.shrink(),f.length=p,f.sort(y),this._drawPrimitives(f)},_setPrimitive:function(){var e=f();return function(t,n,r,i,s,u){var a=i.color,f=a.value&&a.value.length>0,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<r;p++){var d=t.vertices[p];i.position.get(n[p],d),d[3]=1,o.transformMat4(d,d,s),f&&(a.get(n[p],e),o.scaleAndAdd(l,l,e,h));var v=d[0],m=d[1],g=d[2],y=d[3];v>-y&&v<y&&m>-y&&m<y&&g>-y&&g<y&&(c=!1);var b=1/y;d[0]=v*b,d[1]=m*b,d[2]=g*b,t.depth+=d[2]}return c||(t.depth/=r,f?o.mul(l,l,u):o.copy(l,u)),c}}(),_drawPrimitives:function(e){var t=this.ctx;t.save();var n,r=this.devicePixelRatio,i=this._width*r,s=this._height*r,o=i/2,u=s/2,a,f;for(var l=0;l<e.length;l++){var d=e[l],v=d.vertices,m=d.type,g=d.material;g!==n&&(t.globalAlpha=g.opacity,n=g);var y=w(d.color);switch(m){case c:var b=v[0],E=v[1],S=v[2];t.fillStyle=y,t.beginPath(),t.moveTo((b[0]+1)*o,(-b[1]+1)*u),t.lineTo((E[0]+1)*o,(-E[1]+1)*u),t.lineTo((S[0]+1)*o,(-S[1]+1)*u),t.closePath(),t.fill();break;case h:var b=v[0],E=v[1],x=d.lineWidth;f!==y&&(f=t.strokeStyle=y),x!==a&&(t.lineWidth=a=x),t.beginPath(),t.moveTo((b[0]+1)*o,(-b[1]+1)*u),t.lineTo((E[0]+1)*o,(-E[1]+1)*u),t.stroke();break;case p:var T=g.pointSize,N=g.pointShape,C=T/2;if(T>0){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;n<r;n++)t[n]=n+1+": "+t[n];return t.join("\n")}var t=e("./core/Base"),n=e("./core/util"),r=e("./core/Cache"),i=e("./core/vendor"),s=e("./dep/glmatrix"),o=s.mat2,u=s.mat3,a=s.mat4,f=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\w\,]+)?(\[.*?\])?\s*(:\s*([\S\s]+?))?;/g,l=/attribute\s+(float|int|vec2|vec3|vec4)\s+(\w*)\s*(:\s*(\w+))?;/g,c=/#define\s+(\w+)?(\s+[\w-.]+)?\s*\n/g,h={bool:"1i","int":"1i",sampler2D:"t",samplerCube:"t","float":"1f",vec2:"2f",vec3:"3f",vec4:"4f",ivec2:"2i",ivec3:"3i",ivec4:"4i",mat2:"m2",mat3:"m3",mat4:"m4"},p={bool:function(){return!0},"int":function(){return 0},"float":function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return[0,0]},vec3:function(){return[0,0,0]},vec4:function(){return[0,0,0,0]},ivec2:function(){return[0,0]},ivec3:function(){return[0,0,0]},ivec4:function(){return[0,0,0,0]},mat2:function(){return o.create()},mat3:function(){return u.create()},mat4:function(){return a.create()},array:function(){return[]}},d=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT","SKIN_MATRIX"],v=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],m={},g=1,y=2,b=3,w=t.derive(function(){return{vertex:"",fragment:"",precision:"mediump",attribSemantics:{},matrixSemantics:{},matrixSemanticKeys:[],uniformTemplates:{},attributeTemplates:{},vertexDefines:{},fragmentDefines:{},lightNumber:{},_attacheMaterialNumber:0,_uniformList:[],_textureStatus:{},_vertexProcessed:"",_fragmentProcessed:"",_currentLocationsMap:{}}},function(){this._cache=new r,this._updateShaderString()},{setVertex:function(e){this.vertex=e,this._updateShaderString(),this.dirty()},setFragment:function(e){this.fragment=e,this._updateShaderString(),this.dirty()},bind:function(e){var t=this._cache;t.use(e.__GLID__,E),this._currentLocationsMap=t.get("locations");if(t.isDirty()){this._updateShaderString();var n=this._buildProgram(e,this._vertexProcessed,this._fragmentProcessed);t.fresh();if(n)return n}e.useProgram(t.get("program"))},dirty:function(){var e=this._cache;e.dirtyAll();for(var t=0;t<e._caches.length;t++)if(e._caches[t]){var n=e._caches[t];n.locations={},n.attriblocations={}}},_updateShaderString:function(){if(this.vertex!==this._vertexPrev||this.fragment!==this._fragmentPrev)this._parseImport(),this.attribSemantics={},this.matrixSemantics={},this._textureStatus={},this._parseUniforms(),this._parseAttributes(),this._parseDefines(),this._vertexPrev=this.vertex,this._fragmentPrev=this.fragment;this._addDefine()},define:function(e,t,n){var r=this.vertexDefines,i=this.fragmentDefines;n=n!==undefined?n:null,(e=="vertex"||e=="both")&&r[t]!==n&&(r[t]=n,this.dirty()),(e=="fragment"||e=="both")&&i[t]!==n&&(i[t]=n,e!=="both"&&this.dirty())},unDefine:function(e,t){(e=="vertex"||e=="both")&&this.isDefined("vertex",t)&&(delete this.vertexDefines[t],this.dirty()),(e=="fragment"||e=="both")&&this.isDefined("fragment",t)&&(delete this.fragmentDefines[t],e!=="both"&&this.dirty())},isDefined:function(e,t){switch(e){case"vertex":return this.vertexDefines[t]!==undefined;case"fragment":return this.fragmentDefines[t]!==undefined}},getDefine:function(e,t){switch(e){case"vertex":return this.vertexDefines[t];case"fragment":return this.fragmentDefines[t]}},enableTexture:function(e){var t=this._textureStatus[e];if(t){var n=t.enabled;n||(t.enabled=!0,this.dirty())}},enableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!0;this.dirty()},disableTexture:function(e){var t=this._textureStatus[e];if(t){var n=!t.enabled;n||(t.enabled=!1,this.dirty())}},disableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!1;this.dirty()},isTextureEnabled:function(e){return this._textureStatus[e].enabled},getEnabledTextures:function(){var e=[],t=this._textureStatus;for(var n in t)t[n].enabled&&e.push(n);return e},hasUniform:function(e){var t=this._currentLocationsMap[e];return t!==null&&t!==undefined},setUniform:function(e,t,n,r){var s=this._currentLocationsMap,o=s[n];if(o===null||o===undefined)return!1;switch(t){case"m4":e.uniformMatrix4fv(o,!1,r);break;case"2i":e.uniform2i(o,r[0],r[1]);break;case"2f":e.uniform2f(o,r[0],r[1]);break;case"3i":e.uniform3i(o,r[0],r[1],r[2]);break;case"3f":e.uniform3f(o,r[0],r[1],r[2]);break;case"4i":e.uniform4i(o,r[0],r[1],r[2],r[3]);break;case"4f":e.uniform4f(o,r[0],r[1],r[2],r[3]);break;case"1i":e.uniform1i(o,r);break;case"1f":e.uniform1f(o,r);break;case"1fv":e.uniform1fv(o,r);break;case"1iv":e.uniform1iv(o,r);break;case"2iv":e.uniform2iv(o,r);break;case"2fv":e.uniform2fv(o,r);break;case"3iv":e.uniform3iv(o,r);break;case"3fv":e.uniform3fv(o,r);break;case"4iv":e.uniform4iv(o,r);break;case"4fv":e.uniform4fv(o,r);break;case"m2":case"m2v":e.uniformMatrix2fv(o,!1,r);break;case"m3":case"m3v":e.uniformMatrix3fv(o,!1,r);break;case"m4v":if(r instanceof Array){var u=new i.Float32Array(r.length*16),a=0;for(var f=0;f<r.length;f++){var l=r[f];for(var c=0;c<16;c++)u[a++]=l[c]}e.uniformMatrix4fv(o,!1,u)}else r instanceof i.Float32Array&&e.uniformMatrix4fv(o,!1,r)}return!0},setUniformBySemantic:function(e,t,n){var r=this.attribSemantics[t];return r?this.setUniform(e,r.type,r.symbol,n):!1},enableAttributes:function(e,t,n){var r=this._cache.get("program"),i=this._cache.get("attriblocations"),s;n?s=n.__enabledAttributeList:s=m[e.__GLID__],s||(n?s=n.__enabledAttributeList=[]:s=m[e.__GLID__]=[]);var o=[];for(var u=0;u<t.length;u++){var a=t[u];if(!this.attributeTemplates[a]){o[u]=-1;continue}var f=i[a];if(f===undefined){f=e.getAttribLocation(r,a);if(f===-1){o[u]=-1;continue}i[a]=f}o[u]=f,s[f]?s[f]=y:s[f]=g}for(var u=0;u<s.length;u++)switch(s[u]){case g:e.enableVertexAttribArray(u),s[u]=b;break;case y:s[u]=b;break;case b:e.disableVertexAttribArray(u),s[u]=0}return o},_parseImport:function(){this._vertexProcessedNoDefine=w.parseImport(this.vertex),this._fragmentProcessedNoDefine=w.parseImport(this.fragment)},_addDefine:function(){var e=this.lightNumber,t=this._textureStatus,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.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<this._uniformList.length;f++){var l=this._uniformList[f],c=r.get("locations");c[l]=e.getUniformLocation(i,l)}e.deleteShader(s),e.deleteShader(o),r.put("program",i)},clone:function(){var e=new w({vertex:this.vertex,fragment:this.fragment,vertexDefines:n.clone(this.vertexDefines),fragmentDefines:n.clone(this.fragmentDefines)});for(var t in this._textureStatus)e._textureStatus[t]=n.clone(this._textureStatus[t]);return e},dispose:function(e){this._cache.use(e.__GLID__);var t=this._cache.get("program");t&&e.deleteProgram(t),this._cache.deleteContext(e.__GLID__),this._locations={}}}),T=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;w.parseImport=function(e){return e=e.replace(T,function(e,t,n){var e=w.source(n);return e?w.parseImport(e):(console.warn('Shader chunk "'+n+'" not existed in library'),"")}),e};var N=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;return w["import"]=function(e){e.replace(N,function(e,t,n,r){var r=r.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"");if(r){var i=n.split("."),s=w.codes,o=0,u;while(o<i.length-1)u=i[o++],s[u]||(s[u]={}),s=s[u];u=i[o],s[u]=r}return r})},w.codes={},w.source=function(e){var t=e.split("."),n=w.codes,r=0;while(n&&r<t.length){var i=t[r++];n=n[i]}if(!n){console.warn('Shader "'+e+'" not existed in library');return}return n},w}),r("qtek/shader/library",["require","../Shader","../core/util"],function(e){function i(){this._pool={}}function s(e,t,n){r[e]={vertex:t,fragment:n}}var t=e("../Shader"),n=e("../core/util"),r={};i.prototype.get=function(e,n){var i=[],s={},o={};typeof n=="string"?i=Array.prototype.slice.call(arguments,1):Object.prototype.toString.call(n)=="[object Object]"?(i=n.textures||[],s=n.vertexDefines||{},o=n.fragmentDefines||{}):n instanceof Array&&(i=n);var u=Object.keys(s),a=Object.keys(o);i.sort(),u.sort(),a.sort();var f=[e];f=f.concat(i);for(var l=0;l<u.length;l++)f.push(s[u[l]]);for(var l=0;l<a.length;l++)f.push(o[a[l]]);var c=f.join("_");if(this._pool[c])return this._pool[c];var h=r[e];if(!h){console.error('Shader "'+e+'"'+" is not in the library");return}var p=new t({vertex:h.vertex,fragment:h.fragment});for(var l=0;l<i.length;l++)p.enableTexture(i[l]);for(var e in s)p.define("vertex",e,s[e]);for(var e in o)p.define("fragment",e,o[e]);return this._pool[c]=p,p},i.prototype.clear=function(){this._pool={}};var o=new i;return{createLibrary:function(){return new i},get:function(){return o.get.apply(o,arguments)},template:s,clear:function(){return o.clear()}}}),r("qtek/Material",["require","./core/Base","./Texture"],function(e){var t=e("./core/Base"),n=e("./Texture"),r=t.derive({name:"",uniforms:null,shader:null,depthTest:!0,depthMask:!0,transparent:!1,blend:null,_enabledUniforms:null},function(){this.name||(this.name="MATERIAL_"+this.__GUID__),this.shader&&this.attachShader(this.shader),this.uniforms||(this.uniforms={})},{bind:function(e,t){var r=0,i=t&&t.shader===this.shader;for(var s=0;s<this._enabledUniforms.length;s++){var o=this._enabledUniforms[s],u=this.uniforms[o],a=u.value;if(i&&t.uniforms[o].value===a)continue;if(a===undefined){console.warn('Uniform value "'+o+'" is undefined');continue}if(a===null)continue;if(a instanceof Array&&!a.length)continue;if(a instanceof n){var f=this.shader.setUniform(e,"1i",o,r);if(!f)continue;var l=a;e.activeTexture(e.TEXTURE0+r),l.isRenderable()?l.bind(e):l.unbind(e),r++}else if(a instanceof Array){if(a.length===0)continue;var c=a[0];if(c instanceof n){if(!this.shader.hasUniform(o))continue;var h=[];for(var p=0;p<a.length;p++){var l=a[p];e.activeTexture(e.TEXTURE0+r),l.isRenderable()?l.bind(e):l.unbind(e),h.push(r++)}this.shader.setUniform(e,"1iv",o,h)}else this.shader.setUniform(e,u.type,o,a)}else this.shader.setUniform(e,u.type,o,a)}},setUniform:function(e,t){var n=this.uniforms[e];n&&(n.value=t)},setUniforms:function(e){for(var t in e){var n=e[t];this.setUniform(t,n)}},enableUniform:function(e){this.uniforms[e]&&!this.isUniformEnabled(e)&&this._enabledUniforms.push(e)},disableUniform:function(e){var t=this._enabledUniforms.indexOf(e);t>=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;s<i.length;s++)i[s]instanceof n&&i[s].dispose(e)}var o=this.shader;o&&(this.detachShader(),o.isAttachedToAny()||o.dispose(e))}});return r}),r("qtek/math/Vector2",["require","../dep/glmatrix"],function(e){var t=e("../dep/glmatrix"),n=t.vec2,r="_array",i="_dirty",s=function(e,t){e=e||0,t=t||0,this[r]=n.fromValues(e,t),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){return this[r][0]=e,this[r][1]=t,this[i]=!0,this},setArray:function(e){return this[r][0]=e[0],this[r][1]=e[1],this[i]=!0,this},clone:function(){return new s(this.x,this.y)},copy:function(e){return n.copy(this[r],e[r]),this[i]=!0,this},cross:function(e,t){return n.cross(e[r],this[r],t[r]),e[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},transformMat2:function(e){return n.transformMat2(this[r],this[r],e[r]),this[i]=!0,this},transformMat2d:function(e){return n.transformMat2d(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},toString:function(){return"["+Array.prototype.join.call(this[r],",")+"]"}};if(Object.defineProperty){var o=s.prototype;Object.defineProperty(o,"x",{get:function(){return this[r][0]},set:function(e){this[r][0]=e,this[i]=!0}}),Object.defineProperty(o,"y",{get:function(){return this[r][1]},set:function(e){this[r][1]=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){return n.set(e[r],t,s),e[i]=!0,e},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.transformMat2=function(e,t,s){return n.transformMat2(e[r],t[r],s[r]),e[i]=!0,e},s.transformMat2d=function(e,t,s){return n.transformMat2d(e[r],t[r],s[r]),e[i]=!0,e},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}),r("qtek/Renderer",["require","./core/Base","./Texture","./core/glinfo","./core/glenum","./math/BoundingBox","./math/Matrix4","./shader/library","./Material","./math/Vector2","./dep/glmatrix"],function(e){var t=e("./core/Base"),n=e("./Texture"),r=e("./core/glinfo"),i=e("./core/glenum"),s=e("./math/BoundingBox"),o=e("./math/Matrix4"),u=e("./shader/library"),a=e("./Material"),f=e("./math/Vector2"),l=e("./dep/glmatrix"),c=l.mat4,h=l.vec3,p=c.create,d=0,v={},m=t.derive(function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:window.devicePixelRatio||1,color:[0,0,0,0],clear:17664,alhpa:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},_viewportSettings:[],_clearSettings:[],_sceneRendering:null}},function(){this.canvas||(this.canvas=document.createElement("canvas"));var e=this.canvas;try{var t={alhpa:this.alhpa,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t);if(!this.gl)throw new Error;this.gl.__GLID__==null&&(this.gl.__GLID__=d++,r.initialize(this.gl)),this.resize()}catch(n){throw"Error creating WebGL Context "+n}},{resize:function(e,t){var n=this.canvas,r=this.devicePixelRatio;typeof e!="undefined"?(n.style.width=e+"px",n.style.height=t+"px",n.width=e*r,n.height=t*r,this._width=e,this._height=t):(this._width=n.width/r,this._height=n.height/r),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getExtension:function(e){return r.getExtension(this.gl,e)},setViewport:function(e,t,n,r,i){if(typeof e=="object"){var s=e;e=s.x,t=s.y,n=s.width,r=s.height}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,n*i,r*i),this.viewport={x:e,y:t,width:n,height:r}},saveViewport:function(){this._viewportSettings.push(this.viewport)},restoreViewport:function(){this._viewportSettings.length>0&&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;d<u.length;d++){var v=u[d];c.multiply(f,t.viewMatrix._array,v.worldTransform._array),h.transformMat4(l,v.position._array,f),v.__depth=l[2]}}o.sort(m.opaqueSortFunc),u.sort(m.transparentSortFunc),e.trigger("beforerender:opaque",this,o),t.sceneBoundingBoxLastFrame.min.set(Infinity,Infinity,Infinity),t.sceneBoundingBoxLastFrame.max.set(-Infinity,-Infinity,-Infinity),i.disable(i.BLEND),i.enable(i.DEPTH_TEST);var g=this.renderQueue(o,t,a,r);e.trigger("afterrender:opaque",this,o,g),e.trigger("beforerender:transparent",this,u),i.enable(i.BLEND);var y=this.renderQueue(u,t,a);e.trigger("afterrender:transparent",this,u,y);var b={};for(var w in g)b[w]=g[w]+y[w];return e.trigger("afterrender",this,e,t,b),this._sceneRendering=null,b},renderQueue:function(e,t,n,r){var i={faceNumber:0,vertexNumber:0,drawCallNumber:0,meshNumber:e.length,renderedMeshNumber:0};c.copy(g.VIEW,t.viewMatrix._array),c.copy(g.PROJECTION,t.projectionMatrix._array),c.multiply(g.VIEWPROJECTION,t.projectionMatrix._array,g.VIEW),c.copy(g.VIEWINVERSE,t.worldTransform._array),c.invert(g.PROJECTIONINVERSE,g.PROJECTION),c.invert(g.VIEWPROJECTIONINVERSE,g.VIEWPROJECTION);var s=this.gl,o=this._sceneRendering,f,l,h,p,d,m,y,b;if(r){var w=new a({shader:u.get("buildin.prez")}),E=w.shader;b=[],E.bind(s),s.colorMask(!1,!1,!1,!1),s.depthMask(!0),s.enable(s.DEPTH_TEST);for(var S=0;S<e.length;S++){var x=e[S],T=x.worldTransform._array,N=x.geometry;c.multiply(g.WORLDVIEW,g.VIEW,T),c.multiply(g.WORLDVIEWPROJECTION,g.VIEWPROJECTION,T);if(N.boundingBox&&this.isFrustumCulled(x,t,g.WORLDVIEW,g.PROJECTION))continue;if(x.skeleton)continue;x.cullFace!==m&&(m=x.cullFace,s.cullFace(m)),x.frontFace!==y&&(y=x.frontFace,s.frontFace(y)),x.culling!==d&&(d=x.culling,d?s.enable(s.CULL_FACE):s.disable(s.CULL_FACE));var C=E.matrixSemantics.WORLDVIEWPROJECTION;E.setUniform(s,C.type,C.symbol,g.WORLDVIEWPROJECTION),x.render(s,w),b.push(x)}s.depthFunc(s.LEQUAL),s.colorMask(!0,!0,!0,!0),s.depthMask(!1)}else b=e;d=null,m=null,y=null;for(var S=0;S<b.length;S++){var x=b[S],k=n||x.material,L=k.shader,N=x.geometry,T=x.worldTransform._array;c.copy(g.WORLD,T),c.multiply(g.WORLDVIEW,g.VIEW,T),c.multiply(g.WORLDVIEWPROJECTION,g.VIEWPROJECTION,T),(L.matrixSemantics.WORLDINVERSE||L.matrixSemantics.WORLDINVERSETRANSPOSE)&&c.invert(g.WORLDINVERSE,T),(L.matrixSemantics.WORLDVIEWINVERSE||L.matrixSemantics.WORLDVIEWINVERSETRANSPOSE)&&c.invert(g.WORLDVIEWINVERSE,g.WORLDVIEW),(L.matrixSemantics.WORLDVIEWPROJECTIONINVERSE||L.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE)&&c.invert(g.WORLDVIEWPROJECTIONINVERSE,g.WORLDVIEWPROJECTION);if(N.boundingBox&&!r&&this.isFrustumCulled(x,t,g.WORLDVIEW,g.PROJECTION))continue;if(l!==L){o&&o.isShaderLightNumberChanged(L)&&o.setShaderLightNumber(L);var A=L.bind(s);if(A){if(v[L.__GUID__])continue;v[L.__GUID__]=!0;if(this.throwError)throw new Error(A);this.trigger("error",A)}o&&o.setLightUniforms(L,s),l=L}f!==k&&(r||(k.depthTest!==h&&(k.depthTest?s.enable(s.DEPTH_TEST):s.disable(s.DEPTH_TEST),h=k.depthTest),k.depthMask!==p&&(s.depthMask(k.depthMask),p=k.depthMask)),k.bind(s,f),f=k,k.transparent&&(k.blend?k.blend(s):(s.blendEquationSeparate(s.FUNC_ADD,s.FUNC_ADD),s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA))));var O=L.matrixSemanticKeys;for(var M=0;M<O.length;M++){var _=O[M],C=L.matrixSemantics[_],D=g[_];if(C.isTranspose){var P=g[C.semanticNoTranspose];c.transpose(D,P)}L.setUniform(s,C.type,C.symbol,D)}x.cullFace!==m&&(m=x.cullFace,s.cullFace(m)),x.frontFace!==y&&(y=x.frontFace,s.frontFace(y)),x.culling!==d&&(d=x.culling,d?s.enable(s.CULL_FACE):s.disable(s.CULL_FACE));var H=x.render(s,n);H&&(i.faceNumber+=H.faceNumber,i.vertexNumber+=H.vertexNumber,i.drawCallNumber+=H.drawCallNumber,i.renderedMeshNumber++)}return r&&s.depthFunc(s.LESS),i},isFrustumCulled:function(){var e=new s,t=new o;return function(n,r,i,s){var o=n.boundingBox||n.geometry.boundingBox;t._array=i,e.copy(o),e.applyTransform(t),n.isRenderable()&&n.castShadow&&r.sceneBoundingBoxLastFrame.union(e);if(n.frustumCulling){if(!e.intersectBoundingBox(r.frustum.boundingBox))return!0;t._array=s,e.max._array[2]>0&&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&&e<this._length){var t=this._start+this._step*e;return this._hasMap?this._mapValue(t):t}},length:function(){return this._length},toArray:function(){var e=[];for(var t=this._start;t<=this._end;t+=this._step)e.push(this._hasMap?this._mapValue(t):t);return e},map:function(t){var n=new e(this._start,this._end,this._step);return n._mapFuncs=this._mapFuncs.concat([t]),n._hasMap=!0,n},_mapValue:function(e){var t=this._mapFuncs;for(var n=0;n<t.length;n++)e=t[n](e)}},e}),r("grapher/core/number",["require","../generator/Sequence"],function(e){var t={},n=e("../generator/Sequence");return t.rangeOfData=function(e){var t=Infinity,r=-Infinity,i=e instanceof n,s=i?e.length():e.length;for(var o=0;o<s;o++){var u=i?e.at(o):e[o];t=Math.min(u,t),r=Math.max(u,r)}return[t,r]},t.getDimensions=function(e){var t=[],n=e;while(n instanceof Array)t.push(n.length),n=n[0];return t},t.sameDimensions=function(e){var n=t.getDimensions(e);for(var r=1;r<arguments.length;r++){var i=t.getDimensions(arguments[r]);if(!t.arrayEqual(n,i))return!1}return!0},t.arrayEqual=function(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0},t}),r("qtek/Light",["require","./Node"],function(e){var t=e("./Node"),n=t.derive(function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512}},{type:"",clone:function(){var e=t.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}});return n}),r("qtek/Scene",["require","./Node","./Light"],function(e){function i(e,t){if(t.castShadow&&!e.castShadow)return!0}var t=e("./Node"),n=e("./Light"),r=t.derive(function(){return{material:null,autoUpdate:!0,opaqueQueue:[],transparentQueue:[],lights:[],_lightUniforms:{},_lightNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0,AMBIENT_LIGHT:0},_opaqueObjectCount:0,_transparentObjectCount:0,_nodeRepository:{}}},function(){this._scene=this},{addToScene:function(e){e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){e.name&&delete this._nodeRepository[e.name]},getNode:function(e){return this._nodeRepository[e]},cloneNode:function(e){var t=e.clone(),n={},r=function(i,s){i.skeleton&&(s.skeleton=i.skeleton.clone(e,t),s.joints=i.joints.slice()),i.material&&(n[i.material.__GUID__]={oldMat:i.material});for(var o=0;o<i._children.length;o++)r(i._children[o],s._children[o])};r(e,t);for(var i in n)n[i].newMat=n[i].oldMat.clone();return t.traverse(function(e){e.material&&(e.material=n[e.material.__GUID__].newMat)}),t},update:function(e,n){if(!this.autoUpdate&&!e)return;t.prototype.update.call(this,e);var r=this.lights,i=this.material&&this.material.transparent;this._opaqueObjectCount=0,this._transparentObjectCount=0,r.length=0,this._updateRenderQueue(this,i),this.opaqueQueue.length=this._opaqueObjectCount,this.transparentQueue.length=this._transparentObjectCount;if(!n){for(var s in this._lightNumber)this._lightNumber[s]=0;for(var o=0;o<r.length;o++){var u=r[o];this._lightNumber[u.type]++}this._updateLightUniforms()}},_updateRenderQueue:function(e,t){if(!e.visible)return;for(var r=0;r<e._children.length;r++){var i=e._children[r];i instanceof n&&this.lights.push(i),i.isRenderable()&&(i.material.transparent||t?this.transparentQueue[this._transparentObjectCount++]=i:this.opaqueQueue[this._opaqueObjectCount++]=i),i._children.length>0&&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;r<e.length;r++){var s=e[r];for(n in s.uniformTemplates){var o=s.uniformTemplates[n];t[n]||(t[n]={type:"",value:[]});var u=o.value(s),a=t[n];a.type=o.type+"v";switch(o.type){case"1i":case"1f":a.value.push(u);break;case"2f":case"3f":case"4f":for(var f=0;f<u.length;f++)a.value.push(u[f]);break;default:console.error("Unkown light uniform type "+o.type)}}}},isShaderLightNumberChanged:function(e){return e.lightNumber.POINT_LIGHT!==this._lightNumber.POINT_LIGHT||e.lightNumber.DIRECTIONAL_LIGHT!==this._lightNumber.DIRECTIONAL_LIGHT||e.lightNumber.SPOT_LIGHT!==this._lightNumber.SPOT_LIGHT||e.lightNumber.AMBIENT_LIGHT!==this._lightNumber.AMBIENT_LIGHT},setShaderLightNumber:function(e){for(var t in this._lightNumber)e.lightNumber[t]=this._lightNumber[t];e.dirty()},setLightUniforms:function(e,t){for(var n in this._lightUniforms){var r=this._lightUniforms[n];e.setUniform(t,r.type,n,r.value)}},dispose:function(){this.material=null,this.opaqueQueue=[],this.transparentQueue=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}});return r}),r("qtek/math/Plane",["require","./Vector3","../dep/glmatrix"],function(e){var t=e("./Vector3"),n=e("../dep/glmatrix"),r=n.vec3,i=n.mat4,s=n.vec4,o=function(e,n){this.normal=e||new t(0,1,0),this.distance=n||0};return o.prototype={constructor:o,distanceToPoint:function(e){return r.dot(e._array,this.normal._array)-this.distance},projectPoint:function(e,n){n||(n=new t);var i=this.distanceToPoint(e);return r.scaleAndAdd(n._array,e._array,this.normal._array,-i),n._dirty=!0,n},normalize:function(){var e=1/r.len(this.normal._array);r.scale(this.normal._array,e),this.distance*=e},intersectFrustum:function(e){var t=e.vertices,n=this.normal._array,i=r.dot(t[0]._array,n)>this.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<h||h!==h)h=d;l>=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<h||h!==h)h=m;if(h<0)return null;var g=c>=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&&v<i)return null;r.sub(s,d,u);var m=r.dot(o,s)/v;if(m<0||m>1)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<l;v++){var g=p.at(v);for(var y=0;y<c;y++){var b=d.at(y),w=t(g,b),E=n(g,b),S=i(g,b);f.push({x:w,y:E,z:S})}}}else{r.sameDimensions(t,n,i)||console.warn("x, y, z don't have same dimensions");var x=r.getDimensions(t);c=x[0],l=x[1];for(var v=0;v<c;v++)for(var y=0;y<l;y++){var w=t(g,b),E=n(g,b),S=i(g,b);f.push({x:w,y:E,z:S})}}else{t=t||new m(0,100,5),n=n||new m(0,100,5);var T=t instanceof m,N=n instanceof m;l=T?t.length():t.length,c=N?n.length():n.length;for(var v=0;v<c;v++){var E=N?n.at(v):n[v];for(var y=0;y<l;y++){var w=T?t.at(y):t[y],S;u?S=i(w,E):S=i[v][y],f.push({x:w,y:E,z:S})}}}return{uLen:l,vLen:c,data:f}},_constructSurface:function(e,t){var n=new o,r=t.showWireframe&&new o,s=n.attributes,u=s.position,a=s.color,f=this._cartesian,l=e.uLen,h=e.vLen,p=e.data,v=g(p.map(function(e){return e.x})),m=g(p.map(function(e){return e.y})),b=g(p.map(function(e){return e.z})),w=t.color,E=w instanceof Array,S=typeof w=="function",x;E&&(x=w.map(function(e){return i.parse(e)||y}));for(var T=0;T<p.length;T++){var N=p[T],C=f.valueToCoord(N),k=C.z;u.set(T,[C.x,C.y,C.z]);var L;if(E){var A=(N.z-b[0])/(b[1]-b[0]),O=x.length;if(A===1)L=x[O-1].slice();else{var M=(O-1)*A,_=Math.floor(M);L=d.lerp([],x[_],x[_+1],M-_)}}else{var D=(N.x-v[0])/(v[1]-v[0]),P=(N.y-m[0])/(m[1]-m[0]),A=(N.z-b[0])/(b[1]-b[0]);L=i.parse(w(D,P,A,N.x,N.y,N.z))||y}a.set(T,L)}var H=n.faces=[],_=0,B=u.value,j=r&&r.attributes.position;for(var T=0;T<l;T++)for(var F=0;F<h;F++){var I=T*h+F,q=T*h+F+1,R=(T+1)*h+F+1,U=(T+1)*h+F;if(T<l-1&&F<h-1)H.push([q,I,R],[I,U,R]),r&&(j.set(_++,B[q]),j.set(_++,B[I]),j.set(_++,B[I]),j.set(_++,B[U]));else{if(T===l-1&&F===h-1)continue;T===l-1?r&&(j.set(_++,B[q]),j.set(_++,B[I])):r&&(j.set(_++,B[I]),j.set(_++,B[U]))}}var z=this._app3d,W=this._root,X=new c({geometry:n,material:z.createColorMaterial([1,1,1],1,!0),culling:!1});W.add(X);if(r){var V=z.createColorMaterial(i.parse(t.wireframeLineColor)||y,1),$=t.wireframeLineWidth,J=c.LINES,K=new c({geometry:r,material:V,culling:!1,lineWidth:$,mode:J}),Q=new c({geometry:r,material:V,culling:!1,lineWidth:$,mode:J});W.add(K),W.add(Q),K.scale.set(1.002,1.002,1.002),Q.scale.set(.999,.999,.999)}}},E.DEFAULTS=b,E}),r("grapher/grapher",["require","./graph/Surface","./generator/Sequence"],function(e){var t={version:"0.1"};return t.Surface=e("./graph/Surface"),t.generator={Sequence:e("./generator/Sequence")},t}),r("grapher",["grapher/grapher"],function(e){return e});var i=n("grapher");for(var s in i)e[s]=i[s]});