提交 02002210 编写于 作者: A alteredq

Fixed shadow camera helper that got broken with CameraHelper changes.

上级 013f3b37
......@@ -34004,7 +34004,7 @@ THREE.ShadowMapPlugin = function ( ) {
shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );
if ( light.cameraHelper ) light.cameraHelper.lines.visible = light.shadowCameraVisible;
if ( light.cameraHelper ) light.cameraHelper.visible = light.shadowCameraVisible;
if ( light.shadowCameraVisible ) light.cameraHelper.update();
// compute shadow matrix
......
......@@ -748,7 +748,7 @@ y.shadowCameraBottom=s.shadowCameraBottom;y.shadowCameraTop=s.shadowCameraTop;y.
u=u.shadowCascadeFarZ[v];s=s.pointsFrustum;s[0].z=t;s[1].z=t;s[2].z=t;s[3].z=t;s[4].z=u;s[5].z=u;s[6].z=u;s[7].z=u;A[o]=y;o++}else{A[o]=p;o++}}m=0;for(q=A.length;m<q;m++){p=A[m];if(!p.shadowMap){p.shadowMap=new THREE.WebGLRenderTarget(p.shadowMapWidth,p.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat});p.shadowMapSize=new THREE.Vector2(p.shadowMapWidth,p.shadowMapHeight);p.shadowMatrix=new THREE.Matrix4}if(!p.shadowCamera){if(p instanceof THREE.SpotLight)p.shadowCamera=
new THREE.PerspectiveCamera(p.shadowCameraFov,p.shadowMapWidth/p.shadowMapHeight,p.shadowCameraNear,p.shadowCameraFar);else if(p instanceof THREE.DirectionalLight)p.shadowCamera=new THREE.OrthographicCamera(p.shadowCameraLeft,p.shadowCameraRight,p.shadowCameraTop,p.shadowCameraBottom,p.shadowCameraNear,p.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}l.add(p.shadowCamera);b.autoUpdateScene&&l.updateMatrixWorld()}if(p.shadowCameraVisible&&!p.cameraHelper){p.cameraHelper=
new THREE.CameraHelper(p.shadowCamera);p.shadowCamera.add(p.cameraHelper)}if(p.isVirtual&&y.originalCamera==n){r=n;o=p.shadowCamera;t=p.pointsFrustum;s=p.pointsWorld;i.set(Infinity,Infinity,Infinity);j.set(-Infinity,-Infinity,-Infinity);for(u=0;u<8;u++){v=s[u];v.copy(t[u]);THREE.ShadowMapPlugin.__projector.unprojectVector(v,r);o.matrixWorldInverse.multiplyVector3(v);if(v.x<i.x)i.x=v.x;if(v.x>j.x)j.x=v.x;if(v.y<i.y)i.y=v.y;if(v.y>j.y)j.y=v.y;if(v.z<i.z)i.z=v.z;if(v.z>j.z)j.z=v.z}o.left=i.x;o.right=
j.x;o.top=j.y;o.bottom=i.y;o.updateProjectionMatrix()}o=p.shadowMap;t=p.shadowMatrix;r=p.shadowCamera;r.position.copy(p.matrixWorld.getPosition());r.lookAt(p.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);if(p.cameraHelper)p.cameraHelper.lines.visible=p.shadowCameraVisible;p.shadowCameraVisible&&p.cameraHelper.update();t.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);t.multiplySelf(r.projectionMatrix);t.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=
j.x;o.top=j.y;o.bottom=i.y;o.updateProjectionMatrix()}o=p.shadowMap;t=p.shadowMatrix;r=p.shadowCamera;r.position.copy(p.matrixWorld.getPosition());r.lookAt(p.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);if(p.cameraHelper)p.cameraHelper.visible=p.shadowCameraVisible;p.shadowCameraVisible&&p.cameraHelper.update();t.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);t.multiplySelf(r.projectionMatrix);t.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=
new Float32Array(16);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);h.multiply(r.projectionMatrix,r.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(o);b.clear();s=l.__webglObjects;p=0;for(o=s.length;p<o;p++){u=s[p];t=u.object;u.render=false;if(t.visible&&t.castShadow&&(!(t instanceof THREE.Mesh)||!t.frustumCulled||g.contains(t))){t._modelViewMatrix.multiply(r.matrixWorldInverse,
t.matrixWorld);u.render=true}}p=0;for(o=s.length;p<o;p++){u=s[p];if(u.render){t=u.object;u=u.buffer;v=t.customDepthMaterial?t.customDepthMaterial:t instanceof THREE.SkinnedMesh?t.geometry.morphTargets.length?e:f:t.geometry.morphTargets.length?d:c;u instanceof THREE.BufferGeometry?b.renderBufferDirect(r,l.__lights,null,v,u,t):b.renderBuffer(r,l.__lights,null,v,u,t)}}s=l.__webglObjectsImmediate;p=0;for(o=s.length;p<o;p++){u=s[p];t=u.object;if(t.visible&&t.castShadow){t._modelViewMatrix.multiply(r.matrixWorldInverse,
t.matrixWorld);b.renderImmediateObject(r,l.__lights,null,c,t)}}}m=b.getClearColor();q=b.getClearAlpha();a.clearColor(m.r,m.g,m.b,q);a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
......
......@@ -193,7 +193,7 @@ THREE.ShadowMapPlugin = function ( ) {
shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );
if ( light.cameraHelper ) light.cameraHelper.lines.visible = light.shadowCameraVisible;
if ( light.cameraHelper ) light.cameraHelper.visible = light.shadowCameraVisible;
if ( light.shadowCameraVisible ) light.cameraHelper.update();
// compute shadow matrix
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册