From 034e44cca5deead8e740efd7f2f0047f00e52db8 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Mon, 17 Nov 2014 16:46:13 +0100 Subject: [PATCH] Updated builds. --- build/three.js | 144 ++++++++++---- build/three.min.js | 255 +++++++++++++------------ src/extras/animation/MorphAnimation.js | 38 ++-- src/renderers/WebGLRenderer.js | 2 +- 4 files changed, 254 insertions(+), 185 deletions(-) diff --git a/build/three.js b/build/three.js index a193b7efeb..19f3e38edb 100644 --- a/build/three.js +++ b/build/three.js @@ -17869,11 +17869,7 @@ THREE.WebGLRenderer = function ( parameters ) { this.domElement = _canvas; this.context = null; - this.devicePixelRatio = parameters.devicePixelRatio !== undefined - ? parameters.devicePixelRatio - : self.devicePixelRatio !== undefined - ? self.devicePixelRatio - : 1; + this.devicePixelRatio = self.devicePixelRatio !== undefined ? self.devicePixelRatio : 1; // clearing @@ -20597,20 +20593,92 @@ THREE.WebGLRenderer = function ( parameters ) { // render particles - if ( updateBuffers ) { + var mode = _gl.POINTS; - setupVertexAttributes( material, program, geometry, 0 ); + var index = geometry.attributes.index; - } + if ( index ) { - var position = geometry.attributes.position; + // indexed points - // render particles + var type, size; - _gl.drawArrays( _gl.POINTS, 0, position.array.length / 3 ); + if ( index.array instanceof Uint32Array && extensions.get( 'OES_element_index_uint' ) ) { - _this.info.render.calls ++; - _this.info.render.points += position.array.length / 3; + type = _gl.UNSIGNED_INT; + size = 4; + + } else { + + type = _gl.UNSIGNED_SHORT; + size = 2; + + } + + var offsets = geometry.offsets; + + if ( offsets.length === 0 ) { + + if ( updateBuffers ) { + + setupVertexAttributes( material, program, geometry, 0 ); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, index.buffer ); + + } + + _gl.drawElements( mode, index.array.length, type, 0); + + _this.info.render.calls ++; + _this.info.render.points += index.array.length; + + } else { + + // if there is more than 1 chunk + // must set attribute pointers to use new offsets for each chunk + // even if geometry and materials didn't change + + if ( offsets.length > 1 ) updateBuffers = true; + + for ( var i = 0, il = offsets.length; i < il; i ++ ) { + + var startIndex = offsets[ i ].index; + + if ( updateBuffers ) { + + setupVertexAttributes( material, program, geometry, startIndex ); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, index.buffer ); + + } + + // render indexed points + + _gl.drawElements( mode, offsets[ i ].count, type, offsets[ i ].start * size ); + + _this.info.render.calls ++; + _this.info.render.points += offsets[ i ].count; + + } + + } + + } else { + + // non-indexed points + + if ( updateBuffers ) { + + setupVertexAttributes( material, program, geometry, 0 ); + + } + + var position = geometry.attributes.position; + + _gl.drawArrays( mode, 0, position.array.length / 3 ); + + _this.info.render.calls ++; + _this.info.render.points += position.array.length / 3; + + } } else if ( object instanceof THREE.Line ) { @@ -30448,6 +30516,7 @@ THREE.KeyFrameAnimation.prototype.getPrevKeyWith = function( sid, h, key ) { /** * @author mrdoob / http://mrdoob.com + * @author willy-vvu / http://willy-vvu.github.io */ THREE.MorphAnimation = function ( mesh ) { @@ -30457,6 +30526,8 @@ THREE.MorphAnimation = function ( mesh ) { this.currentTime = 0; this.duration = 1000; this.loop = true; + this.lastFrame = 0; + this.currentFrame = 0; this.isPlaying = false; @@ -30464,6 +30535,8 @@ THREE.MorphAnimation = function ( mesh ) { THREE.MorphAnimation.prototype = { + constructor: THREE.MorphAnimation, + play: function () { this.isPlaying = true; @@ -30476,45 +30549,38 @@ THREE.MorphAnimation.prototype = { }, - update: ( function () { - - var lastFrame = 0; - var currentFrame = 0; - - return function ( delta ) { + update: function ( delta ) { - if ( this.isPlaying === false ) return; - - this.currentTime += delta; + if ( this.isPlaying === false ) return; - if ( this.loop === true && this.currentTime > this.duration ) { + this.currentTime += delta; - this.currentTime %= this.duration; + if ( this.loop === true && this.currentTime > this.duration ) { - } + this.currentTime %= this.duration; - this.currentTime = Math.min( this.currentTime, this.duration ); - - var interpolation = this.duration / this.frames; - var frame = Math.floor( this.currentTime / interpolation ); + } - if ( frame != currentFrame ) { + this.currentTime = Math.min( this.currentTime, this.duration ); - this.mesh.morphTargetInfluences[ lastFrame ] = 0; - this.mesh.morphTargetInfluences[ currentFrame ] = 1; - this.mesh.morphTargetInfluences[ frame ] = 0; + var interpolation = this.duration / this.frames; + var frame = Math.floor( this.currentTime / interpolation ); - lastFrame = currentFrame; - currentFrame = frame; + if ( frame != this.currentFrame ) { - } + this.mesh.morphTargetInfluences[ this.lastFrame ] = 0; + this.mesh.morphTargetInfluences[ this.currentFrame ] = 1; + this.mesh.morphTargetInfluences[ frame ] = 0; - this.mesh.morphTargetInfluences[ frame ] = ( this.currentTime % interpolation ) / interpolation; - this.mesh.morphTargetInfluences[ lastFrame ] = 1 - this.mesh.morphTargetInfluences[ frame ]; + this.lastFrame = this.currentFrame; + this.currentFrame = frame; } - } )() + this.mesh.morphTargetInfluences[ frame ] = ( this.currentTime % interpolation ) / interpolation; + this.mesh.morphTargetInfluences[ this.lastFrame ] = 1 - this.mesh.morphTargetInfluences[ frame ]; + + } }; diff --git a/build/three.min.js b/build/three.min.js index 9d7c803ba1..b22a120ea2 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -99,8 +99,8 @@ console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotati b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,n=d*h,p=d*e,b[0]=a-p*c,b[4]=-f*e,b[8]=n+k*c,b[1]=k+n*c,b[5]=f*h,b[9]=p-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,n=c*h,p=c*e,b[0]=g*h,b[4]=n*d-k,b[8]=a*d+p,b[1]=g*e,b[5]=p*d+a,b[9]=k*d-n,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,n=c*g,p=c*d,b[0]=g*h,b[4]=p-a*e,b[8]=n*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+n,b[10]=a-p*e):"XZY"===a.order&&(a=f*g,k=f*d,n=c*g,p=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+p,b[5]=f*h,b[9]=k* e-n,b[2]=n*e-k,b[6]=c*h,b[10]=p*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},setRotationFromQuaternion:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");return this.makeRotationFromQuaternion(a)},makeRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,k=e+e;a=c*g;var n=c*h,c=c*k,p=d*h,d=d*k,e=e*k,g=f*g,h=f*h,f=f*k;b[0]=1-(p+e);b[4]=n-f;b[8]=c+h;b[1]=n+f;b[5]=1- (a+e);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+p);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},lookAt:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(d,e,f){var g=this.elements;c.subVectors(d,e).normalize();0===c.length()&&(c.z=1);a.crossVectors(f,c).normalize();0===a.length()&&(c.x+=1E-4,a.crossVectors(f,c).normalize());b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(), -multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],n=c[1],p=c[5],q=c[9],m=c[13],r=c[2],t=c[6],s=c[10],u=c[14],v=c[3],y=c[7],E=c[11],c=c[15],w=d[0],M=d[4],x=d[8],C=d[12],D=d[1],A=d[5],B=d[9],G=d[13],S=d[2],J=d[6],H=d[10],V=d[14],L=d[3], -I=d[7],R=d[11],d=d[15];e[0]=f*w+g*D+h*S+k*L;e[4]=f*M+g*A+h*J+k*I;e[8]=f*x+g*B+h*H+k*R;e[12]=f*C+g*G+h*V+k*d;e[1]=n*w+p*D+q*S+m*L;e[5]=n*M+p*A+q*J+m*I;e[9]=n*x+p*B+q*H+m*R;e[13]=n*C+p*G+q*V+m*d;e[2]=r*w+t*D+s*S+u*L;e[6]=r*M+t*A+s*J+u*I;e[10]=r*x+t*B+s*H+u*R;e[14]=r*C+t*G+s*V+u*d;e[3]=v*w+y*D+E*S+c*L;e[7]=v*M+y*A+E*J+c*I;e[11]=v*x+y*B+E*H+c*R;e[15]=v*C+y*G+E*V+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]= +multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],n=c[1],p=c[5],q=c[9],m=c[13],r=c[2],t=c[6],s=c[10],u=c[14],v=c[3],y=c[7],E=c[11],c=c[15],w=d[0],M=d[4],x=d[8],C=d[12],D=d[1],A=d[5],B=d[9],G=d[13],S=d[2],K=d[6],I=d[10],V=d[14],L=d[3], +J=d[7],R=d[11],d=d[15];e[0]=f*w+g*D+h*S+k*L;e[4]=f*M+g*A+h*K+k*J;e[8]=f*x+g*B+h*I+k*R;e[12]=f*C+g*G+h*V+k*d;e[1]=n*w+p*D+q*S+m*L;e[5]=n*M+p*A+q*K+m*J;e[9]=n*x+p*B+q*I+m*R;e[13]=n*C+p*G+q*V+m*d;e[2]=r*w+t*D+s*S+u*L;e[6]=r*M+t*A+s*K+u*J;e[10]=r*x+t*B+s*I+u*R;e[14]=r*C+t*G+s*V+u*d;e[3]=v*w+y*D+E*S+c*L;e[7]=v*M+y*A+E*K+c*J;e[11]=v*x+y*B+E*I+c*R;e[15]=v*C+y*G+E*V+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]= d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},multiplyVector3:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead."); return a.applyProjection(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)},applyToVector3Array:function(){var a=new THREE.Vector3;return function(b,c,d){void 0===c&&(c=0);void 0===d&&(d= b.length);for(var e=0;eza?-1:1;h[4*a]=ya.x;h[4*a+1]=ya.y;h[4*a+2]=ya.z;h[4*a+3]=Ga}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var c=this.attributes.index.array,d=this.attributes.position.array, -e=this.attributes.normal.array,f=this.attributes.uv.array,g=d.length/3;void 0===this.attributes.tangent&&this.addAttribute("tangent",new THREE.BufferAttribute(new Float32Array(4*g),4));for(var h=this.attributes.tangent.array,k=[],n=[],p=0;pza?-1:1;h[4*a]=ya.x;h[4*a+1]=ya.y;h[4*a+2]=ya.z;h[4*a+3]=Ga}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var c=this.attributes.index.array,d=this.attributes.position.array, +e=this.attributes.normal.array,f=this.attributes.uv.array,g=d.length/3;void 0===this.attributes.tangent&&this.addAttribute("tangent",new THREE.BufferAttribute(new Float32Array(4*g),4));for(var h=this.attributes.tangent.array,k=[],n=[],p=0;ps;s++)t=a[3*c+s],-1==m[t]?(q[2*s]=t,q[2*s+1]=-1,p++):m[t]k.index+b)for(k={start:f,count:0,index:g},h.push(k),p=0;6>p;p+=2)s=q[p+1],-1p;p+=2)t=q[p],s=q[p+1],-1===s&&(s=g++),m[t]=s,r[s]=t,e[f++]=s-k.index,k.count++}this.reorderBuffers(e,r,g);return this.offsets=h},merge:function(){console.log("BufferGeometry.merge(): TODO")},normalizeNormals:function(){for(var a=this.attributes.normal.array,b,c,d,e=0,f=a.length;eAa;Aa++)Cb=oa[Aa],Ta[Sa]=Cb.x,Ta[Sa+1]=Cb.y,Ta[Sa+2]=Cb.z,Sa+=3;else for(Aa=0;3>Aa;Aa++)Ta[Sa]=ta.x,Ta[Sa+1]=ta.y,Ta[Sa+2]=ta.z,Sa+=3;l.bindBuffer(l.ARRAY_BUFFER,I.__webglNormalBuffer);l.bufferData(l.ARRAY_BUFFER, -Ta,S)}if(Kc&&sa){P=0;for(Z=Q.length;PAa;Aa++)Oa=za[Aa],sb[qb]=Oa.x,sb[qb+1]=Oa.y,qb+=2;0Aa;Aa++)Pb=Ca[Aa],hb[rb]=Pb.x,hb[rb+1]=Pb.y,rb+=2;0Aa;Aa++)Cb=oa[Aa],Ta[Sa]=Cb.x,Ta[Sa+1]=Cb.y,Ta[Sa+2]=Cb.z,Sa+=3;else for(Aa=0;3>Aa;Aa++)Ta[Sa]=ta.x,Ta[Sa+1]=ta.y,Ta[Sa+2]=ta.z,Sa+=3;l.bindBuffer(l.ARRAY_BUFFER,J.__webglNormalBuffer);l.bufferData(l.ARRAY_BUFFER, +Ta,S)}if(Kc&&sa){P=0;for(Z=Q.length;PAa;Aa++)Oa=za[Aa],sb[qb]=Oa.x,sb[qb+1]=Oa.y,qb+=2;0Aa;Aa++)Pb=Ca[Aa],hb[rb]=Pb.x,hb[rb+1]=Pb.y,rb+=2;0h&&(f[v].counter+=1,k=f[v].hash+ +e.sortParticles||w){var Lb=l.DYNAMIC_DRAW,Xa,tb,ub,X,vb,Tb,zc=r.vertices,pb=zc.length,Mb=r.colors,Nb=Mb.length,$b=r.__vertexArray,ac=r.__colorArray,Gb=r.__sortArray,Wb=r.verticesNeedUpdate,Xb=r.colorsNeedUpdate,Hb=r.__webglCustomAttributesList,lb,hc,ca,mb,ia,W;if(e.sortParticles){Gc.copy(Ac);Gc.multiply(e.matrixWorld);for(Xa=0;Xah&&(f[v].counter+=1,k=f[v].hash+ "_"+f[v].counter,k in r||(p={id:rc++,faces3:[],materialIndex:v,vertices:0,numMorphTargets:m,numMorphNormals:n},r[k]=p,q.push(p)));r[k].faces3.push(t);r[k].vertices+=3}a[g]=q;d.groupsNeedUpdate=!1}a=xb[d.id];g=0;for(e=a.length;gEa;Ea++)kb[Ea]=!K.autoScaleCubemaps||Nb||Sb?Sb?sa.image[Ea].image:sa.image[Ea]:S(sa.image[Ea],bd);var la=kb[0],Yb=THREE.Math.isPowerOfTwo(la.width)&&THREE.Math.isPowerOfTwo(la.height),ab=L(sa.format),Fb=L(sa.type);G(l.TEXTURE_CUBE_MAP,sa,Yb);for(Ea=0;6>Ea;Ea++)if(Nb)for(var ib,Zb=kb[Ea].mipmaps, +new Float32Array(16*U.length));Q=0;for(wa=U.length;QEa;Ea++)kb[Ea]=!H.autoScaleCubemaps||Nb||Sb?Sb?sa.image[Ea].image:sa.image[Ea]:S(sa.image[Ea],bd);var la=kb[0],Yb=THREE.Math.isPowerOfTwo(la.width)&&THREE.Math.isPowerOfTwo(la.height),ab=L(sa.format),Fb=L(sa.type);G(l.TEXTURE_CUBE_MAP,sa,Yb);for(Ea=0;6>Ea;Ea++)if(Nb)for(var ib,Zb=kb[Ea].mipmaps, ga=0,Wb=Zb.length;ga=Oc&& console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+Oc);cc+=1;return a}function x(a,b){a._modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getNormalMatrix(a._modelViewMatrix)}function C(a,b,c,d){a[b]=c.r*c.r*d;a[b+1]=c.g*c.g*d;a[b+2]=c.b*c.b*d}function D(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function A(a){a!==Pc&&(l.lineWidth(a),Pc=a)}function B(a,b,c){Qc!==a&&(a?l.enable(l.POLYGON_OFFSET_FILL):l.disable(l.POLYGON_OFFSET_FILL), Qc=a);!a||Rc===b&&Sc===c||(l.polygonOffset(b,c),Rc=b,Sc=c)}function G(a,b,c){c?(l.texParameteri(a,l.TEXTURE_WRAP_S,L(b.wrapS)),l.texParameteri(a,l.TEXTURE_WRAP_T,L(b.wrapT)),l.texParameteri(a,l.TEXTURE_MAG_FILTER,L(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,L(b.minFilter))):(l.texParameteri(a,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(a,l.TEXTURE_WRAP_T,l.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 is set to THREE.ClampToEdgeWrapping. ( "+ -b.sourceFile+" )"),l.texParameteri(a,l.TEXTURE_MAG_FILTER,V(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,V(b.minFilter)),b.minFilter!==THREE.NearestFilter&&b.minFilter!==THREE.LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter is set to THREE.LinearFilter or THREE.NearestFilter. ( "+b.sourceFile+" )"));(c=oa.get("EXT_texture_filter_anisotropic"))&&b.type!==THREE.FloatType&&(1b||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.log("THREE.WebGLRenderer:",a,"is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height+".");return d}return a}function J(a,b){l.bindRenderbuffer(l.RENDERBUFFER, -a);b.depthBuffer&&!b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_COMPONENT16,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_STENCIL,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,a)):l.renderbufferStorage(l.RENDERBUFFER,l.RGBA4,b.width,b.height)}function H(a){a instanceof THREE.WebGLRenderTargetCube?(l.bindTexture(l.TEXTURE_CUBE_MAP, +b.sourceFile+" )"),l.texParameteri(a,l.TEXTURE_MAG_FILTER,V(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,V(b.minFilter)),b.minFilter!==THREE.NearestFilter&&b.minFilter!==THREE.LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter is set to THREE.LinearFilter or THREE.NearestFilter. ( "+b.sourceFile+" )"));(c=ha.get("EXT_texture_filter_anisotropic"))&&b.type!==THREE.FloatType&&(1b||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.log("THREE.WebGLRenderer:",a,"is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height+".");return d}return a}function K(a,b){l.bindRenderbuffer(l.RENDERBUFFER, +a);b.depthBuffer&&!b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_COMPONENT16,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_STENCIL,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,a)):l.renderbufferStorage(l.RENDERBUFFER,l.RGBA4,b.width,b.height)}function I(a){a instanceof THREE.WebGLRenderTargetCube?(l.bindTexture(l.TEXTURE_CUBE_MAP, a.__webglTexture),l.generateMipmap(l.TEXTURE_CUBE_MAP),l.bindTexture(l.TEXTURE_CUBE_MAP,null)):(l.bindTexture(l.TEXTURE_2D,a.__webglTexture),l.generateMipmap(l.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null))}function V(a){return a===THREE.NearestFilter||a===THREE.NearestMipMapNearestFilter||a===THREE.NearestMipMapLinearFilter?l.NEAREST:l.LINEAR}function L(a){var b;if(a===THREE.RepeatWrapping)return l.REPEAT;if(a===THREE.ClampToEdgeWrapping)return l.CLAMP_TO_EDGE;if(a===THREE.MirroredRepeatWrapping)return l.MIRRORED_REPEAT; if(a===THREE.NearestFilter)return l.NEAREST;if(a===THREE.NearestMipMapNearestFilter)return l.NEAREST_MIPMAP_NEAREST;if(a===THREE.NearestMipMapLinearFilter)return l.NEAREST_MIPMAP_LINEAR;if(a===THREE.LinearFilter)return l.LINEAR;if(a===THREE.LinearMipMapNearestFilter)return l.LINEAR_MIPMAP_NEAREST;if(a===THREE.LinearMipMapLinearFilter)return l.LINEAR_MIPMAP_LINEAR;if(a===THREE.UnsignedByteType)return l.UNSIGNED_BYTE;if(a===THREE.UnsignedShort4444Type)return l.UNSIGNED_SHORT_4_4_4_4;if(a===THREE.UnsignedShort5551Type)return l.UNSIGNED_SHORT_5_5_5_1; if(a===THREE.UnsignedShort565Type)return l.UNSIGNED_SHORT_5_6_5;if(a===THREE.ByteType)return l.BYTE;if(a===THREE.ShortType)return l.SHORT;if(a===THREE.UnsignedShortType)return l.UNSIGNED_SHORT;if(a===THREE.IntType)return l.INT;if(a===THREE.UnsignedIntType)return l.UNSIGNED_INT;if(a===THREE.FloatType)return l.FLOAT;if(a===THREE.AlphaFormat)return l.ALPHA;if(a===THREE.RGBFormat)return l.RGB;if(a===THREE.RGBAFormat)return l.RGBA;if(a===THREE.LuminanceFormat)return l.LUMINANCE;if(a===THREE.LuminanceAlphaFormat)return l.LUMINANCE_ALPHA; if(a===THREE.AddEquation)return l.FUNC_ADD;if(a===THREE.SubtractEquation)return l.FUNC_SUBTRACT;if(a===THREE.ReverseSubtractEquation)return l.FUNC_REVERSE_SUBTRACT;if(a===THREE.ZeroFactor)return l.ZERO;if(a===THREE.OneFactor)return l.ONE;if(a===THREE.SrcColorFactor)return l.SRC_COLOR;if(a===THREE.OneMinusSrcColorFactor)return l.ONE_MINUS_SRC_COLOR;if(a===THREE.SrcAlphaFactor)return l.SRC_ALPHA;if(a===THREE.OneMinusSrcAlphaFactor)return l.ONE_MINUS_SRC_ALPHA;if(a===THREE.DstAlphaFactor)return l.DST_ALPHA; -if(a===THREE.OneMinusDstAlphaFactor)return l.ONE_MINUS_DST_ALPHA;if(a===THREE.DstColorFactor)return l.DST_COLOR;if(a===THREE.OneMinusDstColorFactor)return l.ONE_MINUS_DST_COLOR;if(a===THREE.SrcAlphaSaturateFactor)return l.SRC_ALPHA_SATURATE;b=oa.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=oa.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=oa.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 I=void 0!==a.canvas?a.canvas:document.createElement("canvas"),R=void 0!==a.context?a.context:null,Y=void 0!==a.precision?a.precision:"highp",T=void 0!==a.alpha?a.alpha:!1,ya=void 0!==a.depth?a.depth:!0,ia=void 0!==a.stencil?a.stencil:!0,Ca=void 0!==a.antialias?a.antialias:!1,O=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,Ga=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer: -!1,xa=void 0!==a.logarithmicDepthBuffer?a.logarithmicDepthBuffer:!1,za=new THREE.Color(0),Z=0,db=[],eb={},ob=[],bb=[],Ib=[],yb=[],Ra=[];this.domElement=I;this.context=null;this.devicePixelRatio=void 0!==a.devicePixelRatio?a.devicePixelRatio:void 0!==self.devicePixelRatio?self.devicePixelRatio:1;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=this.gammaOutput=this.gammaInput=!1;this.shadowMapType=THREE.PCFShadowMap;this.shadowMapCullFace= -THREE.CullFaceFront;this.shadowMapCascade=this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var K=this,cb=[],tc=null,Tc=null,Jb=-1,Oa=-1,dc=null,cc=0,Kb=-1,Lb=-1,pb=-1,Mb=-1,Nb=-1,Wb=-1,Xb=-1,nb=-1,Qc=null,Rc=null,Sc=null,Pc=null,Ob=0,jc=0,kc=I.width,lc=I.height,Uc=0,Vc=0,wb=new Uint8Array(16),jb=new Uint8Array(16),Ec=new THREE.Frustum,Ac=new THREE.Matrix4, -Gc=new THREE.Matrix4,Na=new THREE.Vector3,ta=new THREE.Vector3,ec=!0,Mc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],anglesCos:[],exponents:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}},l;try{var Wc={alpha:T,depth:ya,stencil:ia,antialias:Ca,premultipliedAlpha:O,preserveDrawingBuffer:Ga};l=R||I.getContext("webgl",Wc)||I.getContext("experimental-webgl", -Wc);if(null===l){if(null!==I.getContext("webgl"))throw"Error creating WebGL context with your selected attributes.";throw"Error creating WebGL context.";}I.addEventListener("webglcontextlost",function(a){a.preventDefault();Xc();Yc();eb={}},!1)}catch(cd){console.error(cd)}void 0===l.getShaderPrecisionFormat&&(l.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}});var oa=new THREE.WebGLExtensions(l);oa.get("OES_texture_float");oa.get("OES_texture_float_linear");oa.get("OES_standard_derivatives"); -xa&&oa.get("EXT_frag_depth");var Yc=function(){l.clearColor(0,0,0,1);l.clearDepth(1);l.clearStencil(0);l.enable(l.DEPTH_TEST);l.depthFunc(l.LEQUAL);l.frontFace(l.CCW);l.cullFace(l.BACK);l.enable(l.CULL_FACE);l.enable(l.BLEND);l.blendEquation(l.FUNC_ADD);l.blendFunc(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA);l.viewport(Ob,jc,kc,lc);l.clearColor(za.r,za.g,za.b,Z)},Xc=function(){dc=tc=null;Jb=Oa=Lb=Kb=nb=Xb=pb=-1;ec=!0};Yc();this.context=l;var Oc=l.getParameter(l.MAX_TEXTURE_IMAGE_UNITS),dd=l.getParameter(l.MAX_VERTEX_TEXTURE_IMAGE_UNITS), -ed=l.getParameter(l.MAX_TEXTURE_SIZE),bd=l.getParameter(l.MAX_CUBE_MAP_TEXTURE_SIZE),sc=0b;b++)l.deleteFramebuffer(a.__webglFramebuffer[b]),l.deleteRenderbuffer(a.__webglRenderbuffer[b]); -else l.deleteFramebuffer(a.__webglFramebuffer),l.deleteRenderbuffer(a.__webglRenderbuffer);delete a.__webglFramebuffer;delete a.__webglRenderbuffer}K.info.memory.textures--},Dc=function(a){a=a.target;a.removeEventListener("dispose",Dc);Cc(a)},$c=function(a){for(var b="__webglVertexBuffer __webglNormalBuffer __webglTangentBuffer __webglColorBuffer __webglUVBuffer __webglUV2Buffer __webglSkinIndicesBuffer __webglSkinWeightsBuffer __webglFaceBuffer __webglLineBuffer __webglLineDistanceBuffer".split(" "), -c=0,d=b.length;cd.numSupportedMorphTargets?(n.sort(p),n.length=d.numSupportedMorphTargets):n.length>d.numSupportedMorphNormals?n.sort(p):0===n.length&&n.push([0, -0]);for(m=0;mb;b++)l.deleteFramebuffer(a.__webglFramebuffer[b]),l.deleteRenderbuffer(a.__webglRenderbuffer[b]);else l.deleteFramebuffer(a.__webglFramebuffer),l.deleteRenderbuffer(a.__webglRenderbuffer); +delete a.__webglFramebuffer;delete a.__webglRenderbuffer}H.info.memory.textures--},Dc=function(a){a=a.target;a.removeEventListener("dispose",Dc);Cc(a)},$c=function(a){for(var b="__webglVertexBuffer __webglNormalBuffer __webglTangentBuffer __webglColorBuffer __webglUVBuffer __webglUV2Buffer __webglSkinIndicesBuffer __webglSkinWeightsBuffer __webglFaceBuffer __webglLineBuffer __webglLineDistanceBuffer".split(" "),c=0,d=b.length;cd.numSupportedMorphTargets?(n.sort(p),n.length=d.numSupportedMorphTargets):n.length>d.numSupportedMorphNormals?n.sort(p):0===n.length&&n.push([0,0]);for(m=0;mf;f++){a.__webglFramebuffer[f]=l.createFramebuffer();a.__webglRenderbuffer[f]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=l.TEXTURE_CUBE_MAP_POSITIVE_X+f;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[f]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,h,g.__webglTexture,0);J(a.__webglRenderbuffer[f],a)}c&&l.generateMipmap(l.TEXTURE_CUBE_MAP)}else a.__webglFramebuffer= +g,d,b.width,b.height,0,b.data):console.warn("Attempt to load unsupported compressed texture format"):l.texImage2D(l.TEXTURE_2D,g,d,b.width,b.height,0,d,e,b.data);else if(0f;f++){a.__webglFramebuffer[f]=l.createFramebuffer();a.__webglRenderbuffer[f]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=l.TEXTURE_CUBE_MAP_POSITIVE_X+f;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[f]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,h,g.__webglTexture,0);K(a.__webglRenderbuffer[f],a)}c&&l.generateMipmap(l.TEXTURE_CUBE_MAP)}else a.__webglFramebuffer= l.createFramebuffer(),a.__webglRenderbuffer=a.shareDepthFrom?a.shareDepthFrom.__webglRenderbuffer:l.createRenderbuffer(),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),G(l.TEXTURE_2D,a,c),l.texImage2D(l.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=l.TEXTURE_2D,l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,d,a.__webglTexture,0),a.shareDepthFrom?a.depthBuffer&&!a.stencilBuffer?l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT, -l.RENDERBUFFER,a.__webglRenderbuffer):a.depthBuffer&&a.stencilBuffer&&l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,a.__webglRenderbuffer):J(a.__webglRenderbuffer,a),c&&l.generateMipmap(l.TEXTURE_2D);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null);l.bindRenderbuffer(l.RENDERBUFFER,null);l.bindFramebuffer(l.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=kc,a=lc, +l.RENDERBUFFER,a.__webglRenderbuffer):a.depthBuffer&&a.stencilBuffer&&l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,a.__webglRenderbuffer):K(a.__webglRenderbuffer,a),c&&l.generateMipmap(l.TEXTURE_2D);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null);l.bindRenderbuffer(l.RENDERBUFFER,null);l.bindFramebuffer(l.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=kc,a=lc, d=Ob,e=jc);b!==Tc&&(l.bindFramebuffer(l.FRAMEBUFFER,b),l.viewport(d,e,c,a),Tc=b);Uc=c;Vc=a};this.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")};this.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")};this.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")};this.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}}; THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.anisotropy=void 0!==c.anisotropy?c.anisotropy:1;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format: THREE.RGBAFormat;this.type=void 0!==c.type?c.type:THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!0;this.shareDepthFrom=null}; @@ -588,35 +589,35 @@ console.error("gl.VALIDATE_STATUS",f.getProgramParameter(g,f.VALIDATE_STATUS)),c q.push("boneGlobalMatrices");e.logarithmicDepthBuffer&&q.push("logDepthBufFC");for(var u in h)q.push(u);h=q;u={};q=0;for(b=h.length;qV;V++)G[V]=new THREE.Vector3,A[V]=new THREE.Vector3;G=B.shadowCascadeNearZ[H];B=B.shadowCascadeFarZ[H];A[0].set(-1,-1,G);A[1].set(1,-1,G);A[2].set(-1,1,G);A[3].set(1,1,G);A[4].set(-1,-1,B);A[5].set(1,-1,B);A[6].set(-1,1,B);A[7].set(1,1,B);J.originalCamera=v;A=new THREE.Gyroscope;A.position.copy(x.shadowCascadeOffset);A.add(J);A.add(J.target);v.add(A);x.shadowCascadeArray[D]=J;console.log("Created virtualLight",J)}H= -x;G=D;B=H.shadowCascadeArray[G];B.position.copy(H.position);B.target.position.copy(H.target.position);B.lookAt(B.target);B.shadowCameraVisible=H.shadowCameraVisible;B.shadowDarkness=H.shadowDarkness;B.shadowBias=H.shadowCascadeBias[G];A=H.shadowCascadeNearZ[G];H=H.shadowCascadeFarZ[G];B=B.pointsFrustum;B[0].z=A;B[1].z=A;B[2].z=A;B[3].z=A;B[4].z=H;B[5].z=H;B[6].z=H;B[7].z=H;S[C]=J;C++}else S[C]=x,C++;u=0;for(M=S.length;uV;V++)G[V]=new THREE.Vector3,A[V]=new THREE.Vector3;G=B.shadowCascadeNearZ[I];B=B.shadowCascadeFarZ[I];A[0].set(-1,-1,G);A[1].set(1,-1,G);A[2].set(-1,1,G);A[3].set(1,1,G);A[4].set(-1,-1,B);A[5].set(1,-1,B);A[6].set(-1,1,B);A[7].set(1,1,B);K.originalCamera=v;A=new THREE.Gyroscope;A.position.copy(x.shadowCascadeOffset);A.add(K);A.add(K.target);v.add(A);x.shadowCascadeArray[D]=K;console.log("Created virtualLight",K)}I= +x;G=D;B=I.shadowCascadeArray[G];B.position.copy(I.position);B.target.position.copy(I.target.position);B.lookAt(B.target);B.shadowCameraVisible=I.shadowCameraVisible;B.shadowDarkness=I.shadowDarkness;B.shadowBias=I.shadowCascadeBias[G];A=I.shadowCascadeNearZ[G];I=I.shadowCascadeFarZ[G];B=B.pointsFrustum;B[0].z=A;B[1].z=A;B[2].z=A;B[3].z=A;B[4].z=I;B[5].z=I;B[6].z=I;B[7].z=I;S[C]=K;C++}else S[C]=x,C++;u=0;for(M=S.length;uH;H++)G=B[H],G.copy(A[H]),G.unproject(D),G.applyMatrix4(C.matrixWorldInverse),G.xr.x&&(r.x=G.x),G.yr.y&&(r.y=G.y),G.zr.z&&(r.z=G.z);C.left=m.x;C.right=r.x;C.top=r.y;C.bottom=m.y;C.updateProjectionMatrix()}C=x.shadowMap;A=x.shadowMatrix;D=x.shadowCamera;D.position.setFromMatrixPosition(x.matrixWorld);t.setFromMatrixPosition(x.target.matrixWorld);D.lookAt(t);D.updateMatrixWorld();D.matrixWorldInverse.getInverse(D.matrixWorld);x.cameraHelper&& -(x.cameraHelper.visible=x.shadowCameraVisible);x.shadowCameraVisible&&x.cameraHelper.update();A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);A.multiply(D.projectionMatrix);A.multiply(D.matrixWorldInverse);q.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse);p.setFromMatrix(q);a.setRenderTarget(C);a.clear();s.length=0;e(c,c,D);x=0;for(C=s.length;xI;I++)G=B[I],G.copy(A[I]),G.unproject(D),G.applyMatrix4(C.matrixWorldInverse),G.xr.x&&(r.x=G.x),G.yr.y&&(r.y=G.y),G.zr.z&&(r.z=G.z);C.left=m.x;C.right=r.x;C.top=r.y;C.bottom=m.y;C.updateProjectionMatrix()}C=x.shadowMap;A=x.shadowMatrix;D=x.shadowCamera;D.position.setFromMatrixPosition(x.matrixWorld);t.setFromMatrixPosition(x.target.matrixWorld);D.lookAt(t);D.updateMatrixWorld();D.matrixWorldInverse.getInverse(D.matrixWorld);x.cameraHelper&& +(x.cameraHelper.visible=x.shadowCameraVisible);x.shadowCameraVisible&&x.cameraHelper.update();A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);A.multiply(D.projectionMatrix);A.multiply(D.matrixWorldInverse);q.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse);p.setFromMatrix(q);a.setRenderTarget(C);a.clear();s.length=0;e(c,c,D);x=0;for(C=s.length;x 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;\nfloat fogFactor = 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")); -w.compileShader(V);w.compileShader(L);w.attachShader(H,V);w.attachShader(H,L);w.linkProgram(H);C=H;v=w.getAttribLocation(C,"position");y=w.getAttribLocation(C,"uv");c=w.getUniformLocation(C,"uvOffset");d=w.getUniformLocation(C,"uvScale");e=w.getUniformLocation(C,"rotation");f=w.getUniformLocation(C,"scale");g=w.getUniformLocation(C,"color");h=w.getUniformLocation(C,"map");k=w.getUniformLocation(C,"opacity");n=w.getUniformLocation(C,"modelViewMatrix");p=w.getUniformLocation(C,"projectionMatrix");q= -w.getUniformLocation(C,"fogType");m=w.getUniformLocation(C,"fogDensity");r=w.getUniformLocation(C,"fogNear");t=w.getUniformLocation(C,"fogFar");s=w.getUniformLocation(C,"fogColor");u=w.getUniformLocation(C,"alphaTest");H=document.createElement("canvas");H.width=8;H.height=8;V=H.getContext("2d");V.fillStyle="white";V.fillRect(0,0,8,8);D=new THREE.Texture(H);D.needsUpdate=!0}w.useProgram(C);w.enableVertexAttribArray(v);w.enableVertexAttribArray(y);w.disable(w.CULL_FACE);w.enable(w.BLEND);w.bindBuffer(w.ARRAY_BUFFER, -M);w.vertexAttribPointer(v,2,w.FLOAT,!1,16,0);w.vertexAttribPointer(y,2,w.FLOAT,!1,16,8);w.bindBuffer(w.ELEMENT_ARRAY_BUFFER,x);w.uniformMatrix4fv(p,!1,J.projectionMatrix.elements);w.activeTexture(w.TEXTURE0);w.uniform1i(h,0);V=H=0;(L=S.fog)?(w.uniform3f(s,L.color.r,L.color.g,L.color.b),L instanceof THREE.Fog?(w.uniform1f(r,L.near),w.uniform1f(t,L.far),w.uniform1i(q,1),V=H=1):L instanceof THREE.FogExp2&&(w.uniform1f(m,L.density),w.uniform1i(q,2),V=H=2)):(w.uniform1i(q,0),V=H=0);for(var L=0,I=b.length;L< -I;L++){var R=b[L];R._modelViewMatrix.multiplyMatrices(J.matrixWorldInverse,R.matrixWorld);R.z=null===R.renderDepth?-R._modelViewMatrix.elements[14]:R.renderDepth}b.sort(E);for(var Y=[],L=0,I=b.length;Le)return null;var f=[],g=[],h=[],k,n,p;if(0=q--){console.log("Warning, unable to triangulate polygon!");break}k=n;e<=k&&(k=0);n=k+1;e<=n&&(n=0);p=n+1;e<=p&&(p=0);var m;a:{var r=m=void 0,t=void 0,s=void 0,u=void 0,v=void 0,y=void 0,E=void 0,w=void 0, -r=a[g[k]].x,t=a[g[k]].y,s=a[g[n]].x,u=a[g[n]].y,v=a[g[p]].x,y=a[g[p]].y;if(1E-10>(s-r)*(y-t)-(u-t)*(v-r))m=!1;else{var M=void 0,x=void 0,C=void 0,D=void 0,A=void 0,B=void 0,G=void 0,S=void 0,J=void 0,H=void 0,J=S=G=w=E=void 0,M=v-s,x=y-u,C=r-v,D=t-y,A=s-r,B=u-t;for(m=0;m(s-r)*(y-t)-(u-t)*(v-r))m=!1;else{var M=void 0,x=void 0,C=void 0,D=void 0,A=void 0,B=void 0,G=void 0,S=void 0,K=void 0,I=void 0,K=S=G=w=E=void 0,M=v-s,x=y-u,C=r-v,D=t-y,A=s-r,B=u-t;for(m=0;mD||D>C)return[];k=n*p-k*q;if(0>k||k>C)return[]}else{if(0d?[]:k==d?f?[]:[g]:a<=d?[g,h]: [g,n]}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return 1E-10f&&(f=d);var g=a+1;g>d&&(g=0);d=e(h[a],h[f],h[g],k[b]);if(!d)return!1; -d=k.length-1;f=b-1;0>f&&(f=d);g=b+1;g>d&&(g=0);return(d=e(k[b],k[f],k[g],h[a]))?!0:!1}function f(a,b){var c,e;for(c=0;cH){console.log("Infinite Loop! Holes left:"+ -n.length+", Probably Hole outside Shape!");break}for(q=B;qh;h++)n=k[h].x+":"+k[h].y, +d=k.length-1;f=b-1;0>f&&(f=d);g=b+1;g>d&&(g=0);return(d=e(k[b],k[f],k[g],h[a]))?!0:!1}function f(a,b){var c,e;for(c=0;cI){console.log("Infinite Loop! Holes left:"+ +n.length+", Probably Hole outside Shape!");break}for(q=B;qh;h++)n=k[h].x+":"+k[h].y, n=p[n],void 0!==n&&(k[h]=n);return q.concat()},isClockWise:function(a){return 0>THREE.FontUtils.Triangulate.area(a)},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a, b)+this.b3p1(a,c)+this.b3p2(a,d)+this.b3p3(a,e)}};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().sub(this.v1);b.multiplyScalar(a).add(this.v1);return b};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(a){return this.v2.clone().sub(this.v1).normalize()}; THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b=new THREE.Vector2;b.x=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);b.y=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return b}; @@ -708,9 +709,9 @@ THREE.KeyFrameAnimation.prototype.play=function(a){this.currentTime=void 0!==a?a this.startTime),this.endTime=Math.max(c[c.length-1].time,this.endTime));this.update(0)}this.isPaused=!1;THREE.AnimationHandler.play(this)};THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.stop(this);for(var a=0;aa&&(this.currentTime%=a);this.currentTime=Math.min(this.currentTime,a);a=0;for(var b=this.hierarchy.length;af.index;)f=g,g=e[f.index+1];d.prevKey= f;d.nextKey=g}g.time>=this.currentTime?f.interpolate(g,this.currentTime):f.interpolate(g,g.time);this.data.hierarchy[a].node.updateMatrix();c.matrixWorldNeedsUpdate=!0}}}};THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c%=b.length;cthis.duration&&(this.currentTime%=this.duration);this.currentTime=Math.min(this.currentTime,this.duration);c=this.duration/this.frames;var d=Math.floor(this.currentTime/c);d!=b&&(this.mesh.morphTargetInfluences[a]=0,this.mesh.morphTargetInfluences[b]=1,this.mesh.morphTargetInfluences[d]= -0,a=b,b=d);this.mesh.morphTargetInfluences[d]=this.currentTime%c/c;this.mesh.morphTargetInfluences[a]=1-this.mesh.morphTargetInfluences[d]}}}()}; +THREE.KeyFrameAnimation.prototype.getPrevKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=0<=c?c:c+b.length;0<=c;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]};THREE.MorphAnimation=function(a){this.mesh=a;this.frames=a.morphTargetInfluences.length;this.currentTime=0;this.duration=1E3;this.loop=!0;this.currentFrame=this.lastFrame=0;this.isPlaying=!1}; +THREE.MorphAnimation.prototype={constructor:THREE.MorphAnimation,play:function(){this.isPlaying=!0},pause:function(){this.isPlaying=!1},update:function(a){if(!1!==this.isPlaying){this.currentTime+=a;!0===this.loop&&this.currentTime>this.duration&&(this.currentTime%=this.duration);this.currentTime=Math.min(this.currentTime,this.duration);a=this.duration/this.frames;var b=Math.floor(this.currentTime/a);b!=this.currentFrame&&(this.mesh.morphTargetInfluences[this.lastFrame]=0,this.mesh.morphTargetInfluences[this.currentFrame]= +1,this.mesh.morphTargetInfluences[b]=0,this.lastFrame=this.currentFrame,this.currentFrame=b);this.mesh.morphTargetInfluences[b]=this.currentTime%a/a;this.mesh.morphTargetInfluences[this.lastFrame]=1-this.mesh.morphTargetInfluences[b]}}}; THREE.BoxGeometry=function(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,s){var u,v=h.widthSegments,y=h.heightSegments,E=e/2,w=f/2,M=h.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)u="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)u="y",y=h.depthSegments;else if("z"===a&&"y"===b||"y"===a&&"z"===b)u="x",v=h.depthSegments;var x=v+1,C=y+1,D=e/v,A=f/y,B=new THREE.Vector3;B[u]=0=d)return new THREE.Vector2(c,a);d=Math.sqrt(d/2)}else a=!1,1E-10d?-1E-10>f&&(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(O=a.length;0<=--O;){c=O;d=O-1;0>d&&(d=a.length-1);for(var e=0,f=r+2*p,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===a instanceof Array&&(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 this.duration ) { + if ( this.loop === true && this.currentTime > this.duration ) { - this.currentTime %= this.duration; + this.currentTime %= this.duration; - } + } - this.currentTime = Math.min( this.currentTime, this.duration ); + this.currentTime = Math.min( this.currentTime, this.duration ); - var interpolation = this.duration / this.frames; - var frame = Math.floor( this.currentTime / interpolation ); + var interpolation = this.duration / this.frames; + var frame = Math.floor( this.currentTime / interpolation ); - if ( frame != this.currentFrame ) { + if ( frame != this.currentFrame ) { - this.mesh.morphTargetInfluences[ this.lastFrame ] = 0; - this.mesh.morphTargetInfluences[ this.currentFrame ] = 1; - this.mesh.morphTargetInfluences[ frame ] = 0; + this.mesh.morphTargetInfluences[ this.lastFrame ] = 0; + this.mesh.morphTargetInfluences[ this.currentFrame ] = 1; + this.mesh.morphTargetInfluences[ frame ] = 0; - this.lastFrame = this.currentFrame; - this.currentFrame = frame; + this.lastFrame = this.currentFrame; + this.currentFrame = frame; - } + } - this.mesh.morphTargetInfluences[ frame ] = ( this.currentTime % interpolation ) / interpolation; - this.mesh.morphTargetInfluences[ this.lastFrame ] = 1 - this.mesh.morphTargetInfluences[ frame ]; + this.mesh.morphTargetInfluences[ frame ] = ( this.currentTime % interpolation ) / interpolation; + this.mesh.morphTargetInfluences[ this.lastFrame ] = 1 - this.mesh.morphTargetInfluences[ frame ]; - } + } }; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 94a80e3ca1..6b0c8a9666 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -2825,7 +2825,7 @@ THREE.WebGLRenderer = function ( parameters ) { // render indexed points - _gl.drawElements( mode, offsets[ i ].count, type, offsets[ i ].start * size ); + _gl.drawElements( mode, offsets[ i ].count, type, offsets[ i ].start * size ); _this.info.render.calls ++; _this.info.render.points += offsets[ i ].count; -- GitLab