fromScene method

dynamic fromScene(
  1. dynamic scene, [
  2. dynamic sigma = 0,
  3. dynamic near = 0.1,
  4. dynamic far = 100,
])

Generates a PMREM from a supplied Scene, which can be faster than using an image if networking bandwidth is low. Optional sigma specifies a blur radius in radians to be applied to the scene before PMREM generation. Optional near and far planes ensure the scene is rendered in its entirety (the cubeCamera is placed at the origin).

Implementation

fromScene(scene, [sigma = 0, near = 0.1, far = 100]) {
  _oldTarget = _renderer.getRenderTarget();

  _setSize(256);
  var cubeUVRenderTarget = _allocateTargets();
  cubeUVRenderTarget.depthBuffer = true;

  _sceneToCubeUV(scene, near, far, cubeUVRenderTarget);
  if (sigma > 0) {
    _blur(cubeUVRenderTarget, 0, 0, sigma, null);
  }

  _applyPMREM(cubeUVRenderTarget);
  _cleanup(cubeUVRenderTarget);

  return cubeUVRenderTarget;
}