jupyter-widgets / pythreejs

A Jupyter - Three.js bridge
https://pythreejs.readthedocs.io
Other
936 stars 187 forks source link

Fog rendering #243

Closed scottlittle closed 5 years ago

scottlittle commented 5 years ago

I can't seem to get Fog or FogExp2 to work. The below code runs, but does nothing in my scene.

# set scene
scene = Scene(children=[ *spheres,
    *lines_, hover_point,
    DirectionalLight(color='#777777', position=[10,20,30]),
    DirectionalLight(color='#777777', position=[10,-20,-30]),
    AmbientLight(color='#ffffff'), FogExp2(color='#ffffff')
    ])
scottlittle commented 5 years ago

I also posted this as a stackoverflow question.

vidartf commented 5 years ago

The fog object should be set to the fog attribute of the scene, not as a child of the scene. Does that fix the issue?

scottlittle commented 5 years ago

Yes. Thanks!

FYI, future googler:

# set scene
scene = Scene( fog=Fog(near=15,far=40), children=[ *spheres,
    *lines_, hover_point,
    DirectionalLight(color='#777777', position=[10,20,30]),
    DirectionalLight(color='#777777', position=[10,-20,-30]),
    AmbientLight(color='#ffffff')
    ])
jasongrout commented 5 years ago

Thanks for following up with a working example!