var Level = function(scene,options) { this.scene= scene; this.game_mesh = new THREE.Object3D(); this.init = function() { var ground = new THREE.PlaneGeometry(options.width, options.height), tall = options.tall, walls = [ new THREE.PlaneGeometry(options.height, tall), new THREE.PlaneGeometry(options.width, tall), new THREE.PlaneGeometry(options.height, tall), new THREE.PlaneGeometry(options.width, tall) ], // Set the material, the "skin" material = new THREE.MeshLambertMaterial({ color: 0xffffff} ), material2 = new THREE.MeshLambertMaterial({ color: 0xffffff} ), i; // Set the "game" modelisation object this.game_mesh.name='game mesh'; // Set and add the ground this.ground = new THREE.Mesh(ground, material2); this.ground.name='Ground'; this.ground.receiveShadow=true; this.ground.castShadow=true; this.game_mesh.receiveShadow=true; this.game_mesh.castShadow=true; this.ground.rotation.x = -Math.PI / 2; this.game_mesh.add(this.ground); // Set and add the walls this.walls = [ new THREE.PlaneGeometry(options.height, tall), new THREE.PlaneGeometry(options.width, tall), new THREE.PlaneGeometry(options.height, tall), new THREE.PlaneGeometry(options.width, tall) ]; for (i = 0; i < walls.length; i += 1) { this.walls[i] = new THREE.Mesh(walls[i], material); this.walls[i].name='Wall '+i; this.walls[i].position.y = tall / 2; this.game_mesh.add(this.walls[i]); } this.walls[0].rotation.y = -Math.PI / 2; this.walls[0].position.x = options.width / 2; this.walls[1].rotation.y = Math.PI; this.walls[1].position.z = options.height / 2; this.walls[2].rotation.y = Math.PI / 2; this.walls[2].position.x = -options.width / 2; this.walls[3].position.z = -options.height / 2; this.scene.add(this.game_mesh); }; this.load = function(options) { this.doors = new Doors(this.game_mesh, options); return this.doors.load(); }; this.add_doors = function() { this.doors.build(); var material = new THREE.MeshLambertMaterial({ color: 0xffffff} ); var obstacles = [ new THREE.CubeGeometry(30, 30, 30) ]; /* // 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.obstacles[i].name='Obstacle '+i; this.game_mesh.add(this.obstacles[i]); } this.obstacles[0].position.set(30, options.cube_sizes, 128); console.log('CUBE POS : 0 '+this.obstacles[0].position.x+' '+this.obstacles[0].position.y+' '+this.obstacles[0].position.z); */ }; };