Created
August 19, 2011 20:53
-
-
Save michiakig/1157978 to your computer and use it in GitHub Desktop.
three.js demo in ClojureScript
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 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) | |
(render)) | |
(animate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment