From c7aa2ab3d1ab6c919fd9590adbad7de30a4209c9 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 26 Feb 2011 10:31:18 +0000 Subject: [PATCH] =?UTF-8?q?Object3D::localMatrix=20=E2=9F=B6=20Object3D::m?= =?UTF-8?q?atrix=20Object3D::globalMatrix=20=E2=9F=B6=20Object3D::matrixWo?= =?UTF-8?q?rld?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added hierarchy examples. --- build/Three.js | 80 ++--- build/custom/ThreeCanvas.js | 44 +-- build/custom/ThreeDOM.js | 26 +- build/custom/ThreeExtras.js | 2 +- build/custom/ThreeSVG.js | 26 +- build/custom/ThreeWebGL.js | 36 +-- examples/canvas_geometry_hierarchy.html | 202 +++++++++++++ examples/canvas_sandbox.html | 2 +- examples/webgl_geometry_hierarchy.html | 203 +++++++++++++ examples/webgl_geometry_hierarchy2.html | 281 ++++++++++++++++++ examples/webgl_performance.html | 217 ++++++++++++++ examples/webgl_ribbons.html | 28 +- ...derer2_sandbox.html => webgl_sandbox.html} | 47 +-- src/cameras/Camera.js | 56 ++-- src/core/Object3D.js | 181 +++++------ src/core/Ray.js | 2 +- src/extras/GeometryUtils.js | 2 +- src/objects/Bone.js | 66 ++-- src/objects/LOD.js | 68 +++-- src/objects/SkinnedMesh.js | 76 +++-- src/objects/Sound3D.js | 12 +- src/renderers/CanvasRenderer.js | 2 +- src/renderers/Projector.js | 10 +- src/renderers/SoundRenderer.js | 8 +- src/renderers/WebGLRenderer.js | 16 +- src/renderers/WebGLRenderer2.js | 8 +- 26 files changed, 1332 insertions(+), 369 deletions(-) create mode 100644 examples/canvas_geometry_hierarchy.html create mode 100644 examples/webgl_geometry_hierarchy.html create mode 100644 examples/webgl_geometry_hierarchy2.html create mode 100644 examples/webgl_performance.html rename examples/{misc_webglrenderer2_sandbox.html => webgl_sandbox.html} (89%) diff --git a/build/Three.js b/build/Three.js index 7d345c70..991c0b4a 100755 --- a/build/Three.js +++ b/build/Three.js @@ -12,7 +12,7 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLengt THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a0&&G>0&&e+G<1}var c,d,f,g,h,k,j,m,n,w, -u,p=a.geometry,x=p.vertices,A=[];c=0;for(d=p.faces.length;cj?d:j;f=f>m?f:m}a()}; this.add3Points=function(j,m,n,w,u,p){if(k){k=!1;b=jn?j>u?j:u:n>u?n:u;f=m>w?m>p?m:p:w>p?w:p}else{b=jn?j>u?j>d?j:d:u>d?u:d:n>u?n>d?n:d:u>d?u:d;f=m>w?m>p?m>f?m:f:p>f?p:f:w>p?w>f?w:f:p>f?p:f}a()};this.addRectangle=function(j){if(k){k=!1;b=j.getLeft();c=j.getTop();d=j.getRight();f=j.getBottom()}else{b=bj.getRight()? @@ -41,11 +41,11 @@ b.n24=f*m*n-g*j*n+g*h*u-c*m*u-f*h*p+c*j*p;b.n31=k*p*x-m*w*x+m*n*A-h*p*A-k*n*v+h* THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*n;c[8]=a*w;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)}; THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-d;m=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((b+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((c+d)/j);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+f)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; -THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale= -1;this.visible=!0}; -THREE.Object3D.prototype={update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}f=Math.sin((1- @@ -77,9 +77,9 @@ THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hie THREE.Camera=function(a,b,c,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.screenCenterY=this.screenCenterX=0;this.target=f||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(g,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);if(h)this.tmpVec.y= 0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(g,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);if(h)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype; THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)}; -THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.globalMatrix, -this.inverseMatrix)}}for(a=0;a-this.near)return!1;if(h+g<-this.far)return!1;h-=g;var k=this.projectionMatrix,j=1/(k.n43*h),m=j*this.screenCenterX,n=(f.n11*b+f.n12*c+f.n13*d+f.n14)*k.n11*m;g=k.n11*g*m;if(n+g<-this.screenCenterX)return!1;if(n-g>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*k.n22*j*this.screenCenterY; +THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.inverseMatrix);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld, +this.inverseMatrix)}}for(a=0;a-this.near)return!1;if(h+g<-this.far)return!1;h-=g;var k=this.projectionMatrix,j=1/(k.n43*h),m=j*this.screenCenterX,n=(f.n11*b+f.n12*c+f.n13*d+f.n14)*k.n11*m;g=k.n11*g*m;if(n+g<-this.screenCenterX)return!1;if(n-g>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*k.n22*j*this.screenCenterY; if(b+g<-this.screenCenterY)return!1;if(b-g>this.screenCenterY)return!1;a.screenPosition.set(n,b,h,g);return!0};function bind(a,b){return function(){b.apply(a,arguments)}} THREE.QuakeCamera=function(a){THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movement_speed=1;this.look_speed=0.005;this.nofly=!1;this.look_vertical=!0;this.domElement=document;if(a){if(a.movement_speed!==undefined)this.movement_speed=a.movement_speed;if(a.look_speed!==undefined)this.look_speed=a.look_speed;if(a.nofly!==undefined)this.nofly=a.nofly;if(a.look_vertical!==undefined)this.look_vertical=a.look_vertical;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta= this.phy=this.lon=this.lat=this.mouseY=this.mouseX=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}};this.onMouseMove= @@ -129,11 +129,11 @@ var Uniforms={clone:function(a){var b,c,d,f={};for(b in a){f[b]={};for(c in a[b] THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1; THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype; THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype; -THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.skinMatrix.multiply(a,this.localMatrix):this.skinMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var d,f=this.children.length;if(this.hasNoneBoneChildren){this.globalMatrix.multiply(this.skin.globalMatrix,this.skinMatrix);for(d=0;d=0&&ea>=0&&J>=0&&$>=0)return!0;else if(Z<0&&ea<0||J<0&&$<0)return!1;else{if(Z<0)V=Math.max(V,Z/(Z-ea));else ea<0&&(S=Math.min(S,Z/(Z-ea)));if(J<0)V=Math.max(V,J/(J-$));else $<0&&(S=Math.min(S,J/(J-$)));if(SZ&&aa.z0&&G.z<1){u=x[p]=x[p]||new THREE.RenderableParticle;u.x=G.x/ -G.w;u.y=G.y/G.w;u.z=G.z;u.rotation=ga.rotation.z;u.scale.x=ga.scale.x*Math.abs(u.x-(G.x+P.projectionMatrix.n11)/(G.w+P.projectionMatrix.n14));u.scale.y=ga.scale.y*Math.abs(u.y-(G.y+P.projectionMatrix.n22)/(G.w+P.projectionMatrix.n24));u.materials=ga.materials;S.push(u);p++}}}}V&&S.sort(a);return S};this.unprojectVector=function(O,P){var V=THREE.Matrix4.makeInvert(P.globalMatrix);V.multiplySelf(THREE.Matrix4.makeInvert(P.projectionMatrix));V.multiplyVector3(O);return O}}; +G.w;u.y=G.y/G.w;u.z=G.z;u.rotation=ga.rotation.z;u.scale.x=ga.scale.x*Math.abs(u.x-(G.x+P.projectionMatrix.n11)/(G.w+P.projectionMatrix.n14));u.scale.y=ga.scale.y*Math.abs(u.y-(G.y+P.projectionMatrix.n22)/(G.w+P.projectionMatrix.n24));u.materials=ga.materials;S.push(u);p++}}}}V&&S.sort(a);return S};this.unprojectVector=function(O,P){var V=THREE.Matrix4.makeInvert(P.matrixWorld);V.multiplySelf(THREE.Matrix4.makeInvert(P.projectionMatrix));V.multiplyVector3(O);return O}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;d=k;f=c/2;g=d/2};this.render=function(h,k){var j,m,n,w,u,p,x,A;a=b.projectScene(h,k);j=0;for(m=a.length;j0){U.r+=Da.r*pa;U.g+=Da.g*pa;U.b+=Da.b*pa}}}}function Ha(K,ja,ba){if(ba.opacity!=0){a(ba.opacity);b(ba.blending);var U,W,pa,Da,Ea,Ia;if(ba instanceof THREE.ParticleBasicMaterial){if(ba.map){Da=ba.map.image;Ea=Da.width>>1;Ia=Da.height>>1;W=ja.scale.x*k;pa=ja.scale.y*j;ba=W*Ea;U=pa*Ia;t.set(K.x-ba,K.y-U,K.x+ba,K.y+U);if(B.instersects(t)){m.save();m.translate(K.x,K.y);m.rotate(-ja.rotation);m.scale(W,-pa);m.translate(-Ea,-Ia);m.drawImage(Da,0,0);m.restore()}}}else if(ba instanceof THREE.ParticleCircleMaterial){if(E){C.r=I.r+L.r+z.r;C.g=I.g+L.g+z.g;C.b=I.b+L.b+z.b;S.r=ba.color.r*C.r;S.g=ba.color.g*C.g;S.b=ba.color.b*C.b;S.updateStyleString()}else S.__styleString=ba.color.__styleString;ba=ja.scale.x*k;U=ja.scale.y*j;t.set(K.x-ba,K.y-U,K.x+ba,K.y+U);if(B.instersects(t)){W=S.__styleString;if(A!=W)m.fillStyle=A=W;m.save();m.translate(K.x,K.y);m.rotate(-ja.rotation);m.scale(ba,U);m.beginPath();m.arc(0,0,1,0,D,!0);m.closePath();m.fill();m.restore()}}}}function La(K,ja,ba,U){if(U.opacity!= 0){a(U.opacity);b(U.blending);m.beginPath();m.moveTo(K.positionScreen.x,K.positionScreen.y);m.lineTo(ja.positionScreen.x,ja.positionScreen.y);m.closePath();if(U instanceof THREE.LineBasicMaterial){S.__styleString=U.color.__styleString;K=U.linewidth;if(G!=K)m.lineWidth=G=K;K=S.__styleString;if(x!=K)m.strokeStyle=x=K;m.stroke();t.inflate(U.linewidth*2)}}}function ca(K,ja,ba,U,W,pa){if(W.opacity!=0){a(W.opacity);b(W.blending);M=K.positionScreen.x;e=K.positionScreen.y;da=ja.positionScreen.x;O=ja.positionScreen.y; -P=ba.positionScreen.x;V=ba.positionScreen.y;m.beginPath();m.moveTo(M,e);m.lineTo(da,O);m.lineTo(P,V);m.lineTo(M,e);m.closePath();if(W instanceof THREE.MeshBasicMaterial)if(W.map)W.map.mapping instanceof THREE.UVMapping&&ra(M,e,da,O,P,V,W.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);else if(W.env_map){if(W.env_map.mapping instanceof THREE.SphericalReflectionMapping){K=Ca.globalMatrix;F.copy(U.vertexNormalsWorld[0]);ia=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;ga=-(F.x* +P=ba.positionScreen.x;V=ba.positionScreen.y;m.beginPath();m.moveTo(M,e);m.lineTo(da,O);m.lineTo(P,V);m.lineTo(M,e);m.closePath();if(W instanceof THREE.MeshBasicMaterial)if(W.map)W.map.mapping instanceof THREE.UVMapping&&ra(M,e,da,O,P,V,W.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);else if(W.env_map){if(W.env_map.mapping instanceof THREE.SphericalReflectionMapping){K=Ca.matrixWorld;F.copy(U.vertexNormalsWorld[0]);ia=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;ga=-(F.x* K.n21+F.y*K.n22+F.z*K.n23)*0.5+0.5;F.copy(U.vertexNormalsWorld[1]);ua=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;xa=-(F.x*K.n21+F.y*K.n22+F.z*K.n23)*0.5+0.5;F.copy(U.vertexNormalsWorld[2]);l=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;y=-(F.x*K.n21+F.y*K.n22+F.z*K.n23)*0.5+0.5;ra(M,e,da,O,P,V,W.env_map.image,ia,ga,ua,xa,l,y)}}else W.wireframe?X(W.color.__styleString,W.wireframe_linewidth):Y(W.color.__styleString);else if(W instanceof THREE.MeshLambertMaterial){if(W.map&&!W.wireframe){W.map.mapping instanceof THREE.UVMapping&&ra(M,e,da,O,P,V,W.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);b(THREE.SubtractiveBlending)}if(E)if(!W.wireframe&&W.shading==THREE.SmoothShading&&U.vertexNormalsWorld.length==3){Z.r=ea.r=J.r=I.r;Z.g=ea.g=J.g=I.g;Z.b=ea.b=J.b=I.b;Ga(pa,U.v1.positionWorld,U.vertexNormalsWorld[0],Z);Ga(pa,U.v2.positionWorld,U.vertexNormalsWorld[1],ea);Ga(pa,U.v3.positionWorld,U.vertexNormalsWorld[2],J);$.r=(ea.r+J.r)*0.5;$.g=(ea.g+J.g)*0.5;$.b=(ea.b+J.b)*0.5;la=Ja(Z,ea, J,$);ra(M,e,da,O,P,V,la,0,0,1,0,0,1)}else{C.r=I.r;C.g=I.g;C.b=I.b;Ga(pa,U.centroidWorld,U.normalWorld,C);S.r=W.color.r*C.r;S.g=W.color.g*C.g;S.b=W.color.b*C.b;S.updateStyleString();W.wireframe?X(S.__styleString,W.wireframe_linewidth):Y(S.__styleString)}else W.wireframe?X(W.color.__styleString,W.wireframe_linewidth):Y(W.color.__styleString)}else if(W instanceof THREE.MeshDepthMaterial){ta=Ca.near;aa=Ca.far;Z.r=Z.g=Z.b=1-Aa(K.positionScreen.z,ta,aa);ea.r=ea.g=ea.b=1-Aa(ja.positionScreen.z,ta,aa);J.r= @@ -194,7 +194,7 @@ document.createElementNS("http://www.w3.org/2000/svg","line");la==0&&ea[C].setAt E.linecap+"; stroke-linejoin: "+E.linejoin);k.appendChild(J)}}}}else if(t instanceof THREE.RenderableFace3){u=t.v1;p=t.v2;x=t.v3;u.positionScreen.x*=n;u.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;x.positionScreen.x*=n;x.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);if(G.instersects(v)){l=0;for(y=t.meshMaterials.length;l=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight> THREE.ParticleSystem)e.drawArrays(e.POINTS,0,t.__webGLParticleCount);else E instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,t.__webGLVertexCount)}function g(l,y){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=e.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=e.createBuffer();if(l.hasPos){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,l.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(y.attributes.position);e.vertexAttribPointer(y.attributes.position, 3,e.FLOAT,!1,0,0)}if(l.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,l.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(y.attributes.normal);e.vertexAttribPointer(y.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,l.count);l.count=0}function h(l){if(V!=l.doubleSided){l.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);V=l.doubleSided}if(S!=l.flipSided){l.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);S=l.flipSided}}function k(l){if(ea!= l){l?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ea=l}}function j(l){J[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);J[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);J[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);J[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);J[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);J[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var y;for(l=0;l<6;l++){y=J[l];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}} -function m(l){for(var y=l.globalMatrix,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),q=0;q<6;q++){l=J[q].x*y.n14+J[q].y*y.n24+J[q].z*y.n34+J[q].w;if(l<=B)return!1}return!0}function n(l,y){l.list[l.count]=y;l.count+=1}function w(l){var y,B,q=l.object,t=l.opaque,E=l.transparent;E.count=0;l=t.count=0;for(y=q.materials.length;l0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+ -E.maxPointLights,E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"",E.light_map?"#define USE_LIGHTMAP":"",E.vertex_colors?"#define USE_COLOR":"",E.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); +function m(l){for(var y=l.matrixWorld,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),q=0;q<6;q++){l=J[q].x*y.n14+J[q].y*y.n24+J[q].z*y.n34+J[q].w;if(l<=B)return!1}return!0}function n(l,y){l.list[l.count]=y;l.count+=1}function w(l){var y,B,q=l.object,t=l.opaque,E=l.transparent;E.count=0;l=t.count=0;for(y=q.materials.length;l0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,E.map?"#define USE_MAP":"", +E.env_map?"#define USE_ENVMAP":"",E.light_map?"#define USE_LIGHTMAP":"",E.vertex_colors?"#define USE_COLOR":"",E.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); e.attachShader(B,H("fragment",t+L));e.attachShader(B,H("vertex",E+y));e.linkProgram(B);e.getProgramParameter(B,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(B,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(q in l.uniforms)B.push(q);q=l.program;L=0;for(y=B.length;L< y;L++){t=B[L];q.uniforms[t]=e.getUniformLocation(q,t)}q=l.program;B=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];L=0;for(y=B.length;L=0&&e.enableVertexAttribArray(q.color);q.normal>=0&&e.enableVertexAttribArray(q.normal);q.tangent>=0&&e.enableVertexAttribArray(q.tangent);if(l.skinning&&q.skinVertexA>=0&&q.skinVertexB>= -0&&q.skinIndex>=0&&q.skinWeight>=0){e.enableVertexAttribArray(q.skinVertexA);e.enableVertexAttribArray(q.skinVertexB);e.enableVertexAttribArray(q.skinIndex);e.enableVertexAttribArray(q.skinWeight)}};this.render=function(l,y,B,q){var t,E,C,I,L,z,D,F,T=l.lights,Q=l.fog;y.matrixAutoUpdate&&y.update();y.globalMatrix.flattenToArray(la);y.projectionMatrix.flattenToArray(ta);y.inverseMatrix.flattenToArray(aa);$.multiply(y.projectionMatrix,y.globalMatrix);j($);THREE.AnimationHandler&&THREE.AnimationHandler.update(); -l.update(undefined,!1,y);this.initWebGLObjects(l,y);v(B,q!==undefined?q:!0);this.autoClear&&this.clear();L=l.__webGLObjects.length;for(q=0;q=0&&q.skinWeight>=0){e.enableVertexAttribArray(q.skinVertexA);e.enableVertexAttribArray(q.skinVertexB);e.enableVertexAttribArray(q.skinIndex);e.enableVertexAttribArray(q.skinWeight)}};this.render=function(l,y,B,q){var t,E,C,I,L,z,D,F,T=l.lights,Q=l.fog;y.matrixAutoUpdate&&y.update();y.matrixWorld.flattenToArray(la);y.projectionMatrix.flattenToArray(ta);y.inverseMatrix.flattenToArray(aa);$.multiply(y.projectionMatrix,y.matrixWorld);j($);THREE.AnimationHandler&&THREE.AnimationHandler.update(); +l.update(undefined,!1,y);this.initWebGLObjects(l,y);v(B,q!==undefined?q:!0);this.autoClear&&this.clear();L=l.__webGLObjects.length;for(q=0;q0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLengt THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a0&&r>0&&F+r<1}var c,d,f,e,h,j,g,i,m,n, -o,q=a.geometry,s=q.vertices,t=[];c=0;for(d=q.faces.length;cg?d:g;f=f>i?f:i}a()}; this.add3Points=function(g,i,m,n,o,q){if(j){j=!1;b=gm?g>o?g:o:m>o?m:o;f=i>n?i>q?i:q:n>q?n:q}else{b=gm?g>o?g>d?g:d:o>d?o:d:m>o?m>d?m:d:o>d?o:d;f=i>n?i>q?i>f?i:f:q>f?q:f:n>q?n>f?n:f:q>f?q:f}a()};this.addRectangle=function(g){if(j){j=!1;b=g.getLeft();c=g.getTop();d=g.getRight();f=g.getBottom()}else{b=bg.getRight()? @@ -41,11 +41,11 @@ b.n24=f*i*m-e*g*m+e*h*o-c*i*o-f*h*q+c*g*q;b.n31=j*q*s-i*n*s+i*m*t-h*q*t-j*m*k+h* THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,e=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*e;c[3]=a*h;c[4]=a*j;c[5]=a*g;c[6]=a*i;c[7]=a*m;c[8]=a*n;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,f,e){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(e+f)/(e-f);h.n34=-2*e*f/(e-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)}; THREE.Matrix4.makeOrtho=function(a,b,c,d,f,e){var h,j,g,i;h=new THREE.Matrix4;j=b-a;g=c-d;i=e-f;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((b+a)/j);h.n21=0;h.n22=2/g;h.n23=0;h.n24=-((c+d)/g);h.n31=0;h.n32=0;h.n33=-2/i;h.n34=-((e+f)/i);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; -THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale= -1;this.visible=!0}; -THREE.Object3D.prototype={update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a-this.near)return!1;if(h+e<-this.far)return!1;h-=e;var j=this.projectionMatrix,g=1/(j.n43*h),i=g*this.screenCenterX,m=(f.n11*b+f.n12*c+f.n13*d+f.n14)*j.n11*i;e=j.n11*e*i;if(m+e<-this.screenCenterX)return!1;if(m-e>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*j.n22*g*this.screenCenterY; +THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.inverseMatrix);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld, +this.inverseMatrix)}}for(a=0;a-this.near)return!1;if(h+e<-this.far)return!1;h-=e;var j=this.projectionMatrix,g=1/(j.n43*h),i=g*this.screenCenterX,m=(f.n11*b+f.n12*c+f.n13*d+f.n14)*j.n11*i;e=j.n11*e*i;if(m+e<-this.screenCenterX)return!1;if(m-e>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*j.n22*g*this.screenCenterY; if(b+e<-this.screenCenterY)return!1;if(b-e>this.screenCenterY)return!1;a.screenPosition.set(m,b,h,e);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1; THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; @@ -108,18 +108,18 @@ THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)th THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b=0&&E>=0&&y>=0&&B>=0)return!0;else if(L<0&&E<0||y<0&&B<0)return!1;else{if(L<0)K=Math.max(K,L/(L-E));else E<0&&(u=Math.min(u,L/(L-E)));if(y<0)K=Math.max(K,y/(y-B));else B<0&&(u=Math.min(u,y/(y-B)));if(uL&&x.z0&&r.z<1){o=s[q]=s[q]||new THREE.RenderableParticle;o.x=r.x/r.w;o.y=r.y/r.w;o.z=r.z;o.rotation=J.rotation.z;o.scale.x=J.scale.x*Math.abs(o.x-(r.x+w.projectionMatrix.n11)/(r.w+w.projectionMatrix.n14)); -o.scale.y=J.scale.y*Math.abs(o.y-(r.y+w.projectionMatrix.n22)/(r.w+w.projectionMatrix.n24));o.materials=J.materials;u.push(o);q++}}}}K&&u.sort(a);return u};this.unprojectVector=function(A,w){var K=THREE.Matrix4.makeInvert(w.globalMatrix);K.multiplySelf(THREE.Matrix4.makeInvert(w.projectionMatrix));K.multiplyVector3(A);return A}}; +C=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Vector4,F=new THREE.Vector4,N;this.projectObjects=function(A,w,K){w=[];var u,L,E;d=0;L=A.objects;A=0;for(u=L.length;AL&&x.z0&&r.z<1){o=s[q]=s[q]||new THREE.RenderableParticle;o.x=r.x/r.w;o.y=r.y/r.w;o.z=r.z;o.rotation=J.rotation.z;o.scale.x=J.scale.x*Math.abs(o.x-(r.x+w.projectionMatrix.n11)/(r.w+w.projectionMatrix.n14)); +o.scale.y=J.scale.y*Math.abs(o.y-(r.y+w.projectionMatrix.n22)/(r.w+w.projectionMatrix.n24));o.materials=J.materials;u.push(o);q++}}}}K&&u.sort(a);return u};this.unprojectVector=function(A,w){var K=THREE.Matrix4.makeInvert(w.matrixWorld);K.multiplySelf(THREE.Matrix4.makeInvert(w.projectionMatrix));K.multiplyVector3(A);return A}}; THREE.CanvasRenderer=function(){function a(V){if(o!=V)i.globalAlpha=o=V}function b(V){if(q!=V){switch(V){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}q=V}}var c=null,d=new THREE.Projector,f=document.createElement("canvas"),e,h,j,g,i=f.getContext("2d"),m=new THREE.Color(0),n=0,o=1,q=0,s=null,t=null,r=1,k,D,C,I,F,N,A,w,K,u=new THREE.Color, L=new THREE.Color,E=new THREE.Color,y=new THREE.Color,B=new THREE.Color,T,x,P,Y,J,ja,ka,la,ma,$=new THREE.Rectangle,O=new THREE.Rectangle,H=new THREE.Rectangle,U=!1,Q=new THREE.Color,aa=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,La=Math.PI*2,R=new THREE.Vector3,ra,sa,Ca,ba,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);ba=Ca.data;ta=document.createElement("canvas"); ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(V,da){e=V;h=da;j=e/2;g=h/2;f.width=e;f.height=h;$.set(-j,-g,j,g);o=1;q=0;t=s=null;r=1};this.setClearColor=function(V,da){m=V;n=da;O.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.setClearColorHex=function(V,da){m.setHex(V);n=da;O.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.clear= @@ -128,7 +128,7 @@ v[l];p=z.color;if(z instanceof THREE.AmbientLight){aa.r+=p.r;aa.g+=p.g;aa.b+=p.b M=z.dot(R)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}}}function Na(l,G,z){if(z.opacity!=0){a(z.opacity);b(z.blending);var p,v,M,W,X,Z;if(z instanceof THREE.ParticleBasicMaterial){if(z.map){W=z.map.image;X=W.width>>1;Z=W.height>>1;v=G.scale.x*j;M=G.scale.y*g;z=v*X;p=M*Z;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(v,-M);i.translate(-X,-Z);i.drawImage(W,0,0);i.restore()}}}else if(z instanceof THREE.ParticleCircleMaterial){if(U){Q.r= aa.r+na.r+oa.r;Q.g=aa.g+na.g+oa.g;Q.b=aa.b+na.b+oa.b;u.r=z.color.r*Q.r;u.g=z.color.g*Q.g;u.b=z.color.b*Q.b;u.updateStyleString()}else u.__styleString=z.color.__styleString;z=G.scale.x*j;p=G.scale.y*g;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){v=u.__styleString;if(t!=v)i.fillStyle=t=v;i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(z,p);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(l,G,z,p){if(p.opacity!=0){a(p.opacity);b(p.blending);i.beginPath(); i.moveTo(l.positionScreen.x,l.positionScreen.y);i.lineTo(G.positionScreen.x,G.positionScreen.y);i.closePath();if(p instanceof THREE.LineBasicMaterial){u.__styleString=p.color.__styleString;l=p.linewidth;if(r!=l)i.lineWidth=r=l;l=u.__styleString;if(s!=l)i.strokeStyle=s=l;i.stroke();H.inflate(p.linewidth*2)}}}function Ha(l,G,z,p,v,M){if(v.opacity!=0){a(v.opacity);b(v.blending);I=l.positionScreen.x;F=l.positionScreen.y;N=G.positionScreen.x;A=G.positionScreen.y;w=z.positionScreen.x;K=z.positionScreen.y; -i.beginPath();i.moveTo(I,F);i.lineTo(N,A);i.lineTo(w,K);i.lineTo(I,F);i.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,K,v.map.image,p.uvs[0].u,p.uvs[0].v,p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);else if(v.env_map){if(v.env_map.mapping instanceof THREE.SphericalReflectionMapping){l=da.globalMatrix;R.copy(p.vertexNormalsWorld[0]);Y=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;J=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[1]); +i.beginPath();i.moveTo(I,F);i.lineTo(N,A);i.lineTo(w,K);i.lineTo(I,F);i.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,K,v.map.image,p.uvs[0].u,p.uvs[0].v,p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);else if(v.env_map){if(v.env_map.mapping instanceof THREE.SphericalReflectionMapping){l=da.matrixWorld;R.copy(p.vertexNormalsWorld[0]);Y=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;J=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[1]); ja=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;ka=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[2]);la=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;ma=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;ua(I,F,N,A,w,K,v.env_map.image,Y,J,ja,ka,la,ma)}}else v.wireframe?za(v.color.__styleString,v.wireframe_linewidth):Aa(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,K,v.map.image,p.uvs[0].u,p.uvs[0].v, p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);b(THREE.SubtractiveBlending)}if(U)if(!v.wireframe&&v.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3){L.r=E.r=y.r=aa.r;L.g=E.g=y.g=aa.g;L.b=E.b=y.b=aa.b;ya(M,p.v1.positionWorld,p.vertexNormalsWorld[0],L);ya(M,p.v2.positionWorld,p.vertexNormalsWorld[1],E);ya(M,p.v3.positionWorld,p.vertexNormalsWorld[2],y);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=Ia(L,E,y,B);ua(I,F,N,A,w,K,P,0,0,1,0,0,1)}else{Q.r=aa.r;Q.g=aa.g;Q.b=aa.b;ya(M,p.centroidWorld, p.normalWorld,Q);u.r=v.color.r*Q.r;u.g=v.color.g*Q.g;u.b=v.color.b*Q.b;u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframe_linewidth):Aa(u.__styleString)}else v.wireframe?za(v.color.__styleString,v.wireframe_linewidth):Aa(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){T=da.near;x=da.far;L.r=L.g=L.b=1-Da(l.positionScreen.z,T,x);E.r=E.g=E.b=1-Da(G.positionScreen.z,T,x);y.r=y.g=y.b=1-Da(z.positionScreen.z,T,x);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P= diff --git a/build/custom/ThreeDOM.js b/build/custom/ThreeDOM.js index 7f8d32bf..bf2a8adc 100644 --- a/build/custom/ThreeDOM.js +++ b/build/custom/ThreeDOM.js @@ -12,7 +12,7 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLengt THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,d=[];a=0;for(b=e.length;a0&&r>0&&G+r<1}var c,e,d,f,g,i,h,j,m,n, -l,o=a.geometry,p=o.vertices,q=[];c=0;for(e=o.faces.length;ch?e:h;d=d>j?d:j}a()}; this.add3Points=function(h,j,m,n,l,o){if(i){i=!1;b=hm?h>l?h:l:m>l?m:l;d=j>n?j>o?j:o:n>o?n:o}else{b=hm?h>l?h>e?h:e:l>e?l:e:m>l?m>e?m:e:l>e?l:e;d=j>n?j>o?j>d?j:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=bh.getRight()? @@ -41,11 +41,11 @@ b.n24=d*j*m-f*h*m+f*g*l-c*j*l-d*g*o+c*h*o;b.n31=i*o*p-j*n*p+j*m*q-g*o*q-i*m*k+g* THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*m;c[8]=a*n;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,e,d,f){var g;g=new THREE.Matrix4;g.n11=2*d/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*d/(e-c);g.n23=(e+c)/(e-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+d)/(f-d);g.n34=-2*f*d/(f-d);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,e){var d;a=c*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*b,a*b,d,a,c,e)}; THREE.Matrix4.makeOrtho=function(a,b,c,e,d,f){var g,i,h,j;g=new THREE.Matrix4;i=b-a;h=c-e;j=f-d;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+e)/h);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+d)/j);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; -THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale= -1;this.visible=!0}; -THREE.Object3D.prototype={update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var e=this.children.length;for(a=0;a-this.near)return!1;if(g+f<-this.far)return!1;g-=f;var i=this.projectionMatrix,h=1/(i.n43*g),j=h*this.screenCenterX,m=(d.n11*b+d.n12*c+d.n13*e+d.n14)*i.n11*j;f=i.n11*f*j;if(m+f<-this.screenCenterX)return!1;if(m-f>this.screenCenterX)return!1;b=(d.n21*b+d.n22*c+d.n23*e+d.n24)*i.n22*h*this.screenCenterY; +THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.inverseMatrix);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld, +this.inverseMatrix)}}for(a=0;a-this.near)return!1;if(g+f<-this.far)return!1;g-=f;var i=this.projectionMatrix,h=1/(i.n43*g),j=h*this.screenCenterX,m=(d.n11*b+d.n12*c+d.n13*e+d.n14)*i.n11*j;f=i.n11*f*j;if(m+f<-this.screenCenterX)return!1;if(m-f>this.screenCenterX)return!1;b=(d.n21*b+d.n22*c+d.n23*e+d.n24)*i.n22*h*this.screenCenterY; if(b+f<-this.screenCenterY)return!1;if(b-f>this.screenCenterY)return!1;a.screenPosition.set(m,b,g,f);return!0};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D; THREE.Particle.prototype.constructor=THREE.Particle;THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];this.sounds=[];this.fog=null};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)}; THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b=0&&E>=0&&y>=0&&u>=0)return!0;else if(D<0&&E<0||y<0&&u<0)return!1;else{if(D<0)C=Math.max(C,D/(D-E));else E<0&&(z=Math.min(z,D/(D-E)));if(y<0)C=Math.max(C,y/(y-u));else u<0&&(z=Math.min(z,y/(y-u)));if(zD&&s.z0&&r.z<1){l=p[o]=p[o]||new THREE.RenderableParticle;l.x=r.x/r.w;l.y=r.y/r.w;l.z=r.z;l.rotation=w.rotation.z;l.scale.x=w.scale.x*Math.abs(l.x-(r.x+t.projectionMatrix.n11)/(r.w+t.projectionMatrix.n14));l.scale.y=w.scale.y* -Math.abs(l.y-(r.y+t.projectionMatrix.n22)/(r.w+t.projectionMatrix.n24));l.materials=w.materials;z.push(l);o++}}}}C&&z.sort(a);return z};this.unprojectVector=function(v,t){var C=THREE.Matrix4.makeInvert(t.globalMatrix);C.multiplySelf(THREE.Matrix4.makeInvert(t.projectionMatrix));C.multiplyVector3(v);return v}}; +Math.abs(l.y-(r.y+t.projectionMatrix.n22)/(r.w+t.projectionMatrix.n24));l.materials=w.materials;z.push(l);o++}}}}C&&z.sort(a);return z};this.unprojectVector=function(v,t){var C=THREE.Matrix4.makeInvert(t.matrixWorld);C.multiplySelf(THREE.Matrix4.makeInvert(t.projectionMatrix));C.multiplyVector3(v);return v}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,d,f;this.domElement=document.createElement("div");this.setSize=function(g,i){c=g;e=i;d=c/2;f=e/2};this.render=function(g,i){var h,j,m,n,l,o,p,q;a=b.projectScene(g,i);h=0;for(j=a.length;h0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLengt THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&t>0&&C+t<1}var c,d,e,f,g,i,h,k,n,m, -l,o=a.geometry,q=o.vertices,s=[];c=0;for(d=o.faces.length;ch?d:h;e=e>k?e:k}a()}; this.add3Points=function(h,k,n,m,l,o){if(i){i=!1;b=hn?h>l?h:l:n>l?n:l;e=k>m?k>o?k:o:m>o?m:o}else{b=hn?h>l?h>d?h:d:l>d?l:d:n>l?n>d?n:d:l>d?l:d;e=k>m?k>o?k>e?k:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=bh.getRight()? @@ -41,11 +41,11 @@ b.n24=e*k*n-f*h*n+f*g*l-c*k*l-e*g*o+c*h*o;b.n31=i*o*q-k*m*q+k*n*s-g*o*s-i*n*j+g* THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,k=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*k;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*k;c[7]=a*n;c[8]=a*m;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,k;g=new THREE.Matrix4;i=b-a;h=c-d;k=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/k;g.n34=-((f+e)/k);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; -THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale= -1;this.visible=!0}; -THREE.Object3D.prototype={update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a-this.near)return!1;if(g+f<-this.far)return!1;g-=f;var i=this.projectionMatrix,h=1/(i.n43*g),k=h*this.screenCenterX,n=(e.n11*b+e.n12*c+e.n13*d+e.n14)*i.n11*k;f=i.n11*f*k;if(n+f<-this.screenCenterX)return!1;if(n-f>this.screenCenterX)return!1;b=(e.n21*b+e.n22*c+e.n23*d+e.n24)*i.n22*h*this.screenCenterY; +THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.inverseMatrix);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld, +this.inverseMatrix)}}for(a=0;a-this.near)return!1;if(g+f<-this.far)return!1;g-=f;var i=this.projectionMatrix,h=1/(i.n43*g),k=h*this.screenCenterX,n=(e.n11*b+e.n12*c+e.n13*d+e.n14)*i.n11*k;f=i.n11*f*k;if(n+f<-this.screenCenterX)return!1;if(n-f>this.screenCenterX)return!1;b=(e.n21*b+e.n22*c+e.n23*d+e.n24)*i.n22*h*this.screenCenterY; if(b+f<-this.screenCenterY)return!1;if(b-f>this.screenCenterY)return!1;a.screenPosition.set(n,b,g,f);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1; THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0}; @@ -105,9 +105,9 @@ THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)th THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b=0&&J>=0&&u>=0&&D>=0)return!0;else if(K<0&&J<0||u<0&&D<0)return!1;else{if(K<0)I=Math.max(I,K/(K-J));else J<0&&(E=Math.min(E,K/(K-J)));if(u<0)I=Math.max(I,u/(u-D));else D<0&&(E=Math.min(E,u/(u-D)));if(EK&&x.z0&&t.z<1){l=q[o]=q[o]||new THREE.RenderableParticle;l.x=t.x/t.w;l.y=t.y/t.w;l.z=t.z;l.rotation=A.rotation.z;l.scale.x=A.scale.x*Math.abs(l.x-(t.x+v.projectionMatrix.n11)/(t.w+v.projectionMatrix.n14));l.scale.y=A.scale.y* -Math.abs(l.y-(t.y+v.projectionMatrix.n22)/(t.w+v.projectionMatrix.n24));l.materials=A.materials;E.push(l);o++}}}}I&&E.sort(a);return E};this.unprojectVector=function(z,v){var I=THREE.Matrix4.makeInvert(v.globalMatrix);I.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));I.multiplyVector3(z);return z}}; +Math.abs(l.y-(t.y+v.projectionMatrix.n22)/(t.w+v.projectionMatrix.n24));l.materials=A.materials;E.push(l);o++}}}}I&&E.sort(a);return E};this.unprojectVector=function(z,v){var I=THREE.Matrix4.makeInvert(v.matrixWorld);I.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));I.multiplyVector3(z);return z}}; THREE.SVGRenderer=function(){function a(F,A,O){var Q,B,w,M;Q=0;for(B=F.lights.length;Q0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}else if(w instanceof THREE.PointLight){I.sub(w.position,A.centroidWorld);I.normalize();M=A.normalWorld.dot(I)*w.intensity;if(M>0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}}}function b(F,A,O,Q,B,w){u=d(D++);u.setAttribute("d","M "+F.positionScreen.x+ " "+F.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(H){y.r=C.r;y.g=C.g;y.b=C.b;a(w,Q,y);p.r=B.color.r*y.r;p.g=B.color.g*y.g;p.b=B.color.b*y.b;p.updateStyleString()}else p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){v=1-B.__2near/(B.__farPlusNear-Q.z*B.__farMinusNear); p.setRGB(v,v,v)}else B instanceof THREE.MeshNormalMaterial&&p.setRGB(e(Q.normalWorld.x),e(Q.normalWorld.y),e(Q.normalWorld.z));B.wireframe?u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):u.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+B.opacity);i.appendChild(u)}function c(F,A,O,Q,B,w,M){u=d(D++);u.setAttribute("d", diff --git a/build/custom/ThreeWebGL.js b/build/custom/ThreeWebGL.js index db71b672..364899fb 100644 --- a/build/custom/ThreeWebGL.js +++ b/build/custom/ThreeWebGL.js @@ -12,7 +12,7 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLengt THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,g=[];a=0;for(c=f.length;a0&&K>0&&b+K<1}var d,f,g,j,k,o,i,t,w,x, -z,A=a.geometry,E=A.vertices,H=[];d=0;for(f=A.faces.length;di?f:i;g=g>t?g:t}a()}; this.add3Points=function(i,t,w,x,z,A){if(o){o=!1;c=iw?i>z?i:z:w>z?w:z;g=t>x?t>A?t:A:x>A?x:A}else{c=iw?i>z?i>f?i:f:z>f?z:f:w>z?w>f?w:f:z>f?z:f;g=t>x?t>A?t>g?t:g:A>g?A:g:x>A?x>g?x:g:A>g?A:g}a()};this.addRectangle=function(i){if(o){o=!1;c=i.getLeft();d=i.getTop();f=i.getRight();g=i.getBottom()}else{c=ci.getRight()? @@ -41,11 +41,11 @@ c.n24=g*t*w-j*i*w+j*k*z-d*t*z-g*k*A+d*i*A;c.n31=o*A*E-t*x*E+t*w*H-k*A*H-o*w*J+k* THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,j=a.n32*a.n21-a.n31*a.n22,k=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,i=-a.n32*a.n11+a.n31*a.n12,t=a.n23*a.n12-a.n22*a.n13,w=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*k+a.n31*t;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*g;d[2]=a*j;d[3]=a*k;d[4]=a*o;d[5]=a*i;d[6]=a*t;d[7]=a*w;d[8]=a*x;return c}; THREE.Matrix4.makeFrustum=function(a,c,d,f,g,j){var k;k=new THREE.Matrix4;k.n11=2*g/(c-a);k.n12=0;k.n13=(c+a)/(c-a);k.n14=0;k.n21=0;k.n22=2*g/(f-d);k.n23=(f+d)/(f-d);k.n24=0;k.n31=0;k.n32=0;k.n33=-(j+g)/(j-g);k.n34=-2*j*g/(j-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,c,d,f){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,f)}; THREE.Matrix4.makeOrtho=function(a,c,d,f,g,j){var k,o,i,t;k=new THREE.Matrix4;o=c-a;i=d-f;t=j-g;k.n11=2/o;k.n12=0;k.n13=0;k.n14=-((c+a)/o);k.n21=0;k.n22=2/i;k.n23=0;k.n24=-((d+f)/i);k.n31=0;k.n32=0;k.n33=-2/t;k.n34=-((j+g)/t);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; -THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale= -1;this.visible=!0}; -THREE.Object3D.prototype={update:function(a,c,d){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;c=!0}var f=this.children.length;for(a=0;a-this.near)return!1;if(k+j<-this.far)return!1;k-=j;var o=this.projectionMatrix,i=1/(o.n43*k),t=i*this.screenCenterX,w=(g.n11*c+g.n12*d+g.n13*f+g.n14)*o.n11*t;j=o.n11*j*t;if(w+j<-this.screenCenterX)return!1;if(w-j>this.screenCenterX)return!1;c=(g.n21*c+g.n22*d+g.n23*f+g.n24)*o.n22*i*this.screenCenterY; +THREE.Camera.prototype.update=function(a,c,d){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.inverseMatrix);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;c=!0;THREE.Matrix4.makeInvert(this.matrixWorld, +this.inverseMatrix)}}for(a=0;a-this.near)return!1;if(k+j<-this.far)return!1;k-=j;var o=this.projectionMatrix,i=1/(o.n43*k),t=i*this.screenCenterX,w=(g.n11*c+g.n12*d+g.n13*f+g.n14)*o.n11*t;j=o.n11*j*t;if(w+j<-this.screenCenterX)return!1;if(w-j>this.screenCenterX)return!1;c=(g.n21*c+g.n22*d+g.n23*f+g.n24)*o.n22*i*this.screenCenterY; if(c+j<-this.screenCenterY)return!1;if(c-j>this.screenCenterY)return!1;a.screenPosition.set(w,c,k,j);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1; THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; @@ -113,7 +113,7 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[]; THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var c=0;c=0&&e.skinVertexB>=0&&e.skinIndex>=0&&e.skinWeight> THREE.ParticleSystem)b.drawArrays(b.POINTS,0,l.__webGLParticleCount);else v instanceof THREE.Ribbon&&b.drawArrays(b.TRIANGLE_STRIP,0,l.__webGLVertexCount)}function j(e,n){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer=b.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=b.createBuffer();if(e.hasPos){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,e.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(n.attributes.position);b.vertexAttribPointer(n.attributes.position, 3,b.FLOAT,!1,0,0)}if(e.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,e.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(n.attributes.normal);b.vertexAttribPointer(n.attributes.normal,3,b.FLOAT,!1,0,0)}b.drawArrays(b.TRIANGLES,0,e.count);e.count=0}function k(e){if(ga!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);ga=e.doubleSided}if(da!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);da=e.flipSided}}function o(e){if(na!= e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST);na=e}}function i(e){$[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);$[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+e.n14);$[2].set(e.n41+e.n21,e.n42+e.n22,e.n43+e.n23,e.n44+e.n24);$[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);$[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);$[5].set(e.n41+e.n31,e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var n;for(e=0;e<6;e++){n=$[e];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}} -function t(e){for(var n=e.globalMatrix,m=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),h=0;h<6;h++){e=$[h].x*n.n14+$[h].y*n.n24+$[h].z*n.n34+$[h].w;if(e<=m)return!1}return!0}function w(e,n){e.list[e.count]=n;e.count+=1}function x(e){var n,m,h=e.object,l=e.opaque,v=e.transparent;v.count=0;e=l.count=0;for(n=h.materials.length;e=0&&b.enableVertexAttribArray(h.color);h.normal>=0&&b.enableVertexAttribArray(h.normal);h.tangent>=0&&b.enableVertexAttribArray(h.tangent);if(e.skinning&&h.skinVertexA>=0&&h.skinVertexB>= -0&&h.skinIndex>=0&&h.skinWeight>=0){b.enableVertexAttribArray(h.skinVertexA);b.enableVertexAttribArray(h.skinVertexB);b.enableVertexAttribArray(h.skinIndex);b.enableVertexAttribArray(h.skinWeight)}};this.render=function(e,n,m,h){var l,v,r,q,s,G,F,I,S=e.lights,y=e.fog;n.matrixAutoUpdate&&n.update();n.globalMatrix.flattenToArray(Ha);n.projectionMatrix.flattenToArray(va);n.inverseMatrix.flattenToArray(wa);qa.multiply(n.projectionMatrix,n.globalMatrix);i(qa);THREE.AnimationHandler&&THREE.AnimationHandler.update(); -e.update(undefined,!1,n);this.initWebGLObjects(e,n);J(m,h!==undefined?h:!0);this.autoClear&&this.clear();s=e.__webGLObjects.length;for(h=0;h=0&&h.skinWeight>=0){b.enableVertexAttribArray(h.skinVertexA);b.enableVertexAttribArray(h.skinVertexB);b.enableVertexAttribArray(h.skinIndex);b.enableVertexAttribArray(h.skinWeight)}};this.render=function(e,n,m,h){var l,v,r,q,s,G,F,I,S=e.lights,y=e.fog;n.matrixAutoUpdate&&n.update();n.matrixWorld.flattenToArray(Ha);n.projectionMatrix.flattenToArray(va);n.inverseMatrix.flattenToArray(wa);qa.multiply(n.projectionMatrix,n.matrixWorld);i(qa);THREE.AnimationHandler&&THREE.AnimationHandler.update(); +e.update(undefined,!1,n);this.initWebGLObjects(e,n);J(m,h!==undefined?h:!0);this.autoClear&&this.clear();s=e.__webGLObjects.length;for(h=0;h + + + three.js canvas - geometry hierarchy 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/canvas_sandbox.html b/examples/canvas_sandbox.html index 718a2011..f6de171f 100644 --- a/examples/canvas_sandbox.html +++ b/examples/canvas_sandbox.html @@ -166,7 +166,7 @@ objects = []; geometry = new Sphere( 100, 16, 8 ); - material = new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ); + material = new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ) } ); for ( var i = 0; i < 10; i ++ ) { diff --git a/examples/webgl_geometry_hierarchy.html b/examples/webgl_geometry_hierarchy.html new file mode 100644 index 00000000..9b1c0105 --- /dev/null +++ b/examples/webgl_geometry_hierarchy.html @@ -0,0 +1,203 @@ + + + + three.js webgl - geometry hierarchy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/webgl_geometry_hierarchy2.html b/examples/webgl_geometry_hierarchy2.html new file mode 100644 index 00000000..2f8ac200 --- /dev/null +++ b/examples/webgl_geometry_hierarchy2.html @@ -0,0 +1,281 @@ + + + + three.js webgl - geometry hierarchy 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/webgl_performance.html b/examples/webgl_performance.html new file mode 100644 index 00000000..2745f2c6 --- /dev/null +++ b/examples/webgl_performance.html @@ -0,0 +1,217 @@ + + + + three.js webgl - performance + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/webgl_ribbons.html b/examples/webgl_ribbons.html index b8654945..56fa53f0 100644 --- a/examples/webgl_ribbons.html +++ b/examples/webgl_ribbons.html @@ -148,25 +148,25 @@ ribbon.matrixAutoUpdate = false; // manually create local matrix - - ribbon.localMatrix.setPosition( ribbon.position ); + + ribbon.matrix.setPosition( ribbon.position ); ribbon.matrixRotation.setRotationFromEuler( ribbon.rotation ); - ribbon.localMatrix.n11 = ribbon.matrixRotation.n11; - ribbon.localMatrix.n12 = ribbon.matrixRotation.n12; - ribbon.localMatrix.n13 = ribbon.matrixRotation.n13; + ribbon.matrix.n11 = ribbon.matrixRotation.n11; + ribbon.matrix.n12 = ribbon.matrixRotation.n12; + ribbon.matrix.n13 = ribbon.matrixRotation.n13; - ribbon.localMatrix.n21 = ribbon.matrixRotation.n21; - ribbon.localMatrix.n22 = ribbon.matrixRotation.n22; - ribbon.localMatrix.n23 = ribbon.matrixRotation.n23; + ribbon.matrix.n21 = ribbon.matrixRotation.n21; + ribbon.matrix.n22 = ribbon.matrixRotation.n22; + ribbon.matrix.n23 = ribbon.matrixRotation.n23; - ribbon.localMatrix.n31 = ribbon.matrixRotation.n31; - ribbon.localMatrix.n32 = ribbon.matrixRotation.n32; - ribbon.localMatrix.n33 = ribbon.matrixRotation.n33; - - ribbon.localMatrix.multiplySelf( tmpRot ); + ribbon.matrix.n31 = ribbon.matrixRotation.n31; + ribbon.matrix.n32 = ribbon.matrixRotation.n32; + ribbon.matrix.n33 = ribbon.matrixRotation.n33; - ribbon.localMatrix.scale( ribbon.scale ); + ribbon.matrix.multiplySelf( tmpRot ); + + ribbon.matrix.scale( ribbon.scale ); ribbon.boundRadiusScale = Math.max( ribbon.scale.x, Math.max( ribbon.scale.y, ribbon.scale.z ) ); ribbons.push( ribbon ); diff --git a/examples/misc_webglrenderer2_sandbox.html b/examples/webgl_sandbox.html similarity index 89% rename from examples/misc_webglrenderer2_sandbox.html rename to examples/webgl_sandbox.html index 126b902c..3d0a27f2 100644 --- a/examples/misc_webglrenderer2_sandbox.html +++ b/examples/webgl_sandbox.html @@ -35,9 +35,7 @@
three.js - webgl cube Fresnel shader demo.
- + @@ -48,28 +46,23 @@ + - - - - - - - - + + @@ -84,13 +77,14 @@ - - - - - - - + + + + + + + + @@ -99,15 +93,24 @@ - + - - + + + + + + + + + + + @@ -202,7 +205,7 @@ } - renderer = new THREE.WebGLRenderer2(); + renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); // renderer.sortObjects = false; container.appendChild( renderer.domElement ); diff --git a/src/cameras/Camera.js b/src/cameras/Camera.js index 9d985af8..83b66272 100644 --- a/src/cameras/Camera.js +++ b/src/cameras/Camera.js @@ -82,24 +82,29 @@ THREE.Camera.prototype.updateProjectionMatrix = function() { * Update */ -THREE.Camera.prototype.update = function( parentGlobalMatrix, forceUpdate, camera ) { +THREE.Camera.prototype.update = function( parentMatrixWorld, forceUpdate, camera ) { if( this.useTarget ) { // local - this.localMatrix.lookAt( this.position, this.target.position, this.up ); + this.matrix.lookAt( this.position, this.target.position, this.up ); // global - if( parentGlobalMatrix ) - this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); - else - this.globalMatrix.copy( this.localMatrix ); + if( parentMatrixWorld ) { - THREE.Matrix4.makeInvert( this.globalMatrix, this.inverseMatrix ); - //THREE.Matrix4.makeInvertTo( this.globalMatrix, this.inverseMatrix ); + this.matrixWorld.multiply( parentMatrixWorld, this.matrix ); + + } else { + + this.matrixWorld.copy( this.matrix ); + + } + + THREE.Matrix4.makeInvert( this.matrixWorld, this.inverseMatrix ); + //THREE.Matrix4.makeInvertTo( this.matrixWorld, this.inverseMatrix ); forceUpdate = true; @@ -110,16 +115,21 @@ THREE.Camera.prototype.update = function( parentGlobalMatrix, forceUpdate, camer if( forceUpdate || this.matrixNeedsUpdate ) { - if( parentGlobalMatrix ) - this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); - else - this.globalMatrix.copy( this.localMatrix ); + if( parentMatrixWorld ) { + + this.matrixWorld.multiply( parentMatrixWorld, this.matrix ); + + } else { + + this.matrixWorld.copy( this.matrix ); + + } this.matrixNeedsUpdate = false; forceUpdate = true; - THREE.Matrix4.makeInvert( this.globalMatrix, this.inverseMatrix ); - //THREE.Matrix4.makeInvertTo( this.globalMatrix, this.inverseMatrix ); + THREE.Matrix4.makeInvert( this.matrixWorld, this.inverseMatrix ); + //THREE.Matrix4.makeInvertTo( this.matrixWorld, this.inverseMatrix ); } @@ -127,8 +137,11 @@ THREE.Camera.prototype.update = function( parentGlobalMatrix, forceUpdate, camer // update children - for( var i = 0; i < this.children.length; i++ ) - this.children[ i ].update( this.globalMatrix, forceUpdate, camera ); + for ( var i = 0; i < this.children.length; i++ ) { + + this.children[ i ].update( this.matrixWorld, forceUpdate, camera ); + + } }; @@ -144,16 +157,15 @@ THREE.Camera.prototype.frustumContains = function( object3D ) { // object pos - var vx0 = object3D.globalMatrix.n14, - vy0 = object3D.globalMatrix.n24, - vz0 = object3D.globalMatrix.n34; - + var vx0 = object3D.matrixWorld.n14, + vy0 = object3D.matrixWorld.n24, + vz0 = object3D.matrixWorld.n34; // check z var inverse = this.inverseMatrix; - var radius = object3D.boundRadius * object3D.boundRadiusScale; - var vz1 = ( inverse.n31 * vx0 + inverse.n32 * vy0 + inverse.n33 * vz0 + inverse.n34 ); + var radius = object3D.boundRadius * object3D.boundRadiusScale; + var vz1 = ( inverse.n31 * vx0 + inverse.n32 * vy0 + inverse.n33 * vz0 + inverse.n34 ); if( vz1 - radius > - this.near ) { diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 24fa6190..88e048fc 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -15,16 +15,18 @@ THREE.Object3D = function() { this.rotation = new THREE.Vector3(); this.scale = new THREE.Vector3( 1.0, 1.0, 1.0 ); - this.matrixRotation = new THREE.Matrix4(); // this is just to cache it when somewhere it's computed somewhere else (stripped down globalMatrix) + this.matrix = new THREE.Matrix4(); + this.matrixWorld = new THREE.Matrix4(); + + this.matrixRotation = new THREE.Matrix4(); + // this.matrixRotationWorld = new THREE.Matrix4(); - this.localMatrix = new THREE.Matrix4(); - this.globalMatrix = new THREE.Matrix4(); this.matrixAutoUpdate = true; this.matrixNeedsUpdate = true; this.quaternion = new THREE.Quaternion(); this.useQuaternion = false; - this.screenPosition = new THREE.Vector4(); // xyzr + this.screenPosition = new THREE.Vector4(); // TODO: Rename to positionScreen this.boundRadius = 0.0; this.boundRadiusScale = 1.0; @@ -36,95 +38,16 @@ THREE.Object3D = function() { THREE.Object3D.prototype = { - update: function ( parentGlobalMatrix, forceUpdate, camera ) { - - if ( this.visible ) { - - if ( this.matrixAutoUpdate ) { - - forceUpdate |= this.updateMatrix(); - - } - - // update global - - if ( forceUpdate || this.matrixNeedsUpdate ) { - - if ( parentGlobalMatrix ) { - - this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); - - } else { - - this.globalMatrix.copy( this.localMatrix ); - - } - - this.matrixNeedsUpdate = false; - forceUpdate = true; - - } - - - // update children - - var i, l = this.children.length; - - for ( i = 0; i < l; i++ ) { - - this.children[ i ].update( this.globalMatrix, forceUpdate, camera ); - - } - - } - - }, - - - updateMatrix: function () { - - this.localMatrix.setPosition( this.position ); - - if ( this.useQuaternion ) { - - this.matrixRotation.setRotationFromQuaternion( this.quaternion ); - - } else { - - this.matrixRotation.setRotationFromEuler( this.rotation ); - - } - - this.localMatrix.n11 = this.matrixRotation.n11; - this.localMatrix.n12 = this.matrixRotation.n12; - this.localMatrix.n13 = this.matrixRotation.n13; - - this.localMatrix.n21 = this.matrixRotation.n21; - this.localMatrix.n22 = this.matrixRotation.n22; - this.localMatrix.n23 = this.matrixRotation.n23; - - this.localMatrix.n31 = this.matrixRotation.n31; - this.localMatrix.n32 = this.matrixRotation.n32; - this.localMatrix.n33 = this.matrixRotation.n33; - - if ( this.scale.x !== 1 || this.scale.y !== 1 || this.scale.z !== 1 ) { - - this.localMatrix.scale( this.scale ); - this.boundRadiusScale = Math.max( this.scale.x, Math.max( this.scale.y, this.scale.z ) ); - - } - - return true; - - }, - addChild: function ( child ) { - if ( this.children.indexOf( child ) === -1 ) { + if ( this.children.indexOf( child ) === - 1 ) { + + if( child.parent !== undefined ) { - if( child.parent !== undefined ) child.parent.removeChild( child ); + } + child.parent = this; this.children.push( child ); @@ -136,13 +59,93 @@ THREE.Object3D.prototype = { var childIndex = this.children.indexOf( child ); - if ( childIndex !== -1 ) { + if ( childIndex !== - 1 ) { this.children.splice( childIndex, 1 ); child.parent = undefined; } + }, + + updateMatrix: function () { + + this.matrix.setPosition( this.position ); + + if ( this.useQuaternion ) { + + this.matrixRotation.setRotationFromQuaternion( this.quaternion ); + + } else { + + this.matrixRotation.setRotationFromEuler( this.rotation ); + + } + + this.matrix.n11 = this.matrixRotation.n11; + this.matrix.n12 = this.matrixRotation.n12; + this.matrix.n13 = this.matrixRotation.n13; + + this.matrix.n21 = this.matrixRotation.n21; + this.matrix.n22 = this.matrixRotation.n22; + this.matrix.n23 = this.matrixRotation.n23; + + this.matrix.n31 = this.matrixRotation.n31; + this.matrix.n32 = this.matrixRotation.n32; + this.matrix.n33 = this.matrixRotation.n33; + + if ( this.scale.x !== 1 || this.scale.y !== 1 || this.scale.z !== 1 ) { + + this.matrix.scale( this.scale ); + this.boundRadiusScale = Math.max( this.scale.x, Math.max( this.scale.y, this.scale.z ) ); + + } + + return true; + + }, + + update: function ( parentMatrixWorld, forceUpdate, camera ) { + + if ( this.visible ) { + + if ( this.matrixAutoUpdate ) { + + forceUpdate |= this.updateMatrix(); + + } + + // update matrixWorld + + if ( forceUpdate || this.matrixNeedsUpdate ) { + + if ( parentMatrixWorld ) { + + this.matrixWorld.multiply( parentMatrixWorld, this.matrix ); + + } else { + + this.matrixWorld.copy( this.matrix ); + + } + + this.matrixNeedsUpdate = false; + forceUpdate = true; + + } + + // update children + + var i, l = this.children.length; + + for ( i = 0; i < l; i++ ) { + + this.children[ i ].update( this.matrixWorld, forceUpdate, camera ); + + } + + } + } } diff --git a/src/core/Ray.js b/src/core/Ray.js index 9d9a987e..da70e314 100644 --- a/src/core/Ray.js +++ b/src/core/Ray.js @@ -53,7 +53,7 @@ THREE.Ray.prototype = { origin = this.origin.clone(); direction = this.direction.clone(); - objMatrix = object.globalMatrix; + objMatrix = object.matrixWorld; a = objMatrix.multiplyVector3( vertices[ face.a ].position.clone() ); b = objMatrix.multiplyVector3( vertices[ face.b ].position.clone() ); diff --git a/src/extras/GeometryUtils.js b/src/extras/GeometryUtils.js index aacc9b20..88f91e46 100644 --- a/src/extras/GeometryUtils.js +++ b/src/extras/GeometryUtils.js @@ -22,7 +22,7 @@ var GeometryUtils = { var vertexCopy = new THREE.Vertex( vertex.position.clone() ); - isMesh && object2.localMatrix.multiplyVector3( vertexCopy.position ); + isMesh && object2.matrix.multiplyVector3( vertexCopy.position ); vertices1.push( vertexCopy ); diff --git a/src/objects/Bone.js b/src/objects/Bone.js index cb60fcc9..602d6460 100644 --- a/src/objects/Bone.js +++ b/src/objects/Bone.js @@ -22,22 +22,30 @@ THREE.Bone.prototype.supr = THREE.Object3D.prototype; */ THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate, camera ) { - - // update local - - if( this.matrixAutoUpdate ) - forceUpdate |= this.updateMatrix(); - + // update local + + if ( this.matrixAutoUpdate ) { + + forceUpdate |= this.updateMatrix(); + + } + + // update skin matrix - if( forceUpdate || this.matrixNeedsUpdate ) { - - if( parentSkinMatrix ) - this.skinMatrix.multiply( parentSkinMatrix, this.localMatrix ); - else - this.skinMatrix.copy( this.localMatrix ); - + if ( forceUpdate || this.matrixNeedsUpdate ) { + + if( parentSkinMatrix ) { + + this.skinMatrix.multiply( parentSkinMatrix, this.matrix ); + + } else { + + this.skinMatrix.copy( this.matrix ); + + } + this.matrixNeedsUpdate = false; forceUpdate = true; @@ -47,24 +55,30 @@ THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate, camera ) // update children var child, i, l = this.children.length; - - if( this.hasNoneBoneChildren ) { - - this.globalMatrix.multiply( this.skin.globalMatrix, this.skinMatrix ); - - for( i = 0; i < l; i++ ) { - + if ( this.hasNoneBoneChildren ) { + + this.matrixWorld.multiply( this.skin.matrixWorld, this.skinMatrix ); + + + for ( i = 0; i < l; i++ ) { + child = this.children[ i ]; - - if( ! ( child instanceof THREE.Bone ) ) - child.update( this.globalMatrix, true, camera ); - else + + if ( ! ( child instanceof THREE.Bone ) ) { + + child.update( this.matrixWorld, true, camera ); + + } else { + child.update( this.skinMatrix, forceUpdate, camera ); + + } + } - + } else { - + for( i = 0; i < l; i++ ) this.children[ i ].update( this.skinMatrix, forceUpdate, camera ); diff --git a/src/objects/LOD.js b/src/objects/LOD.js index a4612803..4b4c895c 100644 --- a/src/objects/LOD.js +++ b/src/objects/LOD.js @@ -19,16 +19,16 @@ THREE.LOD.prototype.supr = THREE.Object3D.prototype; */ THREE.LOD.prototype.add = function( object3D, visibleAtDistance ) { - + if( visibleAtDistance === undefined ) visibleAtDistance = 0; visibleAtDistance = Math.abs( visibleAtDistance ); - + for( var l = 0; l < this.LODs.length; l++ ) { - + if( visibleAtDistance < this.LODs[ l ].visibleAtDistance ) break; } - + this.LODs.splice( l, 0, { visibleAtDistance: visibleAtDistance, object3D: object3D } ); this.addChild( object3D ); @@ -39,59 +39,73 @@ THREE.LOD.prototype.add = function( object3D, visibleAtDistance ) { * Update */ -THREE.LOD.prototype.update = function( parentGlobalMatrix, forceUpdate, camera ) { - +THREE.LOD.prototype.update = function( parentMatrixWorld, forceUpdate, camera ) { + // update local - - if( this.matrixAutoUpdate ) + + if ( this.matrixAutoUpdate ) { + forceUpdate |= this.updateMatrix(); + } + // update global - if( forceUpdate || this.matrixNeedsUpdate ) { - - if( parentGlobalMatrix ) - this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); - else - this.globalMatrix.copy( this.localMatrix ); - + if ( forceUpdate || this.matrixNeedsUpdate ) { + + if ( parentMatrixWorld ) { + + this.matrixWorld.multiply( parentMatrixWorld, this.matrix ); + + } else { + + this.matrixWorld.copy( this.matrix ); + + } + this.matrixNeedsUpdate = false; - forceUpdate = true; + forceUpdate = true; } // update lods - + if( this.LODs.length > 1 ) { - + var distance = -camera.inverseMatrix.mulitplyVector3OnlyZ( this.position ); this.LODs[ 0 ].object3D.visible = true; - - for( var l = 1; l < this.LODs.length; l++ ) { - + + for ( var l = 1; l < this.LODs.length; l++ ) { + if( distance >= this.LODs[ l ].visibleAtDistance ) { - + this.LODs[ l - 1 ].object3D.visible = false; this.LODs[ l ].object3D.visible = true; - } - else + + } else { + break; + } + } - - for( ; l < this.LODs.length; l++ ) + + for( ; l < this.LODs.length; l++ ) { + this.LODs[ l ].object3D.visible = false; + } + } // update children for( var c = 0; c < this.children.length; c++ ) - this.children[ c ].update( this.globalMatrix, forceUpdate, camera ); + this.children[ c ].update( this.matrixWorld, forceUpdate, camera ); }; diff --git a/src/objects/SkinnedMesh.js b/src/objects/SkinnedMesh.js index c57442e5..1c2e9ca7 100644 --- a/src/objects/SkinnedMesh.js +++ b/src/objects/SkinnedMesh.js @@ -46,21 +46,26 @@ THREE.SkinnedMesh = function( geometry, materials ) { bone.scale.set( 1, 1, 1 ); } - + for( b = 0; b < this.bones.length; b++ ) { - + gbone = this.geometry.bones[ b ]; bone = this.bones[ b ]; - - if( gbone.parent === -1 ) + + if ( gbone.parent === -1 ) { + this.addChild( bone ); - else + + } else { + this.bones[ gbone.parent ].addChild( bone ); + } + } this.boneMatrices = new Float32Array( 16 * this.bones.length ); - + this.pose(); } @@ -75,46 +80,59 @@ THREE.SkinnedMesh.prototype.constructor = THREE.SkinnedMesh; * Update */ -THREE.SkinnedMesh.prototype.update = function( parentGlobalMatrix, forceUpdate, camera ) { - +THREE.SkinnedMesh.prototype.update = function( parentMatrixWorld, forceUpdate, camera ) { + // visible? - - if( this.visible ) { + + if ( this.visible ) { // update local - - if( this.matrixAutoUpdate ) + + if ( this.matrixAutoUpdate ) { + forceUpdate |= this.updateMatrix(); + } + // update global - if( forceUpdate || this.matrixNeedsUpdate ) { - - if( parentGlobalMatrix ) - this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); - else - this.globalMatrix.copy( this.localMatrix ); - + if ( forceUpdate || this.matrixNeedsUpdate ) { + + if ( parentMatrixWorld ) { + + this.matrixWorld.multiply( parentMatrixWorld, this.matrix ); + + } else { + + this.matrixWorld.copy( this.matrix ); + + } + this.matrixNeedsUpdate = false; - forceUpdate = true; + forceUpdate = true; } // update children - + var child, i, l = this.children.length; - - for( i = 0; i < l; i++ ) { - + + for ( i = 0; i < l; i++ ) { + child = this.children[ i ]; - - if( child instanceof THREE.Bone ) + + if ( child instanceof THREE.Bone ) { + child.update( this.identityMatrix, false, camera ); - else - child.update( this.globalMatrix, forceUpdate, camera ); - + + } else { + + child.update( this.matrixWorld, forceUpdate, camera ); + + } + } } diff --git a/src/objects/Sound3D.js b/src/objects/Sound3D.js index e8818b93..9400f3cf 100644 --- a/src/objects/Sound3D.js +++ b/src/objects/Sound3D.js @@ -146,13 +146,13 @@ THREE.Sound3D.prototype.calculateVolumeAndPan = function ( cameraRelativePositio }; -THREE.Sound3D.prototype.update = function ( parentGlobalMatrix, forceUpdate, camera ) { +THREE.Sound3D.prototype.update = function ( parentMatrixWorld, forceUpdate, camera ) { // update local (rotation/scale is not used) if ( this.matrixAutoUpdate ) { - this.localMatrix.setPosition( this.position ); + this.matrix.setPosition( this.position ); forceUpdate = true; } @@ -162,13 +162,13 @@ THREE.Sound3D.prototype.update = function ( parentGlobalMatrix, forceUpdate, cam if ( forceUpdate || this.matrixNeedsUpdate ) { - if ( parentGlobalMatrix ) { + if ( parentMatrixWorld ) { - this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); + this.matrixWorld.multiply( parentMatrixWorld, this.matrix ); } else { - this.globalMatrix.copy( this.localMatrix ); + this.matrixWorld.copy( this.matrix ); } @@ -184,7 +184,7 @@ THREE.Sound3D.prototype.update = function ( parentGlobalMatrix, forceUpdate, cam for ( i = 0; i < l; i++ ) { - this.children[ i ].update( this.globalMatrix, forceUpdate, camera ); + this.children[ i ].update( this.matrixWorld, forceUpdate, camera ); } diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js index 80ec291d..63f17e16 100644 --- a/src/renderers/CanvasRenderer.js +++ b/src/renderers/CanvasRenderer.js @@ -524,7 +524,7 @@ THREE.CanvasRenderer = function () { if ( material.env_map.mapping instanceof THREE.SphericalReflectionMapping ) { - var cameraMatrix = camera.globalMatrix; + var cameraMatrix = camera.matrixWorld; _vector3.copy( element.vertexNormalsWorld[ 0 ] ); _uv1x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5; diff --git a/src/renderers/Projector.js b/src/renderers/Projector.js index dc40a51f..b66ebe96 100644 --- a/src/renderers/Projector.js +++ b/src/renderers/Projector.js @@ -48,8 +48,6 @@ THREE.Projector = function() { _object = _objectPool[ _objectCount ] = _objectPool[ _objectCount ] || new THREE.RenderableObject(); _vector3.copy( object.position ); - //matrix = object.globalMatrix; - //_vector3.set( matrix.n14, matrix.n24, matrix.n34 ); _projScreenMatrix.multiplyVector3( _vector3 ); _object.object = object; @@ -82,7 +80,7 @@ THREE.Projector = function() { camera.matrixAutoUpdate && camera.update(); - _projScreenMatrix.multiply( camera.projectionMatrix, camera.globalMatrix ); + _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorld ); computeFrustum( _projScreenMatrix ); scene.update( undefined, false, camera ); @@ -97,7 +95,7 @@ THREE.Projector = function() { object.matrixAutoUpdate && object.updateMatrix(); - objectMatrix = object.globalMatrix; + objectMatrix = object.matrixWorld; objectMatrixRotation = object.matrixRotation; objectMaterials = object.materials; @@ -377,7 +375,7 @@ THREE.Projector = function() { this.unprojectVector = function ( vector, camera ) { - var matrix = THREE.Matrix4.makeInvert( camera.globalMatrix ); + var matrix = THREE.Matrix4.makeInvert( camera.matrixWorld ); matrix.multiplySelf( THREE.Matrix4.makeInvert( camera.projectionMatrix ) ); @@ -413,7 +411,7 @@ THREE.Projector = function() { function isInFrustum( object ) { - var distance, matrix = object.globalMatrix, + var distance, matrix = object.matrixWorld, radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) ); for ( var i = 0; i < 6; i ++ ) { diff --git a/src/renderers/SoundRenderer.js b/src/renderers/SoundRenderer.js index ddec7e0d..04ae7f5f 100644 --- a/src/renderers/SoundRenderer.js +++ b/src/renderers/SoundRenderer.js @@ -23,17 +23,15 @@ THREE.SoundRenderer = function() { var sounds = scene.sounds; var s, l = sounds.length; - //camera.globalMatrix.extractPositionVector( this.cameraPosition ); - for ( s = 0; s < l; s++ ) { sound = sounds[ s ]; this.soundPosition.set( - sound.globalMatrix.n14, - sound.globalMatrix.n24, - sound.globalMatrix.n34 + sound.matrixWorld.n14, + sound.matrixWorld.n24, + sound.matrixWorld.n34 ); diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index ae367b72..a966a577 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -1131,7 +1131,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( object.sortParticles ) { - _projScreenMatrix.multiplySelf( object.globalMatrix ); + _projScreenMatrix.multiplySelf( object.matrixWorld ); for ( v = 0; v < vl; v++ ) { @@ -1750,7 +1750,7 @@ THREE.WebGLRenderer = function ( parameters ) { function isInFrustum( object ) { - var distance, matrix = object.globalMatrix, + var distance, matrix = object.matrixWorld, radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) ); for ( var i = 0; i < 6; i ++ ) { @@ -1858,11 +1858,11 @@ THREE.WebGLRenderer = function ( parameters ) { camera.matrixAutoUpdate && camera.update(); - camera.globalMatrix.flattenToArray( _viewMatrixArray ); + camera.matrixWorld.flattenToArray( _viewMatrixArray ); camera.projectionMatrix.flattenToArray( _projectionMatrixArray ); camera.inverseMatrix.flattenToArray( _cameraInverseMatrixArray ); - _projScreenMatrix.multiply( camera.projectionMatrix, camera.globalMatrix ); + _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorld ); computeFrustum( _projScreenMatrix ); if( THREE.AnimationHandler ) THREE.AnimationHandler.update(); @@ -1892,7 +1892,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) { - object.globalMatrix.flattenToArray( object._objectMatrixArray ); + object.matrixWorld.flattenToArray( object._objectMatrixArray ); setupMatrices( object, camera ); @@ -1940,7 +1940,7 @@ THREE.WebGLRenderer = function ( parameters ) { if( object.matrixAutoUpdate ) { - object.globalMatrix.flattenToArray( object._objectMatrixArray ); + object.matrixWorld.flattenToArray( object._objectMatrixArray ); } @@ -2093,7 +2093,7 @@ THREE.WebGLRenderer = function ( parameters ) { object._modelViewMatrixArray = new Float32Array( 16 ); object._objectMatrixArray = new Float32Array( 16 ); - object.globalMatrix.flattenToArray( object._objectMatrixArray ); + object.matrixWorld.flattenToArray( object._objectMatrixArray ); } @@ -2297,7 +2297,7 @@ THREE.WebGLRenderer = function ( parameters ) { function setupMatrices ( object, camera ) { - object._modelViewMatrix.multiplyToArray( camera.globalMatrix, object.globalMatrix, object._modelViewMatrixArray ); + object._modelViewMatrix.multiplyToArray( camera.matrixWorld, object.matrixWorld, object._modelViewMatrixArray ); THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray ); }; diff --git a/src/renderers/WebGLRenderer2.js b/src/renderers/WebGLRenderer2.js index e50325ae..b2cb5f80 100644 --- a/src/renderers/WebGLRenderer2.js +++ b/src/renderers/WebGLRenderer2.js @@ -101,7 +101,7 @@ THREE.WebGLRenderer2 = function ( antialias ) { // Setup camera matrices - _viewMatrixArray.set( camera.globalMatrix.flatten() ); + _viewMatrixArray.set( camera.matrixWorld.flatten() ); _projectionMatrixArray.set( camera.projectionMatrix.flatten() ); _currentProgram = null; @@ -131,9 +131,9 @@ THREE.WebGLRenderer2 = function ( antialias ) { // Setup object matrices - object.globalMatrix.flattenToArray( _objectMatrixArray ) - - _modelViewMatrix.multiply( camera.globalMatrix, object.globalMatrix ); + object.matrixWorld.flattenToArray( _objectMatrixArray ) + + _modelViewMatrix.multiply( camera.matrixWorld, object.matrixWorld ); _modelViewMatrix.flattenToArray( _modelViewMatrixArray ); _normalMatrix = THREE.Matrix4.makeInvert3x3( _modelViewMatrix ).transpose();