Mr.doob před 9 roky
rodič
revize
81304affea
2 změnil soubory, kde provedl 177 přidání a 95 odebrání
  1. 135 55
      build/three.js
  2. 42 40
      build/three.min.js

+ 135 - 55
build/three.js

@@ -30212,10 +30212,6 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 			}
 
-			// We must call _renderer.resetGLState() at the end of each iteration of
-			// the light loop in order to force material updates for each light.
-			_renderer.resetGLState();
-
 		}
 
 		// Restore GL state.
@@ -30231,8 +30227,6 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 		}
 
-		_renderer.resetGLState();
-
 		scope.needsUpdate = false;
 
 	};
@@ -37147,26 +37141,24 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) {
 
 };
 
-// File:src/extras/geometries/LatheGeometry.js
+// File:src/extras/geometries/LatheBufferGeometry.js
 
 /**
- * @author astrodud / http://astrodud.isgreat.org/
- * @author zz85 / https://github.com/zz85
- * @author bhouston / http://clara.io
+ * @author Mugen87 / https://github.com/Mugen87
  */
 
-// points - to create a closed torus, one must use a set of points
-//    like so: [ a, b, c, d, a ], see first is the same as last.
-// segments - the number of circumference segments to create
-// phiStart - the starting radian
-// phiLength - the radian (0 to 2*PI) range of the lathed section
-//    2*pi is a closed lathe, less than 2PI is a portion.
+ // points - to create a closed torus, one must use a set of points
+ //    like so: [ a, b, c, d, a ], see first is the same as last.
+ // segments - the number of circumference segments to create
+ // phiStart - the starting radian
+ // phiLength - the radian (0 to 2PI) range of the lathed section
+ //    2PI is a closed lathe, less than 2PI is a portion.
 
-THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
+THREE.LatheBufferGeometry = function ( points, segments, phiStart, phiLength ) {
 
-	THREE.Geometry.call( this );
+	THREE.BufferGeometry.call( this );
 
-	this.type = 'LatheGeometry';
+	this.type = 'LatheBufferGeometry';
 
 	this.parameters = {
 		points: points,
@@ -37175,81 +37167,169 @@ THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
 		phiLength: phiLength
 	};
 
-	segments = segments || 12;
+	segments = Math.floor( segments ) || 12;
 	phiStart = phiStart || 0;
-	phiLength = phiLength || 2 * Math.PI;
+	phiLength = phiLength || Math.PI * 2;
+
+	// clamp phiLength so it's in range of [ 0, 2PI ]
+	phiLength = THREE.Math.clamp( phiLength, 0, Math.PI * 2 );
+
+	// these are used to calculate buffer length
+	var vertexCount = ( segments + 1 ) * points.length;
+	var indexCount = segments * points.length * 2 * 3;
 
+	// buffers
+	var indices = new THREE.BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ) , 1 );
+	var vertices = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
+
+	// helper variables
+	var index = 0, indexOffset = 0, base;
 	var inversePointLength = 1.0 / ( points.length - 1 );
 	var inverseSegments = 1.0 / segments;
+	var vertex = new THREE.Vector3();
+	var uv = new THREE.Vector2();
+	var i, j;
+
+	// generate vertices and uvs
 
