|
@@ -49,7 +49,7 @@ this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y
|
|
|
THREE.Camera=function(a,c,f,h){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,c,f,h);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};
|
|
|
THREE.Light=function(a){this.color=new THREE.Color(-16777216|a)};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(0,0,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
|
|
|
-THREE.Object3D=function(){this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixTranslation=new THREE.Matrix4;this.matrixRotation=new THREE.Matrix4;this.matrixScale=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.matrixRotation=THREE.Matrix4.rotationXMatrix(this.rotation.x);
|
|
|
+THREE.Object3D=function(){this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixTranslation=new THREE.Matrix4;this.matrixRotation=new THREE.Matrix4;this.matrixScale=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.matrixRotation=THREE.Matrix4.rotationXMatrix(this.rotation.x);
|
|
|
this.matrixRotation.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.matrixRotation.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.matrixScale=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.matrixRotation);this.matrix.multiplySelf(this.matrixScale)}};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};
|
|
|
THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c instanceof Array?c:[c]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
|
|
|
THREE.Mesh=function(a,c,f){THREE.Object3D.call(this);this.geometry=a;this.material=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.materialFaceGroup={};this.sortFacesByMaterial();f&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;
|
|
@@ -75,7 +75,7 @@ THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);thi
|
|
|
this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
|
|
|
THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,f,h){this.image=a;this.mapping=c!==undefined?c:THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdge;this.wrap_t=h!==undefined?h:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>)"}};THREE.UVMapping=0;
|
|
|
THREE.ReflectionMap=1;THREE.RefractionMap=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,c){this.image=a;this.mapping=c?c:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};
|
|
|
-THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
|
|
+THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){var c=this.objects.indexOf(a);c!==-1&&this.objects.splice(c,1);a.__removed=true};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
|
|
THREE.Projector=function(){function a(r,q){var l=0,Q=1,H=r.z+r.w,T=q.z+q.w,$=-r.z+r.w,t=-q.z+q.w;if(H>=0&&T>=0&&$>=0&&t>=0)return true;else if(H<0&&T<0||$<0&&t<0)return false;else{if(H<0)l=Math.max(l,H/(H-T));else if(T<0)Q=Math.min(Q,H/(H-T));if($<0)l=Math.max(l,$/($-t));else if(t<0)Q=Math.min(Q,$/($-t));if(Q<l)return false;else{r.lerpSelf(q,l);q.lerpSelf(r,1-Q);return true}}}var c=null,f,h,b=[],d,p,s=[],o,e,g=[],k,i,n=[],j=new THREE.Vector4,z=new THREE.Matrix4,C=new THREE.Matrix4,v=new THREE.Vector4,
|
|
|
L=new THREE.Vector4;this.projectScene=function(r,q){var l,Q,H,T,$,t,F,D,u,N,oa,Z,R,B;c=[];i=e=p=h=0;q.autoUpdateMatrix&&q.updateMatrix();z.multiply(q.projectionMatrix,q.matrix);$=r.objects;l=0;for(Q=$.length;l<Q;l++){t=$[l];F=t.matrix;t.autoUpdateMatrix&&t.updateMatrix();if(t instanceof THREE.Mesh){C.multiply(z,F);D=t.geometry.vertices;H=0;for(T=D.length;H<T;H++){u=D[H];N=u.positionScreen;N.copy(u.position);C.transform(N);N.multiplyScalar(1/N.w);u.__visible=N.z>0&&N.z<1}oa=t.geometry.faces;H=0;for(T=
|
|
|
oa.length;H<T;H++){Z=oa[H];if(Z instanceof THREE.Face3){u=D[Z.a];N=D[Z.b];R=D[Z.c];if(u.__visible&&N.__visible&&R.__visible)if(t.doubleSided||t.flipSided!=(R.positionScreen.x-u.positionScreen.x)*(N.positionScreen.y-u.positionScreen.y)-(R.positionScreen.y-u.positionScreen.y)*(N.positionScreen.x-u.positionScreen.x)<0){f=b[h]=b[h]||new THREE.RenderableFace3;f.v1.positionScreen.copy(u.positionScreen);f.v2.positionScreen.copy(N.positionScreen);f.v3.positionScreen.copy(R.positionScreen);f.normalWorld.copy(Z.normal);
|
|
@@ -154,11 +154,11 @@ f(e.map.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(e.map.wrap_t));
|
|
|
for(i=0;i<6;++i)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[i]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.env_map.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_CUBE_MAP,e.env_map.image.__webGLTextureCube);b.uniform1i(d.tCube,1)}b.uniform1i(d.enableCubeMap,1)}else b.uniform1i(d.enableCubeMap,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(d.position,
|
|
|
3,b.FLOAT,false,0,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);if(v){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.enableVertexAttribArray(d.uv);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0)}else b.disableVertexAttribArray(d.uv);if(j){b.lineWidth(z);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
|
|
|
g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,k,i){var n,j,z,C,v;z=0;for(C=e.material.length;z<C;z++){n=e.material[z];if(n instanceof THREE.MeshFaceMaterial){n=0;for(j=g.material.length;n<j;n++)if((v=g.material[n])&&v.blending==k&&v.opacity<1==i){this.setBlending(v.blending);this.renderBuffer(v,g)}}else if((v=n)&&v.blending==k&&v.opacity<1==i){this.setBlending(v.blending);this.renderBuffer(v,g)}}};this.render=function(e,g){var k,i;this.initWebGLObjects(e);this.autoClear&&this.clear();
|
|
|
-g.autoUpdateMatrix&&g.updateMatrix();b.uniform3f(d.cameraPosition,g.position.x,g.position.y,g.position.z);this.setupLights(e);k=0;for(i=e.__webGLObjects.length;k<i;k++){webGLObject=e.__webGLObjects[k];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.NormalBlending,false)}k=0;for(i=e.__webGLObjects.length;k<i;k++){webGLObject=e.__webGLObjects[k];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.AdditiveBlending,
|
|
|
-false);this.renderPass(webGLObject.__object,webGLObject,THREE.SubtractiveBlending,false);this.renderPass(webGLObject.__object,webGLObject,THREE.AdditiveBlending,true);this.renderPass(webGLObject.__object,webGLObject,THREE.SubtractiveBlending,true);this.renderPass(webGLObject.__object,webGLObject,THREE.NormalBlending,true)}};this.initWebGLObjects=function(e){var g,k,i,n,j;if(!e.__webGLObjects)e.__webGLObjects=[];g=0;for(k=e.objects.length;g<k;g++){i=e.objects[g];if(i instanceof THREE.Mesh)for(n in i.materialFaceGroup){j=
|
|
|
-i.materialFaceGroup[n];if(!j.__webGLVertexBuffer){this.createBuffers(i,n);j.__object=i;e.__webGLObjects.push(j)}}}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();p.multiply(g.matrix,e.matrix);d.viewMatrixArray=new Float32Array(g.matrix.flatten());d.modelViewMatrixArray=new Float32Array(p.flatten());d.projectionMatrixArray=new Float32Array(g.projectionMatrix.flatten());s=THREE.Matrix4.makeInvert3x3(p).transpose();d.normalMatrixArray=new Float32Array(s.m);b.uniformMatrix4fv(d.viewMatrix,
|
|
|
-false,d.viewMatrixArray);b.uniformMatrix4fv(d.modelViewMatrix,false,d.modelViewMatrixArray);b.uniformMatrix4fv(d.projectionMatrix,false,d.projectionMatrixArray);b.uniformMatrix3fv(d.normalMatrix,false,d.normalMatrixArray);b.uniformMatrix4fv(d.objMatrix,false,new Float32Array(e.matrix.flatten()))};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);
|
|
|
-b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,g){if(e){!g||g=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)}};
|
|
|
+g.autoUpdateMatrix&&g.updateMatrix();b.uniform3f(d.cameraPosition,g.position.x,g.position.y,g.position.z);this.setupLights(e);k=0;for(i=e.__webGLObjects.length;k<i;k++){webGLObject=e.__webGLObjects[k];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.NormalBlending,false)}}k=0;for(i=e.__webGLObjects.length;k<i;k++){webGLObject=e.__webGLObjects[k];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,
|
|
|
+g);this.renderPass(webGLObject.__object,webGLObject,THREE.AdditiveBlending,false);this.renderPass(webGLObject.__object,webGLObject,THREE.SubtractiveBlending,false);this.renderPass(webGLObject.__object,webGLObject,THREE.AdditiveBlending,true);this.renderPass(webGLObject.__object,webGLObject,THREE.SubtractiveBlending,true);this.renderPass(webGLObject.__object,webGLObject,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var g,k,i,n,j;if(!e.__webGLObjects)e.__webGLObjects=[];g=0;for(k=
|
|
|
+e.objects.length;g<k;g++){i=e.objects[g];if(i instanceof THREE.Mesh)for(n in i.materialFaceGroup){j=i.materialFaceGroup[n];if(!j.__webGLVertexBuffer){this.createBuffers(i,n);j.__object=i;e.__webGLObjects.push(j)}}}for(g=e.__webGLObjects.length-1;g>=0;g--){i=e.__webGLObjects[g].__object;i.__removed&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();p.multiply(g.matrix,e.matrix);d.viewMatrixArray=new Float32Array(g.matrix.flatten());d.modelViewMatrixArray=
|
|
|
+new Float32Array(p.flatten());d.projectionMatrixArray=new Float32Array(g.projectionMatrix.flatten());s=THREE.Matrix4.makeInvert3x3(p).transpose();d.normalMatrixArray=new Float32Array(s.m);b.uniformMatrix4fv(d.viewMatrix,false,d.viewMatrixArray);b.uniformMatrix4fv(d.modelViewMatrix,false,d.modelViewMatrixArray);b.uniformMatrix4fv(d.projectionMatrix,false,d.projectionMatrixArray);b.uniformMatrix3fv(d.normalMatrix,false,d.normalMatrixArray);b.uniformMatrix4fv(d.objMatrix,false,new Float32Array(e.matrix.flatten()))};
|
|
|
+this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,g){if(e){!g||g=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)}};
|
|
|
THREE.RenderableFace3=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.material=this.color=this.z=null};
|
|
|
THREE.RenderableFace4=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.v4=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.material=this.color=this.z=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=this.color=null};
|
|
|
THREE.RenderableLine=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=this.color=this.z=null};
|