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