-	for ( var i = 0, il = segments; i <= il; i ++ ) {
+	for ( i = 0; i <= segments; i ++ ) {
 
 		var phi = phiStart + i * inverseSegments * phiLength;
 
 		var sin = Math.sin( phi );
 		var cos = Math.cos( phi );
 
-		for ( var j = 0, jl = points.length; j < jl; j ++ ) {
+		for ( j = 0; j <= ( points.length - 1 ); j ++ ) {
 
-			var point = points[ j ];
-
-			var vertex = new THREE.Vector3();
+			// vertex
+			vertex.x = points[ j ].x * sin;
+			vertex.y = points[ j ].y;
+			vertex.z = points[ j ].x * cos;
+			vertices.setXYZ( index, vertex.x, vertex.y, vertex.z );
 
-			vertex.x = point.x * sin;
-			vertex.y = point.y;
-			vertex.z = point.x * cos;
+			// uv
+			uv.x = i / segments;
+			uv.y = j / ( points.length - 1 );
+			uvs.setXY( index, uv.x, uv.y );
 
-			this.vertices.push( vertex );
+			// increase index
+			index ++;
 
 		}
 
 	}
 
-	var np = points.length;
+	// generate indices
+
+	for ( i = 0; i < segments; i ++ ) {
 
-	for ( var i = 0, il = segments; i < il; i ++ ) {
+		for ( j = 0; j < ( points.length - 1 ); j ++ ) {
 
-		for ( var j = 0, jl = points.length - 1; j < jl; j ++ ) {
+			base = j + i * points.length;
 
-			var base = j + np * i;
+			// indices
 			var a = base;
-			var b = base + np;
-			var c = base + 1 + np;
+			var b = base + points.length;
+			var c = base + points.length + 1;
 			var d = base + 1;
 
-			var u0 = i * inverseSegments;
-			var v0 = j * inversePointLength;
-			var u1 = u0 + inverseSegments;
-			var v1 = v0 + inversePointLength;
+			// face one
+			indices.setX( indexOffset, a ); indexOffset++;
+			indices.setX( indexOffset, b ); indexOffset++;
+			indices.setX( indexOffset, d ); indexOffset++;
 
-			this.faces.push( new THREE.Face3( a, b, d ) );
+			// face two
+			indices.setX( indexOffset, b ); indexOffset++;
+			indices.setX( indexOffset, c ); indexOffset++;
+			indices.setX( indexOffset, d ); indexOffset++;
 
-			this.faceVertexUvs[ 0 ].push( [
+		}
 
-				new THREE.Vector2( u0, v0 ),
-				new THREE.Vector2( u1, v0 ),
-				new THREE.Vector2( u0, v1 )
+	}
 
-			] );
+	// build geometry
 
-			this.faces.push( new THREE.Face3( b, c, d ) );
+	this.setIndex( indices );
+	this.addAttribute( 'position', vertices );
+	this.addAttribute( 'uv', uvs );
 
-			this.faceVertexUvs[ 0 ].push( [
+	// generate normals
 
-				new THREE.Vector2( u1, v0 ),
-				new THREE.Vector2( u1, v1 ),
-				new THREE.Vector2( u0, v1 )
+	this.computeVertexNormals();
 
-			] );
+	// if the geometry is closed, we need to average the normals along the seam.
+	// because the corresponding vertices are identical (but still have different UVs).
 
+	if( phiLength === Math.PI * 2 ) {
 
-		}
+		var normals = this.attributes.normal.array;
+		var n1 = new THREE.Vector3();
+		var n2 = new THREE.Vector3();
+		var n = new THREE.Vector3();
+
+		// this is the buffer offset for the last line of vertices
+		base = segments * points.length * 3;
+
+		for( i = 0, j = 0; i < points.length; i ++, j += 3 ) {
+
+			// select the normal of the vertex in the first line
+			n1.x = normals[ j + 0 ];
+			n1.y = normals[ j + 1 ];
+			n1.z = normals[ j + 2 ];
+
+			// select the normal of the vertex in the last line
+			n2.x = normals[ base + j + 0 ];
+			n2.y = normals[ base + j + 1 ];
+			n2.z = normals[ base + j + 2 ];
+
+			// average normals
+			n.addVectors( n1, n2 ).normalize();
+
+			// assign the new values to both normals
+			normals[ j + 0 ] = normals[ base + j + 0 ] = n.x;
+			normals[ j + 1 ] = normals[ base + j + 1 ] = n.y;
+			normals[ j + 2 ] = normals[ base + j + 2 ] = n.z;
+
+		} // next row
 
 	}
 
+};
+
+THREE.LatheBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
+THREE.LatheBufferGeometry.prototype.constructor = THREE.LatheBufferGeometry;
+
+// File:src/extras/geometries/LatheGeometry.js
+
+/**
+ * @author astrodud / http://astrodud.isgreat.org/
+ * @author zz85 / https://github.com/zz85
+ * @author bhouston / http://clara.io
+ */
+
+// points - to create a closed torus, one must use a set of points
+//    like so: [ a, b, c, d, a ], see first is the same as last.
+// segments - the number of circumference segments to create
+// phiStart - the starting radian
+// phiLength - the radian (0 to 2PI) range of the lathed section
+//    2PI is a closed lathe, less than 2PI is a portion.
+
+THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
+
+	THREE.Geometry.call( this );
+
+	this.type = 'LatheGeometry';
+
+	this.parameters = {
+		points: points,
+		segments: segments,
+		phiStart: phiStart,
+		phiLength: phiLength
+	};
+
+	this.fromBufferGeometry( new THREE.LatheBufferGeometry( points, segments, phiStart, phiLength ) );
 	this.mergeVertices();
-	this.computeFaceNormals();
-	this.computeVertexNormals();
 
 };
 

+ 42 - 40
build/three.min.js

@@ -492,7 +492,7 @@ THREE.Line.prototype.clone=function(){return(new this.constructor(this.geometry,
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.MeshBasicMaterial({color:16777215*Math.random()});this.drawMode=THREE.TrianglesDrawMode;this.updateMorphTargets()};THREE.Mesh.prototype=Object.create(THREE.Object3D.prototype);THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.setDrawMode=function(a){this.drawMode=a};
 THREE.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&0<this.geometry.morphTargets.length){this.morphTargetBase=-1;this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var a=0,b=this.geometry.morphTargets.length;a<b;a++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[a].name]=a}};
 THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morphTargetDictionary[a])return this.morphTargetDictionary[a];console.warn("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
-THREE.Mesh.prototype.raycast=function(){function a(a,b,c,d,e,g,f){THREE.Triangle.barycoordFromPoint(a,b,c,d,v);e.multiplyScalar(v.x);g.multiplyScalar(v.y);f.multiplyScalar(v.z);e.add(g).add(f);return e.clone()}function b(a,b,c,d,e,g,f){var h=a.material;if(null===(h.side===THREE.BackSide?c.intersectTriangle(g,e,d,!0,f):c.intersectTriangle(d,e,g,h.side!==THREE.DoubleSide,f)))return null;s.copy(f);s.applyMatrix4(a.matrixWorld);c=b.ray.origin.distanceTo(s);return c<b.near||c>b.far?null:{distance:c,point:s.clone(),
+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 c<b.near||c>b.far?null:{distance:c,point:s.clone(),
 object:a}}function c(c,d,e,f,l,p,n,s){g.fromArray(f,3*p);h.fromArray(f,3*n);k.fromArray(f,3*s);if(c=b(c,d,e,g,h,k,t))l&&(m.fromArray(l,2*p),q.fromArray(l,2*n),u.fromArray(l,2*s),c.uv=a(t,g,h,k,m,q,u)),c.face=new THREE.Face3(p,n,s,THREE.Triangle.normal(g,h,k)),c.faceIndex=p;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,p=new THREE.Vector3,n=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,D=this.material,z=this.matrixWorld;if(void 0!==D&&(null===x.boundingSphere&&x.computeBoundingSphere(),f.copy(x.boundingSphere),f.applyMatrix4(z),!1!==s.ray.intersectsSphere(f)&&(d.getInverse(z),e.copy(s.ray).applyMatrix4(d),null===x.boundingBox||!1!==e.intersectsBox(x.boundingBox)))){var y,B;if(x instanceof THREE.BufferGeometry){var G,F,D=x.index,z=x.attributes,x=z.position.array;
 void 0!==z.uv&&(y=z.uv.array);if(null!==D)for(var z=D.array,H=0,L=z.length;H<L;H+=3){if(D=z[H],G=z[H+1],F=z[H+2],B=c(this,s,e,x,y,D,G,F))B.faceIndex=Math.floor(H/3),v.push(B)}else for(H=0,L=x.length;H<L;H+=9)if(D=H/3,G=D+1,F=D+2,B=c(this,s,e,x,y,D,G,F))B.index=D,v.push(B)}else if(x instanceof THREE.Geometry){var A,N,z=D instanceof THREE.MultiMaterial,H=!0===z?D.materials:null,L=x.vertices;G=x.faces;F=x.faceVertexUvs[0];0<F.length&&(y=F);for(var M=0,I=G.length;M<I;M++){var O=G[M];B=!0===z?H[O.materialIndex]:
@@ -589,39 +589,39 @@ equirect:{uniforms:{tEquirect:{type:"t",value:null},tFlip:{type:"f",value:-1}},v
 THREE.WebGLRenderer=function(a){function b(a,b,c,d){!0===P&&(a*=d,b*=d,c*=d);K.clearColor(a,b,c,d)}function c(){K.init();K.scissor(qa.copy(ya).multiplyScalar(aa));K.viewport(ka.copy(la).multiplyScalar(aa));b(ba.r,ba.g,ba.b,ga)}function d(){ma=ha=null;na="";ra=-1;K.reset()}function e(a){a.preventDefault();d();c();U.clear()}function f(a){a=a.target;a.removeEventListener("dispose",f);a:{var b=U.get(a);if(a.image&&b.__image__webglTextureCube)r.deleteTexture(b.__image__webglTextureCube);else{if(void 0===
 b.__webglInit)break a;r.deleteTexture(b.__webglTexture)}U.delete(a)}ia.textures--}function g(a){a=a.target;a.removeEventListener("dispose",g);var b=U.get(a),c=U.get(a.texture);if(a&&void 0!==c.__webglTexture){r.deleteTexture(c.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(c=0;6>c;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)}ia.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&&oa.releaseProgram(b)}function l(a,b){return Math.abs(b[0])-Math.abs(a[0])}function p(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 n(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 g;c.transparent?(d=S,g=++Y):(d=C,g=++Z);g=d[g];void 0!==g?(g.id=a.id,g.object=a,g.geometry=b,g.material=c,g.z=W.z,g.group=e):(g={id:a.id,object:a,geometry:b,material:c,z:W.z,group:e},d.push(g))}function q(a,b){if(!1!==a.visible){if(a.layers.test(b.layers))if(a instanceof THREE.Light)J.push(a);else if(a instanceof THREE.Sprite)!1!==a.frustumCulled&&!0!==za.intersectsObject(a)||ja.push(a);else if(a instanceof
+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=S,f=++Y):(d=C,f=++Z);f=d[f];void 0!==f?(f.id=a.id,f.object=a,f.geometry=b,f.material=c,f.z=W.z,f.group=e):(f={id:a.id,object:a,geometry:b,material:c,z:W.z,group:e},d.push(f))}function q(a,b){if(!1!==a.visible){if(a.layers.test(b.layers))if(a instanceof THREE.Light)J.push(a);else if(a instanceof THREE.Sprite)!1!==a.frustumCulled&&!0!==za.intersectsObject(a)||ja.push(a);else if(a instanceof
 THREE.LensFlare)ea.push(a);else if(a instanceof THREE.ImmediateRenderObject)!0===X.sortObjects&&(W.setFromMatrixPosition(a.matrixWorld),W.applyProjection(sa)),m(a,null,a.material,W.z,null);else if(a instanceof THREE.Mesh||a instanceof THREE.Line||a instanceof THREE.Points)if(a instanceof THREE.SkinnedMesh&&a.skeleton.update(),!1===a.frustumCulled||!0===za.intersectsObject(a)){var c=a.material;if(!0===c.visible){!0===X.sortObjects&&(W.setFromMatrixPosition(a.matrixWorld),W.applyProjection(sa));var d=
-pa.update(a);if(c instanceof THREE.MultiMaterial)for(var e=d.groups,g=c.materials,c=0,f=e.length;c<f;c++){var h=e[c],k=g[h.materialIndex];!0===k.visible&&m(a,d,k,W.z,h)}else m(a,d,c,W.z,null)}}d=a.children;c=0;for(f=d.length;c<f;c++)q(d[c],b)}}function u(a,b,c,d){for(var e=0,g=a.length;e<g;e++){var f=a[e],h=f.object,k=f.geometry,l=void 0===d?f.material:d,f=f.group;h.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,h.matrixWorld);h.normalMatrix.getNormalMatrix(h.modelViewMatrix);if(h instanceof
-THREE.ImmediateRenderObject){v(l);var m=t(b,c,l,h);na="";h.render(function(a){X.renderBufferImmediate(a,m,l)})}else X.renderBufferDirect(b,c,k,l,h,f)}}function v(a){a.side!==THREE.DoubleSide?K.enable(r.CULL_FACE):K.disable(r.CULL_FACE);K.setFlipSided(a.side===THREE.BackSide);!0===a.transparent?K.setBlending(a.blending,a.blendEquation,a.blendSrc,a.blendDst,a.blendEquationAlpha,a.blendSrcAlpha,a.blendDstAlpha,a.premultipliedAlpha):K.setBlending(THREE.NoBlending);K.setDepthFunc(a.depthFunc);K.setDepthTest(a.depthTest);
-K.setDepthWrite(a.depthWrite);K.setColorWrite(a.colorWrite);K.setPolygonOffset(a.polygonOffset,a.polygonOffsetFactor,a.polygonOffsetUnits)}function t(a,b,c,d){ta=0;var e=U.get(c);void 0===e.program&&(c.needsUpdate=!0);void 0!==e.lightsHash&&e.lightsHash!==R.hash&&(c.needsUpdate=!0);if(c.needsUpdate){a:{var g=U.get(c),f=oa.getParameters(c,R,b,d),l=oa.getProgramCode(c,f),m=g.program,p=!0;if(void 0===m)c.addEventListener("dispose",h);else if(m.code!==l)k(c);else if(void 0!==f.shaderID)break a;else p=
-!1;p&&(f.shaderID?(m=THREE.ShaderLib[f.shaderID],g.__webglShader={name:c.type,uniforms:THREE.UniformsUtils.clone(m.uniforms),vertexShader:m.vertexShader,fragmentShader:m.fragmentShader}):g.__webglShader={name:c.type,uniforms:c.uniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader},c.__webglShader=g.__webglShader,m=oa.acquireProgram(c,f,l),g.program=m,c.program=m);f=m.getAttributes();if(c.morphTargets)for(l=c.numSupportedMorphTargets=0;l<X.maxMorphTargets;l++)0<=f["morphTarget"+l]&&
-c.numSupportedMorphTargets++;if(c.morphNormals)for(l=c.numSupportedMorphNormals=0;l<X.maxMorphNormals;l++)0<=f["morphNormal"+l]&&c.numSupportedMorphNormals++;g.uniformsList=[];var f=g.__webglShader.uniforms,l=g.program.getUniforms(),n;for(n in f)(m=l[n])&&g.uniformsList.push([g.__webglShader.uniforms[n],m]);if(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshStandardMaterial||c.lights)g.lightsHash=R.hash,f.ambientLightColor.value=R.ambient,f.directionalLights.value=
-R.directional,f.spotLights.value=R.spot,f.pointLights.value=R.point,f.hemisphereLights.value=R.hemi,f.directionalShadowMap.value=R.directionalShadowMap,f.directionalShadowMatrix.value=R.directionalShadowMatrix,f.spotShadowMap.value=R.spotShadowMap,f.spotShadowMatrix.value=R.spotShadowMatrix,f.pointShadowMap.value=R.pointShadowMap,f.pointShadowMatrix.value=R.pointShadowMatrix;g.hasDynamicUniforms=!1;n=0;for(f=g.uniformsList.length;n<f;n++)if(!0===g.uniformsList[n][0].dynamic){g.hasDynamicUniforms=
-!0;break}}c.needsUpdate=!1}m=l=p=!1;g=e.program;n=g.getUniforms();f=e.__webglShader.uniforms;g.id!==ha&&(r.useProgram(g.program),ha=g.id,m=l=p=!0);c.id!==ra&&(ra=c.id,l=!0);if(p||a!==ma)r.uniformMatrix4fv(n.projectionMatrix,!1,a.projectionMatrix.elements),da.logarithmicDepthBuffer&&r.uniform1f(n.logDepthBufFC,2/(Math.log(a.far+1)/Math.LN2)),a!==ma&&(ma=a,m=l=!0),(c instanceof THREE.ShaderMaterial||c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshStandardMaterial||c.envMap)&&void 0!==n.cameraPosition&&
+pa.update(a);if(c instanceof THREE.MultiMaterial)for(var e=d.groups,f=c.materials,c=0,g=e.length;c<g;c++){var h=e[c],k=f[h.materialIndex];!0===k.visible&&m(a,d,k,W.z,h)}else m(a,d,c,W.z,null)}}d=a.children;c=0;for(g=d.length;c<g;c++)q(d[c],b)}}function u(a,b,c,d){for(var e=0,f=a.length;e<f;e++){var g=a[e],h=g.object,k=g.geometry,l=void 0===d?g.material:d,g=g.group;h.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,h.matrixWorld);h.normalMatrix.getNormalMatrix(h.modelViewMatrix);if(h instanceof
+THREE.ImmediateRenderObject){v(l);var m=t(b,c,l,h);na="";h.render(function(a){X.renderBufferImmediate(a,m,l)})}else X.renderBufferDirect(b,c,k,l,h,g)}}function v(a){a.side!==THREE.DoubleSide?K.enable(r.CULL_FACE):K.disable(r.CULL_FACE);K.setFlipSided(a.side===THREE.BackSide);!0===a.transparent?K.setBlending(a.blending,a.blendEquation,a.blendSrc,a.blendDst,a.blendEquationAlpha,a.blendSrcAlpha,a.blendDstAlpha,a.premultipliedAlpha):K.setBlending(THREE.NoBlending);K.setDepthFunc(a.depthFunc);K.setDepthTest(a.depthTest);
+K.setDepthWrite(a.depthWrite);K.setColorWrite(a.colorWrite);K.setPolygonOffset(a.polygonOffset,a.polygonOffsetFactor,a.polygonOffsetUnits)}function t(a,b,c,d){ta=0;var e=U.get(c);void 0===e.program&&(c.needsUpdate=!0);void 0!==e.lightsHash&&e.lightsHash!==R.hash&&(c.needsUpdate=!0);if(c.needsUpdate){a:{var f=U.get(c),g=oa.getParameters(c,R,b,d),l=oa.getProgramCode(c,g),m=f.program,p=!0;if(void 0===m)c.addEventListener("dispose",h);else if(m.code!==l)k(c);else if(void 0!==g.shaderID)break a;else p=
+!1;p&&(g.shaderID?(m=THREE.ShaderLib[g.shaderID],f.__webglShader={name:c.type,uniforms:THREE.UniformsUtils.clone(m.uniforms),vertexShader:m.vertexShader,fragmentShader:m.fragmentShader}):f.__webglShader={name:c.type,uniforms:c.uniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader},c.__webglShader=f.__webglShader,m=oa.acquireProgram(c,g,l),f.program=m,c.program=m);g=m.getAttributes();if(c.morphTargets)for(l=c.numSupportedMorphTargets=0;l<X.maxMorphTargets;l++)0<=g["morphTarget"+l]&&
+c.numSupportedMorphTargets++;if(c.morphNormals)for(l=c.numSupportedMorphNormals=0;l<X.maxMorphNormals;l++)0<=g["morphNormal"+l]&&c.numSupportedMorphNormals++;f.uniformsList=[];var g=f.__webglShader.uniforms,l=f.program.getUniforms(),n;for(n in g)(m=l[n])&&f.uniformsList.push([f.__webglShader.uniforms[n],m]);if(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshStandardMaterial||c.lights)f.lightsHash=R.hash,g.ambientLightColor.value=R.ambient,g.directionalLights.value=
+R.directional,g.spotLights.value=R.spot,g.pointLights.value=R.point,g.hemisphereLights.value=R.hemi,g.directionalShadowMap.value=R.directionalShadowMap,g.directionalShadowMatrix.value=R.directionalShadowMatrix,g.spotShadowMap.value=R.spotShadowMap,g.spotShadowMatrix.value=R.spotShadowMatrix,g.pointShadowMap.value=R.pointShadowMap,g.pointShadowMatrix.value=R.pointShadowMatrix;f.hasDynamicUniforms=!1;n=0;for(g=f.uniformsList.length;n<g;n++)if(!0===f.uniformsList[n][0].dynamic){f.hasDynamicUniforms=
+!0;break}}c.needsUpdate=!1}m=l=p=!1;f=e.program;n=f.getUniforms();g=e.__webglShader.uniforms;f.id!==ha&&(r.useProgram(f.program),ha=f.id,m=l=p=!0);c.id!==ra&&(ra=c.id,l=!0);if(p||a!==ma)r.uniformMatrix4fv(n.projectionMatrix,!1,a.projectionMatrix.elements),da.logarithmicDepthBuffer&&r.uniform1f(n.logDepthBufFC,2/(Math.log(a.far+1)/Math.LN2)),a!==ma&&(ma=a,m=l=!0),(c instanceof THREE.ShaderMaterial||c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshStandardMaterial||c.envMap)&&void 0!==n.cameraPosition&&
 (W.setFromMatrixPosition(a.matrixWorld),r.uniform3f(n.cameraPosition,W.x,W.y,W.z)),(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshBasicMaterial||c instanceof THREE.MeshStandardMaterial||c instanceof THREE.ShaderMaterial||c.skinning)&&void 0!==n.viewMatrix&&r.uniformMatrix4fv(n.viewMatrix,!1,a.matrixWorldInverse.elements),void 0!==n.toneMappingExposure&&r.uniform1f(n.toneMappingExposure,X.toneMappingExposure),void 0!==n.toneMappingWhitePoint&&
 r.uniform1f(n.toneMappingWhitePoint,X.toneMappingWhitePoint);c.skinning&&(d.bindMatrix&&void 0!==n.bindMatrix&&r.uniformMatrix4fv(n.bindMatrix,!1,d.bindMatrix.elements),d.bindMatrixInverse&&void 0!==n.bindMatrixInverse&&r.uniformMatrix4fv(n.bindMatrixInverse,!1,d.bindMatrixInverse.elements),da.floatVertexTextures&&d.skeleton&&d.skeleton.useVertexTexture?(void 0!==n.boneTexture&&(p=s(),r.uniform1i(n.boneTexture,p),X.setTexture(d.skeleton.boneTexture,p)),void 0!==n.boneTextureWidth&&r.uniform1i(n.boneTextureWidth,
-d.skeleton.boneTextureWidth),void 0!==n.boneTextureHeight&&r.uniform1i(n.boneTextureHeight,d.skeleton.boneTextureHeight)):d.skeleton&&d.skeleton.boneMatrices&&void 0!==n.boneGlobalMatrices&&r.uniformMatrix4fv(n.boneGlobalMatrices,!1,d.skeleton.boneMatrices));if(l){if(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshStandardMaterial||c.lights)l=m,f.ambientLightColor.needsUpdate=l,f.directionalLights.needsUpdate=l,f.pointLights.needsUpdate=l,f.spotLights.needsUpdate=
-l,f.hemisphereLights.needsUpdate=l;b&&c.fog&&(f.fogColor.value=b.color,b instanceof THREE.Fog?(f.fogNear.value=b.near,f.fogFar.value=b.far):b instanceof THREE.FogExp2&&(f.fogDensity.value=b.density));if(c instanceof THREE.MeshBasicMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshStandardMaterial){f.opacity.value=c.opacity;f.diffuse.value=c.color;c.emissive&&f.emissive.value.copy(c.emissive).multiplyScalar(c.emissiveIntensity);f.map.value=
-c.map;f.specularMap.value=c.specularMap;f.alphaMap.value=c.alphaMap;c.aoMap&&(f.aoMap.value=c.aoMap,f.aoMapIntensity.value=c.aoMapIntensity);var q;c.map?q=c.map:c.specularMap?q=c.specularMap:c.displacementMap?q=c.displacementMap:c.normalMap?q=c.normalMap:c.bumpMap?q=c.bumpMap:c.roughnessMap?q=c.roughnessMap:c.metalnessMap?q=c.metalnessMap:c.alphaMap?q=c.alphaMap:c.emissiveMap&&(q=c.emissiveMap);void 0!==q&&(q instanceof THREE.WebGLRenderTarget&&(q=q.texture),b=q.offset,q=q.repeat,f.offsetRepeat.value.set(b.x,
-b.y,q.x,q.y));f.envMap.value=c.envMap;f.flipEnvMap.value=c.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;f.reflectivity.value=c.reflectivity;f.refractionRatio.value=c.refractionRatio}c instanceof THREE.LineBasicMaterial?(f.diffuse.value=c.color,f.opacity.value=c.opacity):c instanceof THREE.LineDashedMaterial?(f.diffuse.value=c.color,f.opacity.value=c.opacity,f.dashSize.value=c.dashSize,f.totalSize.value=c.dashSize+c.gapSize,f.scale.value=c.scale):c instanceof THREE.PointsMaterial?(f.diffuse.value=
-c.color,f.opacity.value=c.opacity,f.size.value=c.size*aa,f.scale.value=A.clientHeight/2,f.map.value=c.map,null!==c.map&&(q=c.map.offset,c=c.map.repeat,f.offsetRepeat.value.set(q.x,q.y,c.x,c.y))):c instanceof THREE.MeshLambertMaterial?(c.lightMap&&(f.lightMap.value=c.lightMap,f.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(f.emissiveMap.value=c.emissiveMap)):c instanceof THREE.MeshPhongMaterial?(f.specular.value=c.specular,f.shininess.value=Math.max(c.shininess,1E-4),c.lightMap&&(f.lightMap.value=
-c.lightMap,f.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(f.emissiveMap.value=c.emissiveMap),c.bumpMap&&(f.bumpMap.value=c.bumpMap,f.bumpScale.value=c.bumpScale),c.normalMap&&(f.normalMap.value=c.normalMap,f.normalScale.value.copy(c.normalScale)),c.displacementMap&&(f.displacementMap.value=c.displacementMap,f.displacementScale.value=c.displacementScale,f.displacementBias.value=c.displacementBias)):c instanceof THREE.MeshStandardMaterial?(f.roughness.value=c.roughness,f.metalness.value=
-c.metalness,c.roughnessMap&&(f.roughnessMap.value=c.roughnessMap),c.metalnessMap&&(f.metalnessMap.value=c.metalnessMap),c.lightMap&&(f.lightMap.value=c.lightMap,f.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(f.emissiveMap.value=c.emissiveMap),c.bumpMap&&(f.bumpMap.value=c.bumpMap,f.bumpScale.value=c.bumpScale),c.normalMap&&(f.normalMap.value=c.normalMap,f.normalScale.value.copy(c.normalScale)),c.displacementMap&&(f.displacementMap.value=c.displacementMap,f.displacementScale.value=
-c.displacementScale,f.displacementBias.value=c.displacementBias),c.envMap&&(f.envMapIntensity.value=c.envMapIntensity)):c instanceof THREE.MeshDepthMaterial?(f.mNear.value=a.near,f.mFar.value=a.far,f.opacity.value=c.opacity):c instanceof THREE.MeshNormalMaterial&&(f.opacity.value=c.opacity);E(e.uniformsList)}r.uniformMatrix4fv(n.modelViewMatrix,!1,d.modelViewMatrix.elements);n.normalMatrix&&r.uniformMatrix3fv(n.normalMatrix,!1,d.normalMatrix.elements);void 0!==n.modelMatrix&&r.uniformMatrix4fv(n.modelMatrix,
-!1,d.matrixWorld.elements);if(!0===e.hasDynamicUniforms){e=e.uniformsList;c=[];q=0;for(b=e.length;q<b;q++)n=e[q][0],f=n.onUpdateCallback,void 0!==f&&(f.bind(n)(d,a),c.push(e[q]));E(c)}return g}function s(){var a=ta;a>=da.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+da.maxTextures);ta+=1;return a}function w(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"===
+d.skeleton.boneTextureWidth),void 0!==n.boneTextureHeight&&r.uniform1i(n.boneTextureHeight,d.skeleton.boneTextureHeight)):d.skeleton&&d.skeleton.boneMatrices&&void 0!==n.boneGlobalMatrices&&r.uniformMatrix4fv(n.boneGlobalMatrices,!1,d.skeleton.boneMatrices));if(l){if(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshStandardMaterial||c.lights)l=m,g.ambientLightColor.needsUpdate=l,g.directionalLights.needsUpdate=l,g.pointLights.needsUpdate=l,g.spotLights.needsUpdate=
+l,g.hemisphereLights.needsUpdate=l;b&&c.fog&&(g.fogColor.value=b.color,b instanceof THREE.Fog?(g.fogNear.value=b.near,g.fogFar.value=b.far):b instanceof THREE.FogExp2&&(g.fogDensity.value=b.density));if(c instanceof THREE.MeshBasicMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshStandardMaterial){g.opacity.value=c.opacity;g.diffuse.value=c.color;c.emissive&&g.emissive.value.copy(c.emissive).multiplyScalar(c.emissiveIntensity);g.map.value=
+c.map;g.specularMap.value=c.specularMap;g.alphaMap.value=c.alphaMap;c.aoMap&&(g.aoMap.value=c.aoMap,g.aoMapIntensity.value=c.aoMapIntensity);var q;c.map?q=c.map:c.specularMap?q=c.specularMap:c.displacementMap?q=c.displacementMap:c.normalMap?q=c.normalMap:c.bumpMap?q=c.bumpMap:c.roughnessMap?q=c.roughnessMap:c.metalnessMap?q=c.metalnessMap:c.alphaMap?q=c.alphaMap:c.emissiveMap&&(q=c.emissiveMap);void 0!==q&&(q instanceof THREE.WebGLRenderTarget&&(q=q.texture),b=q.offset,q=q.repeat,g.offsetRepeat.value.set(b.x,
+b.y,q.x,q.y));g.envMap.value=c.envMap;g.flipEnvMap.value=c.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;g.reflectivity.value=c.reflectivity;g.refractionRatio.value=c.refractionRatio}c instanceof THREE.LineBasicMaterial?(g.diffuse.value=c.color,g.opacity.value=c.opacity):c instanceof THREE.LineDashedMaterial?(g.diffuse.value=c.color,g.opacity.value=c.opacity,g.dashSize.value=c.dashSize,g.totalSize.value=c.dashSize+c.gapSize,g.scale.value=c.scale):c instanceof THREE.PointsMaterial?(g.diffuse.value=
+c.color,g.opacity.value=c.opacity,g.size.value=c.size*aa,g.scale.value=A.clientHeight/2,g.map.value=c.map,null!==c.map&&(q=c.map.offset,c=c.map.repeat,g.offsetRepeat.value.set(q.x,q.y,c.x,c.y))):c instanceof THREE.MeshLambertMaterial?(c.lightMap&&(g.lightMap.value=c.lightMap,g.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(g.emissiveMap.value=c.emissiveMap)):c instanceof THREE.MeshPhongMaterial?(g.specular.value=c.specular,g.shininess.value=Math.max(c.shininess,1E-4),c.lightMap&&(g.lightMap.value=
+c.lightMap,g.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(g.emissiveMap.value=c.emissiveMap),c.bumpMap&&(g.bumpMap.value=c.bumpMap,g.bumpScale.value=c.bumpScale),c.normalMap&&(g.normalMap.value=c.normalMap,g.normalScale.value.copy(c.normalScale)),c.displacementMap&&(g.displacementMap.value=c.displacementMap,g.displacementScale.value=c.displacementScale,g.displacementBias.value=c.displacementBias)):c instanceof THREE.MeshStandardMaterial?(g.roughness.value=c.roughness,g.metalness.value=
+c.metalness,c.roughnessMap&&(g.roughnessMap.value=c.roughnessMap),c.metalnessMap&&(g.metalnessMap.value=c.metalnessMap),c.lightMap&&(g.lightMap.value=c.lightMap,g.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(g.emissiveMap.value=c.emissiveMap),c.bumpMap&&(g.bumpMap.value=c.bumpMap,g.bumpScale.value=c.bumpScale),c.normalMap&&(g.normalMap.value=c.normalMap,g.normalScale.value.copy(c.normalScale)),c.displacementMap&&(g.displacementMap.value=c.displacementMap,g.displacementScale.value=
+c.displacementScale,g.displacementBias.value=c.displacementBias),c.envMap&&(g.envMapIntensity.value=c.envMapIntensity)):c instanceof THREE.MeshDepthMaterial?(g.mNear.value=a.near,g.mFar.value=a.far,g.opacity.value=c.opacity):c instanceof THREE.MeshNormalMaterial&&(g.opacity.value=c.opacity);E(e.uniformsList)}r.uniformMatrix4fv(n.modelViewMatrix,!1,d.modelViewMatrix.elements);n.normalMatrix&&r.uniformMatrix3fv(n.normalMatrix,!1,d.normalMatrix.elements);void 0!==n.modelMatrix&&r.uniformMatrix4fv(n.modelMatrix,
+!1,d.matrixWorld.elements);if(!0===e.hasDynamicUniforms){e=e.uniformsList;c=[];q=0;for(b=e.length;q<b;q++)n=e[q][0],g=n.onUpdateCallback,void 0!==g&&(g.bind(n)(d,a),c.push(e[q]));E(c)}return f}function s(){var a=ta;a>=da.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+da.maxTextures);ta+=1;return a}function w(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("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];w(e,e.type,g,h)}}else if("sa"===b){a=a.properties;b=0;for(var k=d.length;b<k;b++)for(f in a)e=a[f],g=c[b][f],h=d[b][f],w(e,e.type,g,h)}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("v2v"===b){void 0===a._array&&(a._array=new Float32Array(2*d.length));e=b=0;for(f=d.length;b<f;b++,e+=2)a._array[e+0]=d[b].x,a._array[e+1]=d[b].y;r.uniform2fv(c,a._array)}else if("v3v"===b){void 0===a._array&&(a._array=new Float32Array(3*d.length));e=b=0;for(f=d.length;b<f;b++,e+=3)a._array[e+0]=d[b].x,a._array[e+1]=d[b].y,a._array[e+2]=d[b].z;r.uniform3fv(c,a._array)}else if("v4v"===b){void 0===a._array&&(a._array=new Float32Array(4*d.length));e=b=0;for(f=d.length;b<f;b++,
-e+=4)a._array[e+0]=d[b].x,a._array[e+1]=d[b].y,a._array[e+2]=d[b].z,a._array[e+3]=d[b].w;r.uniform4fv(c,a._array)}else if("m2"===b)r.uniformMatrix2fv(c,!1,d.elements);else if("m3"===b)r.uniformMatrix3fv(c,!1,d.elements);else if("m3v"===b){void 0===a._array&&(a._array=new Float32Array(9*d.length));b=0;for(f=d.length;b<f;b++)d[b].flattenToArrayOffset(a._array,9*b);r.uniformMatrix3fv(c,!1,a._array)}else if("m4"===b)r.uniformMatrix4fv(c,!1,d.elements);else if("m4v"===b){void 0===a._array&&(a._array=new Float32Array(16*
-d.length));b=0;for(f=d.length;b<f;b++)d[b].flattenToArrayOffset(a._array,16*b);r.uniformMatrix4fv(c,!1,a._array)}else if("t"===b)e=s(),r.uniform1i(c,e),d&&(d instanceof THREE.CubeTexture||Array.isArray(d.image)&&6===d.image.length?y(d,e):d instanceof THREE.WebGLRenderTargetCube?B(d.texture,e):d instanceof THREE.WebGLRenderTarget?X.setTexture(d.texture,e):X.setTexture(d,e));else if("tv"===b){void 0===a._array&&(a._array=[]);b=0;for(f=a.value.length;b<f;b++)a._array[b]=s();r.uniform1iv(c,a._array);
-b=0;for(f=a.value.length;b<f;b++)d=a.value[b],e=a._array[b],d&&(d instanceof THREE.CubeTexture||d.image instanceof Array&&6===d.image.length?y(d,e):d instanceof THREE.WebGLRenderTarget?X.setTexture(d.texture,e):d instanceof THREE.WebGLRenderTargetCube?B(d.texture,e):X.setTexture(d,e))}else console.warn("THREE.WebGLRenderer: Unknown uniform type: "+b)}function E(a){for(var b=0,c=a.length;b<c;b++){var d=a[b][0];!1!==d.needsUpdate&&w(d,d.type,a[b][1],d.value)}}function x(a,b,c){c?(r.texParameteri(a,
+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 g in a){e=a[g];var f=c[g],h=d[g];w(e,e.type,f,h)}}else if("sa"===b){a=a.properties;b=0;for(var k=d.length;b<k;b++)for(g in a)e=a[g],f=c[b][g],h=d[b][g],w(e,e.type,f,h)}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("v2v"===b){void 0===a._array&&(a._array=new Float32Array(2*d.length));e=b=0;for(g=d.length;b<g;b++,e+=2)a._array[e+0]=d[b].x,a._array[e+1]=d[b].y;r.uniform2fv(c,a._array)}else if("v3v"===b){void 0===a._array&&(a._array=new Float32Array(3*d.length));e=b=0;for(g=d.length;b<g;b++,e+=3)a._array[e+0]=d[b].x,a._array[e+1]=d[b].y,a._array[e+2]=d[b].z;r.uniform3fv(c,a._array)}else if("v4v"===b){void 0===a._array&&(a._array=new Float32Array(4*d.length));e=b=0;for(g=d.length;b<g;b++,
+e+=4)a._array[e+0]=d[b].x,a._array[e+1]=d[b].y,a._array[e+2]=d[b].z,a._array[e+3]=d[b].w;r.uniform4fv(c,a._array)}else if("m2"===b)r.uniformMatrix2fv(c,!1,d.elements);else if("m3"===b)r.uniformMatrix3fv(c,!1,d.elements);else if("m3v"===b){void 0===a._array&&(a._array=new Float32Array(9*d.length));b=0;for(g=d.length;b<g;b++)d[b].flattenToArrayOffset(a._array,9*b);r.uniformMatrix3fv(c,!1,a._array)}else if("m4"===b)r.uniformMatrix4fv(c,!1,d.elements);else if("m4v"===b){void 0===a._array&&(a._array=new Float32Array(16*
+d.length));b=0;for(g=d.length;b<g;b++)d[b].flattenToArrayOffset(a._array,16*b);r.uniformMatrix4fv(c,!1,a._array)}else if("t"===b)e=s(),r.uniform1i(c,e),d&&(d instanceof THREE.CubeTexture||Array.isArray(d.image)&&6===d.image.length?y(d,e):d instanceof THREE.WebGLRenderTargetCube?B(d.texture,e):d instanceof THREE.WebGLRenderTarget?X.setTexture(d.texture,e):X.setTexture(d,e));else if("tv"===b){void 0===a._array&&(a._array=[]);b=0;for(g=a.value.length;b<g;b++)a._array[b]=s();r.uniform1iv(c,a._array);
+b=0;for(g=a.value.length;b<g;b++)d=a.value[b],e=a._array[b],d&&(d instanceof THREE.CubeTexture||d.image instanceof Array&&6===d.image.length?y(d,e):d instanceof THREE.WebGLRenderTarget?X.setTexture(d.texture,e):d instanceof THREE.WebGLRenderTargetCube?B(d.texture,e):X.setTexture(d,e))}else console.warn("THREE.WebGLRenderer: Unknown uniform type: "+b)}function E(a){for(var b=0,c=a.length;b<c;b++){var d=a[b][0];!1!==d.needsUpdate&&w(d,d.type,a[b][1],d.value)}}function x(a,b,c){c?(r.texParameteri(a,
 r.TEXTURE_WRAP_S,L(b.wrapS)),r.texParameteri(a,r.TEXTURE_WRAP_T,L(b.wrapT)),r.texParameteri(a,r.TEXTURE_MAG_FILTER,L(b.magFilter)),r.texParameteri(a,r.TEXTURE_MIN_FILTER,L(b.minFilter))):(r.texParameteri(a,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(a,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),b.wrapS===THREE.ClampToEdgeWrapping&&b.wrapT===THREE.ClampToEdgeWrapping||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",
 b),r.texParameteri(a,r.TEXTURE_MAG_FILTER,H(b.magFilter)),r.texParameteri(a,r.TEXTURE_MIN_FILTER,H(b.minFilter)),b.minFilter!==THREE.NearestFilter&&b.minFilter!==THREE.LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",b));!(c=V.get("EXT_texture_filter_anisotropic"))||b.type===THREE.FloatType&&null===V.get("OES_texture_float_linear")||b.type===THREE.HalfFloatType&&null===V.get("OES_texture_half_float_linear")||
 !(1<b.anisotropy||U.get(b).__currentAnisotropy)||(r.texParameterf(a,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,X.getMaxAnisotropy())),U.get(b).__currentAnisotropy=b.anisotropy)}function D(a,b){if(a.width>b||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 z(a){return THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height)}function y(a,b){var c=U.get(a);if(6===a.image.length)if(0<a.version&&c.__version!==a.version){c.__image__webglTextureCube||(a.addEventListener("dispose",f),c.__image__webglTextureCube=r.createTexture(),ia.textures++);K.activeTexture(r.TEXTURE0+b);K.bindTexture(r.TEXTURE_CUBE_MAP,c.__image__webglTextureCube);r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,a.flipY);
 for(var d=a instanceof THREE.CompressedTexture,e=a.image[0]instanceof THREE.DataTexture,g=[],h=0;6>h;h++)g[h]=!X.autoScaleCubemaps||d||e?e?a.image[h].image:a.image[h]:D(a.image[h],da.maxCubemapSize);var k=z(g[0]),l=L(a.format),m=L(a.type);x(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;q<s;q++)n=p[q],a.format!==THREE.RGBAFormat&&a.format!==THREE.RGBFormat?-1<K.getCompressedTextureFormats().indexOf(l)?K.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,q,l,
 n.width,n.height,0,n.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setCubeTexture()"):K.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,q,l,n.width,n.height,0,l,m,n.data);else e?K.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,l,g[h].width,g[h].height,0,l,m,g[h].data):K.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,l,l,m,g[h]);a.generateMipmaps&&k&&r.generateMipmap(r.TEXTURE_CUBE_MAP);c.__version=a.version;if(a.onUpdate)a.onUpdate(a)}else K.activeTexture(r.TEXTURE0+
-b),K.bindTexture(r.TEXTURE_CUBE_MAP,c.__image__webglTextureCube)}function B(a,b){K.activeTexture(r.TEXTURE0+b);K.bindTexture(r.TEXTURE_CUBE_MAP,U.get(a).__webglTexture)}function G(a,b,c,d){var e=L(b.texture.format),f=L(b.texture.type);K.texImage2D(d,0,e,b.width,b.height,0,e,f,null);r.bindFramebuffer(r.FRAMEBUFFER,a);r.framebufferTexture2D(r.FRAMEBUFFER,c,d,U.get(b.texture).__webglTexture,0);r.bindFramebuffer(r.FRAMEBUFFER,null)}function F(a,b){r.bindRenderbuffer(r.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?
+b),K.bindTexture(r.TEXTURE_CUBE_MAP,c.__image__webglTextureCube)}function B(a,b){K.activeTexture(r.TEXTURE0+b);K.bindTexture(r.TEXTURE_CUBE_MAP,U.get(a).__webglTexture)}function G(a,b,c,d){var e=L(b.texture.format),g=L(b.texture.type);K.texImage2D(d,0,e,b.width,b.height,0,e,g,null);r.bindFramebuffer(r.FRAMEBUFFER,a);r.framebufferTexture2D(r.FRAMEBUFFER,c,d,U.get(b.texture).__webglTexture,0);r.bindFramebuffer(r.FRAMEBUFFER,null)}function F(a,b){r.bindRenderbuffer(r.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?
 (r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,b.width,b.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,b.width,b.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)):r.renderbufferStorage(r.RENDERBUFFER,r.RGBA4,b.width,b.height);r.bindRenderbuffer(r.RENDERBUFFER,null)}function H(a){return a===THREE.NearestFilter||a===THREE.NearestMipMapNearestFilter||
 a===THREE.NearestMipMapLinearFilter?r.NEAREST:r.LINEAR}function L(a){var b;if(a===THREE.RepeatWrapping)return r.REPEAT;if(a===THREE.ClampToEdgeWrapping)return r.CLAMP_TO_EDGE;if(a===THREE.MirroredRepeatWrapping)return r.MIRRORED_REPEAT;if(a===THREE.NearestFilter)return r.NEAREST;if(a===THREE.NearestMipMapNearestFilter)return r.NEAREST_MIPMAP_NEAREST;if(a===THREE.NearestMipMapLinearFilter)return r.NEAREST_MIPMAP_LINEAR;if(a===THREE.LinearFilter)return r.LINEAR;if(a===THREE.LinearMipMapNearestFilter)return r.LINEAR_MIPMAP_NEAREST;
 if(a===THREE.LinearMipMapLinearFilter)return r.LINEAR_MIPMAP_LINEAR;if(a===THREE.UnsignedByteType)return r.UNSIGNED_BYTE;if(a===THREE.UnsignedShort4444Type)return r.UNSIGNED_SHORT_4_4_4_4;if(a===THREE.UnsignedShort5551Type)return r.UNSIGNED_SHORT_5_5_5_1;if(a===THREE.UnsignedShort565Type)return r.UNSIGNED_SHORT_5_6_5;if(a===THREE.ByteType)return r.BYTE;if(a===THREE.ShortType)return r.SHORT;if(a===THREE.UnsignedShortType)return r.UNSIGNED_SHORT;if(a===THREE.IntType)return r.INT;if(a===THREE.UnsignedIntType)return r.UNSIGNED_INT;
@@ -639,16 +639,16 @@ return function(){if(void 0!==a)return a;var b=V.get("EXT_texture_filter_anisotr
 0,a,b)};this.setViewport=function(a,b,c,d){K.viewport(la.set(a,b,c,d))};this.setScissor=function(a,b,c,d){K.scissor(ya.set(a,b,c,d))};this.setScissorTest=function(a){K.setScissorTest(Ba=a)};this.getClearColor=function(){return ba};this.setClearColor=function(a,c){ba.set(a);ga=void 0!==c?c:1;b(ba.r,ba.g,ba.b,ga)};this.getClearAlpha=function(){return ga};this.setClearAlpha=function(a){ga=a;b(ba.r,ba.g,ba.b,ga)};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(){A.removeEventListener("webglcontextlost",e,!1)};this.renderBufferImmediate=function(a,b,c){K.initAttributes();var d=U.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&&c.shading===THREE.FlatShading)for(var e=0,f=3*a.count;e<f;e+=9){var g=a.normalArray,h=(g[e+0]+g[e+3]+g[e+6])/3,k=(g[e+1]+g[e+4]+g[e+7])/3,l=(g[e+2]+g[e+5]+g[e+8])/3;g[e+0]=h;g[e+1]=k;g[e+2]=l;g[e+3]=h;g[e+4]=k;g[e+5]=l;g[e+6]=h;g[e+7]=k;g[e+8]=l}r.bufferData(r.ARRAY_BUFFER,a.normalArray,r.DYNAMIC_DRAW);K.enableAttribute(b.normal);r.vertexAttribPointer(b.normal,3,r.FLOAT,!1,0,0)}a.hasUvs&&c.map&&(r.bindBuffer(r.ARRAY_BUFFER,d.uv),r.bufferData(r.ARRAY_BUFFER,a.uvArray,r.DYNAMIC_DRAW),K.enableAttribute(b.uv),
-r.vertexAttribPointer(b.uv,2,r.FLOAT,!1,0,0));a.hasColors&&c.vertexColors!==THREE.NoColors&&(r.bindBuffer(r.ARRAY_BUFFER,d.color),r.bufferData(r.ARRAY_BUFFER,a.colorArray,r.DYNAMIC_DRAW),K.enableAttribute(b.color),r.vertexAttribPointer(b.color,3,r.FLOAT,!1,0,0));K.disableUnusedAttributes();r.drawArrays(r.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){v(d);var g=t(a,b,d,e),h=!1;a=c.id+"_"+g.id+"_"+d.wireframe;a!==na&&(na=a,h=!0);b=e.morphTargetInfluences;if(void 0!==
-b){a=[];for(var k=0,h=b.length;k<h;k++){var m=b[k];a.push([m,k])}a.sort(l);8<a.length&&(a.length=8);for(var n=c.morphAttributes,k=0,h=a.length;k<h;k++)m=a[k],$[k]=m[0],0!==m[0]?(b=m[1],!0===d.morphTargets&&n.position&&c.addAttribute("morphTarget"+k,n.position[b]),!0===d.morphNormals&&n.normal&&c.addAttribute("morphNormal"+k,n.normal[b])):(!0===d.morphTargets&&c.removeAttribute("morphTarget"+k),!0===d.morphNormals&&c.removeAttribute("morphNormal"+k));a=g.getUniforms();null!==a.morphTargetInfluences&&
+c.type&&c.shading===THREE.FlatShading)for(var e=0,g=3*a.count;e<g;e+=9){var f=a.normalArray,h=(f[e+0]+f[e+3]+f[e+6])/3,k=(f[e+1]+f[e+4]+f[e+7])/3,l=(f[e+2]+f[e+5]+f[e+8])/3;f[e+0]=h;f[e+1]=k;f[e+2]=l;f[e+3]=h;f[e+4]=k;f[e+5]=l;f[e+6]=h;f[e+7]=k;f[e+8]=l}r.bufferData(r.ARRAY_BUFFER,a.normalArray,r.DYNAMIC_DRAW);K.enableAttribute(b.normal);r.vertexAttribPointer(b.normal,3,r.FLOAT,!1,0,0)}a.hasUvs&&c.map&&(r.bindBuffer(r.ARRAY_BUFFER,d.uv),r.bufferData(r.ARRAY_BUFFER,a.uvArray,r.DYNAMIC_DRAW),K.enableAttribute(b.uv),
+r.vertexAttribPointer(b.uv,2,r.FLOAT,!1,0,0));a.hasColors&&c.vertexColors!==THREE.NoColors&&(r.bindBuffer(r.ARRAY_BUFFER,d.color),r.bufferData(r.ARRAY_BUFFER,a.colorArray,r.DYNAMIC_DRAW),K.enableAttribute(b.color),r.vertexAttribPointer(b.color,3,r.FLOAT,!1,0,0));K.disableUnusedAttributes();r.drawArrays(r.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,g){v(d);var f=t(a,b,d,e),h=!1;a=c.id+"_"+f.id+"_"+d.wireframe;a!==na&&(na=a,h=!0);b=e.morphTargetInfluences;if(void 0!==
+b){a=[];for(var k=0,h=b.length;k<h;k++){var m=b[k];a.push([m,k])}a.sort(l);8<a.length&&(a.length=8);for(var n=c.morphAttributes,k=0,h=a.length;k<h;k++)m=a[k],$[k]=m[0],0!==m[0]?(b=m[1],!0===d.morphTargets&&n.position&&c.addAttribute("morphTarget"+k,n.position[b]),!0===d.morphNormals&&n.normal&&c.addAttribute("morphNormal"+k,n.normal[b])):(!0===d.morphTargets&&c.removeAttribute("morphTarget"+k),!0===d.morphNormals&&c.removeAttribute("morphNormal"+k));a=f.getUniforms();null!==a.morphTargetInfluences&&
 r.uniform1fv(a.morphTargetInfluences,$);h=!0}b=c.index;k=c.attributes.position;!0===d.wireframe&&(b=pa.getWireframeAttribute(c));null!==b?(a=Fa,a.setIndex(b)):a=Ea;if(h){a:{var h=void 0,p;if(c instanceof THREE.InstancedBufferGeometry&&(p=V.get("ANGLE_instanced_arrays"),null===p)){console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");break a}void 0===h&&(h=0);K.initAttributes();var m=c.attributes,
-g=g.getAttributes(),n=d.defaultAttributeValues,q;for(q in g){var s=g[q];if(0<=s){var u=m[q];if(void 0!==u){var x=u.itemSize,w=pa.getAttributeBuffer(u);if(u instanceof THREE.InterleavedBufferAttribute){var E=u.data,z=E.stride,u=u.offset;E instanceof THREE.InstancedInterleavedBuffer?(K.enableAttributeAndDivisor(s,E.meshPerAttribute,p),void 0===c.maxInstancedCount&&(c.maxInstancedCount=E.meshPerAttribute*E.count)):K.enableAttribute(s);r.bindBuffer(r.ARRAY_BUFFER,w);r.vertexAttribPointer(s,x,r.FLOAT,
+f=f.getAttributes(),n=d.defaultAttributeValues,q;for(q in f){var s=f[q];if(0<=s){var u=m[q];if(void 0!==u){var x=u.itemSize,w=pa.getAttributeBuffer(u);if(u instanceof THREE.InterleavedBufferAttribute){var E=u.data,z=E.stride,u=u.offset;E instanceof THREE.InstancedInterleavedBuffer?(K.enableAttributeAndDivisor(s,E.meshPerAttribute,p),void 0===c.maxInstancedCount&&(c.maxInstancedCount=E.meshPerAttribute*E.count)):K.enableAttribute(s);r.bindBuffer(r.ARRAY_BUFFER,w);r.vertexAttribPointer(s,x,r.FLOAT,
 !1,z*E.array.BYTES_PER_ELEMENT,(h*z+u)*E.array.BYTES_PER_ELEMENT)}else u instanceof THREE.InstancedBufferAttribute?(K.enableAttributeAndDivisor(s,u.meshPerAttribute,p),void 0===c.maxInstancedCount&&(c.maxInstancedCount=u.meshPerAttribute*u.count)):K.enableAttribute(s),r.bindBuffer(r.ARRAY_BUFFER,w),r.vertexAttribPointer(s,x,r.FLOAT,!1,0,h*x*4)}else if(void 0!==n&&(x=n[q],void 0!==x))switch(x.length){case 2:r.vertexAttrib2fv(s,x);break;case 3:r.vertexAttrib3fv(s,x);break;case 4:r.vertexAttrib4fv(s,
-x);break;default:r.vertexAttrib1fv(s,x)}}}K.disableUnusedAttributes()}null!==b&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,pa.getAttributeBuffer(b))}p=Infinity;null!==b?p=b.count:void 0!==k&&(p=k.count);q=c.drawRange.start;b=c.drawRange.count;k=null!==f?f.start:0;h=null!==f?f.count:Infinity;f=Math.max(0,q,k);p=Math.min(0+p,q+b,k+h)-1;p=Math.max(0,p-f+1);if(e instanceof THREE.Mesh)if(!0===d.wireframe)K.setLineWidth(d.wireframeLinewidth*(null===ca?aa:1)),a.setMode(r.LINES);else switch(e.drawMode){case THREE.TrianglesDrawMode:a.setMode(r.TRIANGLES);
-break;case THREE.TriangleStripDrawMode:a.setMode(r.TRIANGLE_STRIP);break;case THREE.TriangleFanDrawMode:a.setMode(r.TRIANGLE_FAN)}else e instanceof THREE.Line?(d=d.linewidth,void 0===d&&(d=1),K.setLineWidth(d*(null===ca?aa:1)),e instanceof THREE.LineSegments?a.setMode(r.LINES):a.setMode(r.LINE_STRIP)):e instanceof THREE.Points&&a.setMode(r.POINTS);c instanceof THREE.InstancedBufferGeometry?0<c.maxInstancedCount&&a.renderInstances(c,f,p):a.render(f,p)};this.render=function(a,b,c,d){if(!1===b instanceof
-THREE.Camera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else{var e=a.fog;na="";ra=-1;ma=null;!0===a.autoUpdate&&a.updateMatrixWorld();null===b.parent&&b.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);sa.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse);za.setFromMatrix(sa);J.length=0;Y=Z=-1;ja.length=0;ea.length=0;q(a,b);C.length=Z+1;S.length=Y+1;!0===X.sortObjects&&(C.sort(p),S.sort(n));var f=J,g,h,k,l=0,m=0,s=0,t,v,x,w=b.matrixWorldInverse,
-$=0,E=0,y=0,D=0,B=0;g=R.shadowsPointLight=0;for(h=f.length;g<h;g++)if(k=f[g],t=k.color,v=k.intensity,x=k.distance,k instanceof THREE.AmbientLight)l+=t.r*v,m+=t.g*v,s+=t.b*v;else if(k instanceof THREE.DirectionalLight){var A=xa.get(k);A.color.copy(k.color).multiplyScalar(k.intensity);A.direction.setFromMatrixPosition(k.matrixWorld);W.setFromMatrixPosition(k.target.matrixWorld);A.direction.sub(W);A.direction.transformDirection(w);if(A.shadow=k.castShadow)A.shadowBias=k.shadow.bias,A.shadowRadius=k.shadow.radius,
+x);break;default:r.vertexAttrib1fv(s,x)}}}K.disableUnusedAttributes()}null!==b&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,pa.getAttributeBuffer(b))}p=Infinity;null!==b?p=b.count:void 0!==k&&(p=k.count);q=c.drawRange.start;b=c.drawRange.count;k=null!==g?g.start:0;h=null!==g?g.count:Infinity;g=Math.max(0,q,k);p=Math.min(0+p,q+b,k+h)-1;p=Math.max(0,p-g+1);if(e instanceof THREE.Mesh)if(!0===d.wireframe)K.setLineWidth(d.wireframeLinewidth*(null===ca?aa:1)),a.setMode(r.LINES);else switch(e.drawMode){case THREE.TrianglesDrawMode:a.setMode(r.TRIANGLES);
+break;case THREE.TriangleStripDrawMode:a.setMode(r.TRIANGLE_STRIP);break;case THREE.TriangleFanDrawMode:a.setMode(r.TRIANGLE_FAN)}else e instanceof THREE.Line?(d=d.linewidth,void 0===d&&(d=1),K.setLineWidth(d*(null===ca?aa:1)),e instanceof THREE.LineSegments?a.setMode(r.LINES):a.setMode(r.LINE_STRIP)):e instanceof THREE.Points&&a.setMode(r.POINTS);c instanceof THREE.InstancedBufferGeometry?0<c.maxInstancedCount&&a.renderInstances(c,g,p):a.render(g,p)};this.render=function(a,b,c,d){if(!1===b instanceof
+THREE.Camera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else{var e=a.fog;na="";ra=-1;ma=null;!0===a.autoUpdate&&a.updateMatrixWorld();null===b.parent&&b.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);sa.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse);za.setFromMatrix(sa);J.length=0;Y=Z=-1;ja.length=0;ea.length=0;q(a,b);C.length=Z+1;S.length=Y+1;!0===X.sortObjects&&(C.sort(p),S.sort(n));var g=J,f,h,k,l=0,m=0,s=0,t,v,x,w=b.matrixWorldInverse,
+$=0,E=0,y=0,D=0,B=0;f=R.shadowsPointLight=0;for(h=g.length;f<h;f++)if(k=g[f],t=k.color,v=k.intensity,x=k.distance,k instanceof THREE.AmbientLight)l+=t.r*v,m+=t.g*v,s+=t.b*v;else if(k instanceof THREE.DirectionalLight){var A=xa.get(k);A.color.copy(k.color).multiplyScalar(k.intensity);A.direction.setFromMatrixPosition(k.matrixWorld);W.setFromMatrixPosition(k.target.matrixWorld);A.direction.sub(W);A.direction.transformDirection(w);if(A.shadow=k.castShadow)A.shadowBias=k.shadow.bias,A.shadowRadius=k.shadow.radius,
 A.shadowMapSize=k.shadow.mapSize,R.shadows[B++]=k;R.directionalShadowMap[$]=k.shadow.map;R.directionalShadowMatrix[$]=k.shadow.matrix;R.directional[$++]=A}else if(k instanceof THREE.SpotLight){A=xa.get(k);A.position.setFromMatrixPosition(k.matrixWorld);A.position.applyMatrix4(w);A.color.copy(t).multiplyScalar(v);A.distance=x;A.direction.setFromMatrixPosition(k.matrixWorld);W.setFromMatrixPosition(k.target.matrixWorld);A.direction.sub(W);A.direction.transformDirection(w);A.coneCos=Math.cos(k.angle);
 A.penumbraCos=Math.cos(k.angle*(1-k.penumbra));A.decay=0===k.distance?0:k.decay;if(A.shadow=k.castShadow)A.shadowBias=k.shadow.bias,A.shadowRadius=k.shadow.radius,A.shadowMapSize=k.shadow.mapSize,R.shadows[B++]=k;R.spotShadowMap[y]=k.shadow.map;R.spotShadowMatrix[y]=k.shadow.matrix;R.spot[y++]=A}else if(k instanceof THREE.PointLight){A=xa.get(k);A.position.setFromMatrixPosition(k.matrixWorld);A.position.applyMatrix4(w);A.color.copy(k.color).multiplyScalar(k.intensity);A.distance=k.distance;A.decay=
 0===k.distance?0:k.decay;if(A.shadow=k.castShadow)A.shadowBias=k.shadow.bias,A.shadowRadius=k.shadow.radius,A.shadowMapSize=k.shadow.mapSize,R.shadows[B++]=k;R.pointShadowMap[E]=k.shadow.map;void 0===R.pointShadowMatrix[E]&&(R.pointShadowMatrix[E]=new THREE.Matrix4);W.setFromMatrixPosition(k.matrixWorld).negate();R.pointShadowMatrix[E].identity().setPosition(W);R.point[E++]=A}else k instanceof THREE.HemisphereLight&&(A=xa.get(k),A.direction.setFromMatrixPosition(k.matrixWorld),A.direction.transformDirection(w),
@@ -662,9 +662,9 @@ K.texImage2D(r.TEXTURE_2D,l,g,e.width,e.height,0,g,h,e.data);else if(0<k.length&
 U.get(a).__webglFramebuffer){var b=U.get(a),c=U.get(a.texture);a.addEventListener("dispose",g);c.__webglTexture=r.createTexture();ia.textures++;var d=a instanceof THREE.WebGLRenderTargetCube,e=THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height);if(d){b.__webglFramebuffer=[];for(var f=0;6>f;f++)b.__webglFramebuffer[f]=r.createFramebuffer()}else b.__webglFramebuffer=r.createFramebuffer();if(d){K.bindTexture(r.TEXTURE_CUBE_MAP,c.__webglTexture);x(r.TEXTURE_CUBE_MAP,a.texture,e);for(f=
 0;6>f;f++)G(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),x(r.TEXTURE_2D,a.texture,e),G(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=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(),F(b.__webglDepthbuffer[c],a);else r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer=r.createRenderbuffer(),F(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,qa.copy(a.scissor),Aa=a.scissorTest,ka.copy(a.viewport)):(c=null,
-qa.copy(ya).multiplyScalar(aa),Aa=Ba,ka.copy(la).multiplyScalar(aa));ua!==c&&(r.bindFramebuffer(r.FRAMEBUFFER,c),ua=c);K.scissor(qa);K.setScissorTest(Aa);K.viewport(ka);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!==ua&&(r.bindFramebuffer(r.FRAMEBUFFER,g),h=!0);try{var k=a.texture;k.format!==THREE.RGBAFormat&&L(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||L(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,L(k.format),L(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,ua)}}}}};
+qa.copy(ya).multiplyScalar(aa),Aa=Ba,ka.copy(la).multiplyScalar(aa));ua!==c&&(r.bindFramebuffer(r.FRAMEBUFFER,c),ua=c);K.scissor(qa);K.setScissorTest(Aa);K.viewport(ka);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,g){if(!1===a instanceof THREE.WebGLRenderTarget)console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
+else{var f=U.get(a).__webglFramebuffer;if(f){var h=!1;f!==ua&&(r.bindFramebuffer(r.FRAMEBUFFER,f),h=!0);try{var k=a.texture;k.format!==THREE.RGBAFormat&&L(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||L(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,L(k.format),L(k.type),g):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,ua)}}}}};
 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);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;
@@ -702,8 +702,8 @@ s.alphaTest:"","#define GAMMA_FACTOR "+H,s.useFog&&s.fog?"#define USE_FOG":"",s.
 "#define USE_LOGDEPTHBUF":"",s.logarithmicDepthBuffer&&a.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",s.envMap&&a.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",s.toneMapping!==THREE.NoToneMapping?"#define TONE_MAPPING":"",s.toneMapping!==THREE.NoToneMapping?THREE.ShaderChunk.tonemapping_pars_fragment:"",s.toneMapping!==THREE.NoToneMapping?d("toneMapping",s.toneMapping):"",s.outputEncoding||s.mapEncoding||
 s.envMapEncoding||s.emissiveMapEncoding?THREE.ShaderChunk.encodings_pars_fragment:"",s.mapEncoding?b("mapTexelToLinear",s.mapEncoding):"",s.envMapEncoding?b("envMapTexelToLinear",s.envMapEncoding):"",s.emissiveMapEncoding?b("emissiveMapTexelToLinear",s.emissiveMapEncoding):"",s.outputEncoding?c("linearToOutputTexel",s.outputEncoding):"","\n"].filter(g).join("\n"));D=k(D,s);D=h(D,s);z=k(z,s);z=h(z,s);!1===t instanceof THREE.ShaderMaterial&&(D=l(D),z=l(z));z=a+z;D=THREE.WebGLShader(w,w.VERTEX_SHADER,
 x+D);z=THREE.WebGLShader(w,w.FRAGMENT_SHADER,z);w.attachShader(A,D);w.attachShader(A,z);void 0!==t.index0AttributeName?w.bindAttribLocation(A,0,t.index0AttributeName):!0===s.morphTargets&&w.bindAttribLocation(A,0,"position");w.linkProgram(A);s=w.getProgramInfoLog(A);y=w.getShaderInfoLog(D);B=w.getShaderInfoLog(z);F=G=!0;if(!1===w.getProgramParameter(A,w.LINK_STATUS))G=!1,console.error("THREE.WebGLProgram: shader error: ",w.getError(),"gl.VALIDATE_STATUS",w.getProgramParameter(A,w.VALIDATE_STATUS),
-"gl.getProgramInfoLog",s,y,B);else if(""!==s)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",s);else if(""===y||""===B)F=!1;F&&(this.diagnostics={runnable:G,material:t,programLog:s,vertexShader:{log:y,prefix:x},fragmentShader:{log:B,prefix:a}});w.deleteShader(D);w.deleteShader(z);var N;this.getUniforms=function(){if(void 0===N){for(var a={},b=w.getProgramParameter(A,w.ACTIVE_UNIFORMS),c=0;c<b;c++){var d=w.getActiveUniform(A,c).name,e=w.getUniformLocation(A,d),f=n.exec(d);if(f){var d=f[1],
-f=f[2],g=a[d];g||(g=a[d]={});g[f]=e}else if(f=m.exec(d)){var g=f[1],d=f[2],f=f[3],h=a[g];h||(h=a[g]=[]);(g=h[d])||(g=h[d]={});g[f]=e}else(f=q.exec(d))?(g=f[1],a[g]=e):a[d]=e}N=a}return N};var M;this.getAttributes=function(){if(void 0===M){for(var a={},b=w.getProgramParameter(A,w.ACTIVE_ATTRIBUTES),c=0;c<b;c++){var d=w.getActiveAttrib(A,c).name;a[d]=w.getAttribLocation(A,d)}M=a}return M};this.destroy=function(){w.deleteProgram(A);this.program=void 0};Object.defineProperties(this,{uniforms:{get:function(){console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms().");
+"gl.getProgramInfoLog",s,y,B);else if(""!==s)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",s);else if(""===y||""===B)F=!1;F&&(this.diagnostics={runnable:G,material:t,programLog:s,vertexShader:{log:y,prefix:x},fragmentShader:{log:B,prefix:a}});w.deleteShader(D);w.deleteShader(z);var N;this.getUniforms=function(){if(void 0===N){for(var a={},b=w.getProgramParameter(A,w.ACTIVE_UNIFORMS),c=0;c<b;c++){var d=w.getActiveUniform(A,c).name,e=w.getUniformLocation(A,d),g=n.exec(d);if(g){var d=g[1],
+g=g[2],f=a[d];f||(f=a[d]={});f[g]=e}else if(g=m.exec(d)){var f=g[1],d=g[2],g=g[3],h=a[f];h||(h=a[f]=[]);(f=h[d])||(f=h[d]={});f[g]=e}else(g=q.exec(d))?(f=g[1],a[f]=e):a[d]=e}N=a}return N};var M;this.getAttributes=function(){if(void 0===M){for(var a={},b=w.getProgramParameter(A,w.ACTIVE_ATTRIBUTES),c=0;c<b;c++){var d=w.getActiveAttrib(A,c).name;a[d]=w.getAttribLocation(A,d)}M=a}return M};this.destroy=function(){w.deleteProgram(A);this.program=void 0};Object.defineProperties(this,{uniforms:{get:function(){console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms().");
 return this.getUniforms()}},attributes:{get:function(){console.warn("THREE.WebGLProgram: .attributes is now .getAttributes().");return this.getAttributes()}}});this.id=p++;this.code=v;this.usedTimes=1;this.program=A;this.vertexShader=D;this.fragmentShader=z;return this}}();
 THREE.WebGLPrograms=function(a,b){function c(a,b){var c;a?a instanceof THREE.Texture?c=a.encoding:a instanceof THREE.WebGLRenderTarget&&(c=a.texture.encoding):c=THREE.LinearEncoding;c===THREE.LinearEncoding&&b&&(c=THREE.GammaEncoding);return c}var d=[],e={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshStandardMaterial:"standard",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},
 f="precision supportsVertexTextures map mapEncoding envMap envMapMode envMapEncoding lightMap aoMap emissiveMap emissiveMapEncoding bumpMap normalMap displacementMap specularMap roughnessMap metalnessMap alphaMap combine vertexColors fog useFog fogExp flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals premultipliedAlpha numDirLights numPointLights numSpotLights numHemiLights shadowMapEnabled pointLightShadows toneMapping physicallyCorrectLights shadowMapType alphaTest doubleSided flipSided".split(" ");
@@ -721,7 +721,7 @@ z=0;4!==z;++z){var y=0!==(z&1),B=0!==(z&2),G=new THREE.ShaderMaterial({uniforms:
 E=b.shadows;if(0!==E.length&&!1!==F.enabled&&(!1!==F.autoUpdate||!1!==F.needsUpdate)){g.clearColor(1,1,1,1);g.disable(f.BLEND);g.enable(f.CULL_FACE);f.frontFace(f.CCW);f.cullFace(F.cullFace===THREE.CullFaceFront?f.FRONT:f.BACK);g.setDepthTest(!0);g.setScissorTest(!1);for(var z=0,y=E.length;z<y;z++){var D=E[z],B=D.shadow,G=B.camera;l.copy(B.mapSize);if(D instanceof THREE.PointLight){x=6;w=!0;var J=l.x,C=l.y;s[0].set(2*J,C,J,C);s[1].set(0,C,J,C);s[2].set(3*J,C,J,C);s[3].set(J,C,J,C);s[4].set(3*J,0,
 J,C);s[5].set(J,0,J,C);l.x*=4;l.y*=2}else x=1,w=!1;null===B.map&&(B.map=new THREE.WebGLRenderTarget(l.x,l.y,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat}),D instanceof THREE.SpotLight&&(G.aspect=l.x/l.y),G.updateProjectionMatrix());J=B.map;B=B.matrix;n.setFromMatrixPosition(D.matrixWorld);G.position.copy(n);a.setRenderTarget(J);a.clear();for(J=0;J<x;J++){w?(p.copy(G.position),p.add(v[J]),G.up.copy(t[J]),G.lookAt(p),g.viewport(s[J])):(p.setFromMatrixPosition(D.target.matrixWorld),
 G.lookAt(p));G.updateMatrixWorld();G.matrixWorldInverse.getInverse(G.matrixWorld);B.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);B.multiply(G.projectionMatrix);B.multiply(G.matrixWorldInverse);k.multiplyMatrices(G.projectionMatrix,G.matrixWorldInverse);h.setFromMatrix(k);m.length=0;e(q,u,G);for(var C=0,Z=m.length;C<Z;C++){var S=m[C],Y=c.update(S),$=S.material;if($ instanceof THREE.MultiMaterial)for(var ja=Y.groups,$=$.materials,ea=0,X=ja.length;ea<X;ea++){var ha=ja[ea],ca=$[ha.materialIndex];!0===ca.visible&&
-(ca=d(S,ca,w,n),a.renderBufferDirect(G,null,Y,ca,S,ha))}else ca=d(S,$,w,n),a.renderBufferDirect(G,null,Y,ca,S,null)}}a.resetGLState()}x=a.getClearColor();w=a.getClearAlpha();a.setClearColor(x,w);g.enable(f.BLEND);F.cullFace===THREE.CullFaceFront&&f.cullFace(f.BACK);a.resetGLState();F.needsUpdate=!1}}};
+(ca=d(S,ca,w,n),a.renderBufferDirect(G,null,Y,ca,S,ha))}else ca=d(S,$,w,n),a.renderBufferDirect(G,null,Y,ca,S,null)}}}x=a.getClearColor();w=a.getClearAlpha();a.setClearColor(x,w);g.enable(f.BLEND);F.cullFace===THREE.CullFaceFront&&f.cullFace(f.BACK);F.needsUpdate=!1}}};
 THREE.WebGLState=function(a,b,c){var d=this,e=new THREE.Vector4,f=new Uint8Array(16),g=new Uint8Array(16),h=new Uint8Array(16),k={},l=null,p=null,n=null,m=null,q=null,u=null,v=null,t=null,s=!1,w=null,E=null,x=null,D=null,z=null,y=null,B=null,G=null,F=null,H=null,L=null,A=null,N=null,M=null,I=null,O=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),Q=void 0,P={},T=new THREE.Vector4,J=null,C=null,Z=new THREE.Vector4,S=new THREE.Vector4,Y=a.createTexture();a.bindTexture(a.TEXTURE_2D,Y);a.texParameteri(a.TEXTURE_2D,
 a.TEXTURE_MIN_FILTER,a.LINEAR);a.texImage2D(a.TEXTURE_2D,0,a.RGB,1,1,0,a.RGB,a.UNSIGNED_BYTE,new Uint8Array(3));this.init=function(){this.clearColor(0,0,0,1);this.clearDepth(1);this.clearStencil(0);this.enable(a.DEPTH_TEST);a.depthFunc(a.LEQUAL);a.frontFace(a.CCW);a.cullFace(a.BACK);this.enable(a.CULL_FACE);this.enable(a.BLEND);a.blendEquation(a.FUNC_ADD);a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA)};this.initAttributes=function(){for(var a=0,b=f.length;a<b;a++)f[a]=0};this.enableAttribute=function(c){f[c]=
 1;0===g[c]&&(a.enableVertexAttribArray(c),g[c]=1);0!==h[c]&&(b.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(c,0),h[c]=0)};this.enableAttributeAndDivisor=function(b,c,d){f[b]=1;0===g[b]&&(a.enableVertexAttribArray(b),g[b]=1);h[b]!==c&&(d.vertexAttribDivisorANGLE(b,c),h[b]=c)};this.disableUnusedAttributes=function(){for(var b=0,c=g.length;b<c;b++)g[b]!==f[b]&&(a.disableVertexAttribArray(b),g[b]=0)};this.enable=function(b){!0!==k[b]&&(a.enable(b),k[b]=!0)};this.disable=function(b){!1!==k[b]&&
@@ -871,8 +871,10 @@ THREE.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(a,b,c,d){a=a.vert
 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<d;c++)this.addShape(a[c],b);return this};
 THREE.ShapeGeometry.prototype.addShape=function(a,b){void 0===b&&(b={});var c=b.material,d=void 0===b.UVGenerator?THREE.ExtrudeGeometry.WorldUVGenerator:b.UVGenerator,e,f,g,h=this.vertices.length;e=a.extractPoints(void 0!==b.curveSegments?b.curveSegments:12);var k=e.shape,l=e.holes;if(!THREE.ShapeUtils.isClockWise(k))for(k=k.reverse(),e=0,f=l.length;e<f;e++)g=l[e],THREE.ShapeUtils.isClockWise(g)&&(l[e]=g.reverse());var p=THREE.ShapeUtils.triangulateShape(k,l);e=0;for(f=l.length;e<f;e++)g=l[e],k=k.concat(g);
 l=k.length;f=p.length;for(e=0;e<l;e++)g=k[e],this.vertices.push(new THREE.Vector3(g.x,g.y,0));for(e=0;e<f;e++)l=p[e],k=l[0]+h,g=l[1]+h,l=l[2]+h,this.faces.push(new THREE.Face3(k,g,l,null,null,c)),this.faceVertexUvs[0].push(d.generateTopUV(this,k,g,l))};
-THREE.LatheGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};b=b||12;c=c||0;d=d||2*Math.PI;for(var e=1/(a.length-1),f=1/b,g=0,h=b;g<=h;g++)for(var k=c+g*f*d,l=Math.sin(k),p=Math.cos(k),k=0,n=a.length;k<n;k++){var m=a[k],q=new THREE.Vector3;q.x=m.x*l;q.y=m.y;q.z=m.x*p;this.vertices.push(q)}c=a.length;g=0;for(h=b;g<h;g++)for(k=0,n=a.length-1;k<n;k++){b=k+c*g;d=b+c;var l=b+1+c,p=b+1,m=g*f,q=k*e,u=m+f,v=q+e;this.faces.push(new THREE.Face3(b,
-d,p));this.faceVertexUvs[0].push([new THREE.Vector2(m,q),new THREE.Vector2(u,q),new THREE.Vector2(m,v)]);this.faces.push(new THREE.Face3(d,l,p));this.faceVertexUvs[0].push([new THREE.Vector2(u,q),new THREE.Vector2(u,v),new THREE.Vector2(m,v)])}this.mergeVertices();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
+THREE.LatheBufferGeometry=function(a,b,c,d){THREE.BufferGeometry.call(this);this.type="LatheBufferGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};b=Math.floor(b)||12;c=c||0;d=d||2*Math.PI;d=THREE.Math.clamp(d,0,2*Math.PI);for(var e=(b+1)*a.length,f=b*a.length*6,g=new THREE.BufferAttribute(new (65535<f?Uint32Array:Uint16Array)(f),1),h=new THREE.BufferAttribute(new Float32Array(3*e),3),k=new THREE.BufferAttribute(new Float32Array(2*e),2),l=0,p=0,n=1/b,m=new THREE.Vector3,q=new THREE.Vector2,
+e=0;e<=b;e++)for(var f=c+e*n*d,u=Math.sin(f),v=Math.cos(f),f=0;f<=a.length-1;f++)m.x=a[f].x*u,m.y=a[f].y,m.z=a[f].x*v,h.setXYZ(l,m.x,m.y,m.z),q.x=e/b,q.y=f/(a.length-1),k.setXY(l,q.x,q.y),l++;for(e=0;e<b;e++)for(f=0;f<a.length-1;f++)c=f+e*a.length,l=c+a.length,n=c+a.length+1,m=c+1,g.setX(p,c),p++,g.setX(p,l),p++,g.setX(p,m),p++,g.setX(p,l),p++,g.setX(p,n),p++,g.setX(p,m),p++;this.setIndex(g);this.addAttribute("position",h);this.addAttribute("uv",k);this.computeVertexNormals();if(d===2*Math.PI)for(d=
+this.attributes.normal.array,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,c=b*a.length*3,f=e=0;e<a.length;e++,f+=3)g.x=d[f+0],g.y=d[f+1],g.z=d[f+2],h.x=d[c+f+0],h.y=d[c+f+1],h.z=d[c+f+2],k.addVectors(g,h).normalize(),d[f+0]=d[c+f+0]=k.x,d[f+1]=d[c+f+1]=k.y,d[f+2]=d[c+f+2]=k.z};THREE.LatheBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.LatheBufferGeometry.prototype.constructor=THREE.LatheBufferGeometry;
+THREE.LatheGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};this.fromBufferGeometry(new THREE.LatheBufferGeometry(a,b,c,d));this.mergeVertices()};THREE.LatheGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new THREE.PlaneBufferGeometry(a,b,c,d))};THREE.PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
 THREE.PlaneBufferGeometry=function(a,b,c,d){THREE.BufferGeometry.call(this);this.type="PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};var e=a/2,f=b/2;c=Math.floor(c)||1;d=Math.floor(d)||1;var g=c+1,h=d+1,k=a/c,l=b/d;b=new Float32Array(g*h*3);a=new Float32Array(g*h*3);for(var p=new Float32Array(g*h*2),n=0,m=0,q=0;q<h;q++)for(var u=q*l-f,v=0;v<g;v++)b[n]=v*k-e,b[n+1]=-u,a[n+2]=1,p[m]=v/c,p[m+1]=1-q/d,n+=3,m+=2;n=0;e=new (65535<b.length/3?Uint32Array:Uint16Array)(c*
 d*6);for(q=0;q<d;q++)for(v=0;v<c;v++)f=v+g*(q+1),h=v+1+g*(q+1),k=v+1+g*q,e[n]=v+g*q,e[n+1]=f,e[n+2]=k,e[n+3]=f,e[n+4]=h,e[n+5]=k,n+=6;this.setIndex(new THREE.BufferAttribute(e,1));this.addAttribute("position",new THREE.BufferAttribute(b,3));this.addAttribute("normal",new THREE.BufferAttribute(a,3));this.addAttribute("uv",new THREE.BufferAttribute(p,2))};THREE.PlaneBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.PlaneBufferGeometry.prototype.constructor=THREE.PlaneBufferGeometry;