updateMatrices method

void updateMatrices(
  1. Light light, {
  2. int viewportIndex = 0,
})

Implementation

void updateMatrices(Light light, {int viewportIndex = 0}) {
  var shadowCamera = camera;
  var shadowMatrix = matrix;

  var lightPositionWorld = _lightPositionWorld;

  lightPositionWorld.setFromMatrixPosition(light.matrixWorld);
  shadowCamera!.position.copy(lightPositionWorld);

  _lookTarget.setFromMatrixPosition(light.target!.matrixWorld);
  shadowCamera.lookAt(_lookTarget);
  shadowCamera.updateMatrixWorld(false);

  _projScreenMatrix.multiplyMatrices(
      shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse);
  _frustum.setFromProjectionMatrix(_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);
}