http://www.wikiart.org/en/rene-magritte/gonconda-1953 http://threejs.org/docs/
Last active
August 29, 2015 14:07
-
-
Save alecperkins/54e63051921ab501404d to your computer and use it in GitHub Desktop.
A proto project: https://github.com/droptype/proto
This file contains hidden or 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
This file contains hidden or 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
| scene = new THREE.Scene() | |
| camera = new THREE.PerspectiveCamera( | |
| 75 | |
| window.innerWidth / window.innerHeight | |
| 0.1 | |
| 1000 | |
| ) | |
| camera.position.z = 400 | |
| scene.add(camera) | |
| renderer = new THREE.WebGLRenderer() | |
| renderer.setSize(window.innerWidth, window.innerHeight) | |
| renderer.setClearColor(0xffffff,1) | |
| document.body.appendChild(renderer.domElement) | |
| origin = | |
| x: window.innerWidth / 2 | |
| y: window.innerHeight / 2 | |
| renderer.domElement.addEventListener 'mousemove', (e) -> | |
| # Convert the screen coordinates to world | |
| rel_x = origin.x - e.pageX | |
| rel_y = e.pageY - origin.y | |
| # Adjust camera position | |
| SCALE_FACTOR = 0.05 | |
| camera.position.x = rel_x * SCALE_FACTOR | |
| camera.position.y = rel_y * SCALE_FACTOR | |
| requestAnimationFrame(render) | |
| person_geometry = new THREE.BoxGeometry(15, 40, 1) | |
| person_material = new THREE.MeshLambertMaterial(color: 0x00FF00) | |
| PERSON_X_SPACING = 100 | |
| PERSON_Y_SPACING = 100 | |
| PERSON_Z_SPACING = 100 | |
| [-10..10].forEach (x) -> | |
| [-10..10].forEach (y) -> | |
| [0...3].forEach (z) -> | |
| person = new THREE.Mesh( | |
| person_geometry | |
| person_material | |
| ) | |
| offset = if y % 2 then 0.5 else 0 | |
| person.position.set( | |
| (x + offset) * PERSON_X_SPACING | |
| y * PERSON_Y_SPACING | |
| z * PERSON_Z_SPACING | |
| ) | |
| person.castShadow = z is 1 | |
| scene.add(person) | |
| building = new THREE.Mesh( | |
| new THREE.BoxGeometry(1400,300, 10) | |
| new THREE.MeshLambertMaterial(color: 0xffffff) | |
| ) | |
| building.position.z = 90 | |
| building.position.y = -180 | |
| building.receiveShadow = true | |
| scene.add(building) | |
| sun = new THREE.DirectionalLight(0xffffff, 1) | |
| sun.position.set(-400, 300, 200) | |
| sun.castShadow = true | |
| scene.add(sun) | |
| scene.add( new THREE.AmbientLight( 0x222222) ) | |
| renderer.shadowMapEnabled = true | |
| renderer.shadowMapSoft = false | |
| renderer.shadowCameraNear = 3 | |
| renderer.shadowCameraFar = camera.far | |
| renderer.shadowCameraFov = 50 | |
| renderer.shadowMapBias = 0.0039 | |
| renderer.shadowMapDarkness = 0.5 | |
| renderer.shadowMapWidth = 1024 | |
| renderer.shadowMapHeight = 1024 | |
| render = -> | |
| renderer.render(scene, camera) | |
| render() |
This file contains hidden or 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
| { | |
| "name": "magritte-golconda", | |
| "proto_version": "1.5.1", | |
| "script_libraries": [ | |
| "https://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js" | |
| ], | |
| "style_libraries": [ | |
| ], | |
| "extra_head_markup": "<meta name='viewport' content='width=device-width'>" | |
| } |
This file contains hidden or 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
| html, | |
| body | |
| margin: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment