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

Updated builds.

上级 3f839c94
......@@ -31938,12 +31938,33 @@ THREE.CameraHelper.prototype = Object.create( THREE.Line.prototype );
THREE.CameraHelper.prototype.update = function () {
var geometry, pointMap;
var vector = new THREE.Vector3();
var camera = new THREE.Camera();
var setPoint = function ( point, x, y, z ) {
vector.set( x, y, z ).unproject( camera );
var points = pointMap[ point ];
if ( points !== undefined ) {
for ( var i = 0, il = points.length; i < il; i ++ ) {
geometry.vertices[ points[ i ] ].copy( vector );
}
}
};
return function () {
var scope = this;
geometry = this.geometry;
pointMap = this.pointMap;
var w = 1, h = 1;
......@@ -31960,54 +31981,36 @@ THREE.CameraHelper.prototype.update = function () {
// near
setPoint( "n1", - w, - h, - 1 );
setPoint( "n2", w, - h, - 1 );
setPoint( "n3", - w, h, - 1 );
setPoint( "n4", w, h, - 1 );
setPoint( "n2", w, - h, - 1 );
setPoint( "n3", - w, h, - 1 );
setPoint( "n4", w, h, - 1 );
// far
setPoint( "f1", - w, - h, 1 );
setPoint( "f2", w, - h, 1 );
setPoint( "f3", - w, h, 1 );
setPoint( "f4", w, h, 1 );
setPoint( "f2", w, - h, 1 );
setPoint( "f3", - w, h, 1 );
setPoint( "f4", w, h, 1 );
// up
setPoint( "u1", w * 0.7, h * 1.1, - 1 );
setPoint( "u1", w * 0.7, h * 1.1, - 1 );
setPoint( "u2", - w * 0.7, h * 1.1, - 1 );
setPoint( "u3", 0, h * 2, - 1 );
setPoint( "u3", 0, h * 2, - 1 );
// cross
setPoint( "cf1", - w, 0, 1 );
setPoint( "cf2", w, 0, 1 );
setPoint( "cf3", 0, - h, 1 );
setPoint( "cf4", 0, h, 1 );
setPoint( "cn1", - w, 0, - 1 );
setPoint( "cn2", w, 0, - 1 );
setPoint( "cn3", 0, - h, - 1 );
setPoint( "cn4", 0, h, - 1 );
function setPoint( point, x, y, z ) {
setPoint( "cf1", - w, 0, 1 );
setPoint( "cf2", w, 0, 1 );
setPoint( "cf3", 0, - h, 1 );
setPoint( "cf4", 0, h, 1 );
vector.set( x, y, z ).unproject( camera );
setPoint( "cn1", - w, 0, - 1 );
setPoint( "cn2", w, 0, - 1 );
setPoint( "cn3", 0, - h, - 1 );
setPoint( "cn4", 0, h, - 1 );
var points = scope.pointMap[ point ];
if ( points !== undefined ) {
for ( var i = 0, il = points.length; i < il; i ++ ) {
scope.geometry.vertices[ points[ i ] ].copy( vector );
}
}
}
this.geometry.verticesNeedUpdate = true;
geometry.verticesNeedUpdate = true;
};
......@@ -33908,7 +33911,7 @@ THREE.ShadowMapPlugin = function () {
if ( light.shadowCameraVisible && ! light.cameraHelper ) {
light.cameraHelper = new THREE.CameraHelper( light.shadowCamera );
light.shadowCamera.add( light.cameraHelper );
scene.add( light.cameraHelper );
}
......@@ -33922,6 +33925,8 @@ THREE.ShadowMapPlugin = function () {
shadowMatrix = light.shadowMatrix;
shadowCamera = light.shadowCamera;
//
shadowCamera.position.setFromMatrixPosition( light.matrixWorld );
_matrixPosition.setFromMatrixPosition( light.target.matrixWorld );
shadowCamera.lookAt( _matrixPosition );
......@@ -33929,6 +33934,8 @@ THREE.ShadowMapPlugin = function () {
shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );
//
if ( light.cameraHelper ) light.cameraHelper.visible = light.shadowCameraVisible;
if ( light.shadowCameraVisible ) light.cameraHelper.update();
......@@ -33957,7 +33964,8 @@ THREE.ShadowMapPlugin = function () {
// set object matrices & frustum culling
_renderList.length = 0;
projectObject(scene,scene,shadowCamera);
projectObject( scene, scene, shadowCamera );
// render regular objects
......@@ -34053,32 +34061,34 @@ THREE.ShadowMapPlugin = function () {
_renderer.resetGLState();
};
function projectObject(scene, object,shadowCamera){
function projectObject( scene, object, shadowCamera ){
if ( object.visible ) {
var webglObjects = _webglObjects[object.id];
if (webglObjects && object.castShadow && (object.frustumCulled === false || _frustum.intersectsObject( object ) === true) ) {
for (var i = 0, l = webglObjects.length; i < l; i++){
var webglObject = webglObjects[i];
var webglObjects = _webglObjects[ object.id ];
if ( webglObjects && object.castShadow && (object.frustumCulled === false || _frustum.intersectsObject( object ) === true) ) {
for (var i = 0, l = webglObjects.length; i < l; i ++ ) {
var webglObject = webglObjects[ i ];
object._modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );
_renderList.push(webglObject);
_renderList.push( webglObject );
}
}
for(var i = 0, l = object.children.length; i < l; i++) {
projectObject(scene, object.children[i],shadowCamera);
for ( var i = 0, l = object.children.length; i < l; i ++ ) {
projectObject( scene, object.children[ i ], shadowCamera );
}
}
}
function createVirtualLight( light, cascade ) {
......
......@@ -741,8 +741,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;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.CameraHelper.prototype.update=function(){var a,b,c=new THREE.Vector3,d=new THREE.Camera,e=function(e,f,h,k){c.set(f,h,k).unproject(d);e=b[e];if(void 0!==e)for(f=0,h=e.length;f<h;f++)a.vertices[e[f]].copy(c)};return function(){a=this.geometry;b=this.pointMap;d.projectionMatrix.copy(this.camera.projectionMatrix);e("c",0,0,-1);e("t",0,0,1);e("n1",-1,-1,-1);e("n2",1,-1,-1);e("n3",-1,1,-1);e("n4",1,1,-1);e("f1",-1,-1,1);e("f2",1,-1,1);e("f3",-1,1,1);e("f4",1,1,1);e("u1",.7,1.1,-1);e("u2",-.7,1.1,
-1);e("u3",0,2,-1);e("cf1",-1,0,1);e("cf2",1,0,1);e("cf3",0,-1,1);e("cf4",0,1,1);e("cn1",-1,0,-1);e("cn2",1,0,-1);e("cn3",0,-1,-1);e("cn4",0,1,-1);a.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()};
......@@ -798,8 +798,8 @@ v.shadowCascade)for(E=0;E<v.shadowCascadeCount;E++){var G;if(v.shadowCascadeArra
G.shadowBias=A.shadowCascadeBias[L];G.shadowMapWidth=A.shadowCascadeWidth[L];G.shadowMapHeight=A.shadowCascadeHeight[L];G.pointsWorld=[];G.pointsFrustum=[];C=G.pointsWorld;z=G.pointsFrustum;for(var R=0;8>R;R++)C[R]=new THREE.Vector3,z[R]=new THREE.Vector3;C=A.shadowCascadeNearZ[L];A=A.shadowCascadeFarZ[L];z[0].set(-1,-1,C);z[1].set(1,-1,C);z[2].set(-1,1,C);z[3].set(1,1,C);z[4].set(-1,-1,A);z[5].set(1,-1,A);z[6].set(-1,1,A);z[7].set(1,1,A);G.originalCamera=w;z=new THREE.Gyroscope;z.position.copy(v.shadowCascadeOffset);
z.add(G);z.add(G.target);w.add(z);v.shadowCascadeArray[E]=G;console.log("Created virtualLight",G)}L=v;C=E;A=L.shadowCascadeArray[C];A.position.copy(L.position);A.target.position.copy(L.target.position);A.lookAt(A.target);A.shadowCameraVisible=L.shadowCameraVisible;A.shadowDarkness=L.shadowDarkness;A.shadowBias=L.shadowCascadeBias[C];z=L.shadowCascadeNearZ[C];L=L.shadowCascadeFarZ[C];A=A.pointsFrustum;A[0].z=z;A[1].z=z;A[2].z=z;A[3].z=z;A[4].z=L;A[5].z=L;A[6].z=L;A[7].z=L;T[I]=G;I++}else T[I]=v,I++;
y=0;for(x=T.length;y<x;y++){v=T[y];v.shadowMap||(E=THREE.LinearFilter,c.shadowMapType===THREE.PCFSoftShadowMap&&(E=THREE.NearestFilter),v.shadowMap=new THREE.WebGLRenderTarget(v.shadowMapWidth,v.shadowMapHeight,{minFilter:E,magFilter:E,format:THREE.RGBAFormat}),v.shadowMapSize=new THREE.Vector2(v.shadowMapWidth,v.shadowMapHeight),v.shadowMatrix=new THREE.Matrix4);if(!v.shadowCamera){if(v instanceof THREE.SpotLight)v.shadowCamera=new THREE.PerspectiveCamera(v.shadowCameraFov,v.shadowMapWidth/v.shadowMapHeight,
v.shadowCameraNear,v.shadowCameraFar);else if(v instanceof THREE.DirectionalLight)v.shadowCamera=new THREE.OrthographicCamera(v.shadowCameraLeft,v.shadowCameraRight,v.shadowCameraTop,v.shadowCameraBottom,v.shadowCameraNear,v.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}e.add(v.shadowCamera);!0===e.autoUpdate&&e.updateMatrixWorld()}v.shadowCameraVisible&&!v.cameraHelper&&(v.cameraHelper=new THREE.CameraHelper(v.shadowCamera),v.shadowCamera.add(v.cameraHelper));
if(v.isVirtual&&G.originalCamera==w){E=w;I=v.shadowCamera;z=v.pointsFrustum;A=v.pointsWorld;m.set(Infinity,Infinity,Infinity);r.set(-Infinity,-Infinity,-Infinity);for(L=0;8>L;L++)C=A[L],C.copy(z[L]),C.unproject(E),C.applyMatrix4(I.matrixWorldInverse),C.x<m.x&&(m.x=C.x),C.x>r.x&&(r.x=C.x),C.y<m.y&&(m.y=C.y),C.y>r.y&&(r.y=C.y),C.z<m.z&&(m.z=C.z),C.z>r.z&&(r.z=C.z);I.left=m.x;I.right=r.x;I.top=r.y;I.bottom=m.y;I.updateProjectionMatrix()}I=v.shadowMap;z=v.shadowMatrix;E=v.shadowCamera;E.position.setFromMatrixPosition(v.matrixWorld);
v.shadowCameraNear,v.shadowCameraFar);else if(v instanceof THREE.DirectionalLight)v.shadowCamera=new THREE.OrthographicCamera(v.shadowCameraLeft,v.shadowCameraRight,v.shadowCameraTop,v.shadowCameraBottom,v.shadowCameraNear,v.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}e.add(v.shadowCamera);!0===e.autoUpdate&&e.updateMatrixWorld()}v.shadowCameraVisible&&!v.cameraHelper&&(v.cameraHelper=new THREE.CameraHelper(v.shadowCamera),e.add(v.cameraHelper));if(v.isVirtual&&
G.originalCamera==w){E=w;I=v.shadowCamera;z=v.pointsFrustum;A=v.pointsWorld;m.set(Infinity,Infinity,Infinity);r.set(-Infinity,-Infinity,-Infinity);for(L=0;8>L;L++)C=A[L],C.copy(z[L]),C.unproject(E),C.applyMatrix4(I.matrixWorldInverse),C.x<m.x&&(m.x=C.x),C.x>r.x&&(r.x=C.x),C.y<m.y&&(m.y=C.y),C.y>r.y&&(r.y=C.y),C.z<m.z&&(m.z=C.z),C.z>r.z&&(r.z=C.z);I.left=m.x;I.right=r.x;I.top=r.y;I.bottom=m.y;I.updateProjectionMatrix()}I=v.shadowMap;z=v.shadowMatrix;E=v.shadowCamera;E.position.setFromMatrixPosition(v.matrixWorld);
t.setFromMatrixPosition(v.target.matrixWorld);E.lookAt(t);E.updateMatrixWorld();E.matrixWorldInverse.getInverse(E.matrixWorld);v.cameraHelper&&(v.cameraHelper.visible=v.shadowCameraVisible);v.shadowCameraVisible&&v.cameraHelper.update();z.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);z.multiply(E.projectionMatrix);z.multiply(E.matrixWorldInverse);q.multiplyMatrices(E.projectionMatrix,E.matrixWorldInverse);p.setFromMatrix(q);c.setRenderTarget(I);c.clear();s.length=0;a(e,e,E);v=0;for(I=s.length;v<I;v++)A=
s[v],z=A.object,A=A.buffer,L=z.material instanceof THREE.MeshFaceMaterial?z.material.materials[0]:z.material,C=void 0!==z.geometry.morphTargets&&0<z.geometry.morphTargets.length&&L.morphTargets,R=z instanceof THREE.SkinnedMesh&&L.skinning,C=z.customDepthMaterial?z.customDepthMaterial:R?C?n:k:C?h:f,c.setMaterialFaces(L),A instanceof THREE.BufferGeometry?c.renderBufferDirect(E,d,null,C,A,z):c.renderBuffer(E,d,null,C,A,z);v=0;for(I=g.length;v<I;v++)A=g[v],z=A.object,z.visible&&z.castShadow&&(z._modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,
z.matrixWorld),c.renderImmediateObject(E,d,null,f,z))}y=c.getClearColor();x=c.getClearAlpha();b.clearColor(y.r,y.g,y.b,x);b.enable(b.BLEND);c.shadowMapCullFace===THREE.CullFaceFront&&b.cullFace(b.BACK);c.resetGLState()}};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册