-
-
Save seabre/9030268 to your computer and use it in GitHub Desktop.
Three.js demo with ClojureScript. Actually works.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns three.demo) | |
(def THREE js/THREE) | |
(def camera (THREE.PerspectiveCamera. 75 (/ (.-innerWidth js/window) | |
(.-innerHeight js/window)) 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)) | |
(.add scene mesh) | |
(def renderer (THREE.CanvasRenderer.)) | |
(.setSize renderer (.-innerWidth js/window) (.-innerHeight js/window)) | |
(.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) | |
(render)) | |
(animate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi I tried this example after making a tweak to the dom element, but it didn't work. I don't see the animation: