Izzimach / react-three-legacy

React bindings to create and control a 3D scene using three.js
Other
1.52k stars 128 forks source link

Background only works with transparent is truthy #57

Closed scottcheng closed 9 years ago

scottcheng commented 9 years ago
this._THREErenderer.setClearColor(props.background, this.props.transparent ? 1 : 0);

With this line of code, it only sets background color when this.props.transparent is truthy, which seems odd to me. The prop transparent actually means opaque.

On a relevant note, why don't we just have an alpha prop and pass it directly to setClearColor, without coercing it to 1 or 0?

geon commented 9 years ago

Fixed in https://github.com/Izzimach/react-three/pull/58

Izzimach commented 9 years ago

Thanks @geon

The prop is true/false since it is also used as an option when creating the GL context to enable alpha on the canvas. We can add an 'alpha' prop to override the default 0 or 1 behavior if you need it, but I think we should still require the user to explicitly enable canvas transparency with a transparency={true} flag.

scottcheng commented 9 years ago

Thanks @geon! This looks great.

Thanks @Izzimach for the explanation -- I was just curious and didn't really need the alpha. :)