Izzimach / react-three-legacy

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

background property for scene doesnt apply #13

Closed sebastianmenge closed 9 years ago

sebastianmenge commented 9 years ago

hey everyone,

trying to set the background prop on a scene element with an orthographic camera but the canvas always stays black. react-three code looks like it should work. am i missing something? :)

render: function() {
    var width = 1400;
    var height = 900;
    var cameraprops = {left: width / - 2 , right: width / 2 , up: height / 2, bottom: height / - 2, near: 1, far: 1000};

    return (
      <Scene background="0xffffff" width={width} height={height} camera="maincamera">
        <OrthographicCamera name="maincamera" {...cameraprops} />

      </Scene>
    );
  }
Izzimach commented 9 years ago

The background color is actually a number, not a string. I guess the JSX is passing your background prop in as a string. Something like this should work:

<Scene background={0xffffff} width={width} ...

There should be some code that checks that and spits out a warning though. I'll add that.

sebastianmenge commented 9 years ago

oh yeah, right! thanks, that worked :+1: