Created
November 8, 2012 05:46
-
-
Save AGoblinKing/4037061 to your computer and use it in GitHub Desktop.
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
$ -> | |
WIDTH = window.innerWidth | |
HEIGHT = window.innerHeight | |
VIEW_ANGLE = 45 | |
ASPECT = WIDTH/HEIGHT | |
NEAR = 0.1 | |
FAR = 100000 | |
renderer = new THREE.WebGLRenderer() | |
renderer.setSize WIDTH, HEIGHT | |
scene = new THREE.Scene() | |
camera = new THREE.Camera VIEW_ANGLE, ASPECT, NEAR, FAR | |
camera.position.set 20, 20, 20 | |
scene.add camera | |
clock = new THREE.Clock() | |
### | |
controls = new THREE.FirstPersonControls camera | |
controls.movementSpeed = 1000 | |
controls.lookSpeed = 0.125 | |
controls.lookVertical = true | |
### | |
geometry = new THREE.CubeGeometry( 10, 10, 10 ) | |
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } ) | |
mesh = new THREE.Mesh geometry, material | |
mesh.position.set 0, 0, 0 | |
scene.add mesh | |
camera.lookAt mesh | |
render = -> | |
#controls.update clock.getDelta() | |
renderer.render scene, camera | |
requestAnimationFrame render | |
### | |
socket = io.connect() | |
socket.on "view", (world) -> | |
for entity in world.children | |
# Create 1x1 Square @ location | |
geom = new THREE.PlaneGeometry 1, 1 | |
mat = new THREE.MeshLambertMaterial | |
color: entity.properties.color | |
obj = new THREE.Mesh geom, mat | |
props = entity.properties | |
obj.position.x = props.x | |
obj.position.y = props.y | |
obj.position.z = props.z | |
scene.add obj | |
### | |
$("body").append renderer.domElement | |
render() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment