<NME> ShadowMapPass.js
<BEF> (function() {
    var ShadowMapPass = function() {
        this.depthMaterial = new zen3d.DepthMaterial();
        this.depthMaterial.packToRGBA = true;
var defaultDepthMaterial = new DepthMaterial();
defaultDepthMaterial.packToRGBA = true;

var defaultDistanceMaterial = new DistanceMaterial();
defaultDistanceMaterial.uniforms = {};

function _getDepthMaterial(renderable, light) {
	defaultDepthMaterial.side = shadowSide[renderable.material.side];
	return defaultDepthMaterial;
}

function _getDistanceMaterial(renderable, light) {
	defaultDistanceMaterial.side = shadowSide[renderable.material.side];
	defaultDistanceMaterial.uniforms["nearDistance"] = light.shadow.cameraNear;
	defaultDistanceMaterial.uniforms["farDistance"] = light.shadow.cameraFar;
	return defaultDistanceMaterial;
}

var oldClearColor = new Vector4();

/**
            var shadowTarget = shadow.renderTarget;
            var isPointLight = light.lightType == zen3d.LIGHT_TYPE.POINT ? true : false;
            var faces = isPointLight ? 6 : 1;
            var renderList = scene.cache.shadowObjects;

            for (var j = 0; j < faces; j++) {

	 * Override this to use custom depth material.
	 * @type {Function}
	 */
	this.getDepthMaterial = _getDepthMaterial;

	/**
	 * Get distance material function.
	 * Override this to use custom distance material.
	 * @type {Function}
                state.clearColor(1, 1, 1, 1);
                glCore.clear(true, true);

                if (renderList.length == 0) {
                    continue;
                }

                var material = isPointLight ? this.distanceMaterial : this.depthMaterial;
                material.uniforms = material.uniforms || {};
                material.uniforms["nearDistance"] = shadow.cameraNear;
                material.uniforms["farDistance"] = shadow.cameraFar;

                glCore.renderPass(renderList, camera, {
                    getMaterial: function(renderable) {
                        // copy draw side
                        material.side = renderable.material.side;
                        return material;
                    }
                });

	}

	oldClearColor.copy(state.colorBuffer.getClear());
	state.colorBuffer.setClear(1, 1, 1, 1);

	var lights = scene.lights.shadows;
	for (var i = 0; i < lights.length; i++) {
		var light = lights[i];

		var shadow = light.shadow;

		if (shadow.autoUpdate === false && shadow.needsUpdate === false) continue;

		var camera = shadow.camera;
		var shadowTarget = shadow.renderTarget;
		var isPointLight = light.lightType == LIGHT_TYPE.POINT ? true : false;
		var faces = isPointLight ? 6 : 1;

		if (glCore.capabilities.version >= 2) {
			if (!isPointLight && !shadow.depthMap && !glCore.disableShadowSampler) {
				shadow._initDepthMap();
			}
		}

		for (var j = 0; j < faces; j++) {
			if (isPointLight) {
				shadow.update(light, j);
				shadowTarget.activeCubeFace = j;
			} else {
				shadow.update(light);
			}

			var renderList = scene.updateRenderList(camera);

			glCore.renderTarget.setRenderTarget(shadowTarget);

			glCore.clear(true, true);

			glCore.renderPass(renderList.opaque, camera, {
				getMaterial: function(renderable) {
					return isPointLight ? getDistanceMaterial(renderable, light) : getDepthMaterial(renderable, light);
				},
				ifRender: function(renderable) {
					return renderable.object.castShadow;
				}
			});

			// ignore transparent objects?
		}

		// set generateMipmaps false
		// glCore.renderTarget.updateRenderTargetMipmap(shadowTarget);

		shadow.needsUpdate = false;
	}

	if (useStencil) {
		state.stencilBuffer.setTest(true);
	}

	state.colorBuffer.setClear(oldClearColor.x, oldClearColor.y, oldClearColor.z, oldClearColor.w);
}

export { ShadowMapPass };
<MSG> add ifRender option for WebGLCore.renderPass method

<DFF> @@ -1,4 +1,7 @@
 (function() {
+    var RENDER_LAYER = zen3d.RENDER_LAYER;
+    var LAYER_RENDER_LIST = zen3d.LAYER_RENDER_LIST;
+
     var ShadowMapPass = function() {
         this.depthMaterial = new zen3d.DepthMaterial();
         this.depthMaterial.packToRGBA = true;
@@ -26,7 +29,7 @@
             var shadowTarget = shadow.renderTarget;
             var isPointLight = light.lightType == zen3d.LIGHT_TYPE.POINT ? true : false;
             var faces = isPointLight ? 6 : 1;
-            var renderList = scene.cache.shadowObjects;
+            var renderLists = scene.cache.renderLists;
 
             for (var j = 0; j < faces; j++) {
 
@@ -42,20 +45,20 @@
                 state.clearColor(1, 1, 1, 1);
                 glCore.clear(true, true);
 
-                if (renderList.length == 0) {
-                    continue;
-                }
-
                 var material = isPointLight ? this.distanceMaterial : this.depthMaterial;
                 material.uniforms = material.uniforms || {};
                 material.uniforms["nearDistance"] = shadow.cameraNear;
                 material.uniforms["farDistance"] = shadow.cameraFar;
 
-                glCore.renderPass(renderList, camera, {
+                // ignore transparent objects
+                glCore.renderPass(renderLists[RENDER_LAYER.DEFAULT], camera, {
                     getMaterial: function(renderable) {
                         // copy draw side
                         material.side = renderable.material.side;
                         return material;
+                    },
+                    ifRender: function(renderable) {
+                        return renderable.object.castShadow;
                     }
                 });
 

{'commit': 'diff --git a/build/zen3d.js b/build/zen3d.js\nindex 85bbff79..64071f80 100644\n--- a/build/zen3d.js\n+++ b/build/zen3d.js\n@@ -4884,6 +4884,7 @@\n      * @param {zen3d.Camera} camera Camera provide view matrix and porjection matrix.\n      * @param {Object} [config] ?\n      * @param {Function} [config.getMaterial] Get renderable material.\n+     * @param {Function} [config.ifRender] If render the renderable.\n      * @param {RenderCache} [config.cache] render cache\n      */\n     WebGLCore.prototype.renderPass = function(renderList, camera, config) {\n@@ -4899,8 +4900,12 @@\n         var targetHeight = state.currentRenderTarget.height;\n \n         for (var i = 0, l = renderList.length; i < l; i++) {\n-\n             var renderItem = renderList[i];\n+\n+            if(config.ifRender && !config.ifRender(renderItem)) {\n+                continue;\n+            }\n+            \n             var object = renderItem.object;\n             var material = getMaterial.call(this, renderItem);\n             var geometry = renderItem.geometry;\n@@ -6101,6 +6106,9 @@ sprite_vert: "uniform mat4 modelMatrix;\\nuniform mat4 viewMatrix;\\nuniform mat4\n     zen3d.EnvironmentMapPass = EnvironmentMapPass;\n })();\n (function() {\n+    var RENDER_LAYER = zen3d.RENDER_LAYER;\n+    var LAYER_RENDER_LIST = zen3d.LAYER_RENDER_LIST;\n+\n     var ShadowMapPass = function() {\n         this.depthMaterial = new zen3d.DepthMaterial();\n         this.depthMaterial.packToRGBA = true;\n@@ -6128,7 +6136,7 @@ sprite_vert: "uniform mat4 modelMatrix;\\nuniform mat4 viewMatrix;\\nuniform mat4\n             var shadowTarget = shadow.renderTarget;\n             var isPointLight = light.lightType == zen3d.LIGHT_TYPE.POINT ? true : false;\n             var faces = isPointLight ? 6 : 1;\n-            var renderList = scene.cache.shadowObjects;\n+            var renderLists = scene.cache.renderLists;\n \n             for (var j = 0; j < faces; j++) {\n \n@@ -6144,20 +6152,20 @@ sprite_vert: "uniform mat4 modelMatrix;\\nuniform mat4 viewMatrix;\\nuniform mat4\n                 state.clearColor(1, 1, 1, 1);\n                 glCore.clear(true, true);\n \n-                if (renderList.length == 0) {\n-                    continue;\n-                }\n-\n                 var material = isPointLight ? this.distanceMaterial : this.depthMaterial;\n                 material.uniforms = material.uniforms || {};\n                 material.uniforms["nearDistance"] = shadow.cameraNear;\n                 material.uniforms["farDistance"] = shadow.cameraFar;\n \n-                glCore.renderPass(renderList, camera, {\n+                // ignore transparent objects\n+                glCore.renderPass(renderLists[RENDER_LAYER.DEFAULT], camera, {\n                     getMaterial: function(renderable) {\n                         // copy draw side\n                         material.side = renderable.material.side;\n                         return material;\n+                    },\n+                    ifRender: function(renderable) {\n+                        return renderable.object.castShadow;\n                     }\n                 });\n \n@@ -6176,7 +6184,6 @@ sprite_vert: "uniform mat4 modelMatrix;\\nuniform mat4 viewMatrix;\\nuniform mat4\n     zen3d.ShadowMapPass = ShadowMapPass;\n })();\n (function() {\n-    var RENDER_LAYER = zen3d.RENDER_LAYER;\n     var LAYER_RENDER_LIST = zen3d.LAYER_RENDER_LIST;\n \n     var ForwardPass = function() {\ndiff --git a/build/zen3d.min.js b/build/zen3d.min.js\nindex 87ea1b83..859fc6a1 100644\n--- a/build/zen3d.min.js\n+++ b/build/zen3d.min.js\n@@ -1 +1 @@\n-!function(t){var e=t.zen3d=t.zen3d||{},n=function(){};e.inherit=function(e,t){n.prototype=t.prototype,e.superClass=t.prototype,e.prototype=new n,e.prototype.constructor=e};var i,r,a,o;e.generateUUID=(r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),a=new Array(36),o=0,function(){for(var e=0;e<36;e++)8===e||13===e||18===e||23===e?a[e]="-":14===e?a[e]="4":(o<=2&&(o=33554432+16777216*Math.random()|0),i=15&o,o>>=4,a[e]=r[19===e?3&i|8:i]);return a.join("")});e.isMobile=function(){if(!t.navigator)return!0;var e=navigator.userAgent.toLowerCase();return-1!=e.indexOf("mobile")||-1!=e.indexOf("android")}();e.isWeb=!!document;e.createCheckerBoardPixels=function(e,t,n){var i=new Uint8Array(e*t*4),r=[[255,255,255,255],[0,0,0,255]];n=n||5;for(var a=0,o=0;o<t;o++)for(var s=0;s<e;s++){if(0==s?a=1:s%n==0&&(a=(a+1)%2),o%n==0&&0==s){var u=r[0];r[0]=r[1],r[1]=u}i[o*(4*e)+4*s+0]=r[a][0],i[o*(4*e)+4*s+1]=r[a][1],i[o*(4*e)+4*s+2]=r[a][2],i[o*(4*e)+4*s+3]=r[a][3]}return i};e.isPowerOfTwo=function(e){return 0==(e&e-1)&&0!==e};e.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))};e.nextPowerOfTwo=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}}(window),function(){zen3d.OBJECT_TYPE={MESH:"mesh",SKINNED_MESH:"skinned_mesh",LIGHT:"light",CAMERA:"camera",SCENE:"scene",GROUP:"group",POINT:"point",LINE:"line",LINE_LOOP:"line_loop",LINE_SEGMENTS:"line_segments",CANVAS2D:"canvas2d",SPRITE:"sprite",PARTICLE:"particle"};zen3d.LIGHT_TYPE={AMBIENT:"ambient",DIRECT:"direct",POINT:"point",SPOT:"spot"};zen3d.MATERIAL_TYPE={BASIC:"basic",LAMBERT:"lambert",PHONG:"phong",PBR:"pbr",CUBE:"cube",POINT:"point",LINE:"line",LINE_LOOP:"lineloop",LINE_DASHED:"linedashed",CANVAS2D:"canvas2d",SPRITE:"sprite",SHADER:"shader",DEPTH:"depth",DISTANCE:"distance",PARTICLE:"particle"};zen3d.FOG_TYPE={NORMAL:"normal",EXP2:"exp2"};zen3d.BLEND_TYPE={NONE:"none",NORMAL:"normal",ADD:"add"};zen3d.CULL_FACE_TYPE={NONE:"none",FRONT:"front",BACK:"back",FRONT_AND_BACK:"front_and_back"};zen3d.DRAW_SIDE={FRONT:"front",BACK:"back",DOUBLE:"double"};zen3d.SHADING_TYPE={SMOOTH_SHADING:"smooth_shading",FLAT_SHADING:"flat_shading"};zen3d.WEBGL_TEXTURE_TYPE={TEXTURE_2D:3553,TEXTURE_CUBE_MAP:34067};zen3d.WEBGL_PIXEL_FORMAT={DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410};zen3d.WEBGL_PIXEL_TYPE={UNSIGNED_BYTE:5121,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FLOAT:5126};zen3d.WEBGL_TEXTURE_FILTER={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};zen3d.WEBGL_TEXTURE_WRAP={REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648};zen3d.WEBGL_UNIFORM_TYPE={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,BYTE:65535,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126};zen3d.WEBGL_ATTRIBUTE_TYPE={FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,FLOAT:5126,BYTE:65535,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123};zen3d.WEBGL_BUFFER_USAGE={STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048};zen3d.SHADOW_TYPE={HARD:"hard",PCF_SOFT:"pcf_soft"};zen3d.TEXEL_ENCODING_TYPE={LINEAR:"linear",SRGB:"sRGB",RGBE:"RGBE",RGBM7:"RGBM7",RGBM16:"RGBM16",RGBD:"RGBD",GAMMA:"Gamma"};zen3d.ENVMAP_COMBINE_TYPE={MULTIPLY:"multiply",MIX:"mix",ADD:"add"};zen3d.DRAW_MODE={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};var e={DEFAULT:"default",TRANSPARENT:"transparent",CANVAS2D:"canvas2d",SPRITE:"sprite",PARTICLE:"particle"},t=[(zen3d.RENDER_LAYER=e).DEFAULT,e.TRANSPARENT,e.CANVAS2D,e.SPRITE,e.PARTICLE];zen3d.LAYER_RENDER_LIST=t}(),function(){var r=function(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._order=i||r.DefaultOrder};r.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],r.DefaultOrder="XYZ",Object.defineProperties(r.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this.onChangeCallback()}}}),r.prototype.copyFrom=function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},r.prototype.set=function(e,t,n,i){return this._x=e||0,this._y=t||0,this._z=n||0,this._order=i||this._order,this.onChangeCallback(),this},r.prototype.setFromRotationMatrix=function(e,t,n){var i=function(e,t,n){return Math.max(t,Math.min(n,e))},r=e.elements,a=r[0],o=r[4],s=r[8],u=r[1],h=r[5],c=r[9],d=r[2],l=r[6],p=r[10];return"XYZ"===(t=t||this._order)?(this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(l,h),this._z=0)):"YXZ"===t?(this._x=Math.asin(-i(c,-1,1)),Math.abs(c)<.99999?(this._y=Math.atan2(s,p),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-d,a),this._z=0)):"ZXY"===t?(this._x=Math.asin(i(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(u,a))):"ZYX"===t?(this._y=Math.asin(-i(d,-1,1)),Math.abs(d)<.99999?(this._x=Math.atan2(l,p),this._z=Math.atan2(u,a)):(this._x=0,this._z=Math.atan2(-o,h))):"YZX"===t?(this._z=Math.asin(i(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-d,a)):(this._x=0,this._y=Math.atan2(s,p))):"XZY"===t?(this._z=Math.asin(-i(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(l,h),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-c,p),this._y=0)):console.warn("given unsupported order: "+t),this._order=t,!1!==n&&this.onChangeCallback(),this},r.prototype.setFromQuaternion=function(e,t,n){var i=zen3d.helpMatrix;return e.toMatrix4(i),this.setFromRotationMatrix(i,t,n)},r.prototype.onChange=function(e){return this.onChangeCallback=e,this},r.prototype.onChangeCallback=function(){},zen3d.Euler=r}(),function(){var e=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1])};e.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},e.prototype.inverse=function(){return this.getInverse(this)},e.prototype.getInverse=function(e){var t=e.elements,n=this.elements,i=t[0],r=t[1],a=t[2],o=t[3],s=t[4],u=t[5],h=t[6],c=t[7],d=t[8],l=d*s-u*c,p=u*h-d*o,f=c*o-s*h,_=i*l+r*p+a*f;if(0===_){return console.warn("zen3d.Matrix3: .getInverse() can\'t invert matrix, determinant is 0"),this.identity()}var v=1/_;return n[0]=l*v,n[1]=(a*c-d*r)*v,n[2]=(u*r-a*s)*v,n[3]=p*v,n[4]=(d*i-a*h)*v,n[5]=(a*o-u*i)*v,n[6]=f*v,n[7]=(r*h-c*i)*v,n[8]=(s*i-r*o)*v,this},e.prototype.transpose=function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},e.prototype.set=function(e,t,n,i,r,a,o,s,u){var h=this.elements;return h[0]=e,h[3]=t,h[6]=n,h[1]=i,h[4]=r,h[7]=a,h[2]=o,h[5]=s,h[8]=u,this},e.prototype.copy=function(e){return this.elements.set(e.elements),this},e.prototype.multiply=function(e){return this.multiplyMatrices(this,e)},e.prototype.premultiply=function(e){return this.multiplyMatrices(e,this)},e.prototype.multiplyMatrices=function(e,t){var n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],s=n[6],u=n[1],h=n[4],c=n[7],d=n[2],l=n[5],p=n[8],f=i[0],_=i[3],v=i[6],m=i[1],g=i[4],y=i[7],E=i[2],T=i[5],x=i[8];return r[0]=a*f+o*m+s*E,r[3]=a*_+o*g+s*T,r[6]=a*v+o*y+s*x,r[1]=u*f+h*m+c*E,r[4]=u*_+h*g+c*T,r[7]=u*v+h*y+c*x,r[2]=d*f+l*m+p*E,r[5]=d*_+l*g+p*T,r[8]=d*v+l*y+p*x,this},e.prototype.transform=function(e,t,n,i,r,a,o){var s=this.elements,u=1,h=0;if(r%360){var c=r;u=Math.cos(c),h=Math.sin(c)}return s[0]=u*n,s[3]=-h*i,s[6]=e,s[1]=h*n,s[4]=u*i,s[7]=t,s[2]=0,s[5]=0,s[8]=1,(a||o)&&(s[6]-=a*s[0]+o*s[3],s[7]-=a*s[1]+o*s[4]),this},e.prototype.setFromMatrix4=function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},zen3d.Matrix3=e}(),function(){var c,d,l=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])};l.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},l.prototype.set=function(e,t,n,i,r,a,o,s,u,h,c,d,l,p,f,_){var v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=r,v[5]=a,v[9]=o,v[13]=s,v[2]=u,v[6]=h,v[10]=c,v[14]=d,v[3]=l,v[7]=p,v[11]=f,v[15]=_,this},l.prototype.copy=function(e){return this.elements.set(e.elements),this},l.prototype.makeTranslation=function(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this},l.prototype.multiply=function(e){return this.multiplyMatrices(this,e)},l.prototype.premultiply=function(e){return this.multiplyMatrices(e,this)},l.prototype.multiplyMatrices=function(e,t){var n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],u=n[12],h=n[1],c=n[5],d=n[9],l=n[13],p=n[2],f=n[6],_=n[10],v=n[14],m=n[3],g=n[7],y=n[11],E=n[15],T=i[0],x=i[4],M=i[8],w=i[12],S=i[1],z=i[5],A=i[9],b=i[13],L=i[2],P=i[6],R=i[10],C=i[14],N=i[3],I=i[7],D=i[11],F=i[15];return r[0]=a*T+o*S+s*L+u*N,r[4]=a*x+o*z+s*P+u*I,r[8]=a*M+o*A+s*R+u*D,r[12]=a*w+o*b+s*C+u*F,r[1]=h*T+c*S+d*L+l*N,r[5]=h*x+c*z+d*P+l*I,r[9]=h*M+c*A+d*R+l*D,r[13]=h*w+c*b+d*C+l*F,r[2]=p*T+f*S+_*L+v*N,r[6]=p*x+f*z+_*P+v*I,r[10]=p*M+f*A+_*R+v*D,r[14]=p*w+f*b+_*C+v*F,r[3]=m*T+g*S+y*L+E*N,r[7]=m*x+g*z+y*P+E*I,r[11]=m*M+g*A+y*R+E*D,r[15]=m*w+g*b+y*C+E*F,this},l.prototype.transpose=function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},l.prototype.inverse=function(){return this.getInverse(this)},l.prototype.getInverse=function(e){var t=this.elements,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],u=n[5],h=n[6],c=n[7],d=n[8],l=n[9],p=n[10],f=n[11],_=n[12],v=n[13],m=n[14],g=n[15],y=l*m*c-v*p*c+v*h*f-u*m*f-l*h*g+u*p*g,E=_*p*c-d*m*c-_*h*f+s*m*f+d*h*g-s*p*g,T=d*v*c-_*l*c+_*u*f-s*v*f-d*u*g+s*l*g,x=_*l*h-d*v*h-_*u*p+s*v*p+d*u*m-s*l*m,M=i*y+r*E+a*T+o*x;if(0===M)return console.warn("can\'t invert matrix, determinant is 0"),this.identity();var w=1/M;return t[0]=y*w,t[1]=(v*p*o-l*m*o-v*a*f+r*m*f+l*a*g-r*p*g)*w,t[2]=(u*m*o-v*h*o+v*a*c-r*m*c-u*a*g+r*h*g)*w,t[3]=(l*h*o-u*p*o-l*a*c+r*p*c+u*a*f-r*h*f)*w,t[4]=E*w,t[5]=(d*m*o-_*p*o+_*a*f-i*m*f-d*a*g+i*p*g)*w,t[6]=(_*h*o-s*m*o-_*a*c+i*m*c+s*a*g-i*h*g)*w,t[7]=(s*p*o-d*h*o+d*a*c-i*p*c-s*a*f+i*h*f)*w,t[8]=T*w,t[9]=(_*l*o-d*v*o-_*r*f+i*v*f+d*r*g-i*l*g)*w,t[10]=(s*v*o-_*u*o+_*r*c-i*v*c-s*r*g+i*u*g)*w,t[11]=(d*u*o-s*l*o-d*r*c+i*l*c+s*r*f-i*u*f)*w,t[12]=x*w,t[13]=(d*v*a-_*l*a+_*r*p-i*v*p-d*r*m+i*l*m)*w,t[14]=(_*u*a-s*v*a-_*r*h+i*v*h+s*r*m-i*u*m)*w,t[15]=(s*l*a-d*u*a+d*r*h-i*l*h-s*r*p+i*u*p)*w,this},l.prototype.transform=function(e,t,n){var i=n.toMatrix4(zen3d.helpMatrix).elements,r=this.elements;return r[0]=i[0]*t.x,r[1]=i[1]*t.y,r[2]=i[2]*t.z,r[3]=0,r[4]=i[4]*t.x,r[5]=i[5]*t.y,r[6]=i[6]*t.z,r[7]=0,r[8]=i[8]*t.x,r[9]=i[9]*t.y,r[10]=i[10]*t.z,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this},l.prototype.makeRotationFromQuaternion=function(e){var t=this.elements,n=e.x,i=e.y,r=e.z,a=e.w,o=n+n,s=i+i,u=r+r,h=n*o,c=n*s,d=n*u,l=i*s,p=i*u,f=r*u,_=a*o,v=a*s,m=a*u;return t[0]=1-(l+f),t[4]=c-m,t[8]=d+v,t[1]=c+m,t[5]=1-(h+f),t[9]=p-_,t[2]=d-v,t[6]=p+_,t[10]=1-(h+l),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},l.prototype.decompose=function(e,t,n){void 0===c&&(c=new zen3d.Vector3,d=new l);var i=this.elements,r=c.set(i[0],i[1],i[2]).getLength(),a=c.set(i[4],i[5],i[6]).getLength(),o=c.set(i[8],i[9],i[10]).getLength();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],d.elements.set(this.elements);var s=1/r,u=1/a,h=1/o;return d.elements[0]*=s,d.elements[1]*=s,d.elements[2]*=s,d.elements[4]*=u,d.elements[5]*=u,d.elements[6]*=u,d.elements[8]*=h,d.elements[9]*=h,d.elements[10]*=h,t.setFromRotationMatrix(d),n.x=r,n.y=a,n.z=o,this},l.prototype.determinant=function(){var e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],s=e[9],u=e[13],h=e[2],c=e[6],d=e[10],l=e[14];return e[3]*(+r*s*c-i*u*c-r*o*d+n*u*d+i*o*l-n*s*l)+e[7]*(+t*s*l-t*u*d+r*a*d-i*a*l+i*u*h-r*s*h)+e[11]*(+t*u*c-t*o*l-r*a*c+n*a*l+r*o*h-n*u*h)+e[15]*(-i*o*h-t*s*c+t*o*d+i*a*c-n*a*d+n*s*h)},l.prototype.fromArray=function(e,t){void 0===t&&(t=0);for(var n=0;n<16;n++)this.elements[n]=e[n+t];return this},l.prototype.getMaxScaleOnAxis=function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))},l.prototype.toArray=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e},zen3d.Matrix4=l,zen3d.helpMatrix=new l}(),function(){var n=function(e,t){this.x=e||0,this.y=t||0};n.prototype.lerpVectors=function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},n.prototype.set=function(e,t){return this.x=e||0,this.y=t||0,this},n.prototype.min=function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},n.prototype.max=function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},n.prototype.getLength=function(){return Math.sqrt(this.getLengthSquared())},n.prototype.getLengthSquared=function(){return this.x*this.x+this.y*this.y},n.prototype.normalize=function(e){e=e||1;var t=this.getLength();if(0!=t){var n=e/t;return this.x*=n,this.y*=n,this}},n.prototype.subtract=function(e,t){return t||(t=new n),t.set(this.x-e.x,this.y-e.y),t},n.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this},n.prototype.addVectors=function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},n.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},n.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this},n.prototype.distanceToSquared=function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},n.prototype.distanceTo=function(e){return Math.sqrt(this.distanceToSquared(e))},n.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},n.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this},n.prototype.clone=function(){return new n(this.x,this.y)},zen3d.Vector2=n}(),function(){var t,n=function(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0};n.prototype.lerpVectors=function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},n.prototype.set=function(e,t,n){return this.x=e||0,this.y=t||0,this.z=n||0,this},n.prototype.min=function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},n.prototype.max=function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},n.prototype.getLength=function(){return Math.sqrt(this.getLengthSquared())},n.prototype.getLengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.prototype.normalize=function(e){e=e||1;var t=this.getLength();if(0!=t){var n=e/t;return this.x*=n,this.y*=n,this.z*=n,this}},n.prototype.subtract=function(e,t){return t||(t=new n),t.set(this.x-e.x,this.y-e.y,this.z-e.z),t},n.prototype.multiply=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},n.prototype.crossVectors=function(e,t){var n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this},n.prototype.cross=function(e){var t=this.x,n=this.y,i=this.z;return this.x=n*e.z-i*e.y,this.y=i*e.x-t*e.z,this.z=t*e.y-n*e.x,this},n.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},n.prototype.applyQuaternion=function(e){var t=this.x,n=this.y,i=this.z,r=e._x,a=e._y,o=e._z,s=e._w,u=s*t+a*i-o*n,h=s*n+o*t-r*i,c=s*i+r*n-a*t,d=-r*t-a*n-o*i;return this.x=u*s+d*-r+h*-o-c*-a,this.y=h*s+d*-a+c*-r-u*-o,this.z=c*s+d*-o+u*-a-h*-r,this},n.prototype.applyMatrix4=function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12],this.y=r[1]*t+r[5]*n+r[9]*i+r[13],this.z=r[2]*t+r[6]*n+r[10]*i+r[14],this},n.prototype.applyMatrix3=function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this},n.prototype.transformDirection=function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()},n.prototype.setFromMatrixPosition=function(e){return this.setFromMatrixColumn(e,3)},n.prototype.setFromMatrixColumn=function(e,t){return this.fromArray(e.elements,4*t)},n.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},n.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},n.prototype.addVectors=function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},n.prototype.addScalar=function(e){return this.x+=e,this.y+=e,this.z+=e,this},n.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},n.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},n.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},n.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this.z*=e,this},n.prototype.distanceToSquared=function(e){var t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i},n.prototype.distanceTo=function(e){return Math.sqrt(this.distanceToSquared(e))},n.prototype.unproject=function(e){return void 0===t&&(t=new zen3d.Matrix4),t.multiplyMatrices(e.worldMatrix,t.getInverse(e.projectionMatrix)),this.applyProjection(t)},n.prototype.applyProjection=function(e){var t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this},n.prototype.equals=function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},n.prototype.clone=function(){return new n(this.x,this.y,this.z)},zen3d.Vector3=n}(),function(){var e=function(e,t,n,i){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1};e.prototype.lerpVectors=function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},e.prototype.set=function(e,t,n,i){return this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1,this},e.prototype.applyMatrix4=function(e){var t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this},e.prototype.equals=function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},e.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},e.prototype.multiply=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},e.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},zen3d.Vector4=e}(),function(){var n,i,e=function(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1};e.prototype.normalize=function(e){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},e.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},e.prototype.lerpQuaternions=function(e,t,n){var i=e._w,r=e._x,a=e._y,o=e._z,s=t._w,u=t._x,h=t._y,c=t._z,d=i*s+r*u+a*h+o*c;d<0&&(d=-d,s=-s,u=-u,h=-h,c=-c),this._w=i+n*(s-i),this._x=r+n*(u-r),this._y=a+n*(h-a),this._z=o+n*(c-o);var l=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);return this._w*=l,this._x*=l,this._y*=l,this._z*=l,this.onChangeCallback(),this},e.prototype.slerpQuaternions=function(e,t,n){var i=e._w,r=e._x,a=e._y,o=e._z,s=t._w,u=t._x,h=t._y,c=t._z,d=i*s+r*u+a*h+o*c;if(d<0&&(d=-d,s=-s,u=-u,h=-h,c=-c),d<.95){var l=Math.acos(d),p=1/Math.sin(l),f=Math.sin(l*(1-n))*p,_=Math.sin(l*n)*p;this._w=i*f+s*_,this._x=r*f+u*_,this._y=a*f+h*_,this._z=o*f+c*_}else{this._w=i+n*(s-i),this._x=r+n*(u-r),this._y=a+n*(h-a),this._z=o+n*(c-o);var v=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);this._w*=v,this._x*=v,this._y*=v,this._z*=v}return this.onChangeCallback(),this},Object.defineProperties(e.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),e.prototype.set=function(e,t,n,i){return this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1,this.onChangeCallback(),this},e.prototype.copy=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=void 0!==e.w?e.w:1,this.onChangeCallback(),this},e.prototype.setFromEuler=function(e,t){var n=Math.cos(e._x/2),i=Math.cos(e._y/2),r=Math.cos(e._z/2),a=Math.sin(e._x/2),o=Math.sin(e._y/2),s=Math.sin(e._z/2),u=e._order;return"XYZ"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"YXZ"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"ZXY"===u?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"ZYX"===u?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"YZX"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r-a*o*s):"XZY"===u&&(this._x=a*i*r-n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r+a*o*s),!1!==t&&this.onChangeCallback(),this},e.prototype.setFromRotationMatrix=function(e){var t,n=e.elements,i=n[0],r=n[4],a=n[8],o=n[1],s=n[5],u=n[9],h=n[2],c=n[6],d=n[10],l=i+s+d;return 0<l?(t=.5/Math.sqrt(l+1),this._w=.25/t,this._x=(c-u)*t,this._y=(a-h)*t,this._z=(o-r)*t):s<i&&d<i?(t=2*Math.sqrt(1+i-s-d),this._w=(c-u)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(a+h)/t):d<s?(t=2*Math.sqrt(1+s-i-d),this._w=(a-h)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(u+c)/t):(t=2*Math.sqrt(1+d-i-s),this._w=(o-r)/t,this._x=(a+h)/t,this._y=(u+c)/t,this._z=.25*t),this.onChangeCallback(),this},e.prototype.setFromUnitVectors=(i=new zen3d.Vector3,function(e,t){return void 0===i&&(i=new zen3d.Vector3),(n=e.dot(t)+1)<1e-6?(n=0,Math.abs(e.x)>Math.abs(e.z)?i.set(-e.y,e.x,0):i.set(0,-e.z,e.y)):i.crossVectors(e,t),this._x=i.x,this._y=i.y,this._z=i.z,this._w=n,this.normalize()}),e.prototype.premultiply=function(e){return this.multiplyQuaternions(e,this)},e.prototype.multiplyQuaternions=function(e,t){var n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,u=t._z,h=t._w;return this._x=n*h+a*o+i*u-r*s,this._y=i*h+a*s+r*o-n*u,this._z=r*h+a*u+n*s-i*o,this._w=a*h-n*o-i*s-r*u,this.onChangeCallback(),this},e.prototype.toMatrix4=function(e){e||(e=new zen3d.Matrix4);var t=e.elements,n=2*this._x*this._y,i=2*this._x*this._z,r=2*this._x*this._w,a=2*this._y*this._z,o=2*this._y*this._w,s=2*this._z*this._w,u=this._x*this._x,h=this._y*this._y,c=this._z*this._z,d=this._w*this._w;return t[0]=u-h-c+d,t[4]=n-s,t[8]=i+o,t[12]=0,t[1]=n+s,t[5]=-u+h-c+d,t[9]=a-r,t[13]=0,t[2]=i-o,t[6]=a+r,t[10]=-u-h+c+d,t[14]=0,t[3]=0,t[7]=0,t[11]=0,t[15]=1,e},e.prototype.setFromAxisAngle=function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},e.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},e.prototype.onChange=function(e){return this.onChangeCallback=e,this},e.prototype.onChangeCallback=function(){},zen3d.Quaternion=e}(),function(){var e=function(e,t){this.min=void 0!==e?e:new zen3d.Vector2(1/0,1/0),this.max=void 0!==t?t:new zen3d.Vector2(-1/0,-1/0)};e.prototype.set=function(e,t,n,i){this.min.set(e,t),this.max.set(n,i)},e.prototype.copy=function(e){return this.min.copy(e.min),this.max.copy(e.max),this},zen3d.Box2=e}(),function(){var t,e=function(e,t){this.min=void 0!==e?e:new zen3d.Vector3(1/0,1/0,1/0),this.max=void 0!==t?t:new zen3d.Vector3(-1/0,-1/0,-1/0)};e.prototype.set=function(e,t){this.min.copy(e),this.max.copy(t)},e.prototype.setFromPoints=function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this},e.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},e.prototype.expandByPoint=function(e){return this.min.min(e),this.max.max(e),this},e.prototype.expandByScalar=function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},e.prototype.setFromArray=function(e,t){for(var n=1/0,i=1/0,r=1/0,a=-1/0,o=-1/0,s=-1/0,u=void 0!==t?t:3,h=0,c=e.length;h<c;h+=u){var d=e[h],l=e[h+1],p=e[h+2];d<n&&(n=d),l<i&&(i=l),p<r&&(r=p),a<d&&(a=d),o<l&&(o=l),s<p&&(s=p)}return this.min.set(n,i,r),this.max.set(a,o,s),this},e.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},e.prototype.equals=function(e){return e.min.equals(this.min)&&e.max.equals(this.max)},e.prototype.getCenter=function(e){var t=e||new zen3d.Vector3;return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},e.prototype.applyMatrix4=(t=[new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3],function(e){return this.isEmpty()||(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t)),this}),e.prototype.copy=function(e){return this.min.copy(e.min),this.max.copy(e.max),this},zen3d.Box3=e}(),function(){var c,d,e=function(e,t){this.center=void 0!==e?e:new zen3d.Vector3,this.radius=void 0!==t?t:0};e.prototype.set=function(e,t){return this.center.copy(e),this.radius=t,this},e.prototype.setFromArray=(c=new zen3d.Box3,d=new zen3d.Vector3,function(e,t){var n=void 0!==t?t:3,i=this.center;c.setFromArray(e,n).getCenter(i);for(var r=0,a=0,o=e.length;a<o;a+=n){var s=e[a],u=e[a+1],h=e[a+2];d.set(s,u,h),r=Math.max(r,i.distanceToSquared(d))}return this.radius=Math.sqrt(r),this}),e.prototype.applyMatrix4=function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},e.prototype.getBoundingBox=function(e){var t=e||new zen3d.Box3;return t.set(this.center,this.center),t.expandByScalar(this.radius),t},e.prototype.clone=function(){return(new e).copy(this)},e.prototype.copy=function(e){return this.center.copy(e.center),this.radius=e.radius,this},zen3d.Sphere=e}(),function(){var a,o,e=function(e,t){this.normal=void 0!==e?e:new zen3d.Vector3(1,0,0),this.constant=void 0!==t?t:0};e.prototype.set=function(e,t){return this.normal.copy(e),this.constant=t,this},e.prototype.setComponents=function(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this},e.prototype.normalize=function(){var e=1/this.normal.getLength();return this.normal.multiplyScalar(e),this.constant*=e,this},e.prototype.distanceToPoint=function(e){return this.normal.dot(e)+this.constant},e.prototype.coplanarPoint=function(e){return(e||new Vector3).copy(this.normal).multiplyScalar(-this.constant)},e.prototype.copy=function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},e.prototype.applyMatrix4=(a=new zen3d.Vector3,o=new zen3d.Matrix3,function(e,t){var n=t||o.setFromMatrix4(e).inverse().transpose(),i=this.coplanarPoint(a).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}),zen3d.Plane=e}(),function(){var o,s,e=function(e,t,n,i,r,a){this.planes=[void 0!==e?e:new zen3d.Plane,void 0!==t?t:new zen3d.Plane,void 0!==n?n:new zen3d.Plane,void 0!==i?i:new zen3d.Plane,void 0!==r?r:new zen3d.Plane,void 0!==a?a:new zen3d.Plane]};e.prototype.set=function(e,t,n,i,r,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},e.prototype.setFromMatrix=function(e){var t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],u=n[5],h=n[6],c=n[7],d=n[8],l=n[9],p=n[10],f=n[11],_=n[12],v=n[13],m=n[14],g=n[15];return t[0].setComponents(o-i,c-s,f-d,g-_).normalize(),t[1].setComponents(o+i,c+s,f+d,g+_).normalize(),t[2].setComponents(o+r,c+u,f+l,g+v).normalize(),t[3].setComponents(o-r,c-u,f-l,g-v).normalize(),t[4].setComponents(o-a,c-h,f-p,g-m).normalize(),t[5].setComponents(o+a,c+h,f+p,g+m).normalize(),this},e.prototype.intersectsSphere=function(e){for(var t=this.planes,n=e.center,i=-e.radius,r=0;r<6;r++){if(t[r].distanceToPoint(n)<i)return!1}return!0},e.prototype.intersectsBox=(o=new zen3d.Vector3,s=new zen3d.Vector3,function(e){for(var t=this.planes,n=0;n<6;n++){var i=t[n];o.x=0<i.normal.x?e.min.x:e.max.x,s.x=0<i.normal.x?e.max.x:e.min.x,o.y=0<i.normal.y?e.min.y:e.max.y,s.y=0<i.normal.y?e.max.y:e.min.y,o.z=0<i.normal.z?e.min.z:e.max.z,s.z=0<i.normal.z?e.max.z:e.min.z;var r=i.distanceToPoint(o),a=i.distanceToPoint(s);if(r<0&&a<0)return!1}return!0}),zen3d.Frustum=e}(),function(){var e=function(e,t,n){return this.r=0,this.g=0,void(this.b=0)===t&&void 0===n?this.setHex(e):this.setRGB(e,t,n)};e.prototype.lerpColors=function(e,t,n){this.r=n*(t.r-e.r)+e.r,this.g=n*(t.g-e.g)+e.g,this.b=n*(t.b-e.b)+e.b,this.r=this.r,this.g=this.g,this.b=this.b},e.prototype.copy=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},e.prototype.setHex=function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},e.prototype.setRGB=function(e,t,n){return this.r=e,this.g=t,this.b=n,this},e.prototype.setHSL=function(){function o(e,t,n){return n<0&&(n+=1),1<n&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}return function(e,t,n){var i;if(e=(e%(i=1)+i)%i,t=Math.max(0,Math.min(1,t)),n=Math.max(0,Math.min(1,n)),0===t)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=o(a,r,e+1/3),this.g=o(a,r,e),this.b=o(a,r,e-1/3)}return this}}(),e.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},zen3d.Color3=e}(),function(){var u,c,d,l,p,e=function(e,t){this.origin=void 0!==e?e:new zen3d.Vector3,this.direction=void 0!==t?t:new zen3d.Vector3};e.prototype.set=function(e,t){this.origin.copy(e),this.direction.copy(t)},e.prototype.at=function(e,t){return(t||new zen3d.Vector3).copy(this.direction).multiplyScalar(e).add(this.origin)},e.prototype.intersectsSphere=(u=new zen3d.Vector3,function(e,t){u.subVectors(e.center,this.origin);var n=u.dot(this.direction),i=u.dot(u)-n*n,r=e.radius*e.radius;if(r<i)return null;var a=Math.sqrt(r-i),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)}),e.prototype.intersectsBox=function(e,t){var n,i,r,a,o,s,u=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,d=this.origin;return 0<=u?(n=(e.min.x-d.x)*u,i=(e.max.x-d.x)*u):(n=(e.max.x-d.x)*u,i=(e.min.x-d.x)*u),0<=h?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),a<n||i<r?null:((n<r||n!=n)&&(n=r),(a<i||i!=i)&&(i=a),0<=c?(o=(e.min.z-d.z)*c,s=(e.max.z-d.z)*c):(o=(e.max.z-d.z)*c,s=(e.min.z-d.z)*c),s<n||i<o?null:((n<o||n!=n)&&(n=o),(s<i||i!=i)&&(i=s),i<0?null:this.at(0<=n?n:i,t)))},e.prototype.intersectTriangle=(c=new zen3d.Vector3,d=new zen3d.Vector3,l=new zen3d.Vector3,p=new zen3d.Vector3,function(e,t,n,i,r){d.subVectors(t,e),l.subVectors(n,e),p.crossVectors(d,l);var a,o=this.direction.dot(p);if(0<o){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}c.subVectors(this.origin,e);var s=a*this.direction.dot(l.crossVectors(c,l));if(s<0)return null;var u=a*this.direction.dot(d.cross(c));if(u<0)return null;if(o<s+u)return null;var h=-a*c.dot(p);return h<0?null:this.at(h/o,r)}),e.prototype.copy=function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},e.prototype.applyMatrix4=function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this.direction.normalize(),this},zen3d.Ray=e}(),function(){function a(e,t,n){this.a=void 0!==e?e:new zen3d.Vector3,this.b=void 0!==t?t:new zen3d.Vector3,this.c=void 0!==n?n:new zen3d.Vector3}var o,_,v,m,s;a.prototype.set=function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},a.normal=(o=new zen3d.Vector3,function(e,t,n,i){var r=i||new zen3d.Vector3;r.subVectors(n,t),o.subVectors(e,t),r.cross(o);var a=r.getLengthSquared();return 0<a?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}),a.barycoordFromPoint=(_=new zen3d.Vector3,v=new zen3d.Vector3,m=new zen3d.Vector3,function(e,t,n,i,r){_.subVectors(i,t),v.subVectors(n,t),m.subVectors(e,t);var a=_.dot(_),o=_.dot(v),s=_.dot(m),u=v.dot(v),h=v.dot(m),c=a*u-o*o,d=r||new zen3d.Vector3;if(0===c)return d.set(-2,-1,-1);var l=1/c,p=(u*s-o*h)*l,f=(a*h-o*s)*l;return d.set(1-p-f,f,p)}),a.containsPoint=(s=new zen3d.Vector3,function(e,t,n,i){var r=a.barycoordFromPoint(e,t,n,i,s);return 0<=r.x&&0<=r.y&&r.x+r.y<=1}),zen3d.Triangle=a}(),function(){var n,i,r,a,e=function(e,t){this.posPoints=void 0,this.ctrlPoints=void 0,this.segCount=0,this.set(e,t)};e.prototype.set=function(e,t){this.posPoints=e,this.ctrlPoints=t,e.length!==t.length&&console.warn("Curve: posPoints and ctrlPoints\'s length not equal!"),this.segCount=e.length-1},e.prototype.calc=(n=new zen3d.Vector2,i=new zen3d.Vector2,r=new zen3d.Vector2,a=new zen3d.Vector2,function(e){for(var t=0;t<this.segCount;t++)if(e>=this.posPoints[t].x&&e<=this.posPoints[t+1].x){n.copy(this.posPoints[t]),r.copy(this.posPoints[t+1]),i.copy(this.ctrlPoints[t]),a.copy(this.ctrlPoints[t+1]);break}return n||n.copy(this.posPoints[this.posPoints.length-1]),i||i.copy(this.ctrlPoints[this.ctrlPoints.length-1]),r.copy(r||n),a.copy(a||i),e=(e-n.x)/(r.x-n.x),this._cubic_bezier(n.y,i.y,a.y,r.y,e)}),e.prototype.averageXSampler=function(e){e<2&&console.warn("Curve: sampler num less than 2!");for(var t=[],n=this.posPoints[0].x,i=this.posPoints[this.posPoints.length-1].x,r=(i-n)/(e-1),a=0,o=0;o<e;o++)a=o===e-1?i:n+o*r,t.push(a,this.calc(a));return t},e.prototype._cubic_bezier=function(e,t,n,i,r){return e=this._mix(e,t,r),t=this._mix(t,n,r),n=this._mix(n,i,r),e=this._mix(e,t,r),t=this._mix(t,n,r),e=this._mix(e,t,r)},e.prototype._mix=function(e,t,n){return e*(1-n)+t*n},zen3d.Curve=e}(),function(){var e=function(){this.eventMap={}};e.prototype.addEventListener=function(e,t,n){var i=this.eventMap[e];i||(i=this.eventMap[e]=[]),i.push({listener:t,thisObject:n||this})},e.prototype.removeEventListener=function(e,t,n){var i=this.eventMap[e];if(i)for(var r=0,a=i.length;r<a;r++){var o=i[r];if(o.listener==t&&o.thisObject==(n||this)){i.splice(r,1);break}}},e.prototype.dispatchEvent=function(e){(e.target=this).notifyListener(e)},e.prototype.notifyListener=function(e){var t=this.eventMap[e.type];if(t)for(var n=0,i=t.length;n<i;n++){var r=t[n];r.listener.call(r.thisObject,e)}},zen3d.EventDispatcher=e}(),function(){var e=function(e,t,n,i){this.ray=new zen3d.Ray(e,t),this.near=n||0,this.far=i||1/0};function a(e,t){return e.distance-t.distance}function s(e,t,n,i){if(e.raycast(t,n),!0===i)for(var r=e.children,a=0,o=r.length;a<o;a++)s(r[a],t,n,!0)}e.prototype.set=function(e,t){this.ray.set(e,t)},e.prototype.setFromCamera=function(e,t){this.ray.origin.setFromMatrixPosition(t.worldMatrix),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize()},e.prototype.intersectObject=function(e,t){var n=[];return s(e,this,n,t),n.sort(a),n},e.prototype.intersectObjects=function(e,t){var n=[];if(!1===Array.isArray(e))return console.warn("Raycaster.intersectObjects: objects is not an Array."),n;for(var i=0,r=e.length;i<r;i++)s(e[i],this,n,t);return n.sort(a),n},zen3d.Raycaster=e}(),function(){var t=function(e,t){var n=["","WEBKIT_","MOZ_"],i=null;for(var r in n)if(i=e.getExtension(n[r]+t))break;return i};zen3d.WebGLCapabilities=function(e){this.version=parseFloat(/^WebGL\\ ([0-9])/.exec(e.getParameter(e.VERSION))[1]),this.precision="highp",this.maxPrecision=function(e,t){if("highp"===t){if(0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision)return"highp";t="mediump"}return"mediump"===t&&0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision?"mediump":"lowp"}(e,this.precision),this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxVertexTextures=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxCubemapSize=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),this.maxVertexUniformVectors=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),this.floatTextures=!!t(e,"OES_texture_float"),this.anisotropyExt=t(e,"EXT_texture_filter_anisotropic"),this.shaderTextureLOD=t(e,"EXT_shader_texture_lod"),this.maxAnisotropy=null!==this.anisotropyExt?e.getParameter(this.anisotropyExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0;t(e,"OES_standard_derivatives"),t(e,"GL_OES_standard_derivatives")}}(),function(){var i=zen3d.BLEND_TYPE,n=zen3d.CULL_FACE_TYPE;function r(e,t,n,i){var r=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var o=0;o<i;o++)e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,r);return a}var e=function(e,t){this.gl=e,this.capabilities=t,this.states={},this.currentBlending=null,this.currentPremultipliedAlpha=null,this.currentCullFace=null,this.currentViewport=new zen3d.Vector4,this.currentColorMask=null,this.currentClearColor=new zen3d.Vector4,this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBuffers={},this.emptyTextures={},this.emptyTextures[e.TEXTURE_2D]=r(e,e.TEXTURE_2D,e.TEXTURE_2D,1),this.emptyTextures[e.TEXTURE_CUBE_MAP]=r(e,e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),this.currentFlipSided=!1,this.currentDepthMask=!0,this.currentLineWidth=null,this.currentProgram=null,this.currentStencilMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilClear=null,this.currentRenderTarget=null};e.prototype.setBlend=function(e,t){var n=this.gl;e!==i.NONE?this.enable(n.BLEND):this.disable(n.BLEND),e===this.currentBlending&&t===this.currentPremultipliedAlpha||(e===i.NORMAL&&(t?(n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)):(n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA))),e===i.ADD&&(t?(n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.ONE,n.ONE,n.ONE,n.ONE)):(n.blendEquation(n.FUNC_ADD),n.blendFunc(n.SRC_ALPHA,n.ONE))),this.currentBlending=e,this.currentPremultipliedAlpha=t)},e.prototype.setFlipSided=function(e){var t=this.gl;this.currentFlipSided!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e)},e.prototype.setCullFace=function(e){var t=this.gl;e!==n.NONE?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===n.BACK?t.cullFace(t.BACK):e===n.FRONT?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e},e.prototype.viewport=function(e,t,n,i){var r=this.currentViewport;r.x===e&&r.y===t&&r.z===n&&r.w===i||(this.gl.viewport(e,t,n,i),r.set(e,t,n,i))},e.prototype.colorMask=function(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)},e.prototype.clearColor=function(e,t,n,i){var r=this.currentClearColor;r.x===e&&r.y===t&&r.z===n&&r.w===i||(this.gl.clearColor(e,t,n,i),r.set(e,t,n,i))},e.prototype.activeTexture=function(e){var t=this.gl;void 0===e&&(e=t.TEXTURE0+this.capabilities.maxTextures-1),this.currentTextureSlot!==e&&(t.activeTexture(e),this.currentTextureSlot=e)},e.prototype.bindTexture=function(e,t){var n=this.gl;null===this.currentTextureSlot&&this.activeTexture();var i=this.currentBoundTextures[this.currentTextureSlot];void 0===i&&(i={type:void 0,texture:void 0},this.currentBoundTextures[this.currentTextureSlot]=i),i.type===e&&i.texture===t||(n.bindTexture(e,t||this.emptyTextures[e]),i.type=e,i.texture=t)},e.prototype.bindBuffer=function(e,t){var n=this.gl;this.currentBoundBuffers[e]!==t&&(n.bindBuffer(e,t),this.currentBoundBuffers[e]=t)},e.prototype.enable=function(e){!0!==this.states[e]&&(this.gl.enable(e),this.states[e]=!0)},e.prototype.disable=function(e){!1!==this.states[e]&&(this.gl.disable(e),this.states[e]=!1)},e.prototype.depthMask=function(e){e!==this.currentDepthMask&&(this.gl.depthMask(e),this.currentDepthMask=e)},e.prototype.setLineWidth=function(e){e!==this.currentLineWidth&&(1<=this.capabilities.version&&this.gl.lineWidth(e),this.currentLineWidth=e)},e.prototype.setProgram=function(e){this.currentProgram!==e&&(this.gl.useProgram(e.id),this.currentProgram=e)},e.prototype.stencilMask=function(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)},e.prototype.stencilFunc=function(e,t,n){this.currentStencilFunc===e&&this.currentStencilRef===t&&this.currentStencilFuncMask===n||(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)},e.prototype.stencilOp=function(e,t,n){this.currentStencilFail===e&&this.currentStencilZFail===t&&this.currentStencilZPass===n||(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)},e.prototype.clearStencil=function(e){this.currentStencilClear!==e&&(this.gl.clearStencil(e),this.currentStencilClear=e)},zen3d.WebGLState=e}(),function(){var e=function(){this.properties={}};e.prototype.get=function(e){var t=e.uuid,n=this.properties[t];return void 0===n&&(n={},this.properties[t]=n),n},e.prototype.delete=function(e){delete this.properties[e.uuid]},e.prototype.clear=function(){this.properties={}},zen3d.WebGLProperties=e}(),function(){var f=zen3d.WEBGL_TEXTURE_FILTER,_=zen3d.WEBGL_TEXTURE_WRAP,v=zen3d.isWeb;function a(e){return e===f.NEAREST||e===f.NEAREST_MIPMAP_LINEAR||e===f.NEAREST_MIPMAP_NEAREST?f.NEAREST:f.LINEAR}var t=zen3d.isPowerOfTwo,m=zen3d.nearestPowerOfTwo;function g(e){return t(e.width)&&t(e.height)}function y(e,t){if(e.width>t||e.height>t){if(!v)return console.warn("image is too big ("+e.width+"x"+e.height+"). max size is "+t+"x"+t,e),e;var n=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(e.width*n),i.height=Math.floor(e.height*n),i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height,e),i}return e}var e=function(e,t,n,i){this.gl=e,this.state=t,this.properties=n,this.capabilities=i};e.prototype.setTexture2D=function(e,t){var n,i=this.gl,r=this.state,a=this.properties.get(e);if(0<e.version&&a.__version!==e.version){void 0===a.__webglTexture&&(e.addEventListener("dispose",this.onTextureDispose,this),a.__webglTexture=i.createTexture()),r.activeTexture(i.TEXTURE0+t),r.bindTexture(i.TEXTURE_2D,a.__webglTexture);var o=y(e.image,this.capabilities.maxTextureSize);((n=e).wrapS!==_.CLAMP_TO_EDGE||n.wrapT!==_.CLAMP_TO_EDGE||n.minFilter!==f.NEAREST&&n.minFilter!==f.LINEAR)&&!1===g(o)&&(o=function(e){if(v&&(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement)){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.width=m(e.width),t.height=m(e.height),t.getContext("2d").drawImage(e,0,0,t.width,t.height),console.warn("image is not power of two ("+e.width+"x"+e.height+"). Resized to "+t.width+"x"+t.height,e),t}return e}(o));var s=g(o);this.setTextureParameters(e,s);var u,h=e.mipmaps,c=e.pixelFormat,d=e.pixelType;if(e.isDataTexture)if(0<h.length&&s){for(var l=0,p=h.length;l<p;l++)u=h[l],i.texImage2D(i.TEXTURE_2D,l,c,u.width,u.height,e.border,c,d,u.data);e.generateMipmaps=!1}else i.texImage2D(i.TEXTURE_2D,0,c,o.width,o.height,e.border,c,d,o.data);else if(0<h.length&&s){for(l=0,p=h.length;l<p;l++)u=h[l],i.texImage2D(i.TEXTURE_2D,l,c,c,d,u);e.generateMipmaps=!1}else i.texImage2D(i.TEXTURE_2D,0,c,c,d,o);return e.generateMipmaps&&s&&i.generateMipmap(i.TEXTURE_2D),void(a.__version=e.version)}r.activeTexture(i.TEXTURE0+t),r.bindTexture(i.TEXTURE_2D,a.__webglTexture)},e.prototype.setTextureCube=function(e,t){var n=this.gl,i=this.state,r=this.properties.get(e);if(0<e.version&&r.__version!==e.version){void 0===r.__webglTexture&&(e.addEventListener("dispose",this.onTextureDispose,this),r.__webglTexture=n.createTexture()),i.activeTexture(n.TEXTURE0+t),i.bindTexture(n.TEXTURE_CUBE_MAP,r.__webglTexture);for(var a=[],o=0;o<6;o++)a[o]=y(e.images[o],this.capabilities.maxCubemapSize);var s=g(a[0]);this.setTextureParameters(e,s);var u=e.pixelFormat,h=e.pixelType;for(o=0;o<6;o++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,u,u,h,a[o]);return e.generateMipmaps&&s&&n.generateMipmap(n.TEXTURE_CUBE_MAP),void(r.__version=e.version)}i.activeTexture(n.TEXTURE0+t),i.bindTexture(n.TEXTURE_CUBE_MAP,r.__webglTexture)},e.prototype.setTextureParameters=function(e,t){var n=this.gl,i=e.textureType;t?(n.texParameteri(i,n.TEXTURE_WRAP_S,e.wrapS),n.texParameteri(i,n.TEXTURE_WRAP_T,e.wrapT),n.texParameteri(i,n.TEXTURE_MAG_FILTER,e.magFilter),n.texParameteri(i,n.TEXTURE_MIN_FILTER,e.minFilter)):(n.texParameteri(i,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(i,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),e.wrapS===n.CLAMP_TO_EDGE&&e.wrapT===n.CLAMP_TO_EDGE||console.warn("Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to zen3d.TEXTURE_WRAP.CLAMP_TO_EDGE.",e),n.texParameteri(i,n.TEXTURE_MAG_FILTER,a(e.magFilter)),n.texParameteri(i,n.TEXTURE_MIN_FILTER,a(e.minFilter)),(e.minFilter!==n.NEAREST&&e.minFilter!==n.LINEAR||e.magFilter!==n.NEAREST&&e.magFilter!==n.LINEAR)&&console.warn("Texture is not power of two. Texture.minFilter and Texture.magFilter should be set to zen3d.TEXTURE_FILTER.NEAREST or zen3d.TEXTURE_FILTER.LINEAR.",e));var r=this.capabilities.anisotropyExt;r&&1<e.anisotropy&&n.texParameterf(i,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(e.anisotropy,this.capabilities.maxAnisotropy))},e.prototype.setRenderTarget2D=function(e){var t=this.gl,n=this.state,i=this.properties.get(e),r=this.properties.get(e.texture);if(void 0!==r.__webglTexture&&void 0!==i.__webglFramebuffer)t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer);else{e.addEventListener("dispose",this.onRenderTargetDispose,this),r.__webglTexture=t.createTexture(),i.__webglFramebuffer=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer),n.bindTexture(t.TEXTURE_2D,r.__webglTexture);var a=g(e);this.setTextureParameters(e.texture,a);var o=e.texture.pixelFormat,s=e.texture.pixelType;if(t.texImage2D(t.TEXTURE_2D,0,o,e.width,e.height,0,o,s,null),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.__webglTexture,0),e.texture.generateMipmaps&&a&&t.generateMipmap(t.TEXTURE_2D),n.bindTexture(t.TEXTURE_2D,null),e.depthBuffer){i.__webglDepthbuffer=t.createRenderbuffer();var u=i.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,u),e.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,u)):(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,u)),t.bindRenderbuffer(t.RENDERBUFFER,null)}}},e.prototype.setRenderTargetCube=function(e){var t=this.gl,n=this.state,i=this.properties.get(e),r=this.properties.get(e.texture);if(void 0!==r.__webglTexture&&void 0!==i.__webglFramebuffer)t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,r.__webglTexture,0);else{e.addEventListener("dispose",this.onRenderTargetDispose,this),r.__webglTexture=t.createTexture(),i.__webglFramebuffer=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer),n.bindTexture(t.TEXTURE_CUBE_MAP,r.__webglTexture);var a=g(e);this.setTextureParameters(e.texture,a);for(var o=e.texture.pixelFormat,s=e.texture.pixelType,u=0;u<6;u++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,o,e.width,e.height,0,o,s,null);if(t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,r.__webglTexture,0),e.texture.generateMipmaps&&a&&t.generateMipmap(t.TEXTURE_CUBE_MAP),n.bindTexture(t.TEXTURE_CUBE_MAP,null),e.depthBuffer){i.__webglDepthbuffer=t.createRenderbuffer();var h=i.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,h),e.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,h)):(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,h)),t.bindRenderbuffer(t.RENDERBUFFER,null)}}},e.prototype.updateRenderTargetMipmap=function(e){var t=this.gl,n=this.state,i=e.texture;if(i.generateMipmaps&&g(e)&&i.minFilter!==t.NEAREST&&i.minFilter!==t.LINEAR){var r=i.textureType,a=this.properties.get(i).__webglTexture;n.bindTexture(r,a),t.generateMipmap(r),n.bindTexture(r,null)}},e.prototype.onTextureDispose=function(e){var t=this.gl,n=e.target,i=this.properties.get(n);n.removeEventListener("dispose",this.onTextureDispose,this),i.__webglTexture&&t.deleteTexture(i.__webglTexture),this.properties.delete(n)},e.prototype.onRenderTargetDispose=function(e){var t=this.gl,n=e.target,i=this.properties.get(n);n.removeEventListener("dispose",this.onRenderTargetDispose,this),i.__webglTexture&&t.deleteTexture(textureProperties.__webglTexture),i.__webglFramebuffer&&t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),this.properties.delete(n)},e.prototype.setRenderTarget=function(e){var t=this.gl,n=this.state;if(e.texture){var i=void 0!==e.activeCubeFace;if(n.currentRenderTarget!==e)i?this.setRenderTargetCube(e):this.setRenderTarget2D(e),n.currentRenderTarget=e;else if(i){var r=this.properties.get(e.texture);t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,r.__webglTexture,0)}}else n.currentRenderTarget===e||(t.bindFramebuffer(t.FRAMEBUFFER,null),n.currentRenderTarget=e)},zen3d.WebGLTexture=e}(),function(){function a(e,t,n,i){n.isInterleavedBufferAttribute&&(n=n.data);var r,a,o,s,u,h,c=t.get(n);void 0===c.buffer?function(e,t,n,i){var r=n.array,a=n.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW,o=e.createBuffer();e.bindBuffer(i,o),e.bufferData(i,r,a);var s=e.FLOAT;r instanceof Float32Array?s=e.FLOAT:r instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?s=e.UNSIGNED_SHORT:r instanceof Int16Array?s=e.SHORT:r instanceof Uint32Array?s=e.UNSIGNED_INT:r instanceof Int32Array?s=e.INT:r instanceof Int8Array?s=e.BYTE:r instanceof Uint8Array&&(s=e.UNSIGNED_BYTE),t.buffer=o,t.type=s,t.bytesPerElement=r.BYTES_PER_ELEMENT,t.version=n.version}(e,c,n,i):c.version<n.version&&(r=e,a=c.buffer,s=i,u=(o=n).array,h=o.updateRange,r.bindBuffer(s,a),!1===o.dynamic?r.bufferData(s,u,r.STATIC_DRAW):-1===h.count?r.bufferSubData(s,0,u):0===h.count?console.error("updateBuffer: dynamic BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(r.bufferSubData(s,h.offset*u.BYTES_PER_ELEMENT,u.subarray(h.offset,h.offset+h.count)),h.count=-1),c.version=n.version)}function r(e,t,n){n.isInterleavedBufferAttribute&&(n=n.data);var i=t.get(n);i.buffer&&e.deleteBuffer(i.buffer),buffers.delete(n)}var e=function(e,t,n,i){this.gl=e,this.state=t,this.properties=n,this.capabilities=i};e.prototype.setGeometry=function(e){var t=this.gl,n=(this.state,this.properties),i=this.properties.get(e);for(var r in i.created||(e.addEventListener("dispose",this.onGeometryDispose2,this),i.created=!0),null!==e.index&&a(t,n,e.index,t.ELEMENT_ARRAY_BUFFER),e.attributes)a(t,n,e.attributes[r],t.ARRAY_BUFFER)},e.prototype.onGeometryDispose=function(e){var t=this.gl,n=e.target;this.properties.get(n);for(var i in n.removeEventListener("dispose",this.onGeometryDispose,this),null!==n.index&&r(t,properties,n.index),n.attributes)r(t,properties,n.attributes[i]);this.properties.delete(n)},zen3d.WebGLGeometry=e}(),function(){var t=zen3d.WEBGL_UNIFORM_TYPE,e=function(e,t,n){this.gl=e,this.name=n.name,this.type=n.type,this.size=n.size,this.location=e.getUniformLocation(t,this.name),this.setValue=void 0,this.set=void 0,this._generateSetValue()};e.prototype._generateSetValue=function(){var r=this.gl,e=this.type,a=this.location;switch(e){case t.FLOAT:this.setValue=this.set=function(e){r.uniform1f(a,e)};break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.BOOL:case t.INT:this.setValue=this.set=function(e){r.uniform1i(a,e)};break;case t.FLOAT_VEC2:this.setValue=function(e,t){r.uniform2f(a,e,t)},this.set=function(e){r.uniform2fv(a,e)};break;case t.BOOL_VEC2:case t.INT_VEC2:this.setValue=function(e,t){r.uniform2i(a,e,t)},this.set=function(e){r.uniform2iv(a,e)};break;case t.FLOAT_VEC3:this.setValue=function(e,t,n){r.uniform3f(a,e,t,n)},this.set=function(e){r.uniform3fv(a,e)};break;case t.BOOL_VEC3:case t.INT_VEC3:this.setValue=function(e,t,n){r.uniform3i(a,e,t,n)},this.set=function(e){r.uniform3iv(a,e)};break;case t.FLOAT_VEC4:this.setValue=function(e,t,n,i){r.uniform4f(a,e,t,n,i)},this.set=function(e){r.uniform4fv(a,e)};break;case t.BOOL_VEC4:case t.INT_VEC4:this.setValue=function(e,t,n,i){r.uniform4i(a,e,t,n,i)},this.set=function(e){r.uniform4iv(a,e)};break;case t.FLOAT_MAT2:this.setValue=this.set=function(e){r.uniformMatrix2fv(a,!1,e)};break;case t.FLOAT_MAT3:this.setValue=this.set=function(e){r.uniformMatrix3fv(a,!1,e)};break;case t.FLOAT_MAT4:this.setValue=this.set=function(e){r.uniformMatrix4fv(a,!1,e)}}},zen3d.WebGLUniform=e}(),function(){var t=zen3d.WEBGL_ATTRIBUTE_TYPE,e=function(e,t,n){this.gl=e,this.name=n.name,this.type=n.type,this.size=n.size,this.location=e.getAttribLocation(t,this.name),this.count=0,this.initCount(e),this.format=e.FLOAT,this.initFormat(e)};e.prototype.initCount=function(e){switch(this.type){case t.FLOAT:case t.BYTE:case t.UNSIGNED_BYTE:case t.UNSIGNED_SHORT:this.count=1;break;case t.FLOAT_VEC2:this.count=2;break;case t.FLOAT_VEC3:this.count=3;break;case t.FLOAT_VEC4:this.count=4}},e.prototype.initFormat=function(e){switch(this.type){case t.FLOAT:case t.FLOAT_VEC2:case t.FLOAT_VEC3:case t.FLOAT_VEC4:this.format=e.FLOAT;break;case t.UNSIGNED_BYTE:this.format=e.UNSIGNED_BYTE;break;case t.UNSIGNED_SHORT:this.format=e.UNSIGNED_SHORT;break;case t.BYTE:this.format=e.BYTE}},zen3d.WebGLAttribute=e}(),function(){function h(e,t,n){var i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)||(console.log("shader not compiled!"),console.log(e.getShaderInfoLog(i))),i}var e=function(e,t,n){this.uuid=zen3d.generateUUID(),this.vshaderSource=t,this.fshaderSource=n;var i,r,a,o,s=h(e,e.VERTEX_SHADER,this.vshaderSource),u=h(e,e.FRAGMENT_SHADER,this.fshaderSource);this.id=(r=s,a=u,o=(i=e).createProgram(),i.attachShader(o,r),i.attachShader(o,a),i.linkProgram(o),i.getProgramParameter(o,i.LINK_STATUS)||(console.log("program not linked!"),console.log(i.getProgramInfoLog(o))),o),this.uniforms=function(e,t){for(var n={},i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=0;r<i;r++){var a=e.getActiveUniform(t,r),o=a.name,s=new zen3d.WebGLUniform(e,t,a);n[o]=s}return n}(e,this.id),this.attributes=function(e,t){for(var n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),r=0;r<i;r++){var a=e.getActiveAttrib(t,r),o=a.name,s=new zen3d.WebGLAttribute(e,t,a);n[o]=s}return n}(e,this.id),e.deleteShader(s),e.deleteShader(u)};e.prototype.dispose=function(e){e.deleteProgram(this.id)},zen3d.WebGLProgram=e}(),function(){var i,r,a=zen3d.CULL_FACE_TYPE,o=zen3d.BLEND_TYPE,s=zen3d.DRAW_SIDE,N=zen3d.WEBGL_UNIFORM_TYPE,I=new zen3d.Vector3,D=new zen3d.Vector4,F=function(e){return e.material},U=(r=new zen3d.Plane,function(e,t){(!i||i.length<4*e.length)&&(i=new Float32Array(4*e.length));for(var n=0;n<e.length;n++)r.copy(e[n]).applyMatrix4(t.viewMatrix),i[4*n+0]=r.normal.x,i[4*n+1]=r.normal.y,i[4*n+2]=r.normal.z,i[4*n+3]=r.constant;return i}),e=function(e){this.gl=e;var t=new zen3d.WebGLProperties;this.properties=t;var n=new zen3d.WebGLCapabilities(e);this.capabilities=n;var i=new zen3d.WebGLState(e,n);i.enable(e.STENCIL_TEST),i.enable(e.DEPTH_TEST),i.setCullFace(a.BACK),i.setFlipSided(!1),i.clearColor(0,0,0,0),this.state=i,this.texture=new zen3d.WebGLTexture(e,i,t,n),this.geometry=new zen3d.WebGLGeometry(e,i,t,n),this._usedTextureUnits=0,this._currentGeometryProgram=""};e.prototype.clear=function(e,t,n){var i=this.gl,r=0;(void 0===e||e)&&(r|=i.COLOR_BUFFER_BIT),(void 0===t||t)&&(r|=i.DEPTH_BUFFER_BIT),(void 0===n||n)&&(r|=i.STENCIL_BUFFER_BIT),i.clear(r)},e.prototype.renderPass=function(e,t,n){n=n||{};for(var i=this.gl,r=this.state,a=n.getMaterial||F,o=n.cache||{},s=(r.currentRenderTarget.width,r.currentRenderTarget.height),u=0,h=e.length;u<h;u++){var c=e[u],d=c.object,l=a.call(this,c),p=c.geometry,f=c.group,_=zen3d.getProgram(this,t,l,d,o);r.setProgram(_),this.geometry.setGeometry(p);var v=_.uuid+"_"+p.uuid;v!==this._currentGeometryProgram&&(this.setupVertexAttributes(_,p),this._currentGeometryProgram=v);var m=_.uniforms;for(var g in m){var y=m[g];switch(g){case"u_Projection":if(d.type===zen3d.OBJECT_TYPE.CANVAS2D&&d.isScreenCanvas)var E=d.orthoCamera.projectionMatrix.elements;else E=t.projectionMatrix.elements;y.setValue(E);break;case"u_View":if(d.type===zen3d.OBJECT_TYPE.CANVAS2D&&d.isScreenCanvas)var T=d.orthoCamera.viewMatrix.elements;else T=t.viewMatrix.elements;y.setValue(T);break;case"u_Model":var x=d.worldMatrix.elements;y.setValue(x);break;case"u_Color":var M=l.diffuse;y.setValue(M.r,M.g,M.b);break;case"u_Opacity":y.setValue(l.opacity);break;case"texture":var w=this.allocTexUnit();this.texture.setTexture2D(l.diffuseMap,w),y.setValue(w);break;case"normalMap":w=this.allocTexUnit();this.texture.setTexture2D(l.normalMap,w),y.setValue(w);break;case"bumpMap":w=this.allocTexUnit();this.texture.setTexture2D(l.bumpMap,w),y.setValue(w);break;case"bumpScale":y.setValue(l.bumpScale);break;case"envMap":w=this.allocTexUnit();this.texture.setTextureCube(l.envMap,w),y.setValue(w);break;case"cubeMap":w=this.allocTexUnit();this.texture.setTextureCube(l.cubeMap,w),y.setValue(w);break;case"u_EnvMap_Intensity":y.setValue(l.envMapIntensity);break;case"u_Specular":y.setValue(l.shininess);break;case"u_SpecularColor":M=l.specular;y.setValue(M.r,M.g,M.b,1);break;case"specularMap":w=this.allocTexUnit();this.texture.setTexture2D(l.specularMap,w),y.setValue(w);break;case"aoMap":w=this.allocTexUnit();this.texture.setTexture2D(l.aoMap,w),y.setValue(w);break;case"aoMapIntensity":y.setValue(l.aoMapIntensity);break;case"u_Roughness":y.setValue(l.roughness);break;case"roughnessMap":w=this.allocTexUnit();this.texture.setTexture2D(l.roughnessMap,w),y.setValue(w);break;case"u_Metalness":y.setValue(l.metalness);break;case"metalnessMap":w=this.allocTexUnit();this.texture.setTexture2D(l.metalnessMap,w),y.setValue(w);break;case"emissive":M=l.emissive;var S=l.emissiveIntensity;y.setValue(M.r*S,M.g*S,M.b*S);break;case"emissiveMap":w=this.allocTexUnit();this.texture.setTexture2D(l.emissiveMap,w),y.setValue(w);break;case"u_CameraPosition":I.setFromMatrixPosition(t.worldMatrix),y.setValue(I.x,I.y,I.z);break;case"u_FogColor":M=o.fog.color;y.setValue(M.r,M.g,M.b);break;case"u_FogDensity":y.setValue(o.fog.density);break;case"u_FogNear":y.setValue(o.fog.near);break;case"u_FogFar":y.setValue(o.fog.far);break;case"u_PointSize":y.setValue(l.size);break;case"u_PointScale":var z=.5*s;y.setValue(z);break;case"dashSize":y.setValue(l.dashSize);break;case"totalSize":y.setValue(l.dashSize+l.gapSize);break;case"scale":y.setValue(l.scale);break;case"clippingPlanes[0]":var A=U(o.clippingPlanes||[],t);i.uniform4fv(y.location,A);break;default:if(l.uniforms&&l.uniforms[g])if(y.type===N.SAMPLER_2D){w=this.allocTexUnit();this.texture.setTexture2D(l.uniforms[g],w),y.setValue(w)}else if(y.type===N.SAMPLER_CUBE){w=this.allocTexUnit();this.texture.setTextureCube(l.uniforms[g],w),y.setValue(w)}else y.set(l.uniforms[g])}}d.type===zen3d.OBJECT_TYPE.SKINNED_MESH&&this.uploadSkeleton(m,d,_.id),d.type===zen3d.OBJECT_TYPE.SPRITE&&this.uploadSpriteUniform(m,d,t,o.fog),d.type===zen3d.OBJECT_TYPE.PARTICLE&&this.uploadParticlesUniform(m,d,t),l.acceptLight&&o.lights&&this.uploadLights(m,o.lights,d.receiveShadow,t);var b=d.worldMatrix.determinant()<0;this.setStates(l,b);var L=D.set(r.currentRenderTarget.width,r.currentRenderTarget.height,r.currentRenderTarget.width,r.currentRenderTarget.height).multiply(t.rect);if(L.z-=L.x,L.w-=L.y,L.x=Math.floor(L.x),L.y=Math.floor(L.y),L.z=Math.floor(L.z),L.w=Math.floor(L.w),d.type===zen3d.OBJECT_TYPE.CANVAS2D){d.isScreenCanvas&&(d.setRenderViewport(L.x,L.y,L.z,L.w),r.viewport(d.viewport.x,d.viewport.y,d.viewport.z,d.viewport.w));for(var P=0,R=0;R<d.drawArray.length;R++){var C=d.drawArray[R];w=this.allocTexUnit();this.texture.setTexture2D(C.texture,w),m.spriteTexture.setValue(w),i.drawElements(i.TRIANGLES,6*C.count,i.UNSIGNED_SHORT,2*P),P+=6*C.count,this._usedTextureUnits=0}}else r.viewport(L.x,L.y,L.z,L.w),this.draw(p,l,f);this._usedTextureUnits=0}},e.prototype.setStates=function(e,t){var n=this.gl,i=this.state;e.transparent?i.setBlend(e.blending,e.premultipliedAlpha):i.setBlend(o.NONE),e.depthTest?(i.enable(n.DEPTH_TEST),i.depthMask(e.depthWrite)):i.disable(n.DEPTH_TEST),i.setCullFace(e.side===s.DOUBLE?a.NONE:a.BACK);var r=e.side===s.BACK;t&&(r=!r),i.setFlipSided(r),void 0!==e.lineWidth&&i.setLineWidth(e.lineWidth)},e.prototype.draw=function(e,t,n){var i=this.gl,r=null!==e.index,a=0,o=r?e.index.count:e.getAttribute("a_Position").count,s=n?n.start:0,u=n?n.count:1/0;a=Math.max(a,s),o=Math.min(o,u),r?i.drawElements(t.drawMode,o,i.UNSIGNED_SHORT,2*a):i.drawArrays(t.drawMode,a,o)},e.prototype.uploadSkeleton=function(e,t,n){if(t.skeleton&&0<t.skeleton.bones.length){var i=t.skeleton,r=this.gl;if(0<this.capabilities.maxVertexTextures&&this.capabilities.floatTextures){if(void 0===i.boneTexture){var a=Math.sqrt(4*i.bones.length);a=zen3d.nextPowerOfTwo(Math.ceil(a)),a=Math.max(4,a);var o=new Float32Array(a*a*4);o.set(i.boneMatrices);var s=new zen3d.TextureData(o,a,a);i.boneMatrices=o,i.boneTexture=s,i.boneTextureSize=a}var u=this.allocTexUnit();this.texture.setTexture2D(i.boneTexture,u),e.boneTexture&&e.boneTexture.setValue(u),e.boneTextureSize&&e.boneTextureSize.setValue(i.boneTextureSize)}else{var h=r.getUniformLocation(n,"boneMatrices");r.uniformMatrix4fv(h,!1,i.boneMatrices)}}};var f=[],_=[],v=[];e.prototype.uploadLights=function(e,t,n,i){var r=this.gl;0<t.ambientsNum&&e.u_AmbientLightColor.set(t.ambient);for(var a=0;a<t.directsNum;a++){var o=t.directional[a];e["u_Directional["+a+"].direction"].set(o.direction),e["u_Directional["+a+"].intensity"].setValue(1),e["u_Directional["+a+"].color"].set(o.color);var s=o.shadow&&n;if(e["u_Directional["+a+"].shadow"].setValue(s?1:0),s){e["u_Directional["+a+"].shadowBias"].setValue(o.shadowBias),e["u_Directional["+a+"].shadowRadius"].setValue(o.shadowRadius),e["u_Directional["+a+"].shadowMapSize"].set(o.shadowMapSize);var u=this.allocTexUnit();this.texture.setTexture2D(t.directionalShadowMap[a],u),f[a]=u}}if(0<f.length){var h=e["directionalShadowMap[0]"];r.uniform1iv(h.location,f),f.length=0;var c=e["directionalShadowMatrix[0]"];r.uniformMatrix4fv(c.location,!1,t.directionalShadowMatrix)}for(a=0;a<t.pointsNum;a++){o=t.point[a];e["u_Point["+a+"].position"].set(o.position),e["u_Point["+a+"].intensity"].setValue(1),e["u_Point["+a+"].color"].set(o.color),e["u_Point["+a+"].distance"].setValue(o.distance),e["u_Point["+a+"].decay"].setValue(o.decay);s=o.shadow&&n;if(e["u_Point["+a+"].shadow"].setValue(s?1:0),s){e["u_Point["+a+"].shadowBias"].setValue(o.shadowBias),e["u_Point["+a+"].shadowRadius"].setValue(o.shadowRadius),e["u_Point["+a+"].shadowMapSize"].set(o.shadowMapSize),e["u_Point["+a+"].shadowCameraNear"].setValue(o.shadowCameraNear),e["u_Point["+a+"].shadowCameraFar"].setValue(o.shadowCameraFar);u=this.allocTexUnit();this.texture.setTextureCube(t.pointShadowMap[a],u),_[a]=u}}if(0<_.length){var d=e["pointShadowMap[0]"];r.uniform1iv(d.location,_),_.length=0}for(a=0;a<t.spotsNum;a++){o=t.spot[a];e["u_Spot["+a+"].position"].set(o.position),e["u_Spot["+a+"].direction"].set(o.direction),e["u_Spot["+a+"].intensity"].setValue(1),e["u_Spot["+a+"].color"].set(o.color),e["u_Spot["+a+"].distance"].setValue(o.distance),e["u_Spot["+a+"].decay"].setValue(o.decay),e["u_Spot["+a+"].coneCos"].setValue(o.coneCos),e["u_Spot["+a+"].penumbraCos"].setValue(o.penumbraCos);s=o.shadow&&n;if(e["u_Spot["+a+"].shadow"].setValue(s?1:0),s){e["u_Spot["+a+"].shadowBias"].setValue(o.shadowBias),e["u_Spot["+a+"].shadowRadius"].setValue(o.shadowRadius),e["u_Spot["+a+"].shadowMapSize"].set(o.shadowMapSize);u=this.allocTexUnit();this.texture.setTexture2D(t.spotShadowMap[a],u),v[a]=u}}if(0<v.length){var l=e["spotShadowMap[0]"];r.uniform1iv(l.location,v),v.length=0;var p=e["spotShadowMatrix[0]"];r.uniformMatrix4fv(p.location,!1,t.spotShadowMatrix)}};var u=[],h=new zen3d.Vector3,c=new zen3d.Quaternion,d=new zen3d.Vector3;e.prototype.uploadSpriteUniform=function(e,t,n,i){this.gl,this.state,t.geometry;var r=t.material;e.projectionMatrix.setValue(n.projectionMatrix.elements);var a=0;i?(e.fogColor.setValue(i.color.r,i.color.g,i.color.b),i.fogType===zen3d.FOG_TYPE.NORMAL?(e.fogNear.setValue(i.near),e.fogFar.setValue(i.far),e.fogType.setValue(1),a=1):i.fogType===zen3d.FOG_TYPE.EXP2&&(e.fogDensity.setValue(i.density),e.fogType.setValue(2),a=2)):(e.fogType.setValue(0),a=0),e.alphaTest.setValue(0),e.viewMatrix.setValue(n.viewMatrix.elements),e.modelMatrix.setValue(t.worldMatrix.elements),t.worldMatrix.decompose(h,c,d),u[0]=d.x,u[1]=d.y;var o=0;i&&r.fog&&(o=a),e.fogType.setValue(o),r.diffuseMap,e.uvOffset.setValue(0,0),e.uvScale.setValue(1,1),e.opacity.setValue(r.opacity),e.color.setValue(r.diffuse.r,r.diffuse.g,r.diffuse.b),e.rotation.setValue(r.rotation),e.scale.setValue(u[0],u[1]);var s=this.allocTexUnit();this.texture.setTexture2D(r.diffuseMap,s),e.map.setValue(s)},e.prototype.uploadParticlesUniform=function(e,t,n){this.gl,this.state,t.geometry,t.material;e.uTime.setValue(t.time),e.uScale.setValue(1),e.u_Projection.setValue(n.projectionMatrix.elements),e.u_View.setValue(n.viewMatrix.elements),e.u_Model.setValue(t.worldMatrix.elements);var i=this.allocTexUnit();this.texture.setTexture2D(t.particleNoiseTex,i),e.tNoise.setValue(i);i=this.allocTexUnit();this.texture.setTexture2D(t.particleSpriteTex,i),e.tSprite.setValue(i)},e.prototype.allocTexUnit=function(){var e=this._usedTextureUnits;return e>=this.capabilities.maxTextures&&console.warn("trying to use "+e+" texture units while this GPU supports only "+this.capabilities.maxTextures),this._usedTextureUnits+=1,e},e.prototype.setupVertexAttributes=function(e,t){var n=this.gl,i=e.attributes,r=this.properties;for(var a in i){var o=i[a],s=t.getAttribute(a);if(s){var u,h=s.normalized,c=s.size;o.count!==c&&console.warn("WebGLCore: attribute "+a+" size not match! "+o.count+" : "+c);var d=(u=s.isInterleavedBufferAttribute?r.get(s.data):r.get(s)).buffer,l=u.type;o.format!==l&&console.warn("WebGLCore: attribute "+a+" type not match! "+o.format+" : "+l);var p=u.bytesPerElement;if(s.isInterleavedBufferAttribute){var f=s.data.stride,_=s.offset;n.bindBuffer(n.ARRAY_BUFFER,d),n.vertexAttribPointer(o.location,o.count,o.format,h,p*f,p*_),n.enableVertexAttribArray(o.location)}else n.bindBuffer(n.ARRAY_BUFFER,d),n.vertexAttribPointer(o.location,o.count,o.format,h,0,0),n.enableVertexAttribArray(o.location)}else console.warn("WebGLCore: geometry attribute "+a+" not found!")}if(t.index){var v=r.get(t.index);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,v.buffer)}},zen3d.WebGLCore=e}(),zen3d.ShaderChunk={ambientlight_pars_frag:"uniform vec4 u_AmbientLightColor;",aoMap_pars_frag:"#ifdef USE_AOMAP\\n\\tuniform sampler2D aoMap;\\n\\tuniform float aoMapIntensity;\\n#endif",begin_frag:"vec4 outColor = vec4(u_Color, u_Opacity);",begin_vert:"vec3 transformed = vec3(a_Position);\\n#if defined(USE_NORMAL) || defined(USE_ENV_MAP)\\n    vec3 objectNormal = vec3(a_Normal);\\n#endif",bsdfs:"\\nvec4 BRDF_Diffuse_Lambert(vec4 diffuseColor) {\\n    return RECIPROCAL_PI * diffuseColor;\\n}\\nvec4 F_Schlick( const in vec4 specularColor, const in float dotLH ) {\\n\\tfloat fresnel = pow( 1.0 - dotLH, 5.0 );\\n\\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\\n}\\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\\n\\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\\n}\\nfloat G_BlinnPhong_Implicit( ) {\\n\\treturn 0.25;\\n}\\nvec4 BRDF_Specular_BlinnPhong(vec4 specularColor, vec3 N, vec3 L, vec3 V, float shininess) {\\n    vec3 H = normalize(L + V);\\n    float dotNH = saturate(dot(N, H));\\n    float dotLH = saturate(dot(L, H));\\n    vec4 F = F_Schlick(specularColor, dotLH);\\n    float G = G_BlinnPhong_Implicit( );\\n    float D = D_BlinnPhong(shininess, dotNH);\\n    return F * G * D;\\n}\\nfloat D_GGX( const in float alpha, const in float dotNH ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\\n\\treturn RECIPROCAL_PI * a2 / pow2( denom );\\n}\\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\\n\\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\\n\\treturn 1.0 / ( gl * gv );\\n}\\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\\n\\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\\n\\treturn 0.5 / max( gv + gl, EPSILON );\\n}\\nvec4 BRDF_Specular_GGX(vec4 specularColor, vec3 N, vec3 L, vec3 V, float roughness) {\\n\\tfloat alpha = pow2( roughness );\\n\\tvec3 H = normalize(L + V);\\n\\tfloat dotNL = saturate( dot(N, L) );\\n\\tfloat dotNV = saturate( dot(N, V) );\\n\\tfloat dotNH = saturate( dot(N, H) );\\n\\tfloat dotLH = saturate( dot(L, H) );\\n\\tvec4 F = F_Schlick( specularColor, dotLH );\\n\\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\\n\\tfloat D = D_GGX( alpha, dotNH );\\n\\treturn F * G * D;\\n}\\nvec4 BRDF_Specular_GGX_Environment( const in vec3 N, const in vec3 V, const in vec4 specularColor, const in float roughness ) {\\n\\tfloat dotNV = saturate( dot( N, V ) );\\n\\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\\n\\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\\n\\tvec4 r = roughness * c0 + c1;\\n\\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\\n\\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\\n\\treturn specularColor * AB.x + AB.y;\\n}\\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\\n\\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\\n}\\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\\n\\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\\n}",bumpMap_pars_frag:"#ifdef USE_BUMPMAP\\n\\tuniform sampler2D bumpMap;\\n\\tuniform float bumpScale;\\n\\tvec2 dHdxy_fwd(vec2 uv) {\\n\\t\\tvec2 dSTdx = dFdx( uv );\\n\\t\\tvec2 dSTdy = dFdy( uv );\\n\\t\\tfloat Hll = bumpScale * texture2D( bumpMap, uv ).x;\\n\\t\\tfloat dBx = bumpScale * texture2D( bumpMap, uv + dSTdx ).x - Hll;\\n\\t\\tfloat dBy = bumpScale * texture2D( bumpMap, uv + dSTdy ).x - Hll;\\n\\t\\treturn vec2( dBx, dBy );\\n\\t}\\n\\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy) {\\n\\t\\tvec3 vSigmaX = dFdx( surf_pos );\\n\\t\\tvec3 vSigmaY = dFdy( surf_pos );\\n\\t\\tvec3 vN = surf_norm;\\n\\t\\tvec3 R1 = cross( vSigmaY, vN );\\n\\t\\tvec3 R2 = cross( vN, vSigmaX );\\n\\t\\tfloat fDet = dot( vSigmaX, R1 );\\n\\t\\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\\n\\t\\treturn normalize( abs( fDet ) * surf_norm - vGrad );\\n\\t}\\n#endif\\n",clippingPlanes_frag:"#ifdef NUM_CLIPPING_PLANES\\n    vec4 plane;\\n    for ( int i = 0; i < NUM_CLIPPING_PLANES; i ++ ) {\\n        plane = clippingPlanes[ i ];\\n        if ( dot( -v_ViewModelPos, plane.xyz ) > plane.w ) discard;\\n    }\\n#endif",clippingPlanes_pars_frag:"#ifdef NUM_CLIPPING_PLANES\\n    uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\\n#endif",color_frag:"#ifdef USE_VCOLOR\\n    outColor *= v_Color;\\n#endif",color_pars_frag:"#ifdef USE_VCOLOR\\n    varying vec4 v_Color;\\n#endif",color_pars_vert:"#ifdef USE_VCOLOR\\n    attribute vec4 a_Color;\\n    varying vec4 v_Color;\\n#endif",color_vert:"#ifdef USE_VCOLOR\\n    v_Color = a_Color;\\n#endif",common_frag:"uniform mat4 u_View;\\nuniform float u_Opacity;\\nuniform vec3 u_Color;\\nuniform vec3 u_CameraPosition;",common_vert:"attribute vec3 a_Position;\\nattribute vec3 a_Normal;\\n#include <transpose>\\n#include <inverse>\\nuniform mat4 u_Projection;\\nuniform mat4 u_View;\\nuniform mat4 u_Model;\\nuniform vec3 u_CameraPosition;",diffuseMap_frag:"#ifdef USE_DIFFUSE_MAP\\n    vec4 texelColor = texture2D( texture, v_Uv );\\n    texelColor = mapTexelToLinear( texelColor );\\n    outColor *= texelColor;\\n#endif",diffuseMap_pars_frag:"#ifdef USE_DIFFUSE_MAP\\n    uniform sampler2D texture;\\n#endif",directlight_pars_frag:"struct DirectLight\\n{\\n    vec3 direction;\\n    vec4 color;\\n    float intensity;\\n    int shadow;\\n    float shadowBias;\\n    float shadowRadius;\\n    vec2 shadowMapSize;\\n};\\nuniform DirectLight u_Directional[USE_DIRECT_LIGHT];",emissiveMap_frag:"#ifdef USE_EMISSIVEMAP\\n\\tvec4 emissiveColor = texture2D(emissiveMap, v_Uv);\\n\\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\\n\\ttotalEmissiveRadiance *= emissiveColor.rgb;\\n#endif",emissiveMap_pars_frag:"#ifdef USE_EMISSIVEMAP\\n\\tuniform sampler2D emissiveMap;\\n#endif",encodings_frag:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_frag:"\\nvec4 LinearToLinear( in vec4 value ) {\\n\\treturn value;\\n}\\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\\n}\\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\\n}\\nvec4 sRGBToLinear( in vec4 value ) {\\n\\treturn 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\\treturn 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}\\nvec4 RGBEToLinear( in vec4 value ) {\\n\\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\\n}\\nvec4 LinearToRGBE( in vec4 value ) {\\n\\tfloat maxComponent = max( max( value.r, value.g ), value.b );\\n\\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\\n\\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\\n}\\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\\n}\\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\\n\\tfloat M      = clamp( maxRGB / maxRange, 0.0, 1.0 );\\n\\tM            = ceil( M * 255.0 ) / 255.0;\\n\\treturn vec4( value.rgb / ( M * maxRange ), M );\\n}\\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\\n}\\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\\n\\tfloat D      = max( maxRange / maxRGB, 1.0 );\\n\\tD            = min( floor( D ) / 255.0, 1.0 );\\n\\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\\n}\\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\\nvec4 LinearToLogLuv( in vec4 value )  {\\n\\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\\n\\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\\n\\tvec4 vResult;\\n\\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\\n\\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\\n\\tvResult.w = fract(Le);\\n\\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\\n\\treturn vResult;\\n}\\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\\nvec4 LogLuvToLinear( in vec4 value ) {\\n\\tfloat Le = value.z * 255.0 + value.w;\\n\\tvec3 Xp_Y_XYZp;\\n\\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\\n\\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\\n\\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\\n\\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\\n\\treturn vec4( max(vRGB, 0.0), 1.0 );\\n}\\n",end_frag:"gl_FragColor = outColor;",envMap_frag:"#ifdef USE_ENV_MAP\\n    vec3 envDir;\\n    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n        envDir = reflect(normalize(v_worldPos - u_CameraPosition), (vec4(N, 1.0) * u_View).xyz);\\n    #else\\n        envDir = v_EnvPos;\\n    #endif\\n    vec4 envColor = textureCube(envMap, envDir);\\n    envColor = envMapTexelToLinear( envColor );\\n    #ifdef ENVMAP_BLENDING_MULTIPLY\\n\\t\\toutColor = mix(outColor, envColor * outColor, u_EnvMap_Intensity);\\n\\t#elif defined( ENVMAP_BLENDING_MIX )\\n\\t\\toutColor = mix(outColor, envColor, u_EnvMap_Intensity);\\n\\t#elif defined( ENVMAP_BLENDING_ADD )\\n\\t\\toutColor += envColor * u_EnvMap_Intensity;\\n\\t#endif\\n#endif",envMap_pars_frag:"#ifdef USE_ENV_MAP\\n    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n        varying vec3 v_worldPos;\\n    #else\\n        varying vec3 v_EnvPos;\\n    #endif\\n    uniform samplerCube envMap;\\n    uniform float u_EnvMap_Intensity;\\n#endif",envMap_pars_vert:"#ifdef USE_ENV_MAP\\n    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n        varying vec3 v_worldPos;\\n    #else\\n        varying vec3 v_EnvPos;\\n    #endif\\n#endif",envMap_vert:"#ifdef USE_ENV_MAP\\n    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n        v_worldPos = (u_Model * vec4(transformed, 1.0)).xyz;\\n    #else\\n        v_EnvPos = reflect(normalize((u_Model * vec4(transformed, 1.0)).xyz - u_CameraPosition), (transpose(inverse(u_Model)) * vec4(objectNormal, 1.0)).xyz);\\n    #endif\\n#endif",fog_frag:"#ifdef USE_FOG\\n    float depth = gl_FragCoord.z / gl_FragCoord.w;\\n    #ifdef USE_EXP2_FOG\\n        float fogFactor = whiteCompliment( exp2( - u_FogDensity * u_FogDensity * depth * depth * LOG2 ) );\\n    #else\\n        float fogFactor = smoothstep( u_FogNear, u_FogFar, depth );\\n    #endif\\n    gl_FragColor.rgb = mix( gl_FragColor.rgb, u_FogColor, fogFactor );\\n#endif",fog_pars_frag:"#ifdef USE_FOG\\n    uniform vec3 u_FogColor;\\n    #ifdef USE_EXP2_FOG\\n        uniform float u_FogDensity;\\n    #else\\n        uniform float u_FogNear;\\n        uniform float u_FogFar;\\n    #endif\\n#endif",inverse:"mat4 inverse(mat4 m) {\\n    float\\n    a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\\n    a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\\n    a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\\n    a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\\n    b00 = a00 * a11 - a01 * a10,\\n    b01 = a00 * a12 - a02 * a10,\\n    b02 = a00 * a13 - a03 * a10,\\n    b03 = a01 * a12 - a02 * a11,\\n    b04 = a01 * a13 - a03 * a11,\\n    b05 = a02 * a13 - a03 * a12,\\n    b06 = a20 * a31 - a21 * a30,\\n    b07 = a20 * a32 - a22 * a30,\\n    b08 = a20 * a33 - a23 * a30,\\n    b09 = a21 * a32 - a22 * a31,\\n    b10 = a21 * a33 - a23 * a31,\\n    b11 = a22 * a33 - a23 * a32,\\n    det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\\n    return mat4(\\n        a11 * b11 - a12 * b10 + a13 * b09,\\n        a02 * b10 - a01 * b11 - a03 * b09,\\n        a31 * b05 - a32 * b04 + a33 * b03,\\n        a22 * b04 - a21 * b05 - a23 * b03,\\n        a12 * b08 - a10 * b11 - a13 * b07,\\n        a00 * b11 - a02 * b08 + a03 * b07,\\n        a32 * b02 - a30 * b05 - a33 * b01,\\n        a20 * b05 - a22 * b02 + a23 * b01,\\n        a10 * b10 - a11 * b08 + a13 * b06,\\n        a01 * b08 - a00 * b10 - a03 * b06,\\n        a30 * b04 - a31 * b02 + a33 * b00,\\n        a21 * b02 - a20 * b04 - a23 * b00,\\n        a11 * b07 - a10 * b09 - a12 * b06,\\n        a00 * b09 - a01 * b07 + a02 * b06,\\n        a31 * b01 - a30 * b03 - a32 * b00,\\n        a20 * b03 - a21 * b01 + a22 * b00) / det;\\n}",light_frag:"#ifdef USE_LIGHT\\n    vec4 light;\\n    vec3 L;\\n    vec4 totalReflect = vec4(0., 0., 0., 0.);    vec4 indirectIrradiance = vec4(0., 0., 0., 0.);    vec4 indirectRadiance = vec4(0., 0., 0., 0.);\\n    #ifdef USE_PBR\\n        vec4 diffuseColor = outColor.xyzw * (1.0 - metalnessFactor);\\n        vec4 specularColor = mix(vec4(0.04), outColor.xyzw, metalnessFactor);\\n        float roughness = clamp(roughnessFactor, 0.04, 1.0);\\n    #else\\n        vec4 diffuseColor = outColor.xyzw;\\n        #ifdef USE_PHONG\\n            vec4 specularColor = u_SpecularColor;\\n            float shininess = u_Specular;\\n        #endif\\n    #endif\\n    #ifdef USE_AMBIENT_LIGHT\\n        #ifdef USE_PBR\\n            indirectIrradiance += PI * diffuseColor * u_AmbientLightColor;\\n        #else\\n            indirectIrradiance += diffuseColor * u_AmbientLightColor;\\n        #endif\\n    #endif\\n    #ifdef USE_PBR\\n        #ifdef USE_ENV_MAP\\n    \\t\\tvec3 envDir;\\n    \\t    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n    \\t        envDir = reflect(normalize(v_worldPos - u_CameraPosition), (vec4(N, 1.0) * u_View).xyz);\\n    \\t    #else\\n    \\t        envDir = v_EnvPos;\\n    \\t    #endif\\n            indirectIrradiance += getLightProbeIndirectIrradiance(8, envDir);\\n            indirectRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(roughness), 8, envDir);\\n    \\t#endif\\n    #endif\\n    #if (defined(USE_PHONG) || defined(USE_PBR))\\n        vec3 V = normalize( (u_View * vec4(u_CameraPosition, 1.)).xyz - v_ViewModelPos);\\n    #endif\\n    #ifdef USE_DIRECT_LIGHT\\n    for(int i = 0; i < USE_DIRECT_LIGHT; i++) {\\n        L = -u_Directional[i].direction;\\n        light = u_Directional[i].color * u_Directional[i].intensity;\\n        L = normalize(L);\\n        float dotNL = saturate( dot(N, L) );\\n        vec4 irradiance = light * dotNL;\\n        #ifdef USE_SHADOW\\n            irradiance *= bool( u_Directional[i].shadow ) ? getShadow( directionalShadowMap[ i ], vDirectionalShadowCoord[ i ], u_Directional[i].shadowBias, u_Directional[i].shadowRadius, u_Directional[i].shadowMapSize ) : 1.0;\\n        #endif\\n        #ifdef USE_PBR\\n            irradiance *= PI;\\n        #endif\\n        vec4 reflectLight = irradiance * BRDF_Diffuse_Lambert(diffuseColor);\\n        #ifdef USE_PHONG\\n            reflectLight += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\\n        #endif\\n        #ifdef USE_PBR\\n            reflectLight += irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness) * specularStrength;\\n        #endif\\n        totalReflect += reflectLight;\\n    }\\n    #endif\\n    #ifdef USE_POINT_LIGHT\\n    for(int i = 0; i < USE_POINT_LIGHT; i++) {\\n        L = u_Point[i].position - v_ViewModelPos;\\n        float dist = pow(clamp(1. - length(L) / u_Point[i].distance, 0.0, 1.0), u_Point[i].decay);\\n        light = u_Point[i].color * u_Point[i].intensity * dist;\\n        L = normalize(L);\\n        float dotNL = saturate( dot(N, L) );\\n        vec4 irradiance = light * dotNL;\\n        #ifdef USE_PBR\\n            irradiance *= PI;\\n        #endif\\n        #ifdef USE_SHADOW\\n            vec3 worldV = (vec4(v_ViewModelPos, 1.) * u_View - vec4(u_Point[i].position, 1.) * u_View).xyz;\\n            irradiance *= bool( u_Point[i].shadow ) ? getPointShadow( pointShadowMap[ i ], worldV, u_Point[i].shadowBias, u_Point[i].shadowRadius, u_Point[i].shadowMapSize, u_Point[i].shadowCameraNear, u_Point[i].shadowCameraFar ) : 1.0;\\n        #endif\\n        vec4 reflectLight = irradiance * BRDF_Diffuse_Lambert(diffuseColor);\\n        #ifdef USE_PHONG\\n            reflectLight += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\\n        #endif\\n        #ifdef USE_PBR\\n            reflectLight += irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness) * specularStrength;\\n        #endif\\n        totalReflect += reflectLight;\\n    }\\n    #endif\\n    #ifdef USE_SPOT_LIGHT\\n    for(int i = 0; i < USE_SPOT_LIGHT; i++) {\\n        L = u_Spot[i].position - v_ViewModelPos;\\n        float lightDistance = length(L);\\n        L = normalize(L);\\n        float angleCos = dot( L, -normalize(u_Spot[i].direction) );\\n        if( all( bvec2(angleCos > u_Spot[i].coneCos, lightDistance < u_Spot[i].distance) ) ) {\\n            float spotEffect = smoothstep( u_Spot[i].coneCos, u_Spot[i].penumbraCos, angleCos );\\n            float dist = pow(clamp(1. - lightDistance / u_Spot[i].distance, 0.0, 1.0), u_Spot[i].decay);\\n            light = u_Spot[i].color * u_Spot[i].intensity * dist * spotEffect;\\n            float dotNL = saturate( dot(N, L) );\\n            vec4 irradiance = light * dotNL;\\n            #ifdef USE_PBR\\n                irradiance *= PI;\\n            #endif\\n            #ifdef USE_SHADOW\\n                irradiance *= bool( u_Spot[i].shadow ) ? getShadow( spotShadowMap[ i ], vSpotShadowCoord[ i ], u_Spot[i].shadowBias, u_Spot[i].shadowRadius, u_Spot[i].shadowMapSize ) : 1.0;\\n            #endif\\n            vec4 reflectLight = irradiance * BRDF_Diffuse_Lambert(diffuseColor);\\n            #ifdef USE_PHONG\\n                reflectLight += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\\n            #endif\\n            #ifdef USE_PBR\\n                reflectLight += irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness) * specularStrength;\\n            #endif\\n            totalReflect += reflectLight;\\n        }\\n    }\\n    #endif\\n    vec4 indirectDiffuse = indirectIrradiance * BRDF_Diffuse_Lambert(diffuseColor);\\n    vec4 indirectSpecular = vec4(0., 0., 0., 0.);\\n    #if defined( USE_ENV_MAP ) && defined( USE_PBR )\\n        indirectSpecular += indirectRadiance * BRDF_Specular_GGX_Environment(N, V, specularColor, roughness) * specularStrength;\\n    #endif\\n    #ifdef USE_AOMAP\\n    \\tfloat ambientOcclusion = ( texture2D( aoMap, v_Uv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\\n    \\tindirectDiffuse *= ambientOcclusion;\\n    \\t#if defined( USE_ENV_MAP ) && defined( USE_PBR )\\n    \\t\\tfloat dotNV = saturate( dot( N, V ) );\\n    \\t\\tindirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, GGXRoughnessToBlinnExponent(roughness) );\\n    \\t#endif\\n    #endif\\n    outColor.xyz = totalReflect.xyz + indirectDiffuse.xyz + indirectSpecular.xyz;\\n#endif",light_pars_frag:"#ifdef USE_AMBIENT_LIGHT\\n    #include <ambientlight_pars_frag>\\n#endif\\n#ifdef USE_DIRECT_LIGHT\\n    #include <directlight_pars_frag>\\n#endif\\n#ifdef USE_POINT_LIGHT\\n    #include <pointlight_pars_frag>\\n#endif\\n#ifdef USE_SPOT_LIGHT\\n    #include <spotlight_pars_frag>\\n#endif\\n#if defined(USE_PBR) && defined(USE_ENV_MAP)\\n    vec4 getLightProbeIndirectIrradiance(const in int maxMIPLevel, const in vec3 envDir) {\\n    \\t#ifdef TEXTURE_LOD_EXT\\n    \\t\\tvec4 envMapColor = textureCubeLodEXT( envMap, envDir, float( maxMIPLevel ) );\\n    \\t#else\\n    \\t\\tvec4 envMapColor = textureCube( envMap, envDir, float( maxMIPLevel ) );\\n    \\t#endif\\n        envMapColor = envMapTexelToLinear( envMapColor );\\n        return PI * envMapColor * u_EnvMap_Intensity;\\n    }\\n    float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\\n    \\tfloat maxMIPLevelScalar = float( maxMIPLevel );\\n    \\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\\n    \\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\\n    }\\n    vec4 getLightProbeIndirectRadiance(const in float blinnShininessExponent, const in int maxMIPLevel, const in vec3 envDir) {\\n        float specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\\n        #ifdef TEXTURE_LOD_EXT\\n    \\t\\tvec4 envMapColor = textureCubeLodEXT( envMap, envDir, specularMIPLevel );\\n    \\t#else\\n    \\t\\tvec4 envMapColor = textureCube( envMap, envDir, specularMIPLevel );\\n    \\t#endif\\n        envMapColor = envMapTexelToLinear( envMapColor );\\n        return envMapColor * u_EnvMap_Intensity;\\n    }\\n    float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\\n    \\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\\n    }\\n#endif",normalMap_pars_frag:"#include <tbn>\\n#include <tsn>\\nuniform sampler2D normalMap;",normal_frag:"#ifdef USE_NORMAL\\n    #ifdef DOUBLE_SIDED\\n    \\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n    #else\\n    \\tfloat flipNormal = 1.0;\\n    #endif\\n    #ifdef FLAT_SHADED\\n    \\tvec3 fdx = vec3( dFdx( v_ViewModelPos.x ), dFdx( v_ViewModelPos.y ), dFdx( v_ViewModelPos.z ) );\\n    \\tvec3 fdy = vec3( dFdy( v_ViewModelPos.x ), dFdy( v_ViewModelPos.y ), dFdy( v_ViewModelPos.z ) );\\n    \\tvec3 N = normalize( cross( fdx, fdy ) );\\n    #else\\n        vec3 N = normalize(v_Normal) * flipNormal;\\n    #endif\\n    #ifdef USE_NORMAL_MAP\\n        vec3 normalMapColor = texture2D(normalMap, v_Uv).rgb;\\n        mat3 tspace = tsn(N, -v_ViewModelPos, vec2(v_Uv.x, 1.0 - v_Uv.y));\\n        N = normalize(tspace * (normalMapColor * 2.0 - 1.0));\\n    #elif defined(USE_BUMPMAP)\\n        N = perturbNormalArb(-v_ViewModelPos, N, dHdxy_fwd(v_Uv));\\n    #endif\\n#endif",normal_pars_frag:"#ifdef USE_NORMAL\\n    varying vec3 v_Normal;\\n#endif",normal_pars_vert:"#ifdef USE_NORMAL\\n    varying vec3 v_Normal;\\n#endif",normal_vert:"#ifdef USE_NORMAL\\n    v_Normal = (transpose(inverse(u_View * u_Model)) * vec4(objectNormal, 1.0)).xyz;\\n    #ifdef FLIP_SIDED\\n    \\tv_Normal = - v_Normal;\\n    #endif\\n#endif",packing:"const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,  256. );\\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\\nconst float ShiftRight8 = 1. / 256.;\\nvec4 packDepthToRGBA( const in float v ) {\\n    vec4 r = vec4( fract( v * PackFactors ), v );\\n    r.yzw -= r.xyz * ShiftRight8;    return r * PackUpscale;\\n}\\nfloat unpackRGBAToDepth( const in vec4 v ) {\\n    return dot( v, UnpackFactors );\\n}",pointlight_pars_frag:"struct PointLight\\n{\\n    vec3 position;\\n    vec4 color;\\n    float intensity;\\n    float distance;\\n    float decay;\\n    int shadow;\\n    float shadowBias;\\n    float shadowRadius;\\n    vec2 shadowMapSize;\\n    float shadowCameraNear;\\n    float shadowCameraFar;\\n};\\nuniform PointLight u_Point[USE_POINT_LIGHT];",premultipliedAlpha_frag:"#ifdef USE_PREMULTIPLIED_ALPHA\\n    gl_FragColor.rgb = gl_FragColor.rgb * gl_FragColor.a;\\n#endif",pvm_vert:"gl_Position = u_Projection * u_View * u_Model * vec4(transformed, 1.0);",shadowMap_frag:"#ifdef USE_SHADOW\\n#endif",shadowMap_pars_frag:"#ifdef USE_SHADOW\\n    #include <packing>\\n    #ifdef USE_DIRECT_LIGHT\\n        uniform sampler2D directionalShadowMap[ USE_DIRECT_LIGHT ];\\n        varying vec4 vDirectionalShadowCoord[ USE_DIRECT_LIGHT ];\\n    #endif\\n    #ifdef USE_POINT_LIGHT\\n        uniform samplerCube pointShadowMap[ USE_POINT_LIGHT ];\\n    #endif\\n    #ifdef USE_SPOT_LIGHT\\n        uniform sampler2D spotShadowMap[ USE_SPOT_LIGHT ];\\n        varying vec4 vSpotShadowCoord[ USE_SPOT_LIGHT ];\\n    #endif\\n    float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\\n        return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\\n    }\\n    float textureCubeCompare( samplerCube depths, vec3 uv, float compare ) {\\n        return step( compare, unpackRGBAToDepth( textureCube( depths, uv ) ) );\\n    }\\n    float getShadow( sampler2D shadowMap, vec4 shadowCoord, float shadowBias, float shadowRadius, vec2 shadowMapSize ) {\\n        shadowCoord.xyz /= shadowCoord.w;\\n        float depth = shadowCoord.z + shadowBias;\\n        bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\\n        bool inFrustum = all( inFrustumVec );\\n        bvec2 frustumTestVec = bvec2( inFrustum, depth <= 1.0 );\\n        bool frustumTest = all( frustumTestVec );\\n        if ( frustumTest ) {\\n            #ifdef USE_PCF_SOFT_SHADOW\\n                float texelSize = shadowRadius / shadowMapSize.x;\\n                vec2 poissonDisk[4];\\n                poissonDisk[0] = vec2(-0.94201624, -0.39906216);\\n                poissonDisk[1] = vec2(0.94558609, -0.76890725);\\n                poissonDisk[2] = vec2(-0.094184101, -0.92938870);\\n                poissonDisk[3] = vec2(0.34495938, 0.29387760);\\n                return texture2DCompare( shadowMap, shadowCoord.xy + poissonDisk[0] * texelSize, depth ) * 0.25 +\\n                    texture2DCompare( shadowMap, shadowCoord.xy + poissonDisk[1] * texelSize, depth ) * 0.25 +\\n                    texture2DCompare( shadowMap, shadowCoord.xy + poissonDisk[2] * texelSize, depth ) * 0.25 +\\n                    texture2DCompare( shadowMap, shadowCoord.xy + poissonDisk[3] * texelSize, depth ) * 0.25;\\n            #else\\n                return texture2DCompare( shadowMap, shadowCoord.xy, depth );\\n            #endif\\n        }\\n        return 1.0;\\n    }\\n    float getPointShadow( samplerCube shadowMap, vec3 V, float shadowBias, float shadowRadius, vec2 shadowMapSize, float shadowCameraNear, float shadowCameraFar ) {\\n\\t\\tfloat depth = ( length( V ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\\t\\tdepth += shadowBias;\\n        #ifdef USE_PCF_SOFT_SHADOW\\n            float texelSize = shadowRadius / shadowMapSize.x;\\n            vec3 poissonDisk[4];\\n    \\t\\tpoissonDisk[0] = vec3(-1.0, 1.0, -1.0);\\n    \\t\\tpoissonDisk[1] = vec3(1.0, -1.0, -1.0);\\n    \\t\\tpoissonDisk[2] = vec3(-1.0, -1.0, -1.0);\\n    \\t\\tpoissonDisk[3] = vec3(1.0, -1.0, 1.0);\\n            return textureCubeCompare( shadowMap, normalize(V) + poissonDisk[0] * texelSize, depth ) * 0.25 +\\n                textureCubeCompare( shadowMap, normalize(V) + poissonDisk[1] * texelSize, depth ) * 0.25 +\\n                textureCubeCompare( shadowMap, normalize(V) + poissonDisk[2] * texelSize, depth ) * 0.25 +\\n                textureCubeCompare( shadowMap, normalize(V) + poissonDisk[3] * texelSize, depth ) * 0.25;\\n        #else\\n            return textureCubeCompare( shadowMap, normalize(V), depth);\\n        #endif\\n    }\\n#endif",shadowMap_pars_vert:"#ifdef USE_SHADOW\\n    #ifdef USE_DIRECT_LIGHT\\n        uniform mat4 directionalShadowMatrix[ USE_DIRECT_LIGHT ];\\n        varying vec4 vDirectionalShadowCoord[ USE_DIRECT_LIGHT ];\\n    #endif\\n    #ifdef USE_POINT_LIGHT\\n    #endif\\n    #ifdef USE_SPOT_LIGHT\\n        uniform mat4 spotShadowMatrix[ USE_SPOT_LIGHT ];\\n        varying vec4 vSpotShadowCoord[ USE_SPOT_LIGHT ];\\n    #endif\\n#endif",shadowMap_vert:"#ifdef USE_SHADOW\\n    vec4 worldPosition = u_Model * vec4(transformed, 1.0);\\n    #ifdef USE_DIRECT_LIGHT\\n        for ( int i = 0; i < USE_DIRECT_LIGHT; i ++ ) {\\n            vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\\n        }\\n    #endif\\n    #ifdef USE_POINT_LIGHT\\n    #endif\\n    #ifdef USE_SPOT_LIGHT\\n        for ( int i = 0; i < USE_SPOT_LIGHT; i ++ ) {\\n            vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\\n        }\\n    #endif\\n#endif",skinning_pars_vert:"#ifdef USE_SKINNING\\n    attribute vec4 skinIndex;\\n\\tattribute vec4 skinWeight;\\n    #ifdef BONE_TEXTURE\\n        uniform sampler2D boneTexture;\\n        uniform int boneTextureSize;\\n        mat4 getBoneMatrix( const in float i ) {\\n            float j = i * 4.0;\\n            float x = mod( j, float( boneTextureSize ) );\\n            float y = floor( j / float( boneTextureSize ) );\\n            float dx = 1.0 / float( boneTextureSize );\\n            float dy = 1.0 / float( boneTextureSize );\\n            y = dy * ( y + 0.5 );\\n            vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\\n            vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\\n            vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\\n            vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\\n            mat4 bone = mat4( v1, v2, v3, v4 );\\n            return bone;\\n        }\\n    #else\\n        uniform mat4 boneMatrices[MAX_BONES];\\n        mat4 getBoneMatrix(const in float i) {\\n            mat4 bone = boneMatrices[int(i)];\\n            return bone;\\n        }\\n    #endif\\n#endif",skinning_vert:"#ifdef USE_SKINNING\\n    mat4 boneMatX = getBoneMatrix( skinIndex.x );\\n    mat4 boneMatY = getBoneMatrix( skinIndex.y );\\n    mat4 boneMatZ = getBoneMatrix( skinIndex.z );\\n    mat4 boneMatW = getBoneMatrix( skinIndex.w );\\n    vec4 skinVertex = vec4(transformed, 1.0);\\n    vec4 skinned = vec4( 0.0 );\\n\\tskinned += boneMatX * skinVertex * skinWeight.x;\\n\\tskinned += boneMatY * skinVertex * skinWeight.y;\\n\\tskinned += boneMatZ * skinVertex * skinWeight.z;\\n\\tskinned += boneMatW * skinVertex * skinWeight.w;\\n    transformed = vec3(skinned.xyz / skinned.w);\\n    #if defined(USE_NORMAL) || defined(USE_ENV_MAP)\\n        mat4 skinMatrix = mat4( 0.0 );\\n        skinMatrix += skinWeight.x * boneMatX;\\n        skinMatrix += skinWeight.y * boneMatY;\\n        skinMatrix += skinWeight.z * boneMatZ;\\n        skinMatrix += skinWeight.w * boneMatW;\\n        objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\\n    #endif\\n#endif",specularMap_frag:"float specularStrength;\\n#ifdef USE_SPECULARMAP\\n\\tvec4 texelSpecular = texture2D( specularMap, v_Uv );\\n\\tspecularStrength = texelSpecular.r;\\n#else\\n\\tspecularStrength = 1.0;\\n#endif",specularMap_pars_frag:"#ifdef USE_SPECULARMAP\\n\\tuniform sampler2D specularMap;\\n#endif",spotlight_pars_frag:"struct SpotLight\\n{\\n    vec3 position;\\n    vec4 color;\\n    float intensity;\\n    float distance;\\n    float decay;\\n    float coneCos;\\n    float penumbraCos;\\n    vec3 direction;\\n    int shadow;\\n    float shadowBias;\\n    float shadowRadius;\\n    vec2 shadowMapSize;\\n};\\nuniform SpotLight u_Spot[USE_SPOT_LIGHT];",tbn:"mat3 tbn(vec3 N, vec3 p, vec2 uv) {\\n    vec3 dp1 = dFdx(p.xyz);\\n    vec3 dp2 = dFdy(p.xyz);\\n    vec2 duv1 = dFdx(uv.st);\\n    vec2 duv2 = dFdy(uv.st);\\n    vec3 dp2perp = cross(dp2, N);\\n    vec3 dp1perp = cross(N, dp1);\\n    vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\\n    vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\\n    float invmax = 1.0 / sqrt(max(dot(T,T), dot(B,B)));\\n    return mat3(T * invmax, B * invmax, N);\\n}",transpose:"mat4 transpose(mat4 inMatrix) {\\n    vec4 i0 = inMatrix[0];\\n    vec4 i1 = inMatrix[1];\\n    vec4 i2 = inMatrix[2];\\n    vec4 i3 = inMatrix[3];\\n    mat4 outMatrix = mat4(\\n        vec4(i0.x, i1.x, i2.x, i3.x),\\n        vec4(i0.y, i1.y, i2.y, i3.y),\\n        vec4(i0.z, i1.z, i2.z, i3.z),\\n        vec4(i0.w, i1.w, i2.w, i3.w)\\n    );\\n    return outMatrix;\\n}",tsn:"mat3 tsn(vec3 N, vec3 V, vec2 uv) {\\n    vec3 q0 = dFdx( V.xyz );\\n    vec3 q1 = dFdy( V.xyz );\\n    vec2 st0 = dFdx( uv.st );\\n    vec2 st1 = dFdy( uv.st );\\n    vec3 S = normalize( q0 * st1.t - q1 * st0.t );\\n    vec3 T = normalize( -q0 * st1.s + q1 * st0.s );\\n    mat3 tsn = mat3( S, T, N );\\n    return tsn;\\n}",uv_pars_frag:"#if defined(USE_DIFFUSE_MAP) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(USE_SPECULARMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP)\\n    varying vec2 v_Uv;\\n#endif\\n#ifdef USE_AOMAP\\n    varying vec2 v_Uv2;\\n#endif",uv_pars_vert:"#if defined(USE_DIFFUSE_MAP) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(USE_SPECULARMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP)\\n    attribute vec2 a_Uv;\\n    varying vec2 v_Uv;\\n#endif\\n#ifdef USE_AOMAP\\n    attribute vec2 a_Uv2;\\n    varying vec2 v_Uv2;\\n#endif\\n",uv_vert:"#if defined(USE_DIFFUSE_MAP) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(USE_SPECULARMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP)\\n    v_Uv = a_Uv;\\n#endif\\n#ifdef USE_AOMAP\\n    v_Uv2 = a_Uv2;\\n#endif",viewModelPos_pars_frag:"#if defined(USE_POINT_LIGHT) || defined(USE_SPOT_LIGHT) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(FLAT_SHADED) || defined(USE_PHONG) || defined(USE_PBR) || defined(NUM_CLIPPING_PLANES) \\n    varying vec3 v_ViewModelPos;\\n#endif",viewModelPos_pars_vert:"#if defined(USE_POINT_LIGHT) || defined(USE_SPOT_LIGHT) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(FLAT_SHADED) || defined(USE_PHONG) || defined(USE_PBR)|| defined(NUM_CLIPPING_PLANES)\\n    varying vec3 v_ViewModelPos;\\n#endif",viewModelPos_vert:"#if defined(USE_POINT_LIGHT) || defined(USE_SPOT_LIGHT) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(FLAT_SHADED) || defined(USE_PHONG) || defined(USE_PBR) || defined(NUM_CLIPPING_PLANES)\\n    v_ViewModelPos = (u_View * u_Model * vec4(transformed, 1.0)).xyz;\\n#endif"},zen3d.ShaderLib={basic_frag:"#include <common_frag>\\n#include <uv_pars_frag>\\n#include <color_pars_frag>\\n#include <diffuseMap_pars_frag>\\n#include <envMap_pars_frag>\\n#include <aoMap_pars_frag>\\n#include <fog_pars_frag>\\nvoid main() {\\n    #include <begin_frag>\\n    #include <color_frag>\\n    #include <diffuseMap_frag>\\n    #include <envMap_frag>\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",basic_vert:"#include <common_vert>\\n#include <uv_pars_vert>\\n#include <color_pars_vert>\\n#include <envMap_pars_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    #include <uv_vert>\\n    #include <color_vert>\\n    #include <envMap_vert>\\n}",canvas2d_frag:"#include <common_frag>\\nvarying vec2 v_Uv;\\nuniform sampler2D spriteTexture;\\nvoid main() {\\n    #include <begin_frag>\\n    outColor *= texture2D(spriteTexture, v_Uv);\\n    #include <end_frag>\\n    #include <premultipliedAlpha_frag>\\n}",canvas2d_vert:"#include <common_vert>\\nattribute vec2 a_Uv;\\nvarying vec2 v_Uv;\\nvoid main() {\\n    #include <begin_vert>\\n    #include <pvm_vert>\\n    v_Uv = a_Uv;\\n}",cube_frag:"#include <common_frag>\\nuniform samplerCube cubeMap;\\nvarying vec3 v_ModelPos;\\nvoid main() {\\n    #include <begin_frag>\\n    outColor *= textureCube(cubeMap, v_ModelPos);\\n    #include <end_frag>\\n}",cube_vert:"#include <common_vert>\\nvarying vec3 v_ModelPos;\\nvoid main() {\\n    #include <begin_vert>\\n    #include <pvm_vert>\\n    v_ModelPos = (u_Model * vec4(transformed, 1.0)).xyz;\\n}",depth_frag:"#include <common_frag>\\n#include <packing>\\nvoid main() {\\n    #ifdef DEPTH_PACKING_RGBA\\n        gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\\n    #else\\n        gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), u_Opacity );\\n    #endif\\n}",depth_vert:"#include <common_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n}",distance_frag:"#include <common_frag>\\nuniform float nearDistance;\\nuniform float farDistance;\\nvarying vec3 v_ModelPos;\\n#include <packing>\\nvoid main() {\\n    float dist = length( v_ModelPos - u_CameraPosition );\\n\\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\\n\\tdist = saturate( dist );\\n    gl_FragColor = packDepthToRGBA(dist);\\n}",distance_vert:"#include <common_vert>\\nvarying vec3 v_ModelPos;\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    v_ModelPos = (u_Model * vec4(transformed, 1.0)).xyz;\\n}",lambert_frag:"#include <common_frag>\\nuniform vec3 emissive;\\n#include <uv_pars_frag>\\n#include <color_pars_frag>\\n#include <diffuseMap_pars_frag>\\n#include <normalMap_pars_frag>\\n#include <bumpMap_pars_frag>\\n#include <light_pars_frag>\\n#include <normal_pars_frag>\\n#include <viewModelPos_pars_frag>\\n#include <bsdfs>\\n#include <envMap_pars_frag>\\n#include <aoMap_pars_frag>\\n#include <shadowMap_pars_frag>\\n#include <fog_pars_frag>\\n#include <emissiveMap_pars_frag>\\n#include <clippingPlanes_pars_frag>\\nvoid main() {\\n    #include <clippingPlanes_frag>\\n    #include <begin_frag>\\n    #include <color_frag>\\n    #include <diffuseMap_frag>\\n    #include <normal_frag>\\n    #include <light_frag>\\n    #include <envMap_frag>\\n    #include <shadowMap_frag>\\n    vec3 totalEmissiveRadiance = emissive;\\n    #include <emissiveMap_frag>\\n    outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",lambert_vert:"#include <common_vert>\\n#include <normal_pars_vert>\\n#include <uv_pars_vert>\\n#include <color_pars_vert>\\n#include <viewModelPos_pars_vert>\\n#include <envMap_pars_vert>\\n#include <shadowMap_pars_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    #include <normal_vert>\\n    #include <uv_vert>\\n    #include <color_vert>\\n    #include <viewModelPos_vert>\\n    #include <envMap_vert>\\n    #include <shadowMap_vert>\\n}",linedashed_frag:"#include <common_frag>\\n#include <fog_pars_frag>\\nuniform float dashSize;\\nuniform float totalSize;\\nvarying float vLineDistance;\\nvoid main() {\\n    if ( mod( vLineDistance, totalSize ) > dashSize ) {\\n\\t\\tdiscard;\\n\\t}\\n    #include <begin_frag>\\n    #include <end_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",linedashed_vert:"#include <common_vert>\\nuniform float scale;\\nattribute float lineDistance;\\nvarying float vLineDistance;\\nvoid main() {\\n    vLineDistance = scale * lineDistance;\\n    vec3 transformed = vec3(a_Position);\\n    #include <pvm_vert>\\n}",particle_frag:"float scaleLinear(float value, vec2 valueDomain) {\\n    return (value - valueDomain.x) / (valueDomain.y - valueDomain.x);\\n}\\nfloat scaleLinear(float value, vec2 valueDomain, vec2 valueRange) {\\n    return mix(valueRange.x, valueRange.y, scaleLinear(value, valueDomain));\\n}\\nvarying vec4 vColor;\\nvarying float lifeLeft;\\nuniform sampler2D tSprite;\\nvoid main() {\\n    float alpha = 0.;\\n    if( lifeLeft > .995 ) {\\n        alpha = scaleLinear( lifeLeft, vec2(1., .995), vec2(0., 1.));\\n    } else {\\n        alpha = lifeLeft * .75;\\n    }\\n    vec4 tex = texture2D( tSprite, gl_PointCoord );\\n    gl_FragColor = vec4( vColor.rgb * tex.a, alpha * tex.a );\\n}",particle_vert:"const vec4 bitSh = vec4(256. * 256. * 256., 256. * 256., 256., 1.);\\nconst vec4 bitMsk = vec4(0.,vec3(1./256.0));\\nconst vec4 bitShifts = vec4(1.) / bitSh;\\n#define FLOAT_MAX\\t1.70141184e38\\n#define FLOAT_MIN\\t1.17549435e-38\\nlowp vec4 encode_float(highp float v) {\\n    highp float av = abs(v);\\n    if(av < FLOAT_MIN) {\\n        return vec4(0.0, 0.0, 0.0, 0.0);\\n    } else if(v > FLOAT_MAX) {\\n        return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\\n    } else if(v < -FLOAT_MAX) {\\n        return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\\n    }\\n    highp vec4 c = vec4(0,0,0,0);\\n    highp float e = floor(log2(av));\\n    highp float m = av * pow(2.0, -e) - 1.0;\\n    c[1] = floor(128.0 * m);\\n    m -= c[1] / 128.0;\\n    c[2] = floor(32768.0 * m);\\n    m -= c[2] / 32768.0;\\n    c[3] = floor(8388608.0 * m);\\n    highp float ebias = e + 127.0;\\n    c[0] = floor(ebias / 2.0);\\n    ebias -= c[0] * 2.0;\\n    c[1] += floor(ebias) * 128.0;\\n    c[0] += 128.0 * step(0.0, -v);\\n    return c / 255.0;\\n}\\nvec4 pack(const in float depth)\\n{\\n    const vec4 bit_shift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\\n    const vec4 bit_mask\\t= vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\\n    vec4 res = mod(depth*bit_shift*vec4(255), vec4(256))/vec4(255);\\n    res -= res.xxyz * bit_mask;\\n    return res;\\n}\\nfloat unpack(const in vec4 rgba_depth)\\n{\\n    const vec4 bit_shift = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\\n    float depth = dot(rgba_depth, bit_shift);\\n    return depth;\\n}\\nuniform float uTime;\\nuniform float uScale;\\nuniform sampler2D tNoise;\\nuniform mat4 u_Projection;\\nuniform mat4 u_View;\\nuniform mat4 u_Model;\\nattribute vec4 particlePositionsStartTime;\\nattribute vec4 particleVelColSizeLife;\\nvarying vec4 vColor;\\nvarying float lifeLeft;\\nvoid main() {\\n    vColor = encode_float( particleVelColSizeLife.y );\\n    vec4 velTurb = encode_float( particleVelColSizeLife.x );\\n    vec3 velocity = vec3( velTurb.xyz );\\n    float turbulence = velTurb.w;\\n    vec3 newPosition;\\n    float timeElapsed = uTime - particlePositionsStartTime.a;\\n    lifeLeft = 1. - (timeElapsed / particleVelColSizeLife.w);\\n    gl_PointSize = ( uScale * particleVelColSizeLife.z ) * lifeLeft;\\n    velocity.x = ( velocity.x - .5 ) * 3.;\\n    velocity.y = ( velocity.y - .5 ) * 3.;\\n    velocity.z = ( velocity.z - .5 ) * 3.;\\n    newPosition = particlePositionsStartTime.xyz + ( velocity * 10. ) * ( uTime - particlePositionsStartTime.a );\\n    vec3 noise = texture2D( tNoise, vec2( newPosition.x * .015 + (uTime * .05), newPosition.y * .02 + (uTime * .015) )).rgb;\\n    vec3 noiseVel = ( noise.rgb - .5 ) * 30.;\\n    newPosition = mix(newPosition, newPosition + vec3(noiseVel * ( turbulence * 5. ) ), (timeElapsed / particleVelColSizeLife.a) );\\n    if( velocity.y > 0. && velocity.y < .05 ) {\\n        lifeLeft = 0.;\\n    }\\n    if( velocity.x < -1.45 ) {\\n        lifeLeft = 0.;\\n    }\\n    if( timeElapsed > 0. ) {\\n        gl_Position = u_Projection * u_View * u_Model * vec4( newPosition, 1.0 );\\n    } else {\\n        gl_Position = u_Projection * u_View * u_Model * vec4( particlePositionsStartTime.xyz, 1.0 );\\n        lifeLeft = 0.;\\n        gl_PointSize = 0.;\\n    }\\n}",pbr_frag:"#include <common_frag>\\nuniform float u_Metalness;\\n#ifdef USE_METALNESSMAP\\n\\tuniform sampler2D metalnessMap;\\n#endif\\nuniform float u_Roughness;\\n#ifdef USE_ROUGHNESSMAP\\n\\tuniform sampler2D roughnessMap;\\n#endif\\nuniform vec3 emissive;\\n#include <uv_pars_frag>\\n#include <color_pars_frag>\\n#include <diffuseMap_pars_frag>\\n#include <normalMap_pars_frag>\\n#include <bumpMap_pars_frag>\\n#include <envMap_pars_frag>\\n#include <aoMap_pars_frag>\\n#include <light_pars_frag>\\n#include <normal_pars_frag>\\n#include <viewModelPos_pars_frag>\\n#include <bsdfs>\\n#include <shadowMap_pars_frag>\\n#include <fog_pars_frag>\\n#include <emissiveMap_pars_frag>\\n#include <clippingPlanes_pars_frag>\\nvoid main() {\\n    #include <clippingPlanes_frag>\\n    #include <begin_frag>\\n    #include <color_frag>\\n    #include <diffuseMap_frag>\\n    #include <normal_frag>\\n    #include <specularMap_frag>\\n    float roughnessFactor = u_Roughness;\\n    #ifdef USE_ROUGHNESSMAP\\n    \\tvec4 texelRoughness = texture2D( roughnessMap, v_Uv );\\n    \\troughnessFactor *= texelRoughness.g;\\n    #endif\\n    float metalnessFactor = u_Metalness;\\n    #ifdef USE_METALNESSMAP\\n    \\tvec4 texelMetalness = texture2D( metalnessMap, v_Uv );\\n    \\tmetalnessFactor *= texelMetalness.b;\\n    #endif\\n    #include <light_frag>\\n    #include <shadowMap_frag>\\n    vec3 totalEmissiveRadiance = emissive;\\n    #include <emissiveMap_frag>\\n    outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",pbr_vert:"#include <common_vert>\\n#include <normal_pars_vert>\\n#include <uv_pars_vert>\\n#include <color_pars_vert>\\n#include <viewModelPos_pars_vert>\\n#include <envMap_pars_vert>\\n#include <shadowMap_pars_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    #include <normal_vert>\\n    #include <uv_vert>\\n    #include <color_vert>\\n    #include <viewModelPos_vert>\\n    #include <envMap_vert>\\n    #include <shadowMap_vert>\\n}",phong_frag:"#include <common_frag>\\nuniform float u_Specular;\\nuniform vec4 u_SpecularColor;\\n#include <specularMap_pars_frag>\\nuniform vec3 emissive;\\n#include <uv_pars_frag>\\n#include <color_pars_frag>\\n#include <diffuseMap_pars_frag>\\n#include <normalMap_pars_frag>\\n#include <bumpMap_pars_frag>\\n#include <light_pars_frag>\\n#include <normal_pars_frag>\\n#include <viewModelPos_pars_frag>\\n#include <bsdfs>\\n#include <envMap_pars_frag>\\n#include <aoMap_pars_frag>\\n#include <shadowMap_pars_frag>\\n#include <fog_pars_frag>\\n#include <emissiveMap_pars_frag>\\n#include <clippingPlanes_pars_frag>\\nvoid main() {\\n    #include <clippingPlanes_frag>\\n    #include <begin_frag>\\n    #include <color_frag>\\n    #include <diffuseMap_frag>\\n    #include <normal_frag>\\n    #include <specularMap_frag>\\n    #include <light_frag>\\n    #include <envMap_frag>\\n    #include <shadowMap_frag>\\n    vec3 totalEmissiveRadiance = emissive;\\n    #include <emissiveMap_frag>\\n    outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",phong_vert:"#include <common_vert>\\n#include <normal_pars_vert>\\n#include <uv_pars_vert>\\n#include <color_pars_vert>\\n#include <viewModelPos_pars_vert>\\n#include <envMap_pars_vert>\\n#include <shadowMap_pars_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    #include <normal_vert>\\n    #include <uv_vert>\\n    #include <color_vert>\\n    #include <viewModelPos_vert>\\n    #include <envMap_vert>\\n    #include <shadowMap_vert>\\n}",point_frag:"#include <common_frag>\\n#include <diffuseMap_pars_frag>\\n#include <fog_pars_frag>\\nvoid main() {\\n    #include <begin_frag>\\n    #ifdef USE_DIFFUSE_MAP\\n        outColor *= texture2D(texture, vec2(gl_PointCoord.x, 1.0 - gl_PointCoord.y));\\n    #endif\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",point_vert:"#include <common_vert>\\nuniform float u_PointSize;\\nuniform float u_PointScale;\\nvoid main() {\\n    #include <begin_vert>\\n    #include <pvm_vert>\\n    vec4 mvPosition = u_View * u_Model * vec4(transformed, 1.0);\\n    #ifdef USE_SIZEATTENUATION\\n        gl_PointSize = u_PointSize * ( u_PointScale / - mvPosition.z );\\n    #else\\n        gl_PointSize = u_PointSize;\\n    #endif\\n}",sprite_frag:"uniform vec3 color;\\nuniform sampler2D map;\\nuniform float opacity;\\nuniform int fogType;\\nuniform vec3 fogColor;\\nuniform float fogDensity;\\nuniform float fogNear;\\nuniform float fogFar;\\nuniform float alphaTest;\\nvarying vec2 vUV;\\nvoid main() {\\n    vec4 texture = texture2D( map, vUV );\\n    if ( texture.a < alphaTest ) discard;\\n    gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\\n    if ( fogType > 0 ) {\\n        float depth = gl_FragCoord.z / gl_FragCoord.w;\\n        float fogFactor = 0.0;\\n        if ( fogType == 1 ) {\\n            fogFactor = smoothstep( fogNear, fogFar, depth );\\n        } else {\\n            \\n            fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\\n            fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\\n        }\\n        gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\\n    }\\n}",sprite_vert:"uniform mat4 modelMatrix;\\nuniform mat4 viewMatrix;\\nuniform mat4 projectionMatrix;\\nuniform float rotation;\\nuniform vec2 scale;\\nuniform vec2 uvOffset;\\nuniform vec2 uvScale;\\nattribute vec2 position;\\nattribute vec2 uv;\\nvarying vec2 vUV;\\nvoid main() {\\n    vUV = uvOffset + uv * uvScale;\\n    vec2 alignedPosition = position * scale;\\n    vec2 rotatedPosition;\\n    rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\\n    rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\\n    vec4 finalPosition;\\n    finalPosition = viewMatrix * modelMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\\n    finalPosition.xy += rotatedPosition;\\n    finalPosition = projectionMatrix * finalPosition;\\n    gl_Position = finalPosition;\\n}"},function(){var y={};var E=zen3d.MATERIAL_TYPE,i=zen3d.TEXEL_ENCODING_TYPE,f=zen3d.ENVMAP_COMBINE_TYPE;function T(e,t){var n;return e?e.encoding&&(n=e.encoding):n=i.LINEAR,n===i.LINEAR&&t&&(n=i.GAMMA),n}function _(e){switch(e){case i.LINEAR:return["Linear","( value )"];case i.SRGB:return["sRGB","( value )"];case i.RGBE:return["RGBE","( value )"];case i.RGBM7:return["RGBM","( value, 7.0 )"];case i.RGBM16:return["RGBM","( value, 16.0 )"];case i.RGBD:return["RGBD","( value, 256.0 )"];case i.GAMMA:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:console.error("unsupported encoding: "+e)}}function v(e,t){var n=_(t);return"vec4 "+e+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function x(e,t,n,i){var r=zen3d.ShaderLib[t.materialType+"_vert"]||t.vertexShader||zen3d.ShaderLib.basic_vert,a=zen3d.ShaderLib[t.materialType+"_frag"]||t.fragmentShader||zen3d.ShaderLib.basic_frag;r=m(r),a=m(a);var o,s,u,h=[""],c=["#define PI 3.14159265359","#define EPSILON 1e-6","float pow2( const in float x ) { return x*x; }","#define LOG2 1.442695","#define RECIPROCAL_PI 0.31830988618","#define saturate(a) clamp( a, 0.0, 1.0 )","#define whiteCompliment(a) ( 1.0 - saturate( a ) )"];switch(t.materialType){case E.CUBE:case E.CANVAS2D:case E.SPRITE:case E.PARTICLE:case E.SHADER:break;case E.LAMBERT:case E.PHONG:case E.PBR:c.push(t.useRoughnessMap?"#define USE_ROUGHNESSMAP":""),c.push(t.useMetalnessMap?"#define USE_METALNESSMAP":"");case E.POINT:h.push(0<t.pointLightNum?"#define USE_POINT_LIGHT "+t.pointLightNum:""),h.push(0<t.spotLightNum?"#define USE_SPOT_LIGHT "+t.spotLightNum:""),h.push(0<t.directLightNum?"#define USE_DIRECT_LIGHT "+t.directLightNum:""),h.push(0<t.ambientLightNum?"#define USE_AMBIENT_LIGHT "+t.ambientLightNum:""),h.push(0<t.pointLightNum||0<t.directLightNum||0<t.ambientLightNum||0<t.spotLightNum?"#define USE_LIGHT":""),h.push(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum?"#define USE_NORMAL":""),h.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useNormalMap?"#define USE_NORMAL_MAP":""),h.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useBumpMap?"#define USE_BUMPMAP":""),h.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useSpecularMap?"#define USE_SPECULARMAP":""),h.push(t.useEmissiveMap?"#define USE_EMISSIVEMAP":""),h.push(t.useShadow?"#define USE_SHADOW":""),h.push(t.materialType==E.LAMBERT?"#define USE_LAMBERT":""),h.push(t.materialType==E.PHONG?"#define USE_PHONG":""),h.push(t.materialType==E.PBR?"#define USE_PBR":""),h.push(t.flipSided?"#define FLIP_SIDED":""),h.push(0<t.numClippingPlanes?"#define NUM_CLIPPING_PLANES "+t.numClippingPlanes:""),c.push(0<t.pointLightNum?"#define USE_POINT_LIGHT "+t.pointLightNum:""),c.push(0<t.spotLightNum?"#define USE_SPOT_LIGHT "+t.spotLightNum:""),c.push(0<t.directLightNum?"#define USE_DIRECT_LIGHT "+t.directLightNum:""),c.push(0<t.ambientLightNum?"#define USE_AMBIENT_LIGHT "+t.ambientLightNum:""),c.push(0<t.pointLightNum||0<t.directLightNum||0<t.ambientLightNum||0<t.spotLightNum?"#define USE_LIGHT":""),c.push(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum?"#define USE_NORMAL":""),c.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useNormalMap?"#define USE_NORMAL_MAP":""),c.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useBumpMap?"#define USE_BUMPMAP":""),c.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useSpecularMap?"#define USE_SPECULARMAP":""),c.push(t.useEmissiveMap?"#define USE_EMISSIVEMAP":""),c.push(t.useShadow?"#define USE_SHADOW":""),c.push(t.usePCFSoftShadow?"#define USE_PCF_SOFT_SHADOW":""),c.push(t.flatShading?"#define FLAT_SHADED":""),c.push(t.materialType==E.LAMBERT?"#define USE_LAMBERT":""),c.push(t.materialType==E.PHONG?"#define USE_PHONG":""),c.push(t.materialType==E.PBR?"#define USE_PBR":""),c.push(t.doubleSided?"#define DOUBLE_SIDED":""),c.push(t.envMap&&t.useShaderTextureLOD?"#define TEXTURE_LOD_EXT":""),c.push(0<t.numClippingPlanes?"#define NUM_CLIPPING_PLANES "+t.numClippingPlanes:"");case E.BASIC:if(h.push(t.useDiffuseMap?"#define USE_DIFFUSE_MAP":""),h.push(t.useEnvMap?"#define USE_ENV_MAP":""),h.push(t.useVertexColors?"#define USE_VCOLOR":""),h.push(t.sizeAttenuation?"#define USE_SIZEATTENUATION":""),h.push(t.useAOMap?"#define USE_AOMAP":""),c.push(t.useDiffuseMap?"#define USE_DIFFUSE_MAP":""),c.push(t.useEnvMap?"#define USE_ENV_MAP":""),c.push(t.useVertexColors?"#define USE_VCOLOR":""),t.useEnvMap){var d="";switch(t.envMapCombine){case f.MULTIPLY:d="ENVMAP_BLENDING_MULTIPLY";break;case f.MIX:d="ENVMAP_BLENDING_MIX";break;case f.ADD:d="ENVMAP_BLENDING_ADD"}c.push("#define "+d)}c.push(t.useAOMap?"#define USE_AOMAP":"");case E.LINE:case E.LINE_LOOP:c.push(zen3d.ShaderChunk.encodings_pars_frag),c.push("#define GAMMA_FACTOR "+t.gammaFactor),c.push(v("mapTexelToLinear",t.diffuseMapEncoding)),c.push(v("envMapTexelToLinear",t.envMapEncoding)),c.push(v("emissiveMapTexelToLinear",t.emissiveMapEncoding)),c.push((o="linearToOutputTexel",s=t.outputEncoding,u=_(s),"vec4 "+o+"( vec4 value ) { return LinearTo"+u[0]+u[1]+"; }")),c.push(t.premultipliedAlpha?"#define USE_PREMULTIPLIED_ALPHA":"");case E.DEPTH:c.push(t.packDepthToRGBA?"#define DEPTH_PACKING_RGBA":"");case E.DISTANCE:h.push(t.useSkinning?"#define USE_SKINNING":""),h.push(0<t.bonesNum?"#define MAX_BONES "+t.bonesNum:""),h.push(t.useVertexTexture?"#define BONE_TEXTURE":"");case E.LINE_DASHED:c.push(t.fog?"#define USE_FOG":""),c.push(t.fogExp2?"#define USE_EXP2_FOG":"")}var l=["precision "+t.precision+" float;","precision "+t.precision+" int;",h.join("\\n"),r].join("\\n"),p=["#extension GL_OES_standard_derivatives : enable",t.useShaderTextureLOD&&t.useEnvMap?"#extension GL_EXT_shader_texture_lod : enable":"","precision "+t.precision+" float;","precision "+t.precision+" int;",c.join("\\n"),a].join("\\n");return new zen3d.WebGLProgram(e,l,p)}var m=function(e){return e.replace(/#include +<([\\w\\d.]+)>/g,function(e,t){var n=zen3d.ShaderChunk[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return m(n)})};zen3d.getProgram=function(e,t,n,i,r){var a=e.gl,o=e.capabilities,s=(n=n||i.material,r?r.lights:null),u=r?r.fog:null,h=r?r.clippingPlanes:null,c={};c.precision=o.maxPrecision,c.materialType=n.type;var d=e.state.currentRenderTarget;switch(n.type){case E.PBR:c.useRoughnessMap=!!n.roughnessMap,c.useMetalnessMap=!!n.metalnessMap;case E.BASIC:case E.LAMBERT:case E.PHONG:case E.POINT:case E.LINE:case E.LINE_LOOP:c.gammaFactor=t.gammaFactor,c.outputEncoding=T(d.texture||null,t.gammaOutput),c.diffuseMapEncoding=T(n.diffuseMap,t.gammaInput),c.envMapEncoding=T(n.envMap,t.gammaInput),c.emissiveMapEncoding=T(n.emissiveMap,t.gammaInput),c.useShaderTextureLOD=!!o.shaderTextureLOD,c.useVertexColors=n.vertexColors,c.numClippingPlanes=h?h.length:0,c.useAOMap=!!n.aoMap;case E.CUBE:case E.LINE_DASHED:c.useDiffuseMap=!!n.diffuseMap,c.useNormalMap=!!n.normalMap,c.useBumpMap=!!n.bumpMap,c.useSpecularMap=!!n.specularMap,c.useEnvMap=!!n.envMap,c.envMapCombine=n.envMapCombine,c.useEmissiveMap=!!n.emissiveMap,c.useDiffuseColor=!n.diffuseMap,c.ambientLightNum=s?s.ambientsNum:0,c.directLightNum=s?s.directsNum:0,c.pointLightNum=s?s.pointsNum:0,c.spotLightNum=s?s.spotsNum:0,c.flatShading=n.shading===zen3d.SHADING_TYPE.FLAT_SHADING,c.useShadow=i.receiveShadow,c.usePCFSoftShadow=i.shadowType===zen3d.SHADOW_TYPE.PCF_SOFT,c.premultipliedAlpha=n.premultipliedAlpha,c.fog=!!u,c.fogExp2=!!u&&u.fogType===zen3d.FOG_TYPE.EXP2,c.sizeAttenuation=n.sizeAttenuation,c.doubleSided=n.side===zen3d.DRAW_SIDE.DOUBLE,c.flipSided=n.side===zen3d.DRAW_SIDE.BACK;case E.DEPTH:c.packDepthToRGBA=n.packToRGBA;case E.DISTANCE:var l=i.type===zen3d.OBJECT_TYPE.SKINNED_MESH&&i.skeleton,p=o.maxVertexUniformVectors,f=0<o.maxVertexTextures&&o.floatTextures,_=0;f?_=1024:p<16*(_=i.skeleton?i.skeleton.bones.length:0)&&(console.warn("Program: too many bones ("+_+"), current cpu only support "+Math.floor(p/16)+" bones!!"),_=Math.floor(p/16)),c.useSkinning=l,c.bonesNum=_,c.useVertexTexture=f;break;case E.SHADER:c.vertexShader=n.vertexShader,c.fragmentShader=n.fragmentShader;case E.CANVAS2D:case E.PARTICLE:case E.SPRITE:}var v,m=function(e){var t="";for(var n in e)t+=e[n]+"_";return t}(c),g=y;return g[m]?v=g[m]:(v=x(a,c),g[m]=v),v}}(),function(){var e=function(){this.camera=new zen3d.Camera,this.targets=[new zen3d.Vector3(1,0,0),new zen3d.Vector3(-1,0,0),new zen3d.Vector3(0,1,0),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,0,1),new zen3d.Vector3(0,0,-1)],this.ups=[new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,0,1),new zen3d.Vector3(0,0,-1),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,-1,0)],this.camera.setPerspective(.5*Math.PI,1,1,1e3),this.position=new zen3d.Vector3,this.lookTarget=new zen3d.Vector3,this.renderTarget=new zen3d.RenderTargetCube(512,512),this.renderTexture=this.renderTarget.texture,this.renderTexture.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_LINEAR,this.shadowMapPass=new zen3d.ShadowMapPass,this.forwardPass=new zen3d.ForwardPass,this.shadowAutoUpdate=!0,this.shadowNeedsUpdate=!1};e.prototype.render=function(e,t){this.camera.position.copy(this.position);for(var n=0;n<6;n++)this.lookTarget.set(this.targets[n].x+this.camera.position.x,this.targets[n].y+this.camera.position.y,this.targets[n].z+this.camera.position.z),this.camera.setLookAt(this.lookTarget,this.ups[n]),this.camera.updateMatrix(),t.update(this.camera),(this.shadowAutoUpdate||this.shadowNeedsUpdate)&&(this.shadowMapPass.render(e,t),this.shadowNeedsUpdate=!1),this.renderTarget.activeCubeFace=n,e.texture.setRenderTarget(this.renderTarget),e.state.clearColor(0,0,0,0),e.clear(!0,!0,!0),this.forwardPass.render(e,t),e.texture.updateRenderTargetMipmap(this.renderTarget)},zen3d.EnvironmentMapPass=e}(),function(){var e=function(){this.depthMaterial=new zen3d.DepthMaterial,this.depthMaterial.packToRGBA=!0,this.distanceMaterial=new zen3d.DistanceMaterial};e.prototype.render=function(e,t){var n=e.gl,i=e.state,r=i.states[n.STENCIL_TEST];r&&i.disable(n.STENCIL_TEST);for(var a=t.cache.lights.shadows,o=0;o<a.length;o++)for(var s=a[o],u=s.shadow,h=u.camera,c=u.renderTarget,d=s.lightType==zen3d.LIGHT_TYPE.POINT,l=d?6:1,p=t.cache.shadowObjects,f=0;f<l;f++)if(d?(u.update(s,f),c.activeCubeFace=f):u.update(s),e.texture.setRenderTarget(c),i.clearColor(1,1,1,1),e.clear(!0,!0),0!=p.length){var _=d?this.distanceMaterial:this.depthMaterial;_.uniforms=_.uniforms||{},_.uniforms.nearDistance=u.cameraNear,_.uniforms.farDistance=u.cameraFar,e.renderPass(p,h,{getMaterial:function(e){return _.side=e.material.side,_}})}r&&i.enable(n.STENCIL_TEST)},zen3d.ShadowMapPass=e}(),function(){zen3d.RENDER_LAYER;var o=zen3d.LAYER_RENDER_LIST,e=function(){};e.prototype.render=function(e,t){for(var n=t.cache.camera,i=t.cache.renderLists,r=0;r<o.length;r++){var a=o[r];e.renderPass(i[a],n,{getMaterial:function(e){return t.overrideMaterial||e.material},cache:t.cache})}},zen3d.ForwardPass=e}(),function(){var e=function(e,t){this.backRenderTarget=new zen3d.RenderTargetBack(e);var n=e.getContext("webgl",t||{antialias:!0,alpha:!1,stencil:!0});this.glCore=new zen3d.WebGLCore(n),this.autoClear=!0,this.performance=new zen3d.Performance,this.shadowMapPass=new zen3d.ShadowMapPass,this.forwardPass=new zen3d.ForwardPass,this.shadowAutoUpdate=!0,this.shadowNeedsUpdate=!1};e.prototype.render=function(e,t,n,i){var r=this.performance;r.updateFps(),r.startCounter("render",60),e.update(t),r.startCounter("renderShadow",60),(this.shadowAutoUpdate||this.shadowNeedsUpdate)&&(this.shadowMapPass.render(this.glCore,e),this.shadowNeedsUpdate=!1),r.endCounter("renderShadow"),void 0===n&&(n=this.backRenderTarget),this.glCore.texture.setRenderTarget(n),(this.autoClear||i)&&(this.glCore.state.clearColor(0,0,0,0),this.glCore.clear(!0,!0,!0)),r.startCounter("renderList",60),this.forwardPass.render(this.glCore,e),r.endCounter("renderList"),n.texture&&this.glCore.texture.updateRenderTargetMipmap(n),this.performance.endCounter("render")},zen3d.Renderer=e}(),function(){var T=zen3d.OBJECT_TYPE,x=zen3d.LIGHT_TYPE,M=zen3d.RENDER_LAYER,n=zen3d.LAYER_RENDER_LIST,t=function(e,t){return e.z-t.z},i=function(e,t){return t.z-e.z},r={};function w(e){if(void 0!==r[e.uuid])return r[e.uuid];var t;switch(e.lightType){case x.DIRECT:t={direction:new Float32Array(3),color:new Float32Array([0,0,0,1]),shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Float32Array(2)};break;case x.POINT:t={position:new Float32Array(3),color:new Float32Array([0,0,0,1]),distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Float32Array(2),shadowCameraNear:1,shadowCameraFar:1e3};break;case x.SPOT:t={position:new Float32Array(3),direction:new Float32Array(3),color:new Float32Array([0,0,0,1]),distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Float32Array(2)}}return r[e.uuid]=t}var e=function(){for(var e={},t=0;t<n.length;t++)e[n[t]]=new Array;this.renderLists=e,this.shadowObjects=new Array,this.lights={ambient:new Float32Array([0,0,0,1]),directional:[],directionalShadowMap:[],directionalShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],shadows:[],ambientsNum:0,directsNum:0,pointsNum:0,spotsNum:0,shadowsNum:0,totalNum:0},this.camera=null,this.fog=null,this.clippingPlanes=null},S=new zen3d.Vector3,z=new zen3d.Frustum,A=new zen3d.Matrix4,b=new zen3d.Sphere;e.prototype.cacheScene=function(e,t){this.camera=t,this.fog=e.fog,this.clippingPlanes=e.clippingPlanes,this.cacheObject(e)},e.prototype.cacheObject=function(e){var t=this.camera;switch(e.type){case T.POINT:case T.LINE:case T.LINE_LOOP:case T.LINE_SEGMENTS:case T.MESH:case T.SKINNED_MESH:if(e.frustumCulled)if(b.copy(e.geometry.boundingSphere).applyMatrix4(e.worldMatrix),A.multiplyMatrices(t.projectionMatrix,t.viewMatrix),z.setFromMatrix(A),!z.intersectsSphere(b))break;S.setFromMatrixPosition(e.worldMatrix),S.applyMatrix4(t.viewMatrix).applyMatrix4(t.projectionMatrix);var n=e.material;if(Array.isArray(n))for(var i=e.geometry.groups,r=0;r<i.length;r++){var a=i[r],o=n[a.materialIndex];o&&(this.renderLists[o.transparent?M.TRANSPARENT:M.DEFAULT].push({object:e,geometry:e.geometry,material:o,z:S.z,group:a}),e.castShadow&&this.shadowObjects.push({object:e,geometry:e.geometry,material:o,z:S.z,group:a}))}else this.renderLists[n.transparent?M.TRANSPARENT:M.DEFAULT].push({object:e,geometry:e.geometry,material:e.material,z:S.z}),e.castShadow&&this.shadowObjects.push({object:e,geometry:e.geometry,material:e.material,z:S.z});break;case T.CANVAS2D:if(e.frustumCulled)if(b.copy(e.geometry.boundingSphere).applyMatrix4(e.worldMatrix),A.multiplyMatrices(t.projectionMatrix,t.viewMatrix),z.setFromMatrix(A),!z.intersectsSphere(b))break;S.setFromMatrixPosition(e.worldMatrix),S.applyMatrix4(t.viewMatrix).applyMatrix4(t.projectionMatrix),this.renderLists[M.CANVAS2D].push({object:e,geometry:e.geometry,material:e.material,z:S.z});break;case T.SPRITE:if(e.frustumCulled)if(b.center.set(0,0,0),b.radius=.7071067811865476,b.applyMatrix4(e.worldMatrix),A.multiplyMatrices(t.projectionMatrix,t.viewMatrix),z.setFromMatrix(A),!z.intersectsSphere(b))break;S.setFromMatrixPosition(e.worldMatrix),S.applyMatrix4(t.viewMatrix).applyMatrix4(t.projectionMatrix),this.renderLists[M.SPRITE].push({object:e,geometry:e.geometry,material:e.material,z:S.z});break;case T.PARTICLE:S.setFromMatrixPosition(e.worldMatrix),S.applyMatrix4(t.viewMatrix).applyMatrix4(t.projectionMatrix),this.renderLists[M.PARTICLE].push({object:e,geometry:e.geometry,material:e.material,z:S.z});break;case T.LIGHT:var s=this.lights;if(e.lightType==x.AMBIENT){var u=e.intensity,h=e.color;s.ambient[0]+=h.r*u,s.ambient[1]+=h.g*u,s.ambient[2]+=h.b*u,s.ambientsNum++}else if(e.lightType==x.DIRECT){u=e.intensity,h=e.color;(v=w(e)).color[0]=h.r*u,v.color[1]=h.g*u,v.color[2]=h.b*u;var c=S;if(e.getWorldDirection(c),c.transformDirection(t.viewMatrix),v.direction[0]=c.x,v.direction[1]=c.y,v.direction[2]=c.z,e.castShadow?(v.shadow=!0,v.shadowBias=e.shadow.bias,v.shadowRadius=e.shadow.radius,v.shadowMapSize[0]=e.shadow.mapSize.x,v.shadowMapSize[1]=e.shadow.mapSize.y):v.shadow=!1,e.castShadow){var d=16*(s.directsNum+1);if(s.directionalShadowMatrix.length<d){var l=s.directionalShadowMatrix;s.directionalShadowMatrix=new Float32Array(d),s.directionalShadowMatrix.set(l)}s.directionalShadowMatrix.set(e.shadow.matrix.elements,16*s.directsNum),s.directionalShadowMap[s.directsNum]=e.shadow.map}s.directional[s.directsNum]=v,s.directsNum++}else if(e.lightType==x.POINT){u=e.intensity,h=e.color;var p=e.distance,f=e.decay;(v=w(e)).color[0]=h.r*u,v.color[1]=h.g*u,v.color[2]=h.b*u,v.distance=p,v.decay=f;var _=S.setFromMatrixPosition(e.worldMatrix).applyMatrix4(t.viewMatrix);if(v.position[0]=_.x,v.position[1]=_.y,v.position[2]=_.z,e.castShadow?(v.shadow=!0,v.shadowBias=e.shadow.bias,v.shadowRadius=e.shadow.radius,v.shadowMapSize[0]=e.shadow.mapSize.x,v.shadowMapSize[1]=e.shadow.mapSize.y,v.shadowCameraNear=e.shadow.cameraNear,v.shadowCameraFar=e.shadow.cameraFar):v.shadow=!1,e.castShadow){d=16*(s.pointsNum+1);if(s.pointShadowMatrix.length<d){l=s.pointShadowMatrix;s.pointShadowMatrix=new Float32Array(d),s.pointShadowMatrix.set(l)}s.pointShadowMatrix.set(e.shadow.matrix.elements,16*s.pointsNum),s.pointShadowMap[s.pointsNum]=e.shadow.map}s.point[s.pointsNum]=v,s.pointsNum++}else if(e.lightType==x.SPOT){var v;u=e.intensity,h=e.color,p=e.distance,f=e.decay;(v=w(e)).color[0]=h.r*u,v.color[1]=h.g*u,v.color[2]=h.b*u,v.distance=p,v.decay=f;_=S.setFromMatrixPosition(e.worldMatrix).applyMatrix4(t.viewMatrix);v.position[0]=_.x,v.position[1]=_.y,v.position[2]=_.z;c=S;e.getWorldDirection(S),S.transformDirection(t.viewMatrix),v.direction[0]=c.x,v.direction[1]=c.y,v.direction[2]=c.z;var m=Math.cos(e.angle),g=Math.cos(e.angle*(1-e.penumbra));if(v.coneCos=m,v.penumbraCos=g,e.castShadow?(v.shadow=!0,v.shadowBias=e.shadow.bias,v.shadowRadius=e.shadow.radius,v.shadowMapSize[0]=e.shadow.mapSize.x,v.shadowMapSize[1]=e.shadow.mapSize.y):v.shadow=!1,e.castShadow){d=16*(s.spotsNum+1);if(s.spotShadowMatrix.length<d){l=s.spotShadowMatrix;s.spotShadowMatrix=new Float32Array(d),s.spotShadowMatrix.set(l)}s.spotShadowMatrix.set(e.shadow.matrix.elements,16*s.spotsNum),s.spotShadowMap[s.spotsNum]=e.shadow.map}s.spot[s.spotsNum]=v,s.spotsNum++}e.castShadow&&e.lightType!==x.AMBIENT&&(s.shadows.push(e),s.shadowsNum++),s.totalNum++;break;case T.CAMERA:case T.SCENE:case T.GROUP:break;default:console.log("undefined object type")}if(T.CANVAS2D!==e.type)for(var y=e.children,E=(r=0,y.length);r<E;r++)this.cacheObject(y[r])},e.prototype.sort=function(){var e=this.renderLists;e[M.DEFAULT].sort(t),e[M.TRANSPARENT].sort(i),e[M.SPRITE].sort(i),e[M.PARTICLE].sort(i)},e.prototype.clear=function(){var e=this.renderLists;for(var t in e)e[t].length=0;this.shadowObjects.length=0;for(var n=this.lights,i=0;i<3;i++)n.ambient[i]=0;n.shadows.length=0,n.ambientsNum=0,n.directsNum=0,n.pointsNum=0,n.spotsNum=0,n.shadowsNum=0,n.totalNum=0},zen3d.RenderCache=e}(),function(){var n=function(e,t){n.superClass.constructor.call(this),this.uuid=zen3d.generateUUID(),this.width=e,this.height=t,this.depthBuffer=!0,this.stencilBuffer=!0};zen3d.inherit(n,zen3d.EventDispatcher),n.prototype.resize=function(e,t){this.width===e&&this.height===t||this.dispose(),this.width=e,this.height=t},n.prototype.dispose=function(){this.dispatchEvent({type:"dispose"})},zen3d.RenderTargetBase=n}(),function(){var t=function(e){t.superClass.constructor.call(this,e.width,e.height),this.view=e};zen3d.inherit(t,zen3d.RenderTargetBase),t.prototype.resize=function(e,t){this.view.width=e,this.view.height=t,this.width=e,this.height=t},t.prototype.dispose=function(){},zen3d.RenderTargetBack=t}(),function(){var n=function(e,t){n.superClass.constructor.call(this,e,t),this.texture=new zen3d.Texture2D};zen3d.inherit(n,zen3d.RenderTargetBase),zen3d.RenderTarget2D=n}(),function(){var n=function(e,t){n.superClass.constructor.call(this,e,t),this.texture=new zen3d.TextureCube,this.activeCubeFace=0};zen3d.inherit(n,zen3d.RenderTargetBase),zen3d.RenderTargetCube=n}(),function(){var e=function(e,t,n){this.uuid=zen3d.generateUUID(),this.array=e,this.size=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0};e.prototype.setArray=function(e){this.count=void 0!==e?e.length/this.size:0,this.array=e},zen3d.BufferAttribute=e}(),function(){var e=function(e,t){this.uuid=zen3d.generateUUID(),this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0};e.prototype.setArray=function(e){this.count=void 0!==e?e.length/this.stride:0,this.array=e},zen3d.InterleavedBuffer=e}(),function(){var e=function(e,t,n,i){this.uuid=zen3d.generateUUID(),this.data=e,this.size=t,this.offset=n,this.normalized=!0===i};e.prototype.isInterleavedBufferAttribute=!0,Object.defineProperties(e.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),zen3d.InterleavedBufferAttribute=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.uuid=zen3d.generateUUID(),this.attributes={},this.index=null,this.usageType=zen3d.WEBGL_BUFFER_USAGE.STATIC_DRAW,this.boundingBox=new zen3d.Box3,this.boundingSphere=new zen3d.Sphere,this.dirtyRange={enable:!1,start:0,count:0},this.groups=[]};zen3d.inherit(e,zen3d.EventDispatcher),e.prototype.addAttribute=function(e,t){this.attributes[e]=t},e.prototype.getAttribute=function(e){return this.attributes[e]},e.prototype.removeAttribute=function(e){delete this.attributes[e]},e.prototype.setIndex=function(e){Array.isArray(e)?this.index=new zen3d.BufferAttribute(new Uint16Array(e),1):this.index=e},e.prototype.addGroup=function(e,t,n){this.groups.push({start:e,count:t,materialIndex:void 0!==n?n:0})},e.prototype.clearGroups=function(){this.groups=[]},e.prototype.computeBoundingBox=function(){var e=this.attributes.a_Position;if(e.isInterleavedBufferAttribute){var t=e.data;this.boundingBox.setFromArray(t.array,t.stride)}else this.boundingBox.setFromArray(e.array,e.size)},e.prototype.computeBoundingSphere=function(){var e=this.attributes.a_Position;if(e.isInterleavedBufferAttribute){var t=e.data;this.boundingSphere.setFromArray(t.array,t.stride)}else this.boundingSphere.setFromArray(e.array,e.size)},e.prototype.dispose=function(){this.dispatchEvent({type:"dispose"})},zen3d.Geometry=e}(),function(){var o=function(e,t,n,i,r,a){o.superClass.constructor.call(this),this.buildGeometry(e,t,n,i,r,a)};zen3d.inherit(o,zen3d.Geometry),o.prototype.buildGeometry=function(e,t,n,i,r,a){var L=this;e=e||1,t=t||1,n=n||1,i=Math.floor(i)||1,r=Math.floor(r)||1,a=Math.floor(a)||1;var P=[],R=[],C=[],N=[],I=0,D=0;function o(e,t,n,i,r,a,o,s,u,h,c){var d,l,p=a/u,f=o/h,_=a/2,v=o/2,m=s/2,g=u+1,y=h+1,E=0,T=0,x=new zen3d.Vector3;for(l=0;l<y;l++){var M=l*f-v;for(d=0;d<g;d++){var w=d*p-_;x[e]=w*i,x[t]=M*r,x[n]=m,R.push(x.x,x.y,x.z),x[e]=0,x[t]=0,x[n]=0<s?1:-1,C.push(x.x,x.y,x.z),N.push(d/u),N.push(1-l/h),E+=1}}for(l=0;l<h;l++)for(d=0;d<u;d++){var S=I+d+g*l,z=I+d+g*(l+1),A=I+(d+1)+g*(l+1),b=I+(d+1)+g*l;P.push(S,z,b),P.push(z,A,b),T+=6}L.addGroup(D,T,c),D+=T,I+=E}o("z","y","x",-1,-1,n,t,e,a,r,0),o("z","y","x",1,-1,n,t,-e,a,r,1),o("x","z","y",1,1,e,n,t,i,a,2),o("x","z","y",1,-1,e,n,-t,i,a,3),o("x","y","z",1,-1,e,t,n,i,r,4),o("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(P),this.addAttribute("a_Position",new zen3d.BufferAttribute(new Float32Array(R),3)),this.addAttribute("a_Normal",new zen3d.BufferAttribute(new Float32Array(C),3)),this.addAttribute("a_Uv",new zen3d.BufferAttribute(new Float32Array(N),2)),this.computeBoundingBox(),this.computeBoundingSphere()},zen3d.CubeGeometry=o}(),function(){var r=function(e,t,n,i){r.superClass.constructor.call(this),this.buildGeometry(e,t,n,i)};zen3d.inherit(r,zen3d.Geometry),r.prototype.buildGeometry=function(e,t,n,i){var r,a,o=(e=e||1)/2,s=(t=t||1)/2,u=Math.floor(n)||1,h=Math.floor(i)||1,c=u+1,d=h+1,l=e/u,p=t/h,f=[],_=[],v=[],m=[];for(a=0;a<d;a++){var g=a*p-s;for(r=0;r<c;r++){var y=r*l-o;_.push(y,0,g),v.push(0,1,0),m.push(r/u),m.push(1-a/h)}}for(a=0;a<h;a++)for(r=0;r<u;r++){var E=r+c*a,T=r+c*(a+1),x=r+1+c*(a+1),M=r+1+c*a;f.push(E,T,M),f.push(T,x,M)}this.setIndex(f),this.addAttribute("a_Position",new zen3d.BufferAttribute(new Float32Array(_),3)),this.addAttribute("a_Normal",new zen3d.BufferAttribute(new Float32Array(v),3)),this.addAttribute("a_Uv",new zen3d.BufferAttribute(new Float32Array(m),2)),this.computeBoundingBox(),this.computeBoundingSphere()},zen3d.PlaneGeometry=r}(),function(){var s=function(e,t,n,i,r,a,o){s.superClass.constructor.call(this),this.buildGeometry(e,t,n,i,r,a,o)};zen3d.inherit(s,zen3d.Geometry),s.prototype.buildGeometry=function(e,t,n,i,r,a,o){e=e||1,t=Math.max(3,Math.floor(t)||8),n=Math.max(2,Math.floor(n)||6),i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var s,u,h=(a=void 0!==a?a:0)+(o=void 0!==o?o:Math.PI),c=0,d=[],l=new zen3d.Vector3,p=new zen3d.Vector3,f=[],_=[],v=[],m=[];for(u=0;u<=n;u++){var g=[],y=u/n;for(s=0;s<=t;s++){var E=s/t;l.x=-e*Math.cos(i+E*r)*Math.sin(a+y*o),l.y=e*Math.cos(a+y*o),l.z=e*Math.sin(i+E*r)*Math.sin(a+y*o),_.push(l.x,l.y,l.z),p.set(l.x,l.y,l.z).normalize(),v.push(p.x,p.y,p.z),m.push(E,1-y),g.push(c++)}d.push(g)}for(u=0;u<n;u++)for(s=0;s<t;s++){var T=d[u][s+1],x=d[u][s],M=d[u+1][s],w=d[u+1][s+1];(0!==u||0<a)&&f.push(T,x,w),(u!==n-1||h<Math.PI)&&f.push(x,M,w)}this.setIndex(f),this.addAttribute("a_Position",new zen3d.BufferAttribute(new Float32Array(_),3)),this.addAttribute("a_Normal",new zen3d.BufferAttribute(new Float32Array(v),3)),this.addAttribute("a_Uv",new zen3d.BufferAttribute(new Float32Array(m),2)),this.computeBoundingBox(),this.computeBoundingSphere()},zen3d.SphereGeometry=s}(),function(){var u=function(e,t,n,i,r,a,o,s){u.superClass.constructor.call(this),this.buildGeometry(e,t,n,i,r,a,o,s)};zen3d.inherit(u,zen3d.Geometry),u.prototype.buildGeometry=function(m,g,y,E,T,e,x,M){var w=this;m=void 0!==m?m:1,g=void 0!==g?g:1,y=y||1,E=Math.floor(E)||8,T=Math.floor(T)||1,e=void 0!==e&&e,x=void 0!==x?x:0,M=void 0!==M?M:2*Math.PI;var S=[],z=[],A=[],b=[],L=0,P=[],R=y/2,C=0;function t(e){var t,n,i,r=new zen3d.Vector2,a=new zen3d.Vector3,o=0,s=!0===e?m:g,u=!0===e?1:-1;for(n=L,t=1;t<=E;t++)z.push(0,R*u,0),A.push(0,u,0),b.push(.5,.5),L++;for(i=L,t=0;t<=E;t++){var h=t/E*M+x,c=Math.cos(h),d=Math.sin(h);a.x=s*d,a.y=R*u,a.z=s*c,z.push(a.x,a.y,a.z),A.push(0,u,0),r.x=.5*c+.5,r.y=.5*d*u+.5,b.push(r.x,r.y),L++}for(t=0;t<E;t++){var l=n+t,p=i+t;!0===e?S.push(p,p+1,l):S.push(p+1,p,l),o+=3}w.addGroup(C,o,!0===e?1:2),C+=o}!function(){var e,t,n=new zen3d.Vector3,i=new zen3d.Vector3,r=0,a=(g-m)/y;for(t=0;t<=T;t++){var o=[],s=t/T,u=s*(g-m)+m;for(e=0;e<=E;e++){var h=e/E,c=h*M+x,d=Math.sin(c),l=Math.cos(c);i.x=u*d,i.y=-s*y+R,i.z=u*l,z.push(i.x,i.y,i.z),n.set(d,a,l).normalize(),A.push(n.x,n.y,n.z),b.push(h,1-s),o.push(L++)}P.push(o)}for(e=0;e<E;e++)for(t=0;t<T;t++){var p=P[t][e],f=P[t+1][e],_=P[t+1][e+1],v=P[t][e+1];S.push(p,f,v),S.push(f,_,v),r+=6}w.addGroup(C,r,0),C+=r}(),!1===e&&(0<m&&t(!0),0<g&&t(!1)),this.setIndex(S),this.addAttribute("a_Position",new zen3d.BufferAttribute(new Float32Array(z),3)),this.addAttribute("a_Normal",new zen3d.BufferAttribute(new Float32Array(A),3)),this.addAttribute("a_Uv",new zen3d.BufferAttribute(new Float32Array(b),2)),this.computeBoundingBox(),this.computeBoundingSphere()},zen3d.CylinderGeometry=u}(),function(){var e=function(){e.superClass.constructor.call(this),this.uuid=zen3d.generateUUID(),this.textureType="",this.border=0,this.pixelFormat=zen3d.WEBGL_PIXEL_FORMAT.RGBA,this.pixelType=zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_BYTE,this.magFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR,this.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_LINEAR,this.wrapS=zen3d.WEBGL_TEXTURE_WRAP.CLAMP_TO_EDGE,this.wrapT=zen3d.WEBGL_TEXTURE_WRAP.CLAMP_TO_EDGE,this.anisotropy=1,this.generateMipmaps=!0,this.encoding=zen3d.TEXEL_ENCODING_TYPE.LINEAR,this.version=0};zen3d.inherit(e,zen3d.EventDispatcher),e.prototype.dispose=function(){this.dispatchEvent({type:"dispose"}),this.version=0},zen3d.TextureBase=e}(),function(){var i=function(){i.superClass.constructor.call(this),this.textureType=zen3d.WEBGL_TEXTURE_TYPE.TEXTURE_2D,this.image=null,this.mipmaps=[]};zen3d.inherit(i,zen3d.TextureBase),i.fromImage=function(e){var t=new i;return t.image=e,t.version++,t},i.fromSrc=function(e){var t=new i,n=0<e.search(/\\.(jpg|jpeg)$/)||0===e.search(/^data\\:image\\/jpeg/);return(0<e.search(/\\.(tga)$/)||0===e.search(/^data\\:image\\/tga/)?new zen3d.TGALoader:new zen3d.ImageLoader).load(e,function(e){t.pixelFormat=n?zen3d.WEBGL_PIXEL_FORMAT.RGB:zen3d.WEBGL_PIXEL_FORMAT.RGBA,t.image=e,t.version++}),t},zen3d.Texture2D=i}(),function(){var u=function(){u.superClass.constructor.call(this),this.textureType=zen3d.WEBGL_TEXTURE_TYPE.TEXTURE_CUBE_MAP,this.images=[]};zen3d.inherit(u,zen3d.TextureBase),u.fromImage=function(e){for(var t=new u,n=t.images,i=0;i<6;i++)n[i]=e[i];return t.version++,t},u.fromSrc=function(n){var i=new u,r=i.images,e=n[0],a=0<e.search(/\\.(jpg|jpeg)$/)||0===e.search(/^data\\:image\\/jpeg/),o=0<e.search(/\\.(tga)$/)||0===e.search(/^data\\:image\\/tga/),s=0;return function e(t){if(t&&(r.push(t),s++),6<=s)return i.pixelFormat=a?zen3d.WEBGL_PIXEL_FORMAT.RGB:zen3d.WEBGL_PIXEL_FORMAT.RGBA,void i.version++;(o?new zen3d.TGALoader:new zen3d.ImageLoader).load(n[s],e)}(),i},zen3d.TextureCube=u}(),function(){var i=function(e,t,n){i.superClass.constructor.call(this),this.image={data:e,width:t,height:n},this.pixelType=zen3d.WEBGL_PIXEL_TYPE.FLOAT,this.magFilter=zen3d.WEBGL_TEXTURE_FILTER.NEAREST,this.minFilter=zen3d.WEBGL_TEXTURE_FILTER.NEAREST,this.generateMipmaps=!1};zen3d.inherit(i,zen3d.Texture2D),i.prototype.isDataTexture=!0,zen3d.TextureData=i}(),function(){var e=function(){this.type="",this.opacity=1,this.transparent=!1,this.premultipliedAlpha=!1,this.vertexColors=!1,this.diffuse=new zen3d.Color3(16777215),this.diffuseMap=null,this.normalMap=null,this.aoMap=null,this.aoMapIntensity=1,this.bumpMap=null,this.bumpScale=1,this.envMap=null,this.envMapIntensity=1,this.envMapCombine=zen3d.ENVMAP_COMBINE_TYPE.MULTIPLY,this.emissive=new zen3d.Color3(0),this.emissiveMap=null,this.emissiveIntensity=1,this.blending=zen3d.BLEND_TYPE.NORMAL,this.depthTest=!0,this.depthWrite=!0,this.side=zen3d.DRAW_SIDE.FRONT,this.shading=zen3d.SHADING_TYPE.SMOOTH_SHADING,this.acceptLight=!1,this.drawMode=zen3d.DRAW_MODE.TRIANGLES};e.prototype.clone=function(){return(new this.constructor).copy(this)},e.prototype.copy=function(e){return this.type=e.type,this.opacity=e.opacity,this.transparent=e.transparent,this.premultipliedAlpha=e.premultipliedAlpha,this.vertexColors=e.vertexColors,this.diffuse.copy(e.diffuse),this.diffuseMap=e.diffuseMap,this.normalMap=e.normalMap,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.envMapCombine=e.envMapCombine,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.blending=e.blending,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.side=e.side,this.shading=e.shading,this.acceptLight=e.acceptLight,this.drawMode=e.drawMode,this},zen3d.Material=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.BASIC};zen3d.inherit(e,zen3d.Material),zen3d.BasicMaterial=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.LAMBERT,this.acceptLight=!0};zen3d.inherit(e,zen3d.Material),zen3d.LambertMaterial=e}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.PHONG,this.shininess=30,this.specular=new zen3d.Color3(6710886),this.specularMap=null,this.acceptLight=!0};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.shininess=e.shininess,this.specular.copy(e.specular),this.specularMap=e.specularMap,this},zen3d.PhongMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.PBR,this.roughness=.5,this.metalness=.5,this.roughnessMap=null,this.metalnessMap=null,this.acceptLight=!0};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.roughness=e.roughness,this.metalness=e.metalness,this},zen3d.PBRMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.CUBE,this.side=zen3d.DRAW_SIDE.BACK,this.cubeMap=null};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.cubeMap=e.cubeMap,this},zen3d.CubeMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.POINT,this.size=1,this.sizeAttenuation=!0,this.drawMode=zen3d.DRAW_MODE.POINTS};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},zen3d.PointsMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.LINE,this.lineWidth=1,this.drawMode=zen3d.DRAW_MODE.LINES};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.lineWidth=e.lineWidth,this},zen3d.LineMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.LINE_LOOP,this.lineWidth=1,this.drawMode=zen3d.DRAW_MODE.LINE_LOOP};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.lineWidth=e.lineWidth,this},zen3d.LineLoopMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.LINE_DASHED,this.lineWidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.drawMode=zen3d.DRAW_MODE.LINE_STRIP};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.lineWidth=e.lineWidth,this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this},zen3d.LineDashedMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.SPRITE,this.rotation=0,this.fog=!1};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.rotation=e.rotation,this.fog=e.fog,this},zen3d.SpriteMaterial=t}(),function(){var i=function(e,t,n){i.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.SHADER,this.vertexShader=e||"",this.fragmentShader=t||"",this.uniforms=n||{}};zen3d.inherit(i,zen3d.Material),i.prototype.copy=function(e){return i.superClass.copy.call(this,e),this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this},zen3d.ShaderMaterial=i}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.DEPTH,this.blending=zen3d.BLEND_TYPE.NONE,this.packToRGBA=!1};zen3d.inherit(e,zen3d.Material),zen3d.DepthMaterial=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.DISTANCE,this.blending=zen3d.BLEND_TYPE.NONE};zen3d.inherit(e,zen3d.Material),zen3d.DistanceMaterial=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.PARTICLE,this.transparent=!0,this.blending=zen3d.BLEND_TYPE.ADD,this.depthTest=!0,this.depthWrite=!1,this.drawMode=zen3d.DRAW_MODE.POINTS};zen3d.inherit(e,zen3d.Material),zen3d.ParticleMaterial=e}(),function(){var n,i,r,e=function(){this.uuid=zen3d.generateUUID(),this.name="",this.type="",this.position=new zen3d.Vector3,this.scale=new zen3d.Vector3(1,1,1);var e=this.euler=new zen3d.Euler,t=this.quaternion=new zen3d.Quaternion;e.onChange(function(){t.setFromEuler(e,!1)}),t.onChange(function(){e.setFromQuaternion(t,void 0,!1)}),this.matrix=new zen3d.Matrix4,this.worldMatrix=new zen3d.Matrix4,this.children=new Array,this.parent=null,this.castShadow=!1,this.receiveShadow=!1,this.shadowType=zen3d.SHADOW_TYPE.PCF_SOFT,this.frustumCulled=!0,this.userData={}};Object.defineProperties(e.prototype,{rotation:{get:function(){return this.euler},set:function(e){this.euler.copyFrom(e),this.quaternion.setFromEuler(e)}}}),e.prototype.add=function(e){this.children.push(e),e.parent=this},e.prototype.remove=function(e){var t=this.children.indexOf(e);-1!==t&&this.children.splice(t,1),e.parent=null},e.prototype.getObjectByName=function(e){return this.getObjectByProperty("name",e)},e.prototype.getObjectByProperty=function(e,t){if(this[e]===t)return this;for(var n=0,i=this.children.length;n<i;n++){var r=this.children[n].getObjectByProperty(e,t);if(void 0!==r)return r}},e.prototype.updateMatrix=function(){var e=this.matrix.transform(this.position,this.scale,this.quaternion);if(this.worldMatrix.copy(e),this.parent){var t=this.parent.worldMatrix;this.worldMatrix.premultiply(t)}for(var n=this.children,i=0,r=n.length;i<r;i++)n[i].updateMatrix()},e.prototype.getWorldDirection=(n=new zen3d.Vector3,i=new zen3d.Quaternion,r=new zen3d.Vector3,function(e){var t=e||new zen3d.Vector3;return this.worldMatrix.decompose(n,i,r),t.set(0,0,1).applyQuaternion(i),t}),e.prototype.raycast=function(){},e.prototype.traverse=function(e){e(this);for(var t=this.children,n=0,i=t.length;n<i;n++)t[n].traverse(e)},e.prototype.clone=function(e){return(new this.constructor).copy(this,e)},e.prototype.copy=function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.type=e.type,this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.worldMatrix.copy(e.worldMatrix),this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;n<e.children.length;n++){var i=e.children[n];this.add(i.clone())}return this},zen3d.Object3D=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.OBJECT_TYPE.SCENE,this.overrideMaterial=null,this.fog=null,this.clippingPlanes=[],this.cache=new zen3d.RenderCache};zen3d.inherit(e,zen3d.Object3D),e.prototype.update=function(e){this.updateMatrix(),this.cache.clear(),this.cache.cacheScene(this,e),this.cache.sort()},zen3d.Scene=e}(),zen3d.Fog=function(e,t,n){this.fogType=zen3d.FOG_TYPE.NORMAL,this.color=new zen3d.Color3(void 0!==e?e:0),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3},zen3d.FogExp2=function(e,t){this.fogType=zen3d.FOG_TYPE.EXP2,this.color=new zen3d.Color3(void 0!==e?e:0),this.density=void 0!==t?t:25e-5},function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.OBJECT_TYPE.GROUP};zen3d.inherit(e,zen3d.Object3D),zen3d.Group=e}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.OBJECT_TYPE.LIGHT,this.lightType="",this.color=new zen3d.Color3(16777215),this.intensity=1};zen3d.inherit(t,zen3d.Object3D),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.type=e.type,this.lightType=e.lightType,this.color.copy(e.color),this.intensity=e.intensity,this},zen3d.Light=t}(),function(){var e=function(){e.superClass.constructor.call(this),this.lightType=zen3d.LIGHT_TYPE.AMBIENT};zen3d.inherit(e,zen3d.Light),zen3d.AmbientLight=e}(),function(){var t=function(){t.superClass.constructor.call(this),this.lightType=zen3d.LIGHT_TYPE.DIRECT,this.shadow=new zen3d.DirectionalLightShadow};zen3d.inherit(t,zen3d.Light),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.shadow.copy(e.shadow),this},zen3d.DirectionalLight=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.lightType=zen3d.LIGHT_TYPE.POINT,this.decay=2,this.distance=200,this.shadow=new zen3d.PointLightShadow};zen3d.inherit(t,zen3d.Light),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.shadow.copy(e.shadow),this},zen3d.PointLight=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.lightType=zen3d.LIGHT_TYPE.SPOT,this.decay=2,this.distance=200,this.penumbra=0,this.angle=Math.PI/6,this.shadow=new zen3d.SpotLightShadow};zen3d.inherit(t,zen3d.Light),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.shadow.copy(e.shadow),this},zen3d.SpotLight=t}(),function(){var e=function(){this.camera=new zen3d.Camera,this.matrix=new zen3d.Matrix4,this.bias=3e-4,this.radius=2,this.cameraNear=1,this.cameraFar=500,this.mapSize=new zen3d.Vector2(512,512),this.renderTarget=null,this.map=null};e.prototype.update=function(e,t){},e.prototype.copy=function(e){return this.camera.copy(e.camera),this.matrix.copy(e.matrix),this.bias=e.bias,this.radius=e.radius,this.cameraNear=e.cameraNear,this.cameraFar=e.cameraFar,this.mapSize.copy(e.mapSize),this},e.prototype.clone=function(){return(new this.constructor).copy(this)},zen3d.LightShadow=e}(),function(){var t=function(){t.superClass.constructor.call(this),this.renderTarget=new zen3d.RenderTarget2D(this.mapSize.x,this.mapSize.y);var e=this.renderTarget.texture;e.generateMipmaps=!1,e.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR,this.map=e,this.windowSize=500,this._lookTarget=new zen3d.Vector3,this._up=new zen3d.Vector3(0,1,0)};zen3d.inherit(t,zen3d.LightShadow),t.prototype.update=function(e){this._updateCamera(e),this._updateMatrix(),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},t.prototype._updateCamera=function(e){var t=this.camera,n=this._lookTarget;e.getWorldDirection(this._lookTarget),t.position.setFromMatrixPosition(e.worldMatrix),n.set(n.x+t.position.x,n.y+t.position.y,n.z+t.position.z),t.setLookAt(n,this._up),t.updateMatrix(),t.viewMatrix.getInverse(t.worldMatrix);var i=this.windowSize/2;t.setOrtho(-i,i,-i,i,this.cameraNear,this.cameraFar)},t.prototype._updateMatrix=function(){var e=this.matrix,t=this.camera;e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.viewMatrix)},t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.windowSize=e.windowSize,this},zen3d.DirectionalLightShadow=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.renderTarget=new zen3d.RenderTarget2D(this.mapSize.x,this.mapSize.y);var e=this.renderTarget.texture;e.generateMipmaps=!1,e.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR,this.map=e,this._lookTarget=new zen3d.Vector3,this._up=new zen3d.Vector3(0,1,0)};zen3d.inherit(t,zen3d.LightShadow),t.prototype.update=function(e){this._updateCamera(e),this._updateMatrix(),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},t.prototype._updateCamera=function(e){var t=this.camera,n=this._lookTarget;e.getWorldDirection(this._lookTarget),t.position.setFromMatrixPosition(e.worldMatrix),n.set(n.x+t.position.x,n.y+t.position.y,n.z+t.position.z),t.setLookAt(n,this._up),t.updateMatrix(),t.viewMatrix.getInverse(t.worldMatrix),t.setPerspective(2*e.angle,1,this.cameraNear,this.cameraFar)},t.prototype._updateMatrix=function(){var e=this.matrix,t=this.camera;e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.viewMatrix)},zen3d.SpotLightShadow=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.renderTarget=new zen3d.RenderTargetCube(this.mapSize.x,this.mapSize.y);var e=this.renderTarget.texture;e.generateMipmaps=!1,e.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR,this.map=e,this._targets=[new zen3d.Vector3(1,0,0),new zen3d.Vector3(-1,0,0),new zen3d.Vector3(0,1,0),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,0,1),new zen3d.Vector3(0,0,-1)],this._ups=[new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,0,1),new zen3d.Vector3(0,0,-1),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,-1,0)],this._lookTarget=new zen3d.Vector3};zen3d.inherit(t,zen3d.LightShadow),t.prototype.update=function(e,t){this._updateCamera(e,t),this._updateMatrix(),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},t.prototype._updateCamera=function(e,t){var n=this.camera,i=this._lookTarget,r=this._targets,a=this._ups;n.position.setFromMatrixPosition(e.worldMatrix),i.set(r[t].x+n.position.x,r[t].y+n.position.y,r[t].z+n.position.z),n.setLookAt(i,a[t]),n.updateMatrix(),n.viewMatrix.getInverse(n.worldMatrix),n.setPerspective(.5*Math.PI,1,this.cameraNear,this.cameraFar)},t.prototype._updateMatrix=function(){var e=this.matrix,t=this.camera;e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.viewMatrix)},zen3d.PointLightShadow=t}(),function(){var n,i,r,a=function(){a.superClass.constructor.call(this),this.type=zen3d.OBJECT_TYPE.CAMERA,this.viewMatrix=new zen3d.Matrix4,this.projectionMatrix=new zen3d.Matrix4,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.rect=new zen3d.Vector4(0,0,1,1)};zen3d.inherit(a,zen3d.Object3D),a.prototype.setLookAt=function(e,t){var n=this.position,i=new zen3d.Vector3;n.subtract(e,i),i.normalize();var r=new zen3d.Vector3;r.crossVectors(t,i),r.normalize();var a=new zen3d.Vector3;a.crossVectors(i,r),this.quaternion.setFromRotationMatrix(zen3d.helpMatrix.set(r.x,a.x,i.x,0,r.y,a.y,i.y,0,r.z,a.z,i.z,0,0,0,0,1))},a.prototype.setOrtho=function(e,t,n,i,r,a){this.projectionMatrix.set(2/(t-e),0,0,-(t+e)/(t-e),0,2/(i-n),0,-(i+n)/(i-n),0,0,-2/(a-r),-(a+r)/(a-r),0,0,0,1)},a.prototype.setPerspective=function(e,t,n,i){this.projectionMatrix.set(1/(t*Math.tan(e/2)),0,0,0,0,1/Math.tan(e/2),0,0,0,0,-(i+n)/(i-n),-2*i*n/(i-n),0,0,-1,0)},a.prototype.getWorldDirection=(n=new zen3d.Vector3,i=new zen3d.Quaternion,r=new zen3d.Vector3,function(e){var t=e||new zen3d.Vector3;return this.worldMatrix.decompose(n,i,r),t.set(0,0,-1).applyQuaternion(i),t}),a.prototype.updateMatrix=function(){a.superClass.updateMatrix.call(this),this.viewMatrix.getInverse(this.worldMatrix)},a.prototype.copy=function(e,t){return a.superClass.copy.call(this,e,t),this.viewMatrix.copy(e.viewMatrix),this.projectionMatrix.copy(e.projectionMatrix),this},zen3d.Camera=a}(),function(){var n=function(e,t){n.superClass.constructor.call(this),this.geometry=e,this.material=t,this.type=zen3d.OBJECT_TYPE.MESH};zen3d.inherit(n,zen3d.Object3D),n.prototype.raycast=function(){var y=new zen3d.Sphere,E=new zen3d.Box3,T=new zen3d.Matrix4,x=new zen3d.Ray,M=new zen3d.Vector3,w=new zen3d.Vector3,S=new zen3d.Vector3,z=new zen3d.Vector3,A=new zen3d.Vector2,b=new zen3d.Vector2,L=new zen3d.Vector2,P=new zen3d.Vector3,u=new zen3d.Vector3;function R(e,t,n,i,r,a,o){e.material;if(null===n.intersectTriangle(a,r,i,!0,o))return null;u.copy(o),u.applyMatrix4(e.worldMatrix);var s=t.ray.origin.distanceTo(u);return s<t.near||s>t.far?null:{distance:s,point:u.clone(),object:e}}return function(e,t){var n=this.geometry,i=this.worldMatrix;if(y.copy(n.boundingSphere),y.applyMatrix4(i),e.ray.intersectsSphere(y)&&(E.copy(n.boundingBox),E.applyMatrix4(i),e.ray.intersectsBox(E))){T.getInverse(i),x.copy(e.ray).applyMatrix4(T);for(var r,a,o,s,u,h,c,d,l,p,f=n.index.array,_=n.getAttribute("a_Position"),v=n.getAttribute("a_Uv"),m=0;m<f.length;m+=3){r=f[m],a=f[m+1],o=f[m+2],w.fromArray(_.array,3*r),S.fromArray(_.array,3*a),z.fromArray(_.array,3*o);var g=R(this,e,x,w,S,z,P);g&&(A.fromArray(v.array,2*r),b.fromArray(v.array,2*a),L.fromArray(v.array,2*o),g.uv=(s=P,u=w,h=S,c=z,d=A,l=b,p=L,zen3d.Triangle.barycoordFromPoint(s,u,h,c,M),d.multiplyScalar(M.x),l.multiplyScalar(M.y),p.multiplyScalar(M.z),d.add(l).add(p),d.clone()),g.face=[r,a,o],g.faceIndex=r,t.push(g))}}}}(),n.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},zen3d.Mesh=n}(),function(){var n=function(e,t){n.superClass.constructor.call(this,e,t),this.type=zen3d.OBJECT_TYPE.SKINNED_MESH,this.skeleton=void 0};zen3d.inherit(n,zen3d.Mesh),n.prototype.updateMatrix=function(){n.superClass.updateMatrix.call(this),this.skeleton&&this.skeleton.updateBones()},n.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},zen3d.SkinnedMesh=n}(),function(){var n=function(e,t){n.superClass.constructor.call(this),this.geometry=e,this.material=t,this.type=zen3d.OBJECT_TYPE.POINT};zen3d.inherit(n,zen3d.Object3D),zen3d.Points=n}(),function(){var n=function(e,t){n.superClass.constructor.call(this),this.geometry=e,this.material=t,this.type=zen3d.OBJECT_TYPE.LINE};zen3d.inherit(n,zen3d.Object3D),n.prototype.raycast=function(){},zen3d.Line=n}(),function(){var t=new zen3d.Geometry,e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),n=new zen3d.InterleavedBuffer(e,4);t.addAttribute("position",new zen3d.InterleavedBufferAttribute(n,2,0)),t.addAttribute("uv",new zen3d.InterleavedBufferAttribute(n,2,2)),t.setIndex([0,1,2,0,2,3]);var i=function(e){i.superClass.constructor.call(this),this.geometry=t,this.material=void 0!==e?e:new zen3d.SpriteMaterial,this.type=zen3d.OBJECT_TYPE.SPRITE};zen3d.inherit(i,zen3d.Object3D),i.geometry=t,zen3d.Sprite=i}(),function(){var r=new Uint8Array(4),a=new Float32Array(r.buffer);function l(e,t,n,i){return r[0]=Math.floor(i),r[1]=Math.floor(n),r[2]=Math.floor(t),r[3]=Math.floor(e),a[0]}var o=function(e){o.superClass.constructor.call(this);e=e||{};this.maxParticleCount=e.maxParticleCount||1e4,this.particleNoiseTex=e.particleNoiseTex||null,this.particleSpriteTex=e.particleSpriteTex||null,this.geometry=new zen3d.Geometry;for(var t=[],n=0;n<this.maxParticleCount;n++)t[8*n+0]=100,t[8*n+1]=0,t[8*n+2]=0,t[8*n+3]=0,t[8*n+4]=l(128,128,0,0),t[8*n+5]=l(0,254,0,254),t[8*n+6]=1,t[8*n+7]=0;var i,r=new zen3d.InterleavedBuffer(new Float32Array(t),8);r.dynamic=!0,i=new zen3d.InterleavedBufferAttribute(r,3,0),this.geometry.addAttribute("a_Position",i),i=new zen3d.InterleavedBufferAttribute(r,4,0),this.geometry.addAttribute("particlePositionsStartTime",i),i=new zen3d.InterleavedBufferAttribute(r,4,4),this.geometry.addAttribute("particleVelColSizeLife",i),this.particleCursor=0,this.time=0,this.type=zen3d.OBJECT_TYPE.PARTICLE,this.material=new zen3d.ParticleMaterial};zen3d.inherit(o,zen3d.Object3D);var p=new zen3d.Vector3,f=new zen3d.Vector3,_=0,v=0,m=new zen3d.Color3,g=0,y=0,E=0,T=0;o.prototype.spawn=function(e){p=void 0!==(e=e||{}).position?p.copy(e.position):p.set(0,0,0),f=void 0!==e.velocity?f.copy(e.velocity):f.set(0,0,0),_=void 0!==e.positionRandomness?e.positionRandomness:0,v=void 0!==e.velocityRandomness?e.velocityRandomness:0,m=void 0!==e.color?m.copy(e.color):m.setRGB(1,1,1),g=void 0!==e.colorRandomness?e.colorRandomness:1,u=void 0!==e.turbulence?e.turbulence:1,y=void 0!==e.lifetime?e.lifetime:5,E=void 0!==e.size?e.size:10,T=void 0!==e.sizeRandomness?e.sizeRandomness:0;var t=this.particleCursor,n=this.geometry.getAttribute("particlePositionsStartTime").data,i=n.array,r=n.stride;i[t*r+0]=p.x+(Math.random()-.5)*_,i[t*r+1]=p.y+(Math.random()-.5)*_,i[t*r+2]=p.z+(Math.random()-.5)*_,i[t*r+3]=this.time+.02*(Math.random()-.5);var a=f.x+(Math.random()-.5)*v,o=f.y+(Math.random()-.5)*v,s=f.z+(Math.random()-.5)*v,u=Math.floor(254*u);a=Math.floor((a- -2)/4*250),o=Math.floor((o- -2)/4*250),s=Math.floor((s- -2)/4*250),i[t*r+4]=l(a,o,s,u);var h=254*m.r+(Math.random()-.5)*g*254,c=254*m.g+(Math.random()-.5)*g*254,d=254*m.b+(Math.random()-.5)*g*254;254<h&&(h=254),h<0&&(h=0),254<c&&(c=254),c<0&&(c=0),254<d&&(d=254),d<0&&(d=0),i[t*r+5]=l(h,c,d,254),i[t*r+6]=E+(Math.random()-.5)*T,i[t*r+7]=y,this.particleCursor++,this.particleCursor>=this.maxParticleCount?(this.particleCursor=0,n.version++,n.updateRange.offset=0,n.updateRange.count=-1):(n.version++,-1<n.updateRange.count?n.updateRange.count=this.particleCursor*r-n.updateRange.offset:(n.updateRange.offset=t*r,n.updateRange.count=r))},o.prototype.update=function(e){this.time=e},zen3d.ParticleContainer=o}(),function(){var e=function(){e.superClass.constructor.call(this),this.type="bone",this.offsetMatrix=new zen3d.Matrix4};zen3d.inherit(e,zen3d.Object3D),zen3d.Bone=e}(),function(){var t=function(e){t.superClass.constructor.call(this),this.type="skeleton",this.bones=e||[],this.boneMatrices=new Float32Array(16*this.bones.length),this.boneTexture=void 0,this.boneTextureSize=0};zen3d.inherit(t,zen3d.Object3D);var n=new zen3d.Matrix4;t.prototype.updateBones=function(){this.updateMatrix();for(var e=0;e<this.bones.length;e++){var t=this.bones[e];n.multiplyMatrices(t.worldMatrix,t.offsetMatrix),n.toArray(this.boneMatrices,16*e)}void 0!==this.boneTexture&&this.boneTexture.version++},zen3d.Skeleton=t}(),function(){var e=function(){this._keys=[],this._values=[]};e.prototype.addFrame=function(e,t){this._keys.push(e),this._values.push(t)},e.prototype.removeFrame=function(e){var t=this.keys.indexOf(e);-1<t&&(this._keys.splice(t,1),this._values.splice(t,1))},e.prototype.clearFrame=function(){this._keys.length=0,this._values.length=0},e.prototype.sortFrame=function(){},e.prototype.getRange=function(e,t){var n=this._getLastKeyIndex(e),i=this._keys[n],r=this._keys[n+1],a=this._values[n],o=this._values[n+1];return(t=t||{key1:0,value1:0,key2:0,value2:0}).key1=i,t.key2=r,t.value1=a,t.value2=o,t},e.prototype._getLastKeyIndex=function(e){var t,n=0,i=this._keys.length;for(t=0;t<i;t++)e>=this._keys[t]&&(n=t);return n},zen3d.KeyframeData=e}(),function(){var o={key1:0,value1:0,key2:0,value2:0},e=function(e,t){this.target=void 0,this.path=void 0,this.bind(e,t),this.data=new zen3d.KeyframeData,this._frame=0,this.interpolant=!0};e.prototype.bind=function(e,t){if(1<(t=t.split(".")).length){for(var n=e[t[0]],i=1;i<t.length-1;i++)n=n[t[i]];this.path=t[t.length-1],this.target=n}else this.path=t[0],this.target=e},Object.defineProperties(e.prototype,{frame:{get:function(){return this._frame},set:function(e){this._frame=e,this._updateValue(e)}}}),e.prototype._updateValue=function(e){this.data.getRange(e,o);var t=o.key1,n=o.key2,i=o.value1,r=o.value2;if(this.interpolant)if(void 0!==i&&void 0!==r){var a=(e-t)/(n-t);this.target[this.path]=(r-i)*a+i}else this.target[this.path]=i;else this.target[this.path]=i},zen3d.KeyframeTrack=e}(),function(){var o={key1:0,value1:0,key2:0,value2:0},n=function(e,t){n.superClass.constructor.call(this,e,t)};zen3d.inherit(n,zen3d.KeyframeTrack),n.prototype._updateValue=function(e){this.data.getRange(e,o);var t=o.key1,n=o.key2,i=o.value1,r=o.value2;if(this.interpolant)if(void 0!==i&&void 0!==r){var a=(e-t)/(n-t);this.target[this.path].slerpQuaternions(i,r,a)}else this.target[this.path].copy(i);else this.target[this.path].copy(i)},zen3d.QuaternionKeyframeTrack=n}(),function(){var o={key1:0,value1:0,key2:0,value2:0},n=function(e,t){n.superClass.constructor.call(this,e,t)};zen3d.inherit(n,zen3d.KeyframeTrack),n.prototype._updateValue=function(e){this.data.getRange(e,o);var t=o.key1,n=o.key2,i=o.value1,r=o.value2;if(this.interpolant)if(void 0!==i&&void 0!==r){var a=(e-t)/(n-t);this.target[this.path].lerpVectors(i,r,a)}else this.target[this.path].copy(i);else this.target[this.path].copy(i)},zen3d.VectorKeyframeTrack=n}(),function(){var o={key1:0,value1:0,key2:0,value2:0},n=function(e,t){n.superClass.constructor.call(this,e,t)};zen3d.inherit(n,zen3d.KeyframeTrack),n.prototype._updateValue=function(e){this.data.getRange(e,o);var t=o.key1,n=o.key2,i=o.value1,r=o.value2;if(this.interpolant)if(void 0!==i&&void 0!==r){var a=(e-t)/(n-t);this.target[this.path].lerpColors(i,r,a)}else this.target[this.path].copy(i);else this.target[this.path].copy(i)},zen3d.ColorKeyframeTrack=n}(),function(){var e=function(e){this.name=e||"",this.tracks=[],this.loop=!0,this.startFrame=0,this.endFrame=0,this.frame=0};e.prototype.update=function(e){this.frame+=e,this.frame>this.endFrame&&(this.loop?this.frame=this.startFrame:this.frame=this.endFrame),this.setFrame(this.frame)},e.prototype.setFrame=function(e){for(var t=0,n=this.tracks.length;t<n;t++)this.tracks[t].frame=e;this.frame=e},zen3d.KeyframeClip=e}(),function(){var e=function(){this._clips={},this._currentClipName=""};Object.defineProperties(e.prototype,{currentClipName:{get:function(){return this._currentClipName}},currentClip:{get:function(){return this._clips[this._currentClipName]}}}),e.prototype.add=function(e){this._clips[e.name]=e},e.prototype.remove=function(e){delete this._clips[e.name]},e.prototype.update=function(e){var t=this._clips[this._currentClipName];t&&t.update(e)},e.prototype.active=function(e){var t=this._clips[e];t?(this._currentClipName=e,t.setFrame(t.startFrame)):console.warn("KeyframeAnimation: try to active a undefind clip!")},e.prototype.getAllClipNames=function(){var e=[];for(var t in this._clips)e.push(t);return e},zen3d.KeyframeAnimation=e}(),function(){var e=function(){this.texturePath="./"};e.prototype.load=function(e,n,t,i){this.texturePath=this.extractUrlBase(e),(new zen3d.FileLoader).setResponseType("json").load(e,function(e){var t=this.parse(e);n(t.object,t.animation)}.bind(this),t,i)},e.prototype.parseNodeTree=function(e){var t=new zen3d.Object3D;if(t.name=e.name,t.matrix.fromArray(e.transformation).transpose(),e.children)for(var n=0;n<e.children.length;n++){var i=this.parseNodeTree(e.children[n]);t.add(i)}return t},e.prototype.cloneNodeToBones=function(e,t){var n=new zen3d.Bone;if(n.name=e.name,n.matrix.copy(e.matrix),n.matrix.decompose(n.position,n.quaternion,n.scale),t[e.name]||(t[e.name]=[]),t[e.name].push(n),e.children)for(var i=0;i<e.children.length;i++){var r=this.cloneNodeToBones(e.children[i],t);n.add(r)}return n},e.prototype.parseSkeleton=function(e,t,i,n){for(var r=[],a=i.getObjectByName(e);a.parent;)r.push(a.parent.name),a=a.parent;r.push(a);var o,s=[],u=[],h=i.getObjectByName(function(e){for(var t,n=i.getObjectByName(e);n.parent&&(t=n.parent,!(-1<r.indexOf(t.name)));)n=t;return n.name}(t[0].name)),c=this.cloneNodeToBones(h,n);u.push(c);for(var d=0;d<t.length;d++){var l=t[d],p=c.getObjectByName(l.name);p||(h=i.getObjectByName(l.name),c=this.cloneNodeToBones(h,n),u.push(c),p=c.getObjectByName(l.name));var f=t[d].offsetmatrix;p.offsetMatrix.fromArray(f).transpose(),s.push(p)}o=new zen3d.Skeleton(s);for(d=0;d<u.length;d++)o.add(u[d]);return o},e.prototype.parseAnimations=function(e,t){for(var n=new zen3d.KeyframeAnimation,i=0;i<e.length;i++){for(var r=e[i],a=r.name,o=r.channels,s=0,u=new zen3d.KeyframeClip(a),h=0;h<o.length;h++){var c=o[h],d=c.name;if(t[d])for(var l=0;l<t[d].length;l++){var p=t[d][l],f=new zen3d.VectorKeyframeTrack(p,"position");for(l=0;l<c.positionkeys.length;l++){var _=c.positionkeys[l];f.data.addFrame(_[0],new zen3d.Vector3(_[1][0],_[1][1],_[1][2])),_[0]>s&&(s=_[0])}u.tracks.push(f);var v=new zen3d.QuaternionKeyframeTrack(p,"quaternion");for(l=0;l<c.rotationkeys.length;l++){_=c.rotationkeys[l];v.data.addFrame(_[0],new zen3d.Quaternion(_[1][1],_[1][2],_[1][3],_[1][0])),_[0]>s&&(s=_[0])}u.tracks.push(v);var m=new zen3d.VectorKeyframeTrack(p,"scale");for(l=0;l<c.scalingkeys.length;l++){_=c.scalingkeys[l];m.data.addFrame(_[0],new zen3d.Vector3(_[1][0],_[1][1],_[1][2])),_[0]>s&&(s=_[0])}u.tracks.push(m)}else console.log(d)}u.startFrame=0,u.endFrame=s,u.loop=!0,n.add(u)}return n},e.prototype.parse=function(e){for(var t,n=this.parseNodeTree(e.rootnode),i=this.parseList(e.meshes,this.parseMesh),r=this.parseList(e.materials,this.parseMaterial),a={},o={},s=0;s<e.meshes.length;s++)e.meshes[s].bones&&(o[s]=this.parseSkeleton(e.meshes[s].name,e.meshes[s].bones,n,a));return e.animations&&(t=this.parseAnimations(e.animations,a)),{object:this.parseObject(e,e.rootnode,i,r,o),animation:t}},e.prototype.parseList=function(e,t){for(var n=new Array(e.length),i=0;i<e.length;++i)n[i]=t.call(this,e[i]);return n},e.prototype.parseMaterial=function(e){var t=new zen3d.PhongMaterial,n=null,i=null,r=e.properties;for(var a in e.properties){if("$tex.file"===(r=e.properties[a]).key){if(1==r.semantic)o=(o=this.texturePath+r.value).replace(/.\\\\/g,""),(n=new zen3d.Texture2D.fromSrc(o)).wrapS=n.wrapT=zen3d.WEBGL_TEXTURE_WRAP.REPEAT;else if(2==r.semantic);else if(5==r.semantic);else if(6==r.semantic){var o;o=(o=this.texturePath+r.value).replace(/.\\\\/g,""),(i=new zen3d.Texture2D.fromSrc(o)).wrapS=i.wrapT=zen3d.WEBGL_TEXTURE_WRAP.REPEAT}}else if("?mat.name"===r.key);else if("$clr.ambient"===r.key);else if("$clr.diffuse"===r.key){var s=r.value;t.diffuse.setRGB(s[0],s[1],s[2])}else if("$clr.specular"===r.key){s=r.value;t.specular.setRGB(s[0],s[1],s[2])}else if("$clr.emissive"===r.key){s=r.value;t.emissive.setRGB(s[0],s[1],s[2])}else"$mat.opacity"===r.key?(t.transparent=r.value<1,t.opacity=r.value):"$mat.shadingm"===r.key?r.value:"$mat.shininess"===r.key&&(t.shininess=r.value)}return t.diffuseMap=n,t.normalMap=i,t},e.prototype.parseMesh=function(e){var t=new zen3d.Geometry,n=e.faces,i=e.vertices,r=e.normals,a=e.texturecoords&&e.texturecoords[0],o=i.length/3,s=[],u=e.bones,h=[];if(u){for(var c=0;c<o;c++)h[c]=[];var d,l,p;for(c=0;c<u.length;c++){(d=u[c]).name,d.offsetmatrix,l=d.weights;for(var f=0;f<l.length;f++)h[(p=l[f])[0]].push({index:c,weight:p[1]})}for(c=0;c<o;c++){(E=h[c]).sort(function(e,t){return t.weight-e.weight});var _=E[0]?E[0].weight:0,v=E[1]?E[1].weight:0,m=E[2]?E[2].weight:0,g=E[3]?E[3].weight:0,y=_+v+m+g;0<y&&(_/=y,v/=y,m/=y,g/=y),E[0]&&(E[0].weight=_),E[1]&&(E[1].weight=v),E[2]&&(E[2].weight=m),E[3]&&(E[3].weight=g)}}for(c=0;c<o;c++){if(s.push(i[3*c+0]),s.push(i[3*c+1]),s.push(i[3*c+2]),s.push(r[3*c+0]),s.push(r[3*c+1]),s.push(r[3*c+2]),s.push(0),s.push(0),s.push(0),u)for(var E=h[c],T=0;T<4;T++)E[T]?s.push(E[T].index):s.push(0);else s.push(1),s.push(1),s.push(1),s.push(1);if(a?(s.push(a[2*c+0]),s.push(1-a[2*c+1])):(s.push(0),s.push(0)),u)for(E=h[c],T=0;T<4;T++)E[T]?s.push(E[T].weight):s.push(0);else s.push(0),s.push(0)}if(u){var x=new zen3d.InterleavedBuffer(new Float32Array(s),19);M=new zen3d.InterleavedBufferAttribute(x,3,0),t.addAttribute("a_Position",M),M=new zen3d.InterleavedBufferAttribute(x,3,3),t.addAttribute("a_Normal",M),M=new zen3d.InterleavedBufferAttribute(x,4,9),t.addAttribute("skinIndex",M),M=new zen3d.InterleavedBufferAttribute(x,4,15),t.addAttribute("skinWeight",M),M=new zen3d.InterleavedBufferAttribute(x,2,13),t.addAttribute("a_Uv",M)}else{var M;x=new zen3d.InterleavedBuffer(new Float32Array(s),17);M=new zen3d.InterleavedBufferAttribute(x,3,0),t.addAttribute("a_Position",M),M=new zen3d.InterleavedBufferAttribute(x,3,3),t.addAttribute("a_Normal",M),M=new zen3d.InterleavedBufferAttribute(x,4,9),t.addAttribute("a_Color",M),M=new zen3d.InterleavedBufferAttribute(x,2,13),t.addAttribute("a_Uv",M)}var w=[];for(c=0;c<n.length;c++)w.push(n[c][0]),w.push(n[c][1]),w.push(n[c][2]);return t.setIndex(w),t.computeBoundingBox(),t.computeBoundingSphere(),t},e.prototype.parseObject=function(e,t,n,i,r){var a=new zen3d.Group;a.name=t.name||"",a.matrix.fromArray(t.transformation).transpose(),a.matrix.decompose(a.position,a.quaternion,a.scale);for(var o,s=0;t.meshes&&s<t.meshes.length;++s){var u=t.meshes[s],h=i[e.meshes[u].materialindex];r[u]?(o=new zen3d.SkinnedMesh(n[u],h)).skeleton=r[u]:o=new zen3d.Mesh(n[u],h),o.frustumCulled=!1,a.add(o)}for(s=0;t.children&&s<t.children.length;++s)a.add(this.parseObject(e,t.children[s],n,i,r));return a},e.prototype.extractUrlBase=function(e){var t=e.split("/");return t.pop(),(t.length<1?".":t.join("/"))+"/"},zen3d.AssimpJsonLoader=e}(),function(){var e=function(){this.path=void 0,this.responseType=void 0,this.withCredentials=void 0,this.mimeType=void 0,this.requestHeader=void 0};e.prototype.load=function(e,n,t,i){void 0===e&&(e=""),null!=this.path&&(e=this.path+e);var r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){var a=r[1],o=!!r[2],s=r[3];s=window.decodeURIComponent(s),o&&(s=window.atob(s));try{var u,h=(this.responseType||"").toLowerCase();switch(h){case"arraybuffer":case"blob":u=new ArrayBuffer(s.length);for(var c=new Uint8Array(u),d=0;d<s.length;d++)c[d]=s.charCodeAt(d);"blob"===h&&(u=new Blob([u],{type:a}));break;case"document":var l=new DOMParser;u=l.parseFromString(s,a);break;case"json":u=JSON.parse(s);break;default:u=s}window.setTimeout(function(){n&&n(u)},0)}catch(e){window.setTimeout(function(){i&&i(e)},0)}}else{var p=new XMLHttpRequest;for(var f in p.open("GET",e,!0),p.addEventListener("load",function(e){var t=e.target.response;200===this.status?n&&n(t):0===this.status?(console.warn("THREE.FileLoader: HTTP Status 0 received."),n&&n(t)):i&&i(e)},!1),void 0!==t&&p.addEventListener("progress",function(e){t(e)},!1),void 0!==i&&p.addEventListener("error",function(e){i(e)},!1),void 0!==this.responseType&&(p.responseType=this.responseType),void 0!==this.withCredentials&&(p.withCredentials=this.withCredentials),p.overrideMimeType&&p.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)p.setRequestHeader(f,this.requestHeader[f]);p.send(null)}},e.prototype.setPath=function(e){return this.path=e,this},e.prototype.setResponseType=function(e){return this.responseType=e,this},e.prototype.setWithCredentials=function(e){return this.withCredentials=e,this},e.prototype.setMimeType=function(e){return this.mimeType=e,this},e.prototype.setRequestHeader=function(e){return this.requestHeader=e,this},zen3d.FileLoader=e}(),function(){var e=function(){this.crossOrigin=void 0,this.path=void 0};e.prototype.load=function(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e);var r=document.createElementNS("http://www.w3.org/1999/xhtml","img");return r.addEventListener("load",function(){t&&t(this)},!1),r.addEventListener("error",function(e){i&&i(e)},!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(r.crossOrigin=this.crossOrigin),r.src=e,r},e.prototype.setCrossOrigin=function(e){return this.crossOrigin=e,this},e.prototype.setPath=function(e){return this.path=e,this},zen3d.ImageLoader=e}(),function(){var e=function(){};e.prototype.load=function(e,t,n,i){var r=this,a=new zen3d.FileLoader;a.setResponseType("arraybuffer"),a.load(e,function(e){void 0!==t&&t(r.parse(e))},n,i)},e.prototype.parse=function(e){var t=0,n=1,i=2,r=3,a=9,o=10,s=11,d=48,l=4,p=0,f=1,_=2,v=3;e.length<19&&console.error("TGALoader.parse: Not enough data to contain header.");var u=new Uint8Array(e),h=0,m={id_length:u[h++],colormap_type:u[h++],image_type:u[h++],colormap_index:u[h++]|u[h++]<<8,colormap_length:u[h++]|u[h++]<<8,colormap_size:u[h++],origin:[u[h++]|u[h++]<<8,u[h++]|u[h++]<<8],width:u[h++]|u[h++]<<8,height:u[h++]|u[h++]<<8,pixel_size:u[h++],flags:u[h++]};!function(e){switch(e.image_type){case n:case a:(256<e.colormap_length||24!==e.colormap_size||1!==e.colormap_type)&&console.error("TGALoader.parse.tgaCheckHeader: Invalid type colormap data for indexed type");break;case i:case r:case o:case s:e.colormap_type&&console.error("TGALoader.parse.tgaCheckHeader: Invalid type colormap data for colormap type");break;case t:console.error("TGALoader.parse.tgaCheckHeader: No data");default:console.error(\'TGALoader.parse.tgaCheckHeader: Invalid type " \'+e.image_type+\'"\')}(e.width<=0||e.height<=0)&&console.error("TGALoader.parse.tgaCheckHeader: Invalid image size"),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error(\'TGALoader.parse.tgaCheckHeader: Invalid pixel size "\'+e.pixel_size+\'"\')}(m),m.id_length+h>e.length&&console.error("TGALoader.parse: No data"),h+=m.id_length;var c=!1,g=!1,y=!1;switch(m.image_type){case a:g=c=!0;break;case n:g=!0;break;case o:c=!0;break;case i:break;case s:y=c=!0;break;case r:y=!0}var E=document.createElement("canvas");E.width=m.width,E.height=m.height;var T=E.getContext("2d"),x=T.createImageData(m.width,m.height),M=function(e,t,n,i,r){var a,o,s,u;if(o=n.pixel_size>>3,s=n.width*n.height*o,t&&(u=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){var h,c,d;a=new Uint8Array(s);for(var l=0,p=new Uint8Array(o);l<s;)if(c=1+(127&(h=r[i++])),128&h){for(d=0;d<o;++d)p[d]=r[i++];for(d=0;d<c;++d)a.set(p,l+d*o);l+=o*c}else{for(c*=o,d=0;d<c;++d)a[l+d]=r[i++];l+=c}}else a=r.subarray(i,i+=t?n.width*n.height:s);return{pixel_data:a,palettes:u}}(c,g,m,h,u);!function(e,t,n,i,r){var a,o,s,u,h,c;switch((m.flags&d)>>l){default:case _:h=t,o=a=0,u=s=1,c=n;break;case p:a=0,h=t,o=n-(s=1),c=u=-1;break;case v:a=t-1,h=s=-1,o=0,u=1,c=n;break;case f:a=t-1,o=n-1,c=u=h=s=-1}if(y)switch(m.pixel_size){case 8:!function(e,t,n,i,r,a,o,s){var u,h,c,d=0,l=m.width;for(c=t;c!==i;c+=n)for(h=r;h!==o;h+=a,d++)u=s[d],e[4*(h+l*c)+0]=u,e[4*(h+l*c)+1]=u,e[4*(h+l*c)+2]=u,e[4*(h+l*c)+3]=255}(e,o,u,c,a,s,h,i);break;case 16:!function(e,t,n,i,r,a,o,s){var u,h,c=0,d=m.width;for(h=t;h!==i;h+=n)for(u=r;u!==o;u+=a,c+=2)e[4*(u+d*h)+0]=s[c+0],e[4*(u+d*h)+1]=s[c+0],e[4*(u+d*h)+2]=s[c+0],e[4*(u+d*h)+3]=s[c+1]}(e,o,u,c,a,s,h,i);break;default:console.error("TGALoader.parse.getTgaRGBA: not support this format")}else switch(m.pixel_size){case 8:!function(e,t,n,i,r,a,o,s,u){var h,c,d,l=u,p=0,f=m.width;for(d=t;d!==i;d+=n)for(c=r;c!==o;c+=a,p++)h=s[p],e[4*(c+f*d)+3]=255,e[4*(c+f*d)+2]=l[3*h+0],e[4*(c+f*d)+1]=l[3*h+1],e[4*(c+f*d)+0]=l[3*h+2]}(e,o,u,c,a,s,h,i,r);break;case 16:!function(e,t,n,i,r,a,o,s){var u,h,c,d=0,l=m.width;for(c=t;c!==i;c+=n)for(h=r;h!==o;h+=a,d+=2)u=s[d+0]+(s[d+1]<<8),e[4*(h+l*c)+0]=(31744&u)>>7,e[4*(h+l*c)+1]=(992&u)>>2,e[4*(h+l*c)+2]=(31&u)>>3,e[4*(h+l*c)+3]=32768&u?0:255}(e,o,u,c,a,s,h,i);break;case 24:!function(e,t,n,i,r,a,o,s){var u,h,c=0,d=m.width;for(h=t;h!==i;h+=n)for(u=r;u!==o;u+=a,c+=3)e[4*(u+d*h)+3]=255,e[4*(u+d*h)+2]=s[c+0],e[4*(u+d*h)+1]=s[c+1],e[4*(u+d*h)+0]=s[c+2]}(e,o,u,c,a,s,h,i);break;case 32:!function(e,t,n,i,r,a,o,s){var u,h,c=0,d=m.width;for(h=t;h!==i;h+=n)for(u=r;u!==o;u+=a,c+=4)e[4*(u+d*h)+2]=s[c+0],e[4*(u+d*h)+1]=s[c+1],e[4*(u+d*h)+0]=s[c+2],e[4*(u+d*h)+3]=s[c+3]}(e,o,u,c,a,s,h,i);break;default:console.error("TGALoader.parse.getTgaRGBA: not support this format")}}(x.data,m.width,m.height,M.pixel_data,M.palettes);return T.putImageData(x,0,0),E},zen3d.TGALoader=e}(),function(){function u(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);return decodeURIComponent(escape(t))}var t,s=(t=new RegExp("[\\\\[\\\\]\\\\.:\\\\/]","g"),function(e){return e.replace(/\\s/g,"_").replace(t,"")});function h(e,t){return"string"!=typeof e||""===e?"":/^(https?:)?\\/\\//i.test(e)?e:/^data:.*,.*$/i.test(e)?e:/^blob:.*$/i.test(e)?e:t+e}var e=function(){};function i(){var n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}function c(e,t,n){this.json=e||{},this.extensions=t||{},this.options=n||{},this.cache=new i,this.primitiveCache=[],this.textureLoader=new zen3d.ImageLoader,this.fileLoader=new zen3d.FileLoader,this.fileLoader.setResponseType("arraybuffer")}function a(e,t){if(e.indices!==t.indices)return!1;var n=e.attributes||{},i=t.attributes||{},r=Object.keys(n),a=Object.keys(i);if(r.length!==a.length)return!1;for(var o=0,s=r.length;o<s;o++){var u=r[o];if(n[u]!==i[u])return!1}return!0}function p(e,t){for(var n=0,i=e.length;n<i;n++){var r=e[n];if(a(r.primitive,t))return r.promise}return null}function f(e,t,n){var i=t.attributes;for(var r in i){var a=T[r],o=n[i[r]];a&&(a in e.attributes||e.addAttribute(a,o))}void 0===t.indices||e.index||e.setIndex(n[t.indices])}e.prototype.load=function(e,t,n,i){var r,a=this,o=((r=e.split("/")).pop(),(r.length<1?".":r.join("/"))+"/"),s=new zen3d.FileLoader;s.setResponseType("arraybuffer"),s.load(e,function(e){void 0!==t&&a.parse(e,o,t,i)},n,i)},e.prototype.parse=function(e,t,a,n){var i,r={};if("string"==typeof e)i=e;else if(u(new Uint8Array(e,0,4))===l){try{r[_.KHR_BINARY_GLTF]=new g(e)}catch(e){return void(n&&n(e))}i=r[_.KHR_BINARY_GLTF].content}else i=u(new Uint8Array(e));var o=JSON.parse(i);void 0===o.asset||o.asset.version[0]<2?n&&n(new Error("GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.")):(o.extensionsUsed&&(0<=o.extensionsUsed.indexOf(_.KHR_LIGHTS)&&(r[_.KHR_LIGHTS]=new d(o)),0<=o.extensionsUsed.indexOf(_.KHR_MATERIALS_UNLIT)&&console.warn("GLTFLoader:: KHR_MATERIALS_UNLIT not currently supported."),0<=o.extensionsUsed.indexOf(_.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS)&&console.warn("GLTFLoader:: KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS not currently supported."),0<=o.extensionsUsed.indexOf(_.KHR_DRACO_MESH_COMPRESSION)&&(console.warn("GLTFLoader:: no draco loader."),r[_.KHR_DRACO_MESH_COMPRESSION]=new y)),console.time("GLTFLoader"),new c(o,r,{path:t}).parse(function(e,t,n,i,r){console.timeEnd("GLTFLoader"),a({scene:e,scenes:t,cameras:n,animations:i,asset:r})},n))},zen3d.GLTFLoader=e,c.prototype.parse=function(o,e){var s=this.json;this.cache.removeAll(),this.markDefs(),this.getMultiDependencies(["scene","animation","camera"]).then(function(e){var t=e.scenes||[],n=t[s.scene||0],i=e.animations||[],r=s.asset,a=e.cameras||[];o(n,t,a,i,r)}).catch(e)},c.prototype.markDefs=function(){for(var e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[],i={},r={},a=0,o=t.length;a<o;a++)for(var s=t[a].joints,u=0,h=s.length;u<h;u++)e[s[u]].isBone=!0;for(var c=0,d=e.length;c<d;c++){var l=e[c];void 0!==l.mesh&&(void 0===i[l.mesh]&&(i[l.mesh]=r[l.mesh]=0),i[l.mesh]++,void 0!==l.skin&&(n[l.mesh].isSkinnedMesh=!0))}this.json.meshReferences=i,this.json.meshUses=r},c.prototype.getDependency=function(e,t){var n=e+":"+t,i=this.cache.get(n);i||(i=this["load"+e.charAt(0).toUpperCase()+e.slice(1)](t),this.cache.add(n,i));return i},c.prototype.getDependencies=function(n){var e=this.cache.get(n);if(!e){var i=this,t=this.json[n+("mesh"===n?"es":"s")]||[];e=Promise.all(t.map(function(e,t){return i.getDependency(n,t)})),this.cache.add(n,e)}return e},c.prototype.getMultiDependencies=function(e){for(var n={},t=[],i=0,r=e.length;i<r;i++){var a=e[i],o=this.getDependencies(a);o=o.then(function(e,t){n[e]=t}.bind(this,a+("mesh"===a?"es":"s"))),t.push(o)}return Promise.all(t).then(function(){return n})},c.prototype.loadScene=function(){function E(e,t,n,i,r){var a=i[e],o=n.nodes[e];if(void 0!==o.skin)for(var s=!0===a.isGroup?a.children:[a],u=0,h=s.length;u<h;u++){for(var c=s[u],d=r[o.skin],l=[],p=0,f=d.joints.length;p<f;p++){var _=d.joints[p],v=i[_];if(v){l.push(v);var m=new zen3d.Matrix4;void 0!==d.inverseBindMatrices&&m.fromArray(d.inverseBindMatrices.array,16*p),v.offsetMatrix.copy(m)}else console.warn(\'GLTFLoader: Joint "%s" could not be found.\',_)}var g=new zen3d.Skeleton(l);c.skeleton=g}if(t.add(a),o.children){var y=o.children;for(u=0,h=y.length;u<h;u++){E(y[u],a,n,i,r)}}}return function(e){var o=this.json,s=this.extensions,u=this.json.scenes[e];return this.getMultiDependencies(["node","skin"]).then(function(e){var t=new zen3d.Scene;void 0!==u.name&&(t.name=u.name),u.extras&&(t.userData=u.extras);for(var n=u.nodes||[],i=0,r=n.length;i<r;i++)E(n[i],t,o,e.nodes,e.skins);if(u.extensions&&u.extensions[_.KHR_LIGHTS]&&void 0!==u.extensions[_.KHR_LIGHTS].light){var a=s[_.KHR_LIGHTS].lights;t.add(a[u.extensions[_.KHR_LIGHTS].light])}return t})}}(),c.prototype.loadNode=function(e){this.json;var i=this.extensions,r=this.json.meshReferences,a=this.json.meshUses,o=this.json.nodes[e];return this.getMultiDependencies(["mesh","skin","camera"]).then(function(e){var t;if(!0===o.isBone)t=new zen3d.Bone;else if(void 0!==o.mesh){t=e.meshes[o.mesh].clone(),1<r[o.mesh]&&(t.name+="_instance_"+a[o.mesh]++)}else if(void 0!==o.camera)t=e.cameras[o.camera];else if(o.extensions&&o.extensions[_.KHR_LIGHTS]&&void 0!==o.extensions[_.KHR_LIGHTS].light){t=i[_.KHR_LIGHTS].lights[o.extensions[_.KHR_LIGHTS].light]}else t=new zen3d.Object3D;if(void 0!==o.name&&(t.name=s(o.name)),o.extras&&(t.userData=o.extras),void 0!==o.matrix){var n=new zen3d.Matrix4;n.fromArray(o.matrix),t.matrix.multiplyMatrices(n,t.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale)}else void 0!==o.translation&&t.position.fromArray(o.translation),void 0!==o.rotation&&t.quaternion.fromArray(o.rotation),void 0!==o.scale&&t.scale.fromArray(o.scale);return t})},c.prototype.loadCamera=function(e){console.warn("GLTFLoader: camera is not supported yet")},c.prototype.loadSkin=function(e){console.warn("GLTFLoader: skin is not supported yet")},c.prototype.loadAnimation=function(e){console.warn("GLTFLoader: animation is not supported yet")},c.prototype.loadMesh=function(v){var m=this,g=(this.json,this.extensions,this.json.meshes[v]);return this.getMultiDependencies(["accessor","material"]).then(function(p){var f=new zen3d.Group,_=g.primitives;return m.loadGeometries(_).then(function(e){for(var t=0,n=_.length;t<n;t++){var i=_[t],r=e[t],a=void 0===i.material?new zen3d.PBRMaterial:p.materials[i.material];a.aoMap&&void 0===r.attributes.a_Uv2&&void 0!==r.attributes.a_Uv&&(console.log("GLTFLoader: Duplicating UVs to support aoMap."),r.addAttribute("a_Uv2",new zen3d.BufferAttribute(r.attributes.a_Uv.array,2)));var o,s=void 0!==r.attributes.a_Color,u=void 0===r.attributes.a_Normal,h=!0===g.isSkinnedMesh;if((s||u||h)&&(a.isGLTFSpecularGlossinessMaterial?console.warn("GLTFLoader: GLTFSpecularGlossinessMaterial not support"):a=a.clone()),s&&(a.vertexColors=!0),u&&(a.shading=zen3d.SHADING_TYPE.FLAT_SHADING),i.mode===E.TRIANGLES||i.mode===E.TRIANGLE_STRIP||i.mode===E.TRIANGLE_FAN||void 0===i.mode)o=h?new zen3d.SkinnedMesh(r,a):new zen3d.Mesh(r,a),i.mode===E.TRIANGLE_STRIP?a.drawMode=zen3d.DRAW_MODE.TRIANGLE_STRIP:i.mode===E.TRIANGLE_FAN&&(a.drawMode=zen3d.DRAW_MODE.TRIANGLE_FAN);else if(i.mode===E.LINES||i.mode===E.LINE_STRIP||i.mode===E.LINE_LOOP){console.warn("GLTFLoader: line material may has bug");var c="LineBasicMaterial:"+a.uuid,d=m.cache.get(c);d||(d=new zen3d.LineMaterial,zen3d.Material.prototype.copy.call(d,a),d.color.copy(a.color),d.lights=!1,m.cache.add(c,d)),a=d,o=(i.mode===E.LINES||(i.mode,E.LINE_STRIP),new zen3d.Line(r,a))}else{if(i.mode!==E.POINTS)throw new Error("GLTFLoader: Primitive mode unsupported: "+i.mode);c="PointsMaterial:"+a.uuid;var l=m.cache.get(c);l||(l=new zen3d.PointsMaterial,zen3d.Material.prototype.copy.call(l,a),l.diffuse.copy(a.color),l.diffuseMap=a.map,l.acceptLight=!1,m.cache.add(c,l)),a=l,o=new zen3d.Points(r,a)}if(o.name=g.name||"mesh_"+v,void 0!==g.extras&&(o.userData=g.extras),void 0!==i.extras&&(o.geometry.userData=i.extras),!(1<_.length))return o;o.name+="_"+t,f.add(o)}return f})})},c.prototype.loadGeometries=function(h){var c=this,d=this.extensions,l=this.primitiveCache;return this.getDependencies("accessor").then(function(t){for(var n=[],e=[],i=0,r=h.length;i<r;i++){var a,o=h[i],s=p(l,o);if(s)e.push(s.then(function(e){n.push(e)}));else if(o.extensions&&o.extensions[_.KHR_DRACO_MESH_COMPRESSION]){var u=d[_.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,c).then(function(e){return f(e,o,t),n.push(e),e});l.push({primitive:o,promise:u}),e.push(u)}else f(a=new zen3d.Geometry,o,t),l.push({primitive:o,promise:Promise.resolve(a)}),n.push(a)}return Promise.all(e).then(function(){return n})})},c.prototype.loadAccessor=function(e){var x=this,M=this.json,w=this.json.accessors[e];if(void 0===w.bufferView&&void 0===w.sparse)return null;var t=[];return void 0!==w.bufferView?t.push(this.getDependency("bufferView",w.bufferView)):t.push(null),void 0!==w.sparse&&(t.push(this.getDependency("bufferView",w.sparse.indices.bufferView)),t.push(this.getDependency("bufferView",w.sparse.values.bufferView))),Promise.all(t).then(function(e){var t,n,i=e[0],r=S[w.type],a=z[w.componentType],o=a.BYTES_PER_ELEMENT,s=o*r,u=w.byteOffset||0,h=M.bufferViews[w.bufferView].byteStride,c=!0===w.normalized;if(h&&h!==s){var d="InterleavedBuffer:"+w.bufferView+":"+w.componentType,l=x.cache.get(d);l||(t=new a(i),l=new zen3d.InterleavedBuffer(t,h/o),x.cache.add(d,l)),n=new zen3d.InterleavedBufferAttribute(l,r,u/o,c)}else t=null===i?new a(w.count*r):new a(i,u,w.count*r),n=new zen3d.BufferAttribute(t,r,c);if(void 0!==w.sparse){var p=S.SCALAR,f=z[w.sparse.indices.componentType],_=w.sparse.indices.byteOffset||0,v=w.sparse.values.byteOffset||0,m=new f(e[1],_,w.sparse.count*p),g=new a(e[2],v,w.sparse.count*r);null!==i&&n.setArray(n.array.slice());for(var y=0,E=m.length;y<E;y++){var T=m[y];if(n.array[T*n.itemSize]=g[y*r],2<=r&&(n.array[T*n.itemSize+1]=g[y*r+1]),3<=r&&(n.array[T*n.itemSize+2]=g[y*r+2]),4<=r&&(n.array[T*n.itemSize+3]=g[y*r+3]),5<=r)throw new Error("zen3d.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return n})},c.prototype.loadBufferView=function(e){var i=this.json.bufferViews[e];return this.getDependency("buffer",i.buffer).then(function(e){var t=i.byteLength||0,n=i.byteOffset||0;return e.slice(n,n+t)})},c.prototype.loadBuffer=function(e){var n=this.json.buffers[e],i=this.fileLoader;if(n.type&&"arraybuffer"!==n.type)throw new Error("zen3d.GLTFLoader: "+n.type+" buffer type is not supported.");if(void 0===n.uri&&0===e)return Promise.resolve(this.extensions[_.KHR_BINARY_GLTF].body);var r=this.options;return new Promise(function(e,t){i.load(h(n.uri,r.path),e,void 0,function(){t(new Error(\'zen3d.GLTFLoader: Failed to load buffer "\'+n.uri+\'".\'))})})},c.prototype.loadMaterial=function(e){var n,t=this,i=(this.json,this.extensions,this.json.materials[e]),r={},a=i.extensions||{},o=[];if(a[_.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]);else if(a[_.KHR_MATERIALS_UNLIT]);else if(void 0!==i.pbrMetallicRoughness){n=zen3d.PBRMaterial;var s=i.pbrMetallicRoughness;if(r.color=new zen3d.Color3(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){var u=s.baseColorFactor;r.diffuse.fromArray(u),r.opacity=u[3]}if(void 0!==s.baseColorTexture&&o.push(t.assignTexture(r,"diffuseMap",s.baseColorTexture.index)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture){var h=s.metallicRoughnessTexture.index;o.push(t.assignTexture(r,"metalnessMap",h)),o.push(t.assignTexture(r,"roughnessMap",h))}}else n=zen3d.PhongMaterial;!0===i.doubleSided&&(r.side=zen3d.DRAW_SIDE.DOUBLE);var c=i.alphaMode||x.OPAQUE;return c===x.BLEND?r.transparent=!0:(r.transparent=!1,x.MASK),void 0!==i.normalTexture&&o.push(t.assignTexture(r,"normalMap",i.normalTexture.index)),void 0!==i.occlusionTexture&&(o.push(t.assignTexture(r,"aoMap",i.occlusionTexture.index)),void 0!==i.occlusionTexture.strength&&(r.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&(r.emissive=(new zen3d.Color3).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&o.push(t.assignTexture(r,"emissiveMap",i.emissiveTexture.index)),Promise.all(o).then(function(){var e;for(var t in n===zen3d.ShaderMaterial||(e=new n),r)e[t]=r[t];return e.map&&(e.map.encoding=zen3d.TEXEL_ENCODING_TYPE.SRGB),e.emissiveMap&&(e.emissiveMap.encoding=zen3d.TEXEL_ENCODING_TYPE.SRGB),i.extras&&(e.userData=i.extras),e})},c.prototype.assignTexture=function(t,n,e){return this.getDependency("texture",e).then(function(e){t[n]=e})},c.prototype.loadTexture=function(e){var i=this.json,r=this.options,t=this.textureLoader,a=window.URL||window.webkitURL,o=i.textures[e],n=i.images[o.source],s=n.uri,u=!1;return void 0!==n.bufferView&&(s=this.getDependency("bufferView",n.bufferView).then(function(e){u=!0;var t=new Blob([e],{type:n.mimeType});return s=a.createObjectURL(t)})),Promise.resolve(s).then(function(n){var i=t;return new Promise(function(e,t){i.load(h(n,r.path),e,void 0,t)})}).then(function(e){var t=zen3d.Texture2D.fromImage(e);!0===u&&a.revokeObjectURL(s),t.pixelFormat=void 0!==o.format?M[o.format]:zen3d.WEBGL_PIXEL_FORMAT.RGBA,void 0!==o.internalFormat&&t.pixelFormat!==M[o.internalFormat]&&console.warn("zen3d.GLTFLoader: Three.js does not support texture internalFormat which is different from texture format. internalFormat will be forced to be the same value as format."),t.type=void 0!==o.type?w[o.type]:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_BYTE;var n=(i.samplers||{})[o.sampler]||{};return t.magFilter=A[n.magFilter]||zen3d.WEBGL_TEXTURE_FILTER.LINEAR,t.minFilter=A[n.minFilter]||zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_LINEAR,t.wrapS=b[n.wrapS]||zen3d.WEBGL_TEXTURE_WRAP.REPEAT,t.wrapT=b[n.wrapT]||zen3d.WEBGL_TEXTURE_WRAP.REPEAT,t})};var _={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS:"KHR_lights",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_UNLIT:"KHR_materials_unlit"};function d(e){this.name=_.KHR_LIGHTS,this.lights={};var t=(e.extensions&&e.extensions[_.KHR_LIGHTS]||{}).lights||{};for(var n in t){var i,r=t[n],a=(new zen3d.Color3).fromArray(r.color);switch(r.type){case"directional":(i=new zen3d.DirectionalLight).color.copy(a),i.position.set(0,0,1);break;case"point":(i=new zen3d.PointLight).color.copy(a);break;case"spot":(i=new zen3d.SpotLight).color.copy(a),i.position.set(0,0,1);break;case"ambient":(i=new zen3d.AmbientLight).color.copy(a)}i&&(void 0!==r.constantAttenuation&&(i.intensity=r.constantAttenuation),void 0!==r.linearAttenuation&&(i.distance=1/r.linearAttenuation),void 0!==r.quadraticAttenuation&&(i.decay=r.quadraticAttenuation),void 0!==r.fallOffAngle&&(i.angle=r.fallOffAngle),void 0!==r.fallOffExponent&&console.warn("GLTFLoader:: light.fallOffExponent not currently supported."),i.name=r.name||"light_"+n,this.lights[n]=i)}}var l="glTF",v=12,m={JSON:1313821514,BIN:5130562};function g(e){this.name=_.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,v);if(this.header={magic:u(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==l)throw new Error("GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.");for(var n=new DataView(e,v),i=0;i<n.byteLength;){var r=n.getUint32(i,!0);i+=4;var a=n.getUint32(i,!0);if(i+=4,a===m.JSON){var o=new Uint8Array(e,v+i,r);this.content=u(o)}else if(a===m.BIN){var s=v+i;this.body=e.slice(s,s+r)}i+=r}if(null===this.content)throw new Error("GLTFLoader: JSON content not found.")}function y(e){if(!e)throw new Error("GLTFLoader: No DRACOLoader instance provided.");this.name=_.KHR_DRACO_MESH_COMPRESSION,this.dracoLoader=e}y.prototype.decodePrimitive=function(e,t){var n=this.dracoLoader,i=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={};for(var o in r)o in T&&(a[T[o]]=r[o]);return t.getDependency("bufferView",i).then(function(t){return new Promise(function(e){n.decodeDracoFile(t,e,a)})})};var E={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},T={POSITION:"a_Position",NORMAL:"a_Normal",TEXCOORD_0:"a_Uv",TEXCOORD0:"a_Uv",TEXCOORD:"a_Uv",TEXCOORD_1:"a_Uv2",COLOR_0:"a_Color",COLOR0:"a_Color",COLOR:"a_Color",WEIGHTS_0:"skinWeight",WEIGHT:"skinWeight",JOINTS_0:"skinIndex",JOINT:"skinIndex"},S={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},z={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},x={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},M={6406:zen3d.WEBGL_PIXEL_FORMAT.ALPHA,6407:zen3d.WEBGL_PIXEL_FORMAT.RGB,6408:zen3d.WEBGL_PIXEL_FORMAT.RGBA,6409:zen3d.WEBGL_PIXEL_FORMAT.LUMINANCE,6410:zen3d.WEBGL_PIXEL_FORMAT.LUMINANCE_ALPHA},w={5121:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_BYTE,32819:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_SHORT_4_4_4_4,32820:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_SHORT_5_5_5_1,33635:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_SHORT_5_6_5},A={9728:zen3d.WEBGL_TEXTURE_FILTER.NEAREST,9729:zen3d.WEBGL_TEXTURE_FILTER.LINEAR,9984:zen3d.WEBGL_TEXTURE_FILTER.NEAREST_MIPMAP_NEAREST,9985:zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_NEAREST,9986:zen3d.WEBGL_TEXTURE_FILTER.NEAREST_MIPMAP_LINEAR,9987:zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_LINEAR},b={33071:zen3d.WEBGL_TEXTURE_WRAP.CLAMP_TO_EDGE,33648:zen3d.WEBGL_TEXTURE_WRAP.MIRRORED_REPEAT,10497:zen3d.WEBGL_TEXTURE_WRAP.REPEAT}}(),function(){var e=function(){this._entities={},this.enableCounter=!1};e.prototype.getEntity=function(e){return this._entities[e]},e.prototype.getFps=function(){var e=this.getEntity("fps");return e&&e.averageDelta?Math.floor(1e3/e.averageDelta):0},e.prototype.updateFps=function(){this.enableCounter&&(this.endCounter("fps"),this.startCounter("fps",60))},e.prototype.getNow=function(){return window.performance?window.performance.now():(new Date).getTime()},e.prototype.startCounter=function(e,t){if(this.enableCounter){var n=this._entities[e];n||(n={start:0,end:0,delta:0,_cache:[],averageRange:1,averageDelta:0},this._entities[e]=n),n.start=this.getNow(),n.averageRange=t||1}},e.prototype.endCounter=function(e){if(this.enableCounter){var t=this._entities[e];if(t&&(t.end=this.getNow(),t.delta=t.end-t.start,1<t.averageRange)){t._cache.push(t.delta);var n=t._cache.length;if(n>=t.averageRange){n>t.averageRange&&(t._cache.shift(),n--);for(var i=0,r=0;r<n;r++)i+=t._cache[r];t.averageDelta=i/n}}}},zen3d.Performance=e}(),function(){var e=function(e,t){this.camera=e,this.lookAtPoint=t,this.up=new zen3d.Vector3(0,1,0),this.distance=100,this._panAngle=0,this._panRad=0,this.minPanAngle=-1/0,this.maxPanAngle=1/0,this._tiltAngle=0,this._tiltRad=0,this.minTileAngle=-90,this.maxTileAngle=90,this.bindMouse=void 0,this._lastMouseX,this._lastMouseY,this._mouseDown=!1,this.bindTouch=void 0,this._lastTouchX,this._lastTouchY,this._fingerTwo=!1,this._lastDistance};Object.defineProperties(e.prototype,{panAngle:{get:function(){return this._panAngle},set:function(e){this._panAngle=Math.max(this.minPanAngle,Math.min(this.maxPanAngle,e)),this._panRad=this._panAngle*Math.PI/180}},tiltAngle:{get:function(){return this._tiltAngle},set:function(e){this._tiltAngle=Math.max(this.minTileAngle,Math.min(this.maxTileAngle,e)),this._tiltRad=this._tiltAngle*Math.PI/180}}}),e.prototype.update=function(){this.bindMouse&&this._updateMouse(),this.bindTouch&&this._updateTouch();var e=this.distance*Math.sin(this._panRad)*Math.cos(this._tiltRad),t=this.distance*Math.sin(this._tiltRad),n=this.distance*Math.cos(this._panRad)*Math.cos(this._tiltRad),i=this.camera,r=this.lookAtPoint;i.position.set(e+r.x,t+r.y,n+r.z),i.setLookAt(r,this.up)},e.prototype._updateMouse=function(){var e=this.bindMouse;if(e.isPressed(0))if(this._mouseDown&&null!=this._lastMouseX&&null!=this._lastMouseY){var t=e.position.x-this._lastMouseX,n=e.position.y-this._lastMouseY;this.panAngle-=t,this.tiltAngle+=n,this._lastMouseX=e.position.x,this._lastMouseY=e.position.y}else this._mouseDown=!0,this._lastMouseX=e.position.x,this._lastMouseY=e.position.y;else e.wasReleased(0)&&(this._mouseDown=!1);this.distance=Math.max(this.distance-2*e.wheel,1)};var u=new zen3d.Vector2,h=new zen3d.Vector2;e.prototype._updateTouch=function(e){if(0<(e=this.bindTouch).touchCount)if(1==e.touchCount){var t=e.getTouch(0);if(t.phase==zen3d.TouchPhase.BEGAN||this._fingerTwo||null==this._lastTouchX||null==this._lastTouchY)this._lastTouchX=t.position.x,this._lastTouchY=t.position.y;else{var n=t.position.x-this._lastTouchX,i=t.position.y-this._lastTouchY;this.panAngle-=.5*n,this.tiltAngle+=.5*i,this._lastTouchX=t.position.x,this._lastTouchY=t.position.y}this._fingerTwo=!1}else if(2==e.touchCount){var r=e.getTouch(0),a=e.getTouch(1);if(r.phase==zen3d.TouchPhase.BEGAN||a.phase==zen3d.TouchPhase.BEGAN||0==this._fingerTwo||null==this._lastDistance)u.set(r.position.x,r.position.y),h.set(a.position.x,a.position.y),this._lastDistance=u.distanceTo(h);else{u.set(r.position.x,r.position.y),h.set(a.position.x,a.position.y);var o=u.distanceTo(h),s=o-this._lastDistance;this.distance=Math.max(this.distance-s,1),this._lastDistance=o}this._fingerTwo=!0}else this._fingerTwo=!1},zen3d.HoverController=e}(),function(){var e=function(e){this.camera=e,this.camera.euler.order="YXZ",this.bindKeyboard=void 0,this.bindMouse=void 0,this._lastMouseX,this._lastMouseY,this._mouseDown=!1};e.prototype.update=function(){this.bindKeyboard&&this.keyboardUpdate(),this.bindMouse&&this.mouseUpdate()};var i=new zen3d.Vector3,t=new zen3d.Vector3,n=new zen3d.Vector3;e.prototype.keyboardUpdate=function(){var e=this.bindKeyboard;i.set(0,0,-1).applyQuaternion(this.camera.quaternion),t.set(0,1,0).applyQuaternion(this.camera.quaternion),n.set(1,0,0).applyQuaternion(this.camera.quaternion),e.isPressed("W")&&this.camera.position.add(i),e.isPressed("A")&&this.camera.position.sub(n),e.isPressed("S")&&this.camera.position.sub(i),e.isPressed("D")&&this.camera.position.add(n),e.isPressed("E")&&this.camera.position.add(t),e.isPressed("Q")&&this.camera.position.sub(t)},e.prototype.mouseUpdate=function(){var e=this.bindMouse;if(e.isPressed(0))if(this._mouseDown&&null!=this._lastMouseX&&null!=this._lastMouseY){var t=e.position.x-this._lastMouseX,n=e.position.y-this._lastMouseY;this.camera.euler.x-=.01*n,this.camera.euler.y-=.01*t,this._lastMouseX=e.position.x,this._lastMouseY=e.position.y}else this._mouseDown=!0,this._lastMouseX=e.position.x,this._lastMouseY=e.position.y;else e.wasReleased(0)&&(this._mouseDown=!1);0!==e.wheel&&(i.set(0,0,-1).applyQuaternion(this.camera.quaternion).multiplyScalar(e.wheel),this.camera.position.add(i))},zen3d.FreeController=e}();\n\\ No newline at end of file\n+!function(t){var e=t.zen3d=t.zen3d||{},n=function(){};e.inherit=function(e,t){n.prototype=t.prototype,e.superClass=t.prototype,e.prototype=new n,e.prototype.constructor=e};var i,r,a,o;e.generateUUID=(r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),a=new Array(36),o=0,function(){for(var e=0;e<36;e++)8===e||13===e||18===e||23===e?a[e]="-":14===e?a[e]="4":(o<=2&&(o=33554432+16777216*Math.random()|0),i=15&o,o>>=4,a[e]=r[19===e?3&i|8:i]);return a.join("")});e.isMobile=function(){if(!t.navigator)return!0;var e=navigator.userAgent.toLowerCase();return-1!=e.indexOf("mobile")||-1!=e.indexOf("android")}();e.isWeb=!!document;e.createCheckerBoardPixels=function(e,t,n){var i=new Uint8Array(e*t*4),r=[[255,255,255,255],[0,0,0,255]];n=n||5;for(var a=0,o=0;o<t;o++)for(var s=0;s<e;s++){if(0==s?a=1:s%n==0&&(a=(a+1)%2),o%n==0&&0==s){var u=r[0];r[0]=r[1],r[1]=u}i[o*(4*e)+4*s+0]=r[a][0],i[o*(4*e)+4*s+1]=r[a][1],i[o*(4*e)+4*s+2]=r[a][2],i[o*(4*e)+4*s+3]=r[a][3]}return i};e.isPowerOfTwo=function(e){return 0==(e&e-1)&&0!==e};e.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))};e.nextPowerOfTwo=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}}(window),function(){zen3d.OBJECT_TYPE={MESH:"mesh",SKINNED_MESH:"skinned_mesh",LIGHT:"light",CAMERA:"camera",SCENE:"scene",GROUP:"group",POINT:"point",LINE:"line",LINE_LOOP:"line_loop",LINE_SEGMENTS:"line_segments",CANVAS2D:"canvas2d",SPRITE:"sprite",PARTICLE:"particle"};zen3d.LIGHT_TYPE={AMBIENT:"ambient",DIRECT:"direct",POINT:"point",SPOT:"spot"};zen3d.MATERIAL_TYPE={BASIC:"basic",LAMBERT:"lambert",PHONG:"phong",PBR:"pbr",CUBE:"cube",POINT:"point",LINE:"line",LINE_LOOP:"lineloop",LINE_DASHED:"linedashed",CANVAS2D:"canvas2d",SPRITE:"sprite",SHADER:"shader",DEPTH:"depth",DISTANCE:"distance",PARTICLE:"particle"};zen3d.FOG_TYPE={NORMAL:"normal",EXP2:"exp2"};zen3d.BLEND_TYPE={NONE:"none",NORMAL:"normal",ADD:"add"};zen3d.CULL_FACE_TYPE={NONE:"none",FRONT:"front",BACK:"back",FRONT_AND_BACK:"front_and_back"};zen3d.DRAW_SIDE={FRONT:"front",BACK:"back",DOUBLE:"double"};zen3d.SHADING_TYPE={SMOOTH_SHADING:"smooth_shading",FLAT_SHADING:"flat_shading"};zen3d.WEBGL_TEXTURE_TYPE={TEXTURE_2D:3553,TEXTURE_CUBE_MAP:34067};zen3d.WEBGL_PIXEL_FORMAT={DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410};zen3d.WEBGL_PIXEL_TYPE={UNSIGNED_BYTE:5121,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FLOAT:5126};zen3d.WEBGL_TEXTURE_FILTER={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};zen3d.WEBGL_TEXTURE_WRAP={REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648};zen3d.WEBGL_UNIFORM_TYPE={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,BYTE:65535,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126};zen3d.WEBGL_ATTRIBUTE_TYPE={FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,FLOAT:5126,BYTE:65535,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123};zen3d.WEBGL_BUFFER_USAGE={STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048};zen3d.SHADOW_TYPE={HARD:"hard",PCF_SOFT:"pcf_soft"};zen3d.TEXEL_ENCODING_TYPE={LINEAR:"linear",SRGB:"sRGB",RGBE:"RGBE",RGBM7:"RGBM7",RGBM16:"RGBM16",RGBD:"RGBD",GAMMA:"Gamma"};zen3d.ENVMAP_COMBINE_TYPE={MULTIPLY:"multiply",MIX:"mix",ADD:"add"};zen3d.DRAW_MODE={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};var e={DEFAULT:"default",TRANSPARENT:"transparent",CANVAS2D:"canvas2d",SPRITE:"sprite",PARTICLE:"particle"},t=[(zen3d.RENDER_LAYER=e).DEFAULT,e.TRANSPARENT,e.CANVAS2D,e.SPRITE,e.PARTICLE];zen3d.LAYER_RENDER_LIST=t}(),function(){var r=function(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._order=i||r.DefaultOrder};r.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],r.DefaultOrder="XYZ",Object.defineProperties(r.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this.onChangeCallback()}}}),r.prototype.copyFrom=function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},r.prototype.set=function(e,t,n,i){return this._x=e||0,this._y=t||0,this._z=n||0,this._order=i||this._order,this.onChangeCallback(),this},r.prototype.setFromRotationMatrix=function(e,t,n){var i=function(e,t,n){return Math.max(t,Math.min(n,e))},r=e.elements,a=r[0],o=r[4],s=r[8],u=r[1],h=r[5],c=r[9],d=r[2],l=r[6],p=r[10];return"XYZ"===(t=t||this._order)?(this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(l,h),this._z=0)):"YXZ"===t?(this._x=Math.asin(-i(c,-1,1)),Math.abs(c)<.99999?(this._y=Math.atan2(s,p),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-d,a),this._z=0)):"ZXY"===t?(this._x=Math.asin(i(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(u,a))):"ZYX"===t?(this._y=Math.asin(-i(d,-1,1)),Math.abs(d)<.99999?(this._x=Math.atan2(l,p),this._z=Math.atan2(u,a)):(this._x=0,this._z=Math.atan2(-o,h))):"YZX"===t?(this._z=Math.asin(i(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-d,a)):(this._x=0,this._y=Math.atan2(s,p))):"XZY"===t?(this._z=Math.asin(-i(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(l,h),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-c,p),this._y=0)):console.warn("given unsupported order: "+t),this._order=t,!1!==n&&this.onChangeCallback(),this},r.prototype.setFromQuaternion=function(e,t,n){var i=zen3d.helpMatrix;return e.toMatrix4(i),this.setFromRotationMatrix(i,t,n)},r.prototype.onChange=function(e){return this.onChangeCallback=e,this},r.prototype.onChangeCallback=function(){},zen3d.Euler=r}(),function(){var e=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1])};e.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},e.prototype.inverse=function(){return this.getInverse(this)},e.prototype.getInverse=function(e){var t=e.elements,n=this.elements,i=t[0],r=t[1],a=t[2],o=t[3],s=t[4],u=t[5],h=t[6],c=t[7],d=t[8],l=d*s-u*c,p=u*h-d*o,f=c*o-s*h,_=i*l+r*p+a*f;if(0===_){return console.warn("zen3d.Matrix3: .getInverse() can\'t invert matrix, determinant is 0"),this.identity()}var v=1/_;return n[0]=l*v,n[1]=(a*c-d*r)*v,n[2]=(u*r-a*s)*v,n[3]=p*v,n[4]=(d*i-a*h)*v,n[5]=(a*o-u*i)*v,n[6]=f*v,n[7]=(r*h-c*i)*v,n[8]=(s*i-r*o)*v,this},e.prototype.transpose=function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},e.prototype.set=function(e,t,n,i,r,a,o,s,u){var h=this.elements;return h[0]=e,h[3]=t,h[6]=n,h[1]=i,h[4]=r,h[7]=a,h[2]=o,h[5]=s,h[8]=u,this},e.prototype.copy=function(e){return this.elements.set(e.elements),this},e.prototype.multiply=function(e){return this.multiplyMatrices(this,e)},e.prototype.premultiply=function(e){return this.multiplyMatrices(e,this)},e.prototype.multiplyMatrices=function(e,t){var n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],s=n[6],u=n[1],h=n[4],c=n[7],d=n[2],l=n[5],p=n[8],f=i[0],_=i[3],v=i[6],m=i[1],g=i[4],y=i[7],E=i[2],T=i[5],x=i[8];return r[0]=a*f+o*m+s*E,r[3]=a*_+o*g+s*T,r[6]=a*v+o*y+s*x,r[1]=u*f+h*m+c*E,r[4]=u*_+h*g+c*T,r[7]=u*v+h*y+c*x,r[2]=d*f+l*m+p*E,r[5]=d*_+l*g+p*T,r[8]=d*v+l*y+p*x,this},e.prototype.transform=function(e,t,n,i,r,a,o){var s=this.elements,u=1,h=0;if(r%360){var c=r;u=Math.cos(c),h=Math.sin(c)}return s[0]=u*n,s[3]=-h*i,s[6]=e,s[1]=h*n,s[4]=u*i,s[7]=t,s[2]=0,s[5]=0,s[8]=1,(a||o)&&(s[6]-=a*s[0]+o*s[3],s[7]-=a*s[1]+o*s[4]),this},e.prototype.setFromMatrix4=function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},zen3d.Matrix3=e}(),function(){var c,d,l=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])};l.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},l.prototype.set=function(e,t,n,i,r,a,o,s,u,h,c,d,l,p,f,_){var v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=r,v[5]=a,v[9]=o,v[13]=s,v[2]=u,v[6]=h,v[10]=c,v[14]=d,v[3]=l,v[7]=p,v[11]=f,v[15]=_,this},l.prototype.copy=function(e){return this.elements.set(e.elements),this},l.prototype.makeTranslation=function(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this},l.prototype.multiply=function(e){return this.multiplyMatrices(this,e)},l.prototype.premultiply=function(e){return this.multiplyMatrices(e,this)},l.prototype.multiplyMatrices=function(e,t){var n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],u=n[12],h=n[1],c=n[5],d=n[9],l=n[13],p=n[2],f=n[6],_=n[10],v=n[14],m=n[3],g=n[7],y=n[11],E=n[15],T=i[0],x=i[4],M=i[8],w=i[12],S=i[1],z=i[5],A=i[9],b=i[13],L=i[2],P=i[6],R=i[10],C=i[14],N=i[3],I=i[7],D=i[11],F=i[15];return r[0]=a*T+o*S+s*L+u*N,r[4]=a*x+o*z+s*P+u*I,r[8]=a*M+o*A+s*R+u*D,r[12]=a*w+o*b+s*C+u*F,r[1]=h*T+c*S+d*L+l*N,r[5]=h*x+c*z+d*P+l*I,r[9]=h*M+c*A+d*R+l*D,r[13]=h*w+c*b+d*C+l*F,r[2]=p*T+f*S+_*L+v*N,r[6]=p*x+f*z+_*P+v*I,r[10]=p*M+f*A+_*R+v*D,r[14]=p*w+f*b+_*C+v*F,r[3]=m*T+g*S+y*L+E*N,r[7]=m*x+g*z+y*P+E*I,r[11]=m*M+g*A+y*R+E*D,r[15]=m*w+g*b+y*C+E*F,this},l.prototype.transpose=function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},l.prototype.inverse=function(){return this.getInverse(this)},l.prototype.getInverse=function(e){var t=this.elements,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],u=n[5],h=n[6],c=n[7],d=n[8],l=n[9],p=n[10],f=n[11],_=n[12],v=n[13],m=n[14],g=n[15],y=l*m*c-v*p*c+v*h*f-u*m*f-l*h*g+u*p*g,E=_*p*c-d*m*c-_*h*f+s*m*f+d*h*g-s*p*g,T=d*v*c-_*l*c+_*u*f-s*v*f-d*u*g+s*l*g,x=_*l*h-d*v*h-_*u*p+s*v*p+d*u*m-s*l*m,M=i*y+r*E+a*T+o*x;if(0===M)return console.warn("can\'t invert matrix, determinant is 0"),this.identity();var w=1/M;return t[0]=y*w,t[1]=(v*p*o-l*m*o-v*a*f+r*m*f+l*a*g-r*p*g)*w,t[2]=(u*m*o-v*h*o+v*a*c-r*m*c-u*a*g+r*h*g)*w,t[3]=(l*h*o-u*p*o-l*a*c+r*p*c+u*a*f-r*h*f)*w,t[4]=E*w,t[5]=(d*m*o-_*p*o+_*a*f-i*m*f-d*a*g+i*p*g)*w,t[6]=(_*h*o-s*m*o-_*a*c+i*m*c+s*a*g-i*h*g)*w,t[7]=(s*p*o-d*h*o+d*a*c-i*p*c-s*a*f+i*h*f)*w,t[8]=T*w,t[9]=(_*l*o-d*v*o-_*r*f+i*v*f+d*r*g-i*l*g)*w,t[10]=(s*v*o-_*u*o+_*r*c-i*v*c-s*r*g+i*u*g)*w,t[11]=(d*u*o-s*l*o-d*r*c+i*l*c+s*r*f-i*u*f)*w,t[12]=x*w,t[13]=(d*v*a-_*l*a+_*r*p-i*v*p-d*r*m+i*l*m)*w,t[14]=(_*u*a-s*v*a-_*r*h+i*v*h+s*r*m-i*u*m)*w,t[15]=(s*l*a-d*u*a+d*r*h-i*l*h-s*r*p+i*u*p)*w,this},l.prototype.transform=function(e,t,n){var i=n.toMatrix4(zen3d.helpMatrix).elements,r=this.elements;return r[0]=i[0]*t.x,r[1]=i[1]*t.y,r[2]=i[2]*t.z,r[3]=0,r[4]=i[4]*t.x,r[5]=i[5]*t.y,r[6]=i[6]*t.z,r[7]=0,r[8]=i[8]*t.x,r[9]=i[9]*t.y,r[10]=i[10]*t.z,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this},l.prototype.makeRotationFromQuaternion=function(e){var t=this.elements,n=e.x,i=e.y,r=e.z,a=e.w,o=n+n,s=i+i,u=r+r,h=n*o,c=n*s,d=n*u,l=i*s,p=i*u,f=r*u,_=a*o,v=a*s,m=a*u;return t[0]=1-(l+f),t[4]=c-m,t[8]=d+v,t[1]=c+m,t[5]=1-(h+f),t[9]=p-_,t[2]=d-v,t[6]=p+_,t[10]=1-(h+l),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},l.prototype.decompose=function(e,t,n){void 0===c&&(c=new zen3d.Vector3,d=new l);var i=this.elements,r=c.set(i[0],i[1],i[2]).getLength(),a=c.set(i[4],i[5],i[6]).getLength(),o=c.set(i[8],i[9],i[10]).getLength();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],d.elements.set(this.elements);var s=1/r,u=1/a,h=1/o;return d.elements[0]*=s,d.elements[1]*=s,d.elements[2]*=s,d.elements[4]*=u,d.elements[5]*=u,d.elements[6]*=u,d.elements[8]*=h,d.elements[9]*=h,d.elements[10]*=h,t.setFromRotationMatrix(d),n.x=r,n.y=a,n.z=o,this},l.prototype.determinant=function(){var e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],s=e[9],u=e[13],h=e[2],c=e[6],d=e[10],l=e[14];return e[3]*(+r*s*c-i*u*c-r*o*d+n*u*d+i*o*l-n*s*l)+e[7]*(+t*s*l-t*u*d+r*a*d-i*a*l+i*u*h-r*s*h)+e[11]*(+t*u*c-t*o*l-r*a*c+n*a*l+r*o*h-n*u*h)+e[15]*(-i*o*h-t*s*c+t*o*d+i*a*c-n*a*d+n*s*h)},l.prototype.fromArray=function(e,t){void 0===t&&(t=0);for(var n=0;n<16;n++)this.elements[n]=e[n+t];return this},l.prototype.getMaxScaleOnAxis=function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))},l.prototype.toArray=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e},zen3d.Matrix4=l,zen3d.helpMatrix=new l}(),function(){var n=function(e,t){this.x=e||0,this.y=t||0};n.prototype.lerpVectors=function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},n.prototype.set=function(e,t){return this.x=e||0,this.y=t||0,this},n.prototype.min=function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},n.prototype.max=function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},n.prototype.getLength=function(){return Math.sqrt(this.getLengthSquared())},n.prototype.getLengthSquared=function(){return this.x*this.x+this.y*this.y},n.prototype.normalize=function(e){e=e||1;var t=this.getLength();if(0!=t){var n=e/t;return this.x*=n,this.y*=n,this}},n.prototype.subtract=function(e,t){return t||(t=new n),t.set(this.x-e.x,this.y-e.y),t},n.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this},n.prototype.addVectors=function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},n.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},n.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this},n.prototype.distanceToSquared=function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},n.prototype.distanceTo=function(e){return Math.sqrt(this.distanceToSquared(e))},n.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},n.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this},n.prototype.clone=function(){return new n(this.x,this.y)},zen3d.Vector2=n}(),function(){var t,n=function(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0};n.prototype.lerpVectors=function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},n.prototype.set=function(e,t,n){return this.x=e||0,this.y=t||0,this.z=n||0,this},n.prototype.min=function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},n.prototype.max=function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},n.prototype.getLength=function(){return Math.sqrt(this.getLengthSquared())},n.prototype.getLengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.prototype.normalize=function(e){e=e||1;var t=this.getLength();if(0!=t){var n=e/t;return this.x*=n,this.y*=n,this.z*=n,this}},n.prototype.subtract=function(e,t){return t||(t=new n),t.set(this.x-e.x,this.y-e.y,this.z-e.z),t},n.prototype.multiply=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},n.prototype.crossVectors=function(e,t){var n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this},n.prototype.cross=function(e){var t=this.x,n=this.y,i=this.z;return this.x=n*e.z-i*e.y,this.y=i*e.x-t*e.z,this.z=t*e.y-n*e.x,this},n.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},n.prototype.applyQuaternion=function(e){var t=this.x,n=this.y,i=this.z,r=e._x,a=e._y,o=e._z,s=e._w,u=s*t+a*i-o*n,h=s*n+o*t-r*i,c=s*i+r*n-a*t,d=-r*t-a*n-o*i;return this.x=u*s+d*-r+h*-o-c*-a,this.y=h*s+d*-a+c*-r-u*-o,this.z=c*s+d*-o+u*-a-h*-r,this},n.prototype.applyMatrix4=function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12],this.y=r[1]*t+r[5]*n+r[9]*i+r[13],this.z=r[2]*t+r[6]*n+r[10]*i+r[14],this},n.prototype.applyMatrix3=function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this},n.prototype.transformDirection=function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()},n.prototype.setFromMatrixPosition=function(e){return this.setFromMatrixColumn(e,3)},n.prototype.setFromMatrixColumn=function(e,t){return this.fromArray(e.elements,4*t)},n.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},n.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},n.prototype.addVectors=function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},n.prototype.addScalar=function(e){return this.x+=e,this.y+=e,this.z+=e,this},n.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},n.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},n.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},n.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this.z*=e,this},n.prototype.distanceToSquared=function(e){var t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i},n.prototype.distanceTo=function(e){return Math.sqrt(this.distanceToSquared(e))},n.prototype.unproject=function(e){return void 0===t&&(t=new zen3d.Matrix4),t.multiplyMatrices(e.worldMatrix,t.getInverse(e.projectionMatrix)),this.applyProjection(t)},n.prototype.applyProjection=function(e){var t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this},n.prototype.equals=function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},n.prototype.clone=function(){return new n(this.x,this.y,this.z)},zen3d.Vector3=n}(),function(){var e=function(e,t,n,i){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1};e.prototype.lerpVectors=function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},e.prototype.set=function(e,t,n,i){return this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1,this},e.prototype.applyMatrix4=function(e){var t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this},e.prototype.equals=function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},e.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},e.prototype.multiply=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},e.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},zen3d.Vector4=e}(),function(){var n,i,e=function(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1};e.prototype.normalize=function(e){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},e.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},e.prototype.lerpQuaternions=function(e,t,n){var i=e._w,r=e._x,a=e._y,o=e._z,s=t._w,u=t._x,h=t._y,c=t._z,d=i*s+r*u+a*h+o*c;d<0&&(d=-d,s=-s,u=-u,h=-h,c=-c),this._w=i+n*(s-i),this._x=r+n*(u-r),this._y=a+n*(h-a),this._z=o+n*(c-o);var l=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);return this._w*=l,this._x*=l,this._y*=l,this._z*=l,this.onChangeCallback(),this},e.prototype.slerpQuaternions=function(e,t,n){var i=e._w,r=e._x,a=e._y,o=e._z,s=t._w,u=t._x,h=t._y,c=t._z,d=i*s+r*u+a*h+o*c;if(d<0&&(d=-d,s=-s,u=-u,h=-h,c=-c),d<.95){var l=Math.acos(d),p=1/Math.sin(l),f=Math.sin(l*(1-n))*p,_=Math.sin(l*n)*p;this._w=i*f+s*_,this._x=r*f+u*_,this._y=a*f+h*_,this._z=o*f+c*_}else{this._w=i+n*(s-i),this._x=r+n*(u-r),this._y=a+n*(h-a),this._z=o+n*(c-o);var v=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);this._w*=v,this._x*=v,this._y*=v,this._z*=v}return this.onChangeCallback(),this},Object.defineProperties(e.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),e.prototype.set=function(e,t,n,i){return this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1,this.onChangeCallback(),this},e.prototype.copy=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=void 0!==e.w?e.w:1,this.onChangeCallback(),this},e.prototype.setFromEuler=function(e,t){var n=Math.cos(e._x/2),i=Math.cos(e._y/2),r=Math.cos(e._z/2),a=Math.sin(e._x/2),o=Math.sin(e._y/2),s=Math.sin(e._z/2),u=e._order;return"XYZ"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"YXZ"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"ZXY"===u?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"ZYX"===u?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"YZX"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r-a*o*s):"XZY"===u&&(this._x=a*i*r-n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r+a*o*s),!1!==t&&this.onChangeCallback(),this},e.prototype.setFromRotationMatrix=function(e){var t,n=e.elements,i=n[0],r=n[4],a=n[8],o=n[1],s=n[5],u=n[9],h=n[2],c=n[6],d=n[10],l=i+s+d;return 0<l?(t=.5/Math.sqrt(l+1),this._w=.25/t,this._x=(c-u)*t,this._y=(a-h)*t,this._z=(o-r)*t):s<i&&d<i?(t=2*Math.sqrt(1+i-s-d),this._w=(c-u)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(a+h)/t):d<s?(t=2*Math.sqrt(1+s-i-d),this._w=(a-h)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(u+c)/t):(t=2*Math.sqrt(1+d-i-s),this._w=(o-r)/t,this._x=(a+h)/t,this._y=(u+c)/t,this._z=.25*t),this.onChangeCallback(),this},e.prototype.setFromUnitVectors=(i=new zen3d.Vector3,function(e,t){return void 0===i&&(i=new zen3d.Vector3),(n=e.dot(t)+1)<1e-6?(n=0,Math.abs(e.x)>Math.abs(e.z)?i.set(-e.y,e.x,0):i.set(0,-e.z,e.y)):i.crossVectors(e,t),this._x=i.x,this._y=i.y,this._z=i.z,this._w=n,this.normalize()}),e.prototype.premultiply=function(e){return this.multiplyQuaternions(e,this)},e.prototype.multiplyQuaternions=function(e,t){var n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,u=t._z,h=t._w;return this._x=n*h+a*o+i*u-r*s,this._y=i*h+a*s+r*o-n*u,this._z=r*h+a*u+n*s-i*o,this._w=a*h-n*o-i*s-r*u,this.onChangeCallback(),this},e.prototype.toMatrix4=function(e){e||(e=new zen3d.Matrix4);var t=e.elements,n=2*this._x*this._y,i=2*this._x*this._z,r=2*this._x*this._w,a=2*this._y*this._z,o=2*this._y*this._w,s=2*this._z*this._w,u=this._x*this._x,h=this._y*this._y,c=this._z*this._z,d=this._w*this._w;return t[0]=u-h-c+d,t[4]=n-s,t[8]=i+o,t[12]=0,t[1]=n+s,t[5]=-u+h-c+d,t[9]=a-r,t[13]=0,t[2]=i-o,t[6]=a+r,t[10]=-u-h+c+d,t[14]=0,t[3]=0,t[7]=0,t[11]=0,t[15]=1,e},e.prototype.setFromAxisAngle=function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},e.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},e.prototype.onChange=function(e){return this.onChangeCallback=e,this},e.prototype.onChangeCallback=function(){},zen3d.Quaternion=e}(),function(){var e=function(e,t){this.min=void 0!==e?e:new zen3d.Vector2(1/0,1/0),this.max=void 0!==t?t:new zen3d.Vector2(-1/0,-1/0)};e.prototype.set=function(e,t,n,i){this.min.set(e,t),this.max.set(n,i)},e.prototype.copy=function(e){return this.min.copy(e.min),this.max.copy(e.max),this},zen3d.Box2=e}(),function(){var t,e=function(e,t){this.min=void 0!==e?e:new zen3d.Vector3(1/0,1/0,1/0),this.max=void 0!==t?t:new zen3d.Vector3(-1/0,-1/0,-1/0)};e.prototype.set=function(e,t){this.min.copy(e),this.max.copy(t)},e.prototype.setFromPoints=function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this},e.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},e.prototype.expandByPoint=function(e){return this.min.min(e),this.max.max(e),this},e.prototype.expandByScalar=function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},e.prototype.setFromArray=function(e,t){for(var n=1/0,i=1/0,r=1/0,a=-1/0,o=-1/0,s=-1/0,u=void 0!==t?t:3,h=0,c=e.length;h<c;h+=u){var d=e[h],l=e[h+1],p=e[h+2];d<n&&(n=d),l<i&&(i=l),p<r&&(r=p),a<d&&(a=d),o<l&&(o=l),s<p&&(s=p)}return this.min.set(n,i,r),this.max.set(a,o,s),this},e.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},e.prototype.equals=function(e){return e.min.equals(this.min)&&e.max.equals(this.max)},e.prototype.getCenter=function(e){var t=e||new zen3d.Vector3;return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},e.prototype.applyMatrix4=(t=[new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3,new zen3d.Vector3],function(e){return this.isEmpty()||(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t)),this}),e.prototype.copy=function(e){return this.min.copy(e.min),this.max.copy(e.max),this},zen3d.Box3=e}(),function(){var c,d,e=function(e,t){this.center=void 0!==e?e:new zen3d.Vector3,this.radius=void 0!==t?t:0};e.prototype.set=function(e,t){return this.center.copy(e),this.radius=t,this},e.prototype.setFromArray=(c=new zen3d.Box3,d=new zen3d.Vector3,function(e,t){var n=void 0!==t?t:3,i=this.center;c.setFromArray(e,n).getCenter(i);for(var r=0,a=0,o=e.length;a<o;a+=n){var s=e[a],u=e[a+1],h=e[a+2];d.set(s,u,h),r=Math.max(r,i.distanceToSquared(d))}return this.radius=Math.sqrt(r),this}),e.prototype.applyMatrix4=function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},e.prototype.getBoundingBox=function(e){var t=e||new zen3d.Box3;return t.set(this.center,this.center),t.expandByScalar(this.radius),t},e.prototype.clone=function(){return(new e).copy(this)},e.prototype.copy=function(e){return this.center.copy(e.center),this.radius=e.radius,this},zen3d.Sphere=e}(),function(){var a,o,e=function(e,t){this.normal=void 0!==e?e:new zen3d.Vector3(1,0,0),this.constant=void 0!==t?t:0};e.prototype.set=function(e,t){return this.normal.copy(e),this.constant=t,this},e.prototype.setComponents=function(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this},e.prototype.normalize=function(){var e=1/this.normal.getLength();return this.normal.multiplyScalar(e),this.constant*=e,this},e.prototype.distanceToPoint=function(e){return this.normal.dot(e)+this.constant},e.prototype.coplanarPoint=function(e){return(e||new Vector3).copy(this.normal).multiplyScalar(-this.constant)},e.prototype.copy=function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},e.prototype.applyMatrix4=(a=new zen3d.Vector3,o=new zen3d.Matrix3,function(e,t){var n=t||o.setFromMatrix4(e).inverse().transpose(),i=this.coplanarPoint(a).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}),zen3d.Plane=e}(),function(){var o,s,e=function(e,t,n,i,r,a){this.planes=[void 0!==e?e:new zen3d.Plane,void 0!==t?t:new zen3d.Plane,void 0!==n?n:new zen3d.Plane,void 0!==i?i:new zen3d.Plane,void 0!==r?r:new zen3d.Plane,void 0!==a?a:new zen3d.Plane]};e.prototype.set=function(e,t,n,i,r,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},e.prototype.setFromMatrix=function(e){var t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],u=n[5],h=n[6],c=n[7],d=n[8],l=n[9],p=n[10],f=n[11],_=n[12],v=n[13],m=n[14],g=n[15];return t[0].setComponents(o-i,c-s,f-d,g-_).normalize(),t[1].setComponents(o+i,c+s,f+d,g+_).normalize(),t[2].setComponents(o+r,c+u,f+l,g+v).normalize(),t[3].setComponents(o-r,c-u,f-l,g-v).normalize(),t[4].setComponents(o-a,c-h,f-p,g-m).normalize(),t[5].setComponents(o+a,c+h,f+p,g+m).normalize(),this},e.prototype.intersectsSphere=function(e){for(var t=this.planes,n=e.center,i=-e.radius,r=0;r<6;r++){if(t[r].distanceToPoint(n)<i)return!1}return!0},e.prototype.intersectsBox=(o=new zen3d.Vector3,s=new zen3d.Vector3,function(e){for(var t=this.planes,n=0;n<6;n++){var i=t[n];o.x=0<i.normal.x?e.min.x:e.max.x,s.x=0<i.normal.x?e.max.x:e.min.x,o.y=0<i.normal.y?e.min.y:e.max.y,s.y=0<i.normal.y?e.max.y:e.min.y,o.z=0<i.normal.z?e.min.z:e.max.z,s.z=0<i.normal.z?e.max.z:e.min.z;var r=i.distanceToPoint(o),a=i.distanceToPoint(s);if(r<0&&a<0)return!1}return!0}),zen3d.Frustum=e}(),function(){var e=function(e,t,n){return this.r=0,this.g=0,void(this.b=0)===t&&void 0===n?this.setHex(e):this.setRGB(e,t,n)};e.prototype.lerpColors=function(e,t,n){this.r=n*(t.r-e.r)+e.r,this.g=n*(t.g-e.g)+e.g,this.b=n*(t.b-e.b)+e.b,this.r=this.r,this.g=this.g,this.b=this.b},e.prototype.copy=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},e.prototype.setHex=function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},e.prototype.setRGB=function(e,t,n){return this.r=e,this.g=t,this.b=n,this},e.prototype.setHSL=function(){function o(e,t,n){return n<0&&(n+=1),1<n&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}return function(e,t,n){var i;if(e=(e%(i=1)+i)%i,t=Math.max(0,Math.min(1,t)),n=Math.max(0,Math.min(1,n)),0===t)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=o(a,r,e+1/3),this.g=o(a,r,e),this.b=o(a,r,e-1/3)}return this}}(),e.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},zen3d.Color3=e}(),function(){var u,c,d,l,p,e=function(e,t){this.origin=void 0!==e?e:new zen3d.Vector3,this.direction=void 0!==t?t:new zen3d.Vector3};e.prototype.set=function(e,t){this.origin.copy(e),this.direction.copy(t)},e.prototype.at=function(e,t){return(t||new zen3d.Vector3).copy(this.direction).multiplyScalar(e).add(this.origin)},e.prototype.intersectsSphere=(u=new zen3d.Vector3,function(e,t){u.subVectors(e.center,this.origin);var n=u.dot(this.direction),i=u.dot(u)-n*n,r=e.radius*e.radius;if(r<i)return null;var a=Math.sqrt(r-i),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)}),e.prototype.intersectsBox=function(e,t){var n,i,r,a,o,s,u=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,d=this.origin;return 0<=u?(n=(e.min.x-d.x)*u,i=(e.max.x-d.x)*u):(n=(e.max.x-d.x)*u,i=(e.min.x-d.x)*u),0<=h?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),a<n||i<r?null:((n<r||n!=n)&&(n=r),(a<i||i!=i)&&(i=a),0<=c?(o=(e.min.z-d.z)*c,s=(e.max.z-d.z)*c):(o=(e.max.z-d.z)*c,s=(e.min.z-d.z)*c),s<n||i<o?null:((n<o||n!=n)&&(n=o),(s<i||i!=i)&&(i=s),i<0?null:this.at(0<=n?n:i,t)))},e.prototype.intersectTriangle=(c=new zen3d.Vector3,d=new zen3d.Vector3,l=new zen3d.Vector3,p=new zen3d.Vector3,function(e,t,n,i,r){d.subVectors(t,e),l.subVectors(n,e),p.crossVectors(d,l);var a,o=this.direction.dot(p);if(0<o){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}c.subVectors(this.origin,e);var s=a*this.direction.dot(l.crossVectors(c,l));if(s<0)return null;var u=a*this.direction.dot(d.cross(c));if(u<0)return null;if(o<s+u)return null;var h=-a*c.dot(p);return h<0?null:this.at(h/o,r)}),e.prototype.copy=function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},e.prototype.applyMatrix4=function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this.direction.normalize(),this},zen3d.Ray=e}(),function(){function a(e,t,n){this.a=void 0!==e?e:new zen3d.Vector3,this.b=void 0!==t?t:new zen3d.Vector3,this.c=void 0!==n?n:new zen3d.Vector3}var o,_,v,m,s;a.prototype.set=function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},a.normal=(o=new zen3d.Vector3,function(e,t,n,i){var r=i||new zen3d.Vector3;r.subVectors(n,t),o.subVectors(e,t),r.cross(o);var a=r.getLengthSquared();return 0<a?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}),a.barycoordFromPoint=(_=new zen3d.Vector3,v=new zen3d.Vector3,m=new zen3d.Vector3,function(e,t,n,i,r){_.subVectors(i,t),v.subVectors(n,t),m.subVectors(e,t);var a=_.dot(_),o=_.dot(v),s=_.dot(m),u=v.dot(v),h=v.dot(m),c=a*u-o*o,d=r||new zen3d.Vector3;if(0===c)return d.set(-2,-1,-1);var l=1/c,p=(u*s-o*h)*l,f=(a*h-o*s)*l;return d.set(1-p-f,f,p)}),a.containsPoint=(s=new zen3d.Vector3,function(e,t,n,i){var r=a.barycoordFromPoint(e,t,n,i,s);return 0<=r.x&&0<=r.y&&r.x+r.y<=1}),zen3d.Triangle=a}(),function(){var n,i,r,a,e=function(e,t){this.posPoints=void 0,this.ctrlPoints=void 0,this.segCount=0,this.set(e,t)};e.prototype.set=function(e,t){this.posPoints=e,this.ctrlPoints=t,e.length!==t.length&&console.warn("Curve: posPoints and ctrlPoints\'s length not equal!"),this.segCount=e.length-1},e.prototype.calc=(n=new zen3d.Vector2,i=new zen3d.Vector2,r=new zen3d.Vector2,a=new zen3d.Vector2,function(e){for(var t=0;t<this.segCount;t++)if(e>=this.posPoints[t].x&&e<=this.posPoints[t+1].x){n.copy(this.posPoints[t]),r.copy(this.posPoints[t+1]),i.copy(this.ctrlPoints[t]),a.copy(this.ctrlPoints[t+1]);break}return n||n.copy(this.posPoints[this.posPoints.length-1]),i||i.copy(this.ctrlPoints[this.ctrlPoints.length-1]),r.copy(r||n),a.copy(a||i),e=(e-n.x)/(r.x-n.x),this._cubic_bezier(n.y,i.y,a.y,r.y,e)}),e.prototype.averageXSampler=function(e){e<2&&console.warn("Curve: sampler num less than 2!");for(var t=[],n=this.posPoints[0].x,i=this.posPoints[this.posPoints.length-1].x,r=(i-n)/(e-1),a=0,o=0;o<e;o++)a=o===e-1?i:n+o*r,t.push(a,this.calc(a));return t},e.prototype._cubic_bezier=function(e,t,n,i,r){return e=this._mix(e,t,r),t=this._mix(t,n,r),n=this._mix(n,i,r),e=this._mix(e,t,r),t=this._mix(t,n,r),e=this._mix(e,t,r)},e.prototype._mix=function(e,t,n){return e*(1-n)+t*n},zen3d.Curve=e}(),function(){var e=function(){this.eventMap={}};e.prototype.addEventListener=function(e,t,n){var i=this.eventMap[e];i||(i=this.eventMap[e]=[]),i.push({listener:t,thisObject:n||this})},e.prototype.removeEventListener=function(e,t,n){var i=this.eventMap[e];if(i)for(var r=0,a=i.length;r<a;r++){var o=i[r];if(o.listener==t&&o.thisObject==(n||this)){i.splice(r,1);break}}},e.prototype.dispatchEvent=function(e){(e.target=this).notifyListener(e)},e.prototype.notifyListener=function(e){var t=this.eventMap[e.type];if(t)for(var n=0,i=t.length;n<i;n++){var r=t[n];r.listener.call(r.thisObject,e)}},zen3d.EventDispatcher=e}(),function(){var e=function(e,t,n,i){this.ray=new zen3d.Ray(e,t),this.near=n||0,this.far=i||1/0};function a(e,t){return e.distance-t.distance}function s(e,t,n,i){if(e.raycast(t,n),!0===i)for(var r=e.children,a=0,o=r.length;a<o;a++)s(r[a],t,n,!0)}e.prototype.set=function(e,t){this.ray.set(e,t)},e.prototype.setFromCamera=function(e,t){this.ray.origin.setFromMatrixPosition(t.worldMatrix),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize()},e.prototype.intersectObject=function(e,t){var n=[];return s(e,this,n,t),n.sort(a),n},e.prototype.intersectObjects=function(e,t){var n=[];if(!1===Array.isArray(e))return console.warn("Raycaster.intersectObjects: objects is not an Array."),n;for(var i=0,r=e.length;i<r;i++)s(e[i],this,n,t);return n.sort(a),n},zen3d.Raycaster=e}(),function(){var t=function(e,t){var n=["","WEBKIT_","MOZ_"],i=null;for(var r in n)if(i=e.getExtension(n[r]+t))break;return i};zen3d.WebGLCapabilities=function(e){this.version=parseFloat(/^WebGL\\ ([0-9])/.exec(e.getParameter(e.VERSION))[1]),this.precision="highp",this.maxPrecision=function(e,t){if("highp"===t){if(0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision)return"highp";t="mediump"}return"mediump"===t&&0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision?"mediump":"lowp"}(e,this.precision),this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxVertexTextures=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxCubemapSize=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),this.maxVertexUniformVectors=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),this.floatTextures=!!t(e,"OES_texture_float"),this.anisotropyExt=t(e,"EXT_texture_filter_anisotropic"),this.shaderTextureLOD=t(e,"EXT_shader_texture_lod"),this.maxAnisotropy=null!==this.anisotropyExt?e.getParameter(this.anisotropyExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0;t(e,"OES_standard_derivatives"),t(e,"GL_OES_standard_derivatives")}}(),function(){var i=zen3d.BLEND_TYPE,n=zen3d.CULL_FACE_TYPE;function r(e,t,n,i){var r=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var o=0;o<i;o++)e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,r);return a}var e=function(e,t){this.gl=e,this.capabilities=t,this.states={},this.currentBlending=null,this.currentPremultipliedAlpha=null,this.currentCullFace=null,this.currentViewport=new zen3d.Vector4,this.currentColorMask=null,this.currentClearColor=new zen3d.Vector4,this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBuffers={},this.emptyTextures={},this.emptyTextures[e.TEXTURE_2D]=r(e,e.TEXTURE_2D,e.TEXTURE_2D,1),this.emptyTextures[e.TEXTURE_CUBE_MAP]=r(e,e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),this.currentFlipSided=!1,this.currentDepthMask=!0,this.currentLineWidth=null,this.currentProgram=null,this.currentStencilMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilClear=null,this.currentRenderTarget=null};e.prototype.setBlend=function(e,t){var n=this.gl;e!==i.NONE?this.enable(n.BLEND):this.disable(n.BLEND),e===this.currentBlending&&t===this.currentPremultipliedAlpha||(e===i.NORMAL&&(t?(n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)):(n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA))),e===i.ADD&&(t?(n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.ONE,n.ONE,n.ONE,n.ONE)):(n.blendEquation(n.FUNC_ADD),n.blendFunc(n.SRC_ALPHA,n.ONE))),this.currentBlending=e,this.currentPremultipliedAlpha=t)},e.prototype.setFlipSided=function(e){var t=this.gl;this.currentFlipSided!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e)},e.prototype.setCullFace=function(e){var t=this.gl;e!==n.NONE?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===n.BACK?t.cullFace(t.BACK):e===n.FRONT?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e},e.prototype.viewport=function(e,t,n,i){var r=this.currentViewport;r.x===e&&r.y===t&&r.z===n&&r.w===i||(this.gl.viewport(e,t,n,i),r.set(e,t,n,i))},e.prototype.colorMask=function(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)},e.prototype.clearColor=function(e,t,n,i){var r=this.currentClearColor;r.x===e&&r.y===t&&r.z===n&&r.w===i||(this.gl.clearColor(e,t,n,i),r.set(e,t,n,i))},e.prototype.activeTexture=function(e){var t=this.gl;void 0===e&&(e=t.TEXTURE0+this.capabilities.maxTextures-1),this.currentTextureSlot!==e&&(t.activeTexture(e),this.currentTextureSlot=e)},e.prototype.bindTexture=function(e,t){var n=this.gl;null===this.currentTextureSlot&&this.activeTexture();var i=this.currentBoundTextures[this.currentTextureSlot];void 0===i&&(i={type:void 0,texture:void 0},this.currentBoundTextures[this.currentTextureSlot]=i),i.type===e&&i.texture===t||(n.bindTexture(e,t||this.emptyTextures[e]),i.type=e,i.texture=t)},e.prototype.bindBuffer=function(e,t){var n=this.gl;this.currentBoundBuffers[e]!==t&&(n.bindBuffer(e,t),this.currentBoundBuffers[e]=t)},e.prototype.enable=function(e){!0!==this.states[e]&&(this.gl.enable(e),this.states[e]=!0)},e.prototype.disable=function(e){!1!==this.states[e]&&(this.gl.disable(e),this.states[e]=!1)},e.prototype.depthMask=function(e){e!==this.currentDepthMask&&(this.gl.depthMask(e),this.currentDepthMask=e)},e.prototype.setLineWidth=function(e){e!==this.currentLineWidth&&(1<=this.capabilities.version&&this.gl.lineWidth(e),this.currentLineWidth=e)},e.prototype.setProgram=function(e){this.currentProgram!==e&&(this.gl.useProgram(e.id),this.currentProgram=e)},e.prototype.stencilMask=function(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)},e.prototype.stencilFunc=function(e,t,n){this.currentStencilFunc===e&&this.currentStencilRef===t&&this.currentStencilFuncMask===n||(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)},e.prototype.stencilOp=function(e,t,n){this.currentStencilFail===e&&this.currentStencilZFail===t&&this.currentStencilZPass===n||(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)},e.prototype.clearStencil=function(e){this.currentStencilClear!==e&&(this.gl.clearStencil(e),this.currentStencilClear=e)},zen3d.WebGLState=e}(),function(){var e=function(){this.properties={}};e.prototype.get=function(e){var t=e.uuid,n=this.properties[t];return void 0===n&&(n={},this.properties[t]=n),n},e.prototype.delete=function(e){delete this.properties[e.uuid]},e.prototype.clear=function(){this.properties={}},zen3d.WebGLProperties=e}(),function(){var f=zen3d.WEBGL_TEXTURE_FILTER,_=zen3d.WEBGL_TEXTURE_WRAP,v=zen3d.isWeb;function a(e){return e===f.NEAREST||e===f.NEAREST_MIPMAP_LINEAR||e===f.NEAREST_MIPMAP_NEAREST?f.NEAREST:f.LINEAR}var t=zen3d.isPowerOfTwo,m=zen3d.nearestPowerOfTwo;function g(e){return t(e.width)&&t(e.height)}function y(e,t){if(e.width>t||e.height>t){if(!v)return console.warn("image is too big ("+e.width+"x"+e.height+"). max size is "+t+"x"+t,e),e;var n=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(e.width*n),i.height=Math.floor(e.height*n),i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height,e),i}return e}var e=function(e,t,n,i){this.gl=e,this.state=t,this.properties=n,this.capabilities=i};e.prototype.setTexture2D=function(e,t){var n,i=this.gl,r=this.state,a=this.properties.get(e);if(0<e.version&&a.__version!==e.version){void 0===a.__webglTexture&&(e.addEventListener("dispose",this.onTextureDispose,this),a.__webglTexture=i.createTexture()),r.activeTexture(i.TEXTURE0+t),r.bindTexture(i.TEXTURE_2D,a.__webglTexture);var o=y(e.image,this.capabilities.maxTextureSize);((n=e).wrapS!==_.CLAMP_TO_EDGE||n.wrapT!==_.CLAMP_TO_EDGE||n.minFilter!==f.NEAREST&&n.minFilter!==f.LINEAR)&&!1===g(o)&&(o=function(e){if(v&&(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement)){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.width=m(e.width),t.height=m(e.height),t.getContext("2d").drawImage(e,0,0,t.width,t.height),console.warn("image is not power of two ("+e.width+"x"+e.height+"). Resized to "+t.width+"x"+t.height,e),t}return e}(o));var s=g(o);this.setTextureParameters(e,s);var u,h=e.mipmaps,c=e.pixelFormat,d=e.pixelType;if(e.isDataTexture)if(0<h.length&&s){for(var l=0,p=h.length;l<p;l++)u=h[l],i.texImage2D(i.TEXTURE_2D,l,c,u.width,u.height,e.border,c,d,u.data);e.generateMipmaps=!1}else i.texImage2D(i.TEXTURE_2D,0,c,o.width,o.height,e.border,c,d,o.data);else if(0<h.length&&s){for(l=0,p=h.length;l<p;l++)u=h[l],i.texImage2D(i.TEXTURE_2D,l,c,c,d,u);e.generateMipmaps=!1}else i.texImage2D(i.TEXTURE_2D,0,c,c,d,o);return e.generateMipmaps&&s&&i.generateMipmap(i.TEXTURE_2D),void(a.__version=e.version)}r.activeTexture(i.TEXTURE0+t),r.bindTexture(i.TEXTURE_2D,a.__webglTexture)},e.prototype.setTextureCube=function(e,t){var n=this.gl,i=this.state,r=this.properties.get(e);if(0<e.version&&r.__version!==e.version){void 0===r.__webglTexture&&(e.addEventListener("dispose",this.onTextureDispose,this),r.__webglTexture=n.createTexture()),i.activeTexture(n.TEXTURE0+t),i.bindTexture(n.TEXTURE_CUBE_MAP,r.__webglTexture);for(var a=[],o=0;o<6;o++)a[o]=y(e.images[o],this.capabilities.maxCubemapSize);var s=g(a[0]);this.setTextureParameters(e,s);var u=e.pixelFormat,h=e.pixelType;for(o=0;o<6;o++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,u,u,h,a[o]);return e.generateMipmaps&&s&&n.generateMipmap(n.TEXTURE_CUBE_MAP),void(r.__version=e.version)}i.activeTexture(n.TEXTURE0+t),i.bindTexture(n.TEXTURE_CUBE_MAP,r.__webglTexture)},e.prototype.setTextureParameters=function(e,t){var n=this.gl,i=e.textureType;t?(n.texParameteri(i,n.TEXTURE_WRAP_S,e.wrapS),n.texParameteri(i,n.TEXTURE_WRAP_T,e.wrapT),n.texParameteri(i,n.TEXTURE_MAG_FILTER,e.magFilter),n.texParameteri(i,n.TEXTURE_MIN_FILTER,e.minFilter)):(n.texParameteri(i,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(i,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),e.wrapS===n.CLAMP_TO_EDGE&&e.wrapT===n.CLAMP_TO_EDGE||console.warn("Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to zen3d.TEXTURE_WRAP.CLAMP_TO_EDGE.",e),n.texParameteri(i,n.TEXTURE_MAG_FILTER,a(e.magFilter)),n.texParameteri(i,n.TEXTURE_MIN_FILTER,a(e.minFilter)),(e.minFilter!==n.NEAREST&&e.minFilter!==n.LINEAR||e.magFilter!==n.NEAREST&&e.magFilter!==n.LINEAR)&&console.warn("Texture is not power of two. Texture.minFilter and Texture.magFilter should be set to zen3d.TEXTURE_FILTER.NEAREST or zen3d.TEXTURE_FILTER.LINEAR.",e));var r=this.capabilities.anisotropyExt;r&&1<e.anisotropy&&n.texParameterf(i,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(e.anisotropy,this.capabilities.maxAnisotropy))},e.prototype.setRenderTarget2D=function(e){var t=this.gl,n=this.state,i=this.properties.get(e),r=this.properties.get(e.texture);if(void 0!==r.__webglTexture&&void 0!==i.__webglFramebuffer)t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer);else{e.addEventListener("dispose",this.onRenderTargetDispose,this),r.__webglTexture=t.createTexture(),i.__webglFramebuffer=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer),n.bindTexture(t.TEXTURE_2D,r.__webglTexture);var a=g(e);this.setTextureParameters(e.texture,a);var o=e.texture.pixelFormat,s=e.texture.pixelType;if(t.texImage2D(t.TEXTURE_2D,0,o,e.width,e.height,0,o,s,null),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.__webglTexture,0),e.texture.generateMipmaps&&a&&t.generateMipmap(t.TEXTURE_2D),n.bindTexture(t.TEXTURE_2D,null),e.depthBuffer){i.__webglDepthbuffer=t.createRenderbuffer();var u=i.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,u),e.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,u)):(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,u)),t.bindRenderbuffer(t.RENDERBUFFER,null)}}},e.prototype.setRenderTargetCube=function(e){var t=this.gl,n=this.state,i=this.properties.get(e),r=this.properties.get(e.texture);if(void 0!==r.__webglTexture&&void 0!==i.__webglFramebuffer)t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,r.__webglTexture,0);else{e.addEventListener("dispose",this.onRenderTargetDispose,this),r.__webglTexture=t.createTexture(),i.__webglFramebuffer=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer),n.bindTexture(t.TEXTURE_CUBE_MAP,r.__webglTexture);var a=g(e);this.setTextureParameters(e.texture,a);for(var o=e.texture.pixelFormat,s=e.texture.pixelType,u=0;u<6;u++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,o,e.width,e.height,0,o,s,null);if(t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,r.__webglTexture,0),e.texture.generateMipmaps&&a&&t.generateMipmap(t.TEXTURE_CUBE_MAP),n.bindTexture(t.TEXTURE_CUBE_MAP,null),e.depthBuffer){i.__webglDepthbuffer=t.createRenderbuffer();var h=i.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,h),e.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,h)):(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,h)),t.bindRenderbuffer(t.RENDERBUFFER,null)}}},e.prototype.updateRenderTargetMipmap=function(e){var t=this.gl,n=this.state,i=e.texture;if(i.generateMipmaps&&g(e)&&i.minFilter!==t.NEAREST&&i.minFilter!==t.LINEAR){var r=i.textureType,a=this.properties.get(i).__webglTexture;n.bindTexture(r,a),t.generateMipmap(r),n.bindTexture(r,null)}},e.prototype.onTextureDispose=function(e){var t=this.gl,n=e.target,i=this.properties.get(n);n.removeEventListener("dispose",this.onTextureDispose,this),i.__webglTexture&&t.deleteTexture(i.__webglTexture),this.properties.delete(n)},e.prototype.onRenderTargetDispose=function(e){var t=this.gl,n=e.target,i=this.properties.get(n);n.removeEventListener("dispose",this.onRenderTargetDispose,this),i.__webglTexture&&t.deleteTexture(textureProperties.__webglTexture),i.__webglFramebuffer&&t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),this.properties.delete(n)},e.prototype.setRenderTarget=function(e){var t=this.gl,n=this.state;if(e.texture){var i=void 0!==e.activeCubeFace;if(n.currentRenderTarget!==e)i?this.setRenderTargetCube(e):this.setRenderTarget2D(e),n.currentRenderTarget=e;else if(i){var r=this.properties.get(e.texture);t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,r.__webglTexture,0)}}else n.currentRenderTarget===e||(t.bindFramebuffer(t.FRAMEBUFFER,null),n.currentRenderTarget=e)},zen3d.WebGLTexture=e}(),function(){function a(e,t,n,i){n.isInterleavedBufferAttribute&&(n=n.data);var r,a,o,s,u,h,c=t.get(n);void 0===c.buffer?function(e,t,n,i){var r=n.array,a=n.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW,o=e.createBuffer();e.bindBuffer(i,o),e.bufferData(i,r,a);var s=e.FLOAT;r instanceof Float32Array?s=e.FLOAT:r instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?s=e.UNSIGNED_SHORT:r instanceof Int16Array?s=e.SHORT:r instanceof Uint32Array?s=e.UNSIGNED_INT:r instanceof Int32Array?s=e.INT:r instanceof Int8Array?s=e.BYTE:r instanceof Uint8Array&&(s=e.UNSIGNED_BYTE),t.buffer=o,t.type=s,t.bytesPerElement=r.BYTES_PER_ELEMENT,t.version=n.version}(e,c,n,i):c.version<n.version&&(r=e,a=c.buffer,s=i,u=(o=n).array,h=o.updateRange,r.bindBuffer(s,a),!1===o.dynamic?r.bufferData(s,u,r.STATIC_DRAW):-1===h.count?r.bufferSubData(s,0,u):0===h.count?console.error("updateBuffer: dynamic BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(r.bufferSubData(s,h.offset*u.BYTES_PER_ELEMENT,u.subarray(h.offset,h.offset+h.count)),h.count=-1),c.version=n.version)}function r(e,t,n){n.isInterleavedBufferAttribute&&(n=n.data);var i=t.get(n);i.buffer&&e.deleteBuffer(i.buffer),buffers.delete(n)}var e=function(e,t,n,i){this.gl=e,this.state=t,this.properties=n,this.capabilities=i};e.prototype.setGeometry=function(e){var t=this.gl,n=(this.state,this.properties),i=this.properties.get(e);for(var r in i.created||(e.addEventListener("dispose",this.onGeometryDispose2,this),i.created=!0),null!==e.index&&a(t,n,e.index,t.ELEMENT_ARRAY_BUFFER),e.attributes)a(t,n,e.attributes[r],t.ARRAY_BUFFER)},e.prototype.onGeometryDispose=function(e){var t=this.gl,n=e.target;this.properties.get(n);for(var i in n.removeEventListener("dispose",this.onGeometryDispose,this),null!==n.index&&r(t,properties,n.index),n.attributes)r(t,properties,n.attributes[i]);this.properties.delete(n)},zen3d.WebGLGeometry=e}(),function(){var t=zen3d.WEBGL_UNIFORM_TYPE,e=function(e,t,n){this.gl=e,this.name=n.name,this.type=n.type,this.size=n.size,this.location=e.getUniformLocation(t,this.name),this.setValue=void 0,this.set=void 0,this._generateSetValue()};e.prototype._generateSetValue=function(){var r=this.gl,e=this.type,a=this.location;switch(e){case t.FLOAT:this.setValue=this.set=function(e){r.uniform1f(a,e)};break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.BOOL:case t.INT:this.setValue=this.set=function(e){r.uniform1i(a,e)};break;case t.FLOAT_VEC2:this.setValue=function(e,t){r.uniform2f(a,e,t)},this.set=function(e){r.uniform2fv(a,e)};break;case t.BOOL_VEC2:case t.INT_VEC2:this.setValue=function(e,t){r.uniform2i(a,e,t)},this.set=function(e){r.uniform2iv(a,e)};break;case t.FLOAT_VEC3:this.setValue=function(e,t,n){r.uniform3f(a,e,t,n)},this.set=function(e){r.uniform3fv(a,e)};break;case t.BOOL_VEC3:case t.INT_VEC3:this.setValue=function(e,t,n){r.uniform3i(a,e,t,n)},this.set=function(e){r.uniform3iv(a,e)};break;case t.FLOAT_VEC4:this.setValue=function(e,t,n,i){r.uniform4f(a,e,t,n,i)},this.set=function(e){r.uniform4fv(a,e)};break;case t.BOOL_VEC4:case t.INT_VEC4:this.setValue=function(e,t,n,i){r.uniform4i(a,e,t,n,i)},this.set=function(e){r.uniform4iv(a,e)};break;case t.FLOAT_MAT2:this.setValue=this.set=function(e){r.uniformMatrix2fv(a,!1,e)};break;case t.FLOAT_MAT3:this.setValue=this.set=function(e){r.uniformMatrix3fv(a,!1,e)};break;case t.FLOAT_MAT4:this.setValue=this.set=function(e){r.uniformMatrix4fv(a,!1,e)}}},zen3d.WebGLUniform=e}(),function(){var t=zen3d.WEBGL_ATTRIBUTE_TYPE,e=function(e,t,n){this.gl=e,this.name=n.name,this.type=n.type,this.size=n.size,this.location=e.getAttribLocation(t,this.name),this.count=0,this.initCount(e),this.format=e.FLOAT,this.initFormat(e)};e.prototype.initCount=function(e){switch(this.type){case t.FLOAT:case t.BYTE:case t.UNSIGNED_BYTE:case t.UNSIGNED_SHORT:this.count=1;break;case t.FLOAT_VEC2:this.count=2;break;case t.FLOAT_VEC3:this.count=3;break;case t.FLOAT_VEC4:this.count=4}},e.prototype.initFormat=function(e){switch(this.type){case t.FLOAT:case t.FLOAT_VEC2:case t.FLOAT_VEC3:case t.FLOAT_VEC4:this.format=e.FLOAT;break;case t.UNSIGNED_BYTE:this.format=e.UNSIGNED_BYTE;break;case t.UNSIGNED_SHORT:this.format=e.UNSIGNED_SHORT;break;case t.BYTE:this.format=e.BYTE}},zen3d.WebGLAttribute=e}(),function(){function h(e,t,n){var i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)||(console.log("shader not compiled!"),console.log(e.getShaderInfoLog(i))),i}var e=function(e,t,n){this.uuid=zen3d.generateUUID(),this.vshaderSource=t,this.fshaderSource=n;var i,r,a,o,s=h(e,e.VERTEX_SHADER,this.vshaderSource),u=h(e,e.FRAGMENT_SHADER,this.fshaderSource);this.id=(r=s,a=u,o=(i=e).createProgram(),i.attachShader(o,r),i.attachShader(o,a),i.linkProgram(o),i.getProgramParameter(o,i.LINK_STATUS)||(console.log("program not linked!"),console.log(i.getProgramInfoLog(o))),o),this.uniforms=function(e,t){for(var n={},i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=0;r<i;r++){var a=e.getActiveUniform(t,r),o=a.name,s=new zen3d.WebGLUniform(e,t,a);n[o]=s}return n}(e,this.id),this.attributes=function(e,t){for(var n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),r=0;r<i;r++){var a=e.getActiveAttrib(t,r),o=a.name,s=new zen3d.WebGLAttribute(e,t,a);n[o]=s}return n}(e,this.id),e.deleteShader(s),e.deleteShader(u)};e.prototype.dispose=function(e){e.deleteProgram(this.id)},zen3d.WebGLProgram=e}(),function(){var i,r,a=zen3d.CULL_FACE_TYPE,o=zen3d.BLEND_TYPE,s=zen3d.DRAW_SIDE,N=zen3d.WEBGL_UNIFORM_TYPE,I=new zen3d.Vector3,D=new zen3d.Vector4,F=function(e){return e.material},U=(r=new zen3d.Plane,function(e,t){(!i||i.length<4*e.length)&&(i=new Float32Array(4*e.length));for(var n=0;n<e.length;n++)r.copy(e[n]).applyMatrix4(t.viewMatrix),i[4*n+0]=r.normal.x,i[4*n+1]=r.normal.y,i[4*n+2]=r.normal.z,i[4*n+3]=r.constant;return i}),e=function(e){this.gl=e;var t=new zen3d.WebGLProperties;this.properties=t;var n=new zen3d.WebGLCapabilities(e);this.capabilities=n;var i=new zen3d.WebGLState(e,n);i.enable(e.STENCIL_TEST),i.enable(e.DEPTH_TEST),i.setCullFace(a.BACK),i.setFlipSided(!1),i.clearColor(0,0,0,0),this.state=i,this.texture=new zen3d.WebGLTexture(e,i,t,n),this.geometry=new zen3d.WebGLGeometry(e,i,t,n),this._usedTextureUnits=0,this._currentGeometryProgram=""};e.prototype.clear=function(e,t,n){var i=this.gl,r=0;(void 0===e||e)&&(r|=i.COLOR_BUFFER_BIT),(void 0===t||t)&&(r|=i.DEPTH_BUFFER_BIT),(void 0===n||n)&&(r|=i.STENCIL_BUFFER_BIT),i.clear(r)},e.prototype.renderPass=function(e,t,n){n=n||{};for(var i=this.gl,r=this.state,a=n.getMaterial||F,o=n.cache||{},s=(r.currentRenderTarget.width,r.currentRenderTarget.height),u=0,h=e.length;u<h;u++){var c=e[u];if(!n.ifRender||n.ifRender(c)){var d=c.object,l=a.call(this,c),p=c.geometry,f=c.group,_=zen3d.getProgram(this,t,l,d,o);r.setProgram(_),this.geometry.setGeometry(p);var v=_.uuid+"_"+p.uuid;v!==this._currentGeometryProgram&&(this.setupVertexAttributes(_,p),this._currentGeometryProgram=v);var m=_.uniforms;for(var g in m){var y=m[g];switch(g){case"u_Projection":if(d.type===zen3d.OBJECT_TYPE.CANVAS2D&&d.isScreenCanvas)var E=d.orthoCamera.projectionMatrix.elements;else E=t.projectionMatrix.elements;y.setValue(E);break;case"u_View":if(d.type===zen3d.OBJECT_TYPE.CANVAS2D&&d.isScreenCanvas)var T=d.orthoCamera.viewMatrix.elements;else T=t.viewMatrix.elements;y.setValue(T);break;case"u_Model":var x=d.worldMatrix.elements;y.setValue(x);break;case"u_Color":var M=l.diffuse;y.setValue(M.r,M.g,M.b);break;case"u_Opacity":y.setValue(l.opacity);break;case"texture":var w=this.allocTexUnit();this.texture.setTexture2D(l.diffuseMap,w),y.setValue(w);break;case"normalMap":w=this.allocTexUnit();this.texture.setTexture2D(l.normalMap,w),y.setValue(w);break;case"bumpMap":w=this.allocTexUnit();this.texture.setTexture2D(l.bumpMap,w),y.setValue(w);break;case"bumpScale":y.setValue(l.bumpScale);break;case"envMap":w=this.allocTexUnit();this.texture.setTextureCube(l.envMap,w),y.setValue(w);break;case"cubeMap":w=this.allocTexUnit();this.texture.setTextureCube(l.cubeMap,w),y.setValue(w);break;case"u_EnvMap_Intensity":y.setValue(l.envMapIntensity);break;case"u_Specular":y.setValue(l.shininess);break;case"u_SpecularColor":M=l.specular;y.setValue(M.r,M.g,M.b,1);break;case"specularMap":w=this.allocTexUnit();this.texture.setTexture2D(l.specularMap,w),y.setValue(w);break;case"aoMap":w=this.allocTexUnit();this.texture.setTexture2D(l.aoMap,w),y.setValue(w);break;case"aoMapIntensity":y.setValue(l.aoMapIntensity);break;case"u_Roughness":y.setValue(l.roughness);break;case"roughnessMap":w=this.allocTexUnit();this.texture.setTexture2D(l.roughnessMap,w),y.setValue(w);break;case"u_Metalness":y.setValue(l.metalness);break;case"metalnessMap":w=this.allocTexUnit();this.texture.setTexture2D(l.metalnessMap,w),y.setValue(w);break;case"emissive":M=l.emissive;var S=l.emissiveIntensity;y.setValue(M.r*S,M.g*S,M.b*S);break;case"emissiveMap":w=this.allocTexUnit();this.texture.setTexture2D(l.emissiveMap,w),y.setValue(w);break;case"u_CameraPosition":I.setFromMatrixPosition(t.worldMatrix),y.setValue(I.x,I.y,I.z);break;case"u_FogColor":M=o.fog.color;y.setValue(M.r,M.g,M.b);break;case"u_FogDensity":y.setValue(o.fog.density);break;case"u_FogNear":y.setValue(o.fog.near);break;case"u_FogFar":y.setValue(o.fog.far);break;case"u_PointSize":y.setValue(l.size);break;case"u_PointScale":var z=.5*s;y.setValue(z);break;case"dashSize":y.setValue(l.dashSize);break;case"totalSize":y.setValue(l.dashSize+l.gapSize);break;case"scale":y.setValue(l.scale);break;case"clippingPlanes[0]":var A=U(o.clippingPlanes||[],t);i.uniform4fv(y.location,A);break;default:if(l.uniforms&&l.uniforms[g])if(y.type===N.SAMPLER_2D){w=this.allocTexUnit();this.texture.setTexture2D(l.uniforms[g],w),y.setValue(w)}else if(y.type===N.SAMPLER_CUBE){w=this.allocTexUnit();this.texture.setTextureCube(l.uniforms[g],w),y.setValue(w)}else y.set(l.uniforms[g])}}d.type===zen3d.OBJECT_TYPE.SKINNED_MESH&&this.uploadSkeleton(m,d,_.id),d.type===zen3d.OBJECT_TYPE.SPRITE&&this.uploadSpriteUniform(m,d,t,o.fog),d.type===zen3d.OBJECT_TYPE.PARTICLE&&this.uploadParticlesUniform(m,d,t),l.acceptLight&&o.lights&&this.uploadLights(m,o.lights,d.receiveShadow,t);var b=d.worldMatrix.determinant()<0;this.setStates(l,b);var L=D.set(r.currentRenderTarget.width,r.currentRenderTarget.height,r.currentRenderTarget.width,r.currentRenderTarget.height).multiply(t.rect);if(L.z-=L.x,L.w-=L.y,L.x=Math.floor(L.x),L.y=Math.floor(L.y),L.z=Math.floor(L.z),L.w=Math.floor(L.w),d.type===zen3d.OBJECT_TYPE.CANVAS2D){d.isScreenCanvas&&(d.setRenderViewport(L.x,L.y,L.z,L.w),r.viewport(d.viewport.x,d.viewport.y,d.viewport.z,d.viewport.w));for(var P=0,R=0;R<d.drawArray.length;R++){var C=d.drawArray[R];w=this.allocTexUnit();this.texture.setTexture2D(C.texture,w),m.spriteTexture.setValue(w),i.drawElements(i.TRIANGLES,6*C.count,i.UNSIGNED_SHORT,2*P),P+=6*C.count,this._usedTextureUnits=0}}else r.viewport(L.x,L.y,L.z,L.w),this.draw(p,l,f);this._usedTextureUnits=0}}},e.prototype.setStates=function(e,t){var n=this.gl,i=this.state;e.transparent?i.setBlend(e.blending,e.premultipliedAlpha):i.setBlend(o.NONE),e.depthTest?(i.enable(n.DEPTH_TEST),i.depthMask(e.depthWrite)):i.disable(n.DEPTH_TEST),i.setCullFace(e.side===s.DOUBLE?a.NONE:a.BACK);var r=e.side===s.BACK;t&&(r=!r),i.setFlipSided(r),void 0!==e.lineWidth&&i.setLineWidth(e.lineWidth)},e.prototype.draw=function(e,t,n){var i=this.gl,r=null!==e.index,a=0,o=r?e.index.count:e.getAttribute("a_Position").count,s=n?n.start:0,u=n?n.count:1/0;a=Math.max(a,s),o=Math.min(o,u),r?i.drawElements(t.drawMode,o,i.UNSIGNED_SHORT,2*a):i.drawArrays(t.drawMode,a,o)},e.prototype.uploadSkeleton=function(e,t,n){if(t.skeleton&&0<t.skeleton.bones.length){var i=t.skeleton,r=this.gl;if(0<this.capabilities.maxVertexTextures&&this.capabilities.floatTextures){if(void 0===i.boneTexture){var a=Math.sqrt(4*i.bones.length);a=zen3d.nextPowerOfTwo(Math.ceil(a)),a=Math.max(4,a);var o=new Float32Array(a*a*4);o.set(i.boneMatrices);var s=new zen3d.TextureData(o,a,a);i.boneMatrices=o,i.boneTexture=s,i.boneTextureSize=a}var u=this.allocTexUnit();this.texture.setTexture2D(i.boneTexture,u),e.boneTexture&&e.boneTexture.setValue(u),e.boneTextureSize&&e.boneTextureSize.setValue(i.boneTextureSize)}else{var h=r.getUniformLocation(n,"boneMatrices");r.uniformMatrix4fv(h,!1,i.boneMatrices)}}};var f=[],_=[],v=[];e.prototype.uploadLights=function(e,t,n,i){var r=this.gl;0<t.ambientsNum&&e.u_AmbientLightColor.set(t.ambient);for(var a=0;a<t.directsNum;a++){var o=t.directional[a];e["u_Directional["+a+"].direction"].set(o.direction),e["u_Directional["+a+"].intensity"].setValue(1),e["u_Directional["+a+"].color"].set(o.color);var s=o.shadow&&n;if(e["u_Directional["+a+"].shadow"].setValue(s?1:0),s){e["u_Directional["+a+"].shadowBias"].setValue(o.shadowBias),e["u_Directional["+a+"].shadowRadius"].setValue(o.shadowRadius),e["u_Directional["+a+"].shadowMapSize"].set(o.shadowMapSize);var u=this.allocTexUnit();this.texture.setTexture2D(t.directionalShadowMap[a],u),f[a]=u}}if(0<f.length){var h=e["directionalShadowMap[0]"];r.uniform1iv(h.location,f),f.length=0;var c=e["directionalShadowMatrix[0]"];r.uniformMatrix4fv(c.location,!1,t.directionalShadowMatrix)}for(a=0;a<t.pointsNum;a++){o=t.point[a];e["u_Point["+a+"].position"].set(o.position),e["u_Point["+a+"].intensity"].setValue(1),e["u_Point["+a+"].color"].set(o.color),e["u_Point["+a+"].distance"].setValue(o.distance),e["u_Point["+a+"].decay"].setValue(o.decay);s=o.shadow&&n;if(e["u_Point["+a+"].shadow"].setValue(s?1:0),s){e["u_Point["+a+"].shadowBias"].setValue(o.shadowBias),e["u_Point["+a+"].shadowRadius"].setValue(o.shadowRadius),e["u_Point["+a+"].shadowMapSize"].set(o.shadowMapSize),e["u_Point["+a+"].shadowCameraNear"].setValue(o.shadowCameraNear),e["u_Point["+a+"].shadowCameraFar"].setValue(o.shadowCameraFar);u=this.allocTexUnit();this.texture.setTextureCube(t.pointShadowMap[a],u),_[a]=u}}if(0<_.length){var d=e["pointShadowMap[0]"];r.uniform1iv(d.location,_),_.length=0}for(a=0;a<t.spotsNum;a++){o=t.spot[a];e["u_Spot["+a+"].position"].set(o.position),e["u_Spot["+a+"].direction"].set(o.direction),e["u_Spot["+a+"].intensity"].setValue(1),e["u_Spot["+a+"].color"].set(o.color),e["u_Spot["+a+"].distance"].setValue(o.distance),e["u_Spot["+a+"].decay"].setValue(o.decay),e["u_Spot["+a+"].coneCos"].setValue(o.coneCos),e["u_Spot["+a+"].penumbraCos"].setValue(o.penumbraCos);s=o.shadow&&n;if(e["u_Spot["+a+"].shadow"].setValue(s?1:0),s){e["u_Spot["+a+"].shadowBias"].setValue(o.shadowBias),e["u_Spot["+a+"].shadowRadius"].setValue(o.shadowRadius),e["u_Spot["+a+"].shadowMapSize"].set(o.shadowMapSize);u=this.allocTexUnit();this.texture.setTexture2D(t.spotShadowMap[a],u),v[a]=u}}if(0<v.length){var l=e["spotShadowMap[0]"];r.uniform1iv(l.location,v),v.length=0;var p=e["spotShadowMatrix[0]"];r.uniformMatrix4fv(p.location,!1,t.spotShadowMatrix)}};var u=[],h=new zen3d.Vector3,c=new zen3d.Quaternion,d=new zen3d.Vector3;e.prototype.uploadSpriteUniform=function(e,t,n,i){this.gl,this.state,t.geometry;var r=t.material;e.projectionMatrix.setValue(n.projectionMatrix.elements);var a=0;i?(e.fogColor.setValue(i.color.r,i.color.g,i.color.b),i.fogType===zen3d.FOG_TYPE.NORMAL?(e.fogNear.setValue(i.near),e.fogFar.setValue(i.far),e.fogType.setValue(1),a=1):i.fogType===zen3d.FOG_TYPE.EXP2&&(e.fogDensity.setValue(i.density),e.fogType.setValue(2),a=2)):(e.fogType.setValue(0),a=0),e.alphaTest.setValue(0),e.viewMatrix.setValue(n.viewMatrix.elements),e.modelMatrix.setValue(t.worldMatrix.elements),t.worldMatrix.decompose(h,c,d),u[0]=d.x,u[1]=d.y;var o=0;i&&r.fog&&(o=a),e.fogType.setValue(o),r.diffuseMap,e.uvOffset.setValue(0,0),e.uvScale.setValue(1,1),e.opacity.setValue(r.opacity),e.color.setValue(r.diffuse.r,r.diffuse.g,r.diffuse.b),e.rotation.setValue(r.rotation),e.scale.setValue(u[0],u[1]);var s=this.allocTexUnit();this.texture.setTexture2D(r.diffuseMap,s),e.map.setValue(s)},e.prototype.uploadParticlesUniform=function(e,t,n){this.gl,this.state,t.geometry,t.material;e.uTime.setValue(t.time),e.uScale.setValue(1),e.u_Projection.setValue(n.projectionMatrix.elements),e.u_View.setValue(n.viewMatrix.elements),e.u_Model.setValue(t.worldMatrix.elements);var i=this.allocTexUnit();this.texture.setTexture2D(t.particleNoiseTex,i),e.tNoise.setValue(i);i=this.allocTexUnit();this.texture.setTexture2D(t.particleSpriteTex,i),e.tSprite.setValue(i)},e.prototype.allocTexUnit=function(){var e=this._usedTextureUnits;return e>=this.capabilities.maxTextures&&console.warn("trying to use "+e+" texture units while this GPU supports only "+this.capabilities.maxTextures),this._usedTextureUnits+=1,e},e.prototype.setupVertexAttributes=function(e,t){var n=this.gl,i=e.attributes,r=this.properties;for(var a in i){var o=i[a],s=t.getAttribute(a);if(s){var u,h=s.normalized,c=s.size;o.count!==c&&console.warn("WebGLCore: attribute "+a+" size not match! "+o.count+" : "+c);var d=(u=s.isInterleavedBufferAttribute?r.get(s.data):r.get(s)).buffer,l=u.type;o.format!==l&&console.warn("WebGLCore: attribute "+a+" type not match! "+o.format+" : "+l);var p=u.bytesPerElement;if(s.isInterleavedBufferAttribute){var f=s.data.stride,_=s.offset;n.bindBuffer(n.ARRAY_BUFFER,d),n.vertexAttribPointer(o.location,o.count,o.format,h,p*f,p*_),n.enableVertexAttribArray(o.location)}else n.bindBuffer(n.ARRAY_BUFFER,d),n.vertexAttribPointer(o.location,o.count,o.format,h,0,0),n.enableVertexAttribArray(o.location)}else console.warn("WebGLCore: geometry attribute "+a+" not found!")}if(t.index){var v=r.get(t.index);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,v.buffer)}},zen3d.WebGLCore=e}(),zen3d.ShaderChunk={ambientlight_pars_frag:"uniform vec4 u_AmbientLightColor;",aoMap_pars_frag:"#ifdef USE_AOMAP\\n\\tuniform sampler2D aoMap;\\n\\tuniform float aoMapIntensity;\\n#endif",begin_frag:"vec4 outColor = vec4(u_Color, u_Opacity);",begin_vert:"vec3 transformed = vec3(a_Position);\\n#if defined(USE_NORMAL) || defined(USE_ENV_MAP)\\n    vec3 objectNormal = vec3(a_Normal);\\n#endif",bsdfs:"\\nvec4 BRDF_Diffuse_Lambert(vec4 diffuseColor) {\\n    return RECIPROCAL_PI * diffuseColor;\\n}\\nvec4 F_Schlick( const in vec4 specularColor, const in float dotLH ) {\\n\\tfloat fresnel = pow( 1.0 - dotLH, 5.0 );\\n\\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\\n}\\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\\n\\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\\n}\\nfloat G_BlinnPhong_Implicit( ) {\\n\\treturn 0.25;\\n}\\nvec4 BRDF_Specular_BlinnPhong(vec4 specularColor, vec3 N, vec3 L, vec3 V, float shininess) {\\n    vec3 H = normalize(L + V);\\n    float dotNH = saturate(dot(N, H));\\n    float dotLH = saturate(dot(L, H));\\n    vec4 F = F_Schlick(specularColor, dotLH);\\n    float G = G_BlinnPhong_Implicit( );\\n    float D = D_BlinnPhong(shininess, dotNH);\\n    return F * G * D;\\n}\\nfloat D_GGX( const in float alpha, const in float dotNH ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\\n\\treturn RECIPROCAL_PI * a2 / pow2( denom );\\n}\\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\\n\\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\\n\\treturn 1.0 / ( gl * gv );\\n}\\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\\n\\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\\n\\treturn 0.5 / max( gv + gl, EPSILON );\\n}\\nvec4 BRDF_Specular_GGX(vec4 specularColor, vec3 N, vec3 L, vec3 V, float roughness) {\\n\\tfloat alpha = pow2( roughness );\\n\\tvec3 H = normalize(L + V);\\n\\tfloat dotNL = saturate( dot(N, L) );\\n\\tfloat dotNV = saturate( dot(N, V) );\\n\\tfloat dotNH = saturate( dot(N, H) );\\n\\tfloat dotLH = saturate( dot(L, H) );\\n\\tvec4 F = F_Schlick( specularColor, dotLH );\\n\\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\\n\\tfloat D = D_GGX( alpha, dotNH );\\n\\treturn F * G * D;\\n}\\nvec4 BRDF_Specular_GGX_Environment( const in vec3 N, const in vec3 V, const in vec4 specularColor, const in float roughness ) {\\n\\tfloat dotNV = saturate( dot( N, V ) );\\n\\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\\n\\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\\n\\tvec4 r = roughness * c0 + c1;\\n\\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\\n\\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\\n\\treturn specularColor * AB.x + AB.y;\\n}\\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\\n\\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\\n}\\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\\n\\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\\n}",bumpMap_pars_frag:"#ifdef USE_BUMPMAP\\n\\tuniform sampler2D bumpMap;\\n\\tuniform float bumpScale;\\n\\tvec2 dHdxy_fwd(vec2 uv) {\\n\\t\\tvec2 dSTdx = dFdx( uv );\\n\\t\\tvec2 dSTdy = dFdy( uv );\\n\\t\\tfloat Hll = bumpScale * texture2D( bumpMap, uv ).x;\\n\\t\\tfloat dBx = bumpScale * texture2D( bumpMap, uv + dSTdx ).x - Hll;\\n\\t\\tfloat dBy = bumpScale * texture2D( bumpMap, uv + dSTdy ).x - Hll;\\n\\t\\treturn vec2( dBx, dBy );\\n\\t}\\n\\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy) {\\n\\t\\tvec3 vSigmaX = dFdx( surf_pos );\\n\\t\\tvec3 vSigmaY = dFdy( surf_pos );\\n\\t\\tvec3 vN = surf_norm;\\n\\t\\tvec3 R1 = cross( vSigmaY, vN );\\n\\t\\tvec3 R2 = cross( vN, vSigmaX );\\n\\t\\tfloat fDet = dot( vSigmaX, R1 );\\n\\t\\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\\n\\t\\treturn normalize( abs( fDet ) * surf_norm - vGrad );\\n\\t}\\n#endif\\n",clippingPlanes_frag:"#ifdef NUM_CLIPPING_PLANES\\n    vec4 plane;\\n    for ( int i = 0; i < NUM_CLIPPING_PLANES; i ++ ) {\\n        plane = clippingPlanes[ i ];\\n        if ( dot( -v_ViewModelPos, plane.xyz ) > plane.w ) discard;\\n    }\\n#endif",clippingPlanes_pars_frag:"#ifdef NUM_CLIPPING_PLANES\\n    uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\\n#endif",color_frag:"#ifdef USE_VCOLOR\\n    outColor *= v_Color;\\n#endif",color_pars_frag:"#ifdef USE_VCOLOR\\n    varying vec4 v_Color;\\n#endif",color_pars_vert:"#ifdef USE_VCOLOR\\n    attribute vec4 a_Color;\\n    varying vec4 v_Color;\\n#endif",color_vert:"#ifdef USE_VCOLOR\\n    v_Color = a_Color;\\n#endif",common_frag:"uniform mat4 u_View;\\nuniform float u_Opacity;\\nuniform vec3 u_Color;\\nuniform vec3 u_CameraPosition;",common_vert:"attribute vec3 a_Position;\\nattribute vec3 a_Normal;\\n#include <transpose>\\n#include <inverse>\\nuniform mat4 u_Projection;\\nuniform mat4 u_View;\\nuniform mat4 u_Model;\\nuniform vec3 u_CameraPosition;",diffuseMap_frag:"#ifdef USE_DIFFUSE_MAP\\n    vec4 texelColor = texture2D( texture, v_Uv );\\n    texelColor = mapTexelToLinear( texelColor );\\n    outColor *= texelColor;\\n#endif",diffuseMap_pars_frag:"#ifdef USE_DIFFUSE_MAP\\n    uniform sampler2D texture;\\n#endif",directlight_pars_frag:"struct DirectLight\\n{\\n    vec3 direction;\\n    vec4 color;\\n    float intensity;\\n    int shadow;\\n    float shadowBias;\\n    float shadowRadius;\\n    vec2 shadowMapSize;\\n};\\nuniform DirectLight u_Directional[USE_DIRECT_LIGHT];",emissiveMap_frag:"#ifdef USE_EMISSIVEMAP\\n\\tvec4 emissiveColor = texture2D(emissiveMap, v_Uv);\\n\\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\\n\\ttotalEmissiveRadiance *= emissiveColor.rgb;\\n#endif",emissiveMap_pars_frag:"#ifdef USE_EMISSIVEMAP\\n\\tuniform sampler2D emissiveMap;\\n#endif",encodings_frag:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_frag:"\\nvec4 LinearToLinear( in vec4 value ) {\\n\\treturn value;\\n}\\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\\n}\\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\\n}\\nvec4 sRGBToLinear( in vec4 value ) {\\n\\treturn 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\\treturn 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}\\nvec4 RGBEToLinear( in vec4 value ) {\\n\\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\\n}\\nvec4 LinearToRGBE( in vec4 value ) {\\n\\tfloat maxComponent = max( max( value.r, value.g ), value.b );\\n\\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\\n\\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\\n}\\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\\n}\\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\\n\\tfloat M      = clamp( maxRGB / maxRange, 0.0, 1.0 );\\n\\tM            = ceil( M * 255.0 ) / 255.0;\\n\\treturn vec4( value.rgb / ( M * maxRange ), M );\\n}\\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\\n}\\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\\n\\tfloat D      = max( maxRange / maxRGB, 1.0 );\\n\\tD            = min( floor( D ) / 255.0, 1.0 );\\n\\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\\n}\\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\\nvec4 LinearToLogLuv( in vec4 value )  {\\n\\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\\n\\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\\n\\tvec4 vResult;\\n\\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\\n\\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\\n\\tvResult.w = fract(Le);\\n\\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\\n\\treturn vResult;\\n}\\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\\nvec4 LogLuvToLinear( in vec4 value ) {\\n\\tfloat Le = value.z * 255.0 + value.w;\\n\\tvec3 Xp_Y_XYZp;\\n\\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\\n\\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\\n\\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\\n\\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\\n\\treturn vec4( max(vRGB, 0.0), 1.0 );\\n}\\n",end_frag:"gl_FragColor = outColor;",envMap_frag:"#ifdef USE_ENV_MAP\\n    vec3 envDir;\\n    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n        envDir = reflect(normalize(v_worldPos - u_CameraPosition), (vec4(N, 1.0) * u_View).xyz);\\n    #else\\n        envDir = v_EnvPos;\\n    #endif\\n    vec4 envColor = textureCube(envMap, envDir);\\n    envColor = envMapTexelToLinear( envColor );\\n    #ifdef ENVMAP_BLENDING_MULTIPLY\\n\\t\\toutColor = mix(outColor, envColor * outColor, u_EnvMap_Intensity);\\n\\t#elif defined( ENVMAP_BLENDING_MIX )\\n\\t\\toutColor = mix(outColor, envColor, u_EnvMap_Intensity);\\n\\t#elif defined( ENVMAP_BLENDING_ADD )\\n\\t\\toutColor += envColor * u_EnvMap_Intensity;\\n\\t#endif\\n#endif",envMap_pars_frag:"#ifdef USE_ENV_MAP\\n    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n        varying vec3 v_worldPos;\\n    #else\\n        varying vec3 v_EnvPos;\\n    #endif\\n    uniform samplerCube envMap;\\n    uniform float u_EnvMap_Intensity;\\n#endif",envMap_pars_vert:"#ifdef USE_ENV_MAP\\n    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n        varying vec3 v_worldPos;\\n    #else\\n        varying vec3 v_EnvPos;\\n    #endif\\n#endif",envMap_vert:"#ifdef USE_ENV_MAP\\n    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n        v_worldPos = (u_Model * vec4(transformed, 1.0)).xyz;\\n    #else\\n        v_EnvPos = reflect(normalize((u_Model * vec4(transformed, 1.0)).xyz - u_CameraPosition), (transpose(inverse(u_Model)) * vec4(objectNormal, 1.0)).xyz);\\n    #endif\\n#endif",fog_frag:"#ifdef USE_FOG\\n    float depth = gl_FragCoord.z / gl_FragCoord.w;\\n    #ifdef USE_EXP2_FOG\\n        float fogFactor = whiteCompliment( exp2( - u_FogDensity * u_FogDensity * depth * depth * LOG2 ) );\\n    #else\\n        float fogFactor = smoothstep( u_FogNear, u_FogFar, depth );\\n    #endif\\n    gl_FragColor.rgb = mix( gl_FragColor.rgb, u_FogColor, fogFactor );\\n#endif",fog_pars_frag:"#ifdef USE_FOG\\n    uniform vec3 u_FogColor;\\n    #ifdef USE_EXP2_FOG\\n        uniform float u_FogDensity;\\n    #else\\n        uniform float u_FogNear;\\n        uniform float u_FogFar;\\n    #endif\\n#endif",inverse:"mat4 inverse(mat4 m) {\\n    float\\n    a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\\n    a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\\n    a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\\n    a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\\n    b00 = a00 * a11 - a01 * a10,\\n    b01 = a00 * a12 - a02 * a10,\\n    b02 = a00 * a13 - a03 * a10,\\n    b03 = a01 * a12 - a02 * a11,\\n    b04 = a01 * a13 - a03 * a11,\\n    b05 = a02 * a13 - a03 * a12,\\n    b06 = a20 * a31 - a21 * a30,\\n    b07 = a20 * a32 - a22 * a30,\\n    b08 = a20 * a33 - a23 * a30,\\n    b09 = a21 * a32 - a22 * a31,\\n    b10 = a21 * a33 - a23 * a31,\\n    b11 = a22 * a33 - a23 * a32,\\n    det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\\n    return mat4(\\n        a11 * b11 - a12 * b10 + a13 * b09,\\n        a02 * b10 - a01 * b11 - a03 * b09,\\n        a31 * b05 - a32 * b04 + a33 * b03,\\n        a22 * b04 - a21 * b05 - a23 * b03,\\n        a12 * b08 - a10 * b11 - a13 * b07,\\n        a00 * b11 - a02 * b08 + a03 * b07,\\n        a32 * b02 - a30 * b05 - a33 * b01,\\n        a20 * b05 - a22 * b02 + a23 * b01,\\n        a10 * b10 - a11 * b08 + a13 * b06,\\n        a01 * b08 - a00 * b10 - a03 * b06,\\n        a30 * b04 - a31 * b02 + a33 * b00,\\n        a21 * b02 - a20 * b04 - a23 * b00,\\n        a11 * b07 - a10 * b09 - a12 * b06,\\n        a00 * b09 - a01 * b07 + a02 * b06,\\n        a31 * b01 - a30 * b03 - a32 * b00,\\n        a20 * b03 - a21 * b01 + a22 * b00) / det;\\n}",light_frag:"#ifdef USE_LIGHT\\n    vec4 light;\\n    vec3 L;\\n    vec4 totalReflect = vec4(0., 0., 0., 0.);    vec4 indirectIrradiance = vec4(0., 0., 0., 0.);    vec4 indirectRadiance = vec4(0., 0., 0., 0.);\\n    #ifdef USE_PBR\\n        vec4 diffuseColor = outColor.xyzw * (1.0 - metalnessFactor);\\n        vec4 specularColor = mix(vec4(0.04), outColor.xyzw, metalnessFactor);\\n        float roughness = clamp(roughnessFactor, 0.04, 1.0);\\n    #else\\n        vec4 diffuseColor = outColor.xyzw;\\n        #ifdef USE_PHONG\\n            vec4 specularColor = u_SpecularColor;\\n            float shininess = u_Specular;\\n        #endif\\n    #endif\\n    #ifdef USE_AMBIENT_LIGHT\\n        #ifdef USE_PBR\\n            indirectIrradiance += PI * diffuseColor * u_AmbientLightColor;\\n        #else\\n            indirectIrradiance += diffuseColor * u_AmbientLightColor;\\n        #endif\\n    #endif\\n    #ifdef USE_PBR\\n        #ifdef USE_ENV_MAP\\n    \\t\\tvec3 envDir;\\n    \\t    #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\\n    \\t        envDir = reflect(normalize(v_worldPos - u_CameraPosition), (vec4(N, 1.0) * u_View).xyz);\\n    \\t    #else\\n    \\t        envDir = v_EnvPos;\\n    \\t    #endif\\n            indirectIrradiance += getLightProbeIndirectIrradiance(8, envDir);\\n            indirectRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(roughness), 8, envDir);\\n    \\t#endif\\n    #endif\\n    #if (defined(USE_PHONG) || defined(USE_PBR))\\n        vec3 V = normalize( (u_View * vec4(u_CameraPosition, 1.)).xyz - v_ViewModelPos);\\n    #endif\\n    #ifdef USE_DIRECT_LIGHT\\n    for(int i = 0; i < USE_DIRECT_LIGHT; i++) {\\n        L = -u_Directional[i].direction;\\n        light = u_Directional[i].color * u_Directional[i].intensity;\\n        L = normalize(L);\\n        float dotNL = saturate( dot(N, L) );\\n        vec4 irradiance = light * dotNL;\\n        #ifdef USE_SHADOW\\n            irradiance *= bool( u_Directional[i].shadow ) ? getShadow( directionalShadowMap[ i ], vDirectionalShadowCoord[ i ], u_Directional[i].shadowBias, u_Directional[i].shadowRadius, u_Directional[i].shadowMapSize ) : 1.0;\\n        #endif\\n        #ifdef USE_PBR\\n            irradiance *= PI;\\n        #endif\\n        vec4 reflectLight = irradiance * BRDF_Diffuse_Lambert(diffuseColor);\\n        #ifdef USE_PHONG\\n            reflectLight += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\\n        #endif\\n        #ifdef USE_PBR\\n            reflectLight += irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness) * specularStrength;\\n        #endif\\n        totalReflect += reflectLight;\\n    }\\n    #endif\\n    #ifdef USE_POINT_LIGHT\\n    for(int i = 0; i < USE_POINT_LIGHT; i++) {\\n        L = u_Point[i].position - v_ViewModelPos;\\n        float dist = pow(clamp(1. - length(L) / u_Point[i].distance, 0.0, 1.0), u_Point[i].decay);\\n        light = u_Point[i].color * u_Point[i].intensity * dist;\\n        L = normalize(L);\\n        float dotNL = saturate( dot(N, L) );\\n        vec4 irradiance = light * dotNL;\\n        #ifdef USE_PBR\\n            irradiance *= PI;\\n        #endif\\n        #ifdef USE_SHADOW\\n            vec3 worldV = (vec4(v_ViewModelPos, 1.) * u_View - vec4(u_Point[i].position, 1.) * u_View).xyz;\\n            irradiance *= bool( u_Point[i].shadow ) ? getPointShadow( pointShadowMap[ i ], worldV, u_Point[i].shadowBias, u_Point[i].shadowRadius, u_Point[i].shadowMapSize, u_Point[i].shadowCameraNear, u_Point[i].shadowCameraFar ) : 1.0;\\n        #endif\\n        vec4 reflectLight = irradiance * BRDF_Diffuse_Lambert(diffuseColor);\\n        #ifdef USE_PHONG\\n            reflectLight += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\\n        #endif\\n        #ifdef USE_PBR\\n            reflectLight += irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness) * specularStrength;\\n        #endif\\n        totalReflect += reflectLight;\\n    }\\n    #endif\\n    #ifdef USE_SPOT_LIGHT\\n    for(int i = 0; i < USE_SPOT_LIGHT; i++) {\\n        L = u_Spot[i].position - v_ViewModelPos;\\n        float lightDistance = length(L);\\n        L = normalize(L);\\n        float angleCos = dot( L, -normalize(u_Spot[i].direction) );\\n        if( all( bvec2(angleCos > u_Spot[i].coneCos, lightDistance < u_Spot[i].distance) ) ) {\\n            float spotEffect = smoothstep( u_Spot[i].coneCos, u_Spot[i].penumbraCos, angleCos );\\n            float dist = pow(clamp(1. - lightDistance / u_Spot[i].distance, 0.0, 1.0), u_Spot[i].decay);\\n            light = u_Spot[i].color * u_Spot[i].intensity * dist * spotEffect;\\n            float dotNL = saturate( dot(N, L) );\\n            vec4 irradiance = light * dotNL;\\n            #ifdef USE_PBR\\n                irradiance *= PI;\\n            #endif\\n            #ifdef USE_SHADOW\\n                irradiance *= bool( u_Spot[i].shadow ) ? getShadow( spotShadowMap[ i ], vSpotShadowCoord[ i ], u_Spot[i].shadowBias, u_Spot[i].shadowRadius, u_Spot[i].shadowMapSize ) : 1.0;\\n            #endif\\n            vec4 reflectLight = irradiance * BRDF_Diffuse_Lambert(diffuseColor);\\n            #ifdef USE_PHONG\\n                reflectLight += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\\n            #endif\\n            #ifdef USE_PBR\\n                reflectLight += irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness) * specularStrength;\\n            #endif\\n            totalReflect += reflectLight;\\n        }\\n    }\\n    #endif\\n    vec4 indirectDiffuse = indirectIrradiance * BRDF_Diffuse_Lambert(diffuseColor);\\n    vec4 indirectSpecular = vec4(0., 0., 0., 0.);\\n    #if defined( USE_ENV_MAP ) && defined( USE_PBR )\\n        indirectSpecular += indirectRadiance * BRDF_Specular_GGX_Environment(N, V, specularColor, roughness) * specularStrength;\\n    #endif\\n    #ifdef USE_AOMAP\\n    \\tfloat ambientOcclusion = ( texture2D( aoMap, v_Uv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\\n    \\tindirectDiffuse *= ambientOcclusion;\\n    \\t#if defined( USE_ENV_MAP ) && defined( USE_PBR )\\n    \\t\\tfloat dotNV = saturate( dot( N, V ) );\\n    \\t\\tindirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, GGXRoughnessToBlinnExponent(roughness) );\\n    \\t#endif\\n    #endif\\n    outColor.xyz = totalReflect.xyz + indirectDiffuse.xyz + indirectSpecular.xyz;\\n#endif",light_pars_frag:"#ifdef USE_AMBIENT_LIGHT\\n    #include <ambientlight_pars_frag>\\n#endif\\n#ifdef USE_DIRECT_LIGHT\\n    #include <directlight_pars_frag>\\n#endif\\n#ifdef USE_POINT_LIGHT\\n    #include <pointlight_pars_frag>\\n#endif\\n#ifdef USE_SPOT_LIGHT\\n    #include <spotlight_pars_frag>\\n#endif\\n#if defined(USE_PBR) && defined(USE_ENV_MAP)\\n    vec4 getLightProbeIndirectIrradiance(const in int maxMIPLevel, const in vec3 envDir) {\\n    \\t#ifdef TEXTURE_LOD_EXT\\n    \\t\\tvec4 envMapColor = textureCubeLodEXT( envMap, envDir, float( maxMIPLevel ) );\\n    \\t#else\\n    \\t\\tvec4 envMapColor = textureCube( envMap, envDir, float( maxMIPLevel ) );\\n    \\t#endif\\n        envMapColor = envMapTexelToLinear( envMapColor );\\n        return PI * envMapColor * u_EnvMap_Intensity;\\n    }\\n    float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\\n    \\tfloat maxMIPLevelScalar = float( maxMIPLevel );\\n    \\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\\n    \\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\\n    }\\n    vec4 getLightProbeIndirectRadiance(const in float blinnShininessExponent, const in int maxMIPLevel, const in vec3 envDir) {\\n        float specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\\n        #ifdef TEXTURE_LOD_EXT\\n    \\t\\tvec4 envMapColor = textureCubeLodEXT( envMap, envDir, specularMIPLevel );\\n    \\t#else\\n    \\t\\tvec4 envMapColor = textureCube( envMap, envDir, specularMIPLevel );\\n    \\t#endif\\n        envMapColor = envMapTexelToLinear( envMapColor );\\n        return envMapColor * u_EnvMap_Intensity;\\n    }\\n    float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\\n    \\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\\n    }\\n#endif",normalMap_pars_frag:"#include <tbn>\\n#include <tsn>\\nuniform sampler2D normalMap;",normal_frag:"#ifdef USE_NORMAL\\n    #ifdef DOUBLE_SIDED\\n    \\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n    #else\\n    \\tfloat flipNormal = 1.0;\\n    #endif\\n    #ifdef FLAT_SHADED\\n    \\tvec3 fdx = vec3( dFdx( v_ViewModelPos.x ), dFdx( v_ViewModelPos.y ), dFdx( v_ViewModelPos.z ) );\\n    \\tvec3 fdy = vec3( dFdy( v_ViewModelPos.x ), dFdy( v_ViewModelPos.y ), dFdy( v_ViewModelPos.z ) );\\n    \\tvec3 N = normalize( cross( fdx, fdy ) );\\n    #else\\n        vec3 N = normalize(v_Normal) * flipNormal;\\n    #endif\\n    #ifdef USE_NORMAL_MAP\\n        vec3 normalMapColor = texture2D(normalMap, v_Uv).rgb;\\n        mat3 tspace = tsn(N, -v_ViewModelPos, vec2(v_Uv.x, 1.0 - v_Uv.y));\\n        N = normalize(tspace * (normalMapColor * 2.0 - 1.0));\\n    #elif defined(USE_BUMPMAP)\\n        N = perturbNormalArb(-v_ViewModelPos, N, dHdxy_fwd(v_Uv));\\n    #endif\\n#endif",normal_pars_frag:"#ifdef USE_NORMAL\\n    varying vec3 v_Normal;\\n#endif",normal_pars_vert:"#ifdef USE_NORMAL\\n    varying vec3 v_Normal;\\n#endif",normal_vert:"#ifdef USE_NORMAL\\n    v_Normal = (transpose(inverse(u_View * u_Model)) * vec4(objectNormal, 1.0)).xyz;\\n    #ifdef FLIP_SIDED\\n    \\tv_Normal = - v_Normal;\\n    #endif\\n#endif",packing:"const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,  256. );\\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\\nconst float ShiftRight8 = 1. / 256.;\\nvec4 packDepthToRGBA( const in float v ) {\\n    vec4 r = vec4( fract( v * PackFactors ), v );\\n    r.yzw -= r.xyz * ShiftRight8;    return r * PackUpscale;\\n}\\nfloat unpackRGBAToDepth( const in vec4 v ) {\\n    return dot( v, UnpackFactors );\\n}",pointlight_pars_frag:"struct PointLight\\n{\\n    vec3 position;\\n    vec4 color;\\n    float intensity;\\n    float distance;\\n    float decay;\\n    int shadow;\\n    float shadowBias;\\n    float shadowRadius;\\n    vec2 shadowMapSize;\\n    float shadowCameraNear;\\n    float shadowCameraFar;\\n};\\nuniform PointLight u_Point[USE_POINT_LIGHT];",premultipliedAlpha_frag:"#ifdef USE_PREMULTIPLIED_ALPHA\\n    gl_FragColor.rgb = gl_FragColor.rgb * gl_FragColor.a;\\n#endif",pvm_vert:"gl_Position = u_Projection * u_View * u_Model * vec4(transformed, 1.0);",shadowMap_frag:"#ifdef USE_SHADOW\\n#endif",shadowMap_pars_frag:"#ifdef USE_SHADOW\\n    #include <packing>\\n    #ifdef USE_DIRECT_LIGHT\\n        uniform sampler2D directionalShadowMap[ USE_DIRECT_LIGHT ];\\n        varying vec4 vDirectionalShadowCoord[ USE_DIRECT_LIGHT ];\\n    #endif\\n    #ifdef USE_POINT_LIGHT\\n        uniform samplerCube pointShadowMap[ USE_POINT_LIGHT ];\\n    #endif\\n    #ifdef USE_SPOT_LIGHT\\n        uniform sampler2D spotShadowMap[ USE_SPOT_LIGHT ];\\n        varying vec4 vSpotShadowCoord[ USE_SPOT_LIGHT ];\\n    #endif\\n    float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\\n        return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\\n    }\\n    float textureCubeCompare( samplerCube depths, vec3 uv, float compare ) {\\n        return step( compare, unpackRGBAToDepth( textureCube( depths, uv ) ) );\\n    }\\n    float getShadow( sampler2D shadowMap, vec4 shadowCoord, float shadowBias, float shadowRadius, vec2 shadowMapSize ) {\\n        shadowCoord.xyz /= shadowCoord.w;\\n        float depth = shadowCoord.z + shadowBias;\\n        bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\\n        bool inFrustum = all( inFrustumVec );\\n        bvec2 frustumTestVec = bvec2( inFrustum, depth <= 1.0 );\\n        bool frustumTest = all( frustumTestVec );\\n        if ( frustumTest ) {\\n            #ifdef USE_PCF_SOFT_SHADOW\\n                float texelSize = shadowRadius / shadowMapSize.x;\\n                vec2 poissonDisk[4];\\n                poissonDisk[0] = vec2(-0.94201624, -0.39906216);\\n                poissonDisk[1] = vec2(0.94558609, -0.76890725);\\n                poissonDisk[2] = vec2(-0.094184101, -0.92938870);\\n                poissonDisk[3] = vec2(0.34495938, 0.29387760);\\n                return texture2DCompare( shadowMap, shadowCoord.xy + poissonDisk[0] * texelSize, depth ) * 0.25 +\\n                    texture2DCompare( shadowMap, shadowCoord.xy + poissonDisk[1] * texelSize, depth ) * 0.25 +\\n                    texture2DCompare( shadowMap, shadowCoord.xy + poissonDisk[2] * texelSize, depth ) * 0.25 +\\n                    texture2DCompare( shadowMap, shadowCoord.xy + poissonDisk[3] * texelSize, depth ) * 0.25;\\n            #else\\n                return texture2DCompare( shadowMap, shadowCoord.xy, depth );\\n            #endif\\n        }\\n        return 1.0;\\n    }\\n    float getPointShadow( samplerCube shadowMap, vec3 V, float shadowBias, float shadowRadius, vec2 shadowMapSize, float shadowCameraNear, float shadowCameraFar ) {\\n\\t\\tfloat depth = ( length( V ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\\t\\tdepth += shadowBias;\\n        #ifdef USE_PCF_SOFT_SHADOW\\n            float texelSize = shadowRadius / shadowMapSize.x;\\n            vec3 poissonDisk[4];\\n    \\t\\tpoissonDisk[0] = vec3(-1.0, 1.0, -1.0);\\n    \\t\\tpoissonDisk[1] = vec3(1.0, -1.0, -1.0);\\n    \\t\\tpoissonDisk[2] = vec3(-1.0, -1.0, -1.0);\\n    \\t\\tpoissonDisk[3] = vec3(1.0, -1.0, 1.0);\\n            return textureCubeCompare( shadowMap, normalize(V) + poissonDisk[0] * texelSize, depth ) * 0.25 +\\n                textureCubeCompare( shadowMap, normalize(V) + poissonDisk[1] * texelSize, depth ) * 0.25 +\\n                textureCubeCompare( shadowMap, normalize(V) + poissonDisk[2] * texelSize, depth ) * 0.25 +\\n                textureCubeCompare( shadowMap, normalize(V) + poissonDisk[3] * texelSize, depth ) * 0.25;\\n        #else\\n            return textureCubeCompare( shadowMap, normalize(V), depth);\\n        #endif\\n    }\\n#endif",shadowMap_pars_vert:"#ifdef USE_SHADOW\\n    #ifdef USE_DIRECT_LIGHT\\n        uniform mat4 directionalShadowMatrix[ USE_DIRECT_LIGHT ];\\n        varying vec4 vDirectionalShadowCoord[ USE_DIRECT_LIGHT ];\\n    #endif\\n    #ifdef USE_POINT_LIGHT\\n    #endif\\n    #ifdef USE_SPOT_LIGHT\\n        uniform mat4 spotShadowMatrix[ USE_SPOT_LIGHT ];\\n        varying vec4 vSpotShadowCoord[ USE_SPOT_LIGHT ];\\n    #endif\\n#endif",shadowMap_vert:"#ifdef USE_SHADOW\\n    vec4 worldPosition = u_Model * vec4(transformed, 1.0);\\n    #ifdef USE_DIRECT_LIGHT\\n        for ( int i = 0; i < USE_DIRECT_LIGHT; i ++ ) {\\n            vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\\n        }\\n    #endif\\n    #ifdef USE_POINT_LIGHT\\n    #endif\\n    #ifdef USE_SPOT_LIGHT\\n        for ( int i = 0; i < USE_SPOT_LIGHT; i ++ ) {\\n            vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\\n        }\\n    #endif\\n#endif",skinning_pars_vert:"#ifdef USE_SKINNING\\n    attribute vec4 skinIndex;\\n\\tattribute vec4 skinWeight;\\n    #ifdef BONE_TEXTURE\\n        uniform sampler2D boneTexture;\\n        uniform int boneTextureSize;\\n        mat4 getBoneMatrix( const in float i ) {\\n            float j = i * 4.0;\\n            float x = mod( j, float( boneTextureSize ) );\\n            float y = floor( j / float( boneTextureSize ) );\\n            float dx = 1.0 / float( boneTextureSize );\\n            float dy = 1.0 / float( boneTextureSize );\\n            y = dy * ( y + 0.5 );\\n            vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\\n            vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\\n            vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\\n            vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\\n            mat4 bone = mat4( v1, v2, v3, v4 );\\n            return bone;\\n        }\\n    #else\\n        uniform mat4 boneMatrices[MAX_BONES];\\n        mat4 getBoneMatrix(const in float i) {\\n            mat4 bone = boneMatrices[int(i)];\\n            return bone;\\n        }\\n    #endif\\n#endif",skinning_vert:"#ifdef USE_SKINNING\\n    mat4 boneMatX = getBoneMatrix( skinIndex.x );\\n    mat4 boneMatY = getBoneMatrix( skinIndex.y );\\n    mat4 boneMatZ = getBoneMatrix( skinIndex.z );\\n    mat4 boneMatW = getBoneMatrix( skinIndex.w );\\n    vec4 skinVertex = vec4(transformed, 1.0);\\n    vec4 skinned = vec4( 0.0 );\\n\\tskinned += boneMatX * skinVertex * skinWeight.x;\\n\\tskinned += boneMatY * skinVertex * skinWeight.y;\\n\\tskinned += boneMatZ * skinVertex * skinWeight.z;\\n\\tskinned += boneMatW * skinVertex * skinWeight.w;\\n    transformed = vec3(skinned.xyz / skinned.w);\\n    #if defined(USE_NORMAL) || defined(USE_ENV_MAP)\\n        mat4 skinMatrix = mat4( 0.0 );\\n        skinMatrix += skinWeight.x * boneMatX;\\n        skinMatrix += skinWeight.y * boneMatY;\\n        skinMatrix += skinWeight.z * boneMatZ;\\n        skinMatrix += skinWeight.w * boneMatW;\\n        objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\\n    #endif\\n#endif",specularMap_frag:"float specularStrength;\\n#ifdef USE_SPECULARMAP\\n\\tvec4 texelSpecular = texture2D( specularMap, v_Uv );\\n\\tspecularStrength = texelSpecular.r;\\n#else\\n\\tspecularStrength = 1.0;\\n#endif",specularMap_pars_frag:"#ifdef USE_SPECULARMAP\\n\\tuniform sampler2D specularMap;\\n#endif",spotlight_pars_frag:"struct SpotLight\\n{\\n    vec3 position;\\n    vec4 color;\\n    float intensity;\\n    float distance;\\n    float decay;\\n    float coneCos;\\n    float penumbraCos;\\n    vec3 direction;\\n    int shadow;\\n    float shadowBias;\\n    float shadowRadius;\\n    vec2 shadowMapSize;\\n};\\nuniform SpotLight u_Spot[USE_SPOT_LIGHT];",tbn:"mat3 tbn(vec3 N, vec3 p, vec2 uv) {\\n    vec3 dp1 = dFdx(p.xyz);\\n    vec3 dp2 = dFdy(p.xyz);\\n    vec2 duv1 = dFdx(uv.st);\\n    vec2 duv2 = dFdy(uv.st);\\n    vec3 dp2perp = cross(dp2, N);\\n    vec3 dp1perp = cross(N, dp1);\\n    vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\\n    vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\\n    float invmax = 1.0 / sqrt(max(dot(T,T), dot(B,B)));\\n    return mat3(T * invmax, B * invmax, N);\\n}",transpose:"mat4 transpose(mat4 inMatrix) {\\n    vec4 i0 = inMatrix[0];\\n    vec4 i1 = inMatrix[1];\\n    vec4 i2 = inMatrix[2];\\n    vec4 i3 = inMatrix[3];\\n    mat4 outMatrix = mat4(\\n        vec4(i0.x, i1.x, i2.x, i3.x),\\n        vec4(i0.y, i1.y, i2.y, i3.y),\\n        vec4(i0.z, i1.z, i2.z, i3.z),\\n        vec4(i0.w, i1.w, i2.w, i3.w)\\n    );\\n    return outMatrix;\\n}",tsn:"mat3 tsn(vec3 N, vec3 V, vec2 uv) {\\n    vec3 q0 = dFdx( V.xyz );\\n    vec3 q1 = dFdy( V.xyz );\\n    vec2 st0 = dFdx( uv.st );\\n    vec2 st1 = dFdy( uv.st );\\n    vec3 S = normalize( q0 * st1.t - q1 * st0.t );\\n    vec3 T = normalize( -q0 * st1.s + q1 * st0.s );\\n    mat3 tsn = mat3( S, T, N );\\n    return tsn;\\n}",uv_pars_frag:"#if defined(USE_DIFFUSE_MAP) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(USE_SPECULARMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP)\\n    varying vec2 v_Uv;\\n#endif\\n#ifdef USE_AOMAP\\n    varying vec2 v_Uv2;\\n#endif",uv_pars_vert:"#if defined(USE_DIFFUSE_MAP) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(USE_SPECULARMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP)\\n    attribute vec2 a_Uv;\\n    varying vec2 v_Uv;\\n#endif\\n#ifdef USE_AOMAP\\n    attribute vec2 a_Uv2;\\n    varying vec2 v_Uv2;\\n#endif\\n",uv_vert:"#if defined(USE_DIFFUSE_MAP) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(USE_SPECULARMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP)\\n    v_Uv = a_Uv;\\n#endif\\n#ifdef USE_AOMAP\\n    v_Uv2 = a_Uv2;\\n#endif",viewModelPos_pars_frag:"#if defined(USE_POINT_LIGHT) || defined(USE_SPOT_LIGHT) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(FLAT_SHADED) || defined(USE_PHONG) || defined(USE_PBR) || defined(NUM_CLIPPING_PLANES) \\n    varying vec3 v_ViewModelPos;\\n#endif",viewModelPos_pars_vert:"#if defined(USE_POINT_LIGHT) || defined(USE_SPOT_LIGHT) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(FLAT_SHADED) || defined(USE_PHONG) || defined(USE_PBR)|| defined(NUM_CLIPPING_PLANES)\\n    varying vec3 v_ViewModelPos;\\n#endif",viewModelPos_vert:"#if defined(USE_POINT_LIGHT) || defined(USE_SPOT_LIGHT) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(FLAT_SHADED) || defined(USE_PHONG) || defined(USE_PBR) || defined(NUM_CLIPPING_PLANES)\\n    v_ViewModelPos = (u_View * u_Model * vec4(transformed, 1.0)).xyz;\\n#endif"},zen3d.ShaderLib={basic_frag:"#include <common_frag>\\n#include <uv_pars_frag>\\n#include <color_pars_frag>\\n#include <diffuseMap_pars_frag>\\n#include <envMap_pars_frag>\\n#include <aoMap_pars_frag>\\n#include <fog_pars_frag>\\nvoid main() {\\n    #include <begin_frag>\\n    #include <color_frag>\\n    #include <diffuseMap_frag>\\n    #include <envMap_frag>\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",basic_vert:"#include <common_vert>\\n#include <uv_pars_vert>\\n#include <color_pars_vert>\\n#include <envMap_pars_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    #include <uv_vert>\\n    #include <color_vert>\\n    #include <envMap_vert>\\n}",canvas2d_frag:"#include <common_frag>\\nvarying vec2 v_Uv;\\nuniform sampler2D spriteTexture;\\nvoid main() {\\n    #include <begin_frag>\\n    outColor *= texture2D(spriteTexture, v_Uv);\\n    #include <end_frag>\\n    #include <premultipliedAlpha_frag>\\n}",canvas2d_vert:"#include <common_vert>\\nattribute vec2 a_Uv;\\nvarying vec2 v_Uv;\\nvoid main() {\\n    #include <begin_vert>\\n    #include <pvm_vert>\\n    v_Uv = a_Uv;\\n}",cube_frag:"#include <common_frag>\\nuniform samplerCube cubeMap;\\nvarying vec3 v_ModelPos;\\nvoid main() {\\n    #include <begin_frag>\\n    outColor *= textureCube(cubeMap, v_ModelPos);\\n    #include <end_frag>\\n}",cube_vert:"#include <common_vert>\\nvarying vec3 v_ModelPos;\\nvoid main() {\\n    #include <begin_vert>\\n    #include <pvm_vert>\\n    v_ModelPos = (u_Model * vec4(transformed, 1.0)).xyz;\\n}",depth_frag:"#include <common_frag>\\n#include <packing>\\nvoid main() {\\n    #ifdef DEPTH_PACKING_RGBA\\n        gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\\n    #else\\n        gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), u_Opacity );\\n    #endif\\n}",depth_vert:"#include <common_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n}",distance_frag:"#include <common_frag>\\nuniform float nearDistance;\\nuniform float farDistance;\\nvarying vec3 v_ModelPos;\\n#include <packing>\\nvoid main() {\\n    float dist = length( v_ModelPos - u_CameraPosition );\\n\\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\\n\\tdist = saturate( dist );\\n    gl_FragColor = packDepthToRGBA(dist);\\n}",distance_vert:"#include <common_vert>\\nvarying vec3 v_ModelPos;\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    v_ModelPos = (u_Model * vec4(transformed, 1.0)).xyz;\\n}",lambert_frag:"#include <common_frag>\\nuniform vec3 emissive;\\n#include <uv_pars_frag>\\n#include <color_pars_frag>\\n#include <diffuseMap_pars_frag>\\n#include <normalMap_pars_frag>\\n#include <bumpMap_pars_frag>\\n#include <light_pars_frag>\\n#include <normal_pars_frag>\\n#include <viewModelPos_pars_frag>\\n#include <bsdfs>\\n#include <envMap_pars_frag>\\n#include <aoMap_pars_frag>\\n#include <shadowMap_pars_frag>\\n#include <fog_pars_frag>\\n#include <emissiveMap_pars_frag>\\n#include <clippingPlanes_pars_frag>\\nvoid main() {\\n    #include <clippingPlanes_frag>\\n    #include <begin_frag>\\n    #include <color_frag>\\n    #include <diffuseMap_frag>\\n    #include <normal_frag>\\n    #include <light_frag>\\n    #include <envMap_frag>\\n    #include <shadowMap_frag>\\n    vec3 totalEmissiveRadiance = emissive;\\n    #include <emissiveMap_frag>\\n    outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",lambert_vert:"#include <common_vert>\\n#include <normal_pars_vert>\\n#include <uv_pars_vert>\\n#include <color_pars_vert>\\n#include <viewModelPos_pars_vert>\\n#include <envMap_pars_vert>\\n#include <shadowMap_pars_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    #include <normal_vert>\\n    #include <uv_vert>\\n    #include <color_vert>\\n    #include <viewModelPos_vert>\\n    #include <envMap_vert>\\n    #include <shadowMap_vert>\\n}",linedashed_frag:"#include <common_frag>\\n#include <fog_pars_frag>\\nuniform float dashSize;\\nuniform float totalSize;\\nvarying float vLineDistance;\\nvoid main() {\\n    if ( mod( vLineDistance, totalSize ) > dashSize ) {\\n\\t\\tdiscard;\\n\\t}\\n    #include <begin_frag>\\n    #include <end_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",linedashed_vert:"#include <common_vert>\\nuniform float scale;\\nattribute float lineDistance;\\nvarying float vLineDistance;\\nvoid main() {\\n    vLineDistance = scale * lineDistance;\\n    vec3 transformed = vec3(a_Position);\\n    #include <pvm_vert>\\n}",particle_frag:"float scaleLinear(float value, vec2 valueDomain) {\\n    return (value - valueDomain.x) / (valueDomain.y - valueDomain.x);\\n}\\nfloat scaleLinear(float value, vec2 valueDomain, vec2 valueRange) {\\n    return mix(valueRange.x, valueRange.y, scaleLinear(value, valueDomain));\\n}\\nvarying vec4 vColor;\\nvarying float lifeLeft;\\nuniform sampler2D tSprite;\\nvoid main() {\\n    float alpha = 0.;\\n    if( lifeLeft > .995 ) {\\n        alpha = scaleLinear( lifeLeft, vec2(1., .995), vec2(0., 1.));\\n    } else {\\n        alpha = lifeLeft * .75;\\n    }\\n    vec4 tex = texture2D( tSprite, gl_PointCoord );\\n    gl_FragColor = vec4( vColor.rgb * tex.a, alpha * tex.a );\\n}",particle_vert:"const vec4 bitSh = vec4(256. * 256. * 256., 256. * 256., 256., 1.);\\nconst vec4 bitMsk = vec4(0.,vec3(1./256.0));\\nconst vec4 bitShifts = vec4(1.) / bitSh;\\n#define FLOAT_MAX\\t1.70141184e38\\n#define FLOAT_MIN\\t1.17549435e-38\\nlowp vec4 encode_float(highp float v) {\\n    highp float av = abs(v);\\n    if(av < FLOAT_MIN) {\\n        return vec4(0.0, 0.0, 0.0, 0.0);\\n    } else if(v > FLOAT_MAX) {\\n        return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\\n    } else if(v < -FLOAT_MAX) {\\n        return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\\n    }\\n    highp vec4 c = vec4(0,0,0,0);\\n    highp float e = floor(log2(av));\\n    highp float m = av * pow(2.0, -e) - 1.0;\\n    c[1] = floor(128.0 * m);\\n    m -= c[1] / 128.0;\\n    c[2] = floor(32768.0 * m);\\n    m -= c[2] / 32768.0;\\n    c[3] = floor(8388608.0 * m);\\n    highp float ebias = e + 127.0;\\n    c[0] = floor(ebias / 2.0);\\n    ebias -= c[0] * 2.0;\\n    c[1] += floor(ebias) * 128.0;\\n    c[0] += 128.0 * step(0.0, -v);\\n    return c / 255.0;\\n}\\nvec4 pack(const in float depth)\\n{\\n    const vec4 bit_shift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\\n    const vec4 bit_mask\\t= vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\\n    vec4 res = mod(depth*bit_shift*vec4(255), vec4(256))/vec4(255);\\n    res -= res.xxyz * bit_mask;\\n    return res;\\n}\\nfloat unpack(const in vec4 rgba_depth)\\n{\\n    const vec4 bit_shift = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\\n    float depth = dot(rgba_depth, bit_shift);\\n    return depth;\\n}\\nuniform float uTime;\\nuniform float uScale;\\nuniform sampler2D tNoise;\\nuniform mat4 u_Projection;\\nuniform mat4 u_View;\\nuniform mat4 u_Model;\\nattribute vec4 particlePositionsStartTime;\\nattribute vec4 particleVelColSizeLife;\\nvarying vec4 vColor;\\nvarying float lifeLeft;\\nvoid main() {\\n    vColor = encode_float( particleVelColSizeLife.y );\\n    vec4 velTurb = encode_float( particleVelColSizeLife.x );\\n    vec3 velocity = vec3( velTurb.xyz );\\n    float turbulence = velTurb.w;\\n    vec3 newPosition;\\n    float timeElapsed = uTime - particlePositionsStartTime.a;\\n    lifeLeft = 1. - (timeElapsed / particleVelColSizeLife.w);\\n    gl_PointSize = ( uScale * particleVelColSizeLife.z ) * lifeLeft;\\n    velocity.x = ( velocity.x - .5 ) * 3.;\\n    velocity.y = ( velocity.y - .5 ) * 3.;\\n    velocity.z = ( velocity.z - .5 ) * 3.;\\n    newPosition = particlePositionsStartTime.xyz + ( velocity * 10. ) * ( uTime - particlePositionsStartTime.a );\\n    vec3 noise = texture2D( tNoise, vec2( newPosition.x * .015 + (uTime * .05), newPosition.y * .02 + (uTime * .015) )).rgb;\\n    vec3 noiseVel = ( noise.rgb - .5 ) * 30.;\\n    newPosition = mix(newPosition, newPosition + vec3(noiseVel * ( turbulence * 5. ) ), (timeElapsed / particleVelColSizeLife.a) );\\n    if( velocity.y > 0. && velocity.y < .05 ) {\\n        lifeLeft = 0.;\\n    }\\n    if( velocity.x < -1.45 ) {\\n        lifeLeft = 0.;\\n    }\\n    if( timeElapsed > 0. ) {\\n        gl_Position = u_Projection * u_View * u_Model * vec4( newPosition, 1.0 );\\n    } else {\\n        gl_Position = u_Projection * u_View * u_Model * vec4( particlePositionsStartTime.xyz, 1.0 );\\n        lifeLeft = 0.;\\n        gl_PointSize = 0.;\\n    }\\n}",pbr_frag:"#include <common_frag>\\nuniform float u_Metalness;\\n#ifdef USE_METALNESSMAP\\n\\tuniform sampler2D metalnessMap;\\n#endif\\nuniform float u_Roughness;\\n#ifdef USE_ROUGHNESSMAP\\n\\tuniform sampler2D roughnessMap;\\n#endif\\nuniform vec3 emissive;\\n#include <uv_pars_frag>\\n#include <color_pars_frag>\\n#include <diffuseMap_pars_frag>\\n#include <normalMap_pars_frag>\\n#include <bumpMap_pars_frag>\\n#include <envMap_pars_frag>\\n#include <aoMap_pars_frag>\\n#include <light_pars_frag>\\n#include <normal_pars_frag>\\n#include <viewModelPos_pars_frag>\\n#include <bsdfs>\\n#include <shadowMap_pars_frag>\\n#include <fog_pars_frag>\\n#include <emissiveMap_pars_frag>\\n#include <clippingPlanes_pars_frag>\\nvoid main() {\\n    #include <clippingPlanes_frag>\\n    #include <begin_frag>\\n    #include <color_frag>\\n    #include <diffuseMap_frag>\\n    #include <normal_frag>\\n    #include <specularMap_frag>\\n    float roughnessFactor = u_Roughness;\\n    #ifdef USE_ROUGHNESSMAP\\n    \\tvec4 texelRoughness = texture2D( roughnessMap, v_Uv );\\n    \\troughnessFactor *= texelRoughness.g;\\n    #endif\\n    float metalnessFactor = u_Metalness;\\n    #ifdef USE_METALNESSMAP\\n    \\tvec4 texelMetalness = texture2D( metalnessMap, v_Uv );\\n    \\tmetalnessFactor *= texelMetalness.b;\\n    #endif\\n    #include <light_frag>\\n    #include <shadowMap_frag>\\n    vec3 totalEmissiveRadiance = emissive;\\n    #include <emissiveMap_frag>\\n    outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",pbr_vert:"#include <common_vert>\\n#include <normal_pars_vert>\\n#include <uv_pars_vert>\\n#include <color_pars_vert>\\n#include <viewModelPos_pars_vert>\\n#include <envMap_pars_vert>\\n#include <shadowMap_pars_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    #include <normal_vert>\\n    #include <uv_vert>\\n    #include <color_vert>\\n    #include <viewModelPos_vert>\\n    #include <envMap_vert>\\n    #include <shadowMap_vert>\\n}",phong_frag:"#include <common_frag>\\nuniform float u_Specular;\\nuniform vec4 u_SpecularColor;\\n#include <specularMap_pars_frag>\\nuniform vec3 emissive;\\n#include <uv_pars_frag>\\n#include <color_pars_frag>\\n#include <diffuseMap_pars_frag>\\n#include <normalMap_pars_frag>\\n#include <bumpMap_pars_frag>\\n#include <light_pars_frag>\\n#include <normal_pars_frag>\\n#include <viewModelPos_pars_frag>\\n#include <bsdfs>\\n#include <envMap_pars_frag>\\n#include <aoMap_pars_frag>\\n#include <shadowMap_pars_frag>\\n#include <fog_pars_frag>\\n#include <emissiveMap_pars_frag>\\n#include <clippingPlanes_pars_frag>\\nvoid main() {\\n    #include <clippingPlanes_frag>\\n    #include <begin_frag>\\n    #include <color_frag>\\n    #include <diffuseMap_frag>\\n    #include <normal_frag>\\n    #include <specularMap_frag>\\n    #include <light_frag>\\n    #include <envMap_frag>\\n    #include <shadowMap_frag>\\n    vec3 totalEmissiveRadiance = emissive;\\n    #include <emissiveMap_frag>\\n    outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",phong_vert:"#include <common_vert>\\n#include <normal_pars_vert>\\n#include <uv_pars_vert>\\n#include <color_pars_vert>\\n#include <viewModelPos_pars_vert>\\n#include <envMap_pars_vert>\\n#include <shadowMap_pars_vert>\\n#include <skinning_pars_vert>\\nvoid main() {\\n    #include <begin_vert>\\n    #include <skinning_vert>\\n    #include <pvm_vert>\\n    #include <normal_vert>\\n    #include <uv_vert>\\n    #include <color_vert>\\n    #include <viewModelPos_vert>\\n    #include <envMap_vert>\\n    #include <shadowMap_vert>\\n}",point_frag:"#include <common_frag>\\n#include <diffuseMap_pars_frag>\\n#include <fog_pars_frag>\\nvoid main() {\\n    #include <begin_frag>\\n    #ifdef USE_DIFFUSE_MAP\\n        outColor *= texture2D(texture, vec2(gl_PointCoord.x, 1.0 - gl_PointCoord.y));\\n    #endif\\n    #include <end_frag>\\n    #include <encodings_frag>\\n    #include <premultipliedAlpha_frag>\\n    #include <fog_frag>\\n}",point_vert:"#include <common_vert>\\nuniform float u_PointSize;\\nuniform float u_PointScale;\\nvoid main() {\\n    #include <begin_vert>\\n    #include <pvm_vert>\\n    vec4 mvPosition = u_View * u_Model * vec4(transformed, 1.0);\\n    #ifdef USE_SIZEATTENUATION\\n        gl_PointSize = u_PointSize * ( u_PointScale / - mvPosition.z );\\n    #else\\n        gl_PointSize = u_PointSize;\\n    #endif\\n}",sprite_frag:"uniform vec3 color;\\nuniform sampler2D map;\\nuniform float opacity;\\nuniform int fogType;\\nuniform vec3 fogColor;\\nuniform float fogDensity;\\nuniform float fogNear;\\nuniform float fogFar;\\nuniform float alphaTest;\\nvarying vec2 vUV;\\nvoid main() {\\n    vec4 texture = texture2D( map, vUV );\\n    if ( texture.a < alphaTest ) discard;\\n    gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\\n    if ( fogType > 0 ) {\\n        float depth = gl_FragCoord.z / gl_FragCoord.w;\\n        float fogFactor = 0.0;\\n        if ( fogType == 1 ) {\\n            fogFactor = smoothstep( fogNear, fogFar, depth );\\n        } else {\\n            \\n            fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\\n            fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\\n        }\\n        gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\\n    }\\n}",sprite_vert:"uniform mat4 modelMatrix;\\nuniform mat4 viewMatrix;\\nuniform mat4 projectionMatrix;\\nuniform float rotation;\\nuniform vec2 scale;\\nuniform vec2 uvOffset;\\nuniform vec2 uvScale;\\nattribute vec2 position;\\nattribute vec2 uv;\\nvarying vec2 vUV;\\nvoid main() {\\n    vUV = uvOffset + uv * uvScale;\\n    vec2 alignedPosition = position * scale;\\n    vec2 rotatedPosition;\\n    rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\\n    rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\\n    vec4 finalPosition;\\n    finalPosition = viewMatrix * modelMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\\n    finalPosition.xy += rotatedPosition;\\n    finalPosition = projectionMatrix * finalPosition;\\n    gl_Position = finalPosition;\\n}"},function(){var y={};var E=zen3d.MATERIAL_TYPE,i=zen3d.TEXEL_ENCODING_TYPE,f=zen3d.ENVMAP_COMBINE_TYPE;function T(e,t){var n;return e?e.encoding&&(n=e.encoding):n=i.LINEAR,n===i.LINEAR&&t&&(n=i.GAMMA),n}function _(e){switch(e){case i.LINEAR:return["Linear","( value )"];case i.SRGB:return["sRGB","( value )"];case i.RGBE:return["RGBE","( value )"];case i.RGBM7:return["RGBM","( value, 7.0 )"];case i.RGBM16:return["RGBM","( value, 16.0 )"];case i.RGBD:return["RGBD","( value, 256.0 )"];case i.GAMMA:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:console.error("unsupported encoding: "+e)}}function v(e,t){var n=_(t);return"vec4 "+e+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function x(e,t,n,i){var r=zen3d.ShaderLib[t.materialType+"_vert"]||t.vertexShader||zen3d.ShaderLib.basic_vert,a=zen3d.ShaderLib[t.materialType+"_frag"]||t.fragmentShader||zen3d.ShaderLib.basic_frag;r=m(r),a=m(a);var o,s,u,h=[""],c=["#define PI 3.14159265359","#define EPSILON 1e-6","float pow2( const in float x ) { return x*x; }","#define LOG2 1.442695","#define RECIPROCAL_PI 0.31830988618","#define saturate(a) clamp( a, 0.0, 1.0 )","#define whiteCompliment(a) ( 1.0 - saturate( a ) )"];switch(t.materialType){case E.CUBE:case E.CANVAS2D:case E.SPRITE:case E.PARTICLE:case E.SHADER:break;case E.LAMBERT:case E.PHONG:case E.PBR:c.push(t.useRoughnessMap?"#define USE_ROUGHNESSMAP":""),c.push(t.useMetalnessMap?"#define USE_METALNESSMAP":"");case E.POINT:h.push(0<t.pointLightNum?"#define USE_POINT_LIGHT "+t.pointLightNum:""),h.push(0<t.spotLightNum?"#define USE_SPOT_LIGHT "+t.spotLightNum:""),h.push(0<t.directLightNum?"#define USE_DIRECT_LIGHT "+t.directLightNum:""),h.push(0<t.ambientLightNum?"#define USE_AMBIENT_LIGHT "+t.ambientLightNum:""),h.push(0<t.pointLightNum||0<t.directLightNum||0<t.ambientLightNum||0<t.spotLightNum?"#define USE_LIGHT":""),h.push(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum?"#define USE_NORMAL":""),h.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useNormalMap?"#define USE_NORMAL_MAP":""),h.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useBumpMap?"#define USE_BUMPMAP":""),h.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useSpecularMap?"#define USE_SPECULARMAP":""),h.push(t.useEmissiveMap?"#define USE_EMISSIVEMAP":""),h.push(t.useShadow?"#define USE_SHADOW":""),h.push(t.materialType==E.LAMBERT?"#define USE_LAMBERT":""),h.push(t.materialType==E.PHONG?"#define USE_PHONG":""),h.push(t.materialType==E.PBR?"#define USE_PBR":""),h.push(t.flipSided?"#define FLIP_SIDED":""),h.push(0<t.numClippingPlanes?"#define NUM_CLIPPING_PLANES "+t.numClippingPlanes:""),c.push(0<t.pointLightNum?"#define USE_POINT_LIGHT "+t.pointLightNum:""),c.push(0<t.spotLightNum?"#define USE_SPOT_LIGHT "+t.spotLightNum:""),c.push(0<t.directLightNum?"#define USE_DIRECT_LIGHT "+t.directLightNum:""),c.push(0<t.ambientLightNum?"#define USE_AMBIENT_LIGHT "+t.ambientLightNum:""),c.push(0<t.pointLightNum||0<t.directLightNum||0<t.ambientLightNum||0<t.spotLightNum?"#define USE_LIGHT":""),c.push(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum?"#define USE_NORMAL":""),c.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useNormalMap?"#define USE_NORMAL_MAP":""),c.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useBumpMap?"#define USE_BUMPMAP":""),c.push((0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useSpecularMap?"#define USE_SPECULARMAP":""),c.push(t.useEmissiveMap?"#define USE_EMISSIVEMAP":""),c.push(t.useShadow?"#define USE_SHADOW":""),c.push(t.usePCFSoftShadow?"#define USE_PCF_SOFT_SHADOW":""),c.push(t.flatShading?"#define FLAT_SHADED":""),c.push(t.materialType==E.LAMBERT?"#define USE_LAMBERT":""),c.push(t.materialType==E.PHONG?"#define USE_PHONG":""),c.push(t.materialType==E.PBR?"#define USE_PBR":""),c.push(t.doubleSided?"#define DOUBLE_SIDED":""),c.push(t.envMap&&t.useShaderTextureLOD?"#define TEXTURE_LOD_EXT":""),c.push(0<t.numClippingPlanes?"#define NUM_CLIPPING_PLANES "+t.numClippingPlanes:"");case E.BASIC:if(h.push(t.useDiffuseMap?"#define USE_DIFFUSE_MAP":""),h.push(t.useEnvMap?"#define USE_ENV_MAP":""),h.push(t.useVertexColors?"#define USE_VCOLOR":""),h.push(t.sizeAttenuation?"#define USE_SIZEATTENUATION":""),h.push(t.useAOMap?"#define USE_AOMAP":""),c.push(t.useDiffuseMap?"#define USE_DIFFUSE_MAP":""),c.push(t.useEnvMap?"#define USE_ENV_MAP":""),c.push(t.useVertexColors?"#define USE_VCOLOR":""),t.useEnvMap){var d="";switch(t.envMapCombine){case f.MULTIPLY:d="ENVMAP_BLENDING_MULTIPLY";break;case f.MIX:d="ENVMAP_BLENDING_MIX";break;case f.ADD:d="ENVMAP_BLENDING_ADD"}c.push("#define "+d)}c.push(t.useAOMap?"#define USE_AOMAP":"");case E.LINE:case E.LINE_LOOP:c.push(zen3d.ShaderChunk.encodings_pars_frag),c.push("#define GAMMA_FACTOR "+t.gammaFactor),c.push(v("mapTexelToLinear",t.diffuseMapEncoding)),c.push(v("envMapTexelToLinear",t.envMapEncoding)),c.push(v("emissiveMapTexelToLinear",t.emissiveMapEncoding)),c.push((o="linearToOutputTexel",s=t.outputEncoding,u=_(s),"vec4 "+o+"( vec4 value ) { return LinearTo"+u[0]+u[1]+"; }")),c.push(t.premultipliedAlpha?"#define USE_PREMULTIPLIED_ALPHA":"");case E.DEPTH:c.push(t.packDepthToRGBA?"#define DEPTH_PACKING_RGBA":"");case E.DISTANCE:h.push(t.useSkinning?"#define USE_SKINNING":""),h.push(0<t.bonesNum?"#define MAX_BONES "+t.bonesNum:""),h.push(t.useVertexTexture?"#define BONE_TEXTURE":"");case E.LINE_DASHED:c.push(t.fog?"#define USE_FOG":""),c.push(t.fogExp2?"#define USE_EXP2_FOG":"")}var l=["precision "+t.precision+" float;","precision "+t.precision+" int;",h.join("\\n"),r].join("\\n"),p=["#extension GL_OES_standard_derivatives : enable",t.useShaderTextureLOD&&t.useEnvMap?"#extension GL_EXT_shader_texture_lod : enable":"","precision "+t.precision+" float;","precision "+t.precision+" int;",c.join("\\n"),a].join("\\n");return new zen3d.WebGLProgram(e,l,p)}var m=function(e){return e.replace(/#include +<([\\w\\d.]+)>/g,function(e,t){var n=zen3d.ShaderChunk[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return m(n)})};zen3d.getProgram=function(e,t,n,i,r){var a=e.gl,o=e.capabilities,s=(n=n||i.material,r?r.lights:null),u=r?r.fog:null,h=r?r.clippingPlanes:null,c={};c.precision=o.maxPrecision,c.materialType=n.type;var d=e.state.currentRenderTarget;switch(n.type){case E.PBR:c.useRoughnessMap=!!n.roughnessMap,c.useMetalnessMap=!!n.metalnessMap;case E.BASIC:case E.LAMBERT:case E.PHONG:case E.POINT:case E.LINE:case E.LINE_LOOP:c.gammaFactor=t.gammaFactor,c.outputEncoding=T(d.texture||null,t.gammaOutput),c.diffuseMapEncoding=T(n.diffuseMap,t.gammaInput),c.envMapEncoding=T(n.envMap,t.gammaInput),c.emissiveMapEncoding=T(n.emissiveMap,t.gammaInput),c.useShaderTextureLOD=!!o.shaderTextureLOD,c.useVertexColors=n.vertexColors,c.numClippingPlanes=h?h.length:0,c.useAOMap=!!n.aoMap;case E.CUBE:case E.LINE_DASHED:c.useDiffuseMap=!!n.diffuseMap,c.useNormalMap=!!n.normalMap,c.useBumpMap=!!n.bumpMap,c.useSpecularMap=!!n.specularMap,c.useEnvMap=!!n.envMap,c.envMapCombine=n.envMapCombine,c.useEmissiveMap=!!n.emissiveMap,c.useDiffuseColor=!n.diffuseMap,c.ambientLightNum=s?s.ambientsNum:0,c.directLightNum=s?s.directsNum:0,c.pointLightNum=s?s.pointsNum:0,c.spotLightNum=s?s.spotsNum:0,c.flatShading=n.shading===zen3d.SHADING_TYPE.FLAT_SHADING,c.useShadow=i.receiveShadow,c.usePCFSoftShadow=i.shadowType===zen3d.SHADOW_TYPE.PCF_SOFT,c.premultipliedAlpha=n.premultipliedAlpha,c.fog=!!u,c.fogExp2=!!u&&u.fogType===zen3d.FOG_TYPE.EXP2,c.sizeAttenuation=n.sizeAttenuation,c.doubleSided=n.side===zen3d.DRAW_SIDE.DOUBLE,c.flipSided=n.side===zen3d.DRAW_SIDE.BACK;case E.DEPTH:c.packDepthToRGBA=n.packToRGBA;case E.DISTANCE:var l=i.type===zen3d.OBJECT_TYPE.SKINNED_MESH&&i.skeleton,p=o.maxVertexUniformVectors,f=0<o.maxVertexTextures&&o.floatTextures,_=0;f?_=1024:p<16*(_=i.skeleton?i.skeleton.bones.length:0)&&(console.warn("Program: too many bones ("+_+"), current cpu only support "+Math.floor(p/16)+" bones!!"),_=Math.floor(p/16)),c.useSkinning=l,c.bonesNum=_,c.useVertexTexture=f;break;case E.SHADER:c.vertexShader=n.vertexShader,c.fragmentShader=n.fragmentShader;case E.CANVAS2D:case E.PARTICLE:case E.SPRITE:}var v,m=function(e){var t="";for(var n in e)t+=e[n]+"_";return t}(c),g=y;return g[m]?v=g[m]:(v=x(a,c),g[m]=v),v}}(),function(){var e=function(){this.camera=new zen3d.Camera,this.targets=[new zen3d.Vector3(1,0,0),new zen3d.Vector3(-1,0,0),new zen3d.Vector3(0,1,0),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,0,1),new zen3d.Vector3(0,0,-1)],this.ups=[new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,0,1),new zen3d.Vector3(0,0,-1),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,-1,0)],this.camera.setPerspective(.5*Math.PI,1,1,1e3),this.position=new zen3d.Vector3,this.lookTarget=new zen3d.Vector3,this.renderTarget=new zen3d.RenderTargetCube(512,512),this.renderTexture=this.renderTarget.texture,this.renderTexture.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_LINEAR,this.shadowMapPass=new zen3d.ShadowMapPass,this.forwardPass=new zen3d.ForwardPass,this.shadowAutoUpdate=!0,this.shadowNeedsUpdate=!1};e.prototype.render=function(e,t){this.camera.position.copy(this.position);for(var n=0;n<6;n++)this.lookTarget.set(this.targets[n].x+this.camera.position.x,this.targets[n].y+this.camera.position.y,this.targets[n].z+this.camera.position.z),this.camera.setLookAt(this.lookTarget,this.ups[n]),this.camera.updateMatrix(),t.update(this.camera),(this.shadowAutoUpdate||this.shadowNeedsUpdate)&&(this.shadowMapPass.render(e,t),this.shadowNeedsUpdate=!1),this.renderTarget.activeCubeFace=n,e.texture.setRenderTarget(this.renderTarget),e.state.clearColor(0,0,0,0),e.clear(!0,!0,!0),this.forwardPass.render(e,t),e.texture.updateRenderTargetMipmap(this.renderTarget)},zen3d.EnvironmentMapPass=e}(),function(){var v=zen3d.RENDER_LAYER,e=(zen3d.LAYER_RENDER_LIST,function(){this.depthMaterial=new zen3d.DepthMaterial,this.depthMaterial.packToRGBA=!0,this.distanceMaterial=new zen3d.DistanceMaterial});e.prototype.render=function(e,t){var n=e.gl,i=e.state,r=i.states[n.STENCIL_TEST];r&&i.disable(n.STENCIL_TEST);for(var a=t.cache.lights.shadows,o=0;o<a.length;o++)for(var s=a[o],u=s.shadow,h=u.camera,c=u.renderTarget,d=s.lightType==zen3d.LIGHT_TYPE.POINT,l=d?6:1,p=t.cache.renderLists,f=0;f<l;f++){d?(u.update(s,f),c.activeCubeFace=f):u.update(s),e.texture.setRenderTarget(c),i.clearColor(1,1,1,1),e.clear(!0,!0);var _=d?this.distanceMaterial:this.depthMaterial;_.uniforms=_.uniforms||{},_.uniforms.nearDistance=u.cameraNear,_.uniforms.farDistance=u.cameraFar,e.renderPass(p[v.DEFAULT],h,{getMaterial:function(e){return _.side=e.material.side,_},ifRender:function(e){return e.object.castShadow}})}r&&i.enable(n.STENCIL_TEST)},zen3d.ShadowMapPass=e}(),function(){var o=zen3d.LAYER_RENDER_LIST,e=function(){};e.prototype.render=function(e,t){for(var n=t.cache.camera,i=t.cache.renderLists,r=0;r<o.length;r++){var a=o[r];e.renderPass(i[a],n,{getMaterial:function(e){return t.overrideMaterial||e.material},cache:t.cache})}},zen3d.ForwardPass=e}(),function(){var e=function(e,t){this.backRenderTarget=new zen3d.RenderTargetBack(e);var n=e.getContext("webgl",t||{antialias:!0,alpha:!1,stencil:!0});this.glCore=new zen3d.WebGLCore(n),this.autoClear=!0,this.performance=new zen3d.Performance,this.shadowMapPass=new zen3d.ShadowMapPass,this.forwardPass=new zen3d.ForwardPass,this.shadowAutoUpdate=!0,this.shadowNeedsUpdate=!1};e.prototype.render=function(e,t,n,i){var r=this.performance;r.updateFps(),r.startCounter("render",60),e.update(t),r.startCounter("renderShadow",60),(this.shadowAutoUpdate||this.shadowNeedsUpdate)&&(this.shadowMapPass.render(this.glCore,e),this.shadowNeedsUpdate=!1),r.endCounter("renderShadow"),void 0===n&&(n=this.backRenderTarget),this.glCore.texture.setRenderTarget(n),(this.autoClear||i)&&(this.glCore.state.clearColor(0,0,0,0),this.glCore.clear(!0,!0,!0)),r.startCounter("renderList",60),this.forwardPass.render(this.glCore,e),r.endCounter("renderList"),n.texture&&this.glCore.texture.updateRenderTargetMipmap(n),this.performance.endCounter("render")},zen3d.Renderer=e}(),function(){var T=zen3d.OBJECT_TYPE,x=zen3d.LIGHT_TYPE,M=zen3d.RENDER_LAYER,n=zen3d.LAYER_RENDER_LIST,t=function(e,t){return e.z-t.z},i=function(e,t){return t.z-e.z},r={};function w(e){if(void 0!==r[e.uuid])return r[e.uuid];var t;switch(e.lightType){case x.DIRECT:t={direction:new Float32Array(3),color:new Float32Array([0,0,0,1]),shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Float32Array(2)};break;case x.POINT:t={position:new Float32Array(3),color:new Float32Array([0,0,0,1]),distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Float32Array(2),shadowCameraNear:1,shadowCameraFar:1e3};break;case x.SPOT:t={position:new Float32Array(3),direction:new Float32Array(3),color:new Float32Array([0,0,0,1]),distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Float32Array(2)}}return r[e.uuid]=t}var e=function(){for(var e={},t=0;t<n.length;t++)e[n[t]]=new Array;this.renderLists=e,this.shadowObjects=new Array,this.lights={ambient:new Float32Array([0,0,0,1]),directional:[],directionalShadowMap:[],directionalShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],shadows:[],ambientsNum:0,directsNum:0,pointsNum:0,spotsNum:0,shadowsNum:0,totalNum:0},this.camera=null,this.fog=null,this.clippingPlanes=null},S=new zen3d.Vector3,z=new zen3d.Frustum,A=new zen3d.Matrix4,b=new zen3d.Sphere;e.prototype.cacheScene=function(e,t){this.camera=t,this.fog=e.fog,this.clippingPlanes=e.clippingPlanes,this.cacheObject(e)},e.prototype.cacheObject=function(e){var t=this.camera;switch(e.type){case T.POINT:case T.LINE:case T.LINE_LOOP:case T.LINE_SEGMENTS:case T.MESH:case T.SKINNED_MESH:if(e.frustumCulled)if(b.copy(e.geometry.boundingSphere).applyMatrix4(e.worldMatrix),A.multiplyMatrices(t.projectionMatrix,t.viewMatrix),z.setFromMatrix(A),!z.intersectsSphere(b))break;S.setFromMatrixPosition(e.worldMatrix),S.applyMatrix4(t.viewMatrix).applyMatrix4(t.projectionMatrix);var n=e.material;if(Array.isArray(n))for(var i=e.geometry.groups,r=0;r<i.length;r++){var a=i[r],o=n[a.materialIndex];o&&(this.renderLists[o.transparent?M.TRANSPARENT:M.DEFAULT].push({object:e,geometry:e.geometry,material:o,z:S.z,group:a}),e.castShadow&&this.shadowObjects.push({object:e,geometry:e.geometry,material:o,z:S.z,group:a}))}else this.renderLists[n.transparent?M.TRANSPARENT:M.DEFAULT].push({object:e,geometry:e.geometry,material:e.material,z:S.z}),e.castShadow&&this.shadowObjects.push({object:e,geometry:e.geometry,material:e.material,z:S.z});break;case T.CANVAS2D:if(e.frustumCulled)if(b.copy(e.geometry.boundingSphere).applyMatrix4(e.worldMatrix),A.multiplyMatrices(t.projectionMatrix,t.viewMatrix),z.setFromMatrix(A),!z.intersectsSphere(b))break;S.setFromMatrixPosition(e.worldMatrix),S.applyMatrix4(t.viewMatrix).applyMatrix4(t.projectionMatrix),this.renderLists[M.CANVAS2D].push({object:e,geometry:e.geometry,material:e.material,z:S.z});break;case T.SPRITE:if(e.frustumCulled)if(b.center.set(0,0,0),b.radius=.7071067811865476,b.applyMatrix4(e.worldMatrix),A.multiplyMatrices(t.projectionMatrix,t.viewMatrix),z.setFromMatrix(A),!z.intersectsSphere(b))break;S.setFromMatrixPosition(e.worldMatrix),S.applyMatrix4(t.viewMatrix).applyMatrix4(t.projectionMatrix),this.renderLists[M.SPRITE].push({object:e,geometry:e.geometry,material:e.material,z:S.z});break;case T.PARTICLE:S.setFromMatrixPosition(e.worldMatrix),S.applyMatrix4(t.viewMatrix).applyMatrix4(t.projectionMatrix),this.renderLists[M.PARTICLE].push({object:e,geometry:e.geometry,material:e.material,z:S.z});break;case T.LIGHT:var s=this.lights;if(e.lightType==x.AMBIENT){var u=e.intensity,h=e.color;s.ambient[0]+=h.r*u,s.ambient[1]+=h.g*u,s.ambient[2]+=h.b*u,s.ambientsNum++}else if(e.lightType==x.DIRECT){u=e.intensity,h=e.color;(v=w(e)).color[0]=h.r*u,v.color[1]=h.g*u,v.color[2]=h.b*u;var c=S;if(e.getWorldDirection(c),c.transformDirection(t.viewMatrix),v.direction[0]=c.x,v.direction[1]=c.y,v.direction[2]=c.z,e.castShadow?(v.shadow=!0,v.shadowBias=e.shadow.bias,v.shadowRadius=e.shadow.radius,v.shadowMapSize[0]=e.shadow.mapSize.x,v.shadowMapSize[1]=e.shadow.mapSize.y):v.shadow=!1,e.castShadow){var d=16*(s.directsNum+1);if(s.directionalShadowMatrix.length<d){var l=s.directionalShadowMatrix;s.directionalShadowMatrix=new Float32Array(d),s.directionalShadowMatrix.set(l)}s.directionalShadowMatrix.set(e.shadow.matrix.elements,16*s.directsNum),s.directionalShadowMap[s.directsNum]=e.shadow.map}s.directional[s.directsNum]=v,s.directsNum++}else if(e.lightType==x.POINT){u=e.intensity,h=e.color;var p=e.distance,f=e.decay;(v=w(e)).color[0]=h.r*u,v.color[1]=h.g*u,v.color[2]=h.b*u,v.distance=p,v.decay=f;var _=S.setFromMatrixPosition(e.worldMatrix).applyMatrix4(t.viewMatrix);if(v.position[0]=_.x,v.position[1]=_.y,v.position[2]=_.z,e.castShadow?(v.shadow=!0,v.shadowBias=e.shadow.bias,v.shadowRadius=e.shadow.radius,v.shadowMapSize[0]=e.shadow.mapSize.x,v.shadowMapSize[1]=e.shadow.mapSize.y,v.shadowCameraNear=e.shadow.cameraNear,v.shadowCameraFar=e.shadow.cameraFar):v.shadow=!1,e.castShadow){d=16*(s.pointsNum+1);if(s.pointShadowMatrix.length<d){l=s.pointShadowMatrix;s.pointShadowMatrix=new Float32Array(d),s.pointShadowMatrix.set(l)}s.pointShadowMatrix.set(e.shadow.matrix.elements,16*s.pointsNum),s.pointShadowMap[s.pointsNum]=e.shadow.map}s.point[s.pointsNum]=v,s.pointsNum++}else if(e.lightType==x.SPOT){var v;u=e.intensity,h=e.color,p=e.distance,f=e.decay;(v=w(e)).color[0]=h.r*u,v.color[1]=h.g*u,v.color[2]=h.b*u,v.distance=p,v.decay=f;_=S.setFromMatrixPosition(e.worldMatrix).applyMatrix4(t.viewMatrix);v.position[0]=_.x,v.position[1]=_.y,v.position[2]=_.z;c=S;e.getWorldDirection(S),S.transformDirection(t.viewMatrix),v.direction[0]=c.x,v.direction[1]=c.y,v.direction[2]=c.z;var m=Math.cos(e.angle),g=Math.cos(e.angle*(1-e.penumbra));if(v.coneCos=m,v.penumbraCos=g,e.castShadow?(v.shadow=!0,v.shadowBias=e.shadow.bias,v.shadowRadius=e.shadow.radius,v.shadowMapSize[0]=e.shadow.mapSize.x,v.shadowMapSize[1]=e.shadow.mapSize.y):v.shadow=!1,e.castShadow){d=16*(s.spotsNum+1);if(s.spotShadowMatrix.length<d){l=s.spotShadowMatrix;s.spotShadowMatrix=new Float32Array(d),s.spotShadowMatrix.set(l)}s.spotShadowMatrix.set(e.shadow.matrix.elements,16*s.spotsNum),s.spotShadowMap[s.spotsNum]=e.shadow.map}s.spot[s.spotsNum]=v,s.spotsNum++}e.castShadow&&e.lightType!==x.AMBIENT&&(s.shadows.push(e),s.shadowsNum++),s.totalNum++;break;case T.CAMERA:case T.SCENE:case T.GROUP:break;default:console.log("undefined object type")}if(T.CANVAS2D!==e.type)for(var y=e.children,E=(r=0,y.length);r<E;r++)this.cacheObject(y[r])},e.prototype.sort=function(){var e=this.renderLists;e[M.DEFAULT].sort(t),e[M.TRANSPARENT].sort(i),e[M.SPRITE].sort(i),e[M.PARTICLE].sort(i)},e.prototype.clear=function(){var e=this.renderLists;for(var t in e)e[t].length=0;this.shadowObjects.length=0;for(var n=this.lights,i=0;i<3;i++)n.ambient[i]=0;n.shadows.length=0,n.ambientsNum=0,n.directsNum=0,n.pointsNum=0,n.spotsNum=0,n.shadowsNum=0,n.totalNum=0},zen3d.RenderCache=e}(),function(){var n=function(e,t){n.superClass.constructor.call(this),this.uuid=zen3d.generateUUID(),this.width=e,this.height=t,this.depthBuffer=!0,this.stencilBuffer=!0};zen3d.inherit(n,zen3d.EventDispatcher),n.prototype.resize=function(e,t){this.width===e&&this.height===t||this.dispose(),this.width=e,this.height=t},n.prototype.dispose=function(){this.dispatchEvent({type:"dispose"})},zen3d.RenderTargetBase=n}(),function(){var t=function(e){t.superClass.constructor.call(this,e.width,e.height),this.view=e};zen3d.inherit(t,zen3d.RenderTargetBase),t.prototype.resize=function(e,t){this.view.width=e,this.view.height=t,this.width=e,this.height=t},t.prototype.dispose=function(){},zen3d.RenderTargetBack=t}(),function(){var n=function(e,t){n.superClass.constructor.call(this,e,t),this.texture=new zen3d.Texture2D};zen3d.inherit(n,zen3d.RenderTargetBase),zen3d.RenderTarget2D=n}(),function(){var n=function(e,t){n.superClass.constructor.call(this,e,t),this.texture=new zen3d.TextureCube,this.activeCubeFace=0};zen3d.inherit(n,zen3d.RenderTargetBase),zen3d.RenderTargetCube=n}(),function(){var e=function(e,t,n){this.uuid=zen3d.generateUUID(),this.array=e,this.size=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0};e.prototype.setArray=function(e){this.count=void 0!==e?e.length/this.size:0,this.array=e},zen3d.BufferAttribute=e}(),function(){var e=function(e,t){this.uuid=zen3d.generateUUID(),this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0};e.prototype.setArray=function(e){this.count=void 0!==e?e.length/this.stride:0,this.array=e},zen3d.InterleavedBuffer=e}(),function(){var e=function(e,t,n,i){this.uuid=zen3d.generateUUID(),this.data=e,this.size=t,this.offset=n,this.normalized=!0===i};e.prototype.isInterleavedBufferAttribute=!0,Object.defineProperties(e.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),zen3d.InterleavedBufferAttribute=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.uuid=zen3d.generateUUID(),this.attributes={},this.index=null,this.usageType=zen3d.WEBGL_BUFFER_USAGE.STATIC_DRAW,this.boundingBox=new zen3d.Box3,this.boundingSphere=new zen3d.Sphere,this.dirtyRange={enable:!1,start:0,count:0},this.groups=[]};zen3d.inherit(e,zen3d.EventDispatcher),e.prototype.addAttribute=function(e,t){this.attributes[e]=t},e.prototype.getAttribute=function(e){return this.attributes[e]},e.prototype.removeAttribute=function(e){delete this.attributes[e]},e.prototype.setIndex=function(e){Array.isArray(e)?this.index=new zen3d.BufferAttribute(new Uint16Array(e),1):this.index=e},e.prototype.addGroup=function(e,t,n){this.groups.push({start:e,count:t,materialIndex:void 0!==n?n:0})},e.prototype.clearGroups=function(){this.groups=[]},e.prototype.computeBoundingBox=function(){var e=this.attributes.a_Position;if(e.isInterleavedBufferAttribute){var t=e.data;this.boundingBox.setFromArray(t.array,t.stride)}else this.boundingBox.setFromArray(e.array,e.size)},e.prototype.computeBoundingSphere=function(){var e=this.attributes.a_Position;if(e.isInterleavedBufferAttribute){var t=e.data;this.boundingSphere.setFromArray(t.array,t.stride)}else this.boundingSphere.setFromArray(e.array,e.size)},e.prototype.dispose=function(){this.dispatchEvent({type:"dispose"})},zen3d.Geometry=e}(),function(){var o=function(e,t,n,i,r,a){o.superClass.constructor.call(this),this.buildGeometry(e,t,n,i,r,a)};zen3d.inherit(o,zen3d.Geometry),o.prototype.buildGeometry=function(e,t,n,i,r,a){var L=this;e=e||1,t=t||1,n=n||1,i=Math.floor(i)||1,r=Math.floor(r)||1,a=Math.floor(a)||1;var P=[],R=[],C=[],N=[],I=0,D=0;function o(e,t,n,i,r,a,o,s,u,h,c){var d,l,p=a/u,f=o/h,_=a/2,v=o/2,m=s/2,g=u+1,y=h+1,E=0,T=0,x=new zen3d.Vector3;for(l=0;l<y;l++){var M=l*f-v;for(d=0;d<g;d++){var w=d*p-_;x[e]=w*i,x[t]=M*r,x[n]=m,R.push(x.x,x.y,x.z),x[e]=0,x[t]=0,x[n]=0<s?1:-1,C.push(x.x,x.y,x.z),N.push(d/u),N.push(1-l/h),E+=1}}for(l=0;l<h;l++)for(d=0;d<u;d++){var S=I+d+g*l,z=I+d+g*(l+1),A=I+(d+1)+g*(l+1),b=I+(d+1)+g*l;P.push(S,z,b),P.push(z,A,b),T+=6}L.addGroup(D,T,c),D+=T,I+=E}o("z","y","x",-1,-1,n,t,e,a,r,0),o("z","y","x",1,-1,n,t,-e,a,r,1),o("x","z","y",1,1,e,n,t,i,a,2),o("x","z","y",1,-1,e,n,-t,i,a,3),o("x","y","z",1,-1,e,t,n,i,r,4),o("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(P),this.addAttribute("a_Position",new zen3d.BufferAttribute(new Float32Array(R),3)),this.addAttribute("a_Normal",new zen3d.BufferAttribute(new Float32Array(C),3)),this.addAttribute("a_Uv",new zen3d.BufferAttribute(new Float32Array(N),2)),this.computeBoundingBox(),this.computeBoundingSphere()},zen3d.CubeGeometry=o}(),function(){var r=function(e,t,n,i){r.superClass.constructor.call(this),this.buildGeometry(e,t,n,i)};zen3d.inherit(r,zen3d.Geometry),r.prototype.buildGeometry=function(e,t,n,i){var r,a,o=(e=e||1)/2,s=(t=t||1)/2,u=Math.floor(n)||1,h=Math.floor(i)||1,c=u+1,d=h+1,l=e/u,p=t/h,f=[],_=[],v=[],m=[];for(a=0;a<d;a++){var g=a*p-s;for(r=0;r<c;r++){var y=r*l-o;_.push(y,0,g),v.push(0,1,0),m.push(r/u),m.push(1-a/h)}}for(a=0;a<h;a++)for(r=0;r<u;r++){var E=r+c*a,T=r+c*(a+1),x=r+1+c*(a+1),M=r+1+c*a;f.push(E,T,M),f.push(T,x,M)}this.setIndex(f),this.addAttribute("a_Position",new zen3d.BufferAttribute(new Float32Array(_),3)),this.addAttribute("a_Normal",new zen3d.BufferAttribute(new Float32Array(v),3)),this.addAttribute("a_Uv",new zen3d.BufferAttribute(new Float32Array(m),2)),this.computeBoundingBox(),this.computeBoundingSphere()},zen3d.PlaneGeometry=r}(),function(){var s=function(e,t,n,i,r,a,o){s.superClass.constructor.call(this),this.buildGeometry(e,t,n,i,r,a,o)};zen3d.inherit(s,zen3d.Geometry),s.prototype.buildGeometry=function(e,t,n,i,r,a,o){e=e||1,t=Math.max(3,Math.floor(t)||8),n=Math.max(2,Math.floor(n)||6),i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var s,u,h=(a=void 0!==a?a:0)+(o=void 0!==o?o:Math.PI),c=0,d=[],l=new zen3d.Vector3,p=new zen3d.Vector3,f=[],_=[],v=[],m=[];for(u=0;u<=n;u++){var g=[],y=u/n;for(s=0;s<=t;s++){var E=s/t;l.x=-e*Math.cos(i+E*r)*Math.sin(a+y*o),l.y=e*Math.cos(a+y*o),l.z=e*Math.sin(i+E*r)*Math.sin(a+y*o),_.push(l.x,l.y,l.z),p.set(l.x,l.y,l.z).normalize(),v.push(p.x,p.y,p.z),m.push(E,1-y),g.push(c++)}d.push(g)}for(u=0;u<n;u++)for(s=0;s<t;s++){var T=d[u][s+1],x=d[u][s],M=d[u+1][s],w=d[u+1][s+1];(0!==u||0<a)&&f.push(T,x,w),(u!==n-1||h<Math.PI)&&f.push(x,M,w)}this.setIndex(f),this.addAttribute("a_Position",new zen3d.BufferAttribute(new Float32Array(_),3)),this.addAttribute("a_Normal",new zen3d.BufferAttribute(new Float32Array(v),3)),this.addAttribute("a_Uv",new zen3d.BufferAttribute(new Float32Array(m),2)),this.computeBoundingBox(),this.computeBoundingSphere()},zen3d.SphereGeometry=s}(),function(){var u=function(e,t,n,i,r,a,o,s){u.superClass.constructor.call(this),this.buildGeometry(e,t,n,i,r,a,o,s)};zen3d.inherit(u,zen3d.Geometry),u.prototype.buildGeometry=function(m,g,y,E,T,e,x,M){var w=this;m=void 0!==m?m:1,g=void 0!==g?g:1,y=y||1,E=Math.floor(E)||8,T=Math.floor(T)||1,e=void 0!==e&&e,x=void 0!==x?x:0,M=void 0!==M?M:2*Math.PI;var S=[],z=[],A=[],b=[],L=0,P=[],R=y/2,C=0;function t(e){var t,n,i,r=new zen3d.Vector2,a=new zen3d.Vector3,o=0,s=!0===e?m:g,u=!0===e?1:-1;for(n=L,t=1;t<=E;t++)z.push(0,R*u,0),A.push(0,u,0),b.push(.5,.5),L++;for(i=L,t=0;t<=E;t++){var h=t/E*M+x,c=Math.cos(h),d=Math.sin(h);a.x=s*d,a.y=R*u,a.z=s*c,z.push(a.x,a.y,a.z),A.push(0,u,0),r.x=.5*c+.5,r.y=.5*d*u+.5,b.push(r.x,r.y),L++}for(t=0;t<E;t++){var l=n+t,p=i+t;!0===e?S.push(p,p+1,l):S.push(p+1,p,l),o+=3}w.addGroup(C,o,!0===e?1:2),C+=o}!function(){var e,t,n=new zen3d.Vector3,i=new zen3d.Vector3,r=0,a=(g-m)/y;for(t=0;t<=T;t++){var o=[],s=t/T,u=s*(g-m)+m;for(e=0;e<=E;e++){var h=e/E,c=h*M+x,d=Math.sin(c),l=Math.cos(c);i.x=u*d,i.y=-s*y+R,i.z=u*l,z.push(i.x,i.y,i.z),n.set(d,a,l).normalize(),A.push(n.x,n.y,n.z),b.push(h,1-s),o.push(L++)}P.push(o)}for(e=0;e<E;e++)for(t=0;t<T;t++){var p=P[t][e],f=P[t+1][e],_=P[t+1][e+1],v=P[t][e+1];S.push(p,f,v),S.push(f,_,v),r+=6}w.addGroup(C,r,0),C+=r}(),!1===e&&(0<m&&t(!0),0<g&&t(!1)),this.setIndex(S),this.addAttribute("a_Position",new zen3d.BufferAttribute(new Float32Array(z),3)),this.addAttribute("a_Normal",new zen3d.BufferAttribute(new Float32Array(A),3)),this.addAttribute("a_Uv",new zen3d.BufferAttribute(new Float32Array(b),2)),this.computeBoundingBox(),this.computeBoundingSphere()},zen3d.CylinderGeometry=u}(),function(){var e=function(){e.superClass.constructor.call(this),this.uuid=zen3d.generateUUID(),this.textureType="",this.border=0,this.pixelFormat=zen3d.WEBGL_PIXEL_FORMAT.RGBA,this.pixelType=zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_BYTE,this.magFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR,this.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_LINEAR,this.wrapS=zen3d.WEBGL_TEXTURE_WRAP.CLAMP_TO_EDGE,this.wrapT=zen3d.WEBGL_TEXTURE_WRAP.CLAMP_TO_EDGE,this.anisotropy=1,this.generateMipmaps=!0,this.encoding=zen3d.TEXEL_ENCODING_TYPE.LINEAR,this.version=0};zen3d.inherit(e,zen3d.EventDispatcher),e.prototype.dispose=function(){this.dispatchEvent({type:"dispose"}),this.version=0},zen3d.TextureBase=e}(),function(){var i=function(){i.superClass.constructor.call(this),this.textureType=zen3d.WEBGL_TEXTURE_TYPE.TEXTURE_2D,this.image=null,this.mipmaps=[]};zen3d.inherit(i,zen3d.TextureBase),i.fromImage=function(e){var t=new i;return t.image=e,t.version++,t},i.fromSrc=function(e){var t=new i,n=0<e.search(/\\.(jpg|jpeg)$/)||0===e.search(/^data\\:image\\/jpeg/);return(0<e.search(/\\.(tga)$/)||0===e.search(/^data\\:image\\/tga/)?new zen3d.TGALoader:new zen3d.ImageLoader).load(e,function(e){t.pixelFormat=n?zen3d.WEBGL_PIXEL_FORMAT.RGB:zen3d.WEBGL_PIXEL_FORMAT.RGBA,t.image=e,t.version++}),t},zen3d.Texture2D=i}(),function(){var u=function(){u.superClass.constructor.call(this),this.textureType=zen3d.WEBGL_TEXTURE_TYPE.TEXTURE_CUBE_MAP,this.images=[]};zen3d.inherit(u,zen3d.TextureBase),u.fromImage=function(e){for(var t=new u,n=t.images,i=0;i<6;i++)n[i]=e[i];return t.version++,t},u.fromSrc=function(n){var i=new u,r=i.images,e=n[0],a=0<e.search(/\\.(jpg|jpeg)$/)||0===e.search(/^data\\:image\\/jpeg/),o=0<e.search(/\\.(tga)$/)||0===e.search(/^data\\:image\\/tga/),s=0;return function e(t){if(t&&(r.push(t),s++),6<=s)return i.pixelFormat=a?zen3d.WEBGL_PIXEL_FORMAT.RGB:zen3d.WEBGL_PIXEL_FORMAT.RGBA,void i.version++;(o?new zen3d.TGALoader:new zen3d.ImageLoader).load(n[s],e)}(),i},zen3d.TextureCube=u}(),function(){var i=function(e,t,n){i.superClass.constructor.call(this),this.image={data:e,width:t,height:n},this.pixelType=zen3d.WEBGL_PIXEL_TYPE.FLOAT,this.magFilter=zen3d.WEBGL_TEXTURE_FILTER.NEAREST,this.minFilter=zen3d.WEBGL_TEXTURE_FILTER.NEAREST,this.generateMipmaps=!1};zen3d.inherit(i,zen3d.Texture2D),i.prototype.isDataTexture=!0,zen3d.TextureData=i}(),function(){var e=function(){this.type="",this.opacity=1,this.transparent=!1,this.premultipliedAlpha=!1,this.vertexColors=!1,this.diffuse=new zen3d.Color3(16777215),this.diffuseMap=null,this.normalMap=null,this.aoMap=null,this.aoMapIntensity=1,this.bumpMap=null,this.bumpScale=1,this.envMap=null,this.envMapIntensity=1,this.envMapCombine=zen3d.ENVMAP_COMBINE_TYPE.MULTIPLY,this.emissive=new zen3d.Color3(0),this.emissiveMap=null,this.emissiveIntensity=1,this.blending=zen3d.BLEND_TYPE.NORMAL,this.depthTest=!0,this.depthWrite=!0,this.side=zen3d.DRAW_SIDE.FRONT,this.shading=zen3d.SHADING_TYPE.SMOOTH_SHADING,this.acceptLight=!1,this.drawMode=zen3d.DRAW_MODE.TRIANGLES};e.prototype.clone=function(){return(new this.constructor).copy(this)},e.prototype.copy=function(e){return this.type=e.type,this.opacity=e.opacity,this.transparent=e.transparent,this.premultipliedAlpha=e.premultipliedAlpha,this.vertexColors=e.vertexColors,this.diffuse.copy(e.diffuse),this.diffuseMap=e.diffuseMap,this.normalMap=e.normalMap,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.envMapCombine=e.envMapCombine,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.blending=e.blending,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.side=e.side,this.shading=e.shading,this.acceptLight=e.acceptLight,this.drawMode=e.drawMode,this},zen3d.Material=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.BASIC};zen3d.inherit(e,zen3d.Material),zen3d.BasicMaterial=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.LAMBERT,this.acceptLight=!0};zen3d.inherit(e,zen3d.Material),zen3d.LambertMaterial=e}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.PHONG,this.shininess=30,this.specular=new zen3d.Color3(6710886),this.specularMap=null,this.acceptLight=!0};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.shininess=e.shininess,this.specular.copy(e.specular),this.specularMap=e.specularMap,this},zen3d.PhongMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.PBR,this.roughness=.5,this.metalness=.5,this.roughnessMap=null,this.metalnessMap=null,this.acceptLight=!0};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.roughness=e.roughness,this.metalness=e.metalness,this},zen3d.PBRMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.CUBE,this.side=zen3d.DRAW_SIDE.BACK,this.cubeMap=null};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.cubeMap=e.cubeMap,this},zen3d.CubeMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.POINT,this.size=1,this.sizeAttenuation=!0,this.drawMode=zen3d.DRAW_MODE.POINTS};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},zen3d.PointsMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.LINE,this.lineWidth=1,this.drawMode=zen3d.DRAW_MODE.LINES};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.lineWidth=e.lineWidth,this},zen3d.LineMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.LINE_LOOP,this.lineWidth=1,this.drawMode=zen3d.DRAW_MODE.LINE_LOOP};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.lineWidth=e.lineWidth,this},zen3d.LineLoopMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.LINE_DASHED,this.lineWidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.drawMode=zen3d.DRAW_MODE.LINE_STRIP};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.lineWidth=e.lineWidth,this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this},zen3d.LineDashedMaterial=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.SPRITE,this.rotation=0,this.fog=!1};zen3d.inherit(t,zen3d.Material),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.rotation=e.rotation,this.fog=e.fog,this},zen3d.SpriteMaterial=t}(),function(){var i=function(e,t,n){i.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.SHADER,this.vertexShader=e||"",this.fragmentShader=t||"",this.uniforms=n||{}};zen3d.inherit(i,zen3d.Material),i.prototype.copy=function(e){return i.superClass.copy.call(this,e),this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this},zen3d.ShaderMaterial=i}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.DEPTH,this.blending=zen3d.BLEND_TYPE.NONE,this.packToRGBA=!1};zen3d.inherit(e,zen3d.Material),zen3d.DepthMaterial=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.DISTANCE,this.blending=zen3d.BLEND_TYPE.NONE};zen3d.inherit(e,zen3d.Material),zen3d.DistanceMaterial=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.MATERIAL_TYPE.PARTICLE,this.transparent=!0,this.blending=zen3d.BLEND_TYPE.ADD,this.depthTest=!0,this.depthWrite=!1,this.drawMode=zen3d.DRAW_MODE.POINTS};zen3d.inherit(e,zen3d.Material),zen3d.ParticleMaterial=e}(),function(){var n,i,r,e=function(){this.uuid=zen3d.generateUUID(),this.name="",this.type="",this.position=new zen3d.Vector3,this.scale=new zen3d.Vector3(1,1,1);var e=this.euler=new zen3d.Euler,t=this.quaternion=new zen3d.Quaternion;e.onChange(function(){t.setFromEuler(e,!1)}),t.onChange(function(){e.setFromQuaternion(t,void 0,!1)}),this.matrix=new zen3d.Matrix4,this.worldMatrix=new zen3d.Matrix4,this.children=new Array,this.parent=null,this.castShadow=!1,this.receiveShadow=!1,this.shadowType=zen3d.SHADOW_TYPE.PCF_SOFT,this.frustumCulled=!0,this.userData={}};Object.defineProperties(e.prototype,{rotation:{get:function(){return this.euler},set:function(e){this.euler.copyFrom(e),this.quaternion.setFromEuler(e)}}}),e.prototype.add=function(e){this.children.push(e),e.parent=this},e.prototype.remove=function(e){var t=this.children.indexOf(e);-1!==t&&this.children.splice(t,1),e.parent=null},e.prototype.getObjectByName=function(e){return this.getObjectByProperty("name",e)},e.prototype.getObjectByProperty=function(e,t){if(this[e]===t)return this;for(var n=0,i=this.children.length;n<i;n++){var r=this.children[n].getObjectByProperty(e,t);if(void 0!==r)return r}},e.prototype.updateMatrix=function(){var e=this.matrix.transform(this.position,this.scale,this.quaternion);if(this.worldMatrix.copy(e),this.parent){var t=this.parent.worldMatrix;this.worldMatrix.premultiply(t)}for(var n=this.children,i=0,r=n.length;i<r;i++)n[i].updateMatrix()},e.prototype.getWorldDirection=(n=new zen3d.Vector3,i=new zen3d.Quaternion,r=new zen3d.Vector3,function(e){var t=e||new zen3d.Vector3;return this.worldMatrix.decompose(n,i,r),t.set(0,0,1).applyQuaternion(i),t}),e.prototype.raycast=function(){},e.prototype.traverse=function(e){e(this);for(var t=this.children,n=0,i=t.length;n<i;n++)t[n].traverse(e)},e.prototype.clone=function(e){return(new this.constructor).copy(this,e)},e.prototype.copy=function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.type=e.type,this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.worldMatrix.copy(e.worldMatrix),this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;n<e.children.length;n++){var i=e.children[n];this.add(i.clone())}return this},zen3d.Object3D=e}(),function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.OBJECT_TYPE.SCENE,this.overrideMaterial=null,this.fog=null,this.clippingPlanes=[],this.cache=new zen3d.RenderCache};zen3d.inherit(e,zen3d.Object3D),e.prototype.update=function(e){this.updateMatrix(),this.cache.clear(),this.cache.cacheScene(this,e),this.cache.sort()},zen3d.Scene=e}(),zen3d.Fog=function(e,t,n){this.fogType=zen3d.FOG_TYPE.NORMAL,this.color=new zen3d.Color3(void 0!==e?e:0),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3},zen3d.FogExp2=function(e,t){this.fogType=zen3d.FOG_TYPE.EXP2,this.color=new zen3d.Color3(void 0!==e?e:0),this.density=void 0!==t?t:25e-5},function(){var e=function(){e.superClass.constructor.call(this),this.type=zen3d.OBJECT_TYPE.GROUP};zen3d.inherit(e,zen3d.Object3D),zen3d.Group=e}(),function(){var t=function(){t.superClass.constructor.call(this),this.type=zen3d.OBJECT_TYPE.LIGHT,this.lightType="",this.color=new zen3d.Color3(16777215),this.intensity=1};zen3d.inherit(t,zen3d.Object3D),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.type=e.type,this.lightType=e.lightType,this.color.copy(e.color),this.intensity=e.intensity,this},zen3d.Light=t}(),function(){var e=function(){e.superClass.constructor.call(this),this.lightType=zen3d.LIGHT_TYPE.AMBIENT};zen3d.inherit(e,zen3d.Light),zen3d.AmbientLight=e}(),function(){var t=function(){t.superClass.constructor.call(this),this.lightType=zen3d.LIGHT_TYPE.DIRECT,this.shadow=new zen3d.DirectionalLightShadow};zen3d.inherit(t,zen3d.Light),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.shadow.copy(e.shadow),this},zen3d.DirectionalLight=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.lightType=zen3d.LIGHT_TYPE.POINT,this.decay=2,this.distance=200,this.shadow=new zen3d.PointLightShadow};zen3d.inherit(t,zen3d.Light),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.shadow.copy(e.shadow),this},zen3d.PointLight=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.lightType=zen3d.LIGHT_TYPE.SPOT,this.decay=2,this.distance=200,this.penumbra=0,this.angle=Math.PI/6,this.shadow=new zen3d.SpotLightShadow};zen3d.inherit(t,zen3d.Light),t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.shadow.copy(e.shadow),this},zen3d.SpotLight=t}(),function(){var e=function(){this.camera=new zen3d.Camera,this.matrix=new zen3d.Matrix4,this.bias=3e-4,this.radius=2,this.cameraNear=1,this.cameraFar=500,this.mapSize=new zen3d.Vector2(512,512),this.renderTarget=null,this.map=null};e.prototype.update=function(e,t){},e.prototype.copy=function(e){return this.camera.copy(e.camera),this.matrix.copy(e.matrix),this.bias=e.bias,this.radius=e.radius,this.cameraNear=e.cameraNear,this.cameraFar=e.cameraFar,this.mapSize.copy(e.mapSize),this},e.prototype.clone=function(){return(new this.constructor).copy(this)},zen3d.LightShadow=e}(),function(){var t=function(){t.superClass.constructor.call(this),this.renderTarget=new zen3d.RenderTarget2D(this.mapSize.x,this.mapSize.y);var e=this.renderTarget.texture;e.generateMipmaps=!1,e.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR,this.map=e,this.windowSize=500,this._lookTarget=new zen3d.Vector3,this._up=new zen3d.Vector3(0,1,0)};zen3d.inherit(t,zen3d.LightShadow),t.prototype.update=function(e){this._updateCamera(e),this._updateMatrix(),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},t.prototype._updateCamera=function(e){var t=this.camera,n=this._lookTarget;e.getWorldDirection(this._lookTarget),t.position.setFromMatrixPosition(e.worldMatrix),n.set(n.x+t.position.x,n.y+t.position.y,n.z+t.position.z),t.setLookAt(n,this._up),t.updateMatrix(),t.viewMatrix.getInverse(t.worldMatrix);var i=this.windowSize/2;t.setOrtho(-i,i,-i,i,this.cameraNear,this.cameraFar)},t.prototype._updateMatrix=function(){var e=this.matrix,t=this.camera;e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.viewMatrix)},t.prototype.copy=function(e){return t.superClass.copy.call(this,e),this.windowSize=e.windowSize,this},zen3d.DirectionalLightShadow=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.renderTarget=new zen3d.RenderTarget2D(this.mapSize.x,this.mapSize.y);var e=this.renderTarget.texture;e.generateMipmaps=!1,e.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR,this.map=e,this._lookTarget=new zen3d.Vector3,this._up=new zen3d.Vector3(0,1,0)};zen3d.inherit(t,zen3d.LightShadow),t.prototype.update=function(e){this._updateCamera(e),this._updateMatrix(),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},t.prototype._updateCamera=function(e){var t=this.camera,n=this._lookTarget;e.getWorldDirection(this._lookTarget),t.position.setFromMatrixPosition(e.worldMatrix),n.set(n.x+t.position.x,n.y+t.position.y,n.z+t.position.z),t.setLookAt(n,this._up),t.updateMatrix(),t.viewMatrix.getInverse(t.worldMatrix),t.setPerspective(2*e.angle,1,this.cameraNear,this.cameraFar)},t.prototype._updateMatrix=function(){var e=this.matrix,t=this.camera;e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.viewMatrix)},zen3d.SpotLightShadow=t}(),function(){var t=function(){t.superClass.constructor.call(this),this.renderTarget=new zen3d.RenderTargetCube(this.mapSize.x,this.mapSize.y);var e=this.renderTarget.texture;e.generateMipmaps=!1,e.minFilter=zen3d.WEBGL_TEXTURE_FILTER.LINEAR,this.map=e,this._targets=[new zen3d.Vector3(1,0,0),new zen3d.Vector3(-1,0,0),new zen3d.Vector3(0,1,0),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,0,1),new zen3d.Vector3(0,0,-1)],this._ups=[new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,0,1),new zen3d.Vector3(0,0,-1),new zen3d.Vector3(0,-1,0),new zen3d.Vector3(0,-1,0)],this._lookTarget=new zen3d.Vector3};zen3d.inherit(t,zen3d.LightShadow),t.prototype.update=function(e,t){this._updateCamera(e,t),this._updateMatrix(),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},t.prototype._updateCamera=function(e,t){var n=this.camera,i=this._lookTarget,r=this._targets,a=this._ups;n.position.setFromMatrixPosition(e.worldMatrix),i.set(r[t].x+n.position.x,r[t].y+n.position.y,r[t].z+n.position.z),n.setLookAt(i,a[t]),n.updateMatrix(),n.viewMatrix.getInverse(n.worldMatrix),n.setPerspective(.5*Math.PI,1,this.cameraNear,this.cameraFar)},t.prototype._updateMatrix=function(){var e=this.matrix,t=this.camera;e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.viewMatrix)},zen3d.PointLightShadow=t}(),function(){var n,i,r,a=function(){a.superClass.constructor.call(this),this.type=zen3d.OBJECT_TYPE.CAMERA,this.viewMatrix=new zen3d.Matrix4,this.projectionMatrix=new zen3d.Matrix4,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.rect=new zen3d.Vector4(0,0,1,1)};zen3d.inherit(a,zen3d.Object3D),a.prototype.setLookAt=function(e,t){var n=this.position,i=new zen3d.Vector3;n.subtract(e,i),i.normalize();var r=new zen3d.Vector3;r.crossVectors(t,i),r.normalize();var a=new zen3d.Vector3;a.crossVectors(i,r),this.quaternion.setFromRotationMatrix(zen3d.helpMatrix.set(r.x,a.x,i.x,0,r.y,a.y,i.y,0,r.z,a.z,i.z,0,0,0,0,1))},a.prototype.setOrtho=function(e,t,n,i,r,a){this.projectionMatrix.set(2/(t-e),0,0,-(t+e)/(t-e),0,2/(i-n),0,-(i+n)/(i-n),0,0,-2/(a-r),-(a+r)/(a-r),0,0,0,1)},a.prototype.setPerspective=function(e,t,n,i){this.projectionMatrix.set(1/(t*Math.tan(e/2)),0,0,0,0,1/Math.tan(e/2),0,0,0,0,-(i+n)/(i-n),-2*i*n/(i-n),0,0,-1,0)},a.prototype.getWorldDirection=(n=new zen3d.Vector3,i=new zen3d.Quaternion,r=new zen3d.Vector3,function(e){var t=e||new zen3d.Vector3;return this.worldMatrix.decompose(n,i,r),t.set(0,0,-1).applyQuaternion(i),t}),a.prototype.updateMatrix=function(){a.superClass.updateMatrix.call(this),this.viewMatrix.getInverse(this.worldMatrix)},a.prototype.copy=function(e,t){return a.superClass.copy.call(this,e,t),this.viewMatrix.copy(e.viewMatrix),this.projectionMatrix.copy(e.projectionMatrix),this},zen3d.Camera=a}(),function(){var n=function(e,t){n.superClass.constructor.call(this),this.geometry=e,this.material=t,this.type=zen3d.OBJECT_TYPE.MESH};zen3d.inherit(n,zen3d.Object3D),n.prototype.raycast=function(){var y=new zen3d.Sphere,E=new zen3d.Box3,T=new zen3d.Matrix4,x=new zen3d.Ray,M=new zen3d.Vector3,w=new zen3d.Vector3,S=new zen3d.Vector3,z=new zen3d.Vector3,A=new zen3d.Vector2,b=new zen3d.Vector2,L=new zen3d.Vector2,P=new zen3d.Vector3,u=new zen3d.Vector3;function R(e,t,n,i,r,a,o){e.material;if(null===n.intersectTriangle(a,r,i,!0,o))return null;u.copy(o),u.applyMatrix4(e.worldMatrix);var s=t.ray.origin.distanceTo(u);return s<t.near||s>t.far?null:{distance:s,point:u.clone(),object:e}}return function(e,t){var n=this.geometry,i=this.worldMatrix;if(y.copy(n.boundingSphere),y.applyMatrix4(i),e.ray.intersectsSphere(y)&&(E.copy(n.boundingBox),E.applyMatrix4(i),e.ray.intersectsBox(E))){T.getInverse(i),x.copy(e.ray).applyMatrix4(T);for(var r,a,o,s,u,h,c,d,l,p,f=n.index.array,_=n.getAttribute("a_Position"),v=n.getAttribute("a_Uv"),m=0;m<f.length;m+=3){r=f[m],a=f[m+1],o=f[m+2],w.fromArray(_.array,3*r),S.fromArray(_.array,3*a),z.fromArray(_.array,3*o);var g=R(this,e,x,w,S,z,P);g&&(A.fromArray(v.array,2*r),b.fromArray(v.array,2*a),L.fromArray(v.array,2*o),g.uv=(s=P,u=w,h=S,c=z,d=A,l=b,p=L,zen3d.Triangle.barycoordFromPoint(s,u,h,c,M),d.multiplyScalar(M.x),l.multiplyScalar(M.y),p.multiplyScalar(M.z),d.add(l).add(p),d.clone()),g.face=[r,a,o],g.faceIndex=r,t.push(g))}}}}(),n.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},zen3d.Mesh=n}(),function(){var n=function(e,t){n.superClass.constructor.call(this,e,t),this.type=zen3d.OBJECT_TYPE.SKINNED_MESH,this.skeleton=void 0};zen3d.inherit(n,zen3d.Mesh),n.prototype.updateMatrix=function(){n.superClass.updateMatrix.call(this),this.skeleton&&this.skeleton.updateBones()},n.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},zen3d.SkinnedMesh=n}(),function(){var n=function(e,t){n.superClass.constructor.call(this),this.geometry=e,this.material=t,this.type=zen3d.OBJECT_TYPE.POINT};zen3d.inherit(n,zen3d.Object3D),zen3d.Points=n}(),function(){var n=function(e,t){n.superClass.constructor.call(this),this.geometry=e,this.material=t,this.type=zen3d.OBJECT_TYPE.LINE};zen3d.inherit(n,zen3d.Object3D),n.prototype.raycast=function(){},zen3d.Line=n}(),function(){var t=new zen3d.Geometry,e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),n=new zen3d.InterleavedBuffer(e,4);t.addAttribute("position",new zen3d.InterleavedBufferAttribute(n,2,0)),t.addAttribute("uv",new zen3d.InterleavedBufferAttribute(n,2,2)),t.setIndex([0,1,2,0,2,3]);var i=function(e){i.superClass.constructor.call(this),this.geometry=t,this.material=void 0!==e?e:new zen3d.SpriteMaterial,this.type=zen3d.OBJECT_TYPE.SPRITE};zen3d.inherit(i,zen3d.Object3D),i.geometry=t,zen3d.Sprite=i}(),function(){var r=new Uint8Array(4),a=new Float32Array(r.buffer);function l(e,t,n,i){return r[0]=Math.floor(i),r[1]=Math.floor(n),r[2]=Math.floor(t),r[3]=Math.floor(e),a[0]}var o=function(e){o.superClass.constructor.call(this);e=e||{};this.maxParticleCount=e.maxParticleCount||1e4,this.particleNoiseTex=e.particleNoiseTex||null,this.particleSpriteTex=e.particleSpriteTex||null,this.geometry=new zen3d.Geometry;for(var t=[],n=0;n<this.maxParticleCount;n++)t[8*n+0]=100,t[8*n+1]=0,t[8*n+2]=0,t[8*n+3]=0,t[8*n+4]=l(128,128,0,0),t[8*n+5]=l(0,254,0,254),t[8*n+6]=1,t[8*n+7]=0;var i,r=new zen3d.InterleavedBuffer(new Float32Array(t),8);r.dynamic=!0,i=new zen3d.InterleavedBufferAttribute(r,3,0),this.geometry.addAttribute("a_Position",i),i=new zen3d.InterleavedBufferAttribute(r,4,0),this.geometry.addAttribute("particlePositionsStartTime",i),i=new zen3d.InterleavedBufferAttribute(r,4,4),this.geometry.addAttribute("particleVelColSizeLife",i),this.particleCursor=0,this.time=0,this.type=zen3d.OBJECT_TYPE.PARTICLE,this.material=new zen3d.ParticleMaterial};zen3d.inherit(o,zen3d.Object3D);var p=new zen3d.Vector3,f=new zen3d.Vector3,_=0,v=0,m=new zen3d.Color3,g=0,y=0,E=0,T=0;o.prototype.spawn=function(e){p=void 0!==(e=e||{}).position?p.copy(e.position):p.set(0,0,0),f=void 0!==e.velocity?f.copy(e.velocity):f.set(0,0,0),_=void 0!==e.positionRandomness?e.positionRandomness:0,v=void 0!==e.velocityRandomness?e.velocityRandomness:0,m=void 0!==e.color?m.copy(e.color):m.setRGB(1,1,1),g=void 0!==e.colorRandomness?e.colorRandomness:1,u=void 0!==e.turbulence?e.turbulence:1,y=void 0!==e.lifetime?e.lifetime:5,E=void 0!==e.size?e.size:10,T=void 0!==e.sizeRandomness?e.sizeRandomness:0;var t=this.particleCursor,n=this.geometry.getAttribute("particlePositionsStartTime").data,i=n.array,r=n.stride;i[t*r+0]=p.x+(Math.random()-.5)*_,i[t*r+1]=p.y+(Math.random()-.5)*_,i[t*r+2]=p.z+(Math.random()-.5)*_,i[t*r+3]=this.time+.02*(Math.random()-.5);var a=f.x+(Math.random()-.5)*v,o=f.y+(Math.random()-.5)*v,s=f.z+(Math.random()-.5)*v,u=Math.floor(254*u);a=Math.floor((a- -2)/4*250),o=Math.floor((o- -2)/4*250),s=Math.floor((s- -2)/4*250),i[t*r+4]=l(a,o,s,u);var h=254*m.r+(Math.random()-.5)*g*254,c=254*m.g+(Math.random()-.5)*g*254,d=254*m.b+(Math.random()-.5)*g*254;254<h&&(h=254),h<0&&(h=0),254<c&&(c=254),c<0&&(c=0),254<d&&(d=254),d<0&&(d=0),i[t*r+5]=l(h,c,d,254),i[t*r+6]=E+(Math.random()-.5)*T,i[t*r+7]=y,this.particleCursor++,this.particleCursor>=this.maxParticleCount?(this.particleCursor=0,n.version++,n.updateRange.offset=0,n.updateRange.count=-1):(n.version++,-1<n.updateRange.count?n.updateRange.count=this.particleCursor*r-n.updateRange.offset:(n.updateRange.offset=t*r,n.updateRange.count=r))},o.prototype.update=function(e){this.time=e},zen3d.ParticleContainer=o}(),function(){var e=function(){e.superClass.constructor.call(this),this.type="bone",this.offsetMatrix=new zen3d.Matrix4};zen3d.inherit(e,zen3d.Object3D),zen3d.Bone=e}(),function(){var t=function(e){t.superClass.constructor.call(this),this.type="skeleton",this.bones=e||[],this.boneMatrices=new Float32Array(16*this.bones.length),this.boneTexture=void 0,this.boneTextureSize=0};zen3d.inherit(t,zen3d.Object3D);var n=new zen3d.Matrix4;t.prototype.updateBones=function(){this.updateMatrix();for(var e=0;e<this.bones.length;e++){var t=this.bones[e];n.multiplyMatrices(t.worldMatrix,t.offsetMatrix),n.toArray(this.boneMatrices,16*e)}void 0!==this.boneTexture&&this.boneTexture.version++},zen3d.Skeleton=t}(),function(){var e=function(){this._keys=[],this._values=[]};e.prototype.addFrame=function(e,t){this._keys.push(e),this._values.push(t)},e.prototype.removeFrame=function(e){var t=this.keys.indexOf(e);-1<t&&(this._keys.splice(t,1),this._values.splice(t,1))},e.prototype.clearFrame=function(){this._keys.length=0,this._values.length=0},e.prototype.sortFrame=function(){},e.prototype.getRange=function(e,t){var n=this._getLastKeyIndex(e),i=this._keys[n],r=this._keys[n+1],a=this._values[n],o=this._values[n+1];return(t=t||{key1:0,value1:0,key2:0,value2:0}).key1=i,t.key2=r,t.value1=a,t.value2=o,t},e.prototype._getLastKeyIndex=function(e){var t,n=0,i=this._keys.length;for(t=0;t<i;t++)e>=this._keys[t]&&(n=t);return n},zen3d.KeyframeData=e}(),function(){var o={key1:0,value1:0,key2:0,value2:0},e=function(e,t){this.target=void 0,this.path=void 0,this.bind(e,t),this.data=new zen3d.KeyframeData,this._frame=0,this.interpolant=!0};e.prototype.bind=function(e,t){if(1<(t=t.split(".")).length){for(var n=e[t[0]],i=1;i<t.length-1;i++)n=n[t[i]];this.path=t[t.length-1],this.target=n}else this.path=t[0],this.target=e},Object.defineProperties(e.prototype,{frame:{get:function(){return this._frame},set:function(e){this._frame=e,this._updateValue(e)}}}),e.prototype._updateValue=function(e){this.data.getRange(e,o);var t=o.key1,n=o.key2,i=o.value1,r=o.value2;if(this.interpolant)if(void 0!==i&&void 0!==r){var a=(e-t)/(n-t);this.target[this.path]=(r-i)*a+i}else this.target[this.path]=i;else this.target[this.path]=i},zen3d.KeyframeTrack=e}(),function(){var o={key1:0,value1:0,key2:0,value2:0},n=function(e,t){n.superClass.constructor.call(this,e,t)};zen3d.inherit(n,zen3d.KeyframeTrack),n.prototype._updateValue=function(e){this.data.getRange(e,o);var t=o.key1,n=o.key2,i=o.value1,r=o.value2;if(this.interpolant)if(void 0!==i&&void 0!==r){var a=(e-t)/(n-t);this.target[this.path].slerpQuaternions(i,r,a)}else this.target[this.path].copy(i);else this.target[this.path].copy(i)},zen3d.QuaternionKeyframeTrack=n}(),function(){var o={key1:0,value1:0,key2:0,value2:0},n=function(e,t){n.superClass.constructor.call(this,e,t)};zen3d.inherit(n,zen3d.KeyframeTrack),n.prototype._updateValue=function(e){this.data.getRange(e,o);var t=o.key1,n=o.key2,i=o.value1,r=o.value2;if(this.interpolant)if(void 0!==i&&void 0!==r){var a=(e-t)/(n-t);this.target[this.path].lerpVectors(i,r,a)}else this.target[this.path].copy(i);else this.target[this.path].copy(i)},zen3d.VectorKeyframeTrack=n}(),function(){var o={key1:0,value1:0,key2:0,value2:0},n=function(e,t){n.superClass.constructor.call(this,e,t)};zen3d.inherit(n,zen3d.KeyframeTrack),n.prototype._updateValue=function(e){this.data.getRange(e,o);var t=o.key1,n=o.key2,i=o.value1,r=o.value2;if(this.interpolant)if(void 0!==i&&void 0!==r){var a=(e-t)/(n-t);this.target[this.path].lerpColors(i,r,a)}else this.target[this.path].copy(i);else this.target[this.path].copy(i)},zen3d.ColorKeyframeTrack=n}(),function(){var e=function(e){this.name=e||"",this.tracks=[],this.loop=!0,this.startFrame=0,this.endFrame=0,this.frame=0};e.prototype.update=function(e){this.frame+=e,this.frame>this.endFrame&&(this.loop?this.frame=this.startFrame:this.frame=this.endFrame),this.setFrame(this.frame)},e.prototype.setFrame=function(e){for(var t=0,n=this.tracks.length;t<n;t++)this.tracks[t].frame=e;this.frame=e},zen3d.KeyframeClip=e}(),function(){var e=function(){this._clips={},this._currentClipName=""};Object.defineProperties(e.prototype,{currentClipName:{get:function(){return this._currentClipName}},currentClip:{get:function(){return this._clips[this._currentClipName]}}}),e.prototype.add=function(e){this._clips[e.name]=e},e.prototype.remove=function(e){delete this._clips[e.name]},e.prototype.update=function(e){var t=this._clips[this._currentClipName];t&&t.update(e)},e.prototype.active=function(e){var t=this._clips[e];t?(this._currentClipName=e,t.setFrame(t.startFrame)):console.warn("KeyframeAnimation: try to active a undefind clip!")},e.prototype.getAllClipNames=function(){var e=[];for(var t in this._clips)e.push(t);return e},zen3d.KeyframeAnimation=e}(),function(){var e=function(){this.texturePath="./"};e.prototype.load=function(e,n,t,i){this.texturePath=this.extractUrlBase(e),(new zen3d.FileLoader).setResponseType("json").load(e,function(e){var t=this.parse(e);n(t.object,t.animation)}.bind(this),t,i)},e.prototype.parseNodeTree=function(e){var t=new zen3d.Object3D;if(t.name=e.name,t.matrix.fromArray(e.transformation).transpose(),e.children)for(var n=0;n<e.children.length;n++){var i=this.parseNodeTree(e.children[n]);t.add(i)}return t},e.prototype.cloneNodeToBones=function(e,t){var n=new zen3d.Bone;if(n.name=e.name,n.matrix.copy(e.matrix),n.matrix.decompose(n.position,n.quaternion,n.scale),t[e.name]||(t[e.name]=[]),t[e.name].push(n),e.children)for(var i=0;i<e.children.length;i++){var r=this.cloneNodeToBones(e.children[i],t);n.add(r)}return n},e.prototype.parseSkeleton=function(e,t,i,n){for(var r=[],a=i.getObjectByName(e);a.parent;)r.push(a.parent.name),a=a.parent;r.push(a);var o,s=[],u=[],h=i.getObjectByName(function(e){for(var t,n=i.getObjectByName(e);n.parent&&(t=n.parent,!(-1<r.indexOf(t.name)));)n=t;return n.name}(t[0].name)),c=this.cloneNodeToBones(h,n);u.push(c);for(var d=0;d<t.length;d++){var l=t[d],p=c.getObjectByName(l.name);p||(h=i.getObjectByName(l.name),c=this.cloneNodeToBones(h,n),u.push(c),p=c.getObjectByName(l.name));var f=t[d].offsetmatrix;p.offsetMatrix.fromArray(f).transpose(),s.push(p)}o=new zen3d.Skeleton(s);for(d=0;d<u.length;d++)o.add(u[d]);return o},e.prototype.parseAnimations=function(e,t){for(var n=new zen3d.KeyframeAnimation,i=0;i<e.length;i++){for(var r=e[i],a=r.name,o=r.channels,s=0,u=new zen3d.KeyframeClip(a),h=0;h<o.length;h++){var c=o[h],d=c.name;if(t[d])for(var l=0;l<t[d].length;l++){var p=t[d][l],f=new zen3d.VectorKeyframeTrack(p,"position");for(l=0;l<c.positionkeys.length;l++){var _=c.positionkeys[l];f.data.addFrame(_[0],new zen3d.Vector3(_[1][0],_[1][1],_[1][2])),_[0]>s&&(s=_[0])}u.tracks.push(f);var v=new zen3d.QuaternionKeyframeTrack(p,"quaternion");for(l=0;l<c.rotationkeys.length;l++){_=c.rotationkeys[l];v.data.addFrame(_[0],new zen3d.Quaternion(_[1][1],_[1][2],_[1][3],_[1][0])),_[0]>s&&(s=_[0])}u.tracks.push(v);var m=new zen3d.VectorKeyframeTrack(p,"scale");for(l=0;l<c.scalingkeys.length;l++){_=c.scalingkeys[l];m.data.addFrame(_[0],new zen3d.Vector3(_[1][0],_[1][1],_[1][2])),_[0]>s&&(s=_[0])}u.tracks.push(m)}else console.log(d)}u.startFrame=0,u.endFrame=s,u.loop=!0,n.add(u)}return n},e.prototype.parse=function(e){for(var t,n=this.parseNodeTree(e.rootnode),i=this.parseList(e.meshes,this.parseMesh),r=this.parseList(e.materials,this.parseMaterial),a={},o={},s=0;s<e.meshes.length;s++)e.meshes[s].bones&&(o[s]=this.parseSkeleton(e.meshes[s].name,e.meshes[s].bones,n,a));return e.animations&&(t=this.parseAnimations(e.animations,a)),{object:this.parseObject(e,e.rootnode,i,r,o),animation:t}},e.prototype.parseList=function(e,t){for(var n=new Array(e.length),i=0;i<e.length;++i)n[i]=t.call(this,e[i]);return n},e.prototype.parseMaterial=function(e){var t=new zen3d.PhongMaterial,n=null,i=null,r=e.properties;for(var a in e.properties){if("$tex.file"===(r=e.properties[a]).key){if(1==r.semantic)o=(o=this.texturePath+r.value).replace(/.\\\\/g,""),(n=new zen3d.Texture2D.fromSrc(o)).wrapS=n.wrapT=zen3d.WEBGL_TEXTURE_WRAP.REPEAT;else if(2==r.semantic);else if(5==r.semantic);else if(6==r.semantic){var o;o=(o=this.texturePath+r.value).replace(/.\\\\/g,""),(i=new zen3d.Texture2D.fromSrc(o)).wrapS=i.wrapT=zen3d.WEBGL_TEXTURE_WRAP.REPEAT}}else if("?mat.name"===r.key);else if("$clr.ambient"===r.key);else if("$clr.diffuse"===r.key){var s=r.value;t.diffuse.setRGB(s[0],s[1],s[2])}else if("$clr.specular"===r.key){s=r.value;t.specular.setRGB(s[0],s[1],s[2])}else if("$clr.emissive"===r.key){s=r.value;t.emissive.setRGB(s[0],s[1],s[2])}else"$mat.opacity"===r.key?(t.transparent=r.value<1,t.opacity=r.value):"$mat.shadingm"===r.key?r.value:"$mat.shininess"===r.key&&(t.shininess=r.value)}return t.diffuseMap=n,t.normalMap=i,t},e.prototype.parseMesh=function(e){var t=new zen3d.Geometry,n=e.faces,i=e.vertices,r=e.normals,a=e.texturecoords&&e.texturecoords[0],o=i.length/3,s=[],u=e.bones,h=[];if(u){for(var c=0;c<o;c++)h[c]=[];var d,l,p;for(c=0;c<u.length;c++){(d=u[c]).name,d.offsetmatrix,l=d.weights;for(var f=0;f<l.length;f++)h[(p=l[f])[0]].push({index:c,weight:p[1]})}for(c=0;c<o;c++){(E=h[c]).sort(function(e,t){return t.weight-e.weight});var _=E[0]?E[0].weight:0,v=E[1]?E[1].weight:0,m=E[2]?E[2].weight:0,g=E[3]?E[3].weight:0,y=_+v+m+g;0<y&&(_/=y,v/=y,m/=y,g/=y),E[0]&&(E[0].weight=_),E[1]&&(E[1].weight=v),E[2]&&(E[2].weight=m),E[3]&&(E[3].weight=g)}}for(c=0;c<o;c++){if(s.push(i[3*c+0]),s.push(i[3*c+1]),s.push(i[3*c+2]),s.push(r[3*c+0]),s.push(r[3*c+1]),s.push(r[3*c+2]),s.push(0),s.push(0),s.push(0),u)for(var E=h[c],T=0;T<4;T++)E[T]?s.push(E[T].index):s.push(0);else s.push(1),s.push(1),s.push(1),s.push(1);if(a?(s.push(a[2*c+0]),s.push(1-a[2*c+1])):(s.push(0),s.push(0)),u)for(E=h[c],T=0;T<4;T++)E[T]?s.push(E[T].weight):s.push(0);else s.push(0),s.push(0)}if(u){var x=new zen3d.InterleavedBuffer(new Float32Array(s),19);M=new zen3d.InterleavedBufferAttribute(x,3,0),t.addAttribute("a_Position",M),M=new zen3d.InterleavedBufferAttribute(x,3,3),t.addAttribute("a_Normal",M),M=new zen3d.InterleavedBufferAttribute(x,4,9),t.addAttribute("skinIndex",M),M=new zen3d.InterleavedBufferAttribute(x,4,15),t.addAttribute("skinWeight",M),M=new zen3d.InterleavedBufferAttribute(x,2,13),t.addAttribute("a_Uv",M)}else{var M;x=new zen3d.InterleavedBuffer(new Float32Array(s),17);M=new zen3d.InterleavedBufferAttribute(x,3,0),t.addAttribute("a_Position",M),M=new zen3d.InterleavedBufferAttribute(x,3,3),t.addAttribute("a_Normal",M),M=new zen3d.InterleavedBufferAttribute(x,4,9),t.addAttribute("a_Color",M),M=new zen3d.InterleavedBufferAttribute(x,2,13),t.addAttribute("a_Uv",M)}var w=[];for(c=0;c<n.length;c++)w.push(n[c][0]),w.push(n[c][1]),w.push(n[c][2]);return t.setIndex(w),t.computeBoundingBox(),t.computeBoundingSphere(),t},e.prototype.parseObject=function(e,t,n,i,r){var a=new zen3d.Group;a.name=t.name||"",a.matrix.fromArray(t.transformation).transpose(),a.matrix.decompose(a.position,a.quaternion,a.scale);for(var o,s=0;t.meshes&&s<t.meshes.length;++s){var u=t.meshes[s],h=i[e.meshes[u].materialindex];r[u]?(o=new zen3d.SkinnedMesh(n[u],h)).skeleton=r[u]:o=new zen3d.Mesh(n[u],h),o.frustumCulled=!1,a.add(o)}for(s=0;t.children&&s<t.children.length;++s)a.add(this.parseObject(e,t.children[s],n,i,r));return a},e.prototype.extractUrlBase=function(e){var t=e.split("/");return t.pop(),(t.length<1?".":t.join("/"))+"/"},zen3d.AssimpJsonLoader=e}(),function(){var e=function(){this.path=void 0,this.responseType=void 0,this.withCredentials=void 0,this.mimeType=void 0,this.requestHeader=void 0};e.prototype.load=function(e,n,t,i){void 0===e&&(e=""),null!=this.path&&(e=this.path+e);var r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){var a=r[1],o=!!r[2],s=r[3];s=window.decodeURIComponent(s),o&&(s=window.atob(s));try{var u,h=(this.responseType||"").toLowerCase();switch(h){case"arraybuffer":case"blob":u=new ArrayBuffer(s.length);for(var c=new Uint8Array(u),d=0;d<s.length;d++)c[d]=s.charCodeAt(d);"blob"===h&&(u=new Blob([u],{type:a}));break;case"document":var l=new DOMParser;u=l.parseFromString(s,a);break;case"json":u=JSON.parse(s);break;default:u=s}window.setTimeout(function(){n&&n(u)},0)}catch(e){window.setTimeout(function(){i&&i(e)},0)}}else{var p=new XMLHttpRequest;for(var f in p.open("GET",e,!0),p.addEventListener("load",function(e){var t=e.target.response;200===this.status?n&&n(t):0===this.status?(console.warn("THREE.FileLoader: HTTP Status 0 received."),n&&n(t)):i&&i(e)},!1),void 0!==t&&p.addEventListener("progress",function(e){t(e)},!1),void 0!==i&&p.addEventListener("error",function(e){i(e)},!1),void 0!==this.responseType&&(p.responseType=this.responseType),void 0!==this.withCredentials&&(p.withCredentials=this.withCredentials),p.overrideMimeType&&p.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)p.setRequestHeader(f,this.requestHeader[f]);p.send(null)}},e.prototype.setPath=function(e){return this.path=e,this},e.prototype.setResponseType=function(e){return this.responseType=e,this},e.prototype.setWithCredentials=function(e){return this.withCredentials=e,this},e.prototype.setMimeType=function(e){return this.mimeType=e,this},e.prototype.setRequestHeader=function(e){return this.requestHeader=e,this},zen3d.FileLoader=e}(),function(){var e=function(){this.crossOrigin=void 0,this.path=void 0};e.prototype.load=function(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e);var r=document.createElementNS("http://www.w3.org/1999/xhtml","img");return r.addEventListener("load",function(){t&&t(this)},!1),r.addEventListener("error",function(e){i&&i(e)},!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(r.crossOrigin=this.crossOrigin),r.src=e,r},e.prototype.setCrossOrigin=function(e){return this.crossOrigin=e,this},e.prototype.setPath=function(e){return this.path=e,this},zen3d.ImageLoader=e}(),function(){var e=function(){};e.prototype.load=function(e,t,n,i){var r=this,a=new zen3d.FileLoader;a.setResponseType("arraybuffer"),a.load(e,function(e){void 0!==t&&t(r.parse(e))},n,i)},e.prototype.parse=function(e){var t=0,n=1,i=2,r=3,a=9,o=10,s=11,d=48,l=4,p=0,f=1,_=2,v=3;e.length<19&&console.error("TGALoader.parse: Not enough data to contain header.");var u=new Uint8Array(e),h=0,m={id_length:u[h++],colormap_type:u[h++],image_type:u[h++],colormap_index:u[h++]|u[h++]<<8,colormap_length:u[h++]|u[h++]<<8,colormap_size:u[h++],origin:[u[h++]|u[h++]<<8,u[h++]|u[h++]<<8],width:u[h++]|u[h++]<<8,height:u[h++]|u[h++]<<8,pixel_size:u[h++],flags:u[h++]};!function(e){switch(e.image_type){case n:case a:(256<e.colormap_length||24!==e.colormap_size||1!==e.colormap_type)&&console.error("TGALoader.parse.tgaCheckHeader: Invalid type colormap data for indexed type");break;case i:case r:case o:case s:e.colormap_type&&console.error("TGALoader.parse.tgaCheckHeader: Invalid type colormap data for colormap type");break;case t:console.error("TGALoader.parse.tgaCheckHeader: No data");default:console.error(\'TGALoader.parse.tgaCheckHeader: Invalid type " \'+e.image_type+\'"\')}(e.width<=0||e.height<=0)&&console.error("TGALoader.parse.tgaCheckHeader: Invalid image size"),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error(\'TGALoader.parse.tgaCheckHeader: Invalid pixel size "\'+e.pixel_size+\'"\')}(m),m.id_length+h>e.length&&console.error("TGALoader.parse: No data"),h+=m.id_length;var c=!1,g=!1,y=!1;switch(m.image_type){case a:g=c=!0;break;case n:g=!0;break;case o:c=!0;break;case i:break;case s:y=c=!0;break;case r:y=!0}var E=document.createElement("canvas");E.width=m.width,E.height=m.height;var T=E.getContext("2d"),x=T.createImageData(m.width,m.height),M=function(e,t,n,i,r){var a,o,s,u;if(o=n.pixel_size>>3,s=n.width*n.height*o,t&&(u=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){var h,c,d;a=new Uint8Array(s);for(var l=0,p=new Uint8Array(o);l<s;)if(c=1+(127&(h=r[i++])),128&h){for(d=0;d<o;++d)p[d]=r[i++];for(d=0;d<c;++d)a.set(p,l+d*o);l+=o*c}else{for(c*=o,d=0;d<c;++d)a[l+d]=r[i++];l+=c}}else a=r.subarray(i,i+=t?n.width*n.height:s);return{pixel_data:a,palettes:u}}(c,g,m,h,u);!function(e,t,n,i,r){var a,o,s,u,h,c;switch((m.flags&d)>>l){default:case _:h=t,o=a=0,u=s=1,c=n;break;case p:a=0,h=t,o=n-(s=1),c=u=-1;break;case v:a=t-1,h=s=-1,o=0,u=1,c=n;break;case f:a=t-1,o=n-1,c=u=h=s=-1}if(y)switch(m.pixel_size){case 8:!function(e,t,n,i,r,a,o,s){var u,h,c,d=0,l=m.width;for(c=t;c!==i;c+=n)for(h=r;h!==o;h+=a,d++)u=s[d],e[4*(h+l*c)+0]=u,e[4*(h+l*c)+1]=u,e[4*(h+l*c)+2]=u,e[4*(h+l*c)+3]=255}(e,o,u,c,a,s,h,i);break;case 16:!function(e,t,n,i,r,a,o,s){var u,h,c=0,d=m.width;for(h=t;h!==i;h+=n)for(u=r;u!==o;u+=a,c+=2)e[4*(u+d*h)+0]=s[c+0],e[4*(u+d*h)+1]=s[c+0],e[4*(u+d*h)+2]=s[c+0],e[4*(u+d*h)+3]=s[c+1]}(e,o,u,c,a,s,h,i);break;default:console.error("TGALoader.parse.getTgaRGBA: not support this format")}else switch(m.pixel_size){case 8:!function(e,t,n,i,r,a,o,s,u){var h,c,d,l=u,p=0,f=m.width;for(d=t;d!==i;d+=n)for(c=r;c!==o;c+=a,p++)h=s[p],e[4*(c+f*d)+3]=255,e[4*(c+f*d)+2]=l[3*h+0],e[4*(c+f*d)+1]=l[3*h+1],e[4*(c+f*d)+0]=l[3*h+2]}(e,o,u,c,a,s,h,i,r);break;case 16:!function(e,t,n,i,r,a,o,s){var u,h,c,d=0,l=m.width;for(c=t;c!==i;c+=n)for(h=r;h!==o;h+=a,d+=2)u=s[d+0]+(s[d+1]<<8),e[4*(h+l*c)+0]=(31744&u)>>7,e[4*(h+l*c)+1]=(992&u)>>2,e[4*(h+l*c)+2]=(31&u)>>3,e[4*(h+l*c)+3]=32768&u?0:255}(e,o,u,c,a,s,h,i);break;case 24:!function(e,t,n,i,r,a,o,s){var u,h,c=0,d=m.width;for(h=t;h!==i;h+=n)for(u=r;u!==o;u+=a,c+=3)e[4*(u+d*h)+3]=255,e[4*(u+d*h)+2]=s[c+0],e[4*(u+d*h)+1]=s[c+1],e[4*(u+d*h)+0]=s[c+2]}(e,o,u,c,a,s,h,i);break;case 32:!function(e,t,n,i,r,a,o,s){var u,h,c=0,d=m.width;for(h=t;h!==i;h+=n)for(u=r;u!==o;u+=a,c+=4)e[4*(u+d*h)+2]=s[c+0],e[4*(u+d*h)+1]=s[c+1],e[4*(u+d*h)+0]=s[c+2],e[4*(u+d*h)+3]=s[c+3]}(e,o,u,c,a,s,h,i);break;default:console.error("TGALoader.parse.getTgaRGBA: not support this format")}}(x.data,m.width,m.height,M.pixel_data,M.palettes);return T.putImageData(x,0,0),E},zen3d.TGALoader=e}(),function(){function u(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);return decodeURIComponent(escape(t))}var t,s=(t=new RegExp("[\\\\[\\\\]\\\\.:\\\\/]","g"),function(e){return e.replace(/\\s/g,"_").replace(t,"")});function h(e,t){return"string"!=typeof e||""===e?"":/^(https?:)?\\/\\//i.test(e)?e:/^data:.*,.*$/i.test(e)?e:/^blob:.*$/i.test(e)?e:t+e}var e=function(){};function i(){var n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}function c(e,t,n){this.json=e||{},this.extensions=t||{},this.options=n||{},this.cache=new i,this.primitiveCache=[],this.textureLoader=new zen3d.ImageLoader,this.fileLoader=new zen3d.FileLoader,this.fileLoader.setResponseType("arraybuffer")}function a(e,t){if(e.indices!==t.indices)return!1;var n=e.attributes||{},i=t.attributes||{},r=Object.keys(n),a=Object.keys(i);if(r.length!==a.length)return!1;for(var o=0,s=r.length;o<s;o++){var u=r[o];if(n[u]!==i[u])return!1}return!0}function p(e,t){for(var n=0,i=e.length;n<i;n++){var r=e[n];if(a(r.primitive,t))return r.promise}return null}function f(e,t,n){var i=t.attributes;for(var r in i){var a=T[r],o=n[i[r]];a&&(a in e.attributes||e.addAttribute(a,o))}void 0===t.indices||e.index||e.setIndex(n[t.indices])}e.prototype.load=function(e,t,n,i){var r,a=this,o=((r=e.split("/")).pop(),(r.length<1?".":r.join("/"))+"/"),s=new zen3d.FileLoader;s.setResponseType("arraybuffer"),s.load(e,function(e){void 0!==t&&a.parse(e,o,t,i)},n,i)},e.prototype.parse=function(e,t,a,n){var i,r={};if("string"==typeof e)i=e;else if(u(new Uint8Array(e,0,4))===l){try{r[_.KHR_BINARY_GLTF]=new g(e)}catch(e){return void(n&&n(e))}i=r[_.KHR_BINARY_GLTF].content}else i=u(new Uint8Array(e));var o=JSON.parse(i);void 0===o.asset||o.asset.version[0]<2?n&&n(new Error("GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.")):(o.extensionsUsed&&(0<=o.extensionsUsed.indexOf(_.KHR_LIGHTS)&&(r[_.KHR_LIGHTS]=new d(o)),0<=o.extensionsUsed.indexOf(_.KHR_MATERIALS_UNLIT)&&console.warn("GLTFLoader:: KHR_MATERIALS_UNLIT not currently supported."),0<=o.extensionsUsed.indexOf(_.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS)&&console.warn("GLTFLoader:: KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS not currently supported."),0<=o.extensionsUsed.indexOf(_.KHR_DRACO_MESH_COMPRESSION)&&(console.warn("GLTFLoader:: no draco loader."),r[_.KHR_DRACO_MESH_COMPRESSION]=new y)),console.time("GLTFLoader"),new c(o,r,{path:t}).parse(function(e,t,n,i,r){console.timeEnd("GLTFLoader"),a({scene:e,scenes:t,cameras:n,animations:i,asset:r})},n))},zen3d.GLTFLoader=e,c.prototype.parse=function(o,e){var s=this.json;this.cache.removeAll(),this.markDefs(),this.getMultiDependencies(["scene","animation","camera"]).then(function(e){var t=e.scenes||[],n=t[s.scene||0],i=e.animations||[],r=s.asset,a=e.cameras||[];o(n,t,a,i,r)}).catch(e)},c.prototype.markDefs=function(){for(var e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[],i={},r={},a=0,o=t.length;a<o;a++)for(var s=t[a].joints,u=0,h=s.length;u<h;u++)e[s[u]].isBone=!0;for(var c=0,d=e.length;c<d;c++){var l=e[c];void 0!==l.mesh&&(void 0===i[l.mesh]&&(i[l.mesh]=r[l.mesh]=0),i[l.mesh]++,void 0!==l.skin&&(n[l.mesh].isSkinnedMesh=!0))}this.json.meshReferences=i,this.json.meshUses=r},c.prototype.getDependency=function(e,t){var n=e+":"+t,i=this.cache.get(n);i||(i=this["load"+e.charAt(0).toUpperCase()+e.slice(1)](t),this.cache.add(n,i));return i},c.prototype.getDependencies=function(n){var e=this.cache.get(n);if(!e){var i=this,t=this.json[n+("mesh"===n?"es":"s")]||[];e=Promise.all(t.map(function(e,t){return i.getDependency(n,t)})),this.cache.add(n,e)}return e},c.prototype.getMultiDependencies=function(e){for(var n={},t=[],i=0,r=e.length;i<r;i++){var a=e[i],o=this.getDependencies(a);o=o.then(function(e,t){n[e]=t}.bind(this,a+("mesh"===a?"es":"s"))),t.push(o)}return Promise.all(t).then(function(){return n})},c.prototype.loadScene=function(){function E(e,t,n,i,r){var a=i[e],o=n.nodes[e];if(void 0!==o.skin)for(var s=!0===a.isGroup?a.children:[a],u=0,h=s.length;u<h;u++){for(var c=s[u],d=r[o.skin],l=[],p=0,f=d.joints.length;p<f;p++){var _=d.joints[p],v=i[_];if(v){l.push(v);var m=new zen3d.Matrix4;void 0!==d.inverseBindMatrices&&m.fromArray(d.inverseBindMatrices.array,16*p),v.offsetMatrix.copy(m)}else console.warn(\'GLTFLoader: Joint "%s" could not be found.\',_)}var g=new zen3d.Skeleton(l);c.skeleton=g}if(t.add(a),o.children){var y=o.children;for(u=0,h=y.length;u<h;u++){E(y[u],a,n,i,r)}}}return function(e){var o=this.json,s=this.extensions,u=this.json.scenes[e];return this.getMultiDependencies(["node","skin"]).then(function(e){var t=new zen3d.Scene;void 0!==u.name&&(t.name=u.name),u.extras&&(t.userData=u.extras);for(var n=u.nodes||[],i=0,r=n.length;i<r;i++)E(n[i],t,o,e.nodes,e.skins);if(u.extensions&&u.extensions[_.KHR_LIGHTS]&&void 0!==u.extensions[_.KHR_LIGHTS].light){var a=s[_.KHR_LIGHTS].lights;t.add(a[u.extensions[_.KHR_LIGHTS].light])}return t})}}(),c.prototype.loadNode=function(e){this.json;var i=this.extensions,r=this.json.meshReferences,a=this.json.meshUses,o=this.json.nodes[e];return this.getMultiDependencies(["mesh","skin","camera"]).then(function(e){var t;if(!0===o.isBone)t=new zen3d.Bone;else if(void 0!==o.mesh){t=e.meshes[o.mesh].clone(),1<r[o.mesh]&&(t.name+="_instance_"+a[o.mesh]++)}else if(void 0!==o.camera)t=e.cameras[o.camera];else if(o.extensions&&o.extensions[_.KHR_LIGHTS]&&void 0!==o.extensions[_.KHR_LIGHTS].light){t=i[_.KHR_LIGHTS].lights[o.extensions[_.KHR_LIGHTS].light]}else t=new zen3d.Object3D;if(void 0!==o.name&&(t.name=s(o.name)),o.extras&&(t.userData=o.extras),void 0!==o.matrix){var n=new zen3d.Matrix4;n.fromArray(o.matrix),t.matrix.multiplyMatrices(n,t.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale)}else void 0!==o.translation&&t.position.fromArray(o.translation),void 0!==o.rotation&&t.quaternion.fromArray(o.rotation),void 0!==o.scale&&t.scale.fromArray(o.scale);return t})},c.prototype.loadCamera=function(e){console.warn("GLTFLoader: camera is not supported yet")},c.prototype.loadSkin=function(e){console.warn("GLTFLoader: skin is not supported yet")},c.prototype.loadAnimation=function(e){console.warn("GLTFLoader: animation is not supported yet")},c.prototype.loadMesh=function(v){var m=this,g=(this.json,this.extensions,this.json.meshes[v]);return this.getMultiDependencies(["accessor","material"]).then(function(p){var f=new zen3d.Group,_=g.primitives;return m.loadGeometries(_).then(function(e){for(var t=0,n=_.length;t<n;t++){var i=_[t],r=e[t],a=void 0===i.material?new zen3d.PBRMaterial:p.materials[i.material];a.aoMap&&void 0===r.attributes.a_Uv2&&void 0!==r.attributes.a_Uv&&(console.log("GLTFLoader: Duplicating UVs to support aoMap."),r.addAttribute("a_Uv2",new zen3d.BufferAttribute(r.attributes.a_Uv.array,2)));var o,s=void 0!==r.attributes.a_Color,u=void 0===r.attributes.a_Normal,h=!0===g.isSkinnedMesh;if((s||u||h)&&(a.isGLTFSpecularGlossinessMaterial?console.warn("GLTFLoader: GLTFSpecularGlossinessMaterial not support"):a=a.clone()),s&&(a.vertexColors=!0),u&&(a.shading=zen3d.SHADING_TYPE.FLAT_SHADING),i.mode===E.TRIANGLES||i.mode===E.TRIANGLE_STRIP||i.mode===E.TRIANGLE_FAN||void 0===i.mode)o=h?new zen3d.SkinnedMesh(r,a):new zen3d.Mesh(r,a),i.mode===E.TRIANGLE_STRIP?a.drawMode=zen3d.DRAW_MODE.TRIANGLE_STRIP:i.mode===E.TRIANGLE_FAN&&(a.drawMode=zen3d.DRAW_MODE.TRIANGLE_FAN);else if(i.mode===E.LINES||i.mode===E.LINE_STRIP||i.mode===E.LINE_LOOP){console.warn("GLTFLoader: line material may has bug");var c="LineBasicMaterial:"+a.uuid,d=m.cache.get(c);d||(d=new zen3d.LineMaterial,zen3d.Material.prototype.copy.call(d,a),d.color.copy(a.color),d.lights=!1,m.cache.add(c,d)),a=d,o=(i.mode===E.LINES||(i.mode,E.LINE_STRIP),new zen3d.Line(r,a))}else{if(i.mode!==E.POINTS)throw new Error("GLTFLoader: Primitive mode unsupported: "+i.mode);c="PointsMaterial:"+a.uuid;var l=m.cache.get(c);l||(l=new zen3d.PointsMaterial,zen3d.Material.prototype.copy.call(l,a),l.diffuse.copy(a.color),l.diffuseMap=a.map,l.acceptLight=!1,m.cache.add(c,l)),a=l,o=new zen3d.Points(r,a)}if(o.name=g.name||"mesh_"+v,void 0!==g.extras&&(o.userData=g.extras),void 0!==i.extras&&(o.geometry.userData=i.extras),!(1<_.length))return o;o.name+="_"+t,f.add(o)}return f})})},c.prototype.loadGeometries=function(h){var c=this,d=this.extensions,l=this.primitiveCache;return this.getDependencies("accessor").then(function(t){for(var n=[],e=[],i=0,r=h.length;i<r;i++){var a,o=h[i],s=p(l,o);if(s)e.push(s.then(function(e){n.push(e)}));else if(o.extensions&&o.extensions[_.KHR_DRACO_MESH_COMPRESSION]){var u=d[_.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,c).then(function(e){return f(e,o,t),n.push(e),e});l.push({primitive:o,promise:u}),e.push(u)}else f(a=new zen3d.Geometry,o,t),l.push({primitive:o,promise:Promise.resolve(a)}),n.push(a)}return Promise.all(e).then(function(){return n})})},c.prototype.loadAccessor=function(e){var x=this,M=this.json,w=this.json.accessors[e];if(void 0===w.bufferView&&void 0===w.sparse)return null;var t=[];return void 0!==w.bufferView?t.push(this.getDependency("bufferView",w.bufferView)):t.push(null),void 0!==w.sparse&&(t.push(this.getDependency("bufferView",w.sparse.indices.bufferView)),t.push(this.getDependency("bufferView",w.sparse.values.bufferView))),Promise.all(t).then(function(e){var t,n,i=e[0],r=S[w.type],a=z[w.componentType],o=a.BYTES_PER_ELEMENT,s=o*r,u=w.byteOffset||0,h=M.bufferViews[w.bufferView].byteStride,c=!0===w.normalized;if(h&&h!==s){var d="InterleavedBuffer:"+w.bufferView+":"+w.componentType,l=x.cache.get(d);l||(t=new a(i),l=new zen3d.InterleavedBuffer(t,h/o),x.cache.add(d,l)),n=new zen3d.InterleavedBufferAttribute(l,r,u/o,c)}else t=null===i?new a(w.count*r):new a(i,u,w.count*r),n=new zen3d.BufferAttribute(t,r,c);if(void 0!==w.sparse){var p=S.SCALAR,f=z[w.sparse.indices.componentType],_=w.sparse.indices.byteOffset||0,v=w.sparse.values.byteOffset||0,m=new f(e[1],_,w.sparse.count*p),g=new a(e[2],v,w.sparse.count*r);null!==i&&n.setArray(n.array.slice());for(var y=0,E=m.length;y<E;y++){var T=m[y];if(n.array[T*n.itemSize]=g[y*r],2<=r&&(n.array[T*n.itemSize+1]=g[y*r+1]),3<=r&&(n.array[T*n.itemSize+2]=g[y*r+2]),4<=r&&(n.array[T*n.itemSize+3]=g[y*r+3]),5<=r)throw new Error("zen3d.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return n})},c.prototype.loadBufferView=function(e){var i=this.json.bufferViews[e];return this.getDependency("buffer",i.buffer).then(function(e){var t=i.byteLength||0,n=i.byteOffset||0;return e.slice(n,n+t)})},c.prototype.loadBuffer=function(e){var n=this.json.buffers[e],i=this.fileLoader;if(n.type&&"arraybuffer"!==n.type)throw new Error("zen3d.GLTFLoader: "+n.type+" buffer type is not supported.");if(void 0===n.uri&&0===e)return Promise.resolve(this.extensions[_.KHR_BINARY_GLTF].body);var r=this.options;return new Promise(function(e,t){i.load(h(n.uri,r.path),e,void 0,function(){t(new Error(\'zen3d.GLTFLoader: Failed to load buffer "\'+n.uri+\'".\'))})})},c.prototype.loadMaterial=function(e){var n,t=this,i=(this.json,this.extensions,this.json.materials[e]),r={},a=i.extensions||{},o=[];if(a[_.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]);else if(a[_.KHR_MATERIALS_UNLIT]);else if(void 0!==i.pbrMetallicRoughness){n=zen3d.PBRMaterial;var s=i.pbrMetallicRoughness;if(r.color=new zen3d.Color3(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){var u=s.baseColorFactor;r.diffuse.fromArray(u),r.opacity=u[3]}if(void 0!==s.baseColorTexture&&o.push(t.assignTexture(r,"diffuseMap",s.baseColorTexture.index)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture){var h=s.metallicRoughnessTexture.index;o.push(t.assignTexture(r,"metalnessMap",h)),o.push(t.assignTexture(r,"roughnessMap",h))}}else n=zen3d.PhongMaterial;!0===i.doubleSided&&(r.side=zen3d.DRAW_SIDE.DOUBLE);var c=i.alphaMode||x.OPAQUE;return c===x.BLEND?r.transparent=!0:(r.transparent=!1,x.MASK),void 0!==i.normalTexture&&o.push(t.assignTexture(r,"normalMap",i.normalTexture.index)),void 0!==i.occlusionTexture&&(o.push(t.assignTexture(r,"aoMap",i.occlusionTexture.index)),void 0!==i.occlusionTexture.strength&&(r.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&(r.emissive=(new zen3d.Color3).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&o.push(t.assignTexture(r,"emissiveMap",i.emissiveTexture.index)),Promise.all(o).then(function(){var e;for(var t in n===zen3d.ShaderMaterial||(e=new n),r)e[t]=r[t];return e.map&&(e.map.encoding=zen3d.TEXEL_ENCODING_TYPE.SRGB),e.emissiveMap&&(e.emissiveMap.encoding=zen3d.TEXEL_ENCODING_TYPE.SRGB),i.extras&&(e.userData=i.extras),e})},c.prototype.assignTexture=function(t,n,e){return this.getDependency("texture",e).then(function(e){t[n]=e})},c.prototype.loadTexture=function(e){var i=this.json,r=this.options,t=this.textureLoader,a=window.URL||window.webkitURL,o=i.textures[e],n=i.images[o.source],s=n.uri,u=!1;return void 0!==n.bufferView&&(s=this.getDependency("bufferView",n.bufferView).then(function(e){u=!0;var t=new Blob([e],{type:n.mimeType});return s=a.createObjectURL(t)})),Promise.resolve(s).then(function(n){var i=t;return new Promise(function(e,t){i.load(h(n,r.path),e,void 0,t)})}).then(function(e){var t=zen3d.Texture2D.fromImage(e);!0===u&&a.revokeObjectURL(s),t.pixelFormat=void 0!==o.format?M[o.format]:zen3d.WEBGL_PIXEL_FORMAT.RGBA,void 0!==o.internalFormat&&t.pixelFormat!==M[o.internalFormat]&&console.warn("zen3d.GLTFLoader: Three.js does not support texture internalFormat which is different from texture format. internalFormat will be forced to be the same value as format."),t.type=void 0!==o.type?w[o.type]:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_BYTE;var n=(i.samplers||{})[o.sampler]||{};return t.magFilter=A[n.magFilter]||zen3d.WEBGL_TEXTURE_FILTER.LINEAR,t.minFilter=A[n.minFilter]||zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_LINEAR,t.wrapS=b[n.wrapS]||zen3d.WEBGL_TEXTURE_WRAP.REPEAT,t.wrapT=b[n.wrapT]||zen3d.WEBGL_TEXTURE_WRAP.REPEAT,t})};var _={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS:"KHR_lights",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_UNLIT:"KHR_materials_unlit"};function d(e){this.name=_.KHR_LIGHTS,this.lights={};var t=(e.extensions&&e.extensions[_.KHR_LIGHTS]||{}).lights||{};for(var n in t){var i,r=t[n],a=(new zen3d.Color3).fromArray(r.color);switch(r.type){case"directional":(i=new zen3d.DirectionalLight).color.copy(a),i.position.set(0,0,1);break;case"point":(i=new zen3d.PointLight).color.copy(a);break;case"spot":(i=new zen3d.SpotLight).color.copy(a),i.position.set(0,0,1);break;case"ambient":(i=new zen3d.AmbientLight).color.copy(a)}i&&(void 0!==r.constantAttenuation&&(i.intensity=r.constantAttenuation),void 0!==r.linearAttenuation&&(i.distance=1/r.linearAttenuation),void 0!==r.quadraticAttenuation&&(i.decay=r.quadraticAttenuation),void 0!==r.fallOffAngle&&(i.angle=r.fallOffAngle),void 0!==r.fallOffExponent&&console.warn("GLTFLoader:: light.fallOffExponent not currently supported."),i.name=r.name||"light_"+n,this.lights[n]=i)}}var l="glTF",v=12,m={JSON:1313821514,BIN:5130562};function g(e){this.name=_.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,v);if(this.header={magic:u(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==l)throw new Error("GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.");for(var n=new DataView(e,v),i=0;i<n.byteLength;){var r=n.getUint32(i,!0);i+=4;var a=n.getUint32(i,!0);if(i+=4,a===m.JSON){var o=new Uint8Array(e,v+i,r);this.content=u(o)}else if(a===m.BIN){var s=v+i;this.body=e.slice(s,s+r)}i+=r}if(null===this.content)throw new Error("GLTFLoader: JSON content not found.")}function y(e){if(!e)throw new Error("GLTFLoader: No DRACOLoader instance provided.");this.name=_.KHR_DRACO_MESH_COMPRESSION,this.dracoLoader=e}y.prototype.decodePrimitive=function(e,t){var n=this.dracoLoader,i=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={};for(var o in r)o in T&&(a[T[o]]=r[o]);return t.getDependency("bufferView",i).then(function(t){return new Promise(function(e){n.decodeDracoFile(t,e,a)})})};var E={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},T={POSITION:"a_Position",NORMAL:"a_Normal",TEXCOORD_0:"a_Uv",TEXCOORD0:"a_Uv",TEXCOORD:"a_Uv",TEXCOORD_1:"a_Uv2",COLOR_0:"a_Color",COLOR0:"a_Color",COLOR:"a_Color",WEIGHTS_0:"skinWeight",WEIGHT:"skinWeight",JOINTS_0:"skinIndex",JOINT:"skinIndex"},S={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},z={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},x={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},M={6406:zen3d.WEBGL_PIXEL_FORMAT.ALPHA,6407:zen3d.WEBGL_PIXEL_FORMAT.RGB,6408:zen3d.WEBGL_PIXEL_FORMAT.RGBA,6409:zen3d.WEBGL_PIXEL_FORMAT.LUMINANCE,6410:zen3d.WEBGL_PIXEL_FORMAT.LUMINANCE_ALPHA},w={5121:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_BYTE,32819:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_SHORT_4_4_4_4,32820:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_SHORT_5_5_5_1,33635:zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_SHORT_5_6_5},A={9728:zen3d.WEBGL_TEXTURE_FILTER.NEAREST,9729:zen3d.WEBGL_TEXTURE_FILTER.LINEAR,9984:zen3d.WEBGL_TEXTURE_FILTER.NEAREST_MIPMAP_NEAREST,9985:zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_NEAREST,9986:zen3d.WEBGL_TEXTURE_FILTER.NEAREST_MIPMAP_LINEAR,9987:zen3d.WEBGL_TEXTURE_FILTER.LINEAR_MIPMAP_LINEAR},b={33071:zen3d.WEBGL_TEXTURE_WRAP.CLAMP_TO_EDGE,33648:zen3d.WEBGL_TEXTURE_WRAP.MIRRORED_REPEAT,10497:zen3d.WEBGL_TEXTURE_WRAP.REPEAT}}(),function(){var e=function(){this._entities={},this.enableCounter=!1};e.prototype.getEntity=function(e){return this._entities[e]},e.prototype.getFps=function(){var e=this.getEntity("fps");return e&&e.averageDelta?Math.floor(1e3/e.averageDelta):0},e.prototype.updateFps=function(){this.enableCounter&&(this.endCounter("fps"),this.startCounter("fps",60))},e.prototype.getNow=function(){return window.performance?window.performance.now():(new Date).getTime()},e.prototype.startCounter=function(e,t){if(this.enableCounter){var n=this._entities[e];n||(n={start:0,end:0,delta:0,_cache:[],averageRange:1,averageDelta:0},this._entities[e]=n),n.start=this.getNow(),n.averageRange=t||1}},e.prototype.endCounter=function(e){if(this.enableCounter){var t=this._entities[e];if(t&&(t.end=this.getNow(),t.delta=t.end-t.start,1<t.averageRange)){t._cache.push(t.delta);var n=t._cache.length;if(n>=t.averageRange){n>t.averageRange&&(t._cache.shift(),n--);for(var i=0,r=0;r<n;r++)i+=t._cache[r];t.averageDelta=i/n}}}},zen3d.Performance=e}(),function(){var e=function(e,t){this.camera=e,this.lookAtPoint=t,this.up=new zen3d.Vector3(0,1,0),this.distance=100,this._panAngle=0,this._panRad=0,this.minPanAngle=-1/0,this.maxPanAngle=1/0,this._tiltAngle=0,this._tiltRad=0,this.minTileAngle=-90,this.maxTileAngle=90,this.bindMouse=void 0,this._lastMouseX,this._lastMouseY,this._mouseDown=!1,this.bindTouch=void 0,this._lastTouchX,this._lastTouchY,this._fingerTwo=!1,this._lastDistance};Object.defineProperties(e.prototype,{panAngle:{get:function(){return this._panAngle},set:function(e){this._panAngle=Math.max(this.minPanAngle,Math.min(this.maxPanAngle,e)),this._panRad=this._panAngle*Math.PI/180}},tiltAngle:{get:function(){return this._tiltAngle},set:function(e){this._tiltAngle=Math.max(this.minTileAngle,Math.min(this.maxTileAngle,e)),this._tiltRad=this._tiltAngle*Math.PI/180}}}),e.prototype.update=function(){this.bindMouse&&this._updateMouse(),this.bindTouch&&this._updateTouch();var e=this.distance*Math.sin(this._panRad)*Math.cos(this._tiltRad),t=this.distance*Math.sin(this._tiltRad),n=this.distance*Math.cos(this._panRad)*Math.cos(this._tiltRad),i=this.camera,r=this.lookAtPoint;i.position.set(e+r.x,t+r.y,n+r.z),i.setLookAt(r,this.up)},e.prototype._updateMouse=function(){var e=this.bindMouse;if(e.isPressed(0))if(this._mouseDown&&null!=this._lastMouseX&&null!=this._lastMouseY){var t=e.position.x-this._lastMouseX,n=e.position.y-this._lastMouseY;this.panAngle-=t,this.tiltAngle+=n,this._lastMouseX=e.position.x,this._lastMouseY=e.position.y}else this._mouseDown=!0,this._lastMouseX=e.position.x,this._lastMouseY=e.position.y;else e.wasReleased(0)&&(this._mouseDown=!1);this.distance=Math.max(this.distance-2*e.wheel,1)};var u=new zen3d.Vector2,h=new zen3d.Vector2;e.prototype._updateTouch=function(e){if(0<(e=this.bindTouch).touchCount)if(1==e.touchCount){var t=e.getTouch(0);if(t.phase==zen3d.TouchPhase.BEGAN||this._fingerTwo||null==this._lastTouchX||null==this._lastTouchY)this._lastTouchX=t.position.x,this._lastTouchY=t.position.y;else{var n=t.position.x-this._lastTouchX,i=t.position.y-this._lastTouchY;this.panAngle-=.5*n,this.tiltAngle+=.5*i,this._lastTouchX=t.position.x,this._lastTouchY=t.position.y}this._fingerTwo=!1}else if(2==e.touchCount){var r=e.getTouch(0),a=e.getTouch(1);if(r.phase==zen3d.TouchPhase.BEGAN||a.phase==zen3d.TouchPhase.BEGAN||0==this._fingerTwo||null==this._lastDistance)u.set(r.position.x,r.position.y),h.set(a.position.x,a.position.y),this._lastDistance=u.distanceTo(h);else{u.set(r.position.x,r.position.y),h.set(a.position.x,a.position.y);var o=u.distanceTo(h),s=o-this._lastDistance;this.distance=Math.max(this.distance-s,1),this._lastDistance=o}this._fingerTwo=!0}else this._fingerTwo=!1},zen3d.HoverController=e}(),function(){var e=function(e){this.camera=e,this.camera.euler.order="YXZ",this.bindKeyboard=void 0,this.bindMouse=void 0,this._lastMouseX,this._lastMouseY,this._mouseDown=!1};e.prototype.update=function(){this.bindKeyboard&&this.keyboardUpdate(),this.bindMouse&&this.mouseUpdate()};var i=new zen3d.Vector3,t=new zen3d.Vector3,n=new zen3d.Vector3;e.prototype.keyboardUpdate=function(){var e=this.bindKeyboard;i.set(0,0,-1).applyQuaternion(this.camera.quaternion),t.set(0,1,0).applyQuaternion(this.camera.quaternion),n.set(1,0,0).applyQuaternion(this.camera.quaternion),e.isPressed("W")&&this.camera.position.add(i),e.isPressed("A")&&this.camera.position.sub(n),e.isPressed("S")&&this.camera.position.sub(i),e.isPressed("D")&&this.camera.position.add(n),e.isPressed("E")&&this.camera.position.add(t),e.isPressed("Q")&&this.camera.position.sub(t)},e.prototype.mouseUpdate=function(){var e=this.bindMouse;if(e.isPressed(0))if(this._mouseDown&&null!=this._lastMouseX&&null!=this._lastMouseY){var t=e.position.x-this._lastMouseX,n=e.position.y-this._lastMouseY;this.camera.euler.x-=.01*n,this.camera.euler.y-=.01*t,this._lastMouseX=e.position.x,this._lastMouseY=e.position.y}else this._mouseDown=!0,this._lastMouseX=e.position.x,this._lastMouseY=e.position.y;else e.wasReleased(0)&&(this._mouseDown=!1);0!==e.wheel&&(i.set(0,0,-1).applyQuaternion(this.camera.quaternion).multiplyScalar(e.wheel),this.camera.position.add(i))},zen3d.FreeController=e}();\n\\ No newline at end of file\ndiff --git a/src/core/objects/Scene.js b/src/core/objects/Scene.js\nindex d651e03c..af456845 100644\n--- a/src/core/objects/Scene.js\n+++ b/src/core/objects/Scene.js\n@@ -20,7 +20,7 @@\n     zen3d.inherit(Scene, zen3d.Object3D);\n \n     /**\n-     * TODO seperate this method updateMatrix/updateLight/updateRenderList\n+     * TODO seperate this method updateMatrix/updateContext/updateRenderList\n      * update scene matrix and cache it\n      * @param {Camera} camera main camera for this scene\n      */\ndiff --git a/src/core/render/RenderCache.js b/src/core/render/RenderCache.js\nindex 0f71d962..89e00946 100644\n--- a/src/core/render/RenderCache.js\n+++ b/src/core/render/RenderCache.js\n@@ -80,8 +80,6 @@\n         }\n         this.renderLists = renderLists;\n \n-        this.shadowObjects = new Array();\n-\n         // lights\n         this.lights = {\n             ambient: new Float32Array([0, 0, 0, 1]),\n@@ -172,15 +170,6 @@\n                                 group: group\n                             });\n \n-                            if (object.castShadow) {\n-                                this.shadowObjects.push({\n-                                    object: object,\n-                                    geometry: object.geometry,\n-                                    material: groupMaterial,\n-                                    z: helpVector3.z,\n-                                    group: group\n-                                });\n-                            }\n                         }\n                     }\n                 } else {\n@@ -190,15 +179,6 @@\n                         material: object.material,\n                         z: helpVector3.z\n                     });\n-\n-                    if (object.castShadow) {\n-                        this.shadowObjects.push({\n-                            object: object,\n-                            geometry: object.geometry,\n-                            material: object.material,\n-                            z: helpVector3.z\n-                        });\n-                    }\n                 }\n \n                 break;\n@@ -484,8 +464,6 @@\n             renderLists[layer].length = 0;\n         }\n \n-        this.shadowObjects.length = 0;\n-\n         var lights = this.lights;\n         for(var i = 0; i < 3; i++) {\n             lights.ambient[i] = 0;\ndiff --git a/src/core/render/WebGL/WebGLCore.js b/src/core/render/WebGL/WebGLCore.js\nindex 80d29c9b..bad24052 100644\n--- a/src/core/render/WebGL/WebGLCore.js\n+++ b/src/core/render/WebGL/WebGLCore.js\n@@ -81,6 +81,7 @@\n      * @param {zen3d.Camera} camera Camera provide view matrix and porjection matrix.\n      * @param {Object} [config] ?\n      * @param {Function} [config.getMaterial] Get renderable material.\n+     * @param {Function} [config.ifRender] If render the renderable.\n      * @param {RenderCache} [config.cache] render cache\n      */\n     WebGLCore.prototype.renderPass = function(renderList, camera, config) {\n@@ -96,8 +97,12 @@\n         var targetHeight = state.currentRenderTarget.height;\n \n         for (var i = 0, l = renderList.length; i < l; i++) {\n-\n             var renderItem = renderList[i];\n+\n+            if(config.ifRender && !config.ifRender(renderItem)) {\n+                continue;\n+            }\n+            \n             var object = renderItem.object;\n             var material = getMaterial.call(this, renderItem);\n             var geometry = renderItem.geometry;\ndiff --git a/src/core/render/prePass/ShadowMapPass.js b/src/core/render/prePass/ShadowMapPass.js\nindex e3a2fe4f..eb64d2c0 100644\n--- a/src/core/render/prePass/ShadowMapPass.js\n+++ b/src/core/render/prePass/ShadowMapPass.js\n@@ -1,4 +1,7 @@\n (function() {\n+    var RENDER_LAYER = zen3d.RENDER_LAYER;\n+    var LAYER_RENDER_LIST = zen3d.LAYER_RENDER_LIST;\n+\n     var ShadowMapPass = function() {\n         this.depthMaterial = new zen3d.DepthMaterial();\n         this.depthMaterial.packToRGBA = true;\n@@ -26,7 +29,7 @@\n             var shadowTarget = shadow.renderTarget;\n             var isPointLight = light.lightType == zen3d.LIGHT_TYPE.POINT ? true : false;\n             var faces = isPointLight ? 6 : 1;\n-            var renderList = scene.cache.shadowObjects;\n+            var renderLists = scene.cache.renderLists;\n \n             for (var j = 0; j < faces; j++) {\n \n@@ -42,20 +45,20 @@\n                 state.clearColor(1, 1, 1, 1);\n                 glCore.clear(true, true);\n \n-                if (renderList.length == 0) {\n-                    continue;\n-                }\n-\n                 var material = isPointLight ? this.distanceMaterial : this.depthMaterial;\n                 material.uniforms = material.uniforms || {};\n                 material.uniforms["nearDistance"] = shadow.cameraNear;\n                 material.uniforms["farDistance"] = shadow.cameraFar;\n \n-                glCore.renderPass(renderList, camera, {\n+                // ignore transparent objects\n+                glCore.renderPass(renderLists[RENDER_LAYER.DEFAULT], camera, {\n                     getMaterial: function(renderable) {\n                         // copy draw side\n                         material.side = renderable.material.side;\n                         return material;\n+                    },\n+                    ifRender: function(renderable) {\n+                        return renderable.object.castShadow;\n                     }\n                 });\n \n', 'commit_subject': 'add ifRender option for WebGLCore.renderPass method', 'repo_name': 'shawn0326/zen-3d', 'committer': {'name': 'ShawnXie', 'email': '42b7c09476605f2d3029cbf0b282a691785de43b@163.com', 'time_sec': '1524478910', 'tz_offset': '480', 'date': {'seconds': '1524478910'}}, 'commit_tree': '2727abfd97ad6b281f6605c271ad146d06f38f30', 'commit_message': 'add ifRender option for WebGLCore.renderPass method\n', 'language_name': 'HTML', 'license': 'mit', 'hunks': '@@ -1,4 +1,7 @@\n (function() {\n+    var RENDER_LAYER = zen3d.RENDER_LAYER;\n+    var LAYER_RENDER_LIST = zen3d.LAYER_RENDER_LIST;\n+\n     var ShadowMapPass = function() {\n         this.depthMaterial = new zen3d.DepthMaterial();\n         this.depthMaterial.packToRGBA = true;\n@@ -26,7 +29,7 @@\n             var shadowTarget = shadow.renderTarget;\n             var isPointLight = light.lightType == zen3d.LIGHT_TYPE.POINT ? true : false;\n             var faces = isPointLight ? 6 : 1;\n-            var renderList = scene.cache.shadowObjects;\n+            var renderLists = scene.cache.renderLists;\n \n             for (var j = 0; j < faces; j++) {\n \n@@ -42,20 +45,20 @@\n                 state.clearColor(1, 1, 1, 1);\n                 glCore.clear(true, true);\n \n-                if (renderList.length == 0) {\n-                    continue;\n-                }\n-\n                 var material = isPointLight ? this.distanceMaterial : this.depthMaterial;\n                 material.uniforms = material.uniforms || {};\n                 material.uniforms["nearDistance"] = shadow.cameraNear;\n                 material.uniforms["farDistance"] = shadow.cameraFar;\n \n-                glCore.renderPass(renderList, camera, {\n+                // ignore transparent objects\n+                glCore.renderPass(renderLists[RENDER_LAYER.DEFAULT], camera, {\n                     getMaterial: function(renderable) {\n                         // copy draw side\n                         material.side = renderable.material.side;\n                         return material;\n+                    },\n+                    ifRender: function(renderable) {\n+                        return renderable.object.castShadow;\n                     }\n                 });\n \n', 'addition_count': 9, 'deletion_count': 6, 'src_file': 'a/src/core/render/prePass/ShadowMapPass.js', 'tgt_file': 'b/src/core/render/prePass/ShadowMapPass.js', 'file_extension': '.js', 'before_file': '(function() {\n    var ShadowMapPass = function() {\n        this.depthMaterial = new zen3d.DepthMaterial();\n        this.depthMaterial.packToRGBA = true;\nvar defaultDepthMaterial = new DepthMaterial();\ndefaultDepthMaterial.packToRGBA = true;\n\nvar defaultDistanceMaterial = new DistanceMaterial();\ndefaultDistanceMaterial.uniforms = {};\n\nfunction _getDepthMaterial(renderable, light) {\n\tdefaultDepthMaterial.side = shadowSide[renderable.material.side];\n\treturn defaultDepthMaterial;\n}\n\nfunction _getDistanceMaterial(renderable, light) {\n\tdefaultDistanceMaterial.side = shadowSide[renderable.material.side];\n\tdefaultDistanceMaterial.uniforms["nearDistance"] = light.shadow.cameraNear;\n\tdefaultDistanceMaterial.uniforms["farDistance"] = light.shadow.cameraFar;\n\treturn defaultDistanceMaterial;\n}\n\nvar oldClearColor = new Vector4();\n\n/**\n            var shadowTarget = shadow.renderTarget;\n            var isPointLight = light.lightType == zen3d.LIGHT_TYPE.POINT ? true : false;\n            var faces = isPointLight ? 6 : 1;\n            var renderList = scene.cache.shadowObjects;\n\n            for (var j = 0; j < faces; j++) {\n\n\t * Override this to use custom depth material.\n\t * @type {Function}\n\t */\n\tthis.getDepthMaterial = _getDepthMaterial;\n\n\t/**\n\t * Get distance material function.\n\t * Override this to use custom distance material.\n\t * @type {Function}\n                state.clearColor(1, 1, 1, 1);\n                glCore.clear(true, true);\n\n                if (renderList.length == 0) {\n                    continue;\n                }\n\n                var material = isPointLight ? this.distanceMaterial : this.depthMaterial;\n                material.uniforms = material.uniforms || {};\n                material.uniforms["nearDistance"] = shadow.cameraNear;\n                material.uniforms["farDistance"] = shadow.cameraFar;\n\n                glCore.renderPass(renderList, camera, {\n                    getMaterial: function(renderable) {\n                        // copy draw side\n                        material.side = renderable.material.side;\n                        return material;\n                    }\n                });\n\n\t}\n\n\toldClearColor.copy(state.colorBuffer.getClear());\n\tstate.colorBuffer.setClear(1, 1, 1, 1);\n\n\tvar lights = scene.lights.shadows;\n\tfor (var i = 0; i < lights.length; i++) {\n\t\tvar light = lights[i];\n\n\t\tvar shadow = light.shadow;\n\n\t\tif (shadow.autoUpdate === false && shadow.needsUpdate === false) continue;\n\n\t\tvar camera = shadow.camera;\n\t\tvar shadowTarget = shadow.renderTarget;\n\t\tvar isPointLight = light.lightType == LIGHT_TYPE.POINT ? true : false;\n\t\tvar faces = isPointLight ? 6 : 1;\n\n\t\tif (glCore.capabilities.version >= 2) {\n\t\t\tif (!isPointLight && !shadow.depthMap && !glCore.disableShadowSampler) {\n\t\t\t\tshadow._initDepthMap();\n\t\t\t}\n\t\t}\n\n\t\tfor (var j = 0; j < faces; j++) {\n\t\t\tif (isPointLight) {\n\t\t\t\tshadow.update(light, j);\n\t\t\t\tshadowTarget.activeCubeFace = j;\n\t\t\t} else {\n\t\t\t\tshadow.update(light);\n\t\t\t}\n\n\t\t\tvar renderList = scene.updateRenderList(camera);\n\n\t\t\tglCore.renderTarget.setRenderTarget(shadowTarget);\n\n\t\t\tglCore.clear(true, true);\n\n\t\t\tglCore.renderPass(renderList.opaque, camera, {\n\t\t\t\tgetMaterial: function(renderable) {\n\t\t\t\t\treturn isPointLight ? getDistanceMaterial(renderable, light) : getDepthMaterial(renderable, light);\n\t\t\t\t},\n\t\t\t\tifRender: function(renderable) {\n\t\t\t\t\treturn renderable.object.castShadow;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// ignore transparent objects?\n\t\t}\n\n\t\t// set generateMipmaps false\n\t\t// glCore.renderTarget.updateRenderTargetMipmap(shadowTarget);\n\n\t\tshadow.needsUpdate = false;\n\t}\n\n\tif (useStencil) {\n\t\tstate.stencilBuffer.setTest(true);\n\t}\n\n\tstate.colorBuffer.setClear(oldClearColor.x, oldClearColor.y, oldClearColor.z, oldClearColor.w);\n}\n\nexport { ShadowMapPass };', 'message': 'add ifRender option for WebGLCore.renderPass method\n', 'author_name': 'ShawnXie', 'lang': 'js'}