Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding fog to a scene #57

Open
chr15m opened this issue Jul 31, 2022 · 1 comment
Open

Adding fog to a scene #57

chr15m opened this issue Jul 31, 2022 · 1 comment

Comments

@chr15m
Copy link

chr15m commented Jul 31, 2022

What is the recommended way to add fog to a scene? Can I pass the values to the renderer or is it something I should use interop to add after setting up?

@timothypratley
Copy link

This worked for me:

(ns my.ns (:require ["three" :as three]))
(defn canvas [world*]
  (reagent/with-let [render (fn [] [root @world*])]
    [:canvas {:width  400
              :height 300
              :style {:border "solid 1px lightgrey"}
              :ref    (fn [el]
                        (when el
                          (doto (ta/render render el)
                            (-> :threejs-scene (.-background) (set! (three/Color. 0xffffff)))
                            (-> :threejs-scene (.-fog) (set! (three/FogExp2. 0xffffff 0.5))))))}]))

^^ This is inter-oping with the underlying scene directly; it would be nice if scene attributes could be set by data instead like [:scene {:fog ... :background {:color 0xffffff}] but I don't think that's a feature yet.

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

No branches or pull requests

2 participants