提交 45ec0f32 编写于 作者: M Mr.doob

Reverted Camera::FOV,zNear,zFar to Camera::fov,near,far.

Most of the examples or working again as usual. Only `webgl_scene_test.html` and `webgl_ribbons.html` left.
上级 3dc37702
此差异已折叠。
此差异已折叠。
......@@ -54,12 +54,12 @@ THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld
THREE.Face3=function(a,b,c,e,d){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=d instanceof Array?d:[d]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};
THREE.Camera=function(a,b,c,e,d,f){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=e||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,i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);if(i)this.tmpVec.y=
0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(g,i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);if(i)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.zNear,this.zFar)};
THREE.Camera=function(a,b,c,e,d){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=e||2E3;this.screenCenterY=this.screenCenterX=0;this.target=d||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(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);if(g)this.tmpVec.y=
0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);if(g)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.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,e=a.globalMatrix.n34,d=this.inverseMatrix,f=a.boundRadius*a.boundRadiusScale,g=d.n31*b+d.n32*c+d.n33*e+d.n34;if(g-f>-this.zNear)return!1;if(g+f<-this.zFar)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.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,e=a.globalMatrix.n34,d=this.inverseMatrix,f=a.boundRadius*a.boundRadiusScale,g=d.n31*b+d.n32*c+d.n33*e+d.n34;if(g-f>-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<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
......@@ -67,7 +67,7 @@ THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light
THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
THREE.Projector=function(){function a(w,u){return u.z-w.z}function b(w,u){var D=0,A=1,E=w.z+w.w,z=u.z+u.w,v=-w.z+w.w,t=-u.z+u.w;if(E>=0&&z>=0&&v>=0&&t>=0)return!0;else if(E<0&&z<0||v<0&&t<0)return!1;else{if(E<0)D=Math.max(D,E/(E-z));else z<0&&(A=Math.min(A,E/(E-z)));if(v<0)D=Math.max(D,v/(v-t));else t<0&&(A=Math.min(A,v/(v-t)));if(A<D)return!1;else{w.lerpSelf(u,D);u.lerpSelf(w,1-A);return!0}}}var c,e,d=[],f,g,i,h=[],j,m,n=[],l,o,q=[],r=new THREE.Vector4,p=new THREE.Vector4,k=new THREE.Matrix4,C=new THREE.Matrix4,
y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,G=new THREE.Vector4,J;this.projectObjects=function(w,u,D){u=[];var A,E,z;e=0;E=w.objects;w=0;for(A=E.length;w<A;w++){z=E[w];var v;if(!(v=!z.visible))if(v=z instanceof THREE.Mesh){a:{v=void 0;for(var t=z.globalMatrix,I=-z.geometry.boundingSphere.radius*Math.max(z.scale.x,Math.max(z.scale.y,z.scale.z)),s=0;s<6;s++){v=y[s].x*t.n14+y[s].y*t.n24+y[s].z*t.n34+y[s].w;if(v<=
I){v=!1;break a}}v=!0}v=!v}if(!v){c=d[e]=d[e]||new THREE.RenderableObject;r.copy(z.position);k.multiplyVector3(r);c.object=z;c.z=r.z;u.push(c);e++}}D&&u.sort(a);return u};this.projectScene=function(w,u,D){var A=[],E=u.zNear,z=u.zFar,v,t,I,s,H,N,x,P,Q,R,S,O,L,B,K,M;i=m=o=0;u.matrixAutoUpdate&&u.update();k.multiply(u.projectionMatrix,u.globalMatrix);y[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);y[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);y[2].set(k.n41+k.n21,k.n42+k.n22,k.n43+
I){v=!1;break a}}v=!0}v=!v}if(!v){c=d[e]=d[e]||new THREE.RenderableObject;r.copy(z.position);k.multiplyVector3(r);c.object=z;c.z=r.z;u.push(c);e++}}D&&u.sort(a);return u};this.projectScene=function(w,u,D){var A=[],E=u.near,z=u.far,v,t,I,s,H,N,x,P,Q,R,S,O,L,B,K,M;i=m=o=0;u.matrixAutoUpdate&&u.update();k.multiply(u.projectionMatrix,u.globalMatrix);y[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);y[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);y[2].set(k.n41+k.n21,k.n42+k.n22,k.n43+
k.n23,k.n44+k.n24);y[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);y[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);y[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(v=0;v<6;v++){N=y[v];N.divideScalar(Math.sqrt(N.x*N.x+N.y*N.y+N.z*N.z))}w.update(undefined,!1,u);N=this.projectObjects(w,u,!0);w=0;for(v=N.length;w<v;w++){x=N[w].object;if(x.visible){x.matrixAutoUpdate&&x.updateMatrix();P=x.globalMatrix;S=x.matrixRotation;Q=x.materials;R=x.overdraw;if(x instanceof THREE.Mesh){O=
x.geometry;L=O.vertices;t=0;for(I=L.length;t<I;t++){B=L[t];B.positionWorld.copy(B.position);P.multiplyVector3(B.positionWorld);s=B.positionScreen;s.copy(B.positionWorld);k.multiplyVector4(s);s.x/=s.w;s.y/=s.w;B.__visible=s.z>E&&s.z<z}O=O.faces;t=0;for(I=O.length;t<I;t++){B=O[t];if(B instanceof THREE.Face3){s=L[B.a];H=L[B.b];K=L[B.c];if(s.__visible&&H.__visible&&K.__visible&&(x.doubleSided||x.flipSided!=(K.positionScreen.x-s.positionScreen.x)*(H.positionScreen.y-s.positionScreen.y)-(K.positionScreen.y-
s.positionScreen.y)*(H.positionScreen.x-s.positionScreen.x)<0)){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(s.positionWorld);f.v2.positionWorld.copy(H.positionWorld);f.v3.positionWorld.copy(K.positionWorld);f.v1.positionScreen.copy(s.positionScreen);f.v2.positionScreen.copy(H.positionScreen);f.v3.positionScreen.copy(K.positionScreen);f.normalWorld.copy(B.normal);S.multiplyVector3(f.normalWorld);f.centroidWorld.copy(B.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
......
......@@ -11,8 +11,8 @@ else n.type=="ascii_mesh"&&C.loadAscii({model:n.url,callback:e(j)})}for(p in A.t
undefined)n.mag_filter=THREE[j.mag_filter]}F.textures[p]=n}for(l in A.materials){p=A.materials[l];for(x in p.parameters)if(x=="env_map"||x=="map"||x=="light_map")p.parameters[x]=F.textures[p.parameters[x]];else if(x=="shading")p.parameters[x]=p.parameters[x]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(x=="blending")p.parameters[x]=THREE[p.parameters[x]]?THREE[p.parameters[x]]:THREE.NormalBlending;else x=="combine"&&(p.parameters[x]=p.parameters[x]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);
p=new THREE[p.type](p.parameters);F.materials[l]=p}c();d(F)}},addMesh:function(a,d,b,f,g,c,e,h,j,l){d=new THREE.Mesh(d,l);d.scale.x=d.scale.y=d.scale.z=b;d.position.x=f;d.position.y=g;d.position.z=c;d.rotation.x=e;d.rotation.y=h;d.rotation.z=j;a.addObject(d);return d},addPanoramaCubeWebGL:function(a,d,b){var f=ShaderUtils.lib.cube;f.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragment_shader:f.fragment_shader,vertex_shader:f.vertex_shader,uniforms:f.uniforms});d=new THREE.Mesh(new Cube(d,
d,d,1,1,null,!0),b);a.addObject(d);return d},addPanoramaCube:function(a,d,b){var f=[];f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));d=new THREE.Mesh(new Cube(d,
d,d,1,1,f,!0),new THREE.MeshFaceMaterial);a.addObject(d);return d},addPanoramaCubePlanes:function(a,d,b){var f=d/2;d=new Plane(d,d);var g=Math.PI/2,c=Math.PI;SceneUtils.addMesh(a,d,1,0,0,-f,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,d,1,-f,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,d,1,f,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,d,1,0,f,0,g,0,c,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
SceneUtils.addMesh(a,d,1,0,-f,0,-g,0,c,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
d,d,1,1,f,!0),new THREE.MeshFaceMaterial);a.addObject(d);return d},addPanoramaCubePlanes:function(a,d,b){var f=d/2;d=new Plane(d,d);var g=Math.PI,c=Math.PI/2;SceneUtils.addMesh(a,d,1,0,0,-f,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,d,1,-f,0,0,0,c,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,d,1,f,0,0,0,-c,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,d,1,0,f,0,c,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
SceneUtils.addMesh(a,d,1,0,-f,0,-c,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragment_shader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
......
......@@ -66,12 +66,12 @@ z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.
this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var m=[];b=0;for(c=n.length;b<c;b++)n[b]==undefined?m.push("undefined"):m.push(n[b].id);return m.join("_")}var b,c,d,e,f,h,i,g,k={};d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];
h=f.materials;i=a(h);k[i]==undefined&&(k[i]={hash:i,counter:0});g=k[i].hash+"_"+k[i].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0});f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+f>65535){k[i].counter+=1;g=k[i].hash+"_"+k[i].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0})}this.geometryChunks[g].faces.push(d);this.geometryChunks[g].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
THREE.Camera=function(a,b,c,d,e,f){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=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(h,i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);if(i)this.tmpVec.y=
0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(h,i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);if(i)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.zNear,this.zFar)};
THREE.Camera=function(a,b,c,d,e){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=e||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(f,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);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(f,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);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.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,d=a.globalMatrix.n34,e=this.inverseMatrix,f=a.boundRadius*a.boundRadiusScale,h=e.n31*b+e.n32*c+e.n33*d+e.n34;if(h-f>-this.zNear)return!1;if(h+f<-this.zFar)return!1;h-=f;var i=this.projectionMatrix,g=1/(i.n43*h),k=g*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*g*this.screenCenterY;
THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,d=a.globalMatrix.n34,e=this.inverseMatrix,f=a.boundRadius*a.boundRadiusScale,h=e.n31*b+e.n32*c+e.n33*d+e.n34;if(h-f>-this.near)return!1;if(h+f<-this.far)return!1;h-=f;var i=this.projectionMatrix,g=1/(i.n43*h),k=g*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*g*this.screenCenterY;
if(b+f<-this.screenCenterY)return!1;if(b-f>this.screenCenterY)return!1;a.screenPosition.set(n,b,h,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};
......@@ -110,7 +110,7 @@ THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light
THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
THREE.Projector=function(){function a(A,w){return w.z-A.z}function b(A,w){var J=0,E=1,K=A.z+A.w,H=w.z+w.w,r=-A.z+A.w,x=-w.z+w.w;if(K>=0&&H>=0&&r>=0&&x>=0)return!0;else if(K<0&&H<0||r<0&&x<0)return!1;else{if(K<0)J=Math.max(J,K/(K-H));else H<0&&(E=Math.min(E,K/(K-H)));if(r<0)J=Math.max(J,r/(r-x));else x<0&&(E=Math.min(E,r/(r-x)));if(E<J)return!1;else{A.lerpSelf(w,J);w.lerpSelf(A,1-E);return!0}}}var c,d,e=[],f,h,i,g=[],k,n,m=[],l,o,q=[],u=new THREE.Vector4,s=new THREE.Vector4,j=new THREE.Matrix4,I=new THREE.Matrix4,
p=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],z=new THREE.Vector4,D=new THREE.Vector4,M;this.projectObjects=function(A,w,J){w=[];var E,K,H;d=0;K=A.objects;A=0;for(E=K.length;A<E;A++){H=K[A];var r;if(!(r=!H.visible))if(r=H instanceof THREE.Mesh){a:{r=void 0;for(var x=H.globalMatrix,O=-H.geometry.boundingSphere.radius*Math.max(H.scale.x,Math.max(H.scale.y,H.scale.z)),v=0;v<6;v++){r=p[v].x*x.n14+p[v].y*x.n24+p[v].z*x.n34+p[v].w;if(r<=
O){r=!1;break a}}r=!0}r=!r}if(!r){c=e[d]=e[d]||new THREE.RenderableObject;u.copy(H.position);j.multiplyVector3(u);c.object=H;c.z=u.z;w.push(c);d++}}J&&w.sort(a);return w};this.projectScene=function(A,w,J){var E=[],K=w.zNear,H=w.zFar,r,x,O,v,L,F,B,P,R,C,y,N,Q,t,G,S;i=n=o=0;w.matrixAutoUpdate&&w.update();j.multiply(w.projectionMatrix,w.globalMatrix);p[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);p[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);p[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+
O){r=!1;break a}}r=!0}r=!r}if(!r){c=e[d]=e[d]||new THREE.RenderableObject;u.copy(H.position);j.multiplyVector3(u);c.object=H;c.z=u.z;w.push(c);d++}}J&&w.sort(a);return w};this.projectScene=function(A,w,J){var E=[],K=w.near,H=w.far,r,x,O,v,L,F,B,P,R,C,y,N,Q,t,G,S;i=n=o=0;w.matrixAutoUpdate&&w.update();j.multiply(w.projectionMatrix,w.globalMatrix);p[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);p[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);p[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+
j.n23,j.n44+j.n24);p[3].set(j.n41-j.n21,j.n42-j.n22,j.n43-j.n23,j.n44-j.n24);p[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);p[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);for(r=0;r<6;r++){F=p[r];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}A.update(undefined,!1,w);F=this.projectObjects(A,w,!0);A=0;for(r=F.length;A<r;A++){B=F[A].object;if(B.visible){B.matrixAutoUpdate&&B.updateMatrix();P=B.globalMatrix;y=B.matrixRotation;R=B.materials;C=B.overdraw;if(B instanceof THREE.Mesh){N=
B.geometry;Q=N.vertices;x=0;for(O=Q.length;x<O;x++){t=Q[x];t.positionWorld.copy(t.position);P.multiplyVector3(t.positionWorld);v=t.positionScreen;v.copy(t.positionWorld);j.multiplyVector4(v);v.x/=v.w;v.y/=v.w;t.__visible=v.z>K&&v.z<H}N=N.faces;x=0;for(O=N.length;x<O;x++){t=N[x];if(t instanceof THREE.Face3){v=Q[t.a];L=Q[t.b];G=Q[t.c];if(v.__visible&&L.__visible&&G.__visible&&(B.doubleSided||B.flipSided!=(G.positionScreen.x-v.positionScreen.x)*(L.positionScreen.y-v.positionScreen.y)-(G.positionScreen.y-
v.positionScreen.y)*(L.positionScreen.x-v.positionScreen.x)<0)){f=g[i]=g[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(v.positionWorld);f.v2.positionWorld.copy(L.positionWorld);f.v3.positionWorld.copy(G.positionWorld);f.v1.positionScreen.copy(v.positionScreen);f.v2.positionScreen.copy(L.positionScreen);f.v3.positionScreen.copy(G.positionScreen);f.normalWorld.copy(t.normal);y.multiplyVector3(f.normalWorld);f.centroidWorld.copy(t.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
......
......@@ -66,12 +66,12 @@ z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.
this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(w){var x=[];c=0;for(d=w.length;c<d;c++)w[c]==undefined?x.push("undefined"):x.push(w[c].id);return x.join("_")}var c,d,f,g,j,k,o,i,s={};f=0;for(g=this.faces.length;f<g;f++){j=this.faces[f];
k=j.materials;o=a(k);s[o]==undefined&&(s[o]={hash:o,counter:0});i=s[o].hash+"_"+s[o].counter;this.geometryChunks[i]==undefined&&(this.geometryChunks[i]={faces:[],materials:k,vertices:0});j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+j>65535){s[o].counter+=1;i=s[o].hash+"_"+s[o].counter;this.geometryChunks[i]==undefined&&(this.geometryChunks[i]={faces:[],materials:k,vertices:0})}this.geometryChunks[i].faces.push(f);this.geometryChunks[i].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
THREE.Camera=function(a,c,d,f,g,j){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=c||1;this.zNear=d||0.1;this.zFar=f||2E3;this.screenCenterY=this.screenCenterX=0;this.target=j||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(k,o){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.tmpVec.crossSelf(this.up);if(o)this.tmpVec.y=
0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(k,o){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);if(o)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.zNear,this.zFar)};
THREE.Camera=function(a,c,d,f,g){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=d||0.1;this.far=f||2E3;this.screenCenterY=this.screenCenterX=0;this.target=g||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(j,k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);if(k)this.tmpVec.y=
0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(j,k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);if(k)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,c,d){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);c=!0}else{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;THREE.Matrix4.makeInvert(this.globalMatrix,
this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,c,d)};
THREE.Camera.prototype.frustumContains=function(a){var c=a.globalMatrix.n14,d=a.globalMatrix.n24,f=a.globalMatrix.n34,g=this.inverseMatrix,j=a.boundRadius*a.boundRadiusScale,k=g.n31*c+g.n32*d+g.n33*f+g.n34;if(k-j>-this.zNear)return!1;if(k+j<-this.zFar)return!1;k-=j;var o=this.projectionMatrix,i=1/(o.n43*k),s=i*this.screenCenterX,w=(g.n11*c+g.n12*d+g.n13*f+g.n14)*o.n11*s;j=o.n11*j*s;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.frustumContains=function(a){var c=a.globalMatrix.n14,d=a.globalMatrix.n24,f=a.globalMatrix.n34,g=this.inverseMatrix,j=a.boundRadius*a.boundRadiusScale,k=g.n31*c+g.n32*d+g.n33*f+g.n34;if(k-j>-this.near)return!1;if(k+j<-this.far)return!1;k-=j;var o=this.projectionMatrix,i=1/(o.n43*k),s=i*this.screenCenterX,w=(g.n11*c+g.n12*d+g.n13*f+g.n14)*o.n11*s;j=o.n11*j*s;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};
......@@ -125,7 +125,7 @@ THREE.FogExp2)q.fogDensity.value=m.density}if(h instanceof THREE.MeshPhongMateri
O[G+2]=M.z;u+=1}else if(G instanceof THREE.PointLight){G=pa*3;N[G]=y.r*fa;N[G+1]=y.g*fa;N[G+2]=y.b*fa;ta[G]=M.x;ta[G+1]=M.y;ta[G+2]=M.z;pa+=1}}for(m=u*3;m<Q.length;m++)Q[m]=0;for(m=pa*3;m<N.length;m++)N[m]=0;$.point.length=pa;$.directional.length=u;$.ambient[0]=F;$.ambient[1]=I;$.ambient[2]=S;n=da.lights;q.enableLighting.value=n.directional.length+n.point.length;q.ambientLightColor.value=n.ambient;q.directionalLightColor.value=n.directional.colors;q.directionalLightDirection.value=n.directional.positions;
q.pointLightColor.value=n.point.colors;q.pointLightPosition.value=n.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){q.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity;q.map.texture=h.map;q.light_map.texture=h.light_map;q.env_map.texture=h.env_map;q.reflectivity.value=h.reflectivity;q.refraction_ratio.value=h.refraction_ratio;q.combine.value=h.combine;q.useRefract.value=
h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof THREE.LineBasicMaterial){q.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){q.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity;q.size.value=h.size;q.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){q.ambient.value.setRGB(h.ambient.r,h.ambient.g,
h.ambient.b);q.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);q.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){q.mNear.value=e.zNear;q.mFar.value=e.zFar;q.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)q.opacity.value=h.opacity;for(var na in q)if(F=v.uniforms[na]){m=q[na];t=m.type;n=m.value;if(t=="i")b.uniform1i(F,n);else if(t=="f")b.uniform1f(F,n);else if(t=="fv1")b.uniform1fv(F,n);else if(t=="fv")b.uniform3fv(F,n);else if(t=="v2")b.uniform2f(F,
h.ambient.b);q.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);q.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){q.mNear.value=e.near;q.mFar.value=e.far;q.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)q.opacity.value=h.opacity;for(var na in q)if(F=v.uniforms[na]){m=q[na];t=m.type;n=m.value;if(t=="i")b.uniform1i(F,n);else if(t=="f")b.uniform1f(F,n);else if(t=="fv1")b.uniform1fv(F,n);else if(t=="fv")b.uniform3fv(F,n);else if(t=="v2")b.uniform2f(F,
n.x,n.y);else if(t=="v3")b.uniform3f(F,n.x,n.y,n.z);else if(t=="c")b.uniform3f(F,n.r,n.g,n.b);else if(t=="t"){b.uniform1i(F,n);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){if(m.image.length==6){if(m.needsUpdate){if(!m.image.__webGLTextureCube)m.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);
b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(t=0;t<6;++t)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image[t]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);m.needsUpdate=!1}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{if(m.needsUpdate){if(m.__wasSetOnce){b.bindTexture(b.TEXTURE_2D,
m.__webGLTexture);b.texSubImage2D(b.TEXTURE_2D,0,0,0,b.RGBA,b.UNSIGNED_BYTE,m.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,L(m.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,L(m.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,L(m.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,L(m.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}else{m.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,m.__webGLTexture);b.texImage2D(b.TEXTURE_2D,
......
......@@ -83,7 +83,7 @@
scene.addObject( plane );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
......
......@@ -25,23 +25,17 @@
<script type="text/javascript" src="../src/core/Rectangle.js"></script>
<script type="text/javascript" src="../src/core/Matrix3.js"></script>
<script type="text/javascript" src="../src/core/Matrix4.js"></script>
<script type="text/javascript" src="../src/core/Object3D.js"></script>
<script type="text/javascript" src="../src/core/Quaternion.js"></script>
<script type="text/javascript" src="../src/core/Vertex.js"></script>
<script type="text/javascript" src="../src/core/Face3.js"></script>
<script type="text/javascript" src="../src/core/Face4.js"></script>
<script type="text/javascript" src="../src/core/UV.js"></script>
<script type="text/javascript" src="../src/core/Geometry.js"></script>
<script type="text/javascript" src="../src/objects/Object3D.js"></script>
<script type="text/javascript" src="../src/objects/Particle.js"></script>
<script type="text/javascript" src="../src/objects/ParticleSystem.js"></script>
<script type="text/javascript" src="../src/objects/Line.js"></script>
<script type="text/javascript" src="../src/objects/Mesh.js"></script>
<script type="text/javascript" src="../src/objects/Bone.js"></script>
<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
<script type="text/javascript" src="../src/animation/AnimationHandler.js"></script>
<script type="text/javascript" src="../src/animation/Animation.js"></script>
<script type="text/javascript" src="../src/cameras/Camera.js"></script>
<script type="text/javascript" src="../src/cameras/QuakeCamera.js"></script>
<script type="text/javascript" src="../src/lights/Light.js"></script>
<script type="text/javascript" src="../src/lights/AmbientLight.js"></script>
<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
......@@ -68,6 +62,14 @@
<script type="text/javascript" src="../src/materials/mappings/SphericalReflectionMapping.js"></script>
<script type="text/javascript" src="../src/materials/mappings/SphericalRefractionMapping.js"></script>
<script type="text/javascript" src="../src/materials/mappings/UVMapping.js"></script>
<script type="text/javascript" src="../src/objects/Particle.js"></script>
<script type="text/javascript" src="../src/objects/ParticleSystem.js"></script>
<script type="text/javascript" src="../src/objects/Line.js"></script>
<script type="text/javascript" src="../src/objects/Mesh.js"></script>
<script type="text/javascript" src="../src/objects/Bone.js"></script>
<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
<script type="text/javascript" src="../src/objects/Sound3D.js"></script>
<script type="text/javascript" src="../src/scenes/Scene.js"></script>
<script type="text/javascript" src="../src/scenes/Fog.js"></script>
<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
......@@ -76,10 +78,24 @@
<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
<script type="text/javascript" src="../src/extras/GeometryUtils.js"></script>
<script type="text/javascript" src="../src/extras/ImageUtils.js"></script>
<script type="text/javascript" src="../src/extras/SceneUtils.js"></script>
<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
<script type="text/javascript" src="../src/extras/primitives/Cube.js"></script>
<script type="text/javascript" src="../src/extras/primitives/Cylinder.js"></script>
<script type="text/javascript" src="../src/extras/primitives/Plane.js"></script>
<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
<script type="text/javascript" src="../src/extras/primitives/Torus.js"></script>
<script type="text/javascript" src="../src/extras/primitives/Icosahedron.js"></script>
<script type="text/javascript" src="../src/extras/primitives/LathedObject.js"></script>
<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
......
......@@ -15,7 +15,7 @@
font-weight: bold;
text-align:center;
}
a {
color:#0078ff;
}
......@@ -27,7 +27,7 @@
padding: 5px;
z-index:100;
}
</style>
</head>
<body>
......@@ -36,8 +36,9 @@
<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - webgl video demo. playing <a href="http://durian.blender.org/" target="_blank">sintel</a> trailer
</div>
<script type="text/javascript" src="js/ThreeExtrasVideo.js"></script>
<script type="text/javascript" src="../build/Three.js"></script>
<script type="text/javascript" src="js/Detector.js"></script>
<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
<script type="text/javascript" src="js/Stats.js"></script>
......@@ -48,7 +49,7 @@
<script type="text/javascript">
if ( ! THREE.Detector.webgl ) THREE.Detector.addGetWebGLMessage();
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var container, stats;
......@@ -63,15 +64,15 @@
var windowHalfY = window.innerHeight / 2;
var postprocessing = { enabled: true };
var cube_count,
meshes = [],
materials = [],
xgrid = 20,
ygrid = 10;
init();
animate();
......@@ -84,7 +85,7 @@
camera.position.z = 500;
scene = new THREE.Scene();
var light = new THREE.DirectionalLight( 0xffffff );
light.position.set( 0.5, 1, 1 );
light.position.normalize();
......@@ -92,11 +93,11 @@
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
video = document.getElementById( 'video' );
//video.volume = 0;
//video.muted = true;
......@@ -106,13 +107,13 @@
//
var i, j, ux, uy, ox, oy,
var i, j, ux, uy, ox, oy,
geometry,
xsize, ysize;
ux = 1 / xgrid;
uy = 1 / ygrid;
xsize = 480 / xgrid;
ysize = 204 / ygrid;
......@@ -120,22 +121,22 @@
material_base = new THREE.MeshLambertMaterial( parameters );
renderer.initMaterial( material_base, scene.lights, scene.fog );
cube_count = 0;
for( i = 0; i < xgrid; i++)
for( j = 0; j < ygrid; j++) {
ox = i;
oy = j;
geometry = new Cube( xsize, ysize, xsize );
change_uvs( geometry, ux, uy, ox, oy );
materials[ cube_count ] = new THREE.MeshLambertMaterial( parameters );
material = materials[ cube_count ];
material.program = material_base.program;
material.uniforms = Uniforms.clone( THREE.ShaderLib[ 'lambert' ].uniforms );
......@@ -143,20 +144,20 @@
material.saturation = j/ygrid;
material.color.setHSV( material.hue, material.saturation, 1 );
mesh = new THREE.Mesh( geometry, material );
mesh.position.x = ( i - xgrid/2 ) * xsize;
mesh.position.y = - ( j - ygrid/2 ) * ysize;
mesh.position.z = 0;
mesh.position.z = 0;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 1;
scene.addObject(mesh);
mesh.dx = 0.001 * ( 0.5 - Math.random() );
mesh.dy = 0.001 * ( 0.5 - Math.random() );
meshes[ cube_count ] = mesh;
cube_count += 1;
......@@ -174,26 +175,26 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
}
function change_uvs( geometry, unitx, unity, offsetx, offsety ) {
var i, j, uv;
for ( i = 0; i < geometry.uvs.length; i++ ) {
uv = geometry.uvs[ i ];
for ( j = 0; j < uv.length; j++ ) {
uv[j].u = ( uv[j].u + offsetx ) * unitx;
uv[j].v = ( uv[j].v + offsety ) * unity;
}
}
}
function initPostprocessing() {
......@@ -246,11 +247,11 @@
postprocessing.scene.addObject( postprocessing.quad );
}
function onDocumentMouseMove(event) {
mouseX = ( event.clientX - windowHalfX );
mouseY = ( event.clientY - windowHalfY ) * 0.3;
mouseY = ( event.clientY - windowHalfY ) * 0.3;
}
......@@ -264,13 +265,13 @@
stats.update();
}
var h, counter = 1;
function render() {
var time = new Date().getTime() * 0.00005;
camera.position.x += ( mouseX - camera.position.x ) * 0.05;
camera.position.y += ( - mouseY - camera.position.y ) * 0.05;
......@@ -279,22 +280,22 @@
if ( texture ) texture.needsUpdate = true;
}
for( i = 0; i < cube_count; i++ ) {
material = materials[i];
h = ( 360 * ( material.hue + time ) % 360 ) / 360;
material.color.setHSV( h, material.saturation, 1 );
}
if( counter % 1000 > 200 ) {
for( i = 0; i < cube_count; i++ ) {
mesh = meshes[i];
mesh.rotation.x += 10 * mesh.dx;
mesh.rotation.y += 10 * mesh.dy;
......@@ -303,24 +304,24 @@
mesh.position.z += 400 * mesh.dx;
}
}
if( counter % 1000 == 0 ) {
for( i = 0; i < cube_count; i++ ) {
mesh = meshes[i];
mesh.dx *= -1;
mesh.dy *= -1;
}
}
counter++;
if ( postprocessing.enabled ) {
renderer.clear();
......@@ -365,7 +366,7 @@
renderer.render( scene, camera );
}
}
......
......@@ -3,19 +3,22 @@
* @author mikael emtinger / http://gomo.se/
*/
THREE.Camera = function( FOV, aspect, zNear, zFar, target ) {
THREE.Camera = function( fov, aspect, near, far, target ) {
THREE.Object3D.call( this );
this.FOV = FOV || 50;
this.aspect = aspect || 1.0;
this.zNear = zNear || 0.1;
this.zFar = zFar || 2000;
this.screenCenterX = 0;
this.screenCenterY = 0;
this.target = target || new THREE.Object3D();
this.useTarget = true;
this.up = new THREE.Vector3( 0, 1, 0 );
this.fov = fov || 50;
this.aspect = aspect || 1.0;
this.near = near || 0.1;
this.far = far || 2000;
this.screenCenterX = 0;
this.screenCenterY = 0;
this.target = target || new THREE.Object3D();
this.useTarget = true;
this.up = new THREE.Vector3( 0, 1, 0 );
this.inverseMatrix = new THREE.Matrix4();
this.projectionMatrix = null;
......@@ -30,7 +33,7 @@ THREE.Camera = function( FOV, aspect, zNear, zFar, target ) {
this.tmpVec.crossSelf( this.up );
if ( nofly ) this.tmpVec.y = 0;
this.position.addSelf( this.tmpVec );
this.target.position.addSelf( this.tmpVec );
......@@ -47,7 +50,7 @@ THREE.Camera = function( FOV, aspect, zNear, zFar, target ) {
this.tmpVec.sub( this.target.position, this.position ).normalize().multiplyScalar( amount );
if ( nofly ) this.tmpVec.y = 0;
this.position.subSelf( this.tmpVec );
this.target.position.subSelf( this.tmpVec );
......@@ -57,9 +60,9 @@ THREE.Camera = function( FOV, aspect, zNear, zFar, target ) {
}
THREE.Camera.prototype = new THREE.Object3D();
THREE.Camera.prototype = new THREE.Object3D();
THREE.Camera.prototype.constructor = THREE.Camera;
THREE.Camera.prototype.supr = THREE.Object3D.prototype;
THREE.Camera.prototype.supr = THREE.Object3D.prototype;
/*
......@@ -70,7 +73,7 @@ THREE.Camera.prototype.supr = THREE.Object3D.prototype;
THREE.Camera.prototype.updateProjectionMatrix = function() {
this.projectionMatrix = THREE.Matrix4.makePerspective( this.FOV, this.aspect, this.zNear, this.zFar );
this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far );
}
......@@ -152,12 +155,17 @@ THREE.Camera.prototype.frustumContains = function( object3D ) {
var radius = object3D.boundRadius * object3D.boundRadiusScale;
var vz1 = ( inverse.n31 * vx0 + inverse.n32 * vy0 + inverse.n33 * vz0 + inverse.n34 );
if( vz1 - radius > -this.zNear )
if( vz1 - radius > - this.near ) {
return false;
if( vz1 + radius < -this.zFar )
}
if( vz1 + radius < - this.far ) {
return false;
}
// check x
......
var SceneUtils = {
loadScene : function( url, callback_sync, callback_async, callback_progress ) {
var worker = new Worker( url );
......@@ -9,22 +9,22 @@ var SceneUtils = {
var dg, dm, dd, dl, dc, df, dt,
g, o, m, l, p, c, t, f, tt, pp,
geometry, material, camera, fog,
geometry, material, camera, fog,
texture, images,
materials,
data, loader,
data, loader,
counter_models, counter_textures,
total_models, total_textures,
result;
data = event.data;
loader = new THREE.Loader();
counter_models = 0;
counter_textures = 0;
result = {
scene: new THREE.Scene(),
geometries: {},
materials: {},
......@@ -33,372 +33,372 @@ var SceneUtils = {
cameras: {},
lights: {},
fogs: {}
};
function handle_objects() {
for( dd in data.objects ) {
if ( !result.objects[ dd ] ) {
o = data.objects[ dd ];
geometry = result.geometries[ o.geometry ];
if ( geometry ) {
materials = [];
for( i = 0; i < o.materials.length; i++ ) {
materials[ i ] = result.materials[ o.materials[i] ];
}
p = o.position;
r = o.rotation;
s = o.scale;
object = new THREE.Mesh( geometry, materials );
object.position.set( p[0], p[1], p[2] );
object.rotation.set( r[0], r[1], r[2] );
object.scale.set( s[0], s[1], s[2] );
object.visible = o.visible;
result.scene.addObject( object );
result.objects[ dd ] = object;
}
}
}
};
function handle_mesh( geo, id ) {
result.geometries[ id ] = geo;
result.geometries[ id ] = geo;
handle_objects();
};
function create_callback( id ) {
return function( geo ) {
handle_mesh( geo, id );
counter_models -= 1;
async_callback_gate();
}
};
function async_callback_gate() {
var progress = {
total_models: total_models,
total_textures: total_textures,
loaded_models: total_models - counter_models,
loaded_textures: total_textures - counter_textures
};
callback_progress( progress, result );
if( counter_models == 0 && counter_textures == 0 ) {
callback_async( result );
}
};
var callback_texture = function( images ) {
counter_textures -= 1;
async_callback_gate();
async_callback_gate();
};
// first go synchronous elements
// cameras
for( dc in data.cameras ) {
c = data.cameras[ dc ];
if ( c.type == "perspective" ) {
camera = new THREE.Camera( c.fov, c.aspect, c.near, c.far );
} else if ( c.type == "ortho" ) {
camera = new THREE.Camera();
camera.projectionMatrix = THREE.Matrix4.makeOrtho( c.left, c.right, c.top, c.bottom, c.near, c.far );
}
p = c.position;
t = c.target;
camera.position.set( p[0], p[1], p[2] );
camera.target.position.set( t[0], t[1], t[2] );
result.cameras[ dc ] = camera;
}
// lights
for( dl in data.lights ) {
l = data.lights[ dl ];
if ( l.type == "directional" ) {
p = l.direction;
light = new THREE.DirectionalLight();
light.position.set( p[0], p[1], p[2] );
light.position.normalize();
} else if ( l.type == "point" ) {
p = l.position;
light = new THREE.PointLight();
light.position.set( p[0], p[1], p[2] );
}
c = l.color;
i = l.intensity || 1;
light.color.setRGB( c[0] * i, c[1] * i, c[2] * i );
result.scene.addLight( light );
result.lights[ dl ] = light;
}
// fogs
for( df in data.fogs ) {
f = data.fogs[ df ];
if ( f.type == "linear" ) {
fog = new THREE.Fog( 0x000000, f.near, f.far );
} else if ( f.type == "exp2" ) {
fog = new THREE.FogExp2( 0x000000, f.density );
}
c = f.color;
fog.color.setRGB( c[0], c[1], c[2] );
result.fogs[ df ] = fog;
}
// defaults
if ( result.cameras && data.defaults.camera ) {
result.currentCamera = result.cameras[ data.defaults.camera ];
}
if ( result.fogs && data.defaults.fog ) {
result.scene.fog = result.fogs[ data.defaults.fog ];
}
c = data.defaults.bgcolor;
result.bgColor = new THREE.Color();
result.bgColor.setRGB( c[0], c[1], c[2] );
result.bgColorAlpha = data.defaults.bgalpha;
// now come potentially asynchronous elements
// geometries
// count how many models will be loaded asynchronously
for( dg in data.geometries ) {
g = data.geometries[ dg ];
if ( g.type == "bin_mesh" || g.type == "ascii_mesh" ) {
counter_models += 1;
}
}
total_models = counter_models;
for( dg in data.geometries ) {
g = data.geometries[ dg ];
if ( g.type == "cube" ) {
geometry = new Cube( g.width, g.height, g.depth, g.segments_width, g.segments_height, null, g.flipped, g.sides );
result.geometries[ dg ] = geometry;
} else if ( g.type == "plane" ) {
geometry = new Plane( g.width, g.height, g.segments_width, g.segments_height );
result.geometries[ dg ] = geometry;
} else if ( g.type == "sphere" ) {
geometry = new Sphere( g.radius, g.segments_width, g.segments_height );
result.geometries[ dg ] = geometry;
} else if ( g.type == "cylinder" ) {
geometry = new Cylinder( g.numSegs, g.topRad, g.botRad, g.height, g.topOffset, g.botOffset );
result.geometries[ dg ] = geometry;
} else if ( g.type == "torus" ) {
geometry = new Torus( g.radius, g.tube, g.segmentsR, g.segmentsT );
result.geometries[ dg ] = geometry;
} else if ( g.type == "icosahedron" ) {
geometry = new Icosahedron( g.subdivisions );
result.geometries[ dg ] = geometry;
} else if ( g.type == "bin_mesh" ) {
loader.loadBinary( { model: g.url,
loader.loadBinary( { model: g.url,
callback: create_callback( dg )
} );
} else if ( g.type == "ascii_mesh" ) {
loader.loadAscii( { model: g.url,
loader.loadAscii( { model: g.url,
callback: create_callback( dg )
} );
}
}
// textures
// count how many textures will be loaded asynchronously
for( dt in data.textures ) {
tt = data.textures[ dt ];
if( tt.url instanceof Array ) {
counter_textures += tt.url.length;
} else {
counter_textures += 1;
}
}
total_textures = counter_textures;
for( dt in data.textures ) {
tt = data.textures[ dt ];
if ( tt.mapping != undefined && THREE[ tt.mapping ] != undefined ) {
tt.mapping = new THREE[ tt.mapping ]();
}
if( tt.url instanceof Array ) {
images = ImageUtils.loadArray( tt.url, callback_texture );
texture = new THREE.Texture( images, tt.mapping );
} else {
texture = ImageUtils.loadTexture( tt.url, tt.mapping, callback_texture );
if ( THREE[ tt.min_filter ] != undefined )
texture.min_filter = THREE[ tt.min_filter ];
if ( THREE[ tt.mag_filter ] != undefined )
texture.mag_filter = THREE[ tt.mag_filter ];
}
result.textures[ dt ] = texture;
}
// materials
for( dm in data.materials ) {
m = data.materials[ dm ];
for( pp in m.parameters ) {
if ( pp == "env_map" || pp == "map" || pp == "light_map" ) {
m.parameters[ pp ] = result.textures[ m.parameters[ pp ] ];
} else if ( pp == "shading" ) {
m.parameters[ pp ] = ( m.parameters[ pp ] == "flat" ) ? THREE.FlatShading : THREE.SmoothShading;
} else if ( pp == "blending" ) {
m.parameters[ pp ] = THREE[ m.parameters[ pp ] ] ? THREE[ m.parameters[ pp ] ] : THREE.NormalBlending;
} else if ( pp == "combine" ) {
m.parameters[ pp ] = ( m.parameters[ pp ] == "MixOperation" ) ? THREE.MixOperation : THREE.MultiplyOperation;
}
}
material = new THREE[ m.type ]( m.parameters );
result.materials[ dm ] = material;
}
// objects ( synchronous init of procedural primitives )
handle_objects();
// synchronous callback
callback_sync( result );
};
},
addMesh: function ( scene, geometry, scale, x, y, z, rx, ry, rz, material ) {
addMesh : function ( scene, geometry, scale, x, y, z, rx, ry, rz, material ) {
var mesh = new THREE.Mesh( geometry, material );
mesh.scale.x = mesh.scale.y = mesh.scale.z = scale;
......@@ -414,33 +414,32 @@ var SceneUtils = {
},
addPanoramaCubeWebGL: function ( scene, size, textureCube ) {
addPanoramaCubeWebGL : function ( scene, size, textureCube ) {
var shader = ShaderUtils.lib["cube"];
shader.uniforms["tCube"].texture = textureCube;
var material = new THREE.MeshShaderMaterial( { fragment_shader: shader.fragment_shader,
vertex_shader: shader.vertex_shader,
uniforms: shader.uniforms
} ),
mesh = new THREE.Mesh( new Cube( size, size, size, 1, 1, null, true ), material );
vertex_shader: shader.vertex_shader,
uniforms: shader.uniforms
} ),
mesh = new THREE.Mesh( new Cube( size, size, size, 1, 1, null, true ), material );
scene.addObject( mesh );
return mesh;
},
addPanoramaCube: function( scene, size, images ) {
addPanoramaCube : function( scene, size, images ) {
var materials = [], mesh;
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[0] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[1] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[2] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[3] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[4] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[5] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 0 ] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 1 ] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 2 ] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 3 ] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 4 ] ) } ) );
materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 5 ] ) } ) );
mesh = new THREE.Mesh( new Cube( size, size, size, 1, 1, materials, true ), new THREE.MeshFaceMaterial() );
scene.addObject( mesh );
......@@ -449,10 +448,10 @@ var SceneUtils = {
},
addPanoramaCubePlanes: function ( scene, size, images ) {
addPanoramaCubePlanes : function ( scene, size, images ) {
var hsize = size/2, plane = new Plane( size, size ), pi2 = Math.PI/2, pi = Math.PI;
var hsize = size / 2, plane = new Plane( size, size ), pi = Math.PI, pi2 = Math.PI / 2;
SceneUtils.addMesh( scene, plane, 1, 0, 0, -hsize, 0, 0, 0, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[5] ) } ) );
SceneUtils.addMesh( scene, plane, 1, -hsize, 0, 0, 0, pi2, 0, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[0] ) } ) );
......
......@@ -71,7 +71,7 @@ THREE.Projector = function() {
this.projectScene = function ( scene, camera, sort ) {
var renderList = [], near = camera.zNear, far = camera.zFar,
var renderList = [], near = camera.near, far = camera.far,
o, ol, v, vl, f, fl, n, nl, objects, object,
objectMatrix, objectMaterials, objectOverdraw,
objectMatrixRotation,
......
......@@ -1450,8 +1450,8 @@ THREE.WebGLRenderer = function ( parameters ) {
} else if ( material instanceof THREE.MeshDepthMaterial ) {
m_uniforms.mNear.value = camera.zNear;
m_uniforms.mFar.value = camera.zFar;
m_uniforms.mNear.value = camera.near;
m_uniforms.mFar.value = camera.far;
m_uniforms.opacity.value = material.opacity;
} else if ( material instanceof THREE.MeshNormalMaterial ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册