| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import { GPULoadOp } from './constants.js';
- import { Color } from '../../../../build/three.module.js';
- class WebGPUBackground {
- constructor( renderer ) {
- this.renderer = renderer;
- this.clearAlpha = 1;
- this.clearColor = new Color( 0x000000 );
- }
- render( scene ) {
- const renderer = this.renderer;
- const background = ( scene.isScene === true ) ? scene.background : null;
- const clearColor = this.clearColor;
- let clearAlpha = this.clearAlpha;
- let forceClear = false;
- if ( background === null ) {
- // no background settings, use clear color configuration from the renderer
- this.clearColor.copy( renderer._clearColor );
- this.clearAlpha = renderer._clearAlpha;
- } else if ( background !== null && background.isColor === true ) {
- // background is an opaque color
- clearColor.copy( background );
- clearAlpha = 1;
- forceClear = true;
- }
- // configure render pass descriptor
- const renderPassDescriptor = renderer._renderPassDescriptor;
- const colorAttachment = renderPassDescriptor.colorAttachments[ 0 ];
- if ( renderer.autoClear === true || forceClear === true ) {
- colorAttachment.loadValue = { r: clearColor.r, g: clearColor.g, b: clearColor.b, a: clearAlpha };
- } else {
- colorAttachment.loadValue = GPULoadOp.Load;
- }
- }
- }
- export default WebGPUBackground;
|