| 1 | !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("echarts")):"function"==typeof define&&define.amd?define(["echarts"],e):"object"==typeof exports?exports["echarts-gl"]=e(require("echarts")):t["echarts-gl"]=e(t.echarts)}(window,function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(e,r){e.exports=t},function(t,e,r){"use strict";(function(t){var i,n=r(4),a={supportWebGL:function(){if(null==i)try{var t=document.createElement("canvas");if(!(t.getContext("webgl")||t.getContext("experimental-webgl")))throw new Error}catch(t){i=!1}return i}};a.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,a.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,a.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,a.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,a.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,a.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,a.Float64Array="undefined"==typeof Float64Array?Array:Float64Array;var o={};"undefined"!=typeof window?o=window:void 0!==t&&(o=t),a.requestAnimationFrame=o.requestAnimationFrame||o.msRequestAnimationFrame||o.mozRequestAnimationFrame||o.webkitRequestAnimationFrame||function(t){setTimeout(t,16)},a.createCanvas=function(){return document.createElement("canvas")},a.createImage=function(){return new o.Image},a.request={get:n.a.get},a.addEventListener=function(t,e,r,i){t.addEventListener(e,r,i)},a.removeEventListener=function(t,e,r){t.removeEventListener(e,r)},e.a=a}).call(this,r(3))},function(t,e,r){"use strict";r.r(e);var i=r(0);function n(t,e,r){"object"==typeof e&&(r=e,e=null);var i,n=this;if(!(t instanceof Function))for(var o in i=[],t)t.hasOwnProperty(o)&&i.push(o);var s=function(e){if(n.apply(this,arguments),t instanceof Function?a(this,t.call(this,e)):function(t,e,r){for(var i=0;i<r.length;i++){var n=r[i];t[n]=e[n]}}(this,t,i),this.constructor===s)for(var r=s.__initializers__,o=0;o<r.length;o++)r[o].apply(this,arguments)};s.__super__=n,n.__initializers__?s.__initializers__=n.__initializers__.slice():s.__initializers__=[],e&&s.__initializers__.push(e);var l=function(){};return l.prototype=n.prototype,s.prototype=new l,s.prototype.constructor=s,a(s.prototype,r),s.extend=n.extend,s.derive=n.extend,s}function a(t,e){if(e)for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])}var o={extend:n,derive:n};var s={trigger:function(t){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(t)){var e=this.__handlers__[t],r=e.length,i=-1,n=arguments;switch(n.length){case 1:for(;++i<r;)e[i].action.call(e[i].context);return;case 2:for(;++i<r;)e[i].action.call(e[i].context,n[1]);return;case 3:for(;++i<r;)e[i].action.call(e[i].context,n[1],n[2]);return;case 4:for(;++i<r;)e[i].action.call(e[i].context,n[1],n[2],n[3]);return;case 5:for(;++i<r;)e[i].action.call(e[i].context,n[1],n[2],n[3],n[4]);return;default:for(;++i<r;)e[i].action.apply(e[i].context,Array.prototype.slice.call(n,1));return}}},on:function(t,e,r){if(t&&e){var i=this.__handlers__||(this.__handlers__={});if(i[t]){if(this.has(t,e))return}else i[t]=[];var n=new function(t,e){this.action=t,this.context=e}(e,r||this);return i[t].push(n),this}},once:function(t,e,r){if(t&&e){var i=this;return this.on(t,function r(){i.off(t,r),e.apply(this,arguments)},r)}},before:function(t,e,r){if(t&&e)return t="before"+t,this.on(t,e,r)},after:function(t,e,r){if(t&&e)return t="after"+t,this.on(t,e,r)},success:function(t,e){return this.once("success",t,e)},error:function(t,e){return this.once("error",t,e)},off:function(t,e){var r=this.__handlers__||(this.__handlers__={});if(e){if(r[t]){for(var i=r[t],n=[],a=0;a<i.length;a++)e&&i[a].action!==e&&n.push(i[a]);r[t]=n}return this}r[t]=[]},has:function(t,e){var r=this.__handlers__;if(!r||!r[t])return!1;for(var i=r[t],n=0;n<i.length;n++)if(i[n].action===e)return!0}},l=0,h=Array.prototype.forEach,u={genGUID:function(){return++l},relative2absolute:function(t,e){if(!e||t.match(/^\//))return t;for(var r=t.split("/"),i=e.split("/"),n=r[0];"."===n||".."===n;)".."===n&&i.pop(),r.shift(),n=r[0];return i.join("/")+"/"+r.join("/")},extend:function(t,e){if(e)for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t},defaults:function(t,e){if(e)for(var r in e)void 0===t[r]&&(t[r]=e[r]);return t},extendWithPropList:function(t,e,r){if(e)for(var i=0;i<r.length;i++){var n=r[i];t[n]=e[n]}return t},defaultsWithPropList:function(t,e,r){if(e)for(var i=0;i<r.length;i++){var n=r[i];null==t[n]&&(t[n]=e[n])}return t},each:function(t,e,r){if(t&&e)if(t.forEach&&t.forEach===h)t.forEach(e,r);else if(t.length===+t.length)for(var i=0,n=t.length;i<n;i++)e.call(r,t[i],i,t);else for(var a in t)t.hasOwnProperty(a)&&e.call(r,t[a],a,t)},isObject:function(t){return t===Object(t)},isArray:function(t){return Array.isArray(t)},isArrayLike:function(t){return!!t&&t.length===+t.length},clone:function(t){if(u.isObject(t)){if(u.isArray(t))return t.slice();if(u.isArrayLike(t)){for(var e=new t.constructor(t.length),r=0;r<t.length;r++)e[r]=t[r];return e}return u.extend({},t)}return t}},c=u,d=function(){this.__uid__=c.genGUID()};d.__initializers__=[function(t){c.extend(this,t)}],c.extend(d,o),c.extend(d.prototype,s);var f=d,p=["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","EXT_frag_depth","EXT_sRGB","ANGLE_instanced_arrays"],m=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"];var g=function(t){for(var e={},r={},i=0;i<p.length;i++)a(p[i]);for(i=0;i<m.length;i++){var n=m[i];r[n]=t.getParameter(t[n])}function a(r){if(t.getExtension){var i=t.getExtension(r);i||(i=t.getExtension("MOZ_"+r)),i||(i=t.getExtension("WEBKIT_"+r)),e[r]=i}}this.getExtension=function(t){return t in e||a(t),e[t]},this.getParameter=function(t){return r[t]}},_={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},v=r(1),y=function(){this.head=null,this.tail=null,this._length=0};y.prototype.insert=function(t){var e=new y.Entry(t);return this.insertEntry(e),e},y.prototype.insertAt=function(t,e){if(!(t<0)){for(var r=this.head,i=0;r&&i!=t;)r=r.next,i++;if(r){var n=new y.Entry(e),a=r.prev;a?(a.next=n,n.prev=a):this.head=n,n.next=r,r.prev=n}else this.insert(e)}},y.prototype.insertBeforeEntry=function(t,e){var r=new y.Entry(t),i=e.prev;i?(i.next=r,r.prev=i):this.head=r,r.next=e,e.prev=r,this._length++},y.prototype.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,this.tail=t):this.head=this.tail=t,this._length++},y.prototype.remove=function(t){var e=t.prev,r=t.next;e?e.next=r:this.head=r,r?r.prev=e:this.tail=e,t.next=t.prev=null,this._length--},y.prototype.removeAt=function(t){if(!(t<0)){for(var e=this.head,r=0;e&&r!=t;)e=e.next,r++;return e?(this.remove(e),e.value):void 0}},y.prototype.getHead=function(){if(this.head)return this.head.value},y.prototype.getTail=function(){if(this.tail)return this.tail.value},y.prototype.getAt=function(t){if(!(t<0)){for(var e=this.head,r=0;e&&r!=t;)e=e.next,r++;return e.value}},y.prototype.indexOf=function(t){for(var e=this.head,r=0;e;){if(e.value===t)return r;e=e.next,r++}},y.prototype.length=function(){return this._length},y.prototype.isEmpty=function(){return 0===this._length},y.prototype.forEach=function(t,e){for(var r=this.head,i=0,n=void 0!==e;r;)n?t.call(e,r.value,i):t(r.value,i),r=r.next,i++},y.prototype.clear=function(){this.tail=this.head=null,this._length=0},y.Entry=function(t){this.value=t,this.next=null,this.prev=null};var x=y,T=function(t){this._list=new x,this._map={},this._maxSize=t||10};T.prototype.setMaxSize=function(t){this._maxSize=t},T.prototype.put=function(t,e){if(!this._map.hasOwnProperty(t)){var r=this._list.length();if(r>=this._maxSize&&r>0){var i=this._list.head;this._list.remove(i),delete this._map[i.key]}var n=this._list.insert(e);n.key=t,this._map[t]=n}},T.prototype.get=function(t){var e=this._map[t];if(this._map.hasOwnProperty(t))return e!==this._list.tail&&(this._list.remove(e),this._list.insertEntry(e)),e.value},T.prototype.remove=function(t){var e=this._map[t];void 0!==e&&(delete this._map[t],this._list.remove(e))},T.prototype.clear=function(){this._list.clear(),this._map={}};var b=T,w={},S={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]};function E(t){return(t=Math.round(t))<0?0:t>255?255:t}function A(t){return t<0?0:t>1?1:t}function M(t){return t.length&&"%"===t.charAt(t.length-1)?E(parseFloat(t)/100*255):E(parseInt(t,10))}function C(t){return t.length&&"%"===t.charAt(t.length-1)?A(parseFloat(t)/100):A(parseFloat(t))}function D(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}function L(t,e,r){return t+(e-t)*r}function P(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t}function N(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}var R=new b(20),I=null;function O(t,e){I&&N(I,e),I=R.put(t,I||e.slice())}function B(t,e){var r=(parseFloat(t[0])%360+360)%360/360,i=C(t[1]),n=C(t[2]),a=n<=.5?n*(i+1):n+i-n*i,o=2*n-a;return P(e=e||[],E(255*D(o,a,r+1/3)),E(255*D(o,a,r)),E(255*D(o,a,r-1/3)),1),4===t.length&&(e[3]=t[3]),e}w.parse=function(t,e){if(t){e=e||[];var r=R.get(t);if(r)return N(e,r);var i,n=(t+="").replace(/ /g,"").toLowerCase();if(n in S)return N(e,S[n]),O(t,e),e;if("#"===n.charAt(0))return 4===n.length?(i=parseInt(n.substr(1),16))>=0&&i<=4095?(P(e,(3840&i)>>4|(3840&i)>>8,240&i|(240&i)>>4,15&i|(15&i)<<4,1),O(t,e),e):void P(e,0,0,0,1):7===n.length?(i=parseInt(n.substr(1),16))>=0&&i<=16777215?(P(e,(16711680&i)>>16,(65280&i)>>8,255&i,1),O(t,e),e):void P(e,0,0,0,1):void 0;var a=n.indexOf("("),o=n.indexOf(")");if(-1!==a&&o+1===n.length){var s=n.substr(0,a),l=n.substr(a+1,o-(a+1)).split(","),h=1;switch(s){case"rgba":if(4!==l.length)return void P(e,0,0,0,1);h=C(l.pop());case"rgb":return 3!==l.length?void P(e,0,0,0,1):(P(e,M(l[0]),M(l[1]),M(l[2]),h),O(t,e),e);case"hsla":return 4!==l.length?void P(e,0,0,0,1):(l[3]=C(l[3]),B(l,e),O(t,e),e);case"hsl":return 3!==l.length?void P(e,0,0,0,1):(B(l,e),O(t,e),e);default:return}}P(e,0,0,0,1)}},w.parseToFloat=function(t,e){if(e=w.parse(t,e))return e[0]/=255,e[1]/=255,e[2]/=255,e},w.lift=function(t,e){var r=w.parse(t);if(r){for(var i=0;i<3;i++)r[i]=e<0?r[i]*(1-e)|0:(255-r[i])*e+r[i]|0;return w.stringify(r,4===r.length?"rgba":"rgb")}},w.toHex=function(t){var e=w.parse(t);if(e)return((1<<24)+(e[0]<<16)+(e[1]<<8)+ +e[2]).toString(16).slice(1)},w.fastLerp=function(t,e,r){if(e&&e.length&&t>=0&&t<=1){r=r||[];var i=t*(e.length-1),n=Math.floor(i),a=Math.ceil(i),o=e[n],s=e[a],l=i-n;return r[0]=E(L(o[0],s[0],l)),r[1]=E(L(o[1],s[1],l)),r[2]=E(L(o[2],s[2],l)),r[3]=A(L(o[3],s[3],l)),r}},w.fastMapToColor=w.fastLerp,w.lerp=function(t,e,r){if(e&&e.length&&t>=0&&t<=1){var i=t*(e.length-1),n=Math.floor(i),a=Math.ceil(i),o=w.parse(e[n]),s=w.parse(e[a]),l=i-n,h=w.stringify([E(L(o[0],s[0],l)),E(L(o[1],s[1],l)),E(L(o[2],s[2],l)),A(L(o[3],s[3],l))],"rgba");return r?{color:h,leftIndex:n,rightIndex:a,value:i}:h}},w.mapToColor=w.lerp,w.modifyHSL=function(t,e,r,i){if(t=w.parse(t))return t=function(t){if(t){var e,r,i=t[0]/255,n=t[1]/255,a=t[2]/255,o=Math.min(i,n,a),s=Math.max(i,n,a),l=s-o,h=(s+o)/2;if(0===l)e=0,r=0;else{r=h<.5?l/(s+o):l/(2-s-o);var u=((s-i)/6+l/2)/l,c=((s-n)/6+l/2)/l,d=((s-a)/6+l/2)/l;i===s?e=d-c:n===s?e=1/3+u-d:a===s&&(e=2/3+c-u),e<0&&(e+=1),e>1&&(e-=1)}var f=[360*e,r,h];return null!=t[3]&&f.push(t[3]),f}}(t),null!=e&&(t[0]=(n=e,(n=Math.round(n))<0?0:n>360?360:n)),null!=r&&(t[1]=C(r)),null!=i&&(t[2]=C(i)),w.stringify(B(t),"rgba");var n},w.modifyAlpha=function(t,e){if((t=w.parse(t))&&null!=e)return t[3]=A(e),w.stringify(t,"rgba")},w.stringify=function(t,e){if(t&&t.length){var r=t[0]+","+t[1]+","+t[2];return"rgba"!==e&&"hsva"!==e&&"hsla"!==e||(r+=","+t[3]),e+"("+r+")"}};var F=w.parseToFloat,z={};function U(t){var e=Object.keys(t);e.sort();for(var r=[],i=0;i<e.length;i++){var n=e[i],a=t[n];null===a?r.push(n):r.push(n+" "+a.toString())}return r.join("\n")}var k,G=f.extend(function(){return{name:"",depthTest:!0,depthMask:!0,transparent:!1,blend:null,autoUpdateTextureStatus:!0,uniforms:{},vertexDefines:{},fragmentDefines:{},_textureStatus:{},_enabledUniforms:null}},function(){this.name||(this.name="MATERIAL_"+this.__uid__),this.shader&&this.attachShader(this.shader,!0)},{precision:"highp",setUniform:function(t,e){void 0===e&&console.warn('Uniform value "'+t+'" is undefined');var r=this.uniforms[t];r&&("string"==typeof e&&(e=F(e)||e),r.value=e,this.autoUpdateTextureStatus&&"t"===r.type&&(e?this.enableTexture(t):this.disableTexture(t)))},setUniforms:function(t){for(var e in t){var r=t[e];this.setUniform(e,r)}},isUniformEnabled:function(t){return this._enabledUniforms.indexOf(t)>=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(t,e){if("object"==typeof t)for(var r in t){var i=t[r];this.setUniform(r,i)}else this.setUniform(t,e)},get:function(t){var e=this.uniforms[t];if(e)return e.value},attachShader:function(t,e){var r=this.uniforms;this.uniforms=t.createUniforms(),this.shader=t;var i=this.uniforms;this._enabledUniforms=Object.keys(i),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter(function(t){var e=this.uniforms[t].type;return"t"===e||"tv"===e},this);var n=this.vertexDefines,a=this.fragmentDefines;if(this.vertexDefines=c.clone(t.vertexDefines),this.fragmentDefines=c.clone(t.fragmentDefines),e){for(var o in r)i[o]&&(i[o].value=r[o].value);c.defaults(this.vertexDefines,n),c.defaults(this.fragmentDefines,a)}var s={};for(var l in t.textures)s[l]={shaderType:t.textures[l].shaderType,type:t.textures[l].type,enabled:!(!e||!this._textureStatus[l])&&this._textureStatus[l].enabled};this._textureStatus=s,this._programKey=""},clone:function(){var t=new this.constructor({name:this.name,shader:this.shader});for(var e in this.uniforms)t.uniforms[e].value=this.uniforms[e].value;return t.depthTest=this.depthTest,t.depthMask=this.depthMask,t.transparent=this.transparent,t.blend=this.blend,t.vertexDefines=c.clone(this.vertexDefines),t.fragmentDefines=c.clone(this.fragmentDefines),t.enableTexture(this.getEnabledTextures()),t.precision=this.precision,t},define:function(t,e,r){var i=this.vertexDefines,n=this.fragmentDefines;"vertex"!==t&&"fragment"!==t&&"both"!==t&&arguments.length<3&&(r=e,e=t,t="both"),r=null!=r?r:null,"vertex"!==t&&"both"!==t||i[e]!==r&&(i[e]=r,this._programKey=""),"fragment"!==t&&"both"!==t||n[e]!==r&&(n[e]=r,"both"!==t&&(this._programKey=""))},undefine:function(t,e){"vertex"!==t&&"fragment"!==t&&"both"!==t&&arguments.length<2&&(e=t,t="both"),"vertex"!==t&&"both"!==t||this.isDefined("vertex",e)&&(delete this.vertexDefines[e],this._programKey=""),"fragment"!==t&&"both"!==t||this.isDefined("fragment",e)&&(delete this.fragmentDefines[e],"both"!==t&&(this._programKey=""))},isDefined:function(t,e){switch(t){case"vertex":return void 0!==this.vertexDefines[e];case"fragment":return void 0!==this.fragmentDefines[e]}},getDefine:function(t,e){switch(t){case"vertex":return this.vertexDefines[e];case"fragment":return this.fragmentDefines[e]}},enableTexture:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this.enableTexture(t[e]);else{var r=this._textureStatus[t];if(r)r.enabled||(r.enabled=!0,this._programKey="")}},enableTexturesAll:function(){var t=this._textureStatus;for(var e in t)t[e].enabled=!0;this._programKey=""},disableTexture:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this.disableTexture(t[e]);else{var r=this._textureStatus[t];if(r)!r.enabled||(r.enabled=!1,this._programKey="")}},disableTexturesAll:function(){var t=this._textureStatus;for(var e in t)t[e].enabled=!1;this._programKey=""},isTextureEnabled:function(t){var e=this._textureStatus;return!!e[t]&&e[t].enabled},getEnabledTextures:function(){var t=[],e=this._textureStatus;for(var r in e)e[r].enabled&&t.push(r);return t},dirtyDefines:function(){this._programKey=""},getProgramKey:function(){return this._programKey||(this._programKey=function(t,e,r){r.sort();for(var i=[],n=0;n<r.length;n++){var a=r[n];i.push(a)}var o=U(t)+"\n"+U(e)+"\n"+i.join("\n");if(z[o])return z[o];var s=c.genGUID();return z[o]=s,s}(this.vertexDefines,this.fragmentDefines,this.getEnabledTextures())),this._programKey}}),H=Array,V=Math.random,W={};W.create=function(){var t=new H(2);return t[0]=0,t[1]=0,t},W.clone=function(t){var e=new H(2);return e[0]=t[0],e[1]=t[1],e},W.fromValues=function(t,e){var r=new H(2);return r[0]=t,r[1]=e,r},W.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},W.set=function(t,e,r){return t[0]=e,t[1]=r,t},W.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},W.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},W.sub=W.subtract,W.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t},W.mul=W.multiply,W.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t},W.div=W.divide,W.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},W.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},W.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},W.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t},W.distance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)},W.dist=W.distance,W.squaredDistance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i},W.sqrDist=W.squaredDistance,W.length=function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},W.len=W.length,W.squaredLength=function(t){var e=t[0],r=t[1];return e*e+r*r},W.sqrLen=W.squaredLength,W.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},W.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},W.normalize=function(t,e){var r=e[0],i=e[1],n=r*r+i*i;return n>0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n),t},W.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},W.cross=function(t,e,r){var i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t},W.lerp=function(t,e,r,i){var n=e[0],a=e[1];return t[0]=n+i*(r[0]-n),t[1]=a+i*(r[1]-a),t},W.random=function(t,e){e=e||1;var r=2*GLMAT_RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},W.transformMat2=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n,t[1]=r[1]*i+r[3]*n,t},W.transformMat2d=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n+r[4],t[1]=r[1]*i+r[3]*n+r[5],t},W.transformMat3=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[3]*n+r[6],t[1]=r[1]*i+r[4]*n+r[7],t},W.transformMat4=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[4]*n+r[12],t[1]=r[1]*i+r[5]*n+r[13],t},W.forEach=(k=W.create(),function(t,e,r,i,n,a){var o,s;for(e||(e=2),r||(r=0),s=i?Math.min(i*e+r,t.length):t.length,o=r;o<s;o+=e)k[0]=t[o],k[1]=t[o+1],n(k,k,a),t[o]=k[0],t[o+1]=k[1];return t});var X=W,j=function(t,e){t=t||0,e=e||0,this.array=X.fromValues(t,e),this._dirty=!0};if(j.prototype={constructor:j,add:function(t){return X.add(this.array,this.array,t.array),this._dirty=!0,this},set:function(t,e){return this.array[0]=t,this.array[1]=e,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this._dirty=!0,this},clone:function(){return new j(this.x,this.y)},copy:function(t){return X.copy(this.array,t.array),this._dirty=!0,this},cross:function(t,e){return X.cross(t.array,this.array,e.array),t._dirty=!0,this},dist:function(t){return X.dist(this.array,t.array)},distance:function(t){return X.distance(this.array,t.array)},div:function(t){return X.div(this.array,this.array,t.array),this._dirty=!0,this},divide:function(t){return X.divide(this.array,this.array,t.array),this._dirty=!0,this},dot:function(t){return X.dot(this.array,t.array)},len:function(){return X.len(this.array)},length:function(){return X.length(this.array)},lerp:function(t,e,r){return X.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},min:function(t){return X.min(this.array,this.array,t.array),this._dirty=!0,this},max:function(t){return X.max(this.array,this.array,t.array),this._dirty=!0,this},mul:function(t){return X.mul(this.array,this.array,t.array),this._dirty=!0,this},multiply:function(t){return X.multiply(this.array,this.array,t.array),this._dirty=!0,this},negate:function(){return X.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return X.normalize(this.array,this.array),this._dirty=!0,this},random:function(t){return X.random(this.array,t),this._dirty=!0,this},scale:function(t){return X.scale(this.array,this.array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return X.scaleAndAdd(this.array,this.array,t.array,e),this._dirty=!0,this},sqrDist:function(t){return X.sqrDist(this.array,t.array)},squaredDistance:function(t){return X.squaredDistance(this.array,t.array)},sqrLen:function(){return X.sqrLen(this.array)},squaredLength:function(){return X.squaredLength(this.array)},sub:function(t){return X.sub(this.array,this.array,t.array),this._dirty=!0,this},subtract:function(t){return X.subtract(this.array,this.array,t.array),this._dirty=!0,this},transformMat2:function(t){return X.transformMat2(this.array,this.array,t.array),this._dirty=!0,this},transformMat2d:function(t){return X.transformMat2d(this.array,this.array,t.array),this._dirty=!0,this},transformMat3:function(t){return X.transformMat3(this.array,this.array,t.array),this._dirty=!0,this},transformMat4:function(t){return X.transformMat4(this.array,this.array,t.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Object.defineProperty){var q=j.prototype;Object.defineProperty(q,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),Object.defineProperty(q,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}})}j.add=function(t,e,r){return X.add(t.array,e.array,r.array),t._dirty=!0,t},j.set=function(t,e,r){return X.set(t.array,e,r),t._dirty=!0,t},j.copy=function(t,e){return X.copy(t.array,e.array),t._dirty=!0,t},j.cross=function(t,e,r){return X.cross(t.array,e.array,r.array),t._dirty=!0,t},j.distance=j.dist=function(t,e){return X.distance(t.array,e.array)},j.divide=j.div=function(t,e,r){return X.divide(t.array,e.array,r.array),t._dirty=!0,t},j.dot=function(t,e){return X.dot(t.array,e.array)},j.len=function(t){return X.length(t.array)},j.lerp=function(t,e,r,i){return X.lerp(t.array,e.array,r.array,i),t._dirty=!0,t},j.min=function(t,e,r){return X.min(t.array,e.array,r.array),t._dirty=!0,t},j.max=function(t,e,r){return X.max(t.array,e.array,r.array),t._dirty=!0,t},j.multiply=j.mul=function(t,e,r){return X.multiply(t.array,e.array,r.array),t._dirty=!0,t},j.negate=function(t,e){return X.negate(t.array,e.array),t._dirty=!0,t},j.normalize=function(t,e){return X.normalize(t.array,e.array),t._dirty=!0,t},j.random=function(t,e){return X.random(t.array,e),t._dirty=!0,t},j.scale=function(t,e,r){return X.scale(t.array,e.array,r),t._dirty=!0,t},j.scaleAndAdd=function(t,e,r,i){return X.scaleAndAdd(t.array,e.array,r.array,i),t._dirty=!0,t},j.squaredDistance=j.sqrDist=function(t,e){return X.sqrDist(t.array,e.array)},j.squaredLength=j.sqrLen=function(t){return X.sqrLen(t.array)},j.subtract=j.sub=function(t,e,r){return X.subtract(t.array,e.array,r.array),t._dirty=!0,t},j.transformMat2=function(t,e,r){return X.transformMat2(t.array,e.array,r.array),t._dirty=!0,t},j.transformMat2d=function(t,e,r){return X.transformMat2d(t.array,e.array,r.array),t._dirty=!0,t},j.transformMat3=function(t,e,r){return X.transformMat3(t.array,e.array,r.array),t._dirty=!0,t},j.transformMat4=function(t,e,r){return X.transformMat4(t.array,e.array,r.array),t._dirty=!0,t};var Z=j,Y={};function K(t,e,r){if(!t.getShaderParameter(e,t.COMPILE_STATUS))return[t.getShaderInfoLog(e),function(t){for(var e=t.split("\n"),r=0,i=e.length;r<i;r++)e[r]=r+1+": "+e[r];return e.join("\n")}(r)].join("\n")}var Q=new v.a.Float32Array(16),J=f.extend({uniformSemantics:{},attributes:{}},function(){this._locations={},this._textureSlot=0,this._program=null},{bind:function(t){this._textureSlot=0,t.gl.useProgram(this._program)},hasUniform:function(t){var e=this._locations[t];return null!==e&&void 0!==e},useTextureSlot:function(t,e,r){e&&(t.gl.activeTexture(t.gl.TEXTURE0+r),e.isRenderable()?e.bind(t):e.unbind(t))},currentTextureSlot:function(){return this._textureSlot},resetTextureSlot:function(t){this._textureSlot=t||0},takeCurrentTextureSlot:function(t,e){var r=this._textureSlot;return this.useTextureSlot(t,e,r),this._textureSlot++,r},setUniform:function(t,e,r,i){var n=this._locations[r];if(null===n||void 0===n)return!1;switch(e){case"m4":if(!(i instanceof Float32Array)){for(var a=0;a<i.length;a++)Q[a]=i[a];i=Q}t.uniformMatrix4fv(n,!1,i);break;case"2i":t.uniform2i(n,i[0],i[1]);break;case"2f":t.uniform2f(n,i[0],i[1]);break;case"3i":t.uniform3i(n,i[0],i[1],i[2]);break;case"3f":t.uniform3f(n,i[0],i[1],i[2]);break;case"4i":t.uniform4i(n,i[0],i[1],i[2],i[3]);break;case"4f":t.uniform4f(n,i[0],i[1],i[2],i[3]);break;case"1i":t.uniform1i(n,i);break;case"1f":t.uniform1f(n,i);break;case"1fv":t.uniform1fv(n,i);break;case"1iv":t.uniform1iv(n,i);break;case"2iv":t.uniform2iv(n,i);break;case"2fv":t.uniform2fv(n,i);break;case"3iv":t.uniform3iv(n,i);break;case"3fv":t.uniform3fv(n,i);break;case"4iv":t.uniform4iv(n,i);break;case"4fv":t.uniform4fv(n,i);break;case"m2":case"m2v":t.uniformMatrix2fv(n,!1,i);break;case"m3":case"m3v":t.uniformMatrix3fv(n,!1,i);break;case"m4v":if(Array.isArray(i)&&Array.isArray(i[0])){var o=new v.a.Float32Array(16*i.length),s=0;for(a=0;a<i.length;a++)for(var l=i[a],h=0;h<16;h++)o[s++]=l[h];t.uniformMatrix4fv(n,!1,o)}else t.uniformMatrix4fv(n,!1,i)}return!0},setUniformOfSemantic:function(t,e,r){var i=this.uniformSemantics[e];return!!i&&this.setUniform(t,i.type,i.symbol,r)},enableAttributes:function(t,e,r){var i,n=t.gl,a=this._program,o=this._locations;(i=r?r.__enabledAttributeList:Y[t.__uid__])||(i=r?r.__enabledAttributeList=[]:Y[t.__uid__]=[]);for(var s=[],l=0;l<e.length;l++){var h=e[l];if(this.attributes[h]){var u=o[h];if(null==u){if(-1===(u=n.getAttribLocation(a,h))){s[l]=-1;continue}o[h]=u}s[l]=u,i[u]?i[u]=2:i[u]=1}else s[l]=-1}for(l=0;l<i.length;l++)switch(i[l]){case 1:n.enableVertexAttribArray(l),i[l]=3;break;case 2:i[l]=3;break;case 3:n.disableVertexAttribArray(l),i[l]=0}return s},getAttribLocation:function(t,e){var r=this._locations,i=r[e];return null==i&&(i=t.getAttribLocation(this._program,e),r[e]=i),i},buildProgram:function(t,e,r,i){var n=t.createShader(t.VERTEX_SHADER),a=t.createProgram();t.shaderSource(n,r),t.compileShader(n);var o=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(o,i),t.compileShader(o);var s=K(t,n,r);if(s)return s;if(s=K(t,o,i))return s;if(t.attachShader(a,n),t.attachShader(a,o),e.attributeSemantics.POSITION)t.bindAttribLocation(a,0,e.attributeSemantics.POSITION.symbol);else{var l=Object.keys(this.attributes);t.bindAttribLocation(a,0,l[0])}if(t.linkProgram(a),t.deleteShader(n),t.deleteShader(o),this._program=a,this.vertexCode=r,this.fragmentCode=i,!t.getProgramParameter(a,t.LINK_STATUS))return"Could not link program\n"+t.getProgramInfoLog(a);for(var h=0;h<e.uniforms.length;h++){var u=e.uniforms[h];this._locations[u]=t.getUniformLocation(a,u)}}}),$=/for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;function tt(t,e,r){var i={};for(var n in r)i[n+"_COUNT"]=r[n];return t.replace($,function(t,r,n,a){var o="";isNaN(r)&&(r=r in e?e[r]:i[r]),isNaN(n)&&(n=n in e?e[n]:i[n]);for(var s=parseInt(r);s<parseInt(n);s++)o+="{"+a.replace(/float\s*\(\s*_idx_\s*\)/g,s.toFixed(1)).replace(/_idx_/g,s)+"}";return o})}function et(t,e,r){var i=[];if(e)for(var n in e){var a=e[n];a>0&&i.push("#define "+n.toUpperCase()+"_COUNT "+a)}if(r)for(var o=0;o<r.length;o++){var s=r[o];i.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in t){var l=t[s];null===l?i.push("#define "+s):i.push("#define "+s+" "+l.toString())}return i.join("\n")}function rt(t){this._renderer=t,this._cache={}}rt.prototype.getProgram=function(t,e,r){var i=this._cache,n=t.isSkinnedMesh&&t.isSkinnedMesh(),a=t.isInstancedMesh&&t.isInstancedMesh(),o="s"+e.shader.shaderID+"m"+e.getProgramKey();if(r&&(o+="se"+r.getProgramKey(t.lightGroup)),n&&(o+=",sk"+t.joints.length),a&&(o+=",is"),v=i[o])return v;var s=r?r.getLightsNumbers(t.lightGroup):{},l=this._renderer,h=l.gl,u=e.getEnabledTextures(),c="";if(n){var d={SKINNING:null,JOINT_COUNT:t.joints.length};t.joints.length>l.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),c+="\n"+et(d)+"\n"}a&&(c+="\n#define INSTANCING\n");var f=c+et(e.vertexDefines,s,u),p=c+et(e.fragmentDefines,s,u),m=f+"\n"+e.shader.vertex,g=["OES_standard_derivatives","EXT_shader_texture_lod"].filter(function(t){return null!=l.getGLExtension(t)});g.indexOf("EXT_shader_texture_lod")>=0&&(p+="\n#define SUPPORT_TEXTURE_LOD"),g.indexOf("OES_standard_derivatives")>=0&&(p+="\n#define SUPPORT_STANDARD_DERIVATIVES");var _,v,y=function(t){for(var e=[],r=0;r<t.length;r++)e.push("#extension GL_"+t[r]+" : enable");return e.join("\n")}(g)+"\n"+(["precision",_=e.precision,"float"].join(" ")+";\n"+["precision",_,"int"].join(" ")+";\n"+["precision",_,"sampler2D"].join(" ")+";\n")+"\n"+p+"\n"+e.shader.fragment,x=tt(m,e.vertexDefines,s),T=tt(y,e.fragmentDefines,s);(v=new J).uniformSemantics=e.shader.uniformSemantics,v.attributes=e.shader.attributes;var b=v.buildProgram(h,e.shader,x,T);return v.__error=b,i[o]=v,v};var it=rt,nt=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,at=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,ot=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,st={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"};function lt(t){for(var e=[],r=0;r<t;r++)e[r]=0;return e}var ht={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return lt(2)},vec3:function(){return lt(3)},vec4:function(){return lt(4)},ivec2:function(){return lt(2)},ivec3:function(){return lt(3)},ivec4:function(){return lt(4)},mat2:function(){return lt(4)},mat3:function(){return lt(9)},mat4:function(){return lt(16)},array:function(){return[]}},ut=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],ct=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],dt=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],ft={vec4:4,vec3:3,vec2:2,float:1},pt={},mt={};function gt(t){return t.replace(/[ \t]*\/\/.*\n/g,"").replace(/[ \t]*\/\*[\s\S]*?\*\//g,"")}function _t(){console.error("Wrong uniform/attributes syntax")}function vt(t,e){for(var r=/[,=\(\):]/,i=e.replace(/:\s*\[\s*(.*)\s*\]/g,"="+t+"($1)").replace(/\s+/g,"").split(/(?=[,=\(\):])/g),n=[],a=0;a<i.length;a++)i[a].match(r)?n.push(i[a].charAt(0),i[a].slice(1)):n.push(i[a]);var o,s=0,l={},h=null;function u(t){t||_t();var e=t.match(/\[(.*?)\]/);o=t.replace(/\[(.*?)\]/,""),l[o]={},e&&(l[o].isArray=!0,l[o].arraySize=e[1])}u((i=n)[0]);for(a=1;a<i.length;a++){var c=i[a];if(c)if("="!==c)if(":"!==c)if(","!==c)if(")"!==c)if("("!==c)if(c.indexOf("vec")>=0){if(1!==s&&4!==s){_t();break}s=2,h=[]}else if(1!==s)if(4!==s)u(c),s=0;else{var d=c;ut.indexOf(d)>=0||ct.indexOf(d)>=0||dt.indexOf(d)>=0?l[o].semantic=d:"ignore"===d||"unconfigurable"===d?l[o].ignore=!0:l[o].value="bool"===t?"true"===d:parseFloat(d)}else l[o].value="bool"===t?"true"===c:parseFloat(c),h=null;else{if(2!==s){_t();break}if(!(h instanceof Array)){_t();break}h.push(+i[++a])}else l[o].value=new v.a.Float32Array(h),h=null,s=5;else if(2===s){if(!(h instanceof Array)){_t();break}h.push(+i[++a])}else s=5;else s=4;else{if(0!==s&&3!==s){_t();break}s=1}}return l}function yt(t,e){"object"==typeof t&&(e=t.fragment,t=t.vertex),t=gt(t),e=gt(e),this._shaderID=function(t,e){var r="vertex:"+t+"fragment:"+e;if(pt[r])return pt[r];var i=c.genGUID();return pt[r]=i,mt[i]={vertex:t,fragment:e},i}(t,e),this._vertexCode=yt.parseImport(t),this._fragmentCode=yt.parseImport(e),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}yt.prototype={constructor:yt,createUniforms:function(){var t={};for(var e in this.uniformTemplates){var r=this.uniformTemplates[e];t[e]={type:r.type,value:r.value()}}return t},_parseImport:function(){this._vertexCode=yt.parseImport(this.vertex),this._fragmentCode=yt.parseImport(this.fragment)},_addSemanticUniform:function(t,e,r){if(ut.indexOf(r)>=0)this.attributeSemantics[r]={symbol:t,type:e};else if(dt.indexOf(r)>=0){var i=!1,n=r;r.match(/TRANSPOSE$/)&&(i=!0,n=r.slice(0,-9)),this.matrixSemantics[r]={symbol:t,type:e,isTranspose:i,semanticNoTranspose:n}}else ct.indexOf(r)>=0&&(this.uniformSemantics[r]={symbol:t,type:e})},_addMaterialUniform:function(t,e,r,i,n,a){a[t]={type:r,value:n?ht.array:i||ht[e],semantic:null}},_parseUniforms:function(){var t={},e=this,r="vertex";function i(t){return null!=t?function(){return t}:null}function n(n,a,o){var s=vt(a,o),l=[];for(var h in s){var u=s[h],c=u.semantic,d=h,f=st[a],p=i(s[h].value);s[h].isArray&&(d+="["+s[h].arraySize+"]",f+="v"),l.push(d),e._uniformList.push(h),u.ignore||("sampler2D"!==a&&"samplerCube"!==a||(e.textures[h]={shaderType:r,type:a}),c?e._addSemanticUniform(h,f,c):e._addMaterialUniform(h,a,f,p,s[h].isArray,t))}return l.length>0?"uniform "+a+" "+l.join(",")+";\n":""}this._uniformList=[],this._vertexCode=this._vertexCode.replace(nt,n),r="fragment",this._fragmentCode=this._fragmentCode.replace(nt,n),e.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=t},_parseAttributes:function(){var t={},e=this;this._vertexCode=this._vertexCode.replace(at,function(r,i,n){var a=vt(i,n),o=ft[i]||1,s=[];for(var l in a){var h=a[l].semantic;if(t[l]={type:"float",size:o,semantic:h||null},h){if(ut.indexOf(h)<0)throw new Error('Unkown semantic "'+h+'"');e.attributeSemantics[h]={symbol:l,type:i}}s.push(l)}return"attribute "+i+" "+s.join(",")+";\n"}),this.attributes=t},_parseDefines:function(){var t=this,e="vertex";function r(r,i,n){var a="vertex"===e?t.vertexDefines:t.fragmentDefines;return a[i]||(a[i]="false"!==n&&("true"===n||(n?isNaN(parseFloat(n))?n.trim():parseFloat(n):null))),""}this._vertexCode=this._vertexCode.replace(ot,r),e="fragment",this._fragmentCode=this._fragmentCode.replace(ot,r)},clone:function(){var t=mt[this._shaderID];return new yt(t.vertex,t.fragment)}},Object.defineProperty&&(Object.defineProperty(yt.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(yt.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(yt.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(yt.prototype,"uniforms",{get:function(){return this._uniformList}}));var xt=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;yt.parseImport=function(t){return t=t.replace(xt,function(t,e,r){return(t=yt.source(r))?yt.parseImport(t):(console.error('Shader chunk "'+r+'" not existed in library'),"")})};var Tt=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;yt.import=function(t){t.replace(Tt,function(t,e,r,i){if(i=i.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"")){for(var n,a=r.split("."),o=yt.codes,s=0;s<a.length-1;)o[n=a[s++]]||(o[n]={}),o=o[n];o[n=a[s]]=i}return i})},yt.codes={},yt.source=function(t){for(var e=t.split("."),r=yt.codes,i=0;r&&i<e.length;){r=r[e[i++]]}return"string"!=typeof r?(console.error('Shader "'+t+'" not existed in library'),""):r};var bt=yt,wt="@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end",St={create:function(){var t=new H(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},clone:function(t){var e=new H(16);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},copy:function(t,e){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},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},transpose:function(t,e){if(t===e){var r=e[1],i=e[2],n=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=a,t[11]=e[14],t[12]=n,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},invert:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],_=e[15],v=r*s-i*o,y=r*l-n*o,x=r*h-a*o,T=i*l-n*s,b=i*h-a*s,w=n*h-a*l,S=u*m-c*p,E=u*g-d*p,A=u*_-f*p,M=c*g-d*m,C=c*_-f*m,D=d*_-f*g,L=v*D-y*C+x*M+T*A-b*E+w*S;return L?(L=1/L,t[0]=(s*D-l*C+h*M)*L,t[1]=(n*C-i*D-a*M)*L,t[2]=(m*w-g*b+_*T)*L,t[3]=(d*b-c*w-f*T)*L,t[4]=(l*A-o*D-h*E)*L,t[5]=(r*D-n*A+a*E)*L,t[6]=(g*x-p*w-_*y)*L,t[7]=(u*w-d*x+f*y)*L,t[8]=(o*C-s*A+h*S)*L,t[9]=(i*A-r*C-a*S)*L,t[10]=(p*b-m*x+_*v)*L,t[11]=(c*x-u*b-f*v)*L,t[12]=(s*E-o*M-l*S)*L,t[13]=(r*M-i*E+n*S)*L,t[14]=(m*y-p*T-g*v)*L,t[15]=(u*T-c*y+d*v)*L,t):null},adjoint:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],_=e[15];return t[0]=s*(d*_-f*g)-c*(l*_-h*g)+m*(l*f-h*d),t[1]=-(i*(d*_-f*g)-c*(n*_-a*g)+m*(n*f-a*d)),t[2]=i*(l*_-h*g)-s*(n*_-a*g)+m*(n*h-a*l),t[3]=-(i*(l*f-h*d)-s*(n*f-a*d)+c*(n*h-a*l)),t[4]=-(o*(d*_-f*g)-u*(l*_-h*g)+p*(l*f-h*d)),t[5]=r*(d*_-f*g)-u*(n*_-a*g)+p*(n*f-a*d),t[6]=-(r*(l*_-h*g)-o*(n*_-a*g)+p*(n*h-a*l)),t[7]=r*(l*f-h*d)-o*(n*f-a*d)+u*(n*h-a*l),t[8]=o*(c*_-f*m)-u*(s*_-h*m)+p*(s*f-h*c),t[9]=-(r*(c*_-f*m)-u*(i*_-a*m)+p*(i*f-a*c)),t[10]=r*(s*_-h*m)-o*(i*_-a*m)+p*(i*h-a*s),t[11]=-(r*(s*f-h*c)-o*(i*f-a*c)+u*(i*h-a*s)),t[12]=-(o*(c*g-d*m)-u*(s*g-l*m)+p*(s*d-l*c)),t[13]=r*(c*g-d*m)-u*(i*g-n*m)+p*(i*d-n*c),t[14]=-(r*(s*g-l*m)-o*(i*g-n*m)+p*(i*l-n*s)),t[15]=r*(s*d-l*c)-o*(i*d-n*c)+u*(i*l-n*s),t},determinant:function(t){var e=t[0],r=t[1],i=t[2],n=t[3],a=t[4],o=t[5],s=t[6],l=t[7],h=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],m=t[14],g=t[15];return(e*o-r*a)*(c*g-d*m)-(e*s-i*a)*(u*g-d*p)+(e*l-n*a)*(u*m-c*p)+(r*s-i*o)*(h*g-d*f)-(r*l-n*o)*(h*m-c*f)+(i*l-n*s)*(h*p-u*f)},multiply:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],m=e[12],g=e[13],_=e[14],v=e[15],y=r[0],x=r[1],T=r[2],b=r[3];return t[0]=y*i+x*s+T*c+b*m,t[1]=y*n+x*l+T*d+b*g,t[2]=y*a+x*h+T*f+b*_,t[3]=y*o+x*u+T*p+b*v,y=r[4],x=r[5],T=r[6],b=r[7],t[4]=y*i+x*s+T*c+b*m,t[5]=y*n+x*l+T*d+b*g,t[6]=y*a+x*h+T*f+b*_,t[7]=y*o+x*u+T*p+b*v,y=r[8],x=r[9],T=r[10],b=r[11],t[8]=y*i+x*s+T*c+b*m,t[9]=y*n+x*l+T*d+b*g,t[10]=y*a+x*h+T*f+b*_,t[11]=y*o+x*u+T*p+b*v,y=r[12],x=r[13],T=r[14],b=r[15],t[12]=y*i+x*s+T*c+b*m,t[13]=y*n+x*l+T*d+b*g,t[14]=y*a+x*h+T*f+b*_,t[15]=y*o+x*u+T*p+b*v,t},multiplyAffine:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[4],s=e[5],l=e[6],h=e[8],u=e[9],c=e[10],d=e[12],f=e[13],p=e[14],m=r[0],g=r[1],_=r[2];return t[0]=m*i+g*o+_*h,t[1]=m*n+g*s+_*u,t[2]=m*a+g*l+_*c,m=r[4],g=r[5],_=r[6],t[4]=m*i+g*o+_*h,t[5]=m*n+g*s+_*u,t[6]=m*a+g*l+_*c,m=r[8],g=r[9],_=r[10],t[8]=m*i+g*o+_*h,t[9]=m*n+g*s+_*u,t[10]=m*a+g*l+_*c,m=r[12],g=r[13],_=r[14],t[12]=m*i+g*o+_*h+d,t[13]=m*n+g*s+_*u+f,t[14]=m*a+g*l+_*c+p,t}};St.mul=St.multiply,St.mulAffine=St.multiplyAffine,St.translate=function(t,e,r){var i,n,a,o,s,l,h,u,c,d,f,p,m=r[0],g=r[1],_=r[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*_+e[12],t[13]=e[1]*m+e[5]*g+e[9]*_+e[13],t[14]=e[2]*m+e[6]*g+e[10]*_+e[14],t[15]=e[3]*m+e[7]*g+e[11]*_+e[15]):(i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=h,t[7]=u,t[8]=c,t[9]=d,t[10]=f,t[11]=p,t[12]=i*m+s*g+c*_+e[12],t[13]=n*m+l*g+d*_+e[13],t[14]=a*m+h*g+f*_+e[14],t[15]=o*m+u*g+p*_+e[15]),t},St.scale=function(t,e,r){var i=r[0],n=r[1],a=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},St.rotate=function(t,e,r,i){var n,a,o,s,l,h,u,c,d,f,p,m,g,_,v,y,x,T,b,w,S,E,A,M,C=i[0],D=i[1],L=i[2],P=Math.sqrt(C*C+D*D+L*L);return Math.abs(P)<1e-6?null:(C*=P=1/P,D*=P,L*=P,n=Math.sin(r),o=1-(a=Math.cos(r)),s=e[0],l=e[1],h=e[2],u=e[3],c=e[4],d=e[5],f=e[6],p=e[7],m=e[8],g=e[9],_=e[10],v=e[11],y=C*C*o+a,x=D*C*o+L*n,T=L*C*o-D*n,b=C*D*o-L*n,w=D*D*o+a,S=L*D*o+C*n,E=C*L*o+D*n,A=D*L*o-C*n,M=L*L*o+a,t[0]=s*y+c*x+m*T,t[1]=l*y+d*x+g*T,t[2]=h*y+f*x+_*T,t[3]=u*y+p*x+v*T,t[4]=s*b+c*w+m*S,t[5]=l*b+d*w+g*S,t[6]=h*b+f*w+_*S,t[7]=u*b+p*w+v*S,t[8]=s*E+c*A+m*M,t[9]=l*E+d*A+g*M,t[10]=h*E+f*A+_*M,t[11]=u*E+p*A+v*M,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},St.rotateX=function(t,e,r){var i=Math.sin(r),n=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],h=e[8],u=e[9],c=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*n+h*i,t[5]=o*n+u*i,t[6]=s*n+c*i,t[7]=l*n+d*i,t[8]=h*n-a*i,t[9]=u*n-o*i,t[10]=c*n-s*i,t[11]=d*n-l*i,t},St.rotateY=function(t,e,r){var i=Math.sin(r),n=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],h=e[8],u=e[9],c=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*n-h*i,t[1]=o*n-u*i,t[2]=s*n-c*i,t[3]=l*n-d*i,t[8]=a*i+h*n,t[9]=o*i+u*n,t[10]=s*i+c*n,t[11]=l*i+d*n,t},St.rotateZ=function(t,e,r){var i=Math.sin(r),n=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],h=e[4],u=e[5],c=e[6],d=e[7];return e!==t&&(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[0]=a*n+h*i,t[1]=o*n+u*i,t[2]=s*n+c*i,t[3]=l*n+d*i,t[4]=h*n-a*i,t[5]=u*n-o*i,t[6]=c*n-s*i,t[7]=d*n-l*i,t},St.fromRotationTranslation=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=i+i,l=n+n,h=a+a,u=i*s,c=i*l,d=i*h,f=n*l,p=n*h,m=a*h,g=o*s,_=o*l,v=o*h;return t[0]=1-(f+m),t[1]=c+v,t[2]=d-_,t[3]=0,t[4]=c-v,t[5]=1-(u+m),t[6]=p+g,t[7]=0,t[8]=d+_,t[9]=p-g,t[10]=1-(u+f),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},St.fromQuat=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r+r,s=i+i,l=n+n,h=r*o,u=i*o,c=i*s,d=n*o,f=n*s,p=n*l,m=a*o,g=a*s,_=a*l;return t[0]=1-c-p,t[1]=u+_,t[2]=d-g,t[3]=0,t[4]=u-_,t[5]=1-h-p,t[6]=f+m,t[7]=0,t[8]=d+g,t[9]=f-m,t[10]=1-h-c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},St.frustum=function(t,e,r,i,n,a,o){var s=1/(r-e),l=1/(n-i),h=1/(a-o);return t[0]=2*a*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*a*l,t[6]=0,t[7]=0,t[8]=(r+e)*s,t[9]=(n+i)*l,t[10]=(o+a)*h,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*a*2*h,t[15]=0,t},St.perspective=function(t,e,r,i,n){var a=1/Math.tan(e/2),o=1/(i-n);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(n+i)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*n*i*o,t[15]=0,t},St.ortho=function(t,e,r,i,n,a,o){var s=1/(e-r),l=1/(i-n),h=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+r)*s,t[13]=(n+i)*l,t[14]=(o+a)*h,t[15]=1,t},St.lookAt=function(t,e,r,i){var n,a,o,s,l,h,u,c,d,f,p=e[0],m=e[1],g=e[2],_=i[0],v=i[1],y=i[2],x=r[0],T=r[1],b=r[2];return Math.abs(p-x)<1e-6&&Math.abs(m-T)<1e-6&&Math.abs(g-b)<1e-6?St.identity(t):(u=p-x,c=m-T,d=g-b,n=v*(d*=f=1/Math.sqrt(u*u+c*c+d*d))-y*(c*=f),a=y*(u*=f)-_*d,o=_*c-v*u,(f=Math.sqrt(n*n+a*a+o*o))?(n*=f=1/f,a*=f,o*=f):(n=0,a=0,o=0),s=c*o-d*a,l=d*n-u*o,h=u*a-c*n,(f=Math.sqrt(s*s+l*l+h*h))?(s*=f=1/f,l*=f,h*=f):(s=0,l=0,h=0),t[0]=n,t[1]=s,t[2]=u,t[3]=0,t[4]=a,t[5]=l,t[6]=c,t[7]=0,t[8]=o,t[9]=h,t[10]=d,t[11]=0,t[12]=-(n*p+a*m+o*g),t[13]=-(s*p+l*m+h*g),t[14]=-(u*p+c*m+d*g),t[15]=1,t)},St.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2)+Math.pow(t[9],2)+Math.pow(t[10],2)+Math.pow(t[11],2)+Math.pow(t[12],2)+Math.pow(t[13],2)+Math.pow(t[14],2)+Math.pow(t[15],2))};var Et=St,At={create:function(){var t=new H(3);return t[0]=0,t[1]=0,t[2]=0,t},clone:function(t){var e=new H(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},fromValues:function(t,e,r){var i=new H(3);return i[0]=t,i[1]=e,i[2]=r,i},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},set:function(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},subtract:function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}};At.sub=At.subtract,At.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t},At.mul=At.multiply,At.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t},At.div=At.divide,At.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},At.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},At.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},At.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t},At.distance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2];return Math.sqrt(r*r+i*i+n*n)},At.dist=At.distance,At.squaredDistance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2];return r*r+i*i+n*n},At.sqrDist=At.squaredDistance,At.length=function(t){var e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)},At.len=At.length,At.squaredLength=function(t){var e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i},At.sqrLen=At.squaredLength,At.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},At.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},At.normalize=function(t,e){var r=e[0],i=e[1],n=e[2],a=r*r+i*i+n*n;return a>0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t},At.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},At.cross=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=n*l-a*s,t[1]=a*o-i*l,t[2]=i*s-n*o,t},At.lerp=function(t,e,r,i){var n=e[0],a=e[1],o=e[2];return t[0]=n+i*(r[0]-n),t[1]=a+i*(r[1]-a),t[2]=o+i*(r[2]-o),t},At.random=function(t,e){e=e||1;var r=2*V()*Math.PI,i=2*V()-1,n=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t[2]=i*e,t},At.transformMat4=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[3]*i+r[7]*n+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*i+r[4]*n+r[8]*a+r[12])/o,t[1]=(r[1]*i+r[5]*n+r[9]*a+r[13])/o,t[2]=(r[2]*i+r[6]*n+r[10]*a+r[14])/o,t},At.transformMat3=function(t,e,r){var i=e[0],n=e[1],a=e[2];return t[0]=i*r[0]+n*r[3]+a*r[6],t[1]=i*r[1]+n*r[4]+a*r[7],t[2]=i*r[2]+n*r[5]+a*r[8],t},At.transformQuat=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2],h=r[3],u=h*i+s*a-l*n,c=h*n+l*i-o*a,d=h*a+o*n-s*i,f=-o*i-s*n-l*a;return t[0]=u*h+f*-o+c*-l-d*-s,t[1]=c*h+f*-s+d*-o-u*-l,t[2]=d*h+f*-l+u*-s-c*-o,t},At.rotateX=function(t,e,r,i){var n=[],a=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],a[0]=n[0],a[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),a[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},At.rotateY=function(t,e,r,i){var n=[],a=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],a[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),a[1]=n[1],a[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},At.rotateZ=function(t,e,r,i){var n=[],a=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],a[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),a[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),a[2]=n[2],t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},At.forEach=function(){var t=At.create();return function(e,r,i,n,a,o){var s,l;for(r||(r=3),i||(i=0),l=n?Math.min(n*r+i,e.length):e.length,s=i;s<l;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],a(t,t,o),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2];return e}}(),At.angle=function(t,e){var r=At.fromValues(t[0],t[1],t[2]),i=At.fromValues(e[0],e[1],e[2]);At.normalize(r,r),At.normalize(i,i);var n=At.dot(r,i);return n>1?0:Math.acos(n)};var Mt=At;bt.import(wt);var Ct=Et.create,Dt={};function Lt(t){return t.material}function Pt(t,e,r){return e.uniforms[r].value}function Nt(t,e,r,i){return r!==i}function Rt(t){return!0}function It(){}var Ot={float:_.FLOAT,byte:_.BYTE,ubyte:_.UNSIGNED_BYTE,short:_.SHORT,ushort:_.UNSIGNED_SHORT};var Bt=f.extend(function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},maxJointNumber:20,__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}},function(){this.canvas||(this.canvas=v.a.createCanvas());var t=this.canvas;try{var e={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!this.gl)throw new Error;this._glinfo=new g(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(t){throw"Error creating WebGL Context "+t}this._programMgr=new it(this),this._placeholderTexture=new function(t){var e,r;this.bind=function(t){e||((e=v.a.createCanvas()).width=e.height=1,e.getContext("2d"));var i=t.gl,n=!r;n&&(r=i.createTexture()),i.bindTexture(i.TEXTURE_2D,r),n&&i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e)},this.unbind=function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}(this)},{resize:function(t,e){var r=this.canvas,i=this.devicePixelRatio;null!=t?(r.style&&(r.style.width=t+"px",r.style.height=e+"px"),r.width=t*i,r.height=e*i,this._width=t,this._height=e):(this._width=r.width/i,this._height=r.height/i),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var t=this.viewport;return t.width/t.height},setDevicePixelRatio:function(t){this.devicePixelRatio=t,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(t){return this._glinfo.getExtension(t)},getGLParameter:function(t){return this._glinfo.getParameter(t)},setViewport:function(t,e,r,i,n){if("object"==typeof t){var a=t;t=a.x,e=a.y,r=a.width,i=a.height,n=a.devicePixelRatio}n=n||this.devicePixelRatio,this.gl.viewport(t*n,e*n,r*n,i*n),this.viewport={x:t,y:e,width:r,height:i,devicePixelRatio:n}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var t=this._clearStack.pop();this.clearColor=t.clearColor,this.clearBit=t.clearBit}},bindSceneRendering:function(t){this._sceneRendering=t},render:function(t,e,r,i){var n=this.gl,a=this.clearColor;if(this.clearBit){n.colorMask(!0,!0,!0,!0),n.depthMask(!0);var o=this.viewport,s=!1,l=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||l&&l!==this.devicePixelRatio||o.x||o.y)&&(s=!0,n.enable(n.SCISSOR_TEST),n.scissor(o.x*l,o.y*l,o.width*l,o.height*l)),n.clearColor(a[0],a[1],a[2],a[3]),n.clear(this.clearBit),s&&n.disable(n.SCISSOR_TEST)}if(r||t.update(!1),t.updateLights(),e=e||t.getMainCamera()){e.update();var h=t.updateRenderList(e,!0);this._sceneRendering=t;var u=h.opaque,c=h.transparent,d=t.material;t.trigger("beforerender",this,t,e,h),i?(this.renderPreZ(u,t,e),n.depthFunc(n.LEQUAL)):n.depthFunc(n.LESS);for(var f=Ct(),p=Mt.create(),m=0;m<c.length;m++){var g=c[m];Et.multiplyAffine(f,e.viewMatrix.array,g.worldTransform.array),Mt.transformMat4(p,g.position.array,f),g.__depth=p[2]}this.renderPass(u,e,{getMaterial:function(t){return d||t.material},sortCompare:this.opaqueSortCompare}),this.renderPass(c,e,{getMaterial:function(t){return d||t.material},sortCompare:this.transparentSortCompare}),t.trigger("afterrender",this,t,e,h),this._sceneRendering=null}else console.error("Can't find camera in the scene.")},getProgram:function(t,e,r){return e=e||t.material,this._programMgr.getProgram(t,e,r)},validateProgram:function(t){if(t.__error){var e=t.__error;if(Dt[t.__uid__])return;if(Dt[t.__uid__]=!0,this.throwError)throw new Error(e);this.trigger("error",e)}},updatePrograms:function(t,e,r){var i=r&&r.getMaterial||Lt;e=e||null;for(var n=0;n<t.length;n++){var a=t[n],o=i.call(this,a);if(n>0){var s=t[n-1],l=s.joints?s.joints.length:0;if((a.joints?a.joints.length:0)===l&&a.material===s.material&&a.lightGroup===s.lightGroup){a.__program=s.__program;continue}}var h=this._programMgr.getProgram(a,o,e);this.validateProgram(h),a.__program=h}},renderPass:function(t,e,r){this.trigger("beforerenderpass",this,t,e,r),(r=r||{}).getMaterial=r.getMaterial||Lt,r.getUniform=r.getUniform||Pt,r.isMaterialChanged=r.isMaterialChanged||Nt,r.beforeRender=r.beforeRender||It,r.afterRender=r.afterRender||It;var i=r.ifRender||Rt;this.updatePrograms(t,this._sceneRendering,r),r.sortCompare&&t.sort(r.sortCompare);var n=this.viewport,a=n.devicePixelRatio,o=[n.x*a,n.y*a,n.width*a,n.height*a],s=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*s,this._height*s],h=[o[2],o[3]],u=Date.now();e?(Et.copy(Ft.VIEW,e.viewMatrix.array),Et.copy(Ft.PROJECTION,e.projectionMatrix.array),Et.copy(Ft.VIEWINVERSE,e.worldTransform.array)):(Et.identity(Ft.VIEW),Et.identity(Ft.PROJECTION),Et.identity(Ft.VIEWINVERSE)),Et.multiply(Ft.VIEWPROJECTION,Ft.PROJECTION,Ft.VIEW),Et.invert(Ft.PROJECTIONINVERSE,Ft.PROJECTION),Et.invert(Ft.VIEWPROJECTIONINVERSE,Ft.VIEWPROJECTION);for(var c,d,f,p,m,g,_,v,y,x,T,b,w=this.gl,S=this._sceneRendering,E=0;E<t.length;E++){var A,M=t[E],C=null!=M.worldTransform;if(i(M)){C&&(A=M.isSkinnedMesh&&M.isSkinnedMesh()?M.offsetMatrix?M.offsetMatrix.array:Ft.IDENTITY:M.worldTransform.array);var D=M.geometry,L=r.getMaterial.call(this,M),P=M.__program,N=L.shader,R=D.__uid__+"-"+P.__uid__,I=R!==x;x=R,C&&(Et.copy(Ft.WORLD,A),Et.multiply(Ft.WORLDVIEWPROJECTION,Ft.VIEWPROJECTION,A),Et.multiplyAffine(Ft.WORLDVIEW,Ft.VIEW,A),(N.matrixSemantics.WORLDINVERSE||N.matrixSemantics.WORLDINVERSETRANSPOSE)&&Et.invert(Ft.WORLDINVERSE,A),(N.matrixSemantics.WORLDVIEWINVERSE||N.matrixSemantics.WORLDVIEWINVERSETRANSPOSE)&&Et.invert(Ft.WORLDVIEWINVERSE,Ft.WORLDVIEW),(N.matrixSemantics.WORLDVIEWPROJECTIONINVERSE||N.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE)&&Et.invert(Ft.WORLDVIEWPROJECTIONINVERSE,Ft.WORLDVIEWPROJECTION)),M.beforeRender&&M.beforeRender(this),r.beforeRender.call(this,M,L,c);var O=P!==d;O?(P.bind(this),P.setUniformOfSemantic(w,"VIEWPORT",o),P.setUniformOfSemantic(w,"WINDOW_SIZE",l),e&&(P.setUniformOfSemantic(w,"NEAR",e.near),P.setUniformOfSemantic(w,"FAR",e.far)),P.setUniformOfSemantic(w,"DEVICEPIXELRATIO",a),P.setUniformOfSemantic(w,"TIME",u),P.setUniformOfSemantic(w,"VIEWPORT_SIZE",h),S&&S.setLightUniforms(P,M.lightGroup,this)):P=d,(O||r.isMaterialChanged(M,f,L,c))&&(L.depthTest!==p&&(L.depthTest?w.enable(w.DEPTH_TEST):w.disable(w.DEPTH_TEST),p=L.depthTest),L.depthMask!==m&&(w.depthMask(L.depthMask),m=L.depthMask),L.transparent!==y&&(L.transparent?w.enable(w.BLEND):w.disable(w.BLEND),y=L.transparent),L.transparent&&(L.blend?L.blend(w):(w.blendEquationSeparate(w.FUNC_ADD,w.FUNC_ADD),w.blendFuncSeparate(w.SRC_ALPHA,w.ONE_MINUS_SRC_ALPHA,w.ONE,w.ONE_MINUS_SRC_ALPHA))),b=this._bindMaterial(M,L,P,f||null,c||null,d||null,r.getUniform),c=L);var B=N.matrixSemanticKeys;if(C)for(var F=0;F<B.length;F++){var z=B[F],U=N.matrixSemantics[z],k=Ft[z];if(U.isTranspose){var G=Ft[U.semanticNoTranspose];Et.transpose(k,G)}P.setUniform(w,U.type,U.symbol,k)}M.cullFace!==_&&(_=M.cullFace,w.cullFace(_)),M.frontFace!==v&&(v=M.frontFace,w.frontFace(v)),M.culling!==g&&((g=M.culling)?w.enable(w.CULL_FACE):w.disable(w.CULL_FACE)),this._updateSkeleton(M,P,b),I&&(T=this._bindVAO(null,N,D,P)),this._renderObject(M,T,P),r.afterRender(this,M),M.afterRender&&M.afterRender(this),d=P,f=M}}this.trigger("afterrenderpass",this,t,e,r)},getMaxJointNumber:function(){return this.maxJointNumber},_updateSkeleton:function(t,e,r){var i=this.gl,n=t.skeleton;if(n)if(n.update(),t.joints.length>this.getMaxJointNumber()){var a=n.getSubSkinMatricesTexture(t.__uid__,t.joints);e.useTextureSlot(this,a,r),e.setUniform(i,"1i","skinMatricesTexture",r),e.setUniform(i,"1f","skinMatricesTextureSize",a.width)}else{var o=n.getSubSkinMatrices(t.__uid__,t.joints);e.setUniformOfSemantic(i,"SKIN_MATRIX",o)}},_renderObject:function(t,e,r){var i=this.gl,n=t.geometry,a=t.mode;null==a&&(a=4);var o=null,s=t.isInstancedMesh&&t.isInstancedMesh();if(!s||(o=this.getGLExtension("ANGLE_instanced_arrays"))){var l;if(s&&(l=this._bindInstancedAttributes(t,r,o)),e.indicesBuffer){var h=this.getGLExtension("OES_element_index_uint")&&n.indices instanceof Uint32Array?i.UNSIGNED_INT:i.UNSIGNED_SHORT;s?o.drawElementsInstancedANGLE(a,e.indicesBuffer.count,h,0,t.getInstanceCount()):i.drawElements(a,e.indicesBuffer.count,h,0)}else s?o.drawArraysInstancedANGLE(a,0,n.vertexCount,t.getInstanceCount()):i.drawArrays(a,0,n.vertexCount);if(s)for(var u=0;u<l.length;u++)i.disableVertexAttribArray(l[u])}else console.warn("Device not support ANGLE_instanced_arrays extension")},_bindInstancedAttributes:function(t,e,r){for(var i=this.gl,n=t.getInstancedAttributesBuffers(this),a=[],o=0;o<n.length;o++){var s=n[o],l=e.getAttribLocation(i,s.symbol);if(!(l<0)){var h=Ot[s.type]||i.FLOAT;i.enableVertexAttribArray(l),i.bindBuffer(i.ARRAY_BUFFER,s.buffer),i.vertexAttribPointer(l,s.size,h,!1,0,0),r.vertexAttribDivisorANGLE(l,s.divisor),a.push(l)}}return a},_bindMaterial:function(t,e,r,i,n,a,o){for(var s=this.gl,l=a===r,h=r.currentTextureSlot(),u=e.getEnabledUniforms(),c=e.getTextureUniforms(),d=this._placeholderTexture,f=0;f<c.length;f++){var p=o(t,e,_=c[f]);if("t"===(g=e.uniforms[_].type)&&p)p.__slot=-1;else if("tv"===g)for(var m=0;m<p.length;m++)p[m]&&(p[m].__slot=-1)}d.__slot=-1;for(f=0;f<u.length;f++){var g,_=u[f],v=e.uniforms[_],y=(p=o(t,e,_),"t"===(g=v.type));if(y&&(p&&p.isRenderable()||(p=d)),n&&l){var x=o(i,n,_);if(y&&(x&&x.isRenderable()||(x=d)),x===p){if(y)r.takeCurrentTextureSlot(this,null);else if("tv"===g&&p)for(m=0;m<p.length;m++)r.takeCurrentTextureSlot(this,null);continue}}if(null!=p)if(y)if(p.__slot<0){var T=r.currentTextureSlot();r.setUniform(s,"1i",_,T)&&(r.takeCurrentTextureSlot(this,p),p.__slot=T)}else r.setUniform(s,"1i",_,p.__slot);else if(Array.isArray(p)){if(0===p.length)continue;if("tv"===g){if(!r.hasUniform(_))continue;var b=[];for(m=0;m<p.length;m++){var w=p[m];if(w.__slot<0){T=r.currentTextureSlot();b.push(T),r.takeCurrentTextureSlot(this,w),w.__slot=T}else b.push(w.__slot)}r.setUniform(s,"1iv",_,b)}else r.setUniform(s,v.type,_,p)}else r.setUniform(s,v.type,_,p)}var S=r.currentTextureSlot();return r.resetTextureSlot(h),S},_bindVAO:function(t,e,r,i){var n=!r.dynamic,a=this.gl,o=this.__uid__+"-"+i.__uid__,s=r.__vaoCache[o];if(!s){var l=r.getBufferChunks(this);if(!l||!l.length)return;for(var h=l[0],u=h.attributeBuffers,c=h.indicesBuffer,d=[],f=[],p=0;p<u.length;p++){var m,g=(b=u[p]).name,_=b.semantic;if(_){var v=e.attributeSemantics[_];m=v&&v.symbol}else m=g;m&&i.attributes[m]&&(d.push(b),f.push(m))}s=new function(t,e,r){this.availableAttributes=t,this.availableAttributeSymbols=e,this.indicesBuffer=r,this.vao=null}(d,f,c),n&&(r.__vaoCache[o]=s)}var y=!0;t&&n&&(null==s.vao?s.vao=t.createVertexArrayOES():y=!1,t.bindVertexArrayOES(s.vao));d=s.availableAttributes,c=s.indicesBuffer;if(y){var x=i.enableAttributes(this,s.availableAttributeSymbols,t&&n&&s);for(p=0;p<d.length;p++){var T=x[p];if(-1!==T){var b,w=(b=d[p]).buffer,S=b.size,E=Ot[b.type]||a.FLOAT;a.bindBuffer(a.ARRAY_BUFFER,w),a.vertexAttribPointer(T,S,E,!1,0,0)}}r.isUseIndices()&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,c.buffer)}return s},renderPreZ:function(t,e,r){var i=this.gl,n=this._prezMaterial||new G({shader:new bt(bt.source("clay.prez.vertex"),bt.source("clay.prez.fragment"))});this._prezMaterial=n,i.colorMask(!1,!1,!1,!1),i.depthMask(!0),this.renderPass(t,r,{ifRender:function(t){return!t.ignorePreZ},isMaterialChanged:function(t,e){var r=t.material,i=e.material;return r.get("diffuseMap")!==i.get("diffuseMap")||(r.get("alphaCutoff")||0)!==(i.get("alphaCutoff")||0)},getUniform:function(t,e,r){return"alphaMap"===r?t.material.get("diffuseMap"):"alphaCutoff"===r?t.material.isDefined("fragment","ALPHA_TEST")&&t.material.get("diffuseMap")&&t.material.get("alphaCutoff")||0:"uvRepeat"===r?t.material.get("uvRepeat"):"uvOffset"===r?t.material.get("uvOffset"):e.get(r)},getMaterial:function(){return n},sort:this.opaqueSortCompare}),i.colorMask(!0,!0,!0,!0),i.depthMask(!0)},disposeScene:function(t){this.disposeNode(t,!0,!0),t.dispose()},disposeNode:function(t,e,r){t.getParent()&&t.getParent().remove(t);var i={};t.traverse(function(t){var n=t.material;if(t.geometry&&e&&t.geometry.dispose(this),r&&n&&!i[n.__uid__]){for(var a=n.getTextureUniforms(),o=0;o<a.length;o++){var s=a[o],l=n.uniforms[s].value,h=n.uniforms[s].type;if(l)if("t"===h)l.dispose&&l.dispose(this);else if("tv"===h)for(var u=0;u<l.length;u++)l[u]&&l[u].dispose&&l[u].dispose(this)}i[n.__uid__]=!0}t.dispose&&t.dispose(this)},this)},disposeGeometry:function(t){t.dispose(this)},disposeTexture:function(t){t.dispose(this)},disposeFrameBuffer:function(t){t.dispose(this)},dispose:function(){},screenToNDC:function(t,e,r){r||(r=new Z),e=this._height-e;var i=this.viewport,n=r.array;return n[0]=(t-i.x)/i.width,n[0]=2*n[0]-1,n[1]=(e-i.y)/i.height,n[1]=2*n[1]-1,r}});Bt.opaqueSortCompare=Bt.prototype.opaqueSortCompare=function(t,e){return t.renderOrder===e.renderOrder?t.__program===e.__program?t.material===e.material?t.geometry.__uid__-e.geometry.__uid__:t.material.__uid__-e.material.__uid__:t.__program&&e.__program?t.__program.__uid__-e.__program.__uid__:0:t.renderOrder-e.renderOrder},Bt.transparentSortCompare=Bt.prototype.transparentSortCompare=function(t,e){return t.renderOrder===e.renderOrder?t.__depth===e.__depth?t.__program===e.__program?t.material===e.material?t.geometry.__uid__-e.geometry.__uid__:t.material.__uid__-e.material.__uid__:t.__program&&e.__program?t.__program.__uid__-e.__program.__uid__:0:t.__depth-e.__depth:t.renderOrder-e.renderOrder};var Ft={IDENTITY:Ct(),WORLD:Ct(),VIEW:Ct(),PROJECTION:Ct(),WORLDVIEW:Ct(),VIEWPROJECTION:Ct(),WORLDVIEWPROJECTION:Ct(),WORLDINVERSE:Ct(),VIEWINVERSE:Ct(),PROJECTIONINVERSE:Ct(),WORLDVIEWINVERSE:Ct(),VIEWPROJECTIONINVERSE:Ct(),WORLDVIEWPROJECTIONINVERSE:Ct(),WORLDTRANSPOSE:Ct(),VIEWTRANSPOSE:Ct(),PROJECTIONTRANSPOSE:Ct(),WORLDVIEWTRANSPOSE:Ct(),VIEWPROJECTIONTRANSPOSE:Ct(),WORLDVIEWPROJECTIONTRANSPOSE:Ct(),WORLDINVERSETRANSPOSE:Ct(),VIEWINVERSETRANSPOSE:Ct(),PROJECTIONINVERSETRANSPOSE:Ct(),WORLDVIEWINVERSETRANSPOSE:Ct(),VIEWPROJECTIONINVERSETRANSPOSE:Ct(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:Ct()};Bt.COLOR_BUFFER_BIT=_.COLOR_BUFFER_BIT,Bt.DEPTH_BUFFER_BIT=_.DEPTH_BUFFER_BIT,Bt.STENCIL_BUFFER_BIT=_.STENCIL_BUFFER_BIT;var zt=Bt,Ut=function(t,e,r){t=t||0,e=e||0,r=r||0,this.array=Mt.fromValues(t,e,r),this._dirty=!0};Ut.prototype={constructor:Ut,add:function(t){return Mt.add(this.array,this.array,t.array),this._dirty=!0,this},set:function(t,e,r){return this.array[0]=t,this.array[1]=e,this.array[2]=r,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this.array[2]=t[2],this._dirty=!0,this},clone:function(){return new Ut(this.x,this.y,this.z)},copy:function(t){return Mt.copy(this.array,t.array),this._dirty=!0,this},cross:function(t,e){return Mt.cross(this.array,t.array,e.array),this._dirty=!0,this},dist:function(t){return Mt.dist(this.array,t.array)},distance:function(t){return Mt.distance(this.array,t.array)},div:function(t){return Mt.div(this.array,this.array,t.array),this._dirty=!0,this},divide:function(t){return Mt.divide(this.array,this.array,t.array),this._dirty=!0,this},dot:function(t){return Mt.dot(this.array,t.array)},len:function(){return Mt.len(this.array)},length:function(){return Mt.length(this.array)},lerp:function(t,e,r){return Mt.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},min:function(t){return Mt.min(this.array,this.array,t.array),this._dirty=!0,this},max:function(t){return Mt.max(this.array,this.array,t.array),this._dirty=!0,this},mul:function(t){return Mt.mul(this.array,this.array,t.array),this._dirty=!0,this},multiply:function(t){return Mt.multiply(this.array,this.array,t.array),this._dirty=!0,this},negate:function(){return Mt.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return Mt.normalize(this.array,this.array),this._dirty=!0,this},random:function(t){return Mt.random(this.array,t),this._dirty=!0,this},scale:function(t){return Mt.scale(this.array,this.array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return Mt.scaleAndAdd(this.array,this.array,t.array,e),this._dirty=!0,this},sqrDist:function(t){return Mt.sqrDist(this.array,t.array)},squaredDistance:function(t){return Mt.squaredDistance(this.array,t.array)},sqrLen:function(){return Mt.sqrLen(this.array)},squaredLength:function(){return Mt.squaredLength(this.array)},sub:function(t){return Mt.sub(this.array,this.array,t.array),this._dirty=!0,this},subtract:function(t){return Mt.subtract(this.array,this.array,t.array),this._dirty=!0,this},transformMat3:function(t){return Mt.transformMat3(this.array,this.array,t.array),this._dirty=!0,this},transformMat4:function(t){return Mt.transformMat4(this.array,this.array,t.array),this._dirty=!0,this},transformQuat:function(t){return Mt.transformQuat(this.array,this.array,t.array),this._dirty=!0,this},applyProjection:function(t){var e=this.array;if(0===(t=t.array)[15]){var r=-1/e[2];e[0]=t[0]*e[0]*r,e[1]=t[5]*e[1]*r,e[2]=(t[10]*e[2]+t[14])*r}else e[0]=t[0]*e[0]+t[12],e[1]=t[5]*e[1]+t[13],e[2]=t[10]*e[2]+t[14];return this._dirty=!0,this},eulerFromQuat:function(t,e){Ut.eulerFromQuat(this,t,e)},eulerFromMat3:function(t,e){Ut.eulerFromMat3(this,t,e)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var kt=Object.defineProperty;if(kt){var Gt=Ut.prototype;kt(Gt,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),kt(Gt,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}}),kt(Gt,"z",{get:function(){return this.array[2]},set:function(t){this.array[2]=t,this._dirty=!0}})}function Ht(t,e,r){return t<e?e:t>r?r:t}Ut.add=function(t,e,r){return Mt.add(t.array,e.array,r.array),t._dirty=!0,t},Ut.set=function(t,e,r,i){Mt.set(t.array,e,r,i),t._dirty=!0},Ut.copy=function(t,e){return Mt.copy(t.array,e.array),t._dirty=!0,t},Ut.cross=function(t,e,r){return Mt.cross(t.array,e.array,r.array),t._dirty=!0,t},Ut.distance=Ut.dist=function(t,e){return Mt.distance(t.array,e.array)},Ut.divide=Ut.div=function(t,e,r){return Mt.divide(t.array,e.array,r.array),t._dirty=!0,t},Ut.dot=function(t,e){return Mt.dot(t.array,e.array)},Ut.len=function(t){return Mt.length(t.array)},Ut.lerp=function(t,e,r,i){return Mt.lerp(t.array,e.array,r.array,i),t._dirty=!0,t},Ut.min=function(t,e,r){return Mt.min(t.array,e.array,r.array),t._dirty=!0,t},Ut.max=function(t,e,r){return Mt.max(t.array,e.array,r.array),t._dirty=!0,t},Ut.multiply=Ut.mul=function(t,e,r){return Mt.multiply(t.array,e.array,r.array),t._dirty=!0,t},Ut.negate=function(t,e){return Mt.negate(t.array,e.array),t._dirty=!0,t},Ut.normalize=function(t,e){return Mt.normalize(t.array,e.array),t._dirty=!0,t},Ut.random=function(t,e){return Mt.random(t.array,e),t._dirty=!0,t},Ut.scale=function(t,e,r){return Mt.scale(t.array,e.array,r),t._dirty=!0,t},Ut.scaleAndAdd=function(t,e,r,i){return Mt.scaleAndAdd(t.array,e.array,r.array,i),t._dirty=!0,t},Ut.squaredDistance=Ut.sqrDist=function(t,e){return Mt.sqrDist(t.array,e.array)},Ut.squaredLength=Ut.sqrLen=function(t){return Mt.sqrLen(t.array)},Ut.subtract=Ut.sub=function(t,e,r){return Mt.subtract(t.array,e.array,r.array),t._dirty=!0,t},Ut.transformMat3=function(t,e,r){return Mt.transformMat3(t.array,e.array,r.array),t._dirty=!0,t},Ut.transformMat4=function(t,e,r){return Mt.transformMat4(t.array,e.array,r.array),t._dirty=!0,t},Ut.transformQuat=function(t,e,r){return Mt.transformQuat(t.array,e.array,r.array),t._dirty=!0,t};var Vt=Math.atan2,Wt=Math.asin,Xt=Math.abs;Ut.eulerFromQuat=function(t,e,r){t._dirty=!0,e=e.array;var i=t.array,n=e[0],a=e[1],o=e[2],s=e[3],l=n*n,h=a*a,u=o*o,c=s*s;switch(r=(r||"XYZ").toUpperCase()){case"XYZ":i[0]=Vt(2*(n*s-a*o),c-l-h+u),i[1]=Wt(Ht(2*(n*o+a*s),-1,1)),i[2]=Vt(2*(o*s-n*a),c+l-h-u);break;case"YXZ":i[0]=Wt(Ht(2*(n*s-a*o),-1,1)),i[1]=Vt(2*(n*o+a*s),c-l-h+u),i[2]=Vt(2*(n*a+o*s),c-l+h-u);break;case"ZXY":i[0]=Wt(Ht(2*(n*s+a*o),-1,1)),i[1]=Vt(2*(a*s-o*n),c-l-h+u),i[2]=Vt(2*(o*s-n*a),c-l+h-u);break;case"ZYX":i[0]=Vt(2*(n*s+o*a),c-l-h+u),i[1]=Wt(Ht(2*(a*s-n*o),-1,1)),i[2]=Vt(2*(n*a+o*s),c+l-h-u);break;case"YZX":i[0]=Vt(2*(n*s-o*a),c-l+h-u),i[1]=Vt(2*(a*s-n*o),c+l-h-u),i[2]=Wt(Ht(2*(n*a+o*s),-1,1));break;case"XZY":i[0]=Vt(2*(n*s+a*o),c-l+h-u),i[1]=Vt(2*(n*o+a*s),c+l-h-u),i[2]=Wt(Ht(2*(o*s-n*a),-1,1));break;default:console.warn("Unkown order: "+r)}return t},Ut.eulerFromMat3=function(t,e,r){var i=e.array,n=i[0],a=i[3],o=i[6],s=i[1],l=i[4],h=i[7],u=i[2],c=i[5],d=i[8],f=t.array;switch(r=(r||"XYZ").toUpperCase()){case"XYZ":f[1]=Wt(Ht(o,-1,1)),Xt(o)<.99999?(f[0]=Vt(-h,d),f[2]=Vt(-a,n)):(f[0]=Vt(c,l),f[2]=0);break;case"YXZ":f[0]=Wt(-Ht(h,-1,1)),Xt(h)<.99999?(f[1]=Vt(o,d),f[2]=Vt(s,l)):(f[1]=Vt(-u,n),f[2]=0);break;case"ZXY":f[0]=Wt(Ht(c,-1,1)),Xt(c)<.99999?(f[1]=Vt(-u,d),f[2]=Vt(-a,l)):(f[1]=0,f[2]=Vt(s,n));break;case"ZYX":f[1]=Wt(-Ht(u,-1,1)),Xt(u)<.99999?(f[0]=Vt(c,d),f[2]=Vt(s,n)):(f[0]=0,f[2]=Vt(-a,l));break;case"YZX":f[2]=Wt(Ht(s,-1,1)),Xt(s)<.99999?(f[0]=Vt(-h,l),f[1]=Vt(-u,n)):(f[0]=0,f[1]=Vt(o,d));break;case"XZY":f[2]=Wt(-Ht(a,-1,1)),Xt(a)<.99999?(f[0]=Vt(c,l),f[1]=Vt(o,n)):(f[0]=Vt(-h,d),f[1]=0);break;default:console.warn("Unkown order: "+r)}return t._dirty=!0,t},Object.defineProperties(Ut,{POSITIVE_X:{get:function(){return new Ut(1,0,0)}},NEGATIVE_X:{get:function(){return new Ut(-1,0,0)}},POSITIVE_Y:{get:function(){return new Ut(0,1,0)}},NEGATIVE_Y:{get:function(){return new Ut(0,-1,0)}},POSITIVE_Z:{get:function(){return new Ut(0,0,1)}},NEGATIVE_Z:{get:function(){return new Ut(0,0,-1)}},UP:{get:function(){return new Ut(0,1,0)}},ZERO:{get:function(){return new Ut}}});var jt,qt,Zt,Yt,Kt,Qt=Ut,Jt=function(t,e){this.origin=t||new Qt,this.direction=e||new Qt};Jt.prototype={constructor:Jt,intersectPlane:function(t,e){var r=t.normal.array,i=t.distance,n=this.origin.array,a=this.direction.array,o=Mt.dot(r,a);if(0===o)return null;e||(e=new Qt);var s=(Mt.dot(r,n)-i)/o;return Mt.scaleAndAdd(e.array,n,a,-s),e._dirty=!0,e},mirrorAgainstPlane:function(t){var e=Mt.dot(t.normal.array,this.direction.array);Mt.scaleAndAdd(this.direction.array,this.direction.array,t.normal.array,2*-e),this.direction._dirty=!0},distanceToPoint:(Kt=Mt.create(),function(t){Mt.sub(Kt,t,this.origin.array);var e=Mt.dot(Kt,this.direction.array);if(e<0)return Mt.distance(this.origin.array,t);var r=Mt.lenSquared(Kt);return Math.sqrt(r-e*e)}),intersectSphere:function(){var t=Mt.create();return function(e,r,i){var n=this.origin.array,a=this.direction.array;e=e.array,Mt.sub(t,e,n);var o=Mt.dot(t,a),s=Mt.squaredLength(t)-o*o,l=r*r;if(!(s>l)){var h=Math.sqrt(l-s),u=o-h,c=o+h;return i||(i=new Qt),u<0?c<0?null:(Mt.scaleAndAdd(i.array,n,a,c),i):(Mt.scaleAndAdd(i.array,n,a,u),i)}}}(),intersectBoundingBox:function(t,e){var r,i,n,a,o,s,l=this.direction.array,h=this.origin.array,u=t.min.array,c=t.max.array,d=1/l[0],f=1/l[1],p=1/l[2];if(d>=0?(r=(u[0]-h[0])*d,i=(c[0]-h[0])*d):(i=(u[0]-h[0])*d,r=(c[0]-h[0])*d),f>=0?(n=(u[1]-h[1])*f,a=(c[1]-h[1])*f):(a=(u[1]-h[1])*f,n=(c[1]-h[1])*f),r>a||n>i)return null;if((n>r||r!=r)&&(r=n),(a<i||i!=i)&&(i=a),p>=0?(o=(u[2]-h[2])*p,s=(c[2]-h[2])*p):(s=(u[2]-h[2])*p,o=(c[2]-h[2])*p),r>s||o>i)return null;if((o>r||r!=r)&&(r=o),(s<i||i!=i)&&(i=s),i<0)return null;var m=r>=0?r:i;return e||(e=new Qt),Mt.scaleAndAdd(e.array,h,l,m),e},intersectTriangle:(jt=Mt.create(),qt=Mt.create(),Zt=Mt.create(),Yt=Mt.create(),function(t,e,r,i,n,a){var o=this.direction.array,s=this.origin.array;t=t.array,e=e.array,r=r.array,Mt.sub(jt,e,t),Mt.sub(qt,r,t),Mt.cross(Yt,qt,o);var l=Mt.dot(jt,Yt);if(i){if(l>-1e-5)return null}else if(l>-1e-5&&l<1e-5)return null;Mt.sub(Zt,s,t);var h=Mt.dot(Yt,Zt)/l;if(h<0||h>1)return null;Mt.cross(Yt,jt,Zt);var u=Mt.dot(o,Yt)/l;if(u<0||u>1||h+u>1)return null;Mt.cross(Yt,jt,qt);var c=-Mt.dot(Zt,Yt)/l;return c<0?null:(n||(n=new Qt),a&&Qt.set(a,1-h-u,h,u),Mt.scaleAndAdd(n.array,s,o,c),n)}),applyTransform:function(t){Qt.add(this.direction,this.direction,this.origin),Qt.transformMat4(this.origin,this.origin,t),Qt.transformMat4(this.direction,this.direction,t),Qt.sub(this.direction,this.direction,this.origin),Qt.normalize(this.direction,this.direction)},copy:function(t){Qt.copy(this.origin,t.origin),Qt.copy(this.direction,t.direction)},clone:function(){var t=new Jt;return t.copy(this),t}};var $t=Jt,te={create:function(){var t=new H(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},clone:function(t){var e=new H(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},fromValues:function(t,e,r,i){var n=new H(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=i,n},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},set:function(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},subtract:function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}};te.sub=te.subtract,te.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},te.mul=te.multiply,te.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t},te.div=te.divide,te.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},te.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t},te.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},te.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t},te.distance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+i*i+n*n+a*a)},te.dist=te.distance,te.squaredDistance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2],a=e[3]-t[3];return r*r+i*i+n*n+a*a},te.sqrDist=te.squaredDistance,te.length=function(t){var e=t[0],r=t[1],i=t[2],n=t[3];return Math.sqrt(e*e+r*r+i*i+n*n)},te.len=te.length,te.squaredLength=function(t){var e=t[0],r=t[1],i=t[2],n=t[3];return e*e+r*r+i*i+n*n},te.sqrLen=te.squaredLength,te.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},te.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},te.normalize=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r*r+i*i+n*n+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t[3]=e[3]*o),t},te.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},te.lerp=function(t,e,r,i){var n=e[0],a=e[1],o=e[2],s=e[3];return t[0]=n+i*(r[0]-n),t[1]=a+i*(r[1]-a),t[2]=o+i*(r[2]-o),t[3]=s+i*(r[3]-s),t},te.random=function(t,e){return e=e||1,t[0]=V(),t[1]=V(),t[2]=V(),t[3]=V(),te.normalize(t,t),te.scale(t,t,e),t},te.transformMat4=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3];return t[0]=r[0]*i+r[4]*n+r[8]*a+r[12]*o,t[1]=r[1]*i+r[5]*n+r[9]*a+r[13]*o,t[2]=r[2]*i+r[6]*n+r[10]*a+r[14]*o,t[3]=r[3]*i+r[7]*n+r[11]*a+r[15]*o,t},te.transformQuat=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2],h=r[3],u=h*i+s*a-l*n,c=h*n+l*i-o*a,d=h*a+o*n-s*i,f=-o*i-s*n-l*a;return t[0]=u*h+f*-o+c*-l-d*-s,t[1]=c*h+f*-s+d*-o-u*-l,t[2]=d*h+f*-l+u*-s-c*-o,t},te.forEach=function(){var t=te.create();return function(e,r,i,n,a,o){var s,l;for(r||(r=4),i||(i=0),l=n?Math.min(n*r+i,e.length):e.length,s=i;s<l;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],t[3]=e[s+3],a(t,t,o),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2],e[s+3]=t[3];return e}}();var ee=te,re={create:function(){var t=new H(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fromMat4:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},clone:function(t){var e=new H(9);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},copy:function(t,e){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},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},transpose:function(t,e){if(t===e){var r=e[1],i=e[2],n=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=i,t[7]=n}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},invert:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=u*o-s*h,d=-u*a+s*l,f=h*a-o*l,p=r*c+i*d+n*f;return p?(p=1/p,t[0]=c*p,t[1]=(-u*i+n*h)*p,t[2]=(s*i-n*o)*p,t[3]=d*p,t[4]=(u*r-n*l)*p,t[5]=(-s*r+n*a)*p,t[6]=f*p,t[7]=(-h*r+i*l)*p,t[8]=(o*r-i*a)*p,t):null},adjoint:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8];return t[0]=o*u-s*h,t[1]=n*h-i*u,t[2]=i*s-n*o,t[3]=s*l-a*u,t[4]=r*u-n*l,t[5]=n*a-r*s,t[6]=a*h-o*l,t[7]=i*l-r*h,t[8]=r*o-i*a,t},determinant:function(t){var e=t[0],r=t[1],i=t[2],n=t[3],a=t[4],o=t[5],s=t[6],l=t[7],h=t[8];return e*(h*a-o*l)+r*(-h*n+o*s)+i*(l*n-a*s)},multiply:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=r[0],f=r[1],p=r[2],m=r[3],g=r[4],_=r[5],v=r[6],y=r[7],x=r[8];return t[0]=d*i+f*o+p*h,t[1]=d*n+f*s+p*u,t[2]=d*a+f*l+p*c,t[3]=m*i+g*o+_*h,t[4]=m*n+g*s+_*u,t[5]=m*a+g*l+_*c,t[6]=v*i+y*o+x*h,t[7]=v*n+y*s+x*u,t[8]=v*a+y*l+x*c,t}};re.mul=re.multiply,re.translate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=r[0],f=r[1];return t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=d*i+f*o+h,t[7]=d*n+f*s+u,t[8]=d*a+f*l+c,t},re.rotate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=Math.sin(r),f=Math.cos(r);return t[0]=f*i+d*o,t[1]=f*n+d*s,t[2]=f*a+d*l,t[3]=f*o-d*i,t[4]=f*s-d*n,t[5]=f*l-d*a,t[6]=h,t[7]=u,t[8]=c,t},re.scale=function(t,e,r){var i=r[0],n=r[1];return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=n*e[3],t[4]=n*e[4],t[5]=n*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},re.fromMat2d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},re.fromQuat=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r+r,s=i+i,l=n+n,h=r*o,u=i*o,c=i*s,d=n*o,f=n*s,p=n*l,m=a*o,g=a*s,_=a*l;return t[0]=1-c-p,t[3]=u-_,t[6]=d+g,t[1]=u+_,t[4]=1-h-p,t[7]=f-m,t[2]=d-g,t[5]=f+m,t[8]=1-h-c,t},re.normalFromMat4=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],_=e[15],v=r*s-i*o,y=r*l-n*o,x=r*h-a*o,T=i*l-n*s,b=i*h-a*s,w=n*h-a*l,S=u*m-c*p,E=u*g-d*p,A=u*_-f*p,M=c*g-d*m,C=c*_-f*m,D=d*_-f*g,L=v*D-y*C+x*M+T*A-b*E+w*S;return L?(L=1/L,t[0]=(s*D-l*C+h*M)*L,t[1]=(l*A-o*D-h*E)*L,t[2]=(o*C-s*A+h*S)*L,t[3]=(n*C-i*D-a*M)*L,t[4]=(r*D-n*A+a*E)*L,t[5]=(i*A-r*C-a*S)*L,t[6]=(m*w-g*b+_*T)*L,t[7]=(g*x-p*w-_*y)*L,t[8]=(p*b-m*x+_*v)*L,t):null},re.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2))};var ie,ne,ae,oe,se=re,le={};le.create=function(){var t=new H(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},le.rotationTo=(ie=Mt.create(),ne=Mt.fromValues(1,0,0),ae=Mt.fromValues(0,1,0),function(t,e,r){var i=Mt.dot(e,r);return i<-.999999?(Mt.cross(ie,ne,e),Mt.length(ie)<1e-6&&Mt.cross(ie,ae,e),Mt.normalize(ie,ie),le.setAxisAngle(t,ie,Math.PI),t):i>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(Mt.cross(ie,e,r),t[0]=ie[0],t[1]=ie[1],t[2]=ie[2],t[3]=1+i,le.normalize(t,t))}),le.setAxes=(oe=se.create(),function(t,e,r,i){return oe[0]=r[0],oe[3]=r[1],oe[6]=r[2],oe[1]=i[0],oe[4]=i[1],oe[7]=i[2],oe[2]=-e[0],oe[5]=-e[1],oe[8]=-e[2],le.normalize(t,le.fromMat3(t,oe))}),le.clone=ee.clone,le.fromValues=ee.fromValues,le.copy=ee.copy,le.set=ee.set,le.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},le.setAxisAngle=function(t,e,r){r*=.5;var i=Math.sin(r);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(r),t},le.add=ee.add,le.multiply=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1],h=r[2],u=r[3];return t[0]=i*u+o*s+n*h-a*l,t[1]=n*u+o*l+a*s-i*h,t[2]=a*u+o*h+i*l-n*s,t[3]=o*u-i*s-n*l-a*h,t},le.mul=le.multiply,le.scale=ee.scale,le.rotateX=function(t,e,r){r*=.5;var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l+o*s,t[1]=n*l+a*s,t[2]=a*l-n*s,t[3]=o*l-i*s,t},le.rotateY=function(t,e,r){r*=.5;var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l-a*s,t[1]=n*l+o*s,t[2]=a*l+i*s,t[3]=o*l-n*s,t},le.rotateZ=function(t,e,r){r*=.5;var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l+n*s,t[1]=n*l-i*s,t[2]=a*l+o*s,t[3]=o*l-a*s,t},le.calculateW=function(t,e){var r=e[0],i=e[1],n=e[2];return t[0]=r,t[1]=i,t[2]=n,t[3]=Math.sqrt(Math.abs(1-r*r-i*i-n*n)),t},le.dot=ee.dot,le.lerp=ee.lerp,le.slerp=function(t,e,r,i){var n,a,o,s,l,h=e[0],u=e[1],c=e[2],d=e[3],f=r[0],p=r[1],m=r[2],g=r[3];return(a=h*f+u*p+c*m+d*g)<0&&(a=-a,f=-f,p=-p,m=-m,g=-g),1-a>1e-6?(n=Math.acos(a),o=Math.sin(n),s=Math.sin((1-i)*n)/o,l=Math.sin(i*n)/o):(s=1-i,l=i),t[0]=s*h+l*f,t[1]=s*u+l*p,t[2]=s*c+l*m,t[3]=s*d+l*g,t},le.invert=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r*r+i*i+n*n+a*a,s=o?1/o:0;return t[0]=-r*s,t[1]=-i*s,t[2]=-n*s,t[3]=a*s,t},le.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},le.length=ee.length,le.len=le.length,le.squaredLength=ee.squaredLength,le.sqrLen=le.squaredLength,le.normalize=ee.normalize,le.fromMat3=function(t,e){var r,i=e[0]+e[4]+e[8];if(i>0)r=Math.sqrt(i+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var n=0;e[4]>e[0]&&(n=1),e[8]>e[3*n+n]&&(n=2);var a=(n+1)%3,o=(n+2)%3;r=Math.sqrt(e[3*n+n]-e[3*a+a]-e[3*o+o]+1),t[n]=.5*r,r=.5/r,t[3]=(e[3*a+o]-e[3*o+a])*r,t[a]=(e[3*a+n]+e[3*n+a])*r,t[o]=(e[3*o+n]+e[3*n+o])*r}return t};var he,ue,ce,de,fe=le,pe=function(){this._axisX=new Qt,this._axisY=new Qt,this._axisZ=new Qt,this.array=Et.create(),this._dirty=!0};pe.prototype={constructor:pe,setArray:function(t){for(var e=0;e<this.array.length;e++)this.array[e]=t[e];return this._dirty=!0,this},adjoint:function(){return Et.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new pe).copy(this)},copy:function(t){return Et.copy(this.array,t.array),this._dirty=!0,this},determinant:function(){return Et.determinant(this.array)},fromQuat:function(t){return Et.fromQuat(this.array,t.array),this._dirty=!0,this},fromRotationTranslation:function(t,e){return Et.fromRotationTranslation(this.array,t.array,e.array),this._dirty=!0,this},fromMat2d:function(t){return pe.fromMat2d(this,t),this},frustum:function(t,e,r,i,n,a){return Et.frustum(this.array,t,e,r,i,n,a),this._dirty=!0,this},identity:function(){return Et.identity(this.array),this._dirty=!0,this},invert:function(){return Et.invert(this.array,this.array),this._dirty=!0,this},lookAt:function(t,e,r){return Et.lookAt(this.array,t.array,e.array,r.array),this._dirty=!0,this},mul:function(t){return Et.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return Et.mul(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return Et.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return Et.multiply(this.array,t.array,this.array),this._dirty=!0,this},ortho:function(t,e,r,i,n,a){return Et.ortho(this.array,t,e,r,i,n,a),this._dirty=!0,this},perspective:function(t,e,r,i){return Et.perspective(this.array,t,e,r,i),this._dirty=!0,this},rotate:function(t,e){return Et.rotate(this.array,this.array,t,e.array),this._dirty=!0,this},rotateX:function(t){return Et.rotateX(this.array,this.array,t),this._dirty=!0,this},rotateY:function(t){return Et.rotateY(this.array,this.array,t),this._dirty=!0,this},rotateZ:function(t){return Et.rotateZ(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return Et.scale(this.array,this.array,t.array),this._dirty=!0,this},translate:function(t){return Et.translate(this.array,this.array,t.array),this._dirty=!0,this},transpose:function(){return Et.transpose(this.array,this.array),this._dirty=!0,this},decomposeMatrix:(he=Mt.create(),ue=Mt.create(),ce=Mt.create(),de=se.create(),function(t,e,r){var i=this.array;Mt.set(he,i[0],i[1],i[2]),Mt.set(ue,i[4],i[5],i[6]),Mt.set(ce,i[8],i[9],i[10]);var n=Mt.length(he),a=Mt.length(ue),o=Mt.length(ce);this.determinant()<0&&(n=-n),t&&t.set(n,a,o),r.set(i[12],i[13],i[14]),se.fromMat4(de,i),de[0]/=n,de[1]/=n,de[2]/=n,de[3]/=a,de[4]/=a,de[5]/=a,de[6]/=o,de[7]/=o,de[8]/=o,fe.fromMat3(e.array,de),fe.normalize(e.array,e.array),e._dirty=!0,r._dirty=!0}),toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var me=Object.defineProperty;if(me){var ge=pe.prototype;me(ge,"z",{get:function(){var t=this.array;return this._axisZ.set(t[8],t[9],t[10]),this._axisZ},set:function(t){var e=this.array;t=t.array,e[8]=t[0],e[9]=t[1],e[10]=t[2],this._dirty=!0}}),me(ge,"y",{get:function(){var t=this.array;return this._axisY.set(t[4],t[5],t[6]),this._axisY},set:function(t){var e=this.array;t=t.array,e[4]=t[0],e[5]=t[1],e[6]=t[2],this._dirty=!0}}),me(ge,"x",{get:function(){var t=this.array;return this._axisX.set(t[0],t[1],t[2]),this._axisX},set:function(t){var e=this.array;t=t.array,e[0]=t[0],e[1]=t[1],e[2]=t[2],this._dirty=!0}})}pe.adjoint=function(t,e){return Et.adjoint(t.array,e.array),t._dirty=!0,t},pe.copy=function(t,e){return Et.copy(t.array,e.array),t._dirty=!0,t},pe.determinant=function(t){return Et.determinant(t.array)},pe.identity=function(t){return Et.identity(t.array),t._dirty=!0,t},pe.ortho=function(t,e,r,i,n,a,o){return Et.ortho(t.array,e,r,i,n,a,o),t._dirty=!0,t},pe.perspective=function(t,e,r,i,n){return Et.perspective(t.array,e,r,i,n),t._dirty=!0,t},pe.lookAt=function(t,e,r,i){return Et.lookAt(t.array,e.array,r.array,i.array),t._dirty=!0,t},pe.invert=function(t,e){return Et.invert(t.array,e.array),t._dirty=!0,t},pe.multiply=pe.mul=function(t,e,r){return Et.mul(t.array,e.array,r.array),t._dirty=!0,t},pe.fromQuat=function(t,e){return Et.fromQuat(t.array,e.array),t._dirty=!0,t},pe.fromRotationTranslation=function(t,e,r){return Et.fromRotationTranslation(t.array,e.array,r.array),t._dirty=!0,t},pe.fromMat2d=function(t,e){t._dirty=!0;e=e.array;return(t=t.array)[0]=e[0],t[4]=e[2],t[12]=e[4],t[1]=e[1],t[5]=e[3],t[13]=e[5],t},pe.rotate=function(t,e,r,i){return Et.rotate(t.array,e.array,r,i.array),t._dirty=!0,t},pe.rotateX=function(t,e,r){return Et.rotateX(t.array,e.array,r),t._dirty=!0,t},pe.rotateY=function(t,e,r){return Et.rotateY(t.array,e.array,r),t._dirty=!0,t},pe.rotateZ=function(t,e,r){return Et.rotateZ(t.array,e.array,r),t._dirty=!0,t},pe.scale=function(t,e,r){return Et.scale(t.array,e.array,r.array),t._dirty=!0,t},pe.transpose=function(t,e){return Et.transpose(t.array,e.array),t._dirty=!0,t},pe.translate=function(t,e,r){return Et.translate(t.array,e.array,r.array),t._dirty=!0,t};var _e=pe,ve=function(t,e,r,i){t=t||0,e=e||0,r=r||0,i=void 0===i?1:i,this.array=fe.fromValues(t,e,r,i),this._dirty=!0};ve.prototype={constructor:ve,add:function(t){return fe.add(this.array,this.array,t.array),this._dirty=!0,this},calculateW:function(){return fe.calculateW(this.array,this.array),this._dirty=!0,this},set:function(t,e,r,i){return this.array[0]=t,this.array[1]=e,this.array[2]=r,this.array[3]=i,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this.array[2]=t[2],this.array[3]=t[3],this._dirty=!0,this},clone:function(){return new ve(this.x,this.y,this.z,this.w)},conjugate:function(){return fe.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(t){return fe.copy(this.array,t.array),this._dirty=!0,this},dot:function(t){return fe.dot(this.array,t.array)},fromMat3:function(t){return fe.fromMat3(this.array,t.array),this._dirty=!0,this},fromMat4:function(){var t=se.create();return function(e){return se.fromMat4(t,e.array),se.transpose(t,t),fe.fromMat3(this.array,t),this._dirty=!0,this}}(),identity:function(){return fe.identity(this.array),this._dirty=!0,this},invert:function(){return fe.invert(this.array,this.array),this._dirty=!0,this},len:function(){return fe.len(this.array)},length:function(){return fe.length(this.array)},lerp:function(t,e,r){return fe.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},mul:function(t){return fe.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return fe.multiply(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return fe.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return fe.multiply(this.array,t.array,this.array),this._dirty=!0,this},normalize:function(){return fe.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(t){return fe.rotateX(this.array,this.array,t),this._dirty=!0,this},rotateY:function(t){return fe.rotateY(this.array,this.array,t),this._dirty=!0,this},rotateZ:function(t){return fe.rotateZ(this.array,this.array,t),this._dirty=!0,this},rotationTo:function(t,e){return fe.rotationTo(this.array,t.array,e.array),this._dirty=!0,this},setAxes:function(t,e,r){return fe.setAxes(this.array,t.array,e.array,r.array),this._dirty=!0,this},setAxisAngle:function(t,e){return fe.setAxisAngle(this.array,t.array,e),this._dirty=!0,this},slerp:function(t,e,r){return fe.slerp(this.array,t.array,e.array,r),this._dirty=!0,this},sqrLen:function(){return fe.sqrLen(this.array)},squaredLength:function(){return fe.squaredLength(this.array)},fromEuler:function(t,e){return ve.fromEuler(this,t,e)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var ye=Object.defineProperty;if(ye){var xe=ve.prototype;ye(xe,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),ye(xe,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}}),ye(xe,"z",{get:function(){return this.array[2]},set:function(t){this.array[2]=t,this._dirty=!0}}),ye(xe,"w",{get:function(){return this.array[3]},set:function(t){this.array[3]=t,this._dirty=!0}})}ve.add=function(t,e,r){return fe.add(t.array,e.array,r.array),t._dirty=!0,t},ve.set=function(t,e,r,i,n){fe.set(t.array,e,r,i,n),t._dirty=!0},ve.copy=function(t,e){return fe.copy(t.array,e.array),t._dirty=!0,t},ve.calculateW=function(t,e){return fe.calculateW(t.array,e.array),t._dirty=!0,t},ve.conjugate=function(t,e){return fe.conjugate(t.array,e.array),t._dirty=!0,t},ve.identity=function(t){return fe.identity(t.array),t._dirty=!0,t},ve.invert=function(t,e){return fe.invert(t.array,e.array),t._dirty=!0,t},ve.dot=function(t,e){return fe.dot(t.array,e.array)},ve.len=function(t){return fe.length(t.array)},ve.lerp=function(t,e,r,i){return fe.lerp(t.array,e.array,r.array,i),t._dirty=!0,t},ve.slerp=function(t,e,r,i){return fe.slerp(t.array,e.array,r.array,i),t._dirty=!0,t},ve.multiply=ve.mul=function(t,e,r){return fe.multiply(t.array,e.array,r.array),t._dirty=!0,t},ve.rotateX=function(t,e,r){return fe.rotateX(t.array,e.array,r),t._dirty=!0,t},ve.rotateY=function(t,e,r){return fe.rotateY(t.array,e.array,r),t._dirty=!0,t},ve.rotateZ=function(t,e,r){return fe.rotateZ(t.array,e.array,r),t._dirty=!0,t},ve.setAxisAngle=function(t,e,r){return fe.setAxisAngle(t.array,e.array,r),t._dirty=!0,t},ve.normalize=function(t,e){return fe.normalize(t.array,e.array),t._dirty=!0,t},ve.squaredLength=ve.sqrLen=function(t){return fe.sqrLen(t.array)},ve.fromMat3=function(t,e){return fe.fromMat3(t.array,e.array),t._dirty=!0,t},ve.setAxes=function(t,e,r,i){return fe.setAxes(t.array,e.array,r.array,i.array),t._dirty=!0,t},ve.rotationTo=function(t,e,r){return fe.rotationTo(t.array,e.array,r.array),t._dirty=!0,t},ve.fromEuler=function(t,e,r){t._dirty=!0,e=e.array;var i=t.array,n=Math.cos(e[0]/2),a=Math.cos(e[1]/2),o=Math.cos(e[2]/2),s=Math.sin(e[0]/2),l=Math.sin(e[1]/2),h=Math.sin(e[2]/2);switch(r=(r||"XYZ").toUpperCase()){case"XYZ":i[0]=s*a*o+n*l*h,i[1]=n*l*o-s*a*h,i[2]=n*a*h+s*l*o,i[3]=n*a*o-s*l*h;break;case"YXZ":i[0]=s*a*o+n*l*h,i[1]=n*l*o-s*a*h,i[2]=n*a*h-s*l*o,i[3]=n*a*o+s*l*h;break;case"ZXY":i[0]=s*a*o-n*l*h,i[1]=n*l*o+s*a*h,i[2]=n*a*h+s*l*o,i[3]=n*a*o-s*l*h;break;case"ZYX":i[0]=s*a*o-n*l*h,i[1]=n*l*o+s*a*h,i[2]=n*a*h-s*l*o,i[3]=n*a*o+s*l*h;break;case"YZX":i[0]=s*a*o+n*l*h,i[1]=n*l*o+s*a*h,i[2]=n*a*h-s*l*o,i[3]=n*a*o-s*l*h;break;case"XZY":i[0]=s*a*o-n*l*h,i[1]=n*l*o-s*a*h,i[2]=n*a*h+s*l*o,i[3]=n*a*o+s*l*h}};var Te,be,we,Se,Ee,Ae,Me=ve,Ce=Mt.set,De=Mt.copy,Le=function(t,e){this.min=t||new Qt(1/0,1/0,1/0),this.max=e||new Qt(-1/0,-1/0,-1/0),this.vertices=null};Le.prototype={constructor:Le,updateFromVertices:function(t){if(t.length>0){var e=this.min,r=this.max,i=e.array,n=r.array;De(i,t[0]),De(n,t[0]);for(var a=1;a<t.length;a++){var o=t[a];o[0]<i[0]&&(i[0]=o[0]),o[1]<i[1]&&(i[1]=o[1]),o[2]<i[2]&&(i[2]=o[2]),o[0]>n[0]&&(n[0]=o[0]),o[1]>n[1]&&(n[1]=o[1]),o[2]>n[2]&&(n[2]=o[2])}e._dirty=!0,r._dirty=!0}},union:function(t){var e=this.min,r=this.max;return Mt.min(e.array,e.array,t.min.array),Mt.max(r.array,r.array,t.max.array),e._dirty=!0,r._dirty=!0,this},intersection:function(t){var e=this.min,r=this.max;return Mt.max(e.array,e.array,t.min.array),Mt.min(r.array,r.array,t.max.array),e._dirty=!0,r._dirty=!0,this},intersectBoundingBox:function(t){var e=this.min.array,r=this.max.array,i=t.min.array,n=t.max.array;return!(e[0]>n[0]||e[1]>n[1]||e[2]>n[2]||r[0]<i[0]||r[1]<i[1]||r[2]<i[2])},containBoundingBox:function(t){var e=this.min.array,r=this.max.array,i=t.min.array,n=t.max.array;return e[0]<=i[0]&&e[1]<=i[1]&&e[2]<=i[2]&&r[0]>=n[0]&&r[1]>=n[1]&&r[2]>=n[2]},containPoint:function(t){var e=this.min.array,r=this.max.array,i=t.array;return e[0]<=i[0]&&e[1]<=i[1]&&e[2]<=i[2]&&r[0]>=i[0]&&r[1]>=i[1]&&r[2]>=i[2]},isFinite:function(){var t=this.min.array,e=this.max.array;return isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])&&isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])},applyTransform:function(t){this.transformFrom(this,t)},transformFrom:(Te=Mt.create(),be=Mt.create(),we=Mt.create(),Se=Mt.create(),Ee=Mt.create(),Ae=Mt.create(),function(t,e){var r=t.min.array,i=t.max.array,n=e.array;return Te[0]=n[0]*r[0],Te[1]=n[1]*r[0],Te[2]=n[2]*r[0],be[0]=n[0]*i[0],be[1]=n[1]*i[0],be[2]=n[2]*i[0],we[0]=n[4]*r[1],we[1]=n[5]*r[1],we[2]=n[6]*r[1],Se[0]=n[4]*i[1],Se[1]=n[5]*i[1],Se[2]=n[6]*i[1],Ee[0]=n[8]*r[2],Ee[1]=n[9]*r[2],Ee[2]=n[10]*r[2],Ae[0]=n[8]*i[2],Ae[1]=n[9]*i[2],Ae[2]=n[10]*i[2],r=this.min.array,i=this.max.array,r[0]=Math.min(Te[0],be[0])+Math.min(we[0],Se[0])+Math.min(Ee[0],Ae[0])+n[12],r[1]=Math.min(Te[1],be[1])+Math.min(we[1],Se[1])+Math.min(Ee[1],Ae[1])+n[13],r[2]=Math.min(Te[2],be[2])+Math.min(we[2],Se[2])+Math.min(Ee[2],Ae[2])+n[14],i[0]=Math.max(Te[0],be[0])+Math.max(we[0],Se[0])+Math.max(Ee[0],Ae[0])+n[12],i[1]=Math.max(Te[1],be[1])+Math.max(we[1],Se[1])+Math.max(Ee[1],Ae[1])+n[13],i[2]=Math.max(Te[2],be[2])+Math.max(we[2],Se[2])+Math.max(Ee[2],Ae[2])+n[14],this.min._dirty=!0,this.max._dirty=!0,this}),applyProjection:function(t){var e=this.min.array,r=this.max.array,i=t.array,n=e[0],a=e[1],o=e[2],s=r[0],l=r[1],h=e[2],u=r[0],c=r[1],d=r[2];if(1===i[15])e[0]=i[0]*n+i[12],e[1]=i[5]*a+i[13],r[2]=i[10]*o+i[14],r[0]=i[0]*u+i[12],r[1]=i[5]*c+i[13],e[2]=i[10]*d+i[14];else{var f=-1/o;e[0]=i[0]*n*f,e[1]=i[5]*a*f,r[2]=(i[10]*o+i[14])*f,f=-1/h,r[0]=i[0]*s*f,r[1]=i[5]*l*f,f=-1/d,e[2]=(i[10]*d+i[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var t=this.vertices;if(!t){t=[];for(var e=0;e<8;e++)t[e]=Mt.fromValues(0,0,0);this.vertices=t}var r=this.min.array,i=this.max.array;return Ce(t[0],r[0],r[1],r[2]),Ce(t[1],r[0],i[1],r[2]),Ce(t[2],i[0],r[1],r[2]),Ce(t[3],i[0],i[1],r[2]),Ce(t[4],r[0],r[1],i[2]),Ce(t[5],r[0],i[1],i[2]),Ce(t[6],i[0],r[1],i[2]),Ce(t[7],i[0],i[1],i[2]),this},copy:function(t){var e=this.min,r=this.max;return De(e.array,t.min.array),De(r.array,t.max.array),e._dirty=!0,r._dirty=!0,this},clone:function(){var t=new Le;return t.copy(this),t}};var Pe,Ne,Re,Ie=Le,Oe=0,Be=f.extend({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=(this.type||"NODE")+"_"+Oe++),this.position||(this.position=new Qt),this.rotation||(this.rotation=new Me),this.scale||(this.scale=new Qt(1,1,1)),this.worldTransform=new _e,this.localTransform=new _e,this._children=[]},{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(t){var e=this._scene;if(e){var r=e._nodeRepository;delete r[this.name],r[t]=this}this.name=t},add:function(t){var e=t._parent;if(e!==this){e&&e.remove(t),t._parent=this,this._children.push(t);var r=this._scene;r&&r!==t.scene&&t.traverse(this._addSelfToScene,this),t._needsUpdateWorldTransform=!0}},remove:function(t){var e=this._children,r=e.indexOf(t);r<0||(e.splice(r,1),t._parent=null,this._scene&&t.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var t=this._children,e=0;e<t.length;e++)t[e]._parent=null,this._scene&&t[e].traverse(this._removeSelfFromScene,this);this._children=[]},getScene:function(){return this._scene},getParent:function(){return this._parent},_removeSelfFromScene:function(t){t._scene.removeFromScene(t),t._scene=null},_addSelfToScene:function(t){this._scene.addToScene(t),t._scene=this._scene},isAncestor:function(t){for(var e=t._parent;e;){if(e===this)return!0;e=e._parent}return!1},children:function(){return this._children.slice()},childAt:function(t){return this._children[t]},getChildByName:function(t){for(var e=this._children,r=0;r<e.length;r++)if(e[r].name===t)return e[r]},getDescendantByName:function(t){for(var e=this._children,r=0;r<e.length;r++){var i=e[r];if(i.name===t)return i;var n=i.getDescendantByName(t);if(n)return n}},queryNode:function(t){if(t){for(var e=t.split("/"),r=this,i=0;i<e.length;i++){var n=e[i];if(n){for(var a=!1,o=r._children,s=0;s<o.length;s++){var l=o[s];if(l.name===n){r=l,a=!0;break}}if(!a)return}}return r}},getPath:function(t){if(!this._parent)return"/";for(var e=this._parent,r=this.name;e._parent&&(r=e.name+"/"+r,e._parent!=t);)e=e._parent;return!e._parent&&t?null:r},traverse:function(t,e){t.call(e,this);for(var r=this._children,i=0,n=r.length;i<n;i++)r[i].traverse(t,e)},eachChild:function(t,e){for(var r=this._children,i=0,n=r.length;i<n;i++){var a=r[i];t.call(e,a,i)}},setLocalTransform:function(t){Et.copy(this.localTransform.array,t.array),this.decomposeLocalTransform()},decomposeLocalTransform:function(t){var e=t?null:this.scale;this.localTransform.decomposeMatrix(e,this.rotation,this.position)},setWorldTransform:function(t){Et.copy(this.worldTransform.array,t.array),this.decomposeWorldTransform()},decomposeWorldTransform:(Ne=Et.create(),function(t){var e=this.localTransform,r=this.worldTransform;this._parent?(Et.invert(Ne,this._parent.worldTransform.array),Et.multiply(e.array,Ne,r.array)):Et.copy(e.array,r.array);var i=t?null:this.scale;e.decomposeMatrix(i,this.rotation,this.position)}),transformNeedsUpdate:function(){return this.position._dirty||this.rotation._dirty||this.scale._dirty},updateLocalTransform:function(){var t=this.position,e=this.rotation,r=this.scale;if(this.transformNeedsUpdate()){var i=this.localTransform.array;Et.fromRotationTranslation(i,e.array,t.array),Et.scale(i,i,r.array),e._dirty=!1,r._dirty=!1,t._dirty=!1,this._needsUpdateWorldTransform=!0}},_updateWorldTransformTopDown:function(){var t=this.localTransform.array,e=this.worldTransform.array;this._parent?Et.multiplyAffine(e,this._parent.worldTransform.array,t):Et.copy(e,t)},updateWorldTransform:function(){for(var t=this;t&&t.getParent()&&t.getParent().transformNeedsUpdate();)t=t.getParent();t.update()},update:function(t){this.autoUpdateLocalTransform?this.updateLocalTransform():t=!0,(t||this._needsUpdateWorldTransform)&&(this._updateWorldTransformTopDown(),t=!0,this._needsUpdateWorldTransform=!1);for(var e=this._children,r=0,i=e.length;r<i;r++)e[r].update(t)},getBoundingBox:function(){function t(t){return!t.invisible&&t.geometry}var e=new Ie,r=new _e,i=new _e;return function(n,a){return a=a||new Ie,n=n||t,this._parent?_e.invert(i,this._parent.worldTransform):_e.identity(i),this.traverse(function(t){t.geometry&&t.geometry.boundingBox&&(e.copy(t.geometry.boundingBox),_e.multiply(r,i,t.worldTransform),e.applyTransform(r),a.union(e))},this,t),a}}(),getWorldPosition:function(t){this.transformNeedsUpdate()&&this.updateWorldTransform();var e=this.worldTransform.array;if(t){var r=t.array;return r[0]=e[12],r[1]=e[13],r[2]=e[14],t}return new Qt(e[12],e[13],e[14])},clone:function(){var t=new this.constructor,e=this._children;t.setName(this.name),t.position.copy(this.position),t.rotation.copy(this.rotation),t.scale.copy(this.scale);for(var r=0;r<e.length;r++)t.add(e[r].clone());return t},rotateAround:function(){var t=new Qt,e=new _e;return function(r,i,n){t.copy(this.position).subtract(r);var a=this.localTransform;a.identity(),a.translate(r),a.rotate(n,i),e.fromRotationTranslation(this.rotation,t),a.multiply(e),a.scale(this.scale),this.decomposeLocalTransform(),this._needsUpdateWorldTransform=!0}}(),lookAt:(Pe=new _e,function(t,e){Pe.lookAt(this.position,t,e||this.localTransform.y).invert(),this.setLocalTransform(Pe),this.target=t})}),Fe=Be.extend({material:null,geometry:null,mode:_.TRIANGLES,_renderInfo:null},{__program:null,lightGroup:0,renderOrder:0,culling:!0,cullFace:_.BACK,frontFace:_.CCW,frustumCulling:!0,receiveShadow:!0,castShadow:!0,ignorePicking:!1,ignorePreZ:!1,ignoreGBuffer:!1,isRenderable:function(){return this.geometry&&this.material&&this.material.shader&&!this.invisible&&this.geometry.vertexCount>0},beforeRender:function(t){},afterRender:function(t,e){},getBoundingBox:function(t,e){return e=Be.prototype.getBoundingBox.call(this,t,e),this.geometry&&this.geometry.boundingBox&&e.union(this.geometry.boundingBox),e},clone:(Re=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"],function(){var t=Be.prototype.clone.call(this);t.geometry=this.geometry,t.material=this.material;for(var e=0;e<Re.length;e++){var r=Re[e];t[r]!==this[r]&&(t[r]=this[r])}return t})});Fe.POINTS=_.POINTS,Fe.LINES=_.LINES,Fe.LINE_LOOP=_.LINE_LOOP,Fe.LINE_STRIP=_.LINE_STRIP,Fe.TRIANGLES=_.TRIANGLES,Fe.TRIANGLE_STRIP=_.TRIANGLE_STRIP,Fe.TRIANGLE_FAN=_.TRIANGLE_FAN,Fe.BACK=_.BACK,Fe.FRONT=_.FRONT,Fe.FRONT_AND_BACK=_.FRONT_AND_BACK,Fe.CW=_.CW,Fe.CCW=_.CCW;var ze,Ue,ke,Ge,He,Ve=Fe,We=f.extend({scene:null,camera:null,renderer:null},function(){this._ray=new $t,this._ndc=new Z},{pick:function(t,e,r){return this.pickAll(t,e,[],r)[0]||null},pickAll:function(t,e,r,i){return this.renderer.screenToNDC(t,e,this._ndc),this.camera.castRay(this._ndc,this._ray),r=r||[],this._intersectNode(this.scene,r,i||!1),r.sort(this._intersectionCompareFunc),r},_intersectNode:function(t,e,r){t instanceof Ve&&t.isRenderable()&&(t.ignorePicking&&!r||!(t.mode===_.TRIANGLES&&t.geometry.isUseIndices()||t.geometry.pickByRay||t.geometry.pick)||this._intersectRenderable(t,e));for(var i=0;i<t._children.length;i++)this._intersectNode(t._children[i],e,r)},_intersectRenderable:(ze=new Qt,Ue=new Qt,ke=new Qt,Ge=new $t,He=new _e,function(t,e){var r=t.isSkinnedMesh();Ge.copy(this._ray),_e.invert(He,t.worldTransform),r||Ge.applyTransform(He);var i=t.geometry,n=r?t.skeleton.boundingBox:i.boundingBox;if(!n||Ge.intersectBoundingBox(n))if(i.pick)i.pick(this._ndc.x,this._ndc.y,this.renderer,this.camera,t,e);else if(i.pickByRay)i.pickByRay(Ge,t,e);else{var a,o,s=t.cullFace===_.BACK&&t.frontFace===_.CCW||t.cullFace===_.FRONT&&t.frontFace===_.CW,l=i.indices,h=i.attributes.position,u=i.attributes.weight,c=i.attributes.joint,d=[];if(h&&h.value&&l){if(r){o=t.skeleton.getSubSkinMatrices(t.__uid__,t.joints);for(var f=0;f<t.joints.length;f++){d[f]=d[f]||[];for(var p=0;p<16;p++)d[f][p]=o[16*f+p]}var m=[],g=[],v=[],y=[],x=[],T=i.attributes.skinnedPosition;for(T&&T.value||(i.createAttribute("skinnedPosition","f",3),(T=i.attributes.skinnedPosition).init(i.vertexCount)),f=0;f<i.vertexCount;f++){for(h.get(f,m),u.get(f,g),c.get(f,v),g[3]=1-g[0]-g[1]-g[2],Mt.set(y,0,0,0),p=0;p<4;p++)v[p]>=0&&g[p]>1e-4&&(Mt.transformMat4(x,m,d[v[p]]),Mt.scaleAndAdd(y,y,x,g[p]));T.set(f,y)}}for(f=0;f<l.length;f+=3){var b=l[f],w=l[f+1],S=l[f+2],E=r?i.attributes.skinnedPosition:h;if(E.get(b,ze.array),E.get(w,Ue.array),E.get(S,ke.array),a=s?Ge.intersectTriangle(ze,Ue,ke,t.culling):Ge.intersectTriangle(ze,ke,Ue,t.culling)){var A=new Qt;r?Qt.copy(A,a):Qt.transformMat4(A,a,t.worldTransform),e.push(new We.Intersection(a,A,t,[b,w,S],f/3,Qt.dist(A,this._ray.origin)))}}}}}),_intersectionCompareFunc:function(t,e){return t.distance-e.distance}});We.Intersection=function(t,e,r,i,n,a){this.point=t,this.pointWorld=e,this.target=r,this.triangle=i,this.triangleIndex=n,this.distance=a};var Xe=We,je=function(){this._contextId=0,this._caches=[],this._context={}};(je.prototype={use:function(t,e){var r=this._caches;r[t]||(r[t]={},e&&(r[t]=e())),this._contextId=t,this._context=r[t]},put:function(t,e){this._context[t]=e},get:function(t){return this._context[t]},dirty:function(t){var e="__dt__"+(t=t||"");this.put(e,!0)},dirtyAll:function(t){for(var e="__dt__"+(t=t||""),r=this._caches,i=0;i<r.length;i++)r[i]&&(r[i][e]=!0)},fresh:function(t){var e="__dt__"+(t=t||"");this.put(e,!1)},freshAll:function(t){for(var e="__dt__"+(t=t||""),r=this._caches,i=0;i<r.length;i++)r[i]&&(r[i][e]=!1)},isDirty:function(t){var e="__dt__"+(t=t||""),r=this._context;return!r.hasOwnProperty(e)||!0===r[e]},deleteContext:function(t){delete this._caches[t],this._context={}},delete:function(t){delete this._context[t]},clearAll:function(){this._caches={}},getContext:function(){return this._context},eachContext:function(t,e){Object.keys(this._caches).forEach(function(r){t&&t.call(e,r)})},miss:function(t){return!this._context.hasOwnProperty(t)}}).constructor=je;var qe=je,Ze=f.extend({width:512,height:512,type:_.UNSIGNED_BYTE,format:_.RGBA,wrapS:_.REPEAT,wrapT:_.REPEAT,minFilter:_.LINEAR_MIPMAP_LINEAR,magFilter:_.LINEAR,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},function(){this._cache=new qe},{getWebGLTexture:function(t){var e=t.gl,r=this._cache;return r.use(t.__uid__),r.miss("webgl_texture")&&r.put("webgl_texture",e.createTexture()),this.dynamic?this.update(t):r.isDirty()&&(this.update(t),r.fresh()),r.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(t){},updateCommon:function(t){var e=t.gl;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.format===_.DEPTH_COMPONENT&&(this.useMipmap=!1);var r=t.getGLExtension("EXT_sRGB");this.format!==Ze.SRGB||r||(this.format=Ze.RGB),this.format!==Ze.SRGB_ALPHA||r||(this.format=Ze.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?_.CLAMP_TO_EDGE:this.wrapS},getAvailableWrapT:function(){return this.NPOT?_.CLAMP_TO_EDGE:this.wrapT},getAvailableMinFilter:function(){var t=this.minFilter;return this.NPOT||!this.useMipmap?t===_.NEAREST_MIPMAP_NEAREST||t===_.NEAREST_MIPMAP_LINEAR?_.NEAREST:t===_.LINEAR_MIPMAP_LINEAR||t===_.LINEAR_MIPMAP_NEAREST?_.LINEAR:t:t},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(t){--t;for(var e=1;e<32;e<<=1)t|=t>>e;return t+1},dispose:function(t){var e=this._cache;e.use(t.__uid__);var r=e.get("webgl_texture");r&&t.gl.deleteTexture(r),e.deleteContext(t.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(Ze.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(Ze.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),Ze.BYTE=_.BYTE,Ze.UNSIGNED_BYTE=_.UNSIGNED_BYTE,Ze.SHORT=_.SHORT,Ze.UNSIGNED_SHORT=_.UNSIGNED_SHORT,Ze.INT=_.INT,Ze.UNSIGNED_INT=_.UNSIGNED_INT,Ze.FLOAT=_.FLOAT,Ze.HALF_FLOAT=36193,Ze.UNSIGNED_INT_24_8_WEBGL=34042,Ze.DEPTH_COMPONENT=_.DEPTH_COMPONENT,Ze.DEPTH_STENCIL=_.DEPTH_STENCIL,Ze.ALPHA=_.ALPHA,Ze.RGB=_.RGB,Ze.RGBA=_.RGBA,Ze.LUMINANCE=_.LUMINANCE,Ze.LUMINANCE_ALPHA=_.LUMINANCE_ALPHA,Ze.SRGB=35904,Ze.SRGB_ALPHA=35906,Ze.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,Ze.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,Ze.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,Ze.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,Ze.NEAREST=_.NEAREST,Ze.LINEAR=_.LINEAR,Ze.NEAREST_MIPMAP_NEAREST=_.NEAREST_MIPMAP_NEAREST,Ze.LINEAR_MIPMAP_NEAREST=_.LINEAR_MIPMAP_NEAREST,Ze.NEAREST_MIPMAP_LINEAR=_.NEAREST_MIPMAP_LINEAR,Ze.LINEAR_MIPMAP_LINEAR=_.LINEAR_MIPMAP_LINEAR,Ze.REPEAT=_.REPEAT,Ze.CLAMP_TO_EDGE=_.CLAMP_TO_EDGE,Ze.MIRRORED_REPEAT=_.MIRRORED_REPEAT;var Ye=Ze,Ke=Ve.extend({skeleton:null,joints:null},function(){this.joints||(this.joints=[])},{offsetMatrix:null,isInstancedMesh:function(){return!1},isSkinnedMesh:function(){return!!(this.skeleton&&this.joints&&this.joints.length>0)},clone:function(){var t=Ve.prototype.clone.call(this);return t.skeleton=this.skeleton,this.joints&&(t.joints=this.joints.slice()),t}});Ke.POINTS=_.POINTS,Ke.LINES=_.LINES,Ke.LINE_LOOP=_.LINE_LOOP,Ke.LINE_STRIP=_.LINE_STRIP,Ke.TRIANGLES=_.TRIANGLES,Ke.TRIANGLE_STRIP=_.TRIANGLE_STRIP,Ke.TRIANGLE_FAN=_.TRIANGLE_FAN,Ke.BACK=_.BACK,Ke.FRONT=_.FRONT,Ke.FRONT_AND_BACK=_.FRONT_AND_BACK,Ke.CW=_.CW,Ke.CCW=_.CCW;var Qe=Ke,Je={isPowerOfTwo:function(t){return 0==(t&t-1)},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}},$e=Je,tr=$e.isPowerOfTwo;function er(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}var rr=Ye.extend(function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}},{textureType:"texture2D",update:function(t){var e=t.gl;e.bindTexture(e.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(t);var r=this.format,i=this.type,n=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==Ye.REPEAT&&this.wrapT!==Ye.REPEAT||!this.NPOT);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,n?this.wrapS:this.getAvailableWrapS()),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,n?this.wrapT:this.getAvailableWrapT()),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,n?this.magFilter:this.getAvailableMagFilter()),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n?this.minFilter:this.getAvailableMinFilter());var a=t.getGLExtension("EXT_texture_filter_anisotropic");(a&&this.anisotropic>1&&e.texParameterf(e.TEXTURE_2D,a.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===i)&&(t.getGLExtension("OES_texture_half_float")||(i=_.FLOAT));if(this.mipmaps.length)for(var o=this.width,s=this.height,l=0;l<this.mipmaps.length;l++){var h=this.mipmaps[l];this._updateTextureData(e,h,l,o,s,r,i,!1),o/=2,s/=2}else this._updateTextureData(e,this,0,this.width,this.height,r,i,n),!this.useMipmap||this.NPOT&&!n||e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)},_updateTextureData:function(t,e,r,i,n,a,o,s){if(e.image){var l=e.image;s&&(this._potCanvas=function(t,e){var r=er(t.width),i=er(t.height);return(e=e||document.createElement("canvas")).width=r,e.height=i,e.getContext("2d").drawImage(t.image,0,0,r,i),e}(this,this._potCanvas),l=this._potCanvas),t.texImage2D(t.TEXTURE_2D,r,a,a,o,l)}else a<=Ye.COMPRESSED_RGBA_S3TC_DXT5_EXT&&a>=Ye.COMPRESSED_RGB_S3TC_DXT1_EXT?t.compressedTexImage2D(t.TEXTURE_2D,r,a,i,n,0,e.pixels):t.texImage2D(t.TEXTURE_2D,r,a,i,n,0,a,o,e.pixels)},generateMipmap:function(t){var e=t.gl;this.useMipmap&&!this.NPOT&&(e.bindTexture(e.TEXTURE_2D,this._cache.get("webgl_texture")),e.generateMipmap(e.TEXTURE_2D))},isPowerOfTwo:function(){return tr(this.width)&&tr(this.height)},isRenderable:function(){return this.image?this.image.width>0&&this.image.height>0:!(!this.width||!this.height)},bind:function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,this.getWebGLTexture(t))},unbind:function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,null)},load:function(t,e){var r=v.a.createImage();e&&(r.crossOrigin=e);var i=this;return r.onload=function(){i.dirty(),i.trigger("success",i)},r.onerror=function(){i.trigger("error",i)},r.src=t,this.image=r,this}});Object.defineProperty(rr.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(t){this.image?console.warn("Texture from image can't set width"):(this._width!==t&&this.dirty(),this._width=t)}}),Object.defineProperty(rr.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(t){this.image?console.warn("Texture from image can't set height"):(this._height!==t&&this.dirty(),this._height=t)}});var ir=rr;function nr(t){return{byte:v.a.Int8Array,ubyte:v.a.Uint8Array,short:v.a.Int16Array,ushort:v.a.Uint16Array}[t]||v.a.Float32Array}function ar(t){return"attr_"+t}function or(t,e,r,i){switch(this.name=t,this.type=e,this.size=r,this.semantic=i||"",this.value=null,r){case 1:this.get=function(t){return this.value[t]},this.set=function(t,e){this.value[t]=e},this.copy=function(t,e){this.value[t]=this.value[t]};break;case 2:this.get=function(t,e){var r=this.value;return e[0]=r[2*t],e[1]=r[2*t+1],e},this.set=function(t,e){var r=this.value;r[2*t]=e[0],r[2*t+1]=e[1]},this.copy=function(t,e){var r=this.value;e*=2,r[t*=2]=r[e],r[t+1]=r[e+1]};break;case 3:this.get=function(t,e){var r=3*t,i=this.value;return e[0]=i[r],e[1]=i[r+1],e[2]=i[r+2],e},this.set=function(t,e){var r=3*t,i=this.value;i[r]=e[0],i[r+1]=e[1],i[r+2]=e[2]},this.copy=function(t,e){var r=this.value;e*=3,r[t*=3]=r[e],r[t+1]=r[e+1],r[t+2]=r[e+2]};break;case 4:this.get=function(t,e){var r=this.value,i=4*t;return e[0]=r[i],e[1]=r[i+1],e[2]=r[i+2],e[3]=r[i+3],e},this.set=function(t,e){var r=this.value,i=4*t;r[i]=e[0],r[i+1]=e[1],r[i+2]=e[2],r[i+3]=e[3]},this.copy=function(t,e){var r=this.value;e*=4,r[t*=4]=r[e],r[t+1]=r[e+1],r[t+2]=r[e+2],r[t+3]=r[e+3]}}}function sr(t,e,r,i,n){this.name=t,this.type=e,this.buffer=r,this.size=i,this.semantic=n,this.symbol="",this.needsRemove=!1}function lr(t){this.buffer=t,this.count=0}or.prototype.init=function(t){if(!this.value||this.value.length!==t*this.size){var e=nr(this.type);this.value=new e(t*this.size)}},or.prototype.fromArray=function(t){var e,r=nr(this.type);if(t[0]&&t[0].length){var i=0,n=this.size;e=new r(t.length*n);for(var a=0;a<t.length;a++)for(var o=0;o<n;o++)e[i++]=t[a][o]}else e=new r(t);this.value=e},or.prototype.clone=function(t){var e=new or(this.name,this.type,this.size,this.semantic);return t&&console.warn("todo"),e};var hr=f.extend(function(){return{attributes:{},indices:null,dynamic:!0,_enabledAttributes:null,__used:0}},function(){this._cache=new qe,this._attributeList=Object.keys(this.attributes),this.__vaoCache={}},{mainAttribute:"",pick:null,pickByRay:null,dirty:function(){for(var t=this.getEnabledAttributes(),e=0;e<t.length;e++)this.dirtyAttribute(t[e]);this.dirtyIndices(),this._enabledAttributes=null,this._cache.dirty("any")},dirtyIndices:function(){this._cache.dirtyAll("indices")},dirtyAttribute:function(t){this._cache.dirtyAll(ar(t)),this._cache.dirtyAll("attributes")},getTriangleIndices:function(t,e){if(t<this.triangleCount&&t>=0){e||(e=[]);var r=this.indices;return e[0]=r[3*t],e[1]=r[3*t+1],e[2]=r[3*t+2],e}},setTriangleIndices:function(t,e){var r=this.indices;r[3*t]=e[0],r[3*t+1]=e[1],r[3*t+2]=e[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(t){var e,r=this.vertexCount>65535?v.a.Uint32Array:v.a.Uint16Array;if(t[0]&&t[0].length){var i=0;e=new r(3*t.length);for(var n=0;n<t.length;n++)for(var a=0;a<3;a++)e[i++]=t[n][a]}else e=new r(t);this.indices=e},createAttribute:function(t,e,r,i){var n=new or(t,e,r,i);return this.attributes[t]&&this.removeAttribute(t),this.attributes[t]=n,this._attributeList.push(t),n},removeAttribute:function(t){var e=this._attributeList,r=e.indexOf(t);return r>=0&&(e.splice(r,1),delete this.attributes[t],!0)},getAttribute:function(t){return this.attributes[t]},getEnabledAttributes:function(){var t=this._enabledAttributes,e=this._attributeList;if(t)return t;for(var r=[],i=this.vertexCount,n=0;n<e.length;n++){var a=e[n],o=this.attributes[a];o.value&&o.value.length===i*o.size&&r.push(a)}return this._enabledAttributes=r,r},getBufferChunks:function(t){var e=this._cache;e.use(t.__uid__);var r=e.isDirty("attributes"),i=e.isDirty("indices");if(r||i){this._updateBuffer(t.gl,r,i);for(var n=this.getEnabledAttributes(),a=0;a<n.length;a++)e.fresh(ar(n[a]));e.fresh("attributes"),e.fresh("indices")}return e.fresh("any"),e.get("chunks")},_updateBuffer:function(t,e,r){var i=this._cache,n=i.get("chunks"),a=!1;n||((n=[])[0]={attributeBuffers:[],indicesBuffer:null},i.put("chunks",n),a=!0);var o=n[0],s=o.attributeBuffers,l=o.indicesBuffer;if(e||a){var h=this.getEnabledAttributes(),u={};if(!a)for(var c=0;c<s.length;c++)u[s[c].name]=s[c];for(var d=0;d<h.length;d++){var f,p,m=h[d],g=this.attributes[m];a||(f=u[m]),p=f?f.buffer:t.createBuffer(),i.isDirty(ar(m))&&(t.bindBuffer(t.ARRAY_BUFFER,p),t.bufferData(t.ARRAY_BUFFER,g.value,this.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW)),s[d]=new sr(m,g.type,p,g.size,g.semantic)}for(c=d;c<s.length;c++)t.deleteBuffer(s[c].buffer);s.length=d}this.isUseIndices()&&(r||a)&&(l||(l=new lr(t.createBuffer()),o.indicesBuffer=l),l.count=this.indices.length,t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,l.buffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,this.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW))},dispose:function(t){var e=this._cache;e.use(t.__uid__);var r=e.get("chunks");if(r)for(var i=0;i<r.length;i++){for(var n=r[i],a=0;a<n.attributeBuffers.length;a++){var o=n.attributeBuffers[a];t.gl.deleteBuffer(o.buffer)}n.indicesBuffer&&t.gl.deleteBuffer(n.indicesBuffer.buffer)}if(this.__vaoCache){var s=t.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var h=this.__vaoCache[l].vao;h&&s.deleteVertexArrayOES(h)}}this.__vaoCache={},e.deleteContext(t.__uid__)}});Object.defineProperty&&(Object.defineProperty(hr.prototype,"vertexCount",{enumerable:!1,get:function(){var t=this.attributes[this.mainAttribute];return t||(t=this.attributes[this._attributeList[0]]),t&&t.value?t.value.length/t.size:0}}),Object.defineProperty(hr.prototype,"triangleCount",{enumerable:!1,get:function(){var t=this.indices;return t?t.length/3:0}})),hr.STATIC_DRAW=_.STATIC_DRAW,hr.DYNAMIC_DRAW=_.DYNAMIC_DRAW,hr.STREAM_DRAW=_.STREAM_DRAW,hr.AttributeBuffer=sr,hr.IndicesBuffer=lr,hr.Attribute=or;var ur=hr,cr=Mt.create,dr=Mt.add,fr=Mt.set,pr=ur.Attribute,mr=ur.extend(function(){return{attributes:{position:new pr("position","float",3,"POSITION"),texcoord0:new pr("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new pr("texcoord1","float",2,"TEXCOORD_1"),normal:new pr("normal","float",3,"NORMAL"),tangent:new pr("tangent","float",4,"TANGENT"),color:new pr("color","float",4,"COLOR"),weight:new pr("weight","float",3,"WEIGHT"),joint:new pr("joint","float",4,"JOINT"),barycentric:new pr("barycentric","float",3,null)},boundingBox:null}},{mainAttribute:"position",updateBoundingBox:function(){var t=this.boundingBox;t||(t=this.boundingBox=new Ie);var e=this.attributes.position.value;if(e&&e.length){var r=t.min,i=t.max,n=r.array,a=i.array;Mt.set(n,e[0],e[1],e[2]),Mt.set(a,e[0],e[1],e[2]);for(var o=3;o<e.length;){var s=e[o++],l=e[o++],h=e[o++];s<n[0]&&(n[0]=s),l<n[1]&&(n[1]=l),h<n[2]&&(n[2]=h),s>a[0]&&(a[0]=s),l>a[1]&&(a[1]=l),h>a[2]&&(a[2]=h)}r._dirty=!0,i._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var t=this.indices,e=this.attributes,r=e.position.value,i=e.normal.value;if(i&&i.length===r.length)for(var n=0;n<i.length;n++)i[n]=0;else i=e.normal.value=new v.a.Float32Array(r.length);for(var a,o,s,l=cr(),h=cr(),u=cr(),c=cr(),d=cr(),f=cr(),p=t?t.length:this.vertexCount,m=0;m<p;){t?(a=t[m++],o=t[m++],s=t[m++]):(a=m++,o=m++,s=m++),fr(l,r[3*a],r[3*a+1],r[3*a+2]),fr(h,r[3*o],r[3*o+1],r[3*o+2]),fr(u,r[3*s],r[3*s+1],r[3*s+2]),Mt.sub(c,l,h),Mt.sub(d,h,u),Mt.cross(f,c,d);for(n=0;n<3;n++)i[3*a+n]=i[3*a+n]+f[n],i[3*o+n]=i[3*o+n]+f[n],i[3*s+n]=i[3*s+n]+f[n]}for(n=0;n<i.length;)fr(f,i[n],i[n+1],i[n+2]),Mt.normalize(f,f),i[n++]=f[0],i[n++]=f[1],i[n++]=f[2];this.dirty()}},generateFaceNormals:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var t=this.indices,e=this.attributes,r=e.position.value,i=e.normal.value,n=cr(),a=cr(),o=cr(),s=cr(),l=cr(),h=cr();i||(i=e.normal.value=new Float32Array(r.length));for(var u,c,d,f=t?t.length:this.vertexCount,p=0;p<f;){t?(u=t[p++],c=t[p++],d=t[p++]):(u=p++,c=p++,d=p++),fr(n,r[3*u],r[3*u+1],r[3*u+2]),fr(a,r[3*c],r[3*c+1],r[3*c+2]),fr(o,r[3*d],r[3*d+1],r[3*d+2]),Mt.sub(s,n,a),Mt.sub(l,a,o),Mt.cross(h,s,l),Mt.normalize(h,h);for(var m=0;m<3;m++)i[3*u+m]=h[m],i[3*c+m]=h[m],i[3*d+m]=h[m]}this.dirty()}},generateTangents:function(){if(this.vertexCount){var t=this.vertexCount,e=this.attributes;e.tangent.value||(e.tangent.value=new Float32Array(4*t));var r=e.texcoord0.value,i=e.position.value,n=e.tangent.value,a=e.normal.value;if(r){for(var o=[],s=[],l=0;l<t;l++)o[l]=[0,0,0],s[l]=[0,0,0];var h,u,c,d=[0,0,0],f=[0,0,0],p=this.indices,m=p?p.length:this.vertexCount;for(l=0;l<m;){p?(h=p[l++],u=p[l++],c=p[l++]):(h=l++,u=l++,c=l++);var g=r[2*h],_=r[2*u],v=r[2*c],y=r[2*h+1],x=r[2*u+1],T=r[2*c+1],b=i[3*h],w=i[3*u],S=i[3*c],E=i[3*h+1],A=i[3*u+1],M=i[3*c+1],C=i[3*h+2],D=w-b,L=S-b,P=A-E,N=M-E,R=i[3*u+2]-C,I=i[3*c+2]-C,O=_-g,B=v-g,F=x-y,z=T-y,U=1/(O*z-F*B);d[0]=(z*D-F*L)*U,d[1]=(z*P-F*N)*U,d[2]=(z*R-F*I)*U,f[0]=(O*L-B*D)*U,f[1]=(O*N-B*P)*U,f[2]=(O*I-B*R)*U,dr(o[h],o[h],d),dr(o[u],o[u],d),dr(o[c],o[c],d),dr(s[h],s[h],f),dr(s[u],s[u],f),dr(s[c],s[c],f)}var k=cr(),G=cr(),H=cr();for(l=0;l<t;l++){H[0]=a[3*l],H[1]=a[3*l+1],H[2]=a[3*l+2];var V=o[l];Mt.scale(k,H,Mt.dot(H,V)),Mt.sub(k,V,k),Mt.normalize(k,k),Mt.cross(G,H,V),n[4*l]=k[0],n[4*l+1]=k[1],n[4*l+2]=k[2],n[4*l+3]=Mt.dot(G,s[l])<0?-1:1}this.dirty()}else console.warn("Geometry without texcoords can't generate tangents.")}},isUniqueVertex:function(){return!this.isUseIndices()||this.vertexCount===this.indices.length},generateUniqueVertex:function(){if(this.vertexCount&&this.indices){this.indices.length>65535&&(this.indices=new v.a.Uint32Array(this.indices));for(var t=this.attributes,e=this.indices,r=this.getEnabledAttributes(),i={},n=0;n<r.length;n++){i[l=r[n]]=t[l].value,t[l].init(this.indices.length)}for(var a=0,o=0;o<e.length;o++){var s=e[o];for(n=0;n<r.length;n++)for(var l,h=t[l=r[n]].value,u=t[l].size,c=0;c<u;c++)h[a*u+c]=i[l][s*u+c];e[o]=a,a++}this.dirty()}},generateBarycentric:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var t=this.attributes,e=t.barycentric.value,r=this.indices;if(!e||e.length!==3*r.length){e=t.barycentric.value=new Float32Array(3*r.length);for(var i=0;i<(r?r.length:this.vertexCount/3);)for(var n=0;n<3;n++){e[3*(r?r[i++]:3*i+n)+n]=1}this.dirty()}}},applyTransform:function(t){var e=this.attributes,r=e.position.value,i=e.normal.value,n=e.tangent.value;t=t.array;var a=Et.create();Et.invert(a,t),Et.transpose(a,a);var o=Mt.transformMat4,s=Mt.forEach;s(r,3,0,null,o,t),i&&s(i,3,0,null,o,a),n&&s(n,4,0,null,o,a),this.boundingBox&&this.updateBoundingBox()},dispose:function(t){var e=this._cache;e.use(t.__uid__);var r=e.get("chunks");if(r)for(var i=0;i<r.length;i++){for(var n=r[i],a=0;a<n.attributeBuffers.length;a++){var o=n.attributeBuffers[a];t.gl.deleteBuffer(o.buffer)}n.indicesBuffer&&t.gl.deleteBuffer(n.indicesBuffer.buffer)}if(this.__vaoCache){var s=t.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var h=this.__vaoCache[l].vao;h&&s.deleteVertexArrayOES(h)}}this.__vaoCache={},e.deleteContext(t.__uid__)}});mr.STATIC_DRAW=ur.STATIC_DRAW,mr.DYNAMIC_DRAW=ur.DYNAMIC_DRAW,mr.STREAM_DRAW=ur.STREAM_DRAW,mr.AttributeBuffer=ur.AttributeBuffer,mr.IndicesBuffer=ur.IndicesBuffer,mr.Attribute=pr;var gr=mr,_r="@end",vr=["@export clay.header.directional_light","uniform vec3 directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]:unconfigurable;","uniform vec3 directionalLightColor[DIRECTIONAL_LIGHT_COUNT]:unconfigurable;",_r,"@export clay.header.ambient_light","uniform vec3 ambientLightColor[AMBIENT_LIGHT_COUNT]:unconfigurable;",_r,"@export clay.header.ambient_sh_light","uniform vec3 ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]:unconfigurable;","uniform vec3 ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]:unconfigurable;","vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}",_r,"@export clay.header.ambient_cubemap_light","uniform vec3 ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]:unconfigurable;","uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]:unconfigurable;","uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]:unconfigurable;",_r,"@export clay.header.point_light","uniform vec3 pointLightPosition[POINT_LIGHT_COUNT]:unconfigurable;","uniform float pointLightRange[POINT_LIGHT_COUNT]:unconfigurable;","uniform vec3 pointLightColor[POINT_LIGHT_COUNT]:unconfigurable;",_r,"@export clay.header.spot_light","uniform vec3 spotLightPosition[SPOT_LIGHT_COUNT]:unconfigurable;","uniform vec3 spotLightDirection[SPOT_LIGHT_COUNT]:unconfigurable;","uniform float spotLightRange[SPOT_LIGHT_COUNT]:unconfigurable;","uniform float spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]:unconfigurable;","uniform float spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]:unconfigurable;","uniform float spotLightFalloffFactor[SPOT_LIGHT_COUNT]:unconfigurable;","uniform vec3 spotLightColor[SPOT_LIGHT_COUNT]:unconfigurable;",_r].join("\n");bt.import(vr);var yr,xr,Tr,br,wr=Be.extend(function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}},{type:"",clone:function(){var t=Be.prototype.clone.call(this);return t.color=Array.prototype.slice.call(this.color),t.intensity=this.intensity,t.castShadow=this.castShadow,t.shadowResolution=this.shadowResolution,t}}),Sr=function(t,e){this.normal=t||new Qt(0,1,0),this.distance=e||0};Sr.prototype={constructor:Sr,distanceToPoint:function(t){return Mt.dot(t.array,this.normal.array)-this.distance},projectPoint:function(t,e){e||(e=new Qt);var r=this.distanceToPoint(t);return Mt.scaleAndAdd(e.array,t.array,this.normal.array,-r),e._dirty=!0,e},normalize:function(){var t=1/Mt.len(this.normal.array);Mt.scale(this.normal.array,t),this.distance*=t},intersectFrustum:function(t){for(var e=t.vertices,r=this.normal.array,i=Mt.dot(e[0].array,r)>this.distance,n=1;n<8;n++)if(Mt.dot(e[n].array,r)>this.distance!=i)return!0},intersectLine:(br=Mt.create(),function(t,e,r){var i=this.distanceToPoint(t),n=this.distanceToPoint(e);if(i>0&&n>0||i<0&&n<0)return null;var a=this.normal.array,o=this.distance,s=t.array;Mt.sub(br,e.array,t.array),Mt.normalize(br,br);var l=Mt.dot(a,br);if(0===l)return null;r||(r=new Qt);var h=(Mt.dot(a,s)-o)/l;return Mt.scaleAndAdd(r.array,s,br,-h),r._dirty=!0,r}),applyTransform:(yr=Et.create(),xr=ee.create(),Tr=ee.create(),Tr[3]=1,function(t){t=t.array,Mt.scale(Tr,this.normal.array,this.distance),ee.transformMat4(Tr,Tr,t),this.distance=Mt.dot(Tr,this.normal.array),Et.invert(yr,t),Et.transpose(yr,yr),xr[3]=0,Mt.copy(xr,this.normal.array),ee.transformMat4(xr,xr,yr),Mt.copy(this.normal.array,xr)}),copy:function(t){Mt.copy(this.normal.array,t.normal.array),this.normal._dirty=!0,this.distance=t.distance},clone:function(){var t=new Sr;return t.copy(this),t}};var Er,Ar=Sr,Mr=Mt.set,Cr=Mt.copy,Dr=Mt.transformMat4,Lr=Math.min,Pr=Math.max,Nr=function(){this.planes=[];for(var t=0;t<6;t++)this.planes.push(new Ar);this.boundingBox=new Ie,this.vertices=[];for(t=0;t<8;t++)this.vertices[t]=Mt.fromValues(0,0,0)};Nr.prototype={setFromProjection:function(t){var e=this.planes,r=t.array,i=r[0],n=r[1],a=r[2],o=r[3],s=r[4],l=r[5],h=r[6],u=r[7],c=r[8],d=r[9],f=r[10],p=r[11],m=r[12],g=r[13],_=r[14],v=r[15];Mr(e[0].normal.array,o-i,u-s,p-c),e[0].distance=-(v-m),e[0].normalize(),Mr(e[1].normal.array,o+i,u+s,p+c),e[1].distance=-(v+m),e[1].normalize(),Mr(e[2].normal.array,o+n,u+l,p+d),e[2].distance=-(v+g),e[2].normalize(),Mr(e[3].normal.array,o-n,u-l,p-d),e[3].distance=-(v-g),e[3].normalize(),Mr(e[4].normal.array,o-a,u-h,p-f),e[4].distance=-(v-_),e[4].normalize(),Mr(e[5].normal.array,o+a,u+h,p+f),e[5].distance=-(v+_),e[5].normalize();var y=this.boundingBox,x=this.vertices;if(0===v){var T=l/i,b=-_/(f-1),w=-_/(f+1),S=-w/l,E=-b/l;y.min.set(-S*T,-S,w),y.max.set(S*T,S,b),Mr(x[0],-S*T,-S,w),Mr(x[1],-S*T,S,w),Mr(x[2],S*T,-S,w),Mr(x[3],S*T,S,w),Mr(x[4],-E*T,-E,b),Mr(x[5],-E*T,E,b),Mr(x[6],E*T,-E,b),Mr(x[7],E*T,E,b)}else{var A=(-1-m)/i,M=(1-m)/i,C=(1-g)/l,D=(-1-g)/l,L=(-1-_)/f,P=(1-_)/f;y.min.set(Math.min(A,M),Math.min(D,C),Math.min(P,L)),y.max.set(Math.max(M,A),Math.max(C,D),Math.max(L,P));var N=y.min.array,R=y.max.array;Mr(x[0],N[0],N[1],N[2]),Mr(x[1],N[0],R[1],N[2]),Mr(x[2],R[0],N[1],N[2]),Mr(x[3],R[0],R[1],N[2]),Mr(x[4],N[0],N[1],R[2]),Mr(x[5],N[0],R[1],R[2]),Mr(x[6],R[0],N[1],R[2]),Mr(x[7],R[0],R[1],R[2])}},getTransformedBoundingBox:(Er=Mt.create(),function(t,e){var r=this.vertices,i=e.array,n=t.min,a=t.max,o=n.array,s=a.array,l=r[0];Dr(Er,l,i),Cr(o,Er),Cr(s,Er);for(var h=1;h<8;h++)l=r[h],Dr(Er,l,i),o[0]=Lr(Er[0],o[0]),o[1]=Lr(Er[1],o[1]),o[2]=Lr(Er[2],o[2]),s[0]=Pr(Er[0],s[0]),s[1]=Pr(Er[1],s[1]),s[2]=Pr(Er[2],s[2]);return n._dirty=!0,a._dirty=!0,t})};var Rr,Ir,Or,Br=Nr,Fr=Be.extend(function(){return{projectionMatrix:new _e,invProjectionMatrix:new _e,viewMatrix:new _e,frustum:new Br}},function(){this.update(!0)},{update:function(t){Be.prototype.update.call(this,t),_e.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),_e.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(t){_e.copy(this.viewMatrix,t),_e.invert(this.worldTransform,t),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(t){_e.copy(this.projectionMatrix,t),_e.invert(this.invProjectionMatrix,t),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:(Rr=ee.create(),function(t,e){var r=void 0!==e?e:new $t,i=t.array[0],n=t.array[1];return ee.set(Rr,i,n,-1,1),ee.transformMat4(Rr,Rr,this.invProjectionMatrix.array),ee.transformMat4(Rr,Rr,this.worldTransform.array),Mt.scale(r.origin.array,Rr,1/Rr[3]),ee.set(Rr,i,n,1,1),ee.transformMat4(Rr,Rr,this.invProjectionMatrix.array),ee.transformMat4(Rr,Rr,this.worldTransform.array),Mt.scale(Rr,Rr,1/Rr[3]),Mt.sub(r.direction.array,Rr,r.origin.array),Mt.normalize(r.direction.array,r.direction.array),r.direction._dirty=!0,r.origin._dirty=!0,r})}),zr=Et.create(),Ur=Et.create(),kr={};function Gr(t){var e=[],r=Object.keys(t);r.sort();for(var i=0;i<r.length;i++){var n=r[i];e.push(n+" "+t[n])}var a=e.join("\n");if(kr[a])return kr[a];var o=c.genGUID();return kr[a]=o,o}function Hr(){this.opaque=[],this.transparent=[],this._opaqueCount=0,this._transparentCount=0}function Vr(t,e){if(e.castShadow&&!t.castShadow)return!0}Hr.prototype.startCount=function(){this._opaqueCount=0,this._transparentCount=0},Hr.prototype.add=function(t,e){e?this.transparent[this._transparentCount++]=t:this.opaque[this._opaqueCount++]=t},Hr.prototype.endCount=function(){this.transparent.length=this._transparentCount,this.opaque.length=this._opaqueCount};var Wr=Be.extend(function(){return{material:null,lights:[],viewBoundingBoxLastFrame:new Ie,shadowUniforms:{},_cameraList:[],_lightUniforms:{},_previousLightNumber:{},_lightNumber:{},_lightProgramKeys:{},_nodeRepository:{},_renderLists:new b(20)}},function(){this._scene=this},{addToScene:function(t){t instanceof Fr?(this._cameraList.length>0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(t)):t instanceof wr&&this.lights.push(t),t.name&&(this._nodeRepository[t.name]=t)},removeFromScene:function(t){var e;t instanceof Fr?(e=this._cameraList.indexOf(t))>=0&&this._cameraList.splice(e,1):t instanceof wr&&(e=this.lights.indexOf(t))>=0&&this.lights.splice(e,1),t.name&&delete this._nodeRepository[t.name]},getNode:function(t){return this._nodeRepository[t]},setMainCamera:function(t){var e=this._cameraList.indexOf(t);e>=0&&this._cameraList.splice(e,1),this._cameraList.unshift(t)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var t=this.lights;this._previousLightNumber=this._lightNumber;for(var e={},r=0;r<t.length;r++){var i=t[r];if(!i.invisible){var n=i.group;e[n]||(e[n]={}),e[n][i.type]=e[n][i.type]||0,e[n][i.type]++}}for(var a in this._lightNumber=e,e)this._lightProgramKeys[a]=Gr(e[a]);this._updateLightUniforms()},cloneNode:function(t){var e=t.clone(),r={};return function t(e,i){r[e.__uid__]=i;for(var n=0;n<e._children.length;n++)t(e._children[n],i._children[n])}(t,e),e.traverse(function(t){t.skeleton&&(t.skeleton=t.skeleton.clone(r)),t.material&&(t.material=t.material.clone())}),e},updateRenderList:function(t,e){var r=t.__uid__,i=this._renderLists.get(r);i||(i=new Hr,this._renderLists.put(r,i)),i.startCount(),e&&(this.viewBoundingBoxLastFrame.min.set(1/0,1/0,1/0),this.viewBoundingBoxLastFrame.max.set(-1/0,-1/0,-1/0));var n=this.material&&this.material.transparent||!1;return this._doUpdateRenderList(this,t,n,i,e),i.endCount(),i},getRenderList:function(t){return this._renderLists.get(t.__uid__)},_doUpdateRenderList:function(t,e,r,i,n){if(!t.invisible)for(var a=0;a<t._children.length;a++){var o=t._children[a];if(o.isRenderable()){var s=o.isSkinnedMesh()?zr:o.worldTransform.array,l=o.geometry;Et.multiplyAffine(Ur,e.viewMatrix.array,s),(n&&!l.boundingBox||!this.isFrustumCulled(o,e,Ur))&&i.add(o,o.material.transparent||r)}o._children.length>0&&this._doUpdateRenderList(o,e,r,i,n)}},isFrustumCulled:(Ir=new Ie,Or=new _e,function(t,e,r){var i=t.boundingBox;if(i||(i=t.skeleton&&t.skeleton.boundingBox?t.skeleton.boundingBox:t.geometry.boundingBox),!i)return!1;if(Or.array=r,Ir.transformFrom(i,Or),t.castShadow&&this.viewBoundingBoxLastFrame.union(Ir),t.frustumCulling){if(!Ir.intersectBoundingBox(e.frustum.boundingBox))return!0;Or.array=e.projectionMatrix.array,Ir.max.array[2]>0&&Ir.min.array[2]<0&&(Ir.max.array[2]=-1e-20),Ir.applyProjection(Or);var n=Ir.min.array,a=Ir.max.array;if(a[0]<-1||n[0]>1||a[1]<-1||n[1]>1||a[2]<-1||n[2]>1)return!0}return!1}),_updateLightUniforms:function(){var t=this.lights;t.sort(Vr);var e=this._lightUniforms;for(var r in e)for(var i in e[r])e[r][i].value.length=0;for(var n=0;n<t.length;n++){var a=t[n];if(!a.invisible){r=a.group;for(var i in a.uniformTemplates){var o=a.uniformTemplates[i],s=o.value(a);if(null!=s){e[r]||(e[r]={}),e[r][i]||(e[r][i]={type:"",value:[]});var l=e[r][i];switch(l.type=o.type+"v",o.type){case"1i":case"1f":case"t":l.value.push(s);break;case"2f":case"3f":case"4f":for(var h=0;h<s.length;h++)l.value.push(s[h]);break;default:console.error("Unkown light uniform type "+o.type)}}}}}},getLightGroups:function(){var t=[];for(var e in this._lightNumber)t.push(e);return t},getNumberChangedLightGroups:function(){var t=[];for(var e in this._lightNumber)this.isLightNumberChanged(e)&&t.push(e);return t},isLightNumberChanged:function(t){var e=this._previousLightNumber,r=this._lightNumber;for(var i in r[t]){if(!e[t])return!0;if(r[t][i]!==e[t][i])return!0}for(var i in e[t]){if(!r[t])return!0;if(r[t][i]!==e[t][i])return!0}return!1},getLightsNumbers:function(t){return this._lightNumber[t]},getProgramKey:function(t){return this._lightProgramKeys[t]},setLightUniforms:function(){function t(t,e,r){for(var i in t){var n=t[i];if("tv"===n.type){if(!e.hasUniform(i))continue;for(var a=[],o=0;o<n.value.length;o++){var s=n.value[o],l=e.takeCurrentTextureSlot(r,s);a.push(l)}e.setUniform(r.gl,"1iv",i,a)}else e.setUniform(r.gl,n.type,i,n.value)}}return function(e,r,i){t(this._lightUniforms[r],e,i),t(this.shadowUniforms,e,i)}}(),dispose:function(){this.material=null,this._opaqueList=[],this._transparentList=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}}),Xr=function(){return function(t){this.value=t}}(),jr=function(){function t(){this._len=0}return t.prototype.insert=function(t){var e=new Xr(t);return this.insertEntry(e),e},t.prototype.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t):this.head=this.tail=t,this._len++},t.prototype.remove=function(t){var e=t.prev,r=t.next;e?e.next=r:this.head=r,r?r.prev=e:this.tail=e,t.next=t.prev=null,this._len--},t.prototype.len=function(){return this._len},t.prototype.clear=function(){this.head=this.tail=null,this._len=0},t}(),qr=function(){function t(t){this._list=new jr,this._maxSize=10,this._map={},this._maxSize=t}return t.prototype.put=function(t,e){var r=this._list,i=this._map,n=null;if(null==i[t]){var a=r.len(),o=this._lastRemovedEntry;if(a>=this._maxSize&&a>0){var s=r.head;r.remove(s),delete i[s.key],n=s.value,this._lastRemovedEntry=s}o?o.value=e:o=new Xr(e),o.key=t,r.insertEntry(o),i[t]=o}return n},t.prototype.get=function(t){var e=this._map[t],r=this._list;if(null!=e)return e!==r.tail&&(r.remove(e),r.insertEntry(e)),e.value},t.prototype.clear=function(){this._list.clear(),this._map={}},t.prototype.len=function(){return this._list.len()},t}(),Zr=$e.isPowerOfTwo,Yr=["px","nx","py","ny","pz","nz"],Kr=Ye.extend(function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}},{textureType:"textureCube",update:function(t){var e=t.gl;e.bindTexture(e.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(t);var r=this.format,i=this.type;e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,this.getAvailableWrapS()),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,this.getAvailableWrapT()),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var n=t.getGLExtension("EXT_texture_filter_anisotropic");(n&&this.anisotropic>1&&e.texParameterf(e.TEXTURE_CUBE_MAP,n.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===i)&&(t.getGLExtension("OES_texture_half_float")||(i=_.FLOAT));if(this.mipmaps.length)for(var a=this.width,o=this.height,s=0;s<this.mipmaps.length;s++){var l=this.mipmaps[s];this._updateTextureData(e,l,s,a,o,r,i),a/=2,o/=2}else this._updateTextureData(e,this,0,this.width,this.height,r,i),!this.NPOT&&this.useMipmap&&e.generateMipmap(e.TEXTURE_CUBE_MAP);e.bindTexture(e.TEXTURE_CUBE_MAP,null)},_updateTextureData:function(t,e,r,i,n,a,o){for(var s=0;s<6;s++){var l=Yr[s],h=e.image&&e.image[l];h?t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,r,a,a,o,h):t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,r,a,i,n,0,a,o,e.pixels&&e.pixels[l])}},generateMipmap:function(t){var e=t.gl;this.useMipmap&&!this.NPOT&&(e.bindTexture(e.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),e.generateMipmap(e.TEXTURE_CUBE_MAP))},bind:function(t){t.gl.bindTexture(t.gl.TEXTURE_CUBE_MAP,this.getWebGLTexture(t))},unbind:function(t){t.gl.bindTexture(t.gl.TEXTURE_CUBE_MAP,null)},isPowerOfTwo:function(){return this.image.px?Zr(this.image.px.width)&&Zr(this.image.px.height):Zr(this.width)&&Zr(this.height)},isRenderable:function(){return this.image.px?Qr(this.image.px)&&Qr(this.image.nx)&&Qr(this.image.py)&&Qr(this.image.ny)&&Qr(this.image.pz)&&Qr(this.image.nz):!(!this.width||!this.height)},load:function(t,e){var r=0,i=this;return c.each(t,function(t,n){var a=v.a.createImage();e&&(a.crossOrigin=e),a.onload=function(){0===--r&&(i.dirty(),i.trigger("success",i))},a.onerror=function(){r--},r++,a.src=t,i.image[n]=a}),this}});function Qr(t){return t.width>0&&t.height>0}Object.defineProperty(Kr.prototype,"width",{get:function(){return this.image&&this.image.px?this.image.px.width:this._width},set:function(t){this.image&&this.image.px?console.warn("Texture from image can't set width"):(this._width!==t&&this.dirty(),this._width=t)}}),Object.defineProperty(Kr.prototype,"height",{get:function(){return this.image&&this.image.px?this.image.px.height:this._height},set:function(t){this.image&&this.image.px?console.warn("Texture from image can't set height"):(this._height!==t&&this.dirty(),this._height=t)}});var Jr=Kr,$r=Fr.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var t=this.fov/180*Math.PI;this.projectionMatrix.perspective(t,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var t=this.projectionMatrix.array,e=2*Math.atan(1/t[5]);this.fov=e/Math.PI*180,this.aspect=t[5]/t[0],this.near=t[14]/(t[10]-1),this.far=t[14]/(t[10]+1)},clone:function(){var t=Fr.prototype.clone.call(this);return t.fov=this.fov,t.aspect=this.aspect,t.near=this.near,t.far=this.far,t}}),ti=_.FRAMEBUFFER,ei=_.RENDERBUFFER,ri=_.DEPTH_ATTACHMENT,ii=_.COLOR_ATTACHMENT0,ni=f.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},function(){this._cache=new qe,this._textures={}},{getTextureWidth:function(){return this._width},getTextureHeight:function(){return this._height},bind:function(t){if(t.__currentFrameBuffer){if(t.__currentFrameBuffer===this)return;console.warn("Renderer already bound with another framebuffer. Unbind it first")}t.__currentFrameBuffer=this;var e=t.gl;e.bindFramebuffer(ti,this._getFrameBufferGL(t)),this._boundRenderer=t;var r=this._cache;r.put("viewport",t.viewport);var i,n,a=!1;for(var o in this._textures){a=!0;var s=this._textures[o];s&&(i=s.texture.width,n=s.texture.height,this._doAttach(t,s.texture,o,s.target))}this._width=i,this._height=n,!a&&this.depthBuffer&&console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),this.viewport?t.setViewport(this.viewport):t.setViewport(0,0,i,n,1);var l=r.get("attached_textures");if(l)for(var o in l)if(!this._textures[o]){var h=l[o];this._doDetach(e,o,h)}if(!r.get("depthtexture_attached")&&this.depthBuffer){r.miss("renderbuffer")&&r.put("renderbuffer",e.createRenderbuffer());var u=r.get("renderbuffer");i===r.get("renderbuffer_width")&&n===r.get("renderbuffer_height")||(e.bindRenderbuffer(ei,u),e.renderbufferStorage(ei,e.DEPTH_COMPONENT16,i,n),r.put("renderbuffer_width",i),r.put("renderbuffer_height",n),e.bindRenderbuffer(ei,null)),r.get("renderbuffer_attached")||(e.framebufferRenderbuffer(ti,ri,ei,u),r.put("renderbuffer_attached",!0))}},unbind:function(t){t.__currentFrameBuffer=null,t.gl.bindFramebuffer(ti,null),this._boundRenderer=null,this._cache.use(t.__uid__);var e=this._cache.get("viewport");e&&t.setViewport(e),this.updateMipmap(t)},updateMipmap:function(t){var e=t.gl;for(var r in this._textures){var i=this._textures[r];if(i){var n=i.texture;if(!n.NPOT&&n.useMipmap&&n.minFilter===Ye.LINEAR_MIPMAP_LINEAR){var a="textureCube"===n.textureType?_.TEXTURE_CUBE_MAP:_.TEXTURE_2D;e.bindTexture(a,n.getWebGLTexture(t)),e.generateMipmap(a),e.bindTexture(a,null)}}}},checkStatus:function(t){return t.checkFramebufferStatus(ti)},_getFrameBufferGL:function(t){var e=this._cache;return e.use(t.__uid__),e.miss("framebuffer")&&e.put("framebuffer",t.gl.createFramebuffer()),e.get("framebuffer")},attach:function(t,e,r){if(!t.width)throw new Error("The texture attached to color buffer is not a valid.");e=e||ii,r=r||_.TEXTURE_2D;var i,n=this._boundRenderer;if(n&&n.gl){var a=this._cache;a.use(n.__uid__),i=a.get("attached_textures")}var o=this._textures[e];if(!o||o.target!==r||o.texture!==t||!i||null==i[e]){var s=!0;n&&(s=this._doAttach(n,t,e,r),this.viewport||n.setViewport(0,0,t.width,t.height,1)),s&&(this._textures[e]=this._textures[e]||{},this._textures[e].texture=t,this._textures[e].target=r)}},_doAttach:function(t,e,r,i){var n=t.gl,a=e.getWebGLTexture(t),o=this._cache.get("attached_textures");if(o&&o[r]){var s=o[r];if(s.texture===e&&s.target===i)return}var l=!0;if(((r=+r)===ri||r===_.DEPTH_STENCIL_ATTACHMENT)&&(t.getGLExtension("WEBGL_depth_texture")||(console.error("Depth texture is not supported by the browser"),l=!1),e.format!==_.DEPTH_COMPONENT&&e.format!==_.DEPTH_STENCIL&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l)){var h=this._cache.get("renderbuffer");h&&(n.framebufferRenderbuffer(ti,ri,ei,null),n.deleteRenderbuffer(h),this._cache.put("renderbuffer",!1)),this._cache.put("renderbuffer_attached",!1),this._cache.put("depthtexture_attached",!0)}return n.framebufferTexture2D(ti,r,i,a,0),o||(o={},this._cache.put("attached_textures",o)),o[r]=o[r]||{},o[r].texture=e,o[r].target=i,l},_doDetach:function(t,e,r){t.framebufferTexture2D(ti,e,r,null,0);var i=this._cache.get("attached_textures");i&&i[e]&&(i[e]=null),e!==ri&&e!==_.DEPTH_STENCIL_ATTACHMENT||this._cache.put("depthtexture_attached",!1)},detach:function(t,e){(this._textures[t]=null,this._boundRenderer)&&(this._cache.use(this._boundRenderer.__uid__),this._doDetach(this._boundRenderer.gl,t,e))},dispose:function(t){var e=t.gl,r=this._cache;r.use(t.__uid__);var i=r.get("renderbuffer");i&&e.deleteRenderbuffer(i);var n=r.get("framebuffer");n&&e.deleteFramebuffer(n),r.deleteContext(t.__uid__),this._textures={}}});ni.DEPTH_ATTACHMENT=ri,ni.COLOR_ATTACHMENT0=ii,ni.STENCIL_ATTACHMENT=_.STENCIL_ATTACHMENT,ni.DEPTH_STENCIL_ATTACHMENT=_.DEPTH_STENCIL_ATTACHMENT;var ai=ni,oi=["px","nx","py","ny","pz","nz"],si=f.extend(function(){var t={position:new Qt,far:1e3,near:.1,texture:null,shadowMapPass:null},e=t._cameras={px:new $r({fov:90}),nx:new $r({fov:90}),py:new $r({fov:90}),ny:new $r({fov:90}),pz:new $r({fov:90}),nz:new $r({fov:90})};return e.px.lookAt(Qt.POSITIVE_X,Qt.NEGATIVE_Y),e.nx.lookAt(Qt.NEGATIVE_X,Qt.NEGATIVE_Y),e.py.lookAt(Qt.POSITIVE_Y,Qt.POSITIVE_Z),e.ny.lookAt(Qt.NEGATIVE_Y,Qt.NEGATIVE_Z),e.pz.lookAt(Qt.POSITIVE_Z,Qt.NEGATIVE_Y),e.nz.lookAt(Qt.NEGATIVE_Z,Qt.NEGATIVE_Y),t._frameBuffer=new ai,t},{getCamera:function(t){return this._cameras[t]},render:function(t,e,r){var i=t.gl;r||e.update();for(var n=this.texture.width,a=2*Math.atan(n/(n-.5))/Math.PI*180,o=0;o<6;o++){var s=oi[o],l=this._cameras[s];if(Qt.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=a,this.shadowMapPass){l.update();var h=e.getBoundingBox();h.applyTransform(l.viewMatrix),e.viewBoundingBoxLastFrame.copy(h),this.shadowMapPass.render(t,e,l,!0)}this._frameBuffer.attach(this.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._frameBuffer.bind(t),t.render(e,l,!0),this._frameBuffer.unbind(t)}},dispose:function(t){this._frameBuffer.dispose(t)}}),li=gr.extend({dynamic:!1,widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var t=this.heightSegments,e=this.widthSegments,r=this.attributes,i=[],n=[],a=[],o=[],s=0;s<=t;s++)for(var l=s/t,h=0;h<=e;h++){var u=h/e;if(i.push([2*u-1,2*l-1,0]),n&&n.push([u,l]),a&&a.push([0,0,1]),h<e&&s<t){var c=h+s*(e+1);o.push([c,c+1,c+e+1]),o.push([c+e+1,c+1,c+e+2])}}r.position.fromArray(i),r.texcoord0.fromArray(n),r.normal.fromArray(a),this.initIndicesFromArray(o),this.boundingBox=new Ie,this.boundingBox.min.set(-1,-1,0),this.boundingBox.max.set(1,1,0)}}),hi=new _e;function ui(t,e,r){hi.identity();var i=new li({widthSegments:e,heightSegments:r});switch(t){case"px":_e.translate(hi,hi,Qt.POSITIVE_X),_e.rotateY(hi,hi,Math.PI/2);break;case"nx":_e.translate(hi,hi,Qt.NEGATIVE_X),_e.rotateY(hi,hi,-Math.PI/2);break;case"py":_e.translate(hi,hi,Qt.POSITIVE_Y),_e.rotateX(hi,hi,-Math.PI/2);break;case"ny":_e.translate(hi,hi,Qt.NEGATIVE_Y),_e.rotateX(hi,hi,Math.PI/2);break;case"pz":_e.translate(hi,hi,Qt.POSITIVE_Z);break;case"nz":_e.translate(hi,hi,Qt.NEGATIVE_Z),_e.rotateY(hi,hi,Math.PI)}return i.applyTransform(hi),i}var ci=gr.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},function(){this.build()},{build:function(){var t={px:ui("px",this.depthSegments,this.heightSegments),nx:ui("nx",this.depthSegments,this.heightSegments),py:ui("py",this.widthSegments,this.depthSegments),ny:ui("ny",this.widthSegments,this.depthSegments),pz:ui("pz",this.widthSegments,this.heightSegments),nz:ui("nz",this.widthSegments,this.heightSegments)},e=["position","texcoord0","normal"],r=0,i=0;for(var n in t)r+=t[n].vertexCount,i+=t[n].indices.length;for(var a=0;a<e.length;a++)this.attributes[e[a]].init(r);this.indices=new v.a.Uint16Array(i);var o=0,s=0;for(var n in t){var l=t[n];for(a=0;a<e.length;a++)for(var h=e[a],u=l.attributes[h].value,c=l.attributes[h].size,d="normal"===h,f=0;f<u.length;f++){var p=u[f];this.inside&&d&&(p=-p),this.attributes[h].value[f+c*s]=p}var m=l.indices.length;for(f=0;f<l.indices.length;f++)this.indices[f+o]=s+l.indices[this.inside?m-f-1:f];o+=l.indices.length,s+=l.vertexCount}this.boundingBox=new Ie,this.boundingBox.max.set(1,1,1),this.boundingBox.min.set(-1,-1,-1)}});bt.import("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end");var di=Qe.extend(function(){var t=new bt({vertex:bt.source("clay.skybox.vertex"),fragment:bt.source("clay.skybox.fragment")}),e=new G({shader:t,depthMask:!1});return{scene:null,geometry:new ci,material:e,environmentMap:null,culling:!1,_dummyCamera:new $r}},function(){var t=this.scene;t&&this.attachScene(t),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)},{attachScene:function(t){this.scene&&this.detachScene(),t.skybox=this,this.scene=t,t.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&(this.scene.off("beforerender",this._beforeRenderScene),this.scene.skybox=null),this.scene=null},dispose:function(t){this.detachScene(),this.geometry.dispose(t)},setEnvironmentMap:function(t){"texture2D"===t.textureType?(this.material.define("EQUIRECTANGULAR"),t.minFilter=Ye.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",t)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(t,e,r){this.renderSkybox(t,r)},renderSkybox:function(t,e){var r=this._dummyCamera;r.aspect=t.getViewportAspect(),r.fov=e.fov||50,r.updateProjectionMatrix(),_e.invert(r.invProjectionMatrix,r.projectionMatrix),r.worldTransform.copy(e.worldTransform),r.viewMatrix.copy(e.viewMatrix),this.position.copy(e.getWorldPosition()),this.update(),t.gl.disable(t.gl.BLEND),this.material.get("lod")>0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),t.renderPass([this],r)}}),fi=di;function pi(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var mi=pi("DXT1"),gi=pi("DXT3"),_i=pi("DXT5"),vi={parse:function(t,e){var r=new Int32Array(t,0,31);if(542327876!==r[0])return null;if(4&!r(20))return null;var i,n,a=r(21),o=r[4],s=r[3],l=512&r[28],h=131072&r[2];switch(a){case mi:i=8,n=Ye.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case gi:i=16,n=Ye.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case _i:i=16,n=Ye.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var u=r[1]+4,c=l?6:1,d=1;h&&(d=Math.max(1,r[7]));for(var f=[],p=0;p<c;p++){var m=o,g=s;f[p]=new ir({width:m,height:g,format:n});for(var _=[],v=0;v<d;v++){var y=Math.max(4,m)/4*Math.max(4,g)/4*i,x=new Uint8Array(t,u,y);u+=y,m*=.5,g*=.5,_[v]=x}f[p].pixels=_[0],h&&(f[p].mipmaps=_)}if(!e)return f[0];e.width=f[0].width,e.height=f[0].height,e.format=f[0].format,e.pixels=f[0].pixels,e.mipmaps=f[0].mipmaps}},yi=String.fromCharCode,xi=8,Ti=32767;function bi(t,e,r,i){if(t[3]>0){var n=Math.pow(2,t[3]-128-8+i);e[r+0]=t[0]*n,e[r+1]=t[1]*n,e[r+2]=t[2]*n}else e[r+0]=0,e[r+1]=0,e[r+2]=0;return e[r+3]=1,e}function wi(t,e,r,i){for(var n,a,o=0,s=0,l=i;l>0;)if(t[s][0]=e[r++],t[s][1]=e[r++],t[s][2]=e[r++],t[s][3]=e[r++],1===t[s][0]&&1===t[s][1]&&1===t[s][2]){for(var h=t[s][3]<<o>>>0;h>0;h--)n=t[s-1],(a=t[s])[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],s++,l--;o+=8}else s++,l--,o=0;return r}function Si(t,e,r,i){if(i<xi|i>Ti)return wi(t,e,r,i);if(2!=(n=e[r++]))return wi(t,e,r-1,i);if(t[0][1]=e[r++],t[0][2]=e[r++],n=e[r++],(t[0][2]<<8>>>0|n)>>>0!==i)return null;for(var n=0;n<4;n++)for(var a=0;a<i;){var o=e[r++];if(o>128){o=(127&o)>>>0;for(var s=e[r++];o--;)t[a++][n]=s}else for(;o--;)t[a++][n]=e[r++]}return r}var Ei={parseRGBE:function(t,e,r){null==r&&(r=0);var i=new Uint8Array(t),n=i.length;if("#?"===function(t,e,r){for(var i="",n=e;n<r;n++)i+=yi(t[n]);return i}(i,0,2)){for(var a=2;a<n&&("\n"!==yi(i[a])||"\n"!==yi(i[a+1]));a++);if(!(a>=n)){a+=2;for(var o="";a<n;a++){var s=yi(i[a]);if("\n"===s)break;o+=s}var l=o.split(" "),h=parseInt(l[1]),u=parseInt(l[3]);if(u&&h){for(var c=a+1,d=[],f=0;f<u;f++){d[f]=[];for(var p=0;p<4;p++)d[f][p]=0}for(var m=new Float32Array(u*h*4),g=0,_=0;_<h;_++){if(!(c=Si(d,i,c,u)))return null;for(f=0;f<u;f++)bi(d[f],m,g,r),g+=4}return e||(e=new ir),e.width=u,e.height=h,e.pixels=m,e.type=Ye.FLOAT,e}}}},parseRGBEFromPNG:function(t){}},Ai={loadTexture:function(t,e,r,i){var n;if("function"==typeof e?(i=r=e,e={}):e=e||{},"string"==typeof t){if(t.match(/.hdr$/)||"hdr"===e.fileType)return n=new ir({width:0,height:0,sRGB:!1}),Ai._fetchTexture(t,function(t){Ei.parseRGBE(t,n,e.exposure),n.dirty(),r&&r(n)},i),n;t.match(/.dds$/)||"dds"===e.fileType?(n=new ir({width:0,height:0}),Ai._fetchTexture(t,function(t){vi.parse(t,n),n.dirty(),r&&r(n)},i)):((n=new ir).load(t),n.success(r),n.error(i))}else"object"==typeof t&&void 0!==t.px&&((n=new Jr).load(t),n.success(r),n.error(i));return n},loadPanorama:function(t,e,r,i,n,a){var o=this;"function"==typeof i?(a=n=i,i={}):i=i||{},Ai.loadTexture(e,i,function(e){e.flipY=i.flipY||!1,o.panoramaToCubeMap(t,e,r,i),e.dispose(t),n&&n(r)},a)},panoramaToCubeMap:function(t,e,r,i){var n=new si,a=new fi({scene:new Wr});return a.setEnvironmentMap(e),(i=i||{}).encodeRGBM&&a.material.define("fragment","RGBM_ENCODE"),r.sRGB=e.sRGB,n.texture=r,n.render(t,a.scene),n.texture=null,n.dispose(t),r},heightToNormal:function(t,e){var r=document.createElement("canvas"),i=r.width=t.width,n=r.height=t.height,a=r.getContext("2d");a.drawImage(t,0,0,i,n),e=e||!1;for(var o=a.getImageData(0,0,i,n),s=a.createImageData(i,n),l=0;l<o.data.length;l+=4){if(e){var h=o.data[l],u=o.data[l+1],c=o.data[l+2];if(Math.abs(h-u)+Math.abs(u-c)>20)return console.warn("Given image is not a height map"),t}var d,f,p,m;l%(4*i)==0?(d=o.data[l],p=o.data[l+4]):l%(4*i)==4*(i-1)?(d=o.data[l-4],p=o.data[l]):(d=o.data[l-4],p=o.data[l+4]),l<4*i?(f=o.data[l],m=o.data[l+4*i]):l>i*(n-1)*4?(f=o.data[l-4*i],m=o.data[l]):(f=o.data[l-4*i],m=o.data[l+4*i]),s.data[l]=d-p+127,s.data[l+1]=f-m+127,s.data[l+2]=255,s.data[l+3]=255}return a.putImageData(s,0,0),r},isHeightImage:function(t,e,r){if(!t||!t.width||!t.height)return!1;var i=document.createElement("canvas"),n=i.getContext("2d"),a=e||32;r=r||20,i.width=i.height=a,n.drawImage(t,0,0,a,a);for(var o=n.getImageData(0,0,a,a),s=0;s<o.data.length;s+=4){var l=o.data[s],h=o.data[s+1],u=o.data[s+2];if(Math.abs(l-h)+Math.abs(h-u)>r)return!1}return!0},_fetchTexture:function(t,e,r){v.a.request.get({url:t,responseType:"arraybuffer",onload:e,onerror:r})},createChessboard:function(t,e,r,i){t=t||512,e=e||64,r=r||"black",i=i||"white";var n=Math.ceil(t/e),a=document.createElement("canvas");a.width=t,a.height=t;var o=a.getContext("2d");o.fillStyle=i,o.fillRect(0,0,t,t),o.fillStyle=r;for(var s=0;s<n;s++)for(var l=0;l<n;l++){(l%2?s%2:s%2-1)&&o.fillRect(s*e,l*e,e,e)}return new ir({image:a,anisotropic:8})},createBlank:function(t){var e=document.createElement("canvas");e.width=1,e.height=1;var r=e.getContext("2d");return r.fillStyle=t,r.fillRect(0,0,1,1),new ir({image:e})}},Mi=Ai,Ci=["mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","contextmenu"];function Di(t){return"_on"+t}var Li=function(t){var e=this;this._texture=new ir({anisotropic:32,flipY:!1,surface:this,dispose:function(t){e.dispose(),ir.prototype.dispose.call(this,t)}}),Ci.forEach(function(t){this[Di(t)]=function(e){e.triangle&&this._meshes.forEach(function(r){this.dispatchEvent(t,r,e.triangle,e.point)},this)}},this),this._meshes=[],t&&this.setECharts(t),this.onupdate=null};Li.prototype={constructor:Li,getTexture:function(){return this._texture},setECharts:function(t){this._chart=t;var e=t.getDom();if(e instanceof HTMLCanvasElement){var r=this,i=t.getZr(),n=i.__oldRefreshImmediately||i.refreshImmediately;i.refreshImmediately=function(){n.call(this),r._texture.dirty(),r.onupdate&&r.onupdate()},i.__oldRefreshImmediately=n}else console.error("ECharts must init on canvas if it is used as texture."),e=document.createElement("canvas");this._texture.image=e,this._texture.dirty(),this.onupdate&&this.onupdate()},dispatchEvent:function(){var t=new Qt,e=new Qt,r=new Qt,i=new Z,n=new Z,a=new Z,o=new Z,s=new Qt;return function(l,h,u,c){var d=h.geometry,f=d.attributes.position,p=d.attributes.texcoord0,m=Qt.dot,g=Qt.cross;f.get(u[0],t.array),f.get(u[1],e.array),f.get(u[2],r.array),p.get(u[0],i.array),p.get(u[1],n.array),p.get(u[2],a.array),g(s,e,r);var _=m(t,s),v=m(c,s)/_;g(s,r,t);var y=m(c,s)/_;g(s,t,e);var x=m(c,s)/_;Z.scale(o,i,v),Z.scaleAndAdd(o,o,n,y),Z.scaleAndAdd(o,o,a,x);var T=o.x*this._chart.getWidth(),b=o.y*this._chart.getHeight();this._chart.getZr().handler.dispatch(l,{zrX:T,zrY:b})}}(),attachToMesh:function(t){this._meshes.indexOf(t)>=0||(Ci.forEach(function(e){t.on(e,this[Di(e)],this)},this),this._meshes.push(t))},detachFromMesh:function(t){var e=this._meshes.indexOf(t);e>=0&&this._meshes.splice(e,1),Ci.forEach(function(e){t.off(e,this[Di(e)])},this)},dispose:function(){this._meshes.forEach(function(t){this.detachFromMesh(t)},this)}};var Pi=Li,Ni=Fr.extend({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)},decomposeProjectionMatrix:function(){var t=this.projectionMatrix.array;this.left=(-1-t[12])/t[0],this.right=(1-t[12])/t[0],this.top=(1-t[13])/t[5],this.bottom=(-1-t[13])/t[5],this.near=-(-1-t[14])/t[10],this.far=-(1-t[14])/t[10]},clone:function(){var t=Fr.prototype.clone.call(this);return t.left=this.left,t.right=this.right,t.near=this.near,t.far=this.far,t.top=this.top,t.bottom=this.bottom,t}});bt.import("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");var Ri=new li,Ii=new Qe({geometry:Ri,frustumCulling:!1}),Oi=new Ni,Bi=f.extend(function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}},function(){var t=new bt(bt.source("clay.compositor.vertex"),this.fragment),e=new G({shader:t});e.enableTexturesAll(),this.material=e},{setUniform:function(t,e){this.material.setUniform(t,e)},getUniform:function(t){var e=this.material.uniforms[t];if(e)return e.value},attachOutput:function(t,e){this.outputs||(this.outputs={}),e=e||_.COLOR_ATTACHMENT0,this.outputs[e]=t},detachOutput:function(t){for(var e in this.outputs)this.outputs[e]===t&&(this.outputs[e]=null)},bind:function(t,e){if(this.outputs)for(var r in this.outputs){var i=this.outputs[r];i&&e.attach(i,r)}e&&e.bind(t)},unbind:function(t,e){e.unbind(t)},render:function(t,e){var r=t.gl;if(e){this.bind(t,e);var i=t.getGLExtension("EXT_draw_buffers");if(i&&this.outputs){var n=[];for(var a in this.outputs)(a=+a)>=r.COLOR_ATTACHMENT0&&a<=r.COLOR_ATTACHMENT0+8&&n.push(a);i.drawBuffersEXT(n)}}this.trigger("beforerender",this,t);var o=this.clearDepth?r.DEPTH_BUFFER_BIT:0;if(r.depthMask(!0),this.clearColor){o|=r.COLOR_BUFFER_BIT,r.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&r.clearColor(s[0],s[1],s[2],s[3])}r.clear(o),this.blendWithPrevious?(r.enable(r.BLEND),this.material.transparent=!0):(r.disable(r.BLEND),this.material.transparent=!1),this.renderQuad(t),this.trigger("afterrender",this,t),e&&this.unbind(t,e)},renderQuad:function(t){Ii.material=this.material,t.renderPass([Ii],Oi)},dispose:function(t){}}),Fi={},zi=["px","nx","py","ny","pz","nz"];Fi.prefilterEnvironmentMap=function(t,e,r,i,n){n&&i||(i=Fi.generateNormalDistribution(),n=Fi.integrateBRDF(t,i));var a=(r=r||{}).width||64,o=r.height||64,s=r.type||e.type,l=new Jr({width:a,height:o,type:s,flipY:!1,mipmaps:[]});l.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var h=Math.min(a,o),u=Math.log(h)/Math.log(2)+1,c=new G({shader:new bt({vertex:bt.source("clay.skybox.vertex"),fragment:"#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"})});c.set("normalDistribution",i),r.encodeRGBM&&c.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&c.define("fragment","RGBM_DECODE");var d,f=new Wr;if("texture2D"===e.textureType){var p=new Jr({width:a,height:o,type:s===Ye.FLOAT?Ye.HALF_FLOAT:s});Mi.panoramaToCubeMap(t,e,p,{encodeRGBM:r.decodeRGBM}),e=p}(d=new di({scene:f,material:c})).material.set("environmentMap",e);var m=new si({texture:l});r.encodeRGBM&&(s=l.type=Ye.UNSIGNED_BYTE);for(var g=new ir({width:a,height:o,type:s}),_=new ai({depthBuffer:!1}),y=v.a[s===Ye.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],x=0;x<u;x++){l.mipmaps[x]={pixels:{}},d.material.set("roughness",x/(u-1));for(var T=g.width,b=2*Math.atan(T/(T-.5))/Math.PI*180,w=0;w<zi.length;w++){var S=new y(g.width*g.height*4);_.attach(g),_.bind(t);var E=m.getCamera(zi[w]);E.fov=b,t.render(f,E),t.gl.readPixels(0,0,g.width,g.height,Ye.RGBA,s,S),_.unbind(t),l.mipmaps[x].pixels[zi[w]]=S}g.width/=2,g.height/=2,g.dirty()}return _.dispose(t),g.dispose(t),d.dispose(t),i.dispose(t),{environmentMap:l,brdfLookup:n,normalDistribution:i,maxMipmapLevel:u}},Fi.integrateBRDF=function(t,e){e=e||Fi.generateNormalDistribution();var r=new ai({depthBuffer:!1}),i=new Bi({fragment:"#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"}),n=new ir({width:512,height:256,type:Ye.HALF_FLOAT,wrapS:Ye.CLAMP_TO_EDGE,wrapT:Ye.CLAMP_TO_EDGE,minFilter:Ye.NEAREST,magFilter:Ye.NEAREST,useMipmap:!1});return i.setUniform("normalDistribution",e),i.setUniform("viewportSize",[512,256]),i.attachOutput(n),i.render(t,r),r.dispose(t),n},Fi.generateNormalDistribution=function(t,e){for(var r=new ir({width:t=t||256,height:e=e||1024,type:Ye.FLOAT,minFilter:Ye.NEAREST,magFilter:Ye.NEAREST,wrapS:Ye.CLAMP_TO_EDGE,wrapT:Ye.CLAMP_TO_EDGE,useMipmap:!1}),i=new Float32Array(e*t*4),n=[],a=0;a<t;a++){for(var o=a/t,s=o*o,l=0;l<e;l++){var h=(l<<16|l>>>16)>>>0;h=(((16711935&(h=((252645135&(h=((858993459&(h=((1431655765&h)<<1|(2863311530&h)>>>1)>>>0))<<2|(3435973836&h)>>>2)>>>0))<<4|(4042322160&h)>>>4)>>>0))<<8|(4278255360&h)>>>8)>>>0)/4294967296;var u=Math.sqrt((1-h)/(1+(s*s-1)*h));n[l]=u}for(l=0;l<e;l++){var c=4*(l*t+a),d=(u=n[l],Math.sqrt(1-u*u)),f=l/e,p=2*Math.PI*f;i[c]=d*Math.cos(p),i[c+1]=u,i[c+2]=d*Math.sin(p),i[c+3]=1}}return r.pixels=i,r};var Ui=Fi,ki=wr.extend({cubemap:null,castShadow:!1,_normalDistribution:null,_brdfLookup:null},{type:"AMBIENT_CUBEMAP_LIGHT",prefilter:function(t,e){if(t.getGLExtension("EXT_shader_texture_lod")){this._brdfLookup||(this._normalDistribution=Ui.generateNormalDistribution(),this._brdfLookup=Ui.integrateBRDF(t,this._normalDistribution));var r=this.cubemap;if(!r.__prefiltered){var i=Ui.prefilterEnvironmentMap(t,r,{encodeRGBM:!0,width:e,height:e},this._normalDistribution,this._brdfLookup);this.cubemap=i.environmentMap,this.cubemap.__prefiltered=!0,r.dispose(t)}}else console.warn("Device not support textureCubeLodEXT")},getBRDFLookup:function(){return this._brdfLookup},uniformTemplates:{ambientCubemapLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}},ambientCubemapLightCubemap:{type:"t",value:function(t){return t.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(t){return t._brdfLookup}}}}),Gi=wr.extend({castShadow:!1,coefficients:[]},function(){this._coefficientsTmpArr=new v.a.Float32Array(27)},{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}},ambientSHLightCoefficients:{type:"3f",value:function(t){for(var e=t._coefficientsTmpArr,r=0;r<t.coefficients.length;r++)e[r]=t.coefficients[r];return e}}}}),Hi={},Vi=["px","nx","py","ny","pz","nz"];function Wi(t,e){var r=t[0],i=t[1],n=t[2];return 0===e?1:1===e?r:2===e?i:3===e?n:4===e?r*n:5===e?i*n:6===e?r*i:7===e?3*n*n-1:r*r-i*i}var Xi={px:[2,1,0,-1,-1,1],nx:[2,1,0,1,-1,-1],py:[0,2,1,1,-1,-1],ny:[0,2,1,1,1,1],pz:[0,1,2,-1,-1,-1],nz:[0,1,2,1,-1,1]};Hi.projectEnvironmentMap=function(t,e,r){var i;(r=r||{}).lod=r.lod||0;var n=new Wr,a=64;"texture2D"===e.textureType?i=new fi({scene:n,environmentMap:e}):(a=e.image&&e.image.px?e.image.px.width:e.width,i=new di({scene:n,environmentMap:e}));var o=Math.ceil(a/Math.pow(2,r.lod)),s=Math.ceil(a/Math.pow(2,r.lod)),l=new ir({width:o,height:s}),h=new ai;i.material.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&i.material.define("fragment","RGBM_DECODE"),i.material.set("lod",r.lod);for(var u=new si({texture:l}),c={},d=0;d<Vi.length;d++){c[Vi[d]]=new Uint8Array(o*s*4);var f=u.getCamera(Vi[d]);f.fov=90,h.attach(l),h.bind(t),t.render(n,f),t.gl.readPixels(0,0,o,s,Ye.RGBA,Ye.UNSIGNED_BYTE,c[Vi[d]]),h.unbind(t)}return i.dispose(t),h.dispose(t),l.dispose(t),function(t,e,r,i){for(var n=new v.a.Float32Array(27),a=Mt.create(),o=Mt.create(),s=Mt.create(),l=0;l<9;l++){for(var h=Mt.create(),u=0;u<Vi.length;u++){for(var c=e[Vi[u]],d=Mt.create(),f=0,p=0,m=Xi[Vi[u]],g=0;g<i;g++)for(var _=0;_<r;_++){a[0]=_/(r-1)*2-1,a[1]=g/(i-1)*2-1,a[2]=-1,Mt.normalize(a,a),s[0]=a[m[0]]*m[3],s[1]=a[m[1]]*m[4],s[2]=a[m[2]]*m[5],o[0]=c[p++]/255,o[1]=c[p++]/255,o[2]=c[p++]/255;var y=c[p++]/255*8.12;o[0]*=y,o[1]*=y,o[2]*=y,Mt.scaleAndAdd(d,d,o,Wi(s,l)*-a[2]),f+=-a[2]}Mt.scaleAndAdd(h,h,d,1/f)}n[3*l]=h[0]/6,n[3*l+1]=h[1]/6,n[3*l+2]=h[2]/6}return n}(0,c,o,s)};var ji=Hi,qi={firstNotNull:function(){for(var t=0,e=arguments.length;t<e;t++)if(null!=arguments[t])return arguments[t]},queryDataIndex:function(t,e){return null!=e.dataIndexInside?e.dataIndexInside:null!=e.dataIndex?i.util.isArray(e.dataIndex)?i.util.map(e.dataIndex,function(e){return t.indexOfRawIndex(e)}):t.indexOfRawIndex(e.dataIndex):null!=e.name?i.util.isArray(e.name)?i.util.map(e.name,function(e){return t.indexOfName(e)}):t.indexOfName(e.name):void 0}},Zi=gr.extend({dynamic:!1,widthSegments:40,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},function(){this.build()},{build:function(){var t=this.heightSegments,e=this.widthSegments,r=this.attributes.position,i=this.attributes.texcoord0,n=this.attributes.normal,a=(e+1)*(t+1);r.init(a),i.init(a),n.init(a);var o,s,l,h,u,c,d,f,p,m,g,_=a>65535?Uint32Array:Uint16Array,v=this.indices=new _(e*t*6),y=this.radius,x=this.phiStart,T=this.phiLength,b=this.thetaStart,w=this.thetaLength,S=[],E=[],A=0,M=1/(y=this.radius);for(d=0;d<=t;d++)for(c=0;c<=e;c++)h=c/e,u=d/t,o=-y*Math.cos(x+h*T)*Math.sin(b+u*w),s=y*Math.cos(b+u*w),l=y*Math.sin(x+h*T)*Math.sin(b+u*w),S[0]=o,S[1]=s,S[2]=l,E[0]=h,E[1]=u,r.set(A,S),i.set(A,E),S[0]*=M,S[1]*=M,S[2]*=M,n.set(A,S),A++;var C=e+1,D=0;for(d=0;d<t;d++)for(c=0;c<e;c++)p=d*C+c,f=d*C+c+1,g=(d+1)*C+c+1,m=(d+1)*C+c,v[D++]=f,v[D++]=p,v[D++]=g,v[D++]=p,v[D++]=m,v[D++]=g;this.boundingBox=new Ie,this.boundingBox.max.set(y,y,y),this.boundingBox.min.set(-y,-y,-y)}}),Yi=wr.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}}}}),Ki=wr.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(t){return t.__dir=t.__dir||new Qt,t.__dir.copy(t.worldTransform.z).normalize().negate().array}},directionalLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}}},clone:function(){var t=wr.prototype.clone.call(this);return t.shadowBias=this.shadowBias,t.shadowSlopeScale=this.shadowSlopeScale,t}}),Qi=wr.extend({range:100,castShadow:!1},{type:"POINT_LIGHT",uniformTemplates:{pointLightPosition:{type:"3f",value:function(t){return t.getWorldPosition().array}},pointLightRange:{type:"1f",value:function(t){return t.range}},pointLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}}},clone:function(){var t=wr.prototype.clone.call(this);return t.range=this.range,t}}),Ji=wr.extend({range:20,umbraAngle:30,penumbraAngle:45,falloffFactor:2,shadowBias:.001,shadowSlopeScale:2},{type:"SPOT_LIGHT",uniformTemplates:{spotLightPosition:{type:"3f",value:function(t){return t.getWorldPosition().array}},spotLightRange:{type:"1f",value:function(t){return t.range}},spotLightUmbraAngleCosine:{type:"1f",value:function(t){return Math.cos(t.umbraAngle*Math.PI/180)}},spotLightPenumbraAngleCosine:{type:"1f",value:function(t){return Math.cos(t.penumbraAngle*Math.PI/180)}},spotLightFalloffFactor:{type:"1f",value:function(t){return t.falloffFactor}},spotLightDirection:{type:"3f",value:function(t){return t.__dir=t.__dir||new Qt,t.__dir.copy(t.worldTransform.z).negate().array}},spotLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}}},clone:function(){var t=wr.prototype.clone.call(this);return t.range=this.range,t.umbraAngle=this.umbraAngle,t.penumbraAngle=this.penumbraAngle,t.falloffFactor=this.falloffFactor,t.shadowBias=this.shadowBias,t.shadowSlopeScale=this.shadowSlopeScale,t}}),$i=function(t,e,r,i){t=t||0,e=e||0,r=r||0,i=i||0,this.array=ee.fromValues(t,e,r,i),this._dirty=!0};$i.prototype={constructor:$i,add:function(t){return ee.add(this.array,this.array,t.array),this._dirty=!0,this},set:function(t,e,r,i){return this.array[0]=t,this.array[1]=e,this.array[2]=r,this.array[3]=i,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this.array[2]=t[2],this.array[3]=t[3],this._dirty=!0,this},clone:function(){return new $i(this.x,this.y,this.z,this.w)},copy:function(t){return ee.copy(this.array,t.array),this._dirty=!0,this},dist:function(t){return ee.dist(this.array,t.array)},distance:function(t){return ee.distance(this.array,t.array)},div:function(t){return ee.div(this.array,this.array,t.array),this._dirty=!0,this},divide:function(t){return ee.divide(this.array,this.array,t.array),this._dirty=!0,this},dot:function(t){return ee.dot(this.array,t.array)},len:function(){return ee.len(this.array)},length:function(){return ee.length(this.array)},lerp:function(t,e,r){return ee.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},min:function(t){return ee.min(this.array,this.array,t.array),this._dirty=!0,this},max:function(t){return ee.max(this.array,this.array,t.array),this._dirty=!0,this},mul:function(t){return ee.mul(this.array,this.array,t.array),this._dirty=!0,this},multiply:function(t){return ee.multiply(this.array,this.array,t.array),this._dirty=!0,this},negate:function(){return ee.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return ee.normalize(this.array,this.array),this._dirty=!0,this},random:function(t){return ee.random(this.array,t),this._dirty=!0,this},scale:function(t){return ee.scale(this.array,this.array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return ee.scaleAndAdd(this.array,this.array,t.array,e),this._dirty=!0,this},sqrDist:function(t){return ee.sqrDist(this.array,t.array)},squaredDistance:function(t){return ee.squaredDistance(this.array,t.array)},sqrLen:function(){return ee.sqrLen(this.array)},squaredLength:function(){return ee.squaredLength(this.array)},sub:function(t){return ee.sub(this.array,this.array,t.array),this._dirty=!0,this},subtract:function(t){return ee.subtract(this.array,this.array,t.array),this._dirty=!0,this},transformMat4:function(t){return ee.transformMat4(this.array,this.array,t.array),this._dirty=!0,this},transformQuat:function(t){return ee.transformQuat(this.array,this.array,t.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var tn=Object.defineProperty;if(tn){var en=$i.prototype;tn(en,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),tn(en,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}}),tn(en,"z",{get:function(){return this.array[2]},set:function(t){this.array[2]=t,this._dirty=!0}}),tn(en,"w",{get:function(){return this.array[3]},set:function(t){this.array[3]=t,this._dirty=!0}})}$i.add=function(t,e,r){return ee.add(t.array,e.array,r.array),t._dirty=!0,t},$i.set=function(t,e,r,i,n){ee.set(t.array,e,r,i,n),t._dirty=!0},$i.copy=function(t,e){return ee.copy(t.array,e.array),t._dirty=!0,t},$i.distance=$i.dist=function(t,e){return ee.distance(t.array,e.array)},$i.divide=$i.div=function(t,e,r){return ee.divide(t.array,e.array,r.array),t._dirty=!0,t},$i.dot=function(t,e){return ee.dot(t.array,e.array)},$i.len=function(t){return ee.length(t.array)},$i.lerp=function(t,e,r,i){return ee.lerp(t.array,e.array,r.array,i),t._dirty=!0,t},$i.min=function(t,e,r){return ee.min(t.array,e.array,r.array),t._dirty=!0,t},$i.max=function(t,e,r){return ee.max(t.array,e.array,r.array),t._dirty=!0,t},$i.multiply=$i.mul=function(t,e,r){return ee.multiply(t.array,e.array,r.array),t._dirty=!0,t},$i.negate=function(t,e){return ee.negate(t.array,e.array),t._dirty=!0,t},$i.normalize=function(t,e){return ee.normalize(t.array,e.array),t._dirty=!0,t},$i.random=function(t,e){return ee.random(t.array,e),t._dirty=!0,t},$i.scale=function(t,e,r){return ee.scale(t.array,e.array,r),t._dirty=!0,t},$i.scaleAndAdd=function(t,e,r,i){return ee.scaleAndAdd(t.array,e.array,r.array,i),t._dirty=!0,t},$i.squaredDistance=$i.sqrDist=function(t,e){return ee.sqrDist(t.array,e.array)},$i.squaredLength=$i.sqrLen=function(t){return ee.sqrLen(t.array)},$i.subtract=$i.sub=function(t,e,r){return ee.subtract(t.array,e.array,r.array),t._dirty=!0,t},$i.transformMat4=function(t,e,r){return ee.transformMat4(t.array,e.array,r.array),t._dirty=!0,t},$i.transformQuat=function(t,e,r){return ee.transformQuat(t.array,e.array,r.array),t._dirty=!0,t};var rn=$i,nn={create:function(){var t=new H(4);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},clone:function(t){var e=new H(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},transpose:function(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},invert:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r*a-n*i;return o?(o=1/o,t[0]=a*o,t[1]=-i*o,t[2]=-n*o,t[3]=r*o,t):null},adjoint:function(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t},determinant:function(t){return t[0]*t[3]-t[2]*t[1]},multiply:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1],h=r[2],u=r[3];return t[0]=i*s+a*l,t[1]=n*s+o*l,t[2]=i*h+a*u,t[3]=n*h+o*u,t}};nn.mul=nn.multiply,nn.rotate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l+a*s,t[1]=n*l+o*s,t[2]=i*-s+a*l,t[3]=n*-s+o*l,t},nn.scale=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1];return t[0]=i*s,t[1]=n*s,t[2]=a*l,t[3]=o*l,t},nn.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2))},nn.LDU=function(t,e,r,i){return t[2]=i[2]/i[0],r[0]=i[0],r[1]=i[1],r[3]=i[3]-t[2]*r[1],[t,e,r]};var an=nn,on=function(){this.array=an.create(),this._dirty=!0};on.prototype={constructor:on,setArray:function(t){for(var e=0;e<this.array.length;e++)this.array[e]=t[e];return this._dirty=!0,this},clone:function(){return(new on).copy(this)},copy:function(t){return an.copy(this.array,t.array),this._dirty=!0,this},adjoint:function(){return an.adjoint(this.array,this.array),this._dirty=!0,this},determinant:function(){return an.determinant(this.array)},identity:function(){return an.identity(this.array),this._dirty=!0,this},invert:function(){return an.invert(this.array,this.array),this._dirty=!0,this},mul:function(t){return an.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return an.mul(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return an.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return an.multiply(this.array,t.array,this.array),this._dirty=!0,this},rotate:function(t){return an.rotate(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return an.scale(this.array,this.array,t.array),this._dirty=!0,this},transpose:function(){return an.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},on.adjoint=function(t,e){return an.adjoint(t.array,e.array),t._dirty=!0,t},on.copy=function(t,e){return an.copy(t.array,e.array),t._dirty=!0,t},on.determinant=function(t){return an.determinant(t.array)},on.identity=function(t){return an.identity(t.array),t._dirty=!0,t},on.invert=function(t,e){return an.invert(t.array,e.array),t._dirty=!0,t},on.multiply=on.mul=function(t,e,r){return an.mul(t.array,e.array,r.array),t._dirty=!0,t},on.rotate=function(t,e,r){return an.rotate(t.array,e.array,r),t._dirty=!0,t},on.scale=function(t,e,r){return an.scale(t.array,e.array,r.array),t._dirty=!0,t},on.transpose=function(t,e){return an.transpose(t.array,e.array),t._dirty=!0,t};var sn=on,ln={create:function(){var t=new H(6);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},clone:function(t){var e=new H(6);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},copy:function(t,e){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},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},invert:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=r*a-i*n;return l?(l=1/l,t[0]=a*l,t[1]=-i*l,t[2]=-n*l,t[3]=r*l,t[4]=(n*s-a*o)*l,t[5]=(i*o-r*s)*l,t):null},determinant:function(t){return t[0]*t[3]-t[1]*t[2]},multiply:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=r[0],u=r[1],c=r[2],d=r[3],f=r[4],p=r[5];return t[0]=i*h+a*u,t[1]=n*h+o*u,t[2]=i*c+a*d,t[3]=n*c+o*d,t[4]=i*f+a*p+s,t[5]=n*f+o*p+l,t}};ln.mul=ln.multiply,ln.rotate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=Math.sin(r),u=Math.cos(r);return t[0]=i*u+a*h,t[1]=n*u+o*h,t[2]=i*-h+a*u,t[3]=n*-h+o*u,t[4]=s,t[5]=l,t},ln.scale=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=r[0],u=r[1];return t[0]=i*h,t[1]=n*h,t[2]=a*u,t[3]=o*u,t[4]=s,t[5]=l,t},ln.translate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=r[0],u=r[1];return t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=i*h+a*u+s,t[5]=n*h+o*u+l,t},ln.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+1)};var hn=ln,un=function(){this.array=hn.create(),this._dirty=!0};un.prototype={constructor:un,setArray:function(t){for(var e=0;e<this.array.length;e++)this.array[e]=t[e];return this._dirty=!0,this},clone:function(){return(new un).copy(this)},copy:function(t){return hn.copy(this.array,t.array),this._dirty=!0,this},determinant:function(){return hn.determinant(this.array)},identity:function(){return hn.identity(this.array),this._dirty=!0,this},invert:function(){return hn.invert(this.array,this.array),this._dirty=!0,this},mul:function(t){return hn.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return hn.mul(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return hn.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return hn.multiply(this.array,t.array,this.array),this._dirty=!0,this},rotate:function(t){return hn.rotate(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return hn.scale(this.array,this.array,t.array),this._dirty=!0,this},translate:function(t){return hn.translate(this.array,this.array,t.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},un.copy=function(t,e){return hn.copy(t.array,e.array),t._dirty=!0,t},un.determinant=function(t){return hn.determinant(t.array)},un.identity=function(t){return hn.identity(t.array),t._dirty=!0,t},un.invert=function(t,e){return hn.invert(t.array,e.array),t._dirty=!0,t},un.multiply=un.mul=function(t,e,r){return hn.mul(t.array,e.array,r.array),t._dirty=!0,t},un.rotate=function(t,e,r){return hn.rotate(t.array,e.array,r),t._dirty=!0,t},un.scale=function(t,e,r){return hn.scale(t.array,e.array,r.array),t._dirty=!0,t},un.translate=function(t,e,r){return hn.translate(t.array,e.array,r.array),t._dirty=!0,t};var cn=un,dn=function(){this.array=se.create(),this._dirty=!0};dn.prototype={constructor:dn,setArray:function(t){for(var e=0;e<this.array.length;e++)this.array[e]=t[e];return this._dirty=!0,this},adjoint:function(){return se.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new dn).copy(this)},copy:function(t){return se.copy(this.array,t.array),this._dirty=!0,this},determinant:function(){return se.determinant(this.array)},fromMat2d:function(t){return se.fromMat2d(this.array,t.array),this._dirty=!0,this},fromMat4:function(t){return se.fromMat4(this.array,t.array),this._dirty=!0,this},fromQuat:function(t){return se.fromQuat(this.array,t.array),this._dirty=!0,this},identity:function(){return se.identity(this.array),this._dirty=!0,this},invert:function(){return se.invert(this.array,this.array),this._dirty=!0,this},mul:function(t){return se.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return se.mul(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return se.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return se.multiply(this.array,t.array,this.array),this._dirty=!0,this},rotate:function(t){return se.rotate(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return se.scale(this.array,this.array,t.array),this._dirty=!0,this},translate:function(t){return se.translate(this.array,this.array,t.array),this._dirty=!0,this},normalFromMat4:function(t){return se.normalFromMat4(this.array,t.array),this._dirty=!0,this},transpose:function(){return se.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},dn.adjoint=function(t,e){return se.adjoint(t.array,e.array),t._dirty=!0,t},dn.copy=function(t,e){return se.copy(t.array,e.array),t._dirty=!0,t},dn.determinant=function(t){return se.determinant(t.array)},dn.identity=function(t){return se.identity(t.array),t._dirty=!0,t},dn.invert=function(t,e){return se.invert(t.array,e.array),t},dn.multiply=dn.mul=function(t,e,r){return se.mul(t.array,e.array,r.array),t._dirty=!0,t},dn.fromMat2d=function(t,e){return se.fromMat2d(t.array,e.array),t._dirty=!0,t},dn.fromMat4=function(t,e){return se.fromMat4(t.array,e.array),t._dirty=!0,t},dn.fromQuat=function(t,e){return se.fromQuat(t.array,e.array),t._dirty=!0,t},dn.normalFromMat4=function(t,e){return se.normalFromMat4(t.array,e.array),t._dirty=!0,t},dn.rotate=function(t,e,r){return se.rotate(t.array,e.array,r),t._dirty=!0,t},dn.scale=function(t,e,r){return se.scale(t.array,e.array,r.array),t._dirty=!0,t},dn.transpose=function(t,e){return se.transpose(t.array,e.array),t._dirty=!0,t},dn.translate=function(t,e,r){return se.translate(t.array,e.array,r.array),t._dirty=!0,t};var fn=dn,pn={linear:function(t){return t},quadraticIn:function(t){return t*t},quadraticOut:function(t){return t*(2-t)},quadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quarticIn:function(t){return t*t*t*t},quarticOut:function(t){return 1- --t*t*t*t},quarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quinticIn:function(t){return t*t*t*t*t},quinticOut:function(t){return--t*t*t*t*t+1},quinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},sinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},sinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},exponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},exponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},exponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))},circularIn:function(t){return 1-Math.sqrt(1-t*t)},circularOut:function(t){return Math.sqrt(1- --t*t)},circularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),-r*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4))},elasticOut:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),r*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)},elasticInOut:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),(t*=2)<1?r*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:r*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)},bounceIn:function(t){return 1-pn.bounceOut(1-t)},bounceOut:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bounceInOut:function(t){return t<.5?.5*pn.bounceIn(2*t):.5*pn.bounceOut(2*t-1)+.5}},mn=pn,gn=function(){function t(t){this._initialized=!1,this._startTime=0,this._pausedTime=0,this._paused=!1,this._life=t.life||1e3,this._delay=t.delay||0,this.loop=null!=t.loop&&t.loop,this.gap=t.gap||0,this.easing=t.easing||"linear",this.onframe=t.onframe,this.ondestroy=t.ondestroy,this.onrestart=t.onrestart}return t.prototype.step=function(t,e){if(this._initialized||(this._startTime=t+this._delay,this._initialized=!0),!this._paused){var r=(t-this._startTime-this._pausedTime)/this._life;r<0&&(r=0),r=Math.min(r,1);var i=this.easing,n="string"==typeof i?mn[i]:i,a="function"==typeof n?n(r):r;if(this.onframe&&this.onframe(a),1===r){if(!this.loop)return!0;this._restart(t),this.onrestart&&this.onrestart()}return!1}this._pausedTime+=e},t.prototype._restart=function(t){var e=(t-this._startTime-this._pausedTime)%this._life;this._startTime=t-e+this.gap,this._pausedTime=0},t.prototype.pause=function(){this._paused=!0},t.prototype.resume=function(){this._paused=!1},t}(),_n={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]};function vn(t){return(t=Math.round(t))<0?0:t>255?255:t}function yn(t){return t<0?0:t>1?1:t}function xn(t){var e=t;return e.length&&"%"===e.charAt(e.length-1)?vn(parseFloat(e)/100*255):vn(parseInt(e,10))}function Tn(t){var e=t;return e.length&&"%"===e.charAt(e.length-1)?yn(parseFloat(e)/100):yn(parseFloat(e))}function bn(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}function wn(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t}function Sn(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}var En=new qr(20),An=null;function Mn(t,e){An&&Sn(An,e),An=En.put(t,An||e.slice())}function Cn(t,e){if(t){e=e||[];var r=En.get(t);if(r)return Sn(e,r);var i=(t+="").replace(/ /g,"").toLowerCase();if(i in _n)return Sn(e,_n[i]),Mn(t,e),e;var n,a=i.length;if("#"===i.charAt(0))return 4===a||5===a?(n=parseInt(i.slice(1,4),16))>=0&&n<=4095?(wn(e,(3840&n)>>4|(3840&n)>>8,240&n|(240&n)>>4,15&n|(15&n)<<4,5===a?parseInt(i.slice(4),16)/15:1),Mn(t,e),e):void wn(e,0,0,0,1):7===a||9===a?(n=parseInt(i.slice(1,7),16))>=0&&n<=16777215?(wn(e,(16711680&n)>>16,(65280&n)>>8,255&n,9===a?parseInt(i.slice(7),16)/255:1),Mn(t,e),e):void wn(e,0,0,0,1):void 0;var o=i.indexOf("("),s=i.indexOf(")");if(-1!==o&&s+1===a){var l=i.substr(0,o),h=i.substr(o+1,s-(o+1)).split(","),u=1;switch(l){case"rgba":if(4!==h.length)return 3===h.length?wn(e,+h[0],+h[1],+h[2],1):wn(e,0,0,0,1);u=Tn(h.pop());case"rgb":return 3!==h.length?void wn(e,0,0,0,1):(wn(e,xn(h[0]),xn(h[1]),xn(h[2]),u),Mn(t,e),e);case"hsla":return 4!==h.length?void wn(e,0,0,0,1):(h[3]=Tn(h[3]),Dn(h,e),Mn(t,e),e);case"hsl":return 3!==h.length?void wn(e,0,0,0,1):(Dn(h,e),Mn(t,e),e);default:return}}wn(e,0,0,0,1)}}function Dn(t,e){var r=(parseFloat(t[0])%360+360)%360/360,i=Tn(t[1]),n=Tn(t[2]),a=n<=.5?n*(i+1):n+i-n*i,o=2*n-a;return wn(e=e||[],vn(255*bn(o,a,r+1/3)),vn(255*bn(o,a,r)),vn(255*bn(o,a,r-1/3)),1),4===t.length&&(e[3]=t[3]),e}function Ln(t,e){if(t&&t.length){var r=t[0]+","+t[1]+","+t[2];return"rgba"!==e&&"hsva"!==e&&"hsla"!==e||(r+=","+t[3]),e+"("+r+")"}}function Pn(t,e){var r=Cn(t);return r?(.299*r[0]+.587*r[1]+.114*r[2])*r[3]/255+(1-r[3])*e:0}var Nn={"[object Function]":!0,"[object RegExp]":!0,"[object Date]":!0,"[object Error]":!0,"[object CanvasGradient]":!0,"[object CanvasPattern]":!0,"[object Image]":!0,"[object Canvas]":!0},Rn={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0},In=Object.prototype.toString,On=Array.prototype,Bn=On.forEach,Fn=On.filter,zn=On.slice,Un=On.map,kn=function(){}.constructor,Gn=kn?kn.prototype:null,Hn={};var Vn=2311;function Wn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];"undefined"!=typeof console&&console.error.apply(t)}function Xn(t){if(null==t||"object"!=typeof t)return t;var e=t,r=In.call(t);if("[object Array]"===r){if(!_a(t)){e=[];for(var i=0,n=t.length;i<n;i++)e[i]=Xn(t[i])}}else if(Rn[r]){if(!_a(t)){var a=t.constructor;if(a.from)e=a.from(t);else{e=new a(t.length);for(i=0,n=t.length;i<n;i++)e[i]=Xn(t[i])}}}else if(!Nn[r]&&!_a(t)&&!ha(t))for(var o in e={},t)t.hasOwnProperty(o)&&(e[o]=Xn(t[o]));return e}function jn(t,e,r){if(!sa(e)||!sa(t))return r?Xn(e):t;for(var i in e)if(e.hasOwnProperty(i)){var n=t[i],a=e[i];!sa(a)||!sa(n)||na(a)||na(n)||ha(a)||ha(n)||la(a)||la(n)||_a(a)||_a(n)?!r&&i in t||(t[i]=Xn(e[i])):jn(n,a,r)}return t}function qn(t,e){if(Object.assign)Object.assign(t,e);else for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function Zn(t,e,r){for(var i=ra(e),n=0;n<i.length;n++){var a=i[n];(r?null!=e[a]:null==t[a])&&(t[a]=e[a])}return t}var Yn=function(){return Hn.createCanvas()};function Kn(t,e){if(t){if(t.indexOf)return t.indexOf(e);for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r}return-1}function Qn(t,e,r){if(t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,Object.getOwnPropertyNames)for(var i=Object.getOwnPropertyNames(e),n=0;n<i.length;n++){var a=i[n];"constructor"!==a&&(r?null!=e[a]:null==t[a])&&(t[a]=e[a])}else Zn(t,e,r)}function Jn(t){return!!t&&("string"!=typeof t&&"number"==typeof t.length)}function $n(t,e,r){if(t&&e)if(t.forEach&&t.forEach===Bn)t.forEach(e,r);else if(t.length===+t.length)for(var i=0,n=t.length;i<n;i++)e.call(r,t[i],i,t);else for(var a in t)t.hasOwnProperty(a)&&e.call(r,t[a],a,t)}function ta(t,e,r){if(!t)return[];if(!e)return da(t);if(t.map&&t.map===Un)return t.map(e,r);for(var i=[],n=0,a=t.length;n<a;n++)i.push(e.call(r,t[n],n,t));return i}function ea(t,e,r,i){if(t&&e){for(var n=0,a=t.length;n<a;n++)r=e.call(i,r,t[n],n,t);return r}}function ra(t){if(!t)return[];if(Object.keys)return Object.keys(t);var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e}Hn.createCanvas=function(){return document.createElement("canvas")};Gn&&aa(Gn.bind)&&Gn.call.bind(Gn.bind);function ia(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return function(){return t.apply(this,e.concat(zn.call(arguments)))}}function na(t){return Array.isArray?Array.isArray(t):"[object Array]"===In.call(t)}function aa(t){return"function"==typeof t}function oa(t){return"string"==typeof t}function sa(t){var e=typeof t;return"function"===e||!!t&&"object"===e}function la(t){return!!Nn[In.call(t)]}function ha(t){return"object"==typeof t&&"number"==typeof t.nodeType&&"object"==typeof t.ownerDocument}function ua(t,e){return null!=t?t:e}function ca(t,e,r){return null!=t?t:null!=e?e:r}function da(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return zn.apply(t,e)}function fa(t){if("number"==typeof t)return[t,t,t,t];var e=t.length;return 2===e?[t[0],t[1],t[0],t[1]]:3===e?[t[0],t[1],t[2],t[1]]:t}function pa(t,e){if(!t)throw new Error(e)}function ma(t){return null==t?null:"function"==typeof t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}var ga="__ec_primitive__";function _a(t){return t[ga]}var va=function(){function t(e){this.data={};var r=na(e);this.data={};var i=this;function n(t,e){r?i.set(t,e):i.set(e,t)}e instanceof t?e.each(n):e&&$n(e,n)}return t.prototype.get=function(t){return this.data.hasOwnProperty(t)?this.data[t]:null},t.prototype.set=function(t,e){return this.data[t]=e},t.prototype.each=function(t,e){for(var r in this.data)this.data.hasOwnProperty(r)&&t.call(e,this.data[r],r)},t.prototype.keys=function(){return ra(this.data)},t.prototype.removeKey=function(t){delete this.data[t]},t}();function ya(t){return new va(t)}function xa(t,e){for(var r=new t.constructor(t.length+e.length),i=0;i<t.length;i++)r[i]=t[i];var n=t.length;for(i=0;i<e.length;i++)r[i+n]=e[i];return r}function Ta(t,e){var r;if(Object.create)r=Object.create(t);else{var i=function(){};i.prototype=t,r=new i}return e&&qn(r,e),r}var ba=Array.prototype.slice;function wa(t,e,r){return(e-t)*r+t}function Sa(t,e,r,i){for(var n=e.length,a=0;a<n;a++)t[a]=wa(e[a],r[a],i)}function Ea(t,e,r,i){for(var n=e.length,a=0;a<n;a++)t[a]=e[a]+r[a]*i;return t}function Aa(t,e,r,i){for(var n=e.length,a=n&&e[0].length,o=0;o<n;o++){t[o]||(t[o]=[]);for(var s=0;s<a;s++)t[o][s]=e[o][s]+r[o][s]*i}return t}function Ma(t,e,r){var i=t,n=e;if(i.push&&n.push){var a=i.length,o=n.length;if(a!==o)if(a>o)i.length=o;else for(var s=a;s<o;s++)i.push(1===r?n[s]:ba.call(n[s]));var l=i[0]&&i[0].length;for(s=0;s<i.length;s++)if(1===r)isNaN(i[s])&&(i[s]=n[s]);else for(var h=0;h<l;h++)isNaN(i[s][h])&&(i[s][h]=n[s][h])}}function Ca(t,e){var r=t.length;if(r!==e.length)return!1;for(var i=0;i<r;i++)if(t[i]!==e[i])return!1;return!0}function Da(t,e,r,i,n,a,o){var s=.5*(r-t),l=.5*(i-e);return(2*(e-r)+s+l)*o+(-3*(e-r)-2*s-l)*a+s*n+e}function La(t,e,r,i,n,a,o,s){for(var l=e.length,h=0;h<l;h++)t[h]=Da(e[h],r[h],i[h],n[h],a,o,s)}function Pa(t){if(Jn(t)){var e=t.length;if(Jn(t[0])){for(var r=[],i=0;i<e;i++)r.push(ba.call(t[i]));return r}return ba.call(t)}return t}function Na(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.floor(t[2]),"rgba("+t.join(",")+")"}var Ra=[0,0,0,0],Ia=function(){function t(t){this.keyframes=[],this.maxTime=0,this.arrDim=0,this.interpolable=!0,this._needsSort=!1,this._isAllValueEqual=!0,this._lastFrame=0,this._lastFramePercent=0,this.propName=t}return t.prototype.isFinished=function(){return this._finished},t.prototype.setFinished=function(){this._finished=!0,this._additiveTrack&&this._additiveTrack.setFinished()},t.prototype.needsAnimate=function(){return!this._isAllValueEqual&&this.keyframes.length>=2&&this.interpolable},t.prototype.getAdditiveTrack=function(){return this._additiveTrack},t.prototype.addKeyframe=function(t,e){t>=this.maxTime?this.maxTime=t:this._needsSort=!0;var r=this.keyframes,i=r.length;if(this.interpolable)if(Jn(e)){var n=function(t){return Jn(t&&t[0])?2:1}(e);if(i>0&&this.arrDim!==n)return void(this.interpolable=!1);if(1===n&&"number"!=typeof e[0]||2===n&&"number"!=typeof e[0][0])return void(this.interpolable=!1);if(i>0){var a=r[i-1];this._isAllValueEqual&&(1===n&&Ca(e,a.value)||(this._isAllValueEqual=!1))}this.arrDim=n}else{if(this.arrDim>0)return void(this.interpolable=!1);if("string"==typeof e){var o=Cn(e);o?(e=o,this.isValueColor=!0):this.interpolable=!1}else if("number"!=typeof e)return void(this.interpolable=!1);if(this._isAllValueEqual&&i>0){a=r[i-1];this.isValueColor&&!Ca(a.value,e)?this._isAllValueEqual=!1:a.value!==e&&(this._isAllValueEqual=!1)}}var s={time:t,value:e,percent:0};return this.keyframes.push(s),s},t.prototype.prepare=function(t){var e=this.keyframes;this._needsSort&&e.sort(function(t,e){return t.time-e.time});for(var r=this.arrDim,i=e.length,n=e[i-1],a=0;a<i;a++)e[a].percent=e[a].time/this.maxTime,r>0&&a!==i-1&&Ma(e[a].value,n.value,r);if(t&&this.needsAnimate()&&t.needsAnimate()&&r===t.arrDim&&this.isValueColor===t.isValueColor&&!t._finished){this._additiveTrack=t;var o=e[0].value;for(a=0;a<i;a++)0===r?this.isValueColor?e[a].additiveValue=Ea([],e[a].value,o,-1):e[a].additiveValue=e[a].value-o:1===r?e[a].additiveValue=Ea([],e[a].value,o,-1):2===r&&(e[a].additiveValue=Aa([],e[a].value,o,-1))}},t.prototype.step=function(t,e){if(!this._finished){this._additiveTrack&&this._additiveTrack._finished&&(this._additiveTrack=null);var r,i=null!=this._additiveTrack,n=i?"additiveValue":"value",a=this.keyframes,o=this.keyframes.length,s=this.propName,l=this.arrDim,h=this.isValueColor;if(e<0)r=0;else if(e<this._lastFramePercent){for(r=Math.min(this._lastFrame+1,o-1);r>=0&&!(a[r].percent<=e);r--);r=Math.min(r,o-2)}else{for(r=this._lastFrame;r<o&&!(a[r].percent>e);r++);r=Math.min(r-1,o-2)}var u=a[r+1],c=a[r];if(c&&u){this._lastFrame=r,this._lastFramePercent=e;var d=u.percent-c.percent;if(0!==d){var f=(e-c.percent)/d,p=i?this._additiveValue:h?Ra:t[s];if((l>0||h)&&!p&&(p=this._additiveValue=[]),this.useSpline){var m=a[r][n],g=a[0===r?r:r-1][n],_=a[r>o-2?o-1:r+1][n],v=a[r>o-3?o-1:r+2][n];if(l>0)1===l?La(p,g,m,_,v,f,f*f,f*f*f):function(t,e,r,i,n,a,o,s){for(var l=e.length,h=e[0].length,u=0;u<l;u++){t[u]||(t[1]=[]);for(var c=0;c<h;c++)t[u][c]=Da(e[u][c],r[u][c],i[u][c],n[u][c],a,o,s)}}(p,g,m,_,v,f,f*f,f*f*f);else if(h)La(p,g,m,_,v,f,f*f,f*f*f),i||(t[s]=Na(p));else{var y=void 0;y=this.interpolable?Da(g,m,_,v,f,f*f,f*f*f):_,i?this._additiveValue=y:t[s]=y}}else if(l>0)1===l?Sa(p,c[n],u[n],f):function(t,e,r,i){for(var n=e.length,a=n&&e[0].length,o=0;o<n;o++){t[o]||(t[o]=[]);for(var s=0;s<a;s++)t[o][s]=wa(e[o][s],r[o][s],i)}}(p,c[n],u[n],f);else if(h)Sa(p,c[n],u[n],f),i||(t[s]=Na(p));else{y=void 0;y=this.interpolable?wa(c[n],u[n],f):function(t,e,r){return r>.5?e:t}(c[n],u[n],f),i?this._additiveValue=y:t[s]=y}i&&this._addToTarget(t)}}}},t.prototype._addToTarget=function(t){var e=this.arrDim,r=this.propName,i=this._additiveValue;0===e?this.isValueColor?(Cn(t[r],Ra),Ea(Ra,Ra,i,1),t[r]=Na(Ra)):t[r]=t[r]+i:1===e?Ea(t[r],t[r],i,1):2===e&&Aa(t[r],t[r],i,1)},t}(),Oa=function(){function t(t,e,r){this._tracks={},this._trackKeys=[],this._delay=0,this._maxTime=0,this._paused=!1,this._started=0,this._clip=null,this._target=t,this._loop=e,e?Wn("Can' use additive animation on looped animation."):this._additiveAnimators=r}return t.prototype.getTarget=function(){return this._target},t.prototype.changeTarget=function(t){this._target=t},t.prototype.when=function(t,e){return this.whenWithKeys(t,e,ra(e))},t.prototype.whenWithKeys=function(t,e,r){for(var i=this._tracks,n=0;n<r.length;n++){var a=r[n],o=i[a];if(!o){o=i[a]=new Ia(a);var s=void 0,l=this._getAdditiveTrack(a);if(l){var h=l.keyframes[l.keyframes.length-1];s=h&&h.value,l.isValueColor&&s&&(s=Na(s))}else s=this._target[a];if(null==s)continue;0!==t&&o.addKeyframe(0,Pa(s)),this._trackKeys.push(a)}o.addKeyframe(t,Pa(e[a]))}return this._maxTime=Math.max(this._maxTime,t),this},t.prototype.pause=function(){this._clip.pause(),this._paused=!0},t.prototype.resume=function(){this._clip.resume(),this._paused=!1},t.prototype.isPaused=function(){return!!this._paused},t.prototype._doneCallback=function(){this._setTracksFinished(),this._clip=null;var t=this._doneList;if(t)for(var e=t.length,r=0;r<e;r++)t[r].call(this)},t.prototype._abortedCallback=function(){this._setTracksFinished();var t=this.animation,e=this._abortedList;if(t&&t.removeClip(this._clip),this._clip=null,e)for(var r=0;r<e.length;r++)e[r].call(this)},t.prototype._setTracksFinished=function(){for(var t=this._tracks,e=this._trackKeys,r=0;r<e.length;r++)t[e[r]].setFinished()},t.prototype._getAdditiveTrack=function(t){var e,r=this._additiveAnimators;if(r)for(var i=0;i<r.length;i++){var n=r[i].getTrack(t);n&&(e=n)}return e},t.prototype.start=function(t,e){if(!(this._started>0)){this._started=1;for(var r=this,i=[],n=0;n<this._trackKeys.length;n++){var a=this._trackKeys[n],o=this._tracks[a],s=this._getAdditiveTrack(a),l=o.keyframes;if(o.prepare(s),o.needsAnimate())i.push(o);else if(!o.interpolable){var h=l[l.length-1];h&&(r._target[o.propName]=h.value)}}if(i.length||e){var u=new gn({life:this._maxTime,loop:this._loop,delay:this._delay,onframe:function(t){r._started=2;var e=r._additiveAnimators;if(e){for(var n=!1,a=0;a<e.length;a++)if(e[a]._clip){n=!0;break}n||(r._additiveAnimators=null)}for(a=0;a<i.length;a++)i[a].step(r._target,t);var o=r._onframeList;if(o)for(a=0;a<o.length;a++)o[a](r._target,t)},ondestroy:function(){r._doneCallback()}});this._clip=u,this.animation&&this.animation.addClip(u),t&&"spline"!==t&&(u.easing=t)}else this._doneCallback();return this}},t.prototype.stop=function(t){if(this._clip){var e=this._clip;t&&e.onframe(1),this._abortedCallback()}},t.prototype.delay=function(t){return this._delay=t,this},t.prototype.during=function(t){return t&&(this._onframeList||(this._onframeList=[]),this._onframeList.push(t)),this},t.prototype.done=function(t){return t&&(this._doneList||(this._doneList=[]),this._doneList.push(t)),this},t.prototype.aborted=function(t){return t&&(this._abortedList||(this._abortedList=[]),this._abortedList.push(t)),this},t.prototype.getClip=function(){return this._clip},t.prototype.getTrack=function(t){return this._tracks[t]},t.prototype.stopTracks=function(t,e){if(!t.length||!this._clip)return!0;for(var r=this._tracks,i=this._trackKeys,n=0;n<t.length;n++){var a=r[t[n]];a&&(e?a.step(this._target,1):1===this._started&&a.step(this._target,0),a.setFinished())}var o=!0;for(n=0;n<i.length;n++)if(!r[i[n]].isFinished()){o=!1;break}return o&&this._abortedCallback(),o},t.prototype.saveFinalToTarget=function(t,e){if(t){e=e||this._trackKeys;for(var r=0;r<e.length;r++){var i=e[r],n=this._tracks[i];if(n&&!n.isFinished()){var a=n.keyframes,o=a[a.length-1];if(o){var s=Pa(o.value);n.isValueColor&&(s=Na(s)),t[i]=s}}}}},t.prototype.__changeFinalValue=function(t,e){e=e||ra(t);for(var r=0;r<e.length;r++){var i=e[r],n=this._tracks[i];if(n){var a=n.keyframes;if(a.length>1){var o=a.pop();n.addKeyframe(o.time,t[i]),n.prepare(n.getAdditiveTrack())}}}},t}(),Ba={_animators:null,getAnimators:function(){return this._animators=this._animators||[],this._animators},animate:function(t,e){this._animators=this._animators||[];var r;if(t){for(var i=t.split("."),n=this,a=0,o=i.length;a<o;a++)n&&(n=n[i[a]]);n&&(r=n)}else r=this;if(null==r)throw new Error("Target "+t+" not exists");var s=this._animators,l=new Oa(r,e),h=this;return l.during(function(){h.__zr&&h.__zr.refresh()}).done(function(){var t=s.indexOf(l);t>=0&&s.splice(t,1)}),s.push(l),this.__zr&&this.__zr.animation.addAnimator(l),l},stopAnimation:function(t){this._animators=this._animators||[];for(var e=this._animators,r=e.length,i=0;i<r;i++)e[i].stop(t);return e.length=0,this},addAnimatorsToZr:function(t){if(this._animators)for(var e=0;e<this._animators.length;e++)t.animation.addAnimator(this._animators[e])},removeAnimatorsFromZr:function(t){if(this._animators)for(var e=0;e<this._animators.length;e++)t.animation.removeAnimator(this._animators[e])}};function Fa(t){return t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof Image}Object.assign(Be.prototype,Ba),bt.import("\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end"),bt.import(wt),bt.import("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"),bt.import("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\nattribute vec3 normal: NORMAL;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nvarying vec3 v_Normal;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"),bt.import("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),bt.import("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),bt.import("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"),bt.import("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");var za=Wr.prototype.addToScene,Ua=Wr.prototype.removeFromScene;Wr.prototype.addToScene=function(t){if(za.call(this,t),this.__zr){var e=this.__zr;t.traverse(function(t){t.__zr=e,t.addAnimatorsToZr&&t.addAnimatorsToZr(e)})}},Wr.prototype.removeFromScene=function(t){Ua.call(this,t),t.traverse(function(t){var e=t.__zr;t.__zr=null,e&&t.removeAnimatorsFromZr&&t.removeAnimatorsFromZr(e)})},G.prototype.setTextureImage=function(t,e,r,i){if(this.shader){var n,a,o=r.getZr(),s=this;return s.autoUpdateTextureStatus=!1,s.disableTexture(t),(a=e)&&"none"!==a&&(n=ka.loadTexture(e,r,i,function(e){s.enableTexture(t),o&&o.refresh()}),s.set(t,n)),n}};var ka={};ka.Renderer=zt,ka.Node=Be,ka.Mesh=Qe,ka.Shader=bt,ka.Material=G,ka.Texture=Ye,ka.Texture2D=ir,ka.Geometry=gr,ka.SphereGeometry=Zi,ka.PlaneGeometry=li,ka.CubeGeometry=ci,ka.AmbientLight=Yi,ka.DirectionalLight=Ki,ka.PointLight=Qi,ka.SpotLight=Ji,ka.PerspectiveCamera=$r,ka.OrthographicCamera=Ni,ka.Vector2=Z,ka.Vector3=Qt,ka.Vector4=rn,ka.Quaternion=Me,ka.Matrix2=sn,ka.Matrix2d=cn,ka.Matrix3=fn,ka.Matrix4=_e,ka.Plane=Ar,ka.Ray=$t,ka.BoundingBox=Ie,ka.Frustum=Br;var Ga=Mi.createBlank("rgba(255,255,255,0)").image;function Ha(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function Va(t){if((t.wrapS===Ye.REPEAT||t.wrapT===Ye.REPEAT)&&t.image){var e=Ha(t.width),r=Ha(t.height);if(e!==t.width||r!==t.height){var i=document.createElement("canvas");i.width=e,i.height=r,i.getContext("2d").drawImage(t.image,0,0,e,r),t.image=i}}}ka.loadTexture=function(t,e,r,i){"function"==typeof r&&(i=r,r={}),r=r||{};for(var n=Object.keys(r).sort(),a="",o=0;o<n.length;o++)a+=n[o]+"_"+r[n[o]]+"_";var s,l=e.__textureCache=e.__textureCache||new qr(20);if((s=t).getZr&&s.setOption){var h=t.__textureid__;if(c=l.get(a+h))c.texture.surface.setECharts(t),i&&i(c.texture);else{var u=new Pi(t);u.onupdate=function(){e.getZr().refresh()},c={texture:u.getTexture()};for(o=0;o<n.length;o++)c.texture[n[o]]=r[n[o]];h=t.__textureid__||"__ecgl_ec__"+c.texture.__uid__,t.__textureid__=h,l.put(a+h,c),i&&i(c.texture)}return c.texture}if(Fa(t)){var c;h=t.__textureid__;if(!(c=l.get(a+h))){c={texture:new ka.Texture2D({image:t})};for(o=0;o<n.length;o++)c.texture[n[o]]=r[n[o]];h=t.__textureid__||"__ecgl_image__"+c.texture.__uid__,t.__textureid__=h,l.put(a+h,c),Va(c.texture),i&&i(c.texture)}return c.texture}if(c=l.get(a+t))c.callbacks?c.callbacks.push(i):i&&i(c.texture);else if(t.match(/.hdr$|^data:application\/octet-stream/)){c={callbacks:[i]};var d=Mi.loadTexture(t,{exposure:r.exposure,fileType:"hdr"},function(){d.dirty(),c.callbacks.forEach(function(t){t&&t(d)}),c.callbacks=null});c.texture=d,l.put(a+t,c)}else{for(d=new ka.Texture2D({image:new Image}),o=0;o<n.length;o++)d[n[o]]=r[n[o]];c={texture:d,callbacks:[i]};var f=d.image;f.onload=function(){d.image=f,Va(d),d.dirty(),c.callbacks.forEach(function(t){t&&t(d)}),c.callbacks=null},f.src=t,d.image=Ga,l.put(a+t,c)}return c.texture},ka.createAmbientCubemap=function(t,e,r,i){var n=(t=t||{}).texture,a=qi.firstNotNull(t.exposure,1),o=new ki({intensity:qi.firstNotNull(t.specularIntensity,1)}),s=new Gi({intensity:qi.firstNotNull(t.diffuseIntensity,1),coefficients:[.844,.712,.691,-.037,.083,.167,.343,.288,.299,-.041,-.021,-.009,-.003,-.041,-.064,-.011,-.007,-.004,-.031,.034,.081,-.06,-.049,-.06,.046,.056,.05]});return o.cubemap=ka.loadTexture(n,r,{exposure:a},function(){o.cubemap.flipY=!1,o.prefilter(e,32),s.coefficients=ji.projectEnvironmentMap(e,o.cubemap,{lod:1}),i&&i()}),{specular:o,diffuse:s}},ka.createBlankTexture=Mi.createBlank,ka.isImage=Fa,ka.additiveBlend=function(t){t.blendEquation(t.FUNC_ADD),t.blendFunc(t.SRC_ALPHA,t.ONE)},ka.parseColor=function(t,e){return t instanceof Array?(e||(e=[]),e[0]=t[0],e[1]=t[1],e[2]=t[2],t.length>3?e[3]=t[3]:e[3]=1,e):((e=i.color.parse(t||"#000",e)||[0,0,0,0])[0]/=255,e[1]/=255,e[2]/=255,e)},ka.directionFromAlphaBeta=function(t,e){var r=t/180*Math.PI+Math.PI/2,i=-e/180*Math.PI+Math.PI/2,n=[],a=Math.sin(r);return n[0]=a*Math.cos(i),n[1]=-Math.cos(r),n[2]=a*Math.sin(i),n},ka.getShadowResolution=function(t){var e=1024;switch(t){case"low":e=512;break;case"medium":break;case"high":e=2048;break;case"ultra":e=4096}return e},ka.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"],ka.createShader=function(t){"ecgl.shadow"===t&&(t="ecgl.displayShadow");var e=bt.source(t+".vertex"),r=bt.source(t+".fragment");e||console.error("Vertex shader of '%s' not exits",t),r||console.error("Fragment shader of '%s' not exits",t);var i=new bt(e,r);return i.name=t,i},ka.createMaterial=function(t,e){e instanceof Array||(e=[e]);var r=ka.createShader(t),i=new G({shader:r});return e.forEach(function(t){"string"==typeof t&&i.define(t)}),i},ka.setMaterialFromModel=function(t,e,r,i){e.autoUpdateTextureStatus=!1;var n=r.getModel(t+"Material"),a=n.get("detailTexture"),o=qi.firstNotNull(n.get("textureTiling"),1),s=qi.firstNotNull(n.get("textureOffset"),0);"number"==typeof o&&(o=[o,o]),"number"==typeof s&&(s=[s,s]);var l=o[0]>1||o[1]>1?ka.Texture.REPEAT:ka.Texture.CLAMP_TO_EDGE,h={anisotropic:8,wrapS:l,wrapT:l};if("realistic"===t){var u=n.get("roughness"),c=n.get("metalness");null!=c?isNaN(c)&&(e.setTextureImage("metalnessMap",c,i,h),c=qi.firstNotNull(n.get("metalnessAdjust"),.5)):c=0,null!=u?isNaN(u)&&(e.setTextureImage("roughnessMap",u,i,h),u=qi.firstNotNull(n.get("roughnessAdjust"),.5)):u=.5;var d=n.get("normalTexture");e.setTextureImage("detailMap",a,i,h),e.setTextureImage("normalMap",d,i,h),e.set({roughness:u,metalness:c,detailUvRepeat:o,detailUvOffset:s})}else if("lambert"===t)e.setTextureImage("detailMap",a,i,h),e.set({detailUvRepeat:o,detailUvOffset:s});else if("color"===t)e.setTextureImage("detailMap",a,i,h),e.set({detailUvRepeat:o,detailUvOffset:s});else if("hatching"===t){var f=n.get("hatchingTextures")||[];f.length;for(var p=0;p<6;p++)e.setTextureImage("hatch"+(p+1),f[p],i,{anisotropic:8,wrapS:ka.Texture.REPEAT,wrapT:ka.Texture.REPEAT});e.set({detailUvRepeat:o,detailUvOffset:s})}},ka.updateVertexAnimation=function(t,e,r,i){var n=i.get("animation"),a=i.get("animationDurationUpdate"),o=i.get("animationEasingUpdate"),s=r.shadowDepthMaterial;if(n&&e&&a>0&&e.geometry.vertexCount===r.geometry.vertexCount){r.material.define("vertex","VERTEX_ANIMATION"),r.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var l=0;l<t.length;l++)r.geometry.attributes[t[l][0]].value=e.geometry.attributes[t[l][1]].value;r.geometry.dirty(),r.__percent=0,r.material.set("percent",0),r.stopAnimation(),r.animate().when(a,{__percent:1}).during(function(){r.material.set("percent",r.__percent),s&&s.set("percent",r.__percent)}).done(function(){r.ignorePreZ=!1,r.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")}).start(o)}else r.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")};var Wa=ka,Xa="undefined"!=typeof window&&(window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.msRequestAnimationFrame&&window.msRequestAnimationFrame.bind(window)||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(t){return setTimeout(t,16)},ja=function(t,e){this.id=t,this.zr=e;try{this.renderer=new zt({clearBit:0,devicePixelRatio:e.painter.dpr,preserveDrawingBuffer:!0,premultipliedAlpha:!0}),this.renderer.resize(e.painter.getWidth(),e.painter.getHeight())}catch(t){return this.renderer=null,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute; left: 0; top: 0; right: 0; bottom: 0;",this.dom.className="ecgl-nowebgl",this.dom.innerHTML="Sorry, your browser does not support WebGL",void console.error(t)}this.onglobalout=this.onglobalout.bind(this),e.on("globalout",this.onglobalout),this.dom=this.renderer.canvas;var r=this.dom.style;r.position="absolute",r.left="0",r.top="0",this.views=[],this._picking=new Xe({renderer:this.renderer}),this._viewsToDispose=[],this._accumulatingId=0,this._zrEventProxy=new i.graphic.Rect({shape:{x:-1,y:-1,width:2,height:2},__isGLToZRProxy:!0}),this._backgroundColor=null};function qa(t){var e=t.__zr;t.__zr=null,e&&t.removeAnimatorsFromZr&&t.removeAnimatorsFromZr(e)}ja.prototype.addView=function(t){if(t.layer!==this){var e=this._viewsToDispose.indexOf(t);e>=0&&this._viewsToDispose.splice(e,1),this.views.push(t),t.layer=this;var r=this.zr;t.scene.traverse(function(t){t.__zr=r,t.addAnimatorsToZr&&t.addAnimatorsToZr(r)})}},ja.prototype.removeView=function(t){if(t.layer===this){var e=this.views.indexOf(t);e>=0&&(this.views.splice(e,1),t.scene.traverse(qa,this),t.layer=null,this._viewsToDispose.push(t))}},ja.prototype.removeViewsAll=function(){this.views.forEach(function(t){t.scene.traverse(qa,this),t.layer=null,this._viewsToDispose.push(t)},this),this.views.length=0},ja.prototype.resize=function(t,e){this.renderer.resize(t,e)},ja.prototype.clear=function(){var t=this.renderer.gl,e=this._backgroundColor||[0,0,0,0];t.clearColor(e[0],e[1],e[2],e[3]),t.depthMask(!0),t.colorMask(!0,!0,!0,!0),t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT)},ja.prototype.clearDepth=function(){var t=this.renderer.gl;t.clear(t.DEPTH_BUFFER_BIT)},ja.prototype.clearColor=function(){var t=this.renderer.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)},ja.prototype.needsRefresh=function(){this.zr.refresh()},ja.prototype.refresh=function(t){this._backgroundColor=t?Wa.parseColor(t):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var e=0;e<this.views.length;e++)this.views[e].prepareRender(this.renderer);this._doRender(!1),this._trackAndClean();for(e=0;e<this._viewsToDispose.length;e++)this._viewsToDispose[e].dispose(this.renderer);this._viewsToDispose.length=0,this._startAccumulating()},ja.prototype.renderToCanvas=function(t){this._startAccumulating(!0),t.drawImage(this.dom,0,0,t.canvas.width,t.canvas.height)},ja.prototype._doRender=function(t){this.clear(),this.renderer.saveViewport();for(var e=0;e<this.views.length;e++)this.views[e].render(this.renderer,t);this.renderer.restoreViewport()},ja.prototype._stopAccumulating=function(){this._accumulatingId=0,clearTimeout(this._accumulatingTimeout)};var Za=1;function Ya(t){for(var e=0;e<t.length;e++)t[e].__used__=0}function Ka(t,e){for(var r=0;r<e.length;r++)e[r].__used__||e[r].dispose(t)}function Qa(t,e){t.__used__=t.__used__||0,t.__used__++,1===t.__used__&&e.push(t)}function Ja(t,e,r){var i,n;t.traverse(function(t){if(t.isRenderable()){var a=t.geometry,o=t.material;if(o!==i)for(var s=o.getTextureUniforms(),l=0;l<s.length;l++){var h=s[l],u=o.uniforms[h].value;if(u)if(u instanceof Ye)Qa(u,e);else if(u instanceof Array)for(var c=0;c<u.length;c++)u[c]instanceof Ye&&Qa(u[c],e)}a!==n&&Qa(a,r),i=o,n=a}});for(var a=0;a<t.lights.length;a++)t.lights[a].cubemap&&Qa(t.lights[a].cubemap,e)}ja.prototype._startAccumulating=function(t){var e=this;this._stopAccumulating();for(var r=!1,i=0;i<this.views.length;i++)r=this.views[i].needsAccumulate()||r;function n(i){if(e._accumulatingId&&i===e._accumulatingId){for(var a=!0,o=0;o<e.views.length;o++)a=e.views[o].isAccumulateFinished()&&r;a||(e._doRender(!0),t?n(i):Xa(function(){n(i)}))}}r&&(this._accumulatingId=Za++,t?n(e._accumulatingId):this._accumulatingTimeout=setTimeout(function(){n(e._accumulatingId)},50))},ja.prototype._trackAndClean=function(){var t=[],e=[];this._textureList&&(Ya(this._textureList),Ya(this._geometriesList));for(var r=0;r<this.views.length;r++)Ja(this.views[r].scene,t,e);this._textureList&&(Ka(this.renderer,this._textureList),Ka(this.renderer,this._geometriesList)),this._textureList=t,this._geometriesList=e},ja.prototype.dispose=function(){this._stopAccumulating(),this.renderer.disposeScene(this.scene),this.zr.off("globalout",this.onglobalout)},ja.prototype.onmousedown=function(t){if(!t.target||!t.target.__isGLToZRProxy){t=t.event;var e=this.pickObject(t.offsetX,t.offsetY);e&&(this._dispatchEvent("mousedown",t,e),this._dispatchDataEvent("mousedown",t,e)),this._downX=t.offsetX,this._downY=t.offsetY}},ja.prototype.onmousemove=function(t){if(!t.target||!t.target.__isGLToZRProxy){t=t.event;var e=this.pickObject(t.offsetX,t.offsetY),r=e&&e.target,i=this._hovered;this._hovered=e,i&&r!==i.target&&(i.relatedTarget=r,this._dispatchEvent("mouseout",t,i),this.zr.setCursorStyle("default")),this._dispatchEvent("mousemove",t,e),e&&(this.zr.setCursorStyle("pointer"),i&&r===i.target||this._dispatchEvent("mouseover",t,e)),this._dispatchDataEvent("mousemove",t,e)}},ja.prototype.onmouseup=function(t){if(!t.target||!t.target.__isGLToZRProxy){t=t.event;var e=this.pickObject(t.offsetX,t.offsetY);e&&(this._dispatchEvent("mouseup",t,e),this._dispatchDataEvent("mouseup",t,e)),this._upX=t.offsetX,this._upY=t.offsetY}},ja.prototype.onclick=ja.prototype.dblclick=function(t){if(!t.target||!t.target.__isGLToZRProxy){var e=this._upX-this._downX,r=this._upY-this._downY;if(!(Math.sqrt(e*e+r*r)>20)){t=t.event;var i=this.pickObject(t.offsetX,t.offsetY);i&&(this._dispatchEvent(t.type,t,i),this._dispatchDataEvent(t.type,t,i));var n=this._clickToSetFocusPoint(t);if(n)n.view.setDOFFocusOnPoint(n.distance)&&this.zr.refresh()}}},ja.prototype._clickToSetFocusPoint=function(t){for(var e=this.renderer,r=e.viewport,i=this.views.length-1;i>=0;i--){var n=this.views[i];if(n.hasDOF()&&n.containPoint(t.offsetX,t.offsetY)){this._picking.scene=n.scene,this._picking.camera=n.camera,e.viewport=n.viewport;var a=this._picking.pick(t.offsetX,t.offsetY,!0);if(a)return a.view=n,a}}e.viewport=r},ja.prototype.onglobalout=function(t){var e=this._hovered;e&&this._dispatchEvent("mouseout",t,{target:e.target})},ja.prototype.pickObject=function(t,e){for(var r=[],i=this.renderer,n=i.viewport,a=0;a<this.views.length;a++){var o=this.views[a];o.containPoint(t,e)&&(this._picking.scene=o.scene,this._picking.camera=o.camera,i.viewport=o.viewport,this._picking.pickAll(t,e,r))}return i.viewport=n,r.sort(function(t,e){return t.distance-e.distance}),r[0]},ja.prototype._dispatchEvent=function(t,e,r){r||(r={});var i=r.target;for(r.cancelBubble=!1,r.event=e,r.type=t,r.offsetX=e.offsetX,r.offsetY=e.offsetY;i&&(i.trigger(t,r),i=i.getParent(),!r.cancelBubble););this._dispatchToView(t,r)},ja.prototype._dispatchDataEvent=function(t,e,r){var n=r&&r.target,a=n&&n.dataIndex,o=n&&n.seriesIndex,s=n&&n.eventData,l=!1,h=this._zrEventProxy;h.x=e.offsetX,h.y=e.offsetY,h.update();var u={target:h};const c=i.helper.getECData(h);"mousemove"===t&&(null!=a?a!==this._lastDataIndex&&(parseInt(this._lastDataIndex,10)>=0&&(c.dataIndex=this._lastDataIndex,c.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(u,"mouseout",e)),l=!0):null!=s&&s!==this._lastEventData&&(null!=this._lastEventData&&(c.eventData=this._lastEventData,this.zr.handler.dispatchToElement(u,"mouseout",e)),l=!0),this._lastEventData=s,this._lastDataIndex=a,this._lastSeriesIndex=o),c.eventData=s,c.dataIndex=a,c.seriesIndex=o,(null!=s||parseInt(a,10)>=0&&parseInt(o,10)>=0)&&(this.zr.handler.dispatchToElement(u,t,e),l&&this.zr.handler.dispatchToElement(u,"mouseover",e))},ja.prototype._dispatchToView=function(t,e){for(var r=0;r<this.views.length;r++)this.views[r].containPoint(e.offsetX,e.offsetY)&&this.views[r].trigger(t,e)},Object.assign(ja.prototype,s);var $a=ja,to=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];function eo(t,e){if(t&&t[e]&&(t[e].normal||t[e].emphasis)){var r=t[e].normal,i=t[e].emphasis;r&&(t[e]=r),i&&(t.emphasis=t.emphasis||{},t.emphasis[e]=i)}}function ro(t){t&&(t instanceof Array||(t=[t]),i.util.each(t,function(t){if(t.axisLabel){var e=t.axisLabel;Object.assign(e,e.textStyle),e.textStyle=null}}))}function io(t){this._layers={},this._zr=t}io.prototype.update=function(t,e){var r=this,n=e.getZr();if(n.getWidth()&&n.getHeight()){for(var a in this._layers)this._layers[a].removeViewsAll();t.eachComponent(function(r,i){if("series"!==r){var n=e.getViewOfComponentModel(i),a=i.coordinateSystem;if(n.__ecgl__){if(a){if(!a.viewGL)return void console.error("Can't find viewGL in coordinateSystem of component "+i.id);l=a.viewGL}else{if(!i.viewGL)return void console.error("Can't find viewGL of component "+i.id);l=a.viewGL}var l=a.viewGL,h=o(i);h.addView(l),n.afterRender&&n.afterRender(i,t,e,h),s(n.groupGL,i.get("silent"))}}}),t.eachSeries(function(r){var i=e.getViewOfSeriesModel(r),n=r.coordinateSystem;if(i.__ecgl__){if(n&&!n.viewGL&&!i.viewGL)return void console.error("Can't find viewGL of series "+i.id);var a=n&&n.viewGL||i.viewGL,l=o(r);l.addView(a),i.afterRender&&i.afterRender(r,t,e,l),s(i.groupGL,r.get("silent"))}})}else console.warn("Dom has no width or height");function o(t){var e;n.setSleepAfterStill(0),e=(t.coordinateSystem&&t.coordinateSystem.model,t.get("zlevel"));var a=r._layers,o=a[e];if(!o){if(o=a[e]=new $a("gl-"+e,n),n.painter.isSingleCanvas()){o.virtual=!0;var s=new i.graphic.Image({z:1e4,style:{image:o.renderer.canvas},silent:!0});o.__hostImage=s,n.add(s)}n.painter.insertLayer(e,o)}return o.__hostImage&&o.__hostImage.setStyle({width:o.renderer.getWidth(),height:o.renderer.getHeight()}),o}function s(t,e){t&&t.traverse(function(t){t.isRenderable&&t.isRenderable()&&(t.ignorePicking=null!=t.$ignorePicking?t.$ignorePicking:e)})}},i.registerPostInit(function(t){t.getZr().painter.getRenderedCanvas=function(t){if(t=t||{},this._singleCanvas)return this._layers[0].dom;var e=document.createElement("canvas"),r=t.pixelRatio||this.dpr;e.width=this.getWidth()*r,e.height=this.getHeight()*r;var i=e.getContext("2d");i.dpr=r,i.clearRect(0,0,e.width,e.height),t.backgroundColor&&(i.fillStyle=t.backgroundColor,i.fillRect(0,0,e.width,e.height));var n,a=this.storage.getDisplayList(!0),o={},s=this;function l(t,e){var r,n=s._zlevelList;null==t&&(t=-1/0);for(var a=0;a<n.length;a++){var o=n[a],l=s._layers[o];if(!l.__builtin__&&o>t&&o<e){r=l;break}}r&&r.renderToCanvas&&(i.save(),r.renderToCanvas(i),i.restore())}for(var h={ctx:i},u=0;u<a.length;u++){var c=a[u];c.zlevel!==n&&(l(n,c.zlevel),n=c.zlevel),this._doPaintEl(c,h,!0,o)}return l(n,1/0),e}}),i.registerPostUpdate(function(t,e){var r=e.getZr();(r.__egl=r.__egl||new io(r)).update(t,e)}),i.registerPreprocessor(function(t){i.util.each(t.series,function(e){i.util.indexOf(to,e.type)>=0&&(function(t){eo(t,"itemStyle"),eo(t,"lineStyle"),eo(t,"areaStyle"),eo(t,"label")}(e),"mapbox"===e.coordinateSystem&&(e.coordinateSystem="mapbox3D",t.mapbox3D=t.mapbox))}),ro(t.xAxis3D),ro(t.yAxis3D),ro(t.zAxis3D),ro(t.grid3D),eo(t.geo3D)});var no={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},ao=i.util.merge({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},no),oo=i.util.merge({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},no),so=i.util.defaults({scale:!0,min:"dataMin",max:"dataMax"},oo),lo=i.util.defaults({logBase:10},oo);lo.scale=!0;var ho={categoryAxis3D:ao,valueAxis3D:oo,timeAxis3D:so,logAxis3D:lo};function uo(t){return sa(t)&&null!=t.value?t.value:t+""}var co=function(){function t(t){this.categories=t.categories||[],this._needCollect=t.needCollect,this._deduplication=t.deduplication}return t.createByAxisModel=function(e){var r=e.option,i=r.data,n=i&&ta(i,uo);return new t({categories:n,needCollect:!n,deduplication:!1!==r.dedplication})},t.prototype.getOrdinal=function(t){return this._getOrCreateMap().get(t)},t.prototype.parseAndCollect=function(t){var e,r=this._needCollect;if("string"!=typeof t&&!r)return t;if(r&&!this._deduplication)return e=this.categories.length,this.categories[e]=t,e;var i=this._getOrCreateMap();return null==(e=i.get(t))&&(r?(e=this.categories.length,this.categories[e]=t,i.set(t,e)):e=NaN),e},t.prototype._getOrCreateMap=function(){return this._map||(this._map=ya(this.categories))},t}(),fo=["value","category","time","log"],po=function(t,e,r,n){i.util.each(fo,function(a){e.extend({type:t+"Axis3D."+a,__ordinalMeta:null,mergeDefaultAndTheme:function(e,n){var o=n.getTheme();i.util.merge(e,o.get(a+"Axis3D")),i.util.merge(e,this.getDefaultOption()),e.type=r(t,e)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=co.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:i.util.merge(i.util.clone(ho[a+"Axis3D"]),n||{},!0)})}),e.superClass.registerSubTypeDefaulter(t+"Axis3D",i.util.curry(r,t))},mo=i.extendComponentModel({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});function go(t,e){return e.type||(e.data?"category":"value")}i.helper.mixinAxisModelCommonMethods(mo),po("x",mo,go,{name:"X"}),po("y",mo,go,{name:"Y"}),po("z",mo,go,{name:"Z"});var _o={defaultOption:{viewControl:{projection:"perspective",autoRotate:!1,autoRotateDirection:"cw",autoRotateSpeed:10,autoRotateAfterStill:3,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",distance:150,minDistance:40,maxDistance:400,orthographicSize:150,maxOrthographicSize:400,minOrthographicSize:20,center:[0,0,0],alpha:0,beta:0,minAlpha:-90,maxAlpha:90}},setView:function(t){t=t||{},this.option.viewControl=this.option.viewControl||{},null!=t.alpha&&(this.option.viewControl.alpha=t.alpha),null!=t.beta&&(this.option.viewControl.beta=t.beta),null!=t.distance&&(this.option.viewControl.distance=t.distance),null!=t.center&&(this.option.viewControl.center=t.center)}},vo={defaultOption:{postEffect:{enable:!1,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalRange:20,focalDistance:50,blurRadius:10,fstop:2.8,quality:"medium"},screenSpaceAmbientOcclusion:{enable:!1,radius:2,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},edge:{enable:!1},FXAA:{enable:!1}},temporalSuperSampling:{enable:"auto"}}},yo={defaultOption:{light:{main:{shadow:!1,shadowQuality:"high",color:"#fff",intensity:1,alpha:0,beta:0},ambient:{color:"#fff",intensity:.2},ambientCubemap:{texture:null,exposure:1,diffuseIntensity:.5,specularIntensity:.5}}}},xo=i.extendComponentModel({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});i.util.merge(xo.prototype,_o),i.util.merge(xo.prototype,vo),i.util.merge(xo.prototype,yo);var To=function(t,e){return(To=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)}; |