From f38485286f9f995a15eafc0da4dde9da535f283b Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sun, 10 Apr 2016 02:18:36 +0100 Subject: [PATCH] Updated builds. --- build/three.js | 136 +++++++++++++++++--- build/three.min.js | 227 +++++++++++++++++----------------- utils/build/externs/common.js | 1 + 3 files changed, 237 insertions(+), 127 deletions(-) diff --git a/build/three.js b/build/three.js index c6980dacea..9407ed6b2b 100644 --- a/build/three.js +++ b/build/three.js @@ -274,6 +274,7 @@ THREE.LuminanceFormat = 1022; THREE.LuminanceAlphaFormat = 1023; // THREE.RGBEFormat handled as THREE.RGBAFormat in shaders THREE.RGBEFormat = THREE.RGBAFormat; //1024; +THREE.DepthFormat = 1026; // DDS / ST3C Compressed texture formats @@ -22172,6 +22173,31 @@ THREE.EventDispatcher.prototype.apply( THREE.Texture.prototype ); THREE.TextureIdCount = 0; +// File:src/textures/DepthTexture.js + +/** + * @author Matt DesLauriers / @mattdesl + */ + +THREE.DepthTexture = function ( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy ) { + + THREE.Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, THREE.DepthFormat, type, anisotropy ); + + this.image = { width: width, height: height }; + + this.type = type !== undefined ? type : THREE.UnsignedShortType; + + this.magFilter = magFilter !== undefined ? magFilter : THREE.NearestFilter; + this.minFilter = minFilter !== undefined ? minFilter : THREE.NearestFilter; + + this.flipY = false; + this.generateMipmaps = false; + +}; + +THREE.DepthTexture.prototype = Object.create( THREE.Texture.prototype ); +THREE.DepthTexture.prototype.constructor = THREE.DepthTexture; + // File:src/textures/CanvasTexture.js /** @@ -24981,8 +25007,10 @@ THREE.WebGLRenderer = function ( parameters ) { } + var _isWebGL2 = (typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext); var extensions = new THREE.WebGLExtensions( _gl ); + extensions.get( 'WEBGL_depth_texture' ); extensions.get( 'OES_texture_float' ); extensions.get( 'OES_texture_float_linear' ); extensions.get( 'OES_texture_half_float' ); @@ -25345,23 +25373,33 @@ THREE.WebGLRenderer = function ( parameters ) { var renderTargetProperties = properties.get( renderTarget ); var textureProperties = properties.get( renderTarget.texture ); - if ( ! renderTarget || textureProperties.__webglTexture === undefined ) return; + if ( ! renderTarget ) return; + + if ( textureProperties.__webglTexture !== undefined ) { - _gl.deleteTexture( textureProperties.__webglTexture ); + _gl.deleteTexture( textureProperties.__webglTexture ); + + } + + if ( renderTarget.depthTexture ) { + + renderTarget.depthTexture.dispose(); + + } if ( renderTarget instanceof THREE.WebGLRenderTargetCube ) { for ( var i = 0; i < 6; i ++ ) { _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] ); - _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] ); + if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] ); } } else { _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer ); - _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer ); + if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer ); } @@ -27877,7 +27915,27 @@ THREE.WebGLRenderer = function ( parameters ) { var mipmap, mipmaps = texture.mipmaps; - if ( texture instanceof THREE.DataTexture ) { + if ( texture instanceof THREE.DepthTexture ) { + + // populate depth texture with dummy data + + var internalFormat = _gl.DEPTH_COMPONENT; + + if ( texture.type === THREE.FloatType ) { + + if ( !_isWebGL2 ) throw new Error('Float Depth Texture only supported in WebGL2.0'); + internalFormat = _gl.DEPTH_COMPONENT32F; + + } else if ( _isWebGL2 ) { + + // WebGL 2.0 requires signed internalformat for glTexImage2D + internalFormat = _gl.DEPTH_COMPONENT16; + + } + + state.texImage2D( _gl.TEXTURE_2D, 0, internalFormat, image.width, image.height, 0, glFormat, glType, null ); + + } else if ( texture instanceof THREE.DataTexture ) { // use manually created mipmaps if available // if there are no manual mipmaps @@ -28219,6 +28277,36 @@ THREE.WebGLRenderer = function ( parameters ) { } + // Setup resources for a Depth Texture for a FBO (needs an extension) + function setupDepthTexture ( framebuffer, renderTarget ) { + + var isCube = ( renderTarget instanceof THREE.WebGLRenderTargetCube ); + if ( isCube ) throw new Error('Depth Texture with cube render targets is not supported!'); + + _gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer ); + + if ( !( renderTarget.depthTexture instanceof THREE.DepthTexture ) ) { + + throw new Error('renderTarget.depthTexture must be an instance of THREE.DepthTexture'); + + } + + // upload an empty depth texture with framebuffer size + if ( !properties.get( renderTarget.depthTexture ).__webglTexture || + renderTarget.depthTexture.image.width !== renderTarget.width || + renderTarget.depthTexture.image.height !== renderTarget.height ) { + renderTarget.depthTexture.image.width = renderTarget.width; + renderTarget.depthTexture.image.height = renderTarget.height; + renderTarget.depthTexture.needsUpdate = true; + } + + _this.setTexture( renderTarget.depthTexture, 0 ); + + var webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture; + _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 ); + + } + // Setup GL resources for a non-texture depth buffer function setupDepthRenderbuffer( renderTarget ) { @@ -28226,23 +28314,33 @@ THREE.WebGLRenderer = function ( parameters ) { var isCube = ( renderTarget instanceof THREE.WebGLRenderTargetCube ); - if ( isCube ) { + if ( renderTarget.depthTexture ) { - renderTargetProperties.__webglDepthbuffer = []; + if ( isCube ) throw new Error('target.depthTexture not supported in Cube render targets'); - for ( var i = 0; i < 6; i ++ ) { + setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget ); - _gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] ); - renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer(); - setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget ); + } else { - } + if ( isCube ) { - } else { + renderTargetProperties.__webglDepthbuffer = []; + + for ( var i = 0; i < 6; i ++ ) { - _gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer ); - renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer(); - setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget ); + _gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] ); + renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer(); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget ); + + } + + } else { + + _gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer ); + renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer(); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget ); + + } } @@ -28527,6 +28625,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( p === THREE.RGBAFormat ) return _gl.RGBA; if ( p === THREE.LuminanceFormat ) return _gl.LUMINANCE; if ( p === THREE.LuminanceAlphaFormat ) return _gl.LUMINANCE_ALPHA; + if ( p === THREE.DepthFormat ) return _gl.DEPTH_COMPONENT; if ( p === THREE.AddEquation ) return _gl.FUNC_ADD; if ( p === THREE.SubtractEquation ) return _gl.FUNC_SUBTRACT; @@ -28623,6 +28722,7 @@ THREE.WebGLRenderTarget = function ( width, height, options ) { this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true; + this.depthTexture = null; }; @@ -28663,6 +28763,7 @@ THREE.WebGLRenderTarget.prototype = { this.depthBuffer = source.depthBuffer; this.stencilBuffer = source.stencilBuffer; + this.depthTexture = source.depthTexture; return this; @@ -28854,6 +28955,9 @@ THREE.WebGLExtensions = function ( gl ) { switch ( name ) { + case 'WEBGL_depth_texture': + extension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' ); + case 'EXT_texture_filter_anisotropic': extension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' ); break; diff --git a/build/three.min.js b/build/three.min.js index 23950c750b..4b72264639 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -5,7 +5,7 @@ THREE.CullFaceNone=0;THREE.CullFaceBack=1;THREE.CullFaceFront=2;THREE.CullFaceFr THREE.CustomBlending=5;THREE.AddEquation=100;THREE.SubtractEquation=101;THREE.ReverseSubtractEquation=102;THREE.MinEquation=103;THREE.MaxEquation=104;THREE.ZeroFactor=200;THREE.OneFactor=201;THREE.SrcColorFactor=202;THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;THREE.OneMinusSrcAlphaFactor=205;THREE.DstAlphaFactor=206;THREE.OneMinusDstAlphaFactor=207;THREE.DstColorFactor=208;THREE.OneMinusDstColorFactor=209;THREE.SrcAlphaSaturateFactor=210;THREE.NeverDepth=0;THREE.AlwaysDepth=1; THREE.LessDepth=2;THREE.LessEqualDepth=3;THREE.EqualDepth=4;THREE.GreaterEqualDepth=5;THREE.GreaterDepth=6;THREE.NotEqualDepth=7;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.AddOperation=2;THREE.NoToneMapping=0;THREE.LinearToneMapping=1;THREE.ReinhardToneMapping=2;THREE.Uncharted2ToneMapping=3;THREE.CineonToneMapping=4;THREE.UVMapping=300;THREE.CubeReflectionMapping=301;THREE.CubeRefractionMapping=302;THREE.EquirectangularReflectionMapping=303;THREE.EquirectangularRefractionMapping=304; THREE.SphericalReflectionMapping=305;THREE.CubeUVReflectionMapping=306;THREE.CubeUVRefractionMapping=307;THREE.RepeatWrapping=1E3;THREE.ClampToEdgeWrapping=1001;THREE.MirroredRepeatWrapping=1002;THREE.NearestFilter=1003;THREE.NearestMipMapNearestFilter=1004;THREE.NearestMipMapLinearFilter=1005;THREE.LinearFilter=1006;THREE.LinearMipMapNearestFilter=1007;THREE.LinearMipMapLinearFilter=1008;THREE.UnsignedByteType=1009;THREE.ByteType=1010;THREE.ShortType=1011;THREE.UnsignedShortType=1012; -THREE.IntType=1013;THREE.UnsignedIntType=1014;THREE.FloatType=1015;THREE.HalfFloatType=1025;THREE.UnsignedShort4444Type=1016;THREE.UnsignedShort5551Type=1017;THREE.UnsignedShort565Type=1018;THREE.AlphaFormat=1019;THREE.RGBFormat=1020;THREE.RGBAFormat=1021;THREE.LuminanceFormat=1022;THREE.LuminanceAlphaFormat=1023;THREE.RGBEFormat=THREE.RGBAFormat;THREE.RGB_S3TC_DXT1_Format=2001;THREE.RGBA_S3TC_DXT1_Format=2002;THREE.RGBA_S3TC_DXT3_Format=2003;THREE.RGBA_S3TC_DXT5_Format=2004; +THREE.IntType=1013;THREE.UnsignedIntType=1014;THREE.FloatType=1015;THREE.HalfFloatType=1025;THREE.UnsignedShort4444Type=1016;THREE.UnsignedShort5551Type=1017;THREE.UnsignedShort565Type=1018;THREE.AlphaFormat=1019;THREE.RGBFormat=1020;THREE.RGBAFormat=1021;THREE.LuminanceFormat=1022;THREE.LuminanceAlphaFormat=1023;THREE.RGBEFormat=THREE.RGBAFormat;THREE.DepthFormat=1026;THREE.RGB_S3TC_DXT1_Format=2001;THREE.RGBA_S3TC_DXT1_Format=2002;THREE.RGBA_S3TC_DXT3_Format=2003;THREE.RGBA_S3TC_DXT5_Format=2004; THREE.RGB_PVRTC_4BPPV1_Format=2100;THREE.RGB_PVRTC_2BPPV1_Format=2101;THREE.RGBA_PVRTC_4BPPV1_Format=2102;THREE.RGBA_PVRTC_2BPPV1_Format=2103;THREE.RGB_ETC1_Format=2151;THREE.LoopOnce=2200;THREE.LoopRepeat=2201;THREE.LoopPingPong=2202;THREE.InterpolateDiscrete=2300;THREE.InterpolateLinear=2301;THREE.InterpolateSmooth=2302;THREE.ZeroCurvatureEnding=2400;THREE.ZeroSlopeEnding=2401;THREE.WrapAroundEnding=2402;THREE.TrianglesDrawMode=0;THREE.TriangleStripDrawMode=1;THREE.TriangleFanDrawMode=2; THREE.LinearEncoding=3E3;THREE.sRGBEncoding=3001;THREE.GammaEncoding=3007;THREE.RGBEEncoding=3002;THREE.LogLuvEncoding=3003;THREE.RGBM7Encoding=3004;THREE.RGBM16Encoding=3005;THREE.RGBDEncoding=3006;THREE.AutoDepthFormat=3100;THREE.LinearClipZDepthFormat=3101;THREE.InvClipZDepthFormat=3102;THREE.LinearDepthPacking=3200;THREE.RGBADepthPacking=3201;THREE.Color=function(a){return 3===arguments.length?this.fromArray(arguments):this.set(a)}; THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,set:function(a){a instanceof THREE.Color?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1a.x||1a.x?0:1;break;case THREE.MirroredRepeatWrapping:1===Math.abs(Math.floor(a.x)%2)?a.x=Math.ceil(a.x)-a.x:a.x-=Math.floor(a.x)}if(0>a.y||1a.y?0:1;break;case THREE.MirroredRepeatWrapping:1=== -Math.abs(Math.floor(a.y)%2)?a.y=Math.ceil(a.y)-a.y:a.y-=Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};THREE.EventDispatcher.prototype.apply(THREE.Texture.prototype);THREE.TextureIdCount=0;THREE.CanvasTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.needsUpdate=!0};THREE.CanvasTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CanvasTexture.prototype.constructor=THREE.CanvasTexture; +Math.abs(Math.floor(a.y)%2)?a.y=Math.ceil(a.y)-a.y:a.y-=Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};THREE.EventDispatcher.prototype.apply(THREE.Texture.prototype);THREE.TextureIdCount=0;THREE.DepthTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,null,d,e,f,g,h,THREE.DepthFormat,c,k);this.image={width:a,height:b};this.type=void 0!==c?c:THREE.UnsignedShortType;this.magFilter=void 0!==g?g:THREE.NearestFilter;this.minFilter=void 0!==h?h:THREE.NearestFilter;this.generateMipmaps=this.flipY=!1}; +THREE.DepthTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DepthTexture.prototype.constructor=THREE.DepthTexture;THREE.CanvasTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.needsUpdate=!0};THREE.CanvasTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CanvasTexture.prototype.constructor=THREE.CanvasTexture; THREE.CubeTexture=function(a,b,c,d,e,f,g,h,k,l){a=void 0!==a?a:[];b=void 0!==b?b:THREE.CubeReflectionMapping;THREE.Texture.call(this,a,b,c,d,e,f,g,h,k,l);this.flipY=!1};THREE.CubeTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CubeTexture.prototype.constructor=THREE.CubeTexture;Object.defineProperty(THREE.CubeTexture.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}}); THREE.CompressedTexture=function(a,b,c,d,e,f,g,h,k,l,n,p){THREE.Texture.call(this,null,f,g,h,k,l,d,e,n,p);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1};THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CompressedTexture.prototype.constructor=THREE.CompressedTexture; THREE.DataTexture=function(a,b,c,d,e,f,g,h,k,l,n,p){THREE.Texture.call(this,null,f,g,h,k,l,d,e,n,p);this.image={data:a,width:b,height:c};this.magFilter=void 0!==k?k:THREE.NearestFilter;this.minFilter=void 0!==l?l:THREE.NearestFilter;this.generateMipmaps=this.flipY=!1};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.constructor=THREE.DataTexture; @@ -503,9 +504,9 @@ THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morp THREE.Mesh.prototype.raycast=function(){function a(a,b,c,d,e,f,g){THREE.Triangle.barycoordFromPoint(a,b,c,d,v);e.multiplyScalar(v.x);f.multiplyScalar(v.y);g.multiplyScalar(v.z);e.add(f).add(g);return e.clone()}function b(a,b,c,d,e,f,g){var h=a.material;if(null===(h.side===THREE.BackSide?c.intersectTriangle(f,e,d,!0,g):c.intersectTriangle(d,e,f,h.side!==THREE.DoubleSide,g)))return null;s.copy(g);s.applyMatrix4(a.matrixWorld);c=b.ray.origin.distanceTo(s);return cb.far?null:{distance:c,point:s.clone(), object:a}}function c(c,d,e,f,l,n,p,s){g.fromArray(f,3*n);h.fromArray(f,3*p);k.fromArray(f,3*s);if(c=b(c,d,e,g,h,k,t))l&&(m.fromArray(l,2*n),q.fromArray(l,2*p),u.fromArray(l,2*s),c.uv=a(t,g,h,k,m,q,u)),c.face=new THREE.Face3(n,p,s,THREE.Triangle.normal(g,h,k)),c.faceIndex=n;return c}var d=new THREE.Matrix4,e=new THREE.Ray,f=new THREE.Sphere,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,n=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector2,q=new THREE.Vector2, u=new THREE.Vector2,v=new THREE.Vector3,t=new THREE.Vector3,s=new THREE.Vector3;return function(s,v){var x=this.geometry,C=this.material,y=this.matrixWorld;if(void 0!==C&&(null===x.boundingSphere&&x.computeBoundingSphere(),f.copy(x.boundingSphere),f.applyMatrix4(y),!1!==s.ray.intersectsSphere(f)&&(d.getInverse(y),e.copy(s.ray).applyMatrix4(d),null===x.boundingBox||!1!==e.intersectsBox(x.boundingBox)))){var z,A;if(x instanceof THREE.BufferGeometry){var E,F,C=x.index,y=x.attributes,x=y.position.array; -void 0!==y.uv&&(z=y.uv.array);if(null!==C)for(var y=C.array,B=0,M=y.length;Bc;c++)r.deleteFramebuffer(b.__webglFramebuffer[c]),r.deleteRenderbuffer(b.__webglDepthbuffer[c]);else r.deleteFramebuffer(b.__webglFramebuffer),r.deleteRenderbuffer(b.__webglDepthbuffer);U.delete(a.texture); -U.delete(a)}la.textures--}function h(a){a=a.target;a.removeEventListener("dispose",h);k(a);U.delete(a)}function k(a){var b=U.get(a).program;a.program=void 0;void 0!==b&&ra.releaseProgram(b)}function l(a,b){return Math.abs(b[0])-Math.abs(a[0])}function n(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function p(a,b){return a.object.renderOrder!==b.object.renderOrder? -a.object.renderOrder-b.object.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function m(a,b,c,d,e){var f;c.transparent?(d=ha,f=++ma):(d=X,f=++ia);f=d[f];void 0!==f?(f.id=a.id,f.object=a,f.geometry=b,f.material=c,f.z=Y.z,f.group=e):(f={id:a.id,object:a,geometry:b,material:c,z:Y.z,group:e},d.push(f))}function q(a){var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere();var c=Oa.copy(b.boundingSphere).applyMatrix4(a.matrixWorld);if(!La.intersectsSphere(c))return!1;if(0===ca)return!0;a=W.clippingPlanes; -var b=c.center,c=-c.radius,d=0;do if(a[d].distanceToPoint(b)=da.maxTextures&&console.warn("WebGLRenderer: trying to use "+ -a+" texture units while this GPU supports only "+da.maxTextures);xa+=1;return a}function x(a,b,c,d){var e;if("1i"===b)r.uniform1i(c,d);else if("1f"===b)r.uniform1f(c,d);else if("2f"===b)r.uniform2f(c,d[0],d[1]);else if("3f"===b)r.uniform3f(c,d[0],d[1],d[2]);else if("4f"===b)r.uniform4f(c,d[0],d[1],d[2],d[3]);else if("1iv"===b)r.uniform1iv(c,d);else if("3iv"===b)r.uniform3iv(c,d);else if("1fv"===b)r.uniform1fv(c,d);else if("2fv"===b)r.uniform2fv(c,d);else if("3fv"===b)r.uniform3fv(c,d);else if("4fv"=== -b)r.uniform4fv(c,d);else if("Matrix2fv"===b)r.uniformMatrix2fv(c,!1,d);else if("Matrix3fv"===b)r.uniformMatrix3fv(c,!1,d);else if("Matrix4fv"===b)r.uniformMatrix4fv(c,!1,d);else if("i"===b)r.uniform1i(c,d);else if("f"===b)r.uniform1f(c,d);else if("iv1"===b)r.uniform1iv(c,d);else if("iv"===b)r.uniform3iv(c,d);else if("fv1"===b)r.uniform1fv(c,d);else if("fv"===b)r.uniform3fv(c,d);else if("v2"===b)r.uniform2f(c,d.x,d.y);else if("v3"===b)r.uniform3f(c,d.x,d.y,d.z);else if("v4"===b)r.uniform4f(c,d.x,d.y, -d.z,d.w);else if("c"===b)r.uniform3f(c,d.r,d.g,d.b);else if("s"===b){a=a.properties;for(var f in a){e=a[f];var g=c[f],h=d[f];x(e,e.type,g,h)}}else if("sa"===b){a=a.properties;b=0;for(var k=d.length;bb||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElement("canvas");d.width=Math.floor(a.width* -c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a}function F(a){return THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height)}function B(a,b){var c=U.get(a);if(6===a.image.length)if(0h;h++)g[h]=!W.autoScaleCubemaps||d||e?e?a.image[h].image:a.image[h]:E(a.image[h],da.maxCubemapSize);var k=F(g[0]),m=I(a.format),l=I(a.type);A(r.TEXTURE_CUBE_MAP,a,k);for(h=0;6>h;h++)if(d)for(var n,p=g[h].mipmaps,q=0,s=p.length;qc;c++)r.deleteFramebuffer(b.__webglFramebuffer[c]),b.__webglDepthbuffer&&r.deleteRenderbuffer(b.__webglDepthbuffer[c]);else r.deleteFramebuffer(b.__webglFramebuffer), +b.__webglDepthbuffer&&r.deleteRenderbuffer(b.__webglDepthbuffer);T.delete(a.texture);T.delete(a)}la.textures--}function h(a){a=a.target;a.removeEventListener("dispose",h);k(a);T.delete(a)}function k(a){var b=T.get(a).program;a.program=void 0;void 0!==b&&ra.releaseProgram(b)}function l(a,b){return Math.abs(b[0])-Math.abs(a[0])}function n(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!== +b.z?a.z-b.z:a.id-b.id}function p(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function m(a,b,c,d,e){var f;c.transparent?(d=ha,f=++ma):(d=X,f=++ia);f=d[f];void 0!==f?(f.id=a.id,f.object=a,f.geometry=b,f.material=c,f.z=Y.z,f.group=e):(f={id:a.id,object:a,geometry:b,material:c,z:Y.z,group:e},d.push(f))}function q(a){var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere();var c=Pa.copy(b.boundingSphere).applyMatrix4(a.matrixWorld); +if(!La.intersectsSphere(c))return!1;if(0===ca)return!0;a=W.clippingPlanes;var b=c.center,c=-c.radius,d=0;do if(a[d].distanceToPoint(b)=da.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+da.maxTextures);xa+=1;return a}function x(a,b,c,d){var e;if("1i"===b)r.uniform1i(c,d);else if("1f"===b)r.uniform1f(c,d);else if("2f"===b)r.uniform2f(c,d[0],d[1]);else if("3f"===b)r.uniform3f(c,d[0],d[1],d[2]);else if("4f"===b)r.uniform4f(c,d[0],d[1],d[2],d[3]);else if("1iv"===b)r.uniform1iv(c,d);else if("3iv"===b)r.uniform3iv(c,d);else if("1fv"=== +b)r.uniform1fv(c,d);else if("2fv"===b)r.uniform2fv(c,d);else if("3fv"===b)r.uniform3fv(c,d);else if("4fv"===b)r.uniform4fv(c,d);else if("Matrix2fv"===b)r.uniformMatrix2fv(c,!1,d);else if("Matrix3fv"===b)r.uniformMatrix3fv(c,!1,d);else if("Matrix4fv"===b)r.uniformMatrix4fv(c,!1,d);else if("i"===b)r.uniform1i(c,d);else if("f"===b)r.uniform1f(c,d);else if("iv1"===b)r.uniform1iv(c,d);else if("iv"===b)r.uniform3iv(c,d);else if("fv1"===b)r.uniform1fv(c,d);else if("fv"===b)r.uniform3fv(c,d);else if("v2"=== +b)r.uniform2f(c,d.x,d.y);else if("v3"===b)r.uniform3f(c,d.x,d.y,d.z);else if("v4"===b)r.uniform4f(c,d.x,d.y,d.z,d.w);else if("c"===b)r.uniform3f(c,d.r,d.g,d.b);else if("s"===b){a=a.properties;for(var f in a){e=a[f];var g=c[f],h=d[f];x(e,e.type,g,h)}}else if("sa"===b){a=a.properties;b=0;for(var k=d.length;bb||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElement("canvas");d.width=Math.floor(a.width* +c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a}function F(a){return THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height)}function B(a,b){var c=T.get(a);if(6===a.image.length)if(0h;h++)g[h]=!W.autoScaleCubemaps||d||e?e?a.image[h].image:a.image[h]:E(a.image[h],da.maxCubemapSize);var k=F(g[0]),m=I(a.format),l=I(a.type);A(r.TEXTURE_CUBE_MAP,a,k);for(h=0;6>h;h++)if(d)for(var n,p=g[h].mipmaps,q=0,s=p.length;qf;f++)b.__webglFramebuffer[f]=r.createFramebuffer()}else b.__webglFramebuffer=r.createFramebuffer();if(d){L.bindTexture(r.TEXTURE_CUBE_MAP,c.__webglTexture);A(r.TEXTURE_CUBE_MAP,a.texture,e);for(f=0;6>f;f++)J(b.__webglFramebuffer[f],a,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+f);a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_CUBE_MAP); -L.bindTexture(r.TEXTURE_CUBE_MAP,null)}else L.bindTexture(r.TEXTURE_2D,c.__webglTexture),A(r.TEXTURE_2D,a.texture,e),J(b.__webglFramebuffer,a,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_2D),L.bindTexture(r.TEXTURE_2D,null);if(a.depthBuffer){b=U.get(a);if(a instanceof THREE.WebGLRenderTargetCube)for(b.__webglDepthbuffer=[],c=0;6>c;c++)r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[c]),b.__webglDepthbuffer[c]=r.createRenderbuffer(),O(b.__webglDepthbuffer[c], -a);else r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer=r.createRenderbuffer(),O(b.__webglDepthbuffer,a);r.bindFramebuffer(r.FRAMEBUFFER,null)}}b=a instanceof THREE.WebGLRenderTargetCube;a?(c=U.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:c.__webglFramebuffer,va.copy(a.scissor),Ka=a.scissorTest,na.copy(a.viewport)):(c=null,va.copy(Ga).multiplyScalar(aa),Ka=Ma,na.copy(oa).multiplyScalar(aa));Ca!==c&&(r.bindFramebuffer(r.FRAMEBUFFER,c),Ca=c);L.scissor(va);L.setScissorTest(Ka); -L.viewport(na);b&&(b=U.get(a.texture),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels=function(a,b,c,d,e,f){if(!1===a instanceof THREE.WebGLRenderTarget)console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");else{var g=U.get(a).__webglFramebuffer;if(g){var h=!1;g!==Ca&&(r.bindFramebuffer(r.FRAMEBUFFER,g),h=!0);try{var k=a.texture; -k.format!==THREE.RGBAFormat&&I(k.format)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):k.type===THREE.UnsignedByteType||I(k.type)===r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)||k.type===THREE.FloatType&&V.get("WEBGL_color_buffer_float")||k.type===THREE.HalfFloatType&&V.get("EXT_color_buffer_half_float")?r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE? -r.readPixels(b,c,d,e,I(k.format),I(k.type),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&r.bindFramebuffer(r.FRAMEBUFFER,Ca)}}}}}; +if(a===THREE.LuminanceAlphaFormat)return r.LUMINANCE_ALPHA;if(a===THREE.DepthFormat)return r.DEPTH_COMPONENT;if(a===THREE.AddEquation)return r.FUNC_ADD;if(a===THREE.SubtractEquation)return r.FUNC_SUBTRACT;if(a===THREE.ReverseSubtractEquation)return r.FUNC_REVERSE_SUBTRACT;if(a===THREE.ZeroFactor)return r.ZERO;if(a===THREE.OneFactor)return r.ONE;if(a===THREE.SrcColorFactor)return r.SRC_COLOR;if(a===THREE.OneMinusSrcColorFactor)return r.ONE_MINUS_SRC_COLOR;if(a===THREE.SrcAlphaFactor)return r.SRC_ALPHA; +if(a===THREE.OneMinusSrcAlphaFactor)return r.ONE_MINUS_SRC_ALPHA;if(a===THREE.DstAlphaFactor)return r.DST_ALPHA;if(a===THREE.OneMinusDstAlphaFactor)return r.ONE_MINUS_DST_ALPHA;if(a===THREE.DstColorFactor)return r.DST_COLOR;if(a===THREE.OneMinusDstColorFactor)return r.ONE_MINUS_DST_COLOR;if(a===THREE.SrcAlphaSaturateFactor)return r.SRC_ALPHA_SATURATE;b=V.get("WEBGL_compressed_texture_s3tc");if(null!==b){if(a===THREE.RGB_S3TC_DXT1_Format)return b.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT1_Format)return b.COMPRESSED_RGBA_S3TC_DXT1_EXT; +if(a===THREE.RGBA_S3TC_DXT3_Format)return b.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===THREE.RGBA_S3TC_DXT5_Format)return b.COMPRESSED_RGBA_S3TC_DXT5_EXT}b=V.get("WEBGL_compressed_texture_pvrtc");if(null!==b){if(a===THREE.RGB_PVRTC_4BPPV1_Format)return b.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===THREE.RGB_PVRTC_2BPPV1_Format)return b.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===THREE.RGBA_PVRTC_4BPPV1_Format)return b.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===THREE.RGBA_PVRTC_2BPPV1_Format)return b.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}b= +V.get("WEBGL_compressed_texture_etc1");if(null!==b&&a===THREE.RGB_ETC1_Format)return b.COMPRESSED_RGB_ETC1_WEBGL;b=V.get("EXT_blend_minmax");if(null!==b){if(a===THREE.MinEquation)return b.MIN_EXT;if(a===THREE.MaxEquation)return b.MAX_EXT}return 0}console.log("THREE.WebGLRenderer",THREE.REVISION);a=a||{};var H=void 0!==a.canvas?a.canvas:document.createElement("canvas"),P=void 0!==a.context?a.context:null,R=void 0!==a.alpha?a.alpha:!1,Q=void 0!==a.depth?a.depth:!0,N=void 0!==a.stencil?a.stencil:!0, +G=void 0!==a.antialias?a.antialias:!1,Z=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,U=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,$=[],X=[],ia=-1,ha=[],ma=-1,ea=new Float32Array(8),Ia=[],Ja=[];this.domElement=H;this.context=null;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.clippingPlanes=[];this.localClippingEnabled=!1;this.gammaFactor=2;this.physicallyCorrectLights=this.gammaOutput=this.gammaInput=!1;this.toneMapping= +THREE.LinearToneMapping;this.toneMappingWhitePoint=this.toneMappingExposure=1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;var W=this,Ha=null,Ba=null,Ca=null,qa=-1,pa="",ga=null,va=new THREE.Vector4,Ka=null,na=new THREE.Vector4,xa=0,ba=new THREE.Color(0),ka=0,Da=H.width,Ea=H.height,aa=1,Ga=new THREE.Vector4(0,0,Da,Ea),Ma=!1,oa=new THREE.Vector4(0,0,Da,Ea),La=new THREE.Frustum,ya=!1,za=!1,ta=!1,ca=0,fa={type:"4fv",value:null,needsUpdate:!1},Aa=null,ua=0,Qa=new THREE.Matrix3, +Pa=new THREE.Sphere,Ra=new THREE.Plane,wa=new THREE.Matrix4,Y=new THREE.Vector3,S={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},la={geometries:0,textures:0},ja={calls:0,vertices:0,faces:0,points:0};this.info={render:ja,memory:la,programs:null};var r;try{R={alpha:R,depth:Q,stencil:N,antialias:G,premultipliedAlpha:Z,preserveDrawingBuffer:U};r= +P||H.getContext("webgl",R)||H.getContext("experimental-webgl",R);if(null===r){if(null!==H.getContext("webgl"))throw"Error creating WebGL context with your selected attributes.";throw"Error creating WebGL context.";}void 0===r.getShaderPrecisionFormat&&(r.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}});H.addEventListener("webglcontextlost",e,!1)}catch(Sa){console.error("THREE.WebGLRenderer: "+Sa)}var Na="undefined"!==typeof WebGL2RenderingContext&&r instanceof WebGL2RenderingContext, +V=new THREE.WebGLExtensions(r);V.get("WEBGL_depth_texture");V.get("OES_texture_float");V.get("OES_texture_float_linear");V.get("OES_texture_half_float");V.get("OES_texture_half_float_linear");V.get("OES_standard_derivatives");V.get("ANGLE_instanced_arrays");V.get("OES_element_index_uint")&&(THREE.BufferGeometry.MaxIndex=4294967296);var da=new THREE.WebGLCapabilities(r,V,a),K=new THREE.WebGLState(r,V,I),T=new THREE.WebGLProperties,sa=new THREE.WebGLObjects(r,T,this.info),ra=new THREE.WebGLPrograms(this, +da),Fa=new THREE.WebGLLights;this.info.programs=ra.programs;var Ta=new THREE.WebGLBufferRenderer(r,V,ja),Ua=new THREE.WebGLIndexedBufferRenderer(r,V,ja);c();this.context=r;this.capabilities=da;this.extensions=V;this.properties=T;this.state=K;var Oa=new THREE.WebGLShadowMap(this,S,sa);this.shadowMap=Oa;var Va=new THREE.SpritePlugin(this,Ia),Wa=new THREE.LensFlarePlugin(this,Ja);this.getContext=function(){return r};this.getContextAttributes=function(){return r.getContextAttributes()};this.forceContextLoss= +function(){V.get("WEBGL_lose_context").loseContext()};this.getMaxAnisotropy=function(){var a;return function(){if(void 0!==a)return a;var b=V.get("EXT_texture_filter_anisotropic");return a=null!==b?r.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}}();this.getPrecision=function(){return da.precision};this.getPixelRatio=function(){return aa};this.setPixelRatio=function(a){void 0!==a&&(aa=a,this.setSize(oa.z,oa.w,!1))};this.getSize=function(){return{width:Da,height:Ea}};this.setSize=function(a,b,c){Da= +a;Ea=b;H.width=a*aa;H.height=b*aa;!1!==c&&(H.style.width=a+"px",H.style.height=b+"px");this.setViewport(0,0,a,b)};this.setViewport=function(a,b,c,d){K.viewport(oa.set(a,b,c,d))};this.setScissor=function(a,b,c,d){K.scissor(Ga.set(a,b,c,d))};this.setScissorTest=function(a){K.setScissorTest(Ma=a)};this.getClearColor=function(){return ba};this.setClearColor=function(a,c){ba.set(a);ka=void 0!==c?c:1;b(ba.r,ba.g,ba.b,ka)};this.getClearAlpha=function(){return ka};this.setClearAlpha=function(a){ka=a;b(ba.r, +ba.g,ba.b,ka)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=r.COLOR_BUFFER_BIT;if(void 0===b||b)d|=r.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=r.STENCIL_BUFFER_BIT;r.clear(d)};this.clearColor=function(){this.clear(!0,!1,!1)};this.clearDepth=function(){this.clear(!1,!0,!1)};this.clearStencil=function(){this.clear(!1,!1,!0)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.resetGLState=d;this.dispose=function(){H.removeEventListener("webglcontextlost",e,!1)};this.renderBufferImmediate= +function(a,b,c){K.initAttributes();var d=T.get(a);a.hasPositions&&!d.position&&(d.position=r.createBuffer());a.hasNormals&&!d.normal&&(d.normal=r.createBuffer());a.hasUvs&&!d.uv&&(d.uv=r.createBuffer());a.hasColors&&!d.color&&(d.color=r.createBuffer());b=b.getAttributes();a.hasPositions&&(r.bindBuffer(r.ARRAY_BUFFER,d.position),r.bufferData(r.ARRAY_BUFFER,a.positionArray,r.DYNAMIC_DRAW),K.enableAttribute(b.position),r.vertexAttribPointer(b.position,3,r.FLOAT,!1,0,0));if(a.hasNormals){r.bindBuffer(r.ARRAY_BUFFER, +d.normal);if("MeshPhongMaterial"!==c.type&&"MeshStandardMaterial"!==c.type&&"MeshPhysicalMaterial"!==c.type&&c.shading===THREE.FlatShading)for(var e=0,f=3*a.count;ef;f++)b.__webglFramebuffer[f]=r.createFramebuffer()}else b.__webglFramebuffer=r.createFramebuffer();if(d){K.bindTexture(r.TEXTURE_CUBE_MAP,c.__webglTexture);A(r.TEXTURE_CUBE_MAP,a.texture,e);for(f=0;6>f;f++)J(b.__webglFramebuffer[f],a,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+f);a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_CUBE_MAP);K.bindTexture(r.TEXTURE_CUBE_MAP, +null)}else K.bindTexture(r.TEXTURE_2D,c.__webglTexture),A(r.TEXTURE_2D,a.texture,e),J(b.__webglFramebuffer,a,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_2D),K.bindTexture(r.TEXTURE_2D,null);if(a.depthBuffer){b=T.get(a);c=a instanceof THREE.WebGLRenderTargetCube;if(a.depthTexture){if(c)throw Error("target.depthTexture not supported in Cube render targets");if(a instanceof THREE.WebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported!"); +r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer);if(!(a.depthTexture instanceof THREE.DepthTexture))throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");T.get(a.depthTexture).__webglTexture&&a.depthTexture.image.width===a.width&&a.depthTexture.image.height===a.height||(a.depthTexture.image.width=a.width,a.depthTexture.image.height=a.height,a.depthTexture.needsUpdate=!0);W.setTexture(a.depthTexture,0);b=T.get(a.depthTexture).__webglTexture;r.framebufferTexture2D(r.FRAMEBUFFER, +r.DEPTH_ATTACHMENT,r.TEXTURE_2D,b,0)}else if(c)for(b.__webglDepthbuffer=[],c=0;6>c;c++)r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[c]),b.__webglDepthbuffer[c]=r.createRenderbuffer(),O(b.__webglDepthbuffer[c],a);else r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer=r.createRenderbuffer(),O(b.__webglDepthbuffer,a);r.bindFramebuffer(r.FRAMEBUFFER,null)}}b=a instanceof THREE.WebGLRenderTargetCube;a?(c=T.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:c.__webglFramebuffer, +va.copy(a.scissor),Ka=a.scissorTest,na.copy(a.viewport)):(c=null,va.copy(Ga).multiplyScalar(aa),Ka=Ma,na.copy(oa).multiplyScalar(aa));Ca!==c&&(r.bindFramebuffer(r.FRAMEBUFFER,c),Ca=c);K.scissor(va);K.setScissorTest(Ka);K.viewport(na);b&&(b=T.get(a.texture),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels=function(a,b,c,d,e,f){if(!1===a instanceof THREE.WebGLRenderTarget)console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); +else{var g=T.get(a).__webglFramebuffer;if(g){var h=!1;g!==Ca&&(r.bindFramebuffer(r.FRAMEBUFFER,g),h=!0);try{var k=a.texture;k.format!==THREE.RGBAFormat&&I(k.format)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):k.type===THREE.UnsignedByteType||I(k.type)===r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)||k.type===THREE.FloatType&&V.get("WEBGL_color_buffer_float")||k.type=== +THREE.HalfFloatType&&V.get("EXT_color_buffer_half_float")?r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE?r.readPixels(b,c,d,e,I(k.format),I(k.type),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&r.bindFramebuffer(r.FRAMEBUFFER,Ca)}}}}}; THREE.WebGLRenderTarget=function(a,b,c){this.uuid=THREE.Math.generateUUID();this.width=a;this.height=b;this.scissor=new THREE.Vector4(0,0,a,b);this.scissorTest=!1;this.viewport=new THREE.Vector4(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=THREE.LinearFilter);this.texture=new THREE.Texture(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer: -!0};THREE.WebGLRenderTarget.prototype={constructor:THREE.WebGLRenderTarget,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}}; -THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeMipMapLevel=this.activeCubeFace=0};THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube; +!0;this.depthTexture=null}; +THREE.WebGLRenderTarget.prototype={constructor:THREE.WebGLRenderTarget,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this}, +dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeMipMapLevel=this.activeCubeFace=0};THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube; THREE.WebGLBufferRenderer=function(a,b,c){var d;this.setMode=function(a){d=a};this.render=function(b,f){a.drawArrays(d,b,f);c.calls++;c.vertices+=f;d===a.TRIANGLES&&(c.faces+=f/3)};this.renderInstances=function(e){var f=b.get("ANGLE_instanced_arrays");if(null===f)console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");else{var g=e.attributes.position,h=0,h=g instanceof THREE.InterleavedBufferAttribute?g.data.count: g.count;f.drawArraysInstancedANGLE(d,0,h,e.maxInstancedCount);c.calls++;c.vertices+=h*e.maxInstancedCount;d===a.TRIANGLES&&(c.faces+=e.maxInstancedCount*h/3)}}}; THREE.WebGLIndexedBufferRenderer=function(a,b,c){var d,e,f;this.setMode=function(a){d=a};this.setIndex=function(c){c.array instanceof Uint32Array&&b.get("OES_element_index_uint")?(e=a.UNSIGNED_INT,f=4):(e=a.UNSIGNED_SHORT,f=2)};this.render=function(b,h){a.drawElements(d,h,e,b*f);c.calls++;c.vertices+=h;d===a.TRIANGLES&&(c.faces+=h/3)};this.renderInstances=function(g,h,k){var l=b.get("ANGLE_instanced_arrays");null===l?console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."): (l.drawElementsInstancedANGLE(d,k,e,h*f,g.maxInstancedCount),c.calls++,c.vertices+=k*g.maxInstancedCount,d===a.TRIANGLES&&(c.faces+=g.maxInstancedCount*k/3))}}; -THREE.WebGLExtensions=function(a){var b={};this.get=function(c){if(void 0!==b[c])return b[c];var d;switch(c){case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"); -break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case "WEBGL_compressed_texture_etc1":d=a.getExtension("WEBGL_compressed_texture_etc1");break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}}; +THREE.WebGLExtensions=function(a){var b={};this.get=function(c){if(void 0!==b[c])return b[c];var d;switch(c){case "WEBGL_depth_texture":a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d= +a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case "WEBGL_compressed_texture_etc1":d=a.getExtension("WEBGL_compressed_texture_etc1");break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported."); +return b[c]=d}}; THREE.WebGLCapabilities=function(a,b,c){function d(b){if("highp"===b){if(0 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); -x.compileShader(I);x.compileShader(H);x.attachShader(K,I);x.attachShader(K,H);x.linkProgram(K);A=K;s=x.getAttribLocation(A,"position");w=x.getAttribLocation(A,"uv");c=x.getUniformLocation(A,"uvOffset");d=x.getUniformLocation(A,"uvScale");e=x.getUniformLocation(A,"rotation");f=x.getUniformLocation(A,"scale");g=x.getUniformLocation(A,"color");h=x.getUniformLocation(A,"map");k=x.getUniformLocation(A,"opacity");l=x.getUniformLocation(A,"modelViewMatrix");n=x.getUniformLocation(A,"projectionMatrix");p= -x.getUniformLocation(A,"fogType");m=x.getUniformLocation(A,"fogDensity");q=x.getUniformLocation(A,"fogNear");u=x.getUniformLocation(A,"fogFar");v=x.getUniformLocation(A,"fogColor");t=x.getUniformLocation(A,"alphaTest");K=document.createElement("canvas");K.width=8;K.height=8;I=K.getContext("2d");I.fillStyle="white";I.fillRect(0,0,8,8);E=new THREE.Texture(K);E.needsUpdate=!0}x.useProgram(A);C.initAttributes();C.enableAttribute(s);C.enableAttribute(w);C.disableUnusedAttributes();C.disable(x.CULL_FACE); -C.enable(x.BLEND);x.bindBuffer(x.ARRAY_BUFFER,y);x.vertexAttribPointer(s,2,x.FLOAT,!1,16,0);x.vertexAttribPointer(w,2,x.FLOAT,!1,16,8);x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,z);x.uniformMatrix4fv(n,!1,O.projectionMatrix.elements);C.activeTexture(x.TEXTURE0);x.uniform1i(h,0);I=K=0;(H=J.fog)?(x.uniform3f(v,H.color.r,H.color.g,H.color.b),H instanceof THREE.Fog?(x.uniform1f(q,H.near),x.uniform1f(u,H.far),x.uniform1i(p,1),I=K=1):H instanceof THREE.FogExp2&&(x.uniform1f(m,H.density),x.uniform1i(p,2),I=K=2)): -(x.uniform1i(p,0),I=K=0);for(var H=0,P=b.length;Hh&&(h=1);1E-4>k&&(k=h);1E-4>m&&(m=h);c.initNonuniformCatmullRom(l.x,n.x,p.x,g.x,k,h,m);d.initNonuniformCatmullRom(l.y,n.y,p.y,g.y,k,h,m);e.initNonuniformCatmullRom(l.z,n.z,p.z,g.z,k,h,m)}else"catmullrom"===this.type&&(k=void 0!==this.tension?this.tension:.5,c.initCatmullRom(l.x,n.x,p.x,g.x, k),d.initCatmullRom(l.y,n.y,p.y,g.y,k),e.initCatmullRom(l.z,n.z,p.z,g.z,k));return new THREE.Vector3(c.calc(a),d.calc(a),e.calc(a))})}();THREE.ClosedSplineCurve3=function(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.");THREE.CatmullRomCurve3.call(this,a);this.type="catmullrom";this.closed=!0};THREE.ClosedSplineCurve3.prototype=Object.create(THREE.CatmullRomCurve3.prototype); THREE.BoxGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.fromBufferGeometry(new THREE.BoxBufferGeometry(a,b,c,d,e,f));this.mergeVertices()};THREE.BoxGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.BoxGeometry.prototype.constructor=THREE.BoxGeometry;THREE.CubeGeometry=THREE.BoxGeometry; -THREE.BoxBufferGeometry=function(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,k,l,M,J){var O=f/l,K=g/M,I=f/2,H=g/2,P=k/2;g=l+1;for(var R=M+1,Q=f=0,N=new THREE.Vector3,G=0;GNumber.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(c=-e,a=d,d=Math.sqrt(h)):(c=d,a=e,d=Math.sqrt(h/2));return new THREE.Vector2(c/d,a/d)}function e(a,b){var c,d;for(G=a.length;0<=--G;){c=G;d=G-1;0>d&&(d=a.length-1);for(var e=0,f=q+2*n,e=0;eMath.abs(b.y-c.y)?[new THREE.Vector2(b.x,1-b.z),new THREE.Vector2(c.x,1-c.z),new THREE.Vector2(d.x,1-d.z),new THREE.Vector2(e.x,1-e.z)]:[new THREE.Vector2(b.y,1-b.z),new THREE.Vector2(c.y,1-c.z),new THREE.Vector2(d.y, 1-d.z),new THREE.Vector2(e.y,1-e.z)]}};THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);this.type="ShapeGeometry";!1===Array.isArray(a)&&(a=[a]);this.addShapeList(a,b);this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ShapeGeometry.prototype.constructor=THREE.ShapeGeometry;THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;c