Popedenano
parent
e8e76bb716
commit
1ccb3d14a1
|
@ -13,6 +13,7 @@
|
||||||
<script type="text/javascript" src="js/three.min.js"></script>
|
<script type="text/javascript" src="js/three.min.js"></script>
|
||||||
<script type="text/javascript" src="js/audioRecorder.js"></script>
|
<script type="text/javascript" src="js/audioRecorder.js"></script>
|
||||||
<script type="text/javascript" src="js/audioRecorderWorker.js"></script>
|
<script type="text/javascript" src="js/audioRecorderWorker.js"></script>
|
||||||
|
<script type="text/javascript" src="js/NoSleep.min.js"></script>
|
||||||
<script type="text/javascript" src="js/compiled/sliva.js"></script>
|
<script type="text/javascript" src="js/compiled/sliva.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -32,4 +32,5 @@
|
||||||
(do
|
(do
|
||||||
(websocket-init)
|
(websocket-init)
|
||||||
(click-test)
|
(click-test)
|
||||||
|
(.enable (js/NoSleep.))
|
||||||
(init-app)))))
|
(init-app)))))
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
;; ☭☭☭☭ Parametri razni ☭☭☭☭ ;;
|
;; ☭☭☭☭ Parametri razni ☭☭☭☭ ;;
|
||||||
;;;;; ☭☭☭☭☭☭☭☭☭☭☭☭☭☭ ;;;;;;
|
;;;;; ☭☭☭☭☭☭☭☭☭☭☭☭☭☭ ;;;;;;
|
||||||
{:odmik-kamere 100
|
{:odmik-kamere 100
|
||||||
:rotacija-kamere 1
|
;;:rotacija-kamere 1
|
||||||
|
:rotacija-kamere 0.5
|
||||||
:bg-barva 0x000000
|
:bg-barva 0x000000
|
||||||
:FOV 140
|
;;:FOV 140
|
||||||
|
:FOV 65
|
||||||
:lik-sirina 2
|
:lik-sirina 2
|
||||||
:obj-limit 1000
|
:obj-limit 1000
|
||||||
:objekti []
|
:objekti []
|
||||||
|
@ -21,8 +23,10 @@
|
||||||
:center-x 0
|
:center-x 0
|
||||||
:center-y 0
|
:center-y 0
|
||||||
:center-z 0
|
:center-z 0
|
||||||
:zamik-barve 0.0000666
|
;;:zamik-barve 0.0000666
|
||||||
:zacetna-barva 0.333
|
:zamik-barve 0.000000006
|
||||||
|
;;:zacetna-barva 0.333
|
||||||
|
:zacetna-barva 0.01
|
||||||
:saturacija 1
|
:saturacija 1
|
||||||
:svetlost 0.4
|
:svetlost 0.4
|
||||||
:w-diff 0.5
|
:w-diff 0.5
|
||||||
|
|
|
@ -52,30 +52,37 @@
|
||||||
|
|
||||||
(let [obj (js/THREE.Line. geo mat (.-LineSegments js/THREE))
|
(let [obj (js/THREE.Line. geo mat (.-LineSegments js/THREE))
|
||||||
position (.-position obj)
|
position (.-position obj)
|
||||||
|
stari-objekti (drop (get-param :obj-limit) (get-param :objekti))
|
||||||
novi-objekti (conj (take (get-param :obj-limit) (get-param :objekti))
|
novi-objekti (conj (take (get-param :obj-limit) (get-param :objekti))
|
||||||
obj)]
|
obj)]
|
||||||
(-> position
|
|
||||||
(.setX (get-param :center-x))
|
|
||||||
(.setY (get-param :center-y))
|
|
||||||
(.setZ (get-param :center-z)))
|
|
||||||
|
|
||||||
(.add scena obj)
|
(.add scena obj)
|
||||||
|
(->> stari-objekti
|
||||||
|
(run! (fn [old-obj]
|
||||||
|
(.remove scena old-obj))))
|
||||||
|
|
||||||
;; pucaj sceno ane
|
;; pucaj sceno ane
|
||||||
(set-param :objekti novi-objekti))))
|
(set-param :objekti novi-objekti))))
|
||||||
|
|
||||||
(defn obj-anim [obj]
|
(defn obj-anim [obj]
|
||||||
(.rotateY obj (get-param :rotacija-y))
|
(let [position (.-position obj)
|
||||||
(.rotateZ obj (get-param :rotacija-z))
|
new-scale (+ (aget obj "scale" "x")
|
||||||
(.rotateX obj (get-param :rotacija-x))
|
|
||||||
|
|
||||||
(let [new-scale (+ (aget obj "scale" "x")
|
|
||||||
(get-param :w-diff))]
|
(get-param :w-diff))]
|
||||||
(aset obj "scale" "x" new-scale)
|
(doto position
|
||||||
(aset obj "scale" "y" new-scale)
|
(.setX (+ (.-x position) (get-param :center-x)))
|
||||||
(aset obj "scale" "z" new-scale))
|
(.setY (+ (.-y position) (get-param :center-y)))
|
||||||
|
(.setZ (+ (.-z position) (get-param :center-z))))
|
||||||
|
|
||||||
(.offsetHSL (aget obj "material" "color") (get-param :zamik-barve) 0 0))
|
(doto obj
|
||||||
|
(.rotateY (get-param :rotacija-y))
|
||||||
|
(.rotateZ (get-param :rotacija-z))
|
||||||
|
(.rotateX (get-param :rotacija-x))
|
||||||
|
|
||||||
|
(aset "scale" "x" new-scale)
|
||||||
|
(aset "scale" "y" new-scale)
|
||||||
|
(aset "scale" "z" new-scale))
|
||||||
|
|
||||||
|
(.offsetHSL (aget obj "material" "color") (get-param :zamik-barve) 0 0)))
|
||||||
|
|
||||||
(defn cam-rotate []
|
(defn cam-rotate []
|
||||||
(.translateX kamera (get-param :rotacija-kamere))
|
(.translateX kamera (get-param :rotacija-kamere))
|
||||||
|
@ -118,14 +125,14 @@
|
||||||
(.removeChild container (.-firstChild container)))
|
(.removeChild container (.-firstChild container)))
|
||||||
|
|
||||||
(defn spin-objects [[cas a b g]]
|
(defn spin-objects [[cas a b g]]
|
||||||
;; (update-param :rotacija-x (fn [old] (+ old (/ x 1000))))
|
;;(update-param :rotacija-x (fn [old] (+ old (/ a 100000))))
|
||||||
;; (update-param :rotacija-y (fn [old] (+ old (/ y 1000))))
|
;;(update-param :rotacija-y (fn [old] (+ old (/ b 100000))))
|
||||||
;; (update-param :rotacija-z (fn [old] (+ old (/ z 1000)))))
|
;;(update-param :rotacija-z (fn [old] (+ old (/ g 100000)))))
|
||||||
(set-param :rotacija-x (/ a 10000))
|
(set-param :rotacija-x (/ a 10000))
|
||||||
(set-param :rotacija-y (/ b 10000))
|
(set-param :rotacija-y (/ b 10000))
|
||||||
(set-param :rotacija-z (/ g 10000)))
|
(set-param :rotacija-z (/ g 10000)))
|
||||||
|
|
||||||
(defn displace-objects [[cas x y z]]
|
(defn displace-objects [[cas x y z]]
|
||||||
(update-param :center-x (fn [old] (+ old (* x 10))))
|
(update-param :center-x (fn [old] (+ old (/ x 25))))
|
||||||
(update-param :center-y (fn [old] (+ old (* y 10))))
|
(update-param :center-y (fn [old] (+ old (/ y 25))))
|
||||||
(update-param :center-z (fn [old] (+ old (* z 10)))))
|
(update-param :center-z (fn [old] (+ old (/ z 25)))))
|
||||||
|
|
|
@ -19,13 +19,27 @@
|
||||||
(defn stop-motion-track []
|
(defn stop-motion-track []
|
||||||
(.removeEventListener js/window "devicemotion" motion-track))
|
(.removeEventListener js/window "devicemotion" motion-track))
|
||||||
|
|
||||||
|
(def rotation (reagent/atom nil))
|
||||||
(defn rotation-track [event]
|
(defn rotation-track [event]
|
||||||
(let [alpha (.-alpha event)
|
(let [alpha (.-alpha event)
|
||||||
beta (.-beta event)
|
beta (.-beta event)
|
||||||
gamma (.-gamma event)
|
gamma (.-gamma event)
|
||||||
cas (-> (js/Date.)
|
cas (-> (js/Date.)
|
||||||
(.valueOf))]
|
(.valueOf))]
|
||||||
(send-message "rotation" cas alpha beta gamma)))
|
(console.log "rotation:" @rotation)
|
||||||
|
(if @rotation
|
||||||
|
(let [da (- (:a @rotation) alpha)
|
||||||
|
db (- (:b @rotation) beta)
|
||||||
|
dg (- (:g @rotation) gamma)]
|
||||||
|
(send-message
|
||||||
|
"rotation"
|
||||||
|
cas
|
||||||
|
da
|
||||||
|
db
|
||||||
|
dg))
|
||||||
|
(swap! rotation merge {:a alpha
|
||||||
|
:b beta
|
||||||
|
:g gamma}))))
|
||||||
|
|
||||||
(defn start-rotation-track []
|
(defn start-rotation-track []
|
||||||
(.addEventListener js/window "deviceorientation" rotation-track))
|
(.addEventListener js/window "deviceorientation" rotation-track))
|
||||||
|
@ -42,13 +56,18 @@
|
||||||
:component-will-unmount (fn []
|
:component-will-unmount (fn []
|
||||||
(stop-motion-track)
|
(stop-motion-track)
|
||||||
(stop-rotation-track))
|
(stop-rotation-track))
|
||||||
|
:should-component-update #(true)
|
||||||
:reagent-render
|
:reagent-render
|
||||||
(fn []
|
(fn []
|
||||||
[:div
|
[:div
|
||||||
[:h3 "gibaj me!"]
|
[:h3 "gibaj me!"]
|
||||||
(let [vizual [:vizual @appstate]]
|
[:div
|
||||||
[:input {:type "range"
|
[:h4 "Rotacija"]
|
||||||
:min 0
|
[:div "Alfa:" (:a @rotation)]
|
||||||
:max 50}])
|
[:div "Beta:" (:b @rotation)]
|
||||||
|
[:div "Gama:" (:g @rotation)]]
|
||||||
|
[:input {:type "range"
|
||||||
|
:min 0
|
||||||
|
:max 50}]
|
||||||
[navigation]])}))
|
[navigation]])}))
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
(send-all "open" [cid])
|
(send-all "open" [cid])
|
||||||
(go-loop []
|
(go-loop []
|
||||||
(let [{:keys [message]} (<! ws-ch)]
|
(let [{:keys [message]} (<! ws-ch)]
|
||||||
(println "GOT MSG!" message)
|
;;(println "GOT MSG!" message)
|
||||||
(let [[cmd & args] (str/split message #":")]
|
(let [[cmd & args] (str/split message #":")]
|
||||||
(println "command" cmd args)
|
;;(println "command" cmd args)
|
||||||
(condp = cmd
|
(condp = cmd
|
||||||
"ping" (>! ws-ch "pong")
|
"ping" (>! ws-ch "pong")
|
||||||
"motion" (send-all "displace" args)
|
"motion" (send-all "displace" args)
|
||||||
|
|
Loading…
Reference in New Issue