Skip to content

Examples: Explicitly set clear color in WebGPU demos#33452

Open
gkjohnson wants to merge 2 commits intomrdoob:devfrom
gkjohnson:example-backgrounds
Open

Examples: Explicitly set clear color in WebGPU demos#33452
gkjohnson wants to merge 2 commits intomrdoob:devfrom
gkjohnson:example-backgrounds

Conversation

@gkjohnson
Copy link
Copy Markdown
Collaborator

Related issue: #33450, #33437

Description

Explicitly set the clear color in webgpu demos.

renderer = new THREE.WebGPURenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
renderer.setClearColor( 0x000000 );
Copy link
Copy Markdown
Collaborator

@Mugen87 Mugen87 Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using setClearColor() do you mind using Scene.background instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with setClearColor? Many webgpu examples already use it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scene.background should be the first choice of users for defining the background of a scene.

The more technical setClearColor() is mainly intended for transparent clears and if you can't use Scene.background for whatever reasons (e.g. if you directly render a mesh).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants