|
|
|
@@ -51,7 +51,7 @@ multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,e=a.z,g=this.x,h=this.y,j
|
|
|
|
|
THREE.Quaternion.slerp=function(a,c,b,d){var e=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(e)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
|
|
|
|
THREE.Face3=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
|
|
|
|
|
THREE.Face4=function(a,c,b,d,e,g,h){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)};THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};
|
|
|
|
|
THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[];this.faceVertexUvs=[];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
|
|
|
|
|
THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
|
|
|
|
|
THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];b.centroid.set(0,0,0);if(b instanceof THREE.Face3){b.centroid.addSelf(this.vertices[b.a].position);b.centroid.addSelf(this.vertices[b.b].position);b.centroid.addSelf(this.vertices[b.c].position);b.centroid.divideScalar(3)}else if(b instanceof THREE.Face4){b.centroid.addSelf(this.vertices[b.a].position);b.centroid.addSelf(this.vertices[b.b].position);b.centroid.addSelf(this.vertices[b.c].position);
|
|
|
|
|
b.centroid.addSelf(this.vertices[b.d].position);b.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,b,d,e,g,h,j=new THREE.Vector3,k=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){j.set(0,0,0);c=0;for(b=g.vertexNormals.length;c<b;c++)j.addSelf(g.vertexNormals[c]);j.divideScalar(3)}else{c=this.vertices[g.a];b=this.vertices[g.b];h=this.vertices[g.c];j.sub(h.position,b.position);k.sub(c.position,b.position);j.crossSelf(k)}j.isZero()||
|
|
|
|
|
j.normalize();g.normal.copy(j)}},computeVertexNormals:function(){var a,c,b,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)d[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];if(b instanceof THREE.Face3)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(b instanceof THREE.Face4)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=
|
|
|
|
@@ -292,21 +292,21 @@ THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElem
|
|
|
|
|
THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
|
|
|
|
|
THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.uvs=[];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};
|
|
|
|
|
THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
|
|
|
|
|
var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,d=a.vertices.length,e=b?c.geometry:c,g=a.vertices,h=e.vertices,j=a.faces,k=e.faces,o=a.uvs;e=e.uvs;b&&c.matrixAutoUpdate&&c.updateMatrix();for(var t=0,x=h.length;t<x;t++){var y=new THREE.Vertex(h[t].position.clone());b&&c.matrix.multiplyVector3(y.position);g.push(y)}t=0;for(x=k.length;t<x;t++){h=k[t];var q,A=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(q=new THREE.Face4(h.a+
|
|
|
|
|
d,h.b+d,h.c+d,h.d+d));q.centroid.copy(h.centroid);q.normal.copy(h.normal);b=0;for(g=A.length;b<g;b++){y=A[b];q.vertexNormals.push(y.clone())}q.materials=h.materials.slice();j.push(q)}t=0;for(x=e.length;t<x;t++){d=e[t];j=[];b=0;for(g=d.length;b<g;b++)j.push(new THREE.UV(d[b].u,d[b].v));o.push(j)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,e=new THREE.Texture(d,c);d.onload=function(){e.needsUpdate=!0;b&&b(this)};d.src=a;return e},loadTextureCube:function(a,c,b){var d,e=[],g=new THREE.Texture(e,
|
|
|
|
|
c);c=e.loadCount=0;for(d=a.length;c<d;++c){e[c]=new Image;e[c].onload=function(){e.loadCount+=1;if(e.loadCount==6)g.needsUpdate=!0;b&&b(this)};e[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,c,b,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(e){function g(){for(t in V.objects)if(!N.objects[t]){H=V.objects[t];if(z=N.geometries[H.geometry]){Z=[];for(i=0;i<H.materials.length;i++)Z[i]=N.materials[H.materials[i]];J=H.position;r=H.rotation;s=H.scale;object=new THREE.Mesh(z,Z);object.position.set(J[0],
|
|
|
|
|
J[1],J[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=H.visible;N.scene.addObject(object);N.objects[t]=object}}}function h(xa){return function(ta){N.geometries[xa]=ta;g();fa-=1;j()}}function j(){d({total_models:W,total_textures:na,loaded_models:W-fa,loaded_textures:na-R},N);fa==0&&R==0&&b(N)}var k,o,t,x,y,q,A,H,J,F,K,z,I,Q,Z,V,f,fa,R,W,na,N;V=e.data;f=new THREE.Loader;R=fa=0;N={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},
|
|
|
|
|
lights:{},fogs:{}};e=function(){R-=1;j()};for(y in V.cameras){F=V.cameras[y];if(F.type=="perspective")I=new THREE.Camera(F.fov,F.aspect,F.near,F.far);else if(F.type=="ortho"){I=new THREE.Camera;I.projectionMatrix=THREE.Matrix4.makeOrtho(F.left,F.right,F.top,F.bottom,F.near,F.far)}J=F.position;F=F.target;I.position.set(J[0],J[1],J[2]);I.target.position.set(F[0],F[1],F[2]);N.cameras[y]=I}for(x in V.lights){y=V.lights[x];if(y.type=="directional"){J=y.direction;light=new THREE.DirectionalLight;light.position.set(J[0],
|
|
|
|
|
J[1],J[2]);light.position.normalize()}else if(y.type=="point"){J=y.position;light=new THREE.PointLight;light.position.set(J[0],J[1],J[2])}F=y.color;i=y.intensity||1;light.color.setRGB(F[0]*i,F[1]*i,F[2]*i);N.scene.addLight(light);N.lights[x]=light}for(q in V.fogs){x=V.fogs[q];if(x.type=="linear")Q=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(Q=new THREE.FogExp2(0,x.density));F=x.color;Q.color.setRGB(F[0],F[1],F[2]);N.fogs[q]=Q}if(N.cameras&&V.defaults.camera)N.currentCamera=N.cameras[V.defaults.camera];
|
|
|
|
|
if(N.fogs&&V.defaults.fog)N.scene.fog=N.fogs[V.defaults.fog];F=V.defaults.bgcolor;N.bgColor=new THREE.Color;N.bgColor.setRGB(F[0],F[1],F[2]);N.bgColorAlpha=V.defaults.bgalpha;for(k in V.geometries){q=V.geometries[k];if(q.type=="bin_mesh"||q.type=="ascii_mesh")fa+=1}W=fa;for(k in V.geometries){q=V.geometries[k];if(q.type=="cube"){z=new Cube(q.width,q.height,q.depth,q.segmentsWidth,q.segmentsHeight,q.segmentsDepth,null,q.flipped,q.sides);N.geometries[k]=z}else if(q.type=="plane"){z=new Plane(q.width,
|
|
|
|
|
q.height,q.segmentsWidth,q.segmentsHeight);N.geometries[k]=z}else if(q.type=="sphere"){z=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);N.geometries[k]=z}else if(q.type=="cylinder"){z=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);N.geometries[k]=z}else if(q.type=="torus"){z=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);N.geometries[k]=z}else if(q.type=="icosahedron"){z=new Icosahedron(q.subdivisions);N.geometries[k]=z}else if(q.type=="bin_mesh")f.loadBinary({model:q.url,
|
|
|
|
|
callback:h(k)});else q.type=="ascii_mesh"&&f.loadAscii({model:q.url,callback:h(k)})}for(A in V.textures){k=V.textures[A];R+=k.url instanceof Array?k.url.length:1}na=R;for(A in V.textures){k=V.textures[A];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array)q=ImageUtils.loadTextureCube(k.url,k.mapping,e);else{q=ImageUtils.loadTexture(k.url,k.mapping,e);if(THREE[k.minFilter]!=undefined)q.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=undefined)q.magFilter=
|
|
|
|
|
THREE[k.magFilter]}N.textures[A]=q}for(o in V.materials){A=V.materials[o];for(K in A.parameters)if(K=="envMap"||K=="map"||K=="lightMap")A.parameters[K]=N.textures[A.parameters[K]];else if(K=="shading")A.parameters[K]=A.parameters[K]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(K=="blending")A.parameters[K]=THREE[A.parameters[K]]?THREE[A.parameters[K]]:THREE.NormalBlending;else K=="combine"&&(A.parameters[K]=A.parameters[K]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);A=new THREE[A.type](A.parameters);
|
|
|
|
|
N.materials[o]=A}g();c(N)}},addMesh:function(a,c,b,d,e,g,h,j,k,o){c=new THREE.Mesh(c,o);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=d;c.position.y=e;c.position.z=g;c.rotation.x=h;c.rotation.y=j;c.rotation.z=k;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,b){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,vertexShader:d.vertexShader,uniforms:d.uniforms});c=new THREE.Mesh(new Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);
|
|
|
|
|
return c},addPanoramaCube:function(a,c,b){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));c=new THREE.Mesh(new Cube(c,c,c,1,1,d,!0),new THREE.MeshFaceMaterial);
|
|
|
|
|
a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var d=c/2;c=new Plane(c,c);var e=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,c,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,c,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,c,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,c,1,0,d,0,g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
|
|
|
|
|
SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,d,e=a.children.length;for(d=0;d<e;d++){b=a.children[d];c(b);SceneUtils.traverseHierarchy(b,c)}}},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}},fragmentShader:"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}",
|
|
|
|
|
var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,d=a.vertices.length,e=b?c.geometry:c,g=a.vertices,h=e.vertices,j=a.faces,k=e.faces,o=a.faceVertexUvs[0];e=e.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var t=0,x=h.length;t<x;t++){var y=new THREE.Vertex(h[t].position.clone());b&&c.matrix.multiplyVector3(y.position);g.push(y)}t=0;for(x=k.length;t<x;t++){h=k[t];var q,A=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof
|
|
|
|
|
THREE.Face4&&(q=new THREE.Face4(h.a+d,h.b+d,h.c+d,h.d+d));q.centroid.copy(h.centroid);q.normal.copy(h.normal);b=0;for(g=A.length;b<g;b++){y=A[b];q.vertexNormals.push(y.clone())}q.materials=h.materials.slice();j.push(q)}t=0;for(x=e.length;t<x;t++){d=e[t];j=[];b=0;for(g=d.length;b<g;b++)j.push(new THREE.UV(d[b].u,d[b].v));o.push(j)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,e=new THREE.Texture(d,c);d.onload=function(){e.needsUpdate=!0;b&&b(this)};d.src=a;return e},loadTextureCube:function(a,
|
|
|
|
|
c,b){var d,e=[],g=new THREE.Texture(e,c);c=e.loadCount=0;for(d=a.length;c<d;++c){e[c]=new Image;e[c].onload=function(){e.loadCount+=1;if(e.loadCount==6)g.needsUpdate=!0;b&&b(this)};e[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,c,b,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(e){function g(){for(t in V.objects)if(!N.objects[t]){H=V.objects[t];if(z=N.geometries[H.geometry]){Z=[];for(i=0;i<H.materials.length;i++)Z[i]=N.materials[H.materials[i]];J=H.position;r=H.rotation;s=H.scale;
|
|
|
|
|
object=new THREE.Mesh(z,Z);object.position.set(J[0],J[1],J[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=H.visible;N.scene.addObject(object);N.objects[t]=object}}}function h(xa){return function(ta){N.geometries[xa]=ta;g();fa-=1;j()}}function j(){d({total_models:W,total_textures:na,loaded_models:W-fa,loaded_textures:na-R},N);fa==0&&R==0&&b(N)}var k,o,t,x,y,q,A,H,J,F,K,z,I,Q,Z,V,f,fa,R,W,na,N;V=e.data;f=new THREE.Loader;R=fa=0;N={scene:new THREE.Scene,geometries:{},
|
|
|
|
|
materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};e=function(){R-=1;j()};for(y in V.cameras){F=V.cameras[y];if(F.type=="perspective")I=new THREE.Camera(F.fov,F.aspect,F.near,F.far);else if(F.type=="ortho"){I=new THREE.Camera;I.projectionMatrix=THREE.Matrix4.makeOrtho(F.left,F.right,F.top,F.bottom,F.near,F.far)}J=F.position;F=F.target;I.position.set(J[0],J[1],J[2]);I.target.position.set(F[0],F[1],F[2]);N.cameras[y]=I}for(x in V.lights){y=V.lights[x];if(y.type=="directional"){J=y.direction;
|
|
|
|
|
light=new THREE.DirectionalLight;light.position.set(J[0],J[1],J[2]);light.position.normalize()}else if(y.type=="point"){J=y.position;light=new THREE.PointLight;light.position.set(J[0],J[1],J[2])}F=y.color;i=y.intensity||1;light.color.setRGB(F[0]*i,F[1]*i,F[2]*i);N.scene.addLight(light);N.lights[x]=light}for(q in V.fogs){x=V.fogs[q];if(x.type=="linear")Q=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(Q=new THREE.FogExp2(0,x.density));F=x.color;Q.color.setRGB(F[0],F[1],F[2]);N.fogs[q]=Q}if(N.cameras&&
|
|
|
|
|
V.defaults.camera)N.currentCamera=N.cameras[V.defaults.camera];if(N.fogs&&V.defaults.fog)N.scene.fog=N.fogs[V.defaults.fog];F=V.defaults.bgcolor;N.bgColor=new THREE.Color;N.bgColor.setRGB(F[0],F[1],F[2]);N.bgColorAlpha=V.defaults.bgalpha;for(k in V.geometries){q=V.geometries[k];if(q.type=="bin_mesh"||q.type=="ascii_mesh")fa+=1}W=fa;for(k in V.geometries){q=V.geometries[k];if(q.type=="cube"){z=new Cube(q.width,q.height,q.depth,q.segmentsWidth,q.segmentsHeight,q.segmentsDepth,null,q.flipped,q.sides);
|
|
|
|
|
N.geometries[k]=z}else if(q.type=="plane"){z=new Plane(q.width,q.height,q.segmentsWidth,q.segmentsHeight);N.geometries[k]=z}else if(q.type=="sphere"){z=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);N.geometries[k]=z}else if(q.type=="cylinder"){z=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);N.geometries[k]=z}else if(q.type=="torus"){z=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);N.geometries[k]=z}else if(q.type=="icosahedron"){z=new Icosahedron(q.subdivisions);
|
|
|
|
|
N.geometries[k]=z}else if(q.type=="bin_mesh")f.loadBinary({model:q.url,callback:h(k)});else q.type=="ascii_mesh"&&f.loadAscii({model:q.url,callback:h(k)})}for(A in V.textures){k=V.textures[A];R+=k.url instanceof Array?k.url.length:1}na=R;for(A in V.textures){k=V.textures[A];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array)q=ImageUtils.loadTextureCube(k.url,k.mapping,e);else{q=ImageUtils.loadTexture(k.url,k.mapping,e);if(THREE[k.minFilter]!=
|
|
|
|
|
undefined)q.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=undefined)q.magFilter=THREE[k.magFilter]}N.textures[A]=q}for(o in V.materials){A=V.materials[o];for(K in A.parameters)if(K=="envMap"||K=="map"||K=="lightMap")A.parameters[K]=N.textures[A.parameters[K]];else if(K=="shading")A.parameters[K]=A.parameters[K]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(K=="blending")A.parameters[K]=THREE[A.parameters[K]]?THREE[A.parameters[K]]:THREE.NormalBlending;else K=="combine"&&(A.parameters[K]=
|
|
|
|
|
A.parameters[K]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);A=new THREE[A.type](A.parameters);N.materials[o]=A}g();c(N)}},addMesh:function(a,c,b,d,e,g,h,j,k,o){c=new THREE.Mesh(c,o);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=d;c.position.y=e;c.position.z=g;c.rotation.x=h;c.rotation.y=j;c.rotation.z=k;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,b){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,vertexShader:d.vertexShader,
|
|
|
|
|
uniforms:d.uniforms});c=new THREE.Mesh(new Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);return c},addPanoramaCube:function(a,c,b){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));
|
|
|
|
|
c=new THREE.Mesh(new Cube(c,c,c,1,1,d,!0),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var d=c/2;c=new Plane(c,c);var e=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,c,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,c,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,c,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,
|
|
|
|
|
c,1,0,d,0,g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,d,e=a.children.length;for(d=0;d<e;d++){b=a.children[d];c(b);SceneUtils.traverseHierarchy(b,c)}}},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}},fragmentShader:"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}",
|
|
|
|
|
vertexShader:"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}},fragmentShader:"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}",
|
|
|
|
@@ -333,7 +333,7 @@ this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.win
|
|
|
|
|
this.phi=(this.phi-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.horizontalAngleMap.srcRange;q=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,o,t,x)};this.onMouseMove=function(o){this.mouseX=o.clientX-this.windowHalfX;this.mouseY=o.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
|
|
|
|
|
this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),j=new Cube(10,10,20),k=new Cube(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
|
|
|
|
|
c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(o,t){return function(){t.apply(o,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
|
|
|
|
|
var Cube=function(a,c,b,d,e,g,h,j,k){function o(J,F,K,z,I,Q,Z,V){var f,fa,R=d||1,W=e||1,na=I/2,N=Q/2,xa=t.vertices.length;if(J=="x"&&F=="y"||J=="y"&&F=="x")f="z";else if(J=="x"&&F=="z"||J=="z"&&F=="x"){f="y";W=g||1}else if(J=="z"&&F=="y"||J=="y"&&F=="z"){f="x";R=g||1}var ta=R+1,qa=W+1;I/=R;var ua=Q/W;for(fa=0;fa<qa;fa++)for(Q=0;Q<ta;Q++){var la=new THREE.Vector3;la[J]=(Q*I-na)*K;la[F]=(fa*ua-N)*z;la[f]=Z;t.vertices.push(new THREE.Vertex(la))}t.faceVertexUvs[0]=[];for(fa=0;fa<W;fa++)for(Q=0;Q<R;Q++){t.faces.push(new THREE.Face4(Q+
|
|
|
|
|
var Cube=function(a,c,b,d,e,g,h,j,k){function o(J,F,K,z,I,Q,Z,V){var f,fa,R=d||1,W=e||1,na=I/2,N=Q/2,xa=t.vertices.length;if(J=="x"&&F=="y"||J=="y"&&F=="x")f="z";else if(J=="x"&&F=="z"||J=="z"&&F=="x"){f="y";W=g||1}else if(J=="z"&&F=="y"||J=="y"&&F=="z"){f="x";R=g||1}var ta=R+1,qa=W+1;I/=R;var ua=Q/W;for(fa=0;fa<qa;fa++)for(Q=0;Q<ta;Q++){var la=new THREE.Vector3;la[J]=(Q*I-na)*K;la[F]=(fa*ua-N)*z;la[f]=Z;t.vertices.push(new THREE.Vertex(la))}for(fa=0;fa<W;fa++)for(Q=0;Q<R;Q++){t.faces.push(new THREE.Face4(Q+
|
|
|
|
|
ta*fa+xa,Q+ta*(fa+1)+xa,Q+1+ta*(fa+1)+xa,Q+1+ta*fa+xa,null,null,V));t.faceVertexUvs[0].push([new THREE.UV(Q/R,fa/W),new THREE.UV(Q/R,(fa+1)/W),new THREE.UV((Q+1)/R,(fa+1)/W),new THREE.UV((Q+1)/R,fa/W)])}}THREE.Geometry.call(this);var t=this,x=a/2,y=c/2,q=b/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var A=0;A<6;A++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var H in k)this.sides[H]!=
|
|
|
|
|
undefined&&(this.sides[H]=k[H]);this.sides.px&&o("z","y",1*j,-1,b,c,-x,this.materials[0]);this.sides.nx&&o("z","y",-1*j,-1,b,c,x,this.materials[1]);this.sides.py&&o("x","z",1*j,1,a,b,y,this.materials[2]);this.sides.ny&&o("x","z",1*j,-1,a,b,-y,this.materials[3]);this.sides.pz&&o("x","y",1*j,-1,a,c,q,this.materials[4]);this.sides.nz&&o("x","y",-1*j,-1,a,c,-q,this.materials[5]);(function(){for(var J=[],F=[],K=0,z=t.vertices.length;K<z;K++){for(var I=t.vertices[K],Q=!1,Z=0,V=J.length;Z<V;Z++){var f=J[Z];
|
|
|
|
|
if(I.position.x==f.position.x&&I.position.y==f.position.y&&I.position.z==f.position.z){F[K]=Z;Q=!0;break}}if(!Q){F[K]=J.length;J.push(new THREE.Vertex(I.position.clone()))}}K=0;for(z=t.faces.length;K<z;K++){I=t.faces[K];I.a=F[I.a];I.b=F[I.b];I.c=F[I.c];I.d=F[I.d]}t.vertices=J})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
|
|
|
@@ -343,19 +343,18 @@ var Icosahedron=function(a){function c(x,y,q){var A=Math.sqrt(x*x+y*y+q*q);retur
|
|
|
|
|
1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var j in g.faces){var k=d(g.faces[j].a,g.faces[j].b),o=d(g.faces[j].b,g.faces[j].c),t=d(g.faces[j].c,g.faces[j].a);b(g.faces[j].a,k,t,h);b(g.faces[j].b,o,k,h);b(g.faces[j].c,
|
|
|
|
|
t,o,h);b(k,o,t,h)}g.faces=h.faces}e.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
|
|
|
|
|
function Lathe(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;for(var d=[],e=[],g=[],h=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));d[j]=a[j].clone();e[j]=this.vertices.length-1}for(var k=(new THREE.Matrix4).setRotationZ(c),o=0;o<=this.angle+0.0010;o+=c){for(j=0;j<d.length;j++)if(o<this.angle){d[j]=k.multiplyVector3(d[j].clone());this.vertices.push(new THREE.Vertex(d[j]));g[j]=this.vertices.length-1}else g=h;o==0&&(h=e);for(j=
|
|
|
|
|
0;j<e.length-1;j++){this.faces.push(new THREE.Face4(g[j],g[j+1],e[j+1],e[j]));this.uvs.push([new THREE.UV(o/b,j/a.length),new THREE.UV(o/b,(j+1)/a.length),new THREE.UV((o-c)/b,(j+1)/a.length),new THREE.UV((o-c)/b,j/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
|
|
|
|
|
var Plane=function(a,c,b,d){THREE.Geometry.call(this);var e,g=a/2,h=c/2;b=b||1;d=d||1;var j=b+1,k=d+1;a/=b;var o=c/d;for(e=0;e<k;e++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(e*o-h),0)));this.faceVertexUvs[0]=[];for(e=0;e<d;e++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+j*e,c+j*(e+1),c+1+j*(e+1),c+1+j*e));this.faceVertexUvs[0].push([new THREE.UV(c/b,e/d),new THREE.UV(c/b,(e+1)/d),new THREE.UV((c+1)/b,(e+1)/d),new THREE.UV((c+1)/b,e/d)])}this.computeCentroids();
|
|
|
|
|
this.computeFaceNormals()};Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
|
|
|
|
var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){d=b/h;var j=a*Math.cos(d*e),k=a*Math.sin(d*e),o=[],t=0;for(d=0;d<g;d++){var x=2*d/g,y=k*Math.sin(x*e);x=k*Math.cos(x*e);(b==0||b==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,j,y)))-1);o.push(t)}c.push(o)}var q,A,H;e=c.length;this.faceVertexUvs[0]=[];for(b=0;b<e;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){o=d==g-1;h=c[b][o?0:d+1];j=c[b][o?g-1:d];
|
|
|
|
|
k=c[b-1][o?g-1:d];o=c[b-1][o?0:d+1];y=b/(e-1);q=(b-1)/(e-1);A=(d+1)/g;x=d/g;t=new THREE.UV(1-A,y);y=new THREE.UV(1-x,y);x=new THREE.UV(1-x,q);var J=new THREE.UV(1-A,q);if(b<c.length-1){q=this.vertices[h].position.clone();A=this.vertices[j].position.clone();H=this.vertices[k].position.clone();q.normalize();A.normalize();H.normalize();this.faces.push(new THREE.Face3(h,j,k,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([t,y,
|
|
|
|
|
x])}if(b>1){q=this.vertices[h].position.clone();A=this.vertices[k].position.clone();H=this.vertices[o].position.clone();q.normalize();A.normalize();H.normalize();this.faces.push(new THREE.Face3(h,k,o,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([t,x,J])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;
|
|
|
|
|
Sphere.prototype.constructor=Sphere;
|
|
|
|
|
0;j<e.length-1;j++){this.faces.push(new THREE.Face4(g[j],g[j+1],e[j+1],e[j]));this.faceVertexUvs[0].push([new THREE.UV(o/b,j/a.length),new THREE.UV(o/b,(j+1)/a.length),new THREE.UV((o-c)/b,(j+1)/a.length),new THREE.UV((o-c)/b,j/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
|
|
|
|
|
var Plane=function(a,c,b,d){THREE.Geometry.call(this);var e,g=a/2,h=c/2;b=b||1;d=d||1;var j=b+1,k=d+1;a/=b;var o=c/d;for(e=0;e<k;e++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(e*o-h),0)));for(e=0;e<d;e++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+j*e,c+j*(e+1),c+1+j*(e+1),c+1+j*e));this.faceVertexUvs[0].push([new THREE.UV(c/b,e/d),new THREE.UV(c/b,(e+1)/d),new THREE.UV((c+1)/b,(e+1)/d),new THREE.UV((c+1)/b,e/d)])}this.computeCentroids();this.computeFaceNormals()};
|
|
|
|
|
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
|
|
|
|
var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){d=b/h;var j=a*Math.cos(d*e),k=a*Math.sin(d*e),o=[],t=0;for(d=0;d<g;d++){var x=2*d/g,y=k*Math.sin(x*e);x=k*Math.cos(x*e);(b==0||b==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,j,y)))-1);o.push(t)}c.push(o)}var q,A,H;e=c.length;for(b=0;b<e;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){o=d==g-1;h=c[b][o?0:d+1];j=c[b][o?g-1:d];k=c[b-1][o?g-1:d];o=c[b-1][o?
|
|
|
|
|
0:d+1];y=b/(e-1);q=(b-1)/(e-1);A=(d+1)/g;x=d/g;t=new THREE.UV(1-A,y);y=new THREE.UV(1-x,y);x=new THREE.UV(1-x,q);var J=new THREE.UV(1-A,q);if(b<c.length-1){q=this.vertices[h].position.clone();A=this.vertices[j].position.clone();H=this.vertices[k].position.clone();q.normalize();A.normalize();H.normalize();this.faces.push(new THREE.Face3(h,j,k,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([t,y,x])}if(b>1){q=this.vertices[h].position.clone();
|
|
|
|
|
A=this.vertices[k].position.clone();H=this.vertices[o].position.clone();q.normalize();A.normalize();H.normalize();this.faces.push(new THREE.Face3(h,k,o,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([t,x,J])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
|
|
|
|
var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
|
|
|
|
|
1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
|
|
|
|
|
1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
|
|
|
|
|
var TorusKnot=function(a,c,b,d,e,g,h){function j(x,y,q,A,H,J){y=q/A*x;q=Math.cos(y);return new THREE.Vector3(H*(2+q)*0.5*Math.cos(x),H*(2+q)*Math.sin(x)*0.5,J*H*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var k=
|
|
|
|
|
a/this.segmentsR*2*this.p*Math.PI;h=c/this.segmentsT*2*Math.PI;e=j(k,h,this.q,this.p,this.radius,this.heightScale);k=j(k+0.01,h,this.q,this.p,this.radius,this.heightScale);b.x=k.x-e.x;b.y=k.y-e.y;b.z=k.z-e.z;d.x=k.x+e.x;d.y=k.y+e.y;d.z=k.z+e.z;g.cross(b,d);d.cross(g,b);g.normalize();d.normalize();k=this.tube*Math.cos(h);h=this.tube*Math.sin(h);e.x+=k*d.x+h*g.x;e.y+=k*d.y+h*g.y;e.z+=k*d.z+h*g.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=
|
|
|
|
|
0;c<this.segmentsT;++c){g=(a+1)%this.segmentsR;h=(c+1)%this.segmentsT;e=this.grid[a][c];b=this.grid[g][c];d=this.grid[a][h];g=this.grid[g][h];h=new THREE.UV(a/this.segmentsR,c/this.segmentsT);k=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var o=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT),t=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face3(e,b,d));this.uvs.push([h,k,o]);this.faces.push(new THREE.Face3(g,d,b));this.uvs.push([t,o,k])}this.computeCentroids();
|
|
|
|
|
this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null};
|
|
|
|
|
0;c<this.segmentsT;++c){g=(a+1)%this.segmentsR;h=(c+1)%this.segmentsT;e=this.grid[a][c];b=this.grid[g][c];d=this.grid[a][h];g=this.grid[g][h];h=new THREE.UV(a/this.segmentsR,c/this.segmentsT);k=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var o=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT),t=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face3(e,b,d));this.faceVertexUvs[0].push([h,k,o]);this.faces.push(new THREE.Face3(g,d,b));this.faceVertexUvs[0].push([t,
|
|
|
|
|
o,k])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null};
|
|
|
|
|
THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
|
|
|
|
|
c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,c,b){a.materials=[];for(var d=0;d<c.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(c[d],b)]},createMaterial:function(a,c){function b(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function d(j,k){var o=new Image;o.onload=function(){if(!b(this.width)||!b(this.height)){var t=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),x=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));
|
|
|
|
|
j.image.width=t;j.image.height=x;j.image.getContext("2d").drawImage(this,0,0,t,x)}else j.image=this;j.needsUpdate=!0};o.src=k}var e,g,h;e="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(e="MeshPhongMaterial");if(a.mapDiffuse&&c){h=document.createElement("canvas");g.map=new THREE.Texture(h);g.map.sourceFile=a.mapDiffuse;d(g.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*
|
|
|
|
|