fromScene method
RenderTarget
fromScene(
- Scene scene, {
- double sigma = 0,
- double near = 0.1,
- double far = 100,
- PMREMGeneratorOptions? options,
- 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
/// * 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).
/// *
RenderTarget fromScene(Scene scene, {double sigma = 0, double near = 0.1, double far = 100, PMREMGeneratorOptions? options}) {
options ??= PMREMGeneratorOptions();
_oldTarget = _renderer.getRenderTarget();
_oldActiveCubeFace = _renderer.getActiveCubeFace();
_oldActiveMipmapLevel = _renderer.getActiveMipmapLevel();
_oldXrEnabled = _renderer.xr.enabled;
_renderer.xr.enabled = false;
_setSize(options.size);
final cubeUVRenderTarget = this._allocateTargets();
cubeUVRenderTarget.depthBuffer = true;
_sceneToCubeUV(scene, near, far, cubeUVRenderTarget, options.position);
if (sigma > 0) {
_blur(cubeUVRenderTarget, 0, 0, sigma);
}
_applyPMREM(cubeUVRenderTarget);
_cleanup(cubeUVRenderTarget);
return cubeUVRenderTarget;
}