提交 764121a8 编写于 作者: A alteredq

Merge branch 'master' of http://github.com/mrdoob/three.js

因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
...@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined? ...@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*= THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this}, -1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this},
multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,m=h*e+i*c-g*d,l=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+m*-i-l*-f;b.y=m*h+c*-f+l*-g-j*-i;b.z=l*h+c*-i+j*-f-m*-g;return b}}; multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,m=h*e+i*c-g*d,l=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+m*-i-l*-f;b.y=m*h+c*-f+l*-g-j*-i;b.z=l*h+c*-i+j*-f-m*-g;return b}};
THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)}; THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}}; THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};
...@@ -71,9 +71,8 @@ THREE.Animation.prototype.interpolate=function(a,b,c,e,d,g,f){a=(c-a)*0.5;e=(e-b ...@@ -71,9 +71,8 @@ THREE.Animation.prototype.interpolate=function(a,b,c,e,d,g,f){a=(c-a)*0.5;e=(e-b
THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]}; THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
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.target=d||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype; 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.target=d||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)}; THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate= THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position)}a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0;for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};
!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};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.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.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var e,d=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<d;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(e=0;e<d;e++)this.children[e].update(this.skinMatrix, THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var e,d=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<d;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(e=0;e<d;e++)this.children[e].update(this.skinMatrix,
b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}}; b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};
THREE.Sound=function(a,b,c,e){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,c!==undefined?c:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=e!==undefined?e:!0;this.sources=a instanceof Array?a:[a];var d;c=this.sources.length;for(a=0;a<c;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)d= THREE.Sound=function(a,b,c,e){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,c!==undefined?c:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=e!==undefined?e:!0;this.sources=a instanceof Array?a:[a];var d;c=this.sources.length;for(a=0;a<c;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)d=
......
...@@ -24,7 +24,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195 ...@@ -24,7 +24,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"}, film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var e,b,c,d,f=2*Math.ceil(a*3)+1;f>25&&(f=25);d=(f-1)*0.5;b=Array(f);for(e=c=0;e<f;++e){b[e]=Math.exp(-((e-d)*(e-d))/(2*a*a));c+=b[e]}for(e=0;e<f;++e)b[e]/=c;return b}}; fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var e,b,c,d,f=2*Math.ceil(a*3)+1;f>25&&(f=25);d=(f-1)*0.5;b=Array(f);for(e=c=0;e<f;++e){b[e]=Math.exp(-((e-d)*(e-d))/(2*a*a));c+=b[e]}for(e=0;e<f;++e)b[e]/=c;return b}};
THREE.QuakeCamera=function(a){function e(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly= THREE.QuakeCamera=function(a){function e(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat= a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=
this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward= this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=
!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward= !1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
...@@ -34,7 +34,7 @@ var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mo ...@@ -34,7 +34,7 @@ var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mo
THREE.QuakeCamera.prototype.translate=function(a,e){this.matrix.rotateAxis(e);if(this.noFly)e.y=0;this.position.addSelf(e.multiplyScalar(a));this.target.position.addSelf(e.multiplyScalar(a))}; THREE.QuakeCamera.prototype.translate=function(a,e){this.matrix.rotateAxis(e);if(this.noFly)e.y=0;this.position.addSelf(e.multiplyScalar(a));this.target.position.addSelf(e.multiplyScalar(a))};
THREE.PathCamera=function(a){function e(k,j,m,p){var w={name:m,fps:0.6,length:p,hierarchy:[]},t,z=j.getControlPointsArray(),y=j.getLength(),A=z.length,C=0;t=A-1;j={parent:-1,keys:[]};j.keys[0]={time:0,pos:z[0],rot:[0,0,0,1],scl:[1,1,1]};j.keys[t]={time:p,pos:z[t],rot:[0,0,0,1],scl:[1,1,1]};for(t=1;t<A-1;t++){C=p*y.chunks[t]/y.total;j.keys[t]={time:C,pos:z[t]}}w.hierarchy[0]=j;THREE.AnimationHandler.add(w);return new THREE.Animation(k,m,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(k,j){var m, THREE.PathCamera=function(a){function e(k,j,m,p){var w={name:m,fps:0.6,length:p,hierarchy:[]},t,z=j.getControlPointsArray(),y=j.getLength(),A=z.length,C=0;t=A-1;j={parent:-1,keys:[]};j.keys[0]={time:0,pos:z[0],rot:[0,0,0,1],scl:[1,1,1]};j.keys[t]={time:p,pos:z[t],rot:[0,0,0,1],scl:[1,1,1]};for(t=1;t<A-1;t++){C=p*y.chunks[t]/y.total;j.keys[t]={time:C,pos:z[t]}}w.hierarchy[0]=j;THREE.AnimationHandler.add(w);return new THREE.Animation(k,m,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(k,j){var m,
p,w=new THREE.Geometry;for(m=0;m<k.points.length*j;m++){p=m/(k.points.length*j);p=k.getPoint(p);w.vertices[m]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return w}function c(k,j){var m=b(j,10),p=b(j,10),w=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(m,w);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);k.addChild(lineObj);particleObj.scale.set(1,1,1);k.addChild(particleObj);p=new Sphere(1, p,w=new THREE.Geometry;for(m=0;m<k.points.length*j;m++){p=m/(k.points.length*j);p=k.getPoint(p);w.vertices[m]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return w}function c(k,j){var m=b(j,10),p=b(j,10),w=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(m,w);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);k.addChild(lineObj);particleObj.scale.set(1,1,1);k.addChild(particleObj);p=new Sphere(1,
16,8);w=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<j.points.length;i++){m=new THREE.Mesh(p,w);m.position.copy(j.points[i]);m.updateMatrix();k.addChild(m)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical= 16,8);w=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<j.points.length;i++){m=new THREE.Mesh(p,w);m.position.copy(j.points[i]);m.updateMatrix();k.addChild(m)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
!0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath; !0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon= if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var d=Math.PI*2,f=Math.PI/180;this.update=function(k,j,m){var p,w;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*f;this.theta=this.lon*f;p=this.phi%d;this.phi=p>=0?p:p+d;p=this.verticalAngleMap.srcRange;w=this.verticalAngleMap.dstRange; this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var d=Math.PI*2,f=Math.PI/180;this.update=function(k,j,m){var p,w;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*f;this.theta=this.lon*f;p=this.phi%d;this.phi=p>=0?p:p+d;p=this.verticalAngleMap.srcRange;w=this.verticalAngleMap.dstRange;
...@@ -50,7 +50,7 @@ for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2* ...@@ -50,7 +50,7 @@ for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2*
var Icosahedron=function(a){function e(m,p,w){var t=Math.sqrt(m*m+p*p+w*w);return d.vertices.push(new THREE.Vertex(new THREE.Vector3(m/t,p/t,w/t)))-1}function b(m,p,w,t){t.faces.push(new THREE.Face3(m,p,w))}function c(m,p){var w=d.vertices[m].position,t=d.vertices[p].position;return e((w.x+t.x)/2,(w.y+t.y)/2,(w.z+t.z)/2)}var d=this,f=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;e(-1,a,0);e(1,a,0);e(-1,-a,0);e(1,-a,0);e(0,-1,a);e(0,1,a);e(0,-1,-a);e(0, var Icosahedron=function(a){function e(m,p,w){var t=Math.sqrt(m*m+p*p+w*w);return d.vertices.push(new THREE.Vertex(new THREE.Vector3(m/t,p/t,w/t)))-1}function b(m,p,w,t){t.faces.push(new THREE.Face3(m,p,w))}function c(m,p){var w=d.vertices[m].position,t=d.vertices[p].position;return e((w.x+t.x)/2,(w.y+t.y)/2,(w.z+t.z)/2)}var d=this,f=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;e(-1,a,0);e(1,a,0);e(-1,-a,0);e(1,-a,0);e(0,-1,a);e(0,1,a);e(0,-1,-a);e(0,
1,-a);e(a,0,-1);e(a,0,1);e(-a,0,-1);e(-a,0,1);b(0,11,5,f);b(0,5,1,f);b(0,1,7,f);b(0,7,10,f);b(0,10,11,f);b(1,5,9,f);b(5,11,4,f);b(11,10,2,f);b(10,7,6,f);b(7,1,8,f);b(3,9,4,f);b(3,4,2,f);b(3,2,6,f);b(3,6,8,f);b(3,8,9,f);b(4,9,5,f);b(2,4,11,f);b(6,2,10,f);b(8,6,7,f);b(9,8,1,f);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in f.faces){var l=c(f.faces[h].a,f.faces[h].b),k=c(f.faces[h].b,f.faces[h].c),j=c(f.faces[h].c,f.faces[h].a);b(f.faces[h].a,l,j,g);b(f.faces[h].b,k,l,g);b(f.faces[h].c, 1,-a);e(a,0,-1);e(a,0,1);e(-a,0,-1);e(-a,0,1);b(0,11,5,f);b(0,5,1,f);b(0,1,7,f);b(0,7,10,f);b(0,10,11,f);b(1,5,9,f);b(5,11,4,f);b(11,10,2,f);b(10,7,6,f);b(7,1,8,f);b(3,9,4,f);b(3,4,2,f);b(3,2,6,f);b(3,6,8,f);b(3,8,9,f);b(4,9,5,f);b(2,4,11,f);b(6,2,10,f);b(8,6,7,f);b(9,8,1,f);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in f.faces){var l=c(f.faces[h].a,f.faces[h].b),k=c(f.faces[h].b,f.faces[h].c),j=c(f.faces[h].c,f.faces[h].a);b(f.faces[h].a,l,j,g);b(f.faces[h].b,k,l,g);b(f.faces[h].c,
j,k,g);b(l,k,j,g)}f.faces=g.faces}d.faces=f.faces;delete f;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron; j,k,g);b(l,k,j,g)}f.faces=g.faces}d.faces=f.faces;delete f;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
function Lathe(a,e,b){THREE.Geometry.call(this);this.steps=e||12;this.angle=b||2*Math.PI;e=this.angle/this.steps;for(var c=[],d=[],f=[],g=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));c[h]=a[h].clone();d[h]=this.vertices.length-1}for(var l=(new THREE.Matrix4).setRotationZ(e),k=0;k<=this.angle+0.0010;k+=e){for(h=0;h<c.length;h++)if(k<this.angle){c[h]=l.multiplyVector3(c[h].clone());this.vertices.push(new THREE.Vertex(c[h]));f[h]=this.vertices.length-1}else f=g;k==0&&(g=d);for(h= function Lathe(a,e,b){THREE.Geometry.call(this);this.steps=e||12;this.angle=b||2*Math.PI;e=this.angle/this.steps;for(var c=[],d=[],f=[],g=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));c[h]=a[h].clone();d[h]=this.vertices.length-1}for(var l=(new THREE.Matrix4).setRotationZ(e),k=0;k<=this.angle+0.001;k+=e){for(h=0;h<c.length;h++)if(k<this.angle){c[h]=l.multiplyVector3(c[h].clone());this.vertices.push(new THREE.Vertex(c[h]));f[h]=this.vertices.length-1}else f=g;k==0&&(g=d);for(h=
0;h<d.length-1;h++){this.faces.push(new THREE.Face4(f[h],f[h+1],d[h+1],d[h]));this.faceVertexUvs[0].push([new THREE.UV(k/b,h/a.length),new THREE.UV(k/b,(h+1)/a.length),new THREE.UV((k-e)/b,(h+1)/a.length),new THREE.UV((k-e)/b,h/a.length)])}d=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe; 0;h<d.length-1;h++){this.faces.push(new THREE.Face4(f[h],f[h+1],d[h+1],d[h]));this.faceVertexUvs[0].push([new THREE.UV(k/b,h/a.length),new THREE.UV(k/b,(h+1)/a.length),new THREE.UV((k-e)/b,(h+1)/a.length),new THREE.UV((k-e)/b,h/a.length)])}d=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
var Plane=function(a,e,b,c){THREE.Geometry.call(this);var d,f=a/2,g=e/2;b=b||1;c=c||1;var h=b+1,l=c+1;a/=b;var k=e/c;for(d=0;d<l;d++)for(e=0;e<h;e++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(e*a-f,-(d*k-g),0)));for(d=0;d<c;d++)for(e=0;e<b;e++){this.faces.push(new THREE.Face4(e+h*d,e+h*(d+1),e+1+h*(d+1),e+1+h*d));this.faceVertexUvs[0].push([new THREE.UV(e/b,d/c),new THREE.UV(e/b,(d+1)/c),new THREE.UV((e+1)/b,(d+1)/c),new THREE.UV((e+1)/b,d/c)])}this.computeCentroids();this.computeFaceNormals()}; var Plane=function(a,e,b,c){THREE.Geometry.call(this);var d,f=a/2,g=e/2;b=b||1;c=c||1;var h=b+1,l=c+1;a/=b;var k=e/c;for(d=0;d<l;d++)for(e=0;e<h;e++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(e*a-f,-(d*k-g),0)));for(d=0;d<c;d++)for(e=0;e<b;e++){this.faces.push(new THREE.Face4(e+h*d,e+h*(d+1),e+1+h*(d+1),e+1+h*d));this.faceVertexUvs[0].push([new THREE.UV(e/b,d/c),new THREE.UV(e/b,(d+1)/c),new THREE.UV((e+1)/b,(d+1)/c),new THREE.UV((e+1)/b,d/c)])}this.computeCentroids();this.computeFaceNormals()};
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane; Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
......
...@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined? ...@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=e*d;this.w=g*f-i*c;this.x=g*c+i*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*= THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=e*d;this.w=g*f-i*c;this.x=g*c+i*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,d=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+d*f+c*i-e*g;this.y=c*a+d*g+e*f-b*i;this.z=e*a+d*i+b*g-c*f;this.w=d*a-b*f-c*g-e*i;return this}, -1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,d=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+d*f+c*i-e*g;this.y=c*a+d*g+e*f-b*i;this.z=e*a+d*i+b*g-c*f;this.w=d*a-b*f-c*g-e*i;return this},
multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*d-i*e,m=h*e+i*c-f*d,l=h*d+f*e-g*c;c=-f*c-g*e-i*d;b.x=j*h+c*-f+m*-i-l*-g;b.y=m*h+c*-g+l*-f-j*-i;b.z=l*h+c*-i+j*-g-m*-f;return b}}; multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*d-i*e,m=h*e+i*c-f*d,l=h*d+f*e-g*c;c=-f*c-g*e-i*d;b.x=j*h+c*-f+m*-i-l*-g;b.y=m*h+c*-g+l*-f-j*-i;b.z=l*h+c*-i+j*-g-m*-f;return b}};
THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);if(Math.abs(g)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);if(Math.abs(g)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
THREE.Face3=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3}; THREE.Face3=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};
THREE.Face4=function(a,b,c,e,d,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)}; THREE.Face4=function(a,b,c,e,d,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;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.UV.prototype={set:function(a,b){this.u=a;this.v=b;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};
...@@ -80,10 +80,10 @@ THREE.Animation.prototype.interpolate=function(a,b,c,e,d,f,g){a=(c-a)*0.5;e=(e-b ...@@ -80,10 +80,10 @@ THREE.Animation.prototype.interpolate=function(a,b,c,e,d,f,g){a=(c-a)*0.5;e=(e-b
THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]}; THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
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.target=d||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype; 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.target=d||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)}; THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate= THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position)}a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0;for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};
!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};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.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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1;this.distance=c||0};THREE.DirectionalLight.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.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1;this.distance=c||0};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.MultiplyBlending=3;THREE.MaterialCounter={value:0}; THREE.MultiplyBlending=3;THREE.MaterialCounter={value:0};
THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth= THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth=
a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}}; a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1; THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;
......
此差异已折叠。
...@@ -69,9 +69,8 @@ ...@@ -69,9 +69,8 @@
particleMaterial = new THREE.ParticleCanvasMaterial( { particleMaterial = new THREE.ParticleCanvasMaterial( {
color: 0x000000, color: 0x000000,
program: function ( context, color ) { program: function ( context ) {
context.fillStyle = color.__styleString;
context.beginPath(); context.beginPath();
context.arc( 0, 0, 1, 0, PI2, true ); context.arc( 0, 0, 1, 0, PI2, true );
context.closePath(); context.closePath();
......
...@@ -64,19 +64,18 @@ ...@@ -64,19 +64,18 @@
scene.addLight( new THREE.AmbientLight( 0x00020 ) ); scene.addLight( new THREE.AmbientLight( 0x00020 ) );
light1 = new THREE.PointLight( 0xff0040 ); light1 = new THREE.PointLight( 0xff0040, 1, 50 );
scene.addLight( light1 ); scene.addLight( light1 );
light2 = new THREE.PointLight( 0x0040ff ); light2 = new THREE.PointLight( 0x0040ff, 1, 50 );
scene.addLight( light2 ); scene.addLight( light2 );
light3 = new THREE.PointLight( 0x80ff80 ); light3 = new THREE.PointLight( 0x80ff80, 1, 50 );
scene.addLight( light3 ); scene.addLight( light3 );
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var program = function ( context, color ) { var program = function ( context ) {
context.fillStyle = color.__styleString;
context.beginPath(); context.beginPath();
context.arc( 0, 0, 1, 0, PI2, true ); context.arc( 0, 0, 1, 0, PI2, true );
context.closePath(); context.closePath();
......
...@@ -64,19 +64,18 @@ ...@@ -64,19 +64,18 @@
scene.addLight( new THREE.AmbientLight( 0x00020 ) ); scene.addLight( new THREE.AmbientLight( 0x00020 ) );
light1 = new THREE.PointLight( 0xff0040 ); light1 = new THREE.PointLight( 0xff0040, 1, 50 );
scene.addLight( light1 ); scene.addLight( light1 );
light2 = new THREE.PointLight( 0x0040ff ); light2 = new THREE.PointLight( 0x0040ff, 1, 50 );
scene.addLight( light2 ); scene.addLight( light2 );
light3 = new THREE.PointLight( 0x80ff80 ); light3 = new THREE.PointLight( 0x80ff80, 1, 50 );
scene.addLight( light3 ); scene.addLight( light3 );
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var program = function ( context, color ) { var program = function ( context ) {
context.fillStyle = color.__styleString;
context.beginPath(); context.beginPath();
context.arc( 0, 0, 1, 0, PI2, true ); context.arc( 0, 0, 1, 0, PI2, true );
context.closePath(); context.closePath();
......
...@@ -60,16 +60,15 @@ ...@@ -60,16 +60,15 @@
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var material = new THREE.ParticleCanvasMaterial( { var material = new THREE.ParticleCanvasMaterial( {
color: 0xffffff, color: 0xffffff,
program: function ( context, color ) { program: function ( context ) {
context.fillStyle = color.__styleString; context.beginPath();
context.beginPath(); context.arc( 0, 0, 1, 0, PI2, true );
context.arc( 0, 0, 1, 0, PI2, true ); context.closePath();
context.closePath(); context.fill();
context.fill();
} }
} ); } );
......
...@@ -63,16 +63,15 @@ ...@@ -63,16 +63,15 @@
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var material = new THREE.ParticleCanvasMaterial( { var material = new THREE.ParticleCanvasMaterial( {
color: 0xffffff, color: 0xffffff,
program: function ( context, color ) { program: function ( context ) {
context.fillStyle = color.__styleString; context.beginPath();
context.beginPath(); context.arc( 0, 0, 1, 0, PI2, true );
context.arc( 0, 0, 1, 0, PI2, true ); context.closePath();
context.closePath(); context.fill();
context.fill();
} }
} ); } );
......
...@@ -112,9 +112,8 @@ ...@@ -112,9 +112,8 @@
} }
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var program = function ( context, color ) { var program = function ( context ) {
context.fillStyle = color.__styleString;
context.beginPath(); context.beginPath();
context.arc( 0, 0, 1, 0, PI2, true ); context.arc( 0, 0, 1, 0, PI2, true );
context.closePath(); context.closePath();
......
...@@ -128,16 +128,15 @@ ...@@ -128,16 +128,15 @@
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var material = new THREE.ParticleCanvasMaterial( { var material = new THREE.ParticleCanvasMaterial( {
color: 0x0808080, color: 0x0808080,
program: function ( context, color ) { program: function ( context ) {
context.fillStyle = color.__styleString; context.beginPath();
context.beginPath(); context.arc( 0, 0, 1, 0, PI2, true );
context.arc( 0, 0, 1, 0, PI2, true ); context.closePath();
context.closePath(); context.fill();
context.fill();
} }
} ); } );
......
...@@ -53,9 +53,8 @@ ...@@ -53,9 +53,8 @@
var material = new THREE.ParticleCanvasMaterial( { var material = new THREE.ParticleCanvasMaterial( {
color: 0xffffff, color: 0xffffff,
program: function ( context, color ) { program: function ( context ) {
context.fillStyle = color.__styleString;
context.beginPath(); context.beginPath();
context.arc( 0, 0, 1, 0, PI2, true ); context.arc( 0, 0, 1, 0, PI2, true );
context.closePath(); context.closePath();
......
...@@ -46,9 +46,8 @@ ...@@ -46,9 +46,8 @@
scene = new THREE.Scene(); scene = new THREE.Scene();
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var program = function ( context, color ) { var program = function ( context ) {
context.fillStyle = color.__styleString;
context.beginPath(); context.beginPath();
context.arc( 0, 0, 1, 0, PI2, true ); context.arc( 0, 0, 1, 0, PI2, true );
context.closePath(); context.closePath();
......
...@@ -54,16 +54,15 @@ ...@@ -54,16 +54,15 @@
var PI2 = Math.PI * 2; var PI2 = Math.PI * 2;
var material = new THREE.ParticleCanvasMaterial( { var material = new THREE.ParticleCanvasMaterial( {
color: 0xffffff, color: 0xffffff,
program: function ( context, color ) { program: function ( context ) {
context.strokeStyle = color.__styleString; context.beginPath();
context.beginPath(); context.arc( 0, 0, 1, 0, PI2, true );
context.arc( 0, 0, 1, 0, PI2, true ); context.closePath();
context.closePath(); context.stroke();
context.stroke();
} }
} ); } );
......
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
directionalLight.position.z = 0; directionalLight.position.z = 0;
scene.addLight( directionalLight ); scene.addLight( directionalLight );
var pointLight = new THREE.PointLight( 0xff0000, 1 ); var pointLight = new THREE.PointLight( 0xff0000, 1, 500 );
scene.addLight( pointLight ); scene.addLight( pointLight );
renderer = new THREE.CanvasRenderer(); renderer = new THREE.CanvasRenderer();
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
var container = document.getElementById( 'container' ); var container = document.getElementById( 'container' );
camera = new THREE.Camera( 65, window.innerWidth / window.innerHeight, 1, 1000 ); camera = new THREE.Camera( 50, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.z = 100; camera.position.z = 100;
scene = new THREE.Scene(); scene = new THREE.Scene();
...@@ -98,13 +98,13 @@ ...@@ -98,13 +98,13 @@
scene.addLight( new THREE.AmbientLight( 0x00000 ) ); scene.addLight( new THREE.AmbientLight( 0x00000 ) );
light1 = new THREE.PointLight( 0xff0040 ); light1 = new THREE.PointLight( 0xff0040, 1, 50 );
scene.addLight( light1 ); scene.addLight( light1 );
light2 = new THREE.PointLight( 0x0040ff ); light2 = new THREE.PointLight( 0x0040ff, 1, 50 );
scene.addLight( light2 ); scene.addLight( light2 );
light3 = new THREE.PointLight( 0x80ff80 ); light3 = new THREE.PointLight( 0x80ff80, 1, 50 );
scene.addLight( light3 ); scene.addLight( light3 );
var sphere = new Sphere( 0.5, 16, 8 ); var sphere = new Sphere( 0.5, 16, 8 );
......
...@@ -77,30 +77,19 @@ THREE.Camera.prototype.update = function ( parentMatrixWorld, forceUpdate, camer ...@@ -77,30 +77,19 @@ THREE.Camera.prototype.update = function ( parentMatrixWorld, forceUpdate, camer
} else { } else {
if ( this.matrixAutoUpdate ) { if ( parentMatrixWorld ) {
forceUpdate |= this.updateMatrix(); this.matrixWorld.multiply( parentMatrixWorld, this.matrix );
}
if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
if ( parentMatrixWorld ) {
this.matrixWorld.multiply( parentMatrixWorld, this.matrix );
} else {
this.matrixWorld.copy( this.matrix ); } else {
} this.matrixWorld.copy( this.matrix );
this.matrixWorldNeedsUpdate = false; }
forceUpdate = true;
THREE.Matrix4.makeInvert( this.matrixWorld, this.matrixWorldInverse ); THREE.Matrix4.makeInvert( this.matrixWorld, this.matrixWorldInverse );
} forceUpdate = true;
} }
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
* @author mr.doob / http://mrdoob.com/ * @author mr.doob / http://mrdoob.com/
*/ */
THREE.DirectionalLight = function ( hex, intensity ) { THREE.DirectionalLight = function ( hex, intensity, distance ) {
THREE.Light.call( this, hex ); THREE.Light.call( this, hex );
this.position = new THREE.Vector3( 0, 1, 0 ); this.position = new THREE.Vector3( 0, 1, 0 );
this.intensity = intensity || 1; this.intensity = intensity || 1;
this.distance = distance || 0;
}; };
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
* @author mr.doob / http://mrdoob.com/ * @author mr.doob / http://mrdoob.com/
*/ */
THREE.PointLight = function ( hex, intensity ) { THREE.PointLight = function ( hex, intensity, distance ) {
THREE.Light.call( this, hex ); THREE.Light.call( this, hex );
this.position = new THREE.Vector3(); this.position = new THREE.Vector3();
this.intensity = intensity || 1; this.intensity = intensity || 1;
this.distance = distance || 0;
}; };
......
...@@ -358,12 +358,16 @@ THREE.CanvasRenderer = function () { ...@@ -358,12 +358,16 @@ THREE.CanvasRenderer = function () {
} else if ( light instanceof THREE.DirectionalLight ) { } else if ( light instanceof THREE.DirectionalLight ) {
// for particles
_directionalLights.r += lightColor.r; _directionalLights.r += lightColor.r;
_directionalLights.g += lightColor.g; _directionalLights.g += lightColor.g;
_directionalLights.b += lightColor.b; _directionalLights.b += lightColor.b;
} else if ( light instanceof THREE.PointLight ) { } else if ( light instanceof THREE.PointLight ) {
// for particles
_pointLights.r += lightColor.r; _pointLights.r += lightColor.r;
_pointLights.g += lightColor.g; _pointLights.g += lightColor.g;
_pointLights.b += lightColor.b; _pointLights.b += lightColor.b;
...@@ -376,41 +380,41 @@ THREE.CanvasRenderer = function () { ...@@ -376,41 +380,41 @@ THREE.CanvasRenderer = function () {
function calculateLight( scene, position, normal, color ) { function calculateLight( scene, position, normal, color ) {
var l, ll, light, lightColor, lightIntensity, var l, ll, light, lightColor,
amount, lights = scene.lights; amount, lights = scene.lights;
for ( l = 0, ll = lights.length; l < ll; l ++ ) { for ( l = 0, ll = lights.length; l < ll; l ++ ) {
light = lights[ l ]; light = lights[ l ];
lightColor = light.color; lightColor = light.color;
lightIntensity = light.intensity;
if ( light instanceof THREE.DirectionalLight ) { if ( light instanceof THREE.DirectionalLight ) {
amount = normal.dot( light.position ) * lightIntensity; amount = normal.dot( light.position );
if ( amount > 0 ) { if ( amount <= 0 ) continue;
color.r += lightColor.r * amount; amount *= light.intensity;
color.g += lightColor.g * amount;
color.b += lightColor.b * amount;
} color.r += lightColor.r * amount;
color.g += lightColor.g * amount;
color.b += lightColor.b * amount;
} else if ( light instanceof THREE.PointLight ) { } else if ( light instanceof THREE.PointLight ) {
_vector3.sub( light.position, position ); amount = normal.dot( _vector3.sub( light.position, position ).normalize() );
_vector3.normalize();
amount = normal.dot( _vector3 ) * lightIntensity; if ( amount <= 0 ) continue;
if ( amount > 0 ) { amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( light.position ) / light.distance, 1 );
color.r += lightColor.r * amount; if ( amount == 0 ) continue;
color.g += lightColor.g * amount;
color.b += lightColor.b * amount;
} amount *= light.intensity;
color.r += lightColor.r * amount;
color.g += lightColor.g * amount;
color.b += lightColor.b * amount;
} }
...@@ -475,24 +479,6 @@ THREE.CanvasRenderer = function () { ...@@ -475,24 +479,6 @@ THREE.CanvasRenderer = function () {
} else if ( material instanceof THREE.ParticleCanvasMaterial ) { } else if ( material instanceof THREE.ParticleCanvasMaterial ) {
if ( _enableLighting ) {
_light.r = _ambientLight.r + _directionalLights.r + _pointLights.r;
_light.g = _ambientLight.g + _directionalLights.g + _pointLights.g;
_light.b = _ambientLight.b + _directionalLights.b + _pointLights.b;
_color.r = material.color.r * _light.r;
_color.g = material.color.g * _light.g;
_color.b = material.color.b * _light.b;
_color.updateStyleString();
} else {
_color.__styleString = material.color.__styleString;
}
width = element.scale.x * _canvasWidthHalf; width = element.scale.x * _canvasWidthHalf;
height = element.scale.y * _canvasHeightHalf; height = element.scale.y * _canvasHeightHalf;
...@@ -504,12 +490,15 @@ THREE.CanvasRenderer = function () { ...@@ -504,12 +490,15 @@ THREE.CanvasRenderer = function () {
} }
setStrokeStyle( material.color.__styleString );
setFillStyle( material.color.__styleString );
_context.save(); _context.save();
_context.translate( v1.x, v1.y ); _context.translate( v1.x, v1.y );
_context.rotate( - element.rotation ); _context.rotate( - element.rotation );
_context.scale( width, height ); _context.scale( width, height );
material.program( _context, _color ); material.program( _context );
_context.restore(); _context.restore();
......
...@@ -63,7 +63,7 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -63,7 +63,7 @@ THREE.WebGLRenderer = function ( parameters ) {
ambient: [ 0, 0, 0 ], ambient: [ 0, 0, 0 ],
directional: { length: 0, colors: new Array(), positions: new Array() }, directional: { length: 0, colors: new Array(), positions: new Array() },
point: { length: 0, colors: new Array(), positions: new Array() } point: { length: 0, colors: new Array(), positions: new Array(), distances: new Array() }
}, },
...@@ -192,15 +192,16 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -192,15 +192,16 @@ THREE.WebGLRenderer = function ( parameters ) {
function setupLights ( program, lights ) { function setupLights ( program, lights ) {
var l, ll, light, r = 0, g = 0, b = 0, var l, ll, light, r = 0, g = 0, b = 0,
color, position, intensity, color, position, intensity, distance,
zlights = _lights, zlights = _lights,
dcolors = zlights.directional.colors, dcolors = zlights.directional.colors,
dpositions = zlights.directional.positions, dpositions = zlights.directional.positions,
pcolors = zlights.point.colors, pcolors = zlights.point.colors,
ppositions = zlights.point.positions, ppositions = zlights.point.positions,
pdistances = zlights.point.distances,
dlength = 0, dlength = 0,
plength = 0, plength = 0,
...@@ -212,8 +213,10 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -212,8 +213,10 @@ THREE.WebGLRenderer = function ( parameters ) {
light = lights[ l ]; light = lights[ l ];
color = light.color; color = light.color;
position = light.position; position = light.position;
intensity = light.intensity; intensity = light.intensity;
distance = light.distance;
if ( light instanceof THREE.AmbientLight ) { if ( light instanceof THREE.AmbientLight ) {
...@@ -225,11 +228,11 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -225,11 +228,11 @@ THREE.WebGLRenderer = function ( parameters ) {
doffset = dlength * 3; doffset = dlength * 3;
dcolors[ doffset ] = color.r * intensity; dcolors[ doffset ] = color.r * intensity;
dcolors[ doffset + 1 ] = color.g * intensity; dcolors[ doffset + 1 ] = color.g * intensity;
dcolors[ doffset + 2 ] = color.b * intensity; dcolors[ doffset + 2 ] = color.b * intensity;
dpositions[ doffset ] = position.x; dpositions[ doffset ] = position.x;
dpositions[ doffset + 1 ] = position.y; dpositions[ doffset + 1 ] = position.y;
dpositions[ doffset + 2 ] = position.z; dpositions[ doffset + 2 ] = position.z;
...@@ -239,14 +242,16 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -239,14 +242,16 @@ THREE.WebGLRenderer = function ( parameters ) {
poffset = plength * 3; poffset = plength * 3;
pcolors[ poffset ] = color.r * intensity; pcolors[ poffset ] = color.r * intensity;
pcolors[ poffset + 1 ] = color.g * intensity; pcolors[ poffset + 1 ] = color.g * intensity;
pcolors[ poffset + 2 ] = color.b * intensity; pcolors[ poffset + 2 ] = color.b * intensity;
ppositions[ poffset ] = position.x; ppositions[ poffset ] = position.x;
ppositions[ poffset + 1 ] = position.y; ppositions[ poffset + 1 ] = position.y;
ppositions[ poffset + 2 ] = position.z; ppositions[ poffset + 2 ] = position.z;
pdistances[ plength ] = distance;
plength += 1; plength += 1;
} }
...@@ -1594,6 +1599,7 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -1594,6 +1599,7 @@ THREE.WebGLRenderer = function ( parameters ) {
uniforms.directionalLightDirection.value = lights.directional.positions; uniforms.directionalLightDirection.value = lights.directional.positions;
uniforms.pointLightColor.value = lights.point.colors; uniforms.pointLightColor.value = lights.point.colors;
uniforms.pointLightPosition.value = lights.point.positions; uniforms.pointLightPosition.value = lights.point.positions;
uniforms.pointLightDistance.value = lights.point.distances;
}; };
...@@ -3867,19 +3873,19 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -3867,19 +3873,19 @@ THREE.WebGLRenderer = function ( parameters ) {
// - leave some extra space for other uniforms // - leave some extra space for other uniforms
// - limit here is ANGLE's 254 max uniform vectors // - limit here is ANGLE's 254 max uniform vectors
// (up to 54 should be safe) // (up to 54 should be safe)
var maxBones = 50; var maxBones = 50;
if ( object !== undefined && object instanceof THREE.SkinnedMesh ) { if ( object !== undefined && object instanceof THREE.SkinnedMesh ) {
maxBones = object.bones.length; maxBones = object.bones.length;
} }
return maxBones; return maxBones;
}; };
function allocateLights ( lights, maxLights ) { function allocateLights ( lights, maxLights ) {
var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights; var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights;
......
...@@ -240,9 +240,10 @@ THREE.ShaderChunk = { ...@@ -240,9 +240,10 @@ THREE.ShaderChunk = {
"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];", "uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];",
"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];", "uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];",
"uniform float pointLightDistance[ MAX_POINT_LIGHTS ];",
"#ifdef PHONG", "#ifdef PHONG",
"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];", "varying vec4 vPointLight[ MAX_POINT_LIGHTS ];",
"#endif", "#endif",
"#endif" "#endif"
...@@ -275,18 +276,27 @@ THREE.ShaderChunk = { ...@@ -275,18 +276,27 @@ THREE.ShaderChunk = {
"#if MAX_POINT_LIGHTS > 0", "#if MAX_POINT_LIGHTS > 0",
"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {", "for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {",
"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );", "vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );",
"vec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );",
"float pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );",
"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;",
"#ifdef PHONG", "vec3 lVector = lPosition.xyz - mvPosition.xyz;",
"vPointLightVector[ i ] = pointLightVector;",
"#endif",
"}", "float lDistance = 1.0;",
"if ( pointLightDistance[ i ] > 0.0 )",
"lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );",
"lVector = normalize( lVector );",
"float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );",
"vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;",
"#ifdef PHONG",
"vPointLight[ i ] = vec4( lVector, lDistance );",
"#endif",
"}",
"#endif", "#endif",
...@@ -301,7 +311,7 @@ THREE.ShaderChunk = { ...@@ -301,7 +311,7 @@ THREE.ShaderChunk = {
"#endif", "#endif",
"#if MAX_POINT_LIGHTS > 0", "#if MAX_POINT_LIGHTS > 0",
"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];", "varying vec4 vPointLight[ MAX_POINT_LIGHTS ];",
"#endif", "#endif",
"varying vec3 vViewPosition;", "varying vec3 vViewPosition;",
...@@ -322,22 +332,24 @@ THREE.ShaderChunk = { ...@@ -322,22 +332,24 @@ THREE.ShaderChunk = {
"vec4 pointDiffuse = vec4( 0.0 );", "vec4 pointDiffuse = vec4( 0.0 );",
"vec4 pointSpecular = vec4( 0.0 );", "vec4 pointSpecular = vec4( 0.0 );",
"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {", "for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {",
"vec3 pointVector = normalize( vPointLightVector[ i ] );", "vec3 pointVector = normalize( vPointLight[ i ].xyz );",
"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );", "vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );",
"float pointDistance = vPointLight[ i ].w;",
"float pointDotNormalHalf = dot( normal, pointHalfVector );", "float pointDotNormalHalf = dot( normal, pointHalfVector );",
"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );", "float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
"float pointSpecularWeight = 0.0;", "float pointSpecularWeight = 0.0;",
"if ( pointDotNormalHalf >= 0.0 )", "if ( pointDotNormalHalf >= 0.0 )",
"pointSpecularWeight = pow( pointDotNormalHalf, shininess );", "pointSpecularWeight = pow( pointDotNormalHalf, shininess );",
"pointDiffuse += mColor * pointDiffuseWeight;", "pointDiffuse += mColor * pointDiffuseWeight * pointDistance;",
"pointSpecular += mSpecular * pointSpecularWeight;", "pointSpecular += mSpecular * pointSpecularWeight * pointDistance;",
"}", "}",
"#endif", "#endif",
...@@ -505,50 +517,51 @@ THREE.UniformsLib = { ...@@ -505,50 +517,51 @@ THREE.UniformsLib = {
common: { common: {
"diffuse" : { type: "c", value: new THREE.Color( 0xeeeeee ) }, "diffuse" : { type: "c", value: new THREE.Color( 0xeeeeee ) },
"opacity" : { type: "f", value: 1.0 }, "opacity" : { type: "f", value: 1.0 },
"map" : { type: "t", value: 0, texture: null }, "map" : { type: "t", value: 0, texture: null },
"lightMap" : { type: "t", value: 2, texture: null }, "lightMap" : { type: "t", value: 2, texture: null },
"envMap" : { type: "t", value: 1, texture: null }, "envMap" : { type: "t", value: 1, texture: null },
"useRefract" : { type: "i", value: 0 }, "useRefract" : { type: "i", value: 0 },
"reflectivity" : { type: "f", value: 1.0 }, "reflectivity" : { type: "f", value: 1.0 },
"refractionRatio": { type: "f", value: 0.98 }, "refractionRatio" : { type: "f", value: 0.98 },
"combine" : { type: "i", value: 0 }, "combine" : { type: "i", value: 0 },
"fogDensity": { type: "f", value: 0.00025 }, "fogDensity" : { type: "f", value: 0.00025 },
"fogNear" : { type: "f", value: 1 }, "fogNear" : { type: "f", value: 1 },
"fogFar" : { type: "f", value: 2000 }, "fogFar" : { type: "f", value: 2000 },
"fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) }, "fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) },
"morphTargetInfluences" : { type: "f", value: 0 } "morphTargetInfluences" : { type: "f", value: 0 }
}, },
lights: { lights: {
"enableLighting" : { type: "i", value: 1 }, "enableLighting" : { type: "i", value: 1 },
"ambientLightColor" : { type: "fv", value: [] }, "ambientLightColor" : { type: "fv", value: [] },
"directionalLightDirection" : { type: "fv", value: [] }, "directionalLightDirection" : { type: "fv", value: [] },
"directionalLightColor" : { type: "fv", value: [] }, "directionalLightColor" : { type: "fv", value: [] },
"pointLightPosition" : { type: "fv", value: [] }, "pointLightColor" : { type: "fv", value: [] },
"pointLightColor" : { type: "fv", value: [] } "pointLightPosition" : { type: "fv", value: [] },
"pointLightDistance" : { type: "fv1", value: [] }
}, },
particle: { particle: {
"psColor" : { type: "c", value: new THREE.Color( 0xeeeeee ) }, "psColor" : { type: "c", value: new THREE.Color( 0xeeeeee ) },
"opacity" : { type: "f", value: 1.0 }, "opacity" : { type: "f", value: 1.0 },
"size" : { type: "f", value: 1.0 }, "size" : { type: "f", value: 1.0 },
"scale" : { type: "f", value: 1.0 }, "scale" : { type: "f", value: 1.0 },
"map" : { type: "t", value: 0, texture: null }, "map" : { type: "t", value: 0, texture: null },
"fogDensity": { type: "f", value: 0.00025 }, "fogDensity" : { type: "f", value: 0.00025 },
"fogNear" : { type: "f", value: 1 }, "fogNear" : { type: "f", value: 1 },
"fogFar" : { type: "f", value: 2000 }, "fogFar" : { type: "f", value: 2000 },
"fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) } "fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册