Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
three.js demo in ClojureScript
(ns three.demo)
(def camera (THREE.Camera. 75 (/ window/innerWidth
window/innerHeight) 1 10000))
(set! (.z (.position camera)) 1000)
(def scene (THREE.Scene.))
(def geometry (THREE.CubeGeometry. 200 200 200))
(def obj (js/Object.))
(set! (.color obj) 0xff0000)
(set! (.wireframe obj) true)
(def material (THREE.MeshBasicMaterial. obj))
(def mesh (THREE.Mesh. geometry material))
(.addObject scene mesh)
(def renderer (THREE.CanvasRenderer.))
(.setSize renderer window/innerWidth window/innerHeight)
(.appendChild (.body js/document) (.domElement renderer))
(defn render []
(set! (.x (.rotation mesh)) (+ (.x (.rotation mesh)) 0.01))
(set! (.y (.rotation mesh)) (+ (.y (.rotation mesh)) 0.02))
(.render renderer scene camera))
(defn animate []
(.requestAnimationFrame js/window animate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.