WebGLRenderer: Difference between Scene.background and setClearColor()
See original GitHub issueUsing Scene.background
and WebGLRenderer.setClearColor()
produces the same output in the following demos:
Scene.background
: https://jsfiddle.net/xkf3o8uw/5/
setClearColor()
: https://jsfiddle.net/xkf3o8uw/4/
However, when setting autoClear
to false
, the behavior is different:
Scene.background
: https://jsfiddle.net/0o38d67m/
setClearColor()
: https://jsfiddle.net/xkf3o8uw/2/
Scene.background
still works because of this line in Scene.background
:
What is the reason for this discrepancy? Does it just mean Scene.background
used with a color should be decoupled of autoClear
settings?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
WebGLRenderer#setClearColor – three.js docs
The WebGL renderer displays your beautifully crafted scenes using WebGL. ... to use this if dealing with huge differences in scale in a...
Read more >Transparent background with three.js - Stack Overflow
If you want a transparent background in three.js, you need pass in the alpha parameter to the WebGLRenderer constructor.
Read more >Scene: background, fog and shadow. · Issue #17420 - GitHub
This is the current thinking: Background Taking #16900 and #17199 into account... scene.background = new ... setClearColor() and renderer.
Read more >Define a Transparent Background in ThreeJS - DevSamples
Setting a Clear Background in a ThreeJS Scene. Copy renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true }); // Second argument is for...
Read more >Three.js Multiple Canvases Multiple Scenes
The solution is one canvas that fills the viewport in the background and some other element to ... return {scene, camera, elem};; };...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure.
I think that is all correct…
And for consistency, the scene background color should be assumed to be in linear colorspace. Currently it is an unusual special case.
+1 That
forceClear = true
got me real confused this morning, I didn’t expectScene.background
to still clear the color even ifautoClear === false
😕 ! For that reason, I ended up not usingScene.background
at all.