提交 bcc037e4 编写于 作者: S supereggbert

make class the abstract for use in the other light shadow classes

上级 0442b430
import { Matrix4 } from '../math/Matrix4.js';
import { Vector2 } from '../math/Vector2.js';
import { Vector3 } from '../math/Vector3.js';
import { Vector4 } from '../math/Vector4.js';
import { Frustum } from '../math/Frustum.js';
/**
* @author mrdoob / http://mrdoob.com/
......@@ -17,10 +20,72 @@ function LightShadow( camera ) {
this.map = null;
this.matrix = new Matrix4();
this._frustum = new Frustum();
this._frameExtents = new Vector2( 1, 1 );
this._viewportCount = 1;
this._viewports = [
new Vector4( 0, 0, 1, 1)
];
}
Object.assign( LightShadow.prototype, {
_projScreenMatrix: new Matrix4(),
_lightPositionWorld: new Vector3(),
_lookTarget: new Vector3(),
getViewportCount: function () {
return this._viewportCount;
},
getFrustum: function() {
return this._frustum;
},
updateMatrices: function ( light, viewCamera, viewportIndex ) {
var shadowCamera = this.camera,
shadowMatrix = this.matrix,
projScreenMatrix = this._projScreenMatrix;
projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
this._frustum.setFromMatrix( projScreenMatrix );
shadowMatrix.set(
0.5, 0.0, 0.0, 0.5,
0.0, 0.5, 0.0, 0.5,
0.0, 0.0, 0.5, 0.5,
0.0, 0.0, 0.0, 1.0
);
shadowMatrix.multiply( shadowCamera.projectionMatrix );
shadowMatrix.multiply( shadowCamera.matrixWorldInverse );
},
getViewport: function ( viewportIndex ) {
return this._viewports[ viewportIndex ];
},
getFrameExtents: function () {
return this._frameExtents;
},
copy: function ( source ) {
this.camera = source.camera.clone();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册