var World = Class.extend({ var scene, lock, SCREEN_HEIGHT, SCREEN_HEIGHT, camera, renderer; init: function(parent_dom) { scene = new THREE.Scene(); clock = new THREE.Clock(); SCREEN_WIDTH = window.innerWidth; SCREEN_HEIGHT = window.innerHeight; camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); renderer = new THREE.WebGLRenderer({ antialias:true}); renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setClearColor( scene.fog.color ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT ); renderer.domElement.style.position = "relative"; parent_dom.appendChild( renderer.domElement ); }, create_room: function() { var ground = new THREE.PlaneGeometry(512, 1024), height = 128, walls = [ new THREE.PlaneGeometry(ground.height, height), new THREE.PlaneGeometry(ground.width, height), new THREE.PlaneGeometry(ground.height, height), new THREE.PlaneGeometry(ground.width, height) ], obstacles = [ new THREE.CubeGeometry(64, 64, 64) ], // Set the material, the "skin" material = new THREE.MeshLambertMaterial(args), i; // Set the "world" modelisation object this.mesh = new THREE.Object3D(); // Set and add the ground this.ground = new THREE.Mesh(ground, material); this.ground.rotation.x = -Math.PI / 2; this.mesh.add(this.ground); // Set and add the walls this.walls = []; for (i = 0; i < walls.length; i += 1) { this.walls[i] = new THREE.Mesh(walls[i], material); this.walls[i].position.y = height / 2; this.mesh.add(this.walls[i]); } this.walls[0].rotation.y = -Math.PI / 2; this.walls[0].position.x = ground.width / 2; this.walls[1].rotation.y = Math.PI; this.walls[1].position.z = ground.height / 2; this.walls[2].rotation.y = Math.PI / 2; this.walls[2].position.x = -ground.width / 2; this.walls[3].position.z = -ground.height / 2; // Set and add the obstacles this.obstacles = []; for (i = 0; i < obstacles.length; i += 1) { this.obstacles[i] = new THREE.Mesh(obstacles[i], material); this.mesh.add(this.obstacles[i]); } this.obstacles[0].position.set(0, 32, 128); }, getObstacles: function () { 'use strict'; return this.obstacles.concat(this.walls); } });