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

Updated builds.

上级 61b7c68a
......@@ -31797,7 +31797,6 @@ THREE.CameraHelper.prototype.update = function () {
var vector = new THREE.Vector3();
var camera = new THREE.Camera();
var projector = new THREE.Projector();
return function () {
......@@ -31849,8 +31848,7 @@ THREE.CameraHelper.prototype.update = function () {
function setPoint( point, x, y, z ) {
vector.set( x, y, z );
projector.unprojectVector( vector, camera );
vector.set( x, y, z ).unproject( camera );
var points = scope.pointMap[ point ];
......@@ -34035,7 +34033,7 @@ THREE.ShadowMapPlugin = function () {
var p = pointsWorld[ i ];
p.copy( pointsFrustum[ i ] );
THREE.ShadowMapPlugin.__projector.unprojectVector( p, camera );
p.unproject( camera );
p.applyMatrix4( shadowCamera.matrixWorldInverse );
......@@ -34076,8 +34074,6 @@ THREE.ShadowMapPlugin = function () {
};
THREE.ShadowMapPlugin.__projector = new THREE.Projector();
// File:src/extras/renderers/plugins/SpritePlugin.js
/**
......
......@@ -738,8 +738,8 @@ this.matrixAutoUpdate=!1};THREE.BoundingBoxHelper=function(a,b){var c=void 0!==b
THREE.CameraHelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.vertices.push(new THREE.Vector3);d.colors.push(new THREE.Color(b));void 0===g[a]&&(g[a]=[]);g[a].push(d.vertices.length-1)}var d=new THREE.Geometry,e=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors}),g={};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);
b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);THREE.Line.call(this,d,e,THREE.LinePieces);this.camera=a;this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=g;this.update()};
THREE.CameraHelper.prototype=Object.create(THREE.Line.prototype);
THREE.CameraHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Camera,c=new THREE.Projector;return function(){function d(d,f,h,k){a.set(f,h,k);c.unprojectVector(a,b);d=e.pointMap[d];if(void 0!==d)for(f=0,h=d.length;f<h;f++)e.geometry.vertices[d[f]].copy(a)}var e=this;b.projectionMatrix.copy(this.camera.projectionMatrix);d("c",0,0,-1);d("t",0,0,1);d("n1",-1,-1,-1);d("n2",1,-1,-1);d("n3",-1,1,-1);d("n4",1,1,-1);d("f1",-1,-1,1);d("f2",1,-1,1);d("f3",-1,1,1);d("f4",1,1,1);d("u1",.7,
1.1,-1);d("u2",-.7,1.1,-1);d("u3",0,2,-1);d("cf1",-1,0,1);d("cf2",1,0,1);d("cf3",0,-1,1);d("cf4",0,1,1);d("cn1",-1,0,-1);d("cn2",1,0,-1);d("cn3",0,-1,-1);d("cn4",0,1,-1);this.geometry.verticesNeedUpdate=!0}}();
THREE.CameraHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Camera;return function(){function c(c,g,f,h){a.set(g,f,h).unproject(b);c=d.pointMap[c];if(void 0!==c)for(g=0,f=c.length;g<f;g++)d.geometry.vertices[c[g]].copy(a)}var d=this;b.projectionMatrix.copy(this.camera.projectionMatrix);c("c",0,0,-1);c("t",0,0,1);c("n1",-1,-1,-1);c("n2",1,-1,-1);c("n3",-1,1,-1);c("n4",1,1,-1);c("f1",-1,-1,1);c("f2",1,-1,1);c("f3",-1,1,1);c("f4",1,1,1);c("u1",.7,1.1,-1);c("u2",-.7,1.1,-1);c("u3",
0,2,-1);c("cf1",-1,0,1);c("cf2",1,0,1);c("cf3",0,-1,1);c("cf4",0,1,1);c("cn1",-1,0,-1);c("cn2",1,0,-1);c("cn3",0,-1,-1);c("cn4",0,1,-1);this.geometry.verticesNeedUpdate=!0}}();
THREE.DirectionalLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;b=b||1;var c=new THREE.Geometry;c.vertices.push(new THREE.Vector3(-b,b,0),new THREE.Vector3(b,b,0),new THREE.Vector3(b,-b,0),new THREE.Vector3(-b,-b,0),new THREE.Vector3(-b,b,0));var d=new THREE.LineBasicMaterial({fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.lightPlane=new THREE.Line(c,d);this.add(this.lightPlane);
c=new THREE.Geometry;c.vertices.push(new THREE.Vector3,new THREE.Vector3);d=new THREE.LineBasicMaterial({fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.targetLine=new THREE.Line(c,d);this.add(this.targetLine);this.update()};THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype);
THREE.DirectionalLightHelper.prototype.dispose=function(){this.lightPlane.geometry.dispose();this.lightPlane.material.dispose();this.targetLine.geometry.dispose();this.targetLine.material.dispose()};
......@@ -797,10 +797,10 @@ K.shadowDarkness=y.shadowDarkness;K.shadowBias=y.shadowCascadeBias[S];K.shadowMa
B.position.copy(x.shadowCascadeOffset);B.add(K);B.add(K.target);w.add(B);x.shadowCascadeArray[C]=K;console.log("Created virtualLight",K)}S=x;D=C;y=S.shadowCascadeArray[D];y.position.copy(S.position);y.target.position.copy(S.target.position);y.lookAt(y.target);y.shadowCameraVisible=S.shadowCameraVisible;y.shadowDarkness=S.shadowDarkness;y.shadowBias=S.shadowCascadeBias[D];B=S.shadowCascadeNearZ[D];S=S.shadowCascadeFarZ[D];y=y.pointsFrustum;y[0].z=B;y[1].z=B;y[2].z=B;y[3].z=B;y[4].z=S;y[5].z=S;y[6].z=
S;y[7].z=S;J[F]=K;F++}else J[F]=x,F++;u=0;for(z=J.length;u<z;u++){x=J[u];x.shadowMap||(C=THREE.LinearFilter,c.shadowMapType===THREE.PCFSoftShadowMap&&(C=THREE.NearestFilter),x.shadowMap=new THREE.WebGLRenderTarget(x.shadowMapWidth,x.shadowMapHeight,{minFilter:C,magFilter:C,format:THREE.RGBAFormat}),x.shadowMapSize=new THREE.Vector2(x.shadowMapWidth,x.shadowMapHeight),x.shadowMatrix=new THREE.Matrix4);if(!x.shadowCamera){if(x instanceof THREE.SpotLight)x.shadowCamera=new THREE.PerspectiveCamera(x.shadowCameraFov,
x.shadowMapWidth/x.shadowMapHeight,x.shadowCameraNear,x.shadowCameraFar);else if(x instanceof THREE.DirectionalLight)x.shadowCamera=new THREE.OrthographicCamera(x.shadowCameraLeft,x.shadowCameraRight,x.shadowCameraTop,x.shadowCameraBottom,x.shadowCameraNear,x.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}e.add(x.shadowCamera);!0===e.autoUpdate&&e.updateMatrixWorld()}x.shadowCameraVisible&&!x.cameraHelper&&(x.cameraHelper=new THREE.CameraHelper(x.shadowCamera),x.shadowCamera.add(x.cameraHelper));
if(x.isVirtual&&K.originalCamera==w){C=w;F=x.shadowCamera;B=x.pointsFrustum;y=x.pointsWorld;r.set(Infinity,Infinity,Infinity);t.set(-Infinity,-Infinity,-Infinity);for(S=0;8>S;S++)D=y[S],D.copy(B[S]),THREE.ShadowMapPlugin.__projector.unprojectVector(D,C),D.applyMatrix4(F.matrixWorldInverse),D.x<r.x&&(r.x=D.x),D.x>t.x&&(t.x=D.x),D.y<r.y&&(r.y=D.y),D.y>t.y&&(t.y=D.y),D.z<r.z&&(r.z=D.z),D.z>t.z&&(t.z=D.z);F.left=r.x;F.right=t.x;F.top=t.y;F.bottom=r.y;F.updateProjectionMatrix()}F=x.shadowMap;B=x.shadowMatrix;
C=x.shadowCamera;C.position.setFromMatrixPosition(x.matrixWorld);p.setFromMatrixPosition(x.target.matrixWorld);C.lookAt(p);C.updateMatrixWorld();C.matrixWorldInverse.getInverse(C.matrixWorld);x.cameraHelper&&(x.cameraHelper.visible=x.shadowCameraVisible);x.shadowCameraVisible&&x.cameraHelper.update();B.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);B.multiply(C.projectionMatrix);B.multiply(C.matrixWorldInverse);q.multiplyMatrices(C.projectionMatrix,C.matrixWorldInverse);n.setFromMatrix(q);c.setRenderTarget(F);
c.clear();s.length=0;a(e,e,C);x=0;for(F=s.length;x<F;x++)y=s[x],B=y.object,y=y.buffer,S=B.material instanceof THREE.MeshFaceMaterial?B.material.materials[0]:B.material,D=void 0!==B.geometry.morphTargets&&0<B.geometry.morphTargets.length&&S.morphTargets,Q=B instanceof THREE.SkinnedMesh&&S.skinning,D=B.customDepthMaterial?B.customDepthMaterial:Q?D?m:k:D?h:f,c.setMaterialFaces(S),y instanceof THREE.BufferGeometry?c.renderBufferDirect(C,d,null,D,y,B):c.renderBuffer(C,d,null,D,y,B);x=0;for(F=g.length;x<
F;x++)y=g[x],B=y.object,B.visible&&B.castShadow&&(B._modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,B.matrixWorld),c.renderImmediateObject(C,d,null,f,B))}u=c.getClearColor();z=c.getClearAlpha();b.clearColor(u.r,u.g,u.b,z);b.enable(b.BLEND);c.shadowMapCullFace===THREE.CullFaceFront&&b.cullFace(b.BACK);c.resetGLState()}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
if(x.isVirtual&&K.originalCamera==w){C=w;F=x.shadowCamera;B=x.pointsFrustum;y=x.pointsWorld;r.set(Infinity,Infinity,Infinity);t.set(-Infinity,-Infinity,-Infinity);for(S=0;8>S;S++)D=y[S],D.copy(B[S]),D.unproject(C),D.applyMatrix4(F.matrixWorldInverse),D.x<r.x&&(r.x=D.x),D.x>t.x&&(t.x=D.x),D.y<r.y&&(r.y=D.y),D.y>t.y&&(t.y=D.y),D.z<r.z&&(r.z=D.z),D.z>t.z&&(t.z=D.z);F.left=r.x;F.right=t.x;F.top=t.y;F.bottom=r.y;F.updateProjectionMatrix()}F=x.shadowMap;B=x.shadowMatrix;C=x.shadowCamera;C.position.setFromMatrixPosition(x.matrixWorld);
p.setFromMatrixPosition(x.target.matrixWorld);C.lookAt(p);C.updateMatrixWorld();C.matrixWorldInverse.getInverse(C.matrixWorld);x.cameraHelper&&(x.cameraHelper.visible=x.shadowCameraVisible);x.shadowCameraVisible&&x.cameraHelper.update();B.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);B.multiply(C.projectionMatrix);B.multiply(C.matrixWorldInverse);q.multiplyMatrices(C.projectionMatrix,C.matrixWorldInverse);n.setFromMatrix(q);c.setRenderTarget(F);c.clear();s.length=0;a(e,e,C);x=0;for(F=s.length;x<F;x++)y=
s[x],B=y.object,y=y.buffer,S=B.material instanceof THREE.MeshFaceMaterial?B.material.materials[0]:B.material,D=void 0!==B.geometry.morphTargets&&0<B.geometry.morphTargets.length&&S.morphTargets,Q=B instanceof THREE.SkinnedMesh&&S.skinning,D=B.customDepthMaterial?B.customDepthMaterial:Q?D?m:k:D?h:f,c.setMaterialFaces(S),y instanceof THREE.BufferGeometry?c.renderBufferDirect(C,d,null,D,y,B):c.renderBuffer(C,d,null,D,y,B);x=0;for(F=g.length;x<F;x++)y=g[x],B=y.object,B.visible&&B.castShadow&&(B._modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,
B.matrixWorld),c.renderImmediateObject(C,d,null,f,B))}u=c.getClearColor();z=c.getClearAlpha();b.clearColor(u.r,u.g,u.b,z);b.enable(b.BLEND);c.shadowMapCullFace===THREE.CullFaceFront&&b.cullFace(b.BACK);c.resetGLState()}};
THREE.SpritePlugin=function(){var a,b,c,d,e,g,f,h,k,m,n,q,r,t,p,s,v;function w(a,b){return a.z!==b.z?b.z-a.z:b.id-a.id}var u,z,x,F=[],C,B,y,D,J;this.init=function(w){u=w.context;z=w;C=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]);B=new Uint16Array([0,1,2,0,2,3]);y=u.createBuffer();D=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,y);u.bufferData(u.ARRAY_BUFFER,C,u.STATIC_DRAW);u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,D);u.bufferData(u.ELEMENT_ARRAY_BUFFER,B,u.STATIC_DRAW);w=u.createProgram();
var F=u.createShader(u.VERTEX_SHADER),Q=u.createShader(u.FRAGMENT_SHADER);u.shaderSource(F,["precision "+z.getPrecision()+" float;","uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\nvec4 finalPosition;\nfinalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition;\nfinalPosition = projectionMatrix * finalPosition;\ngl_Position = finalPosition;\n}"].join("\n"));
u.shaderSource(Q,["precision "+z.getPrecision()+" float;","uniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册