var Path = function(game, options) { this.path_length = 5; this.get_start_pos = function() { return { x: options.x, z: options.z}; }; this.get_end_pos = function() { var angle = Math.radians(30); var width = this.cube_width; return { x: options.x + Math.cos(angle)*width, z: options.z + Math.sin(angle)*width}; }; this.id = 'maze_'+Math.random()+'_'+Math.random(); this.load = function() { }; this.getObstacles = function() { return [this.top_mesh, this.bottom_mesh]; }; this.getCollisionCallbacks = function() { }; this.collisionCallbacks = function(perso,collisions) { if(collisions.length===0) { return; } }; this.build = function() { var numPoints = 100; var current_x = options.x; var current_z = options.z; this.container = new THREE.Object3D(); this.cube_width = game.opt.door_size * this.path_length; this.real_cube_width = this.cube_width - game.opt.door_size; this.cube_height = game.opt.door_size*0.7; var path_wall_texture = game.assets.path_wall_texture; path_wall_texture.repeat.set( this.real_cube_width/30, this.cube_height/30 ); var path_wall_texture_bump = game.assets.path_wall_texture_bump; path_wall_texture_bump.repeat.set( this.real_cube_width/100, this.cube_height/100 ); var path_floor_texture = game.assets.path_floor_texture; path_floor_texture.repeat.set( this.real_cube_width/100, this.cube_height/100 ); var path_floor_texture_bump = game.assets.path_floor_texture_bump; path_floor_texture_bump.repeat.set( this.real_cube_width/100, this.cube_height/100 ); var floor_material = new THREE.MeshPhongMaterial({ bumpScale:0.5, map: path_floor_texture, bumpMap: path_floor_texture_bump }); var wall_material = new THREE.MeshPhongMaterial( { map: path_wall_texture, bumpMap: path_wall_texture_bump } ); if(game.opt.debug_level>1) { wall_material = new THREE.MeshPhongMaterial(); floor_material = new THREE.MeshPhongMaterial(); } var cube_geo = new THREE.BoxGeometry(this.real_cube_width, this.cube_height, 1); var top_geo = new THREE.BoxGeometry(this.real_cube_width, game.opt.door_size*0.5, 1); this.path_mesh = new THREE.Mesh(cube_geo, floor_material); this.path_mesh.receiveShadow=true; this.path_mesh.position.x = this.real_cube_width/2; this.top_mesh = new THREE.Mesh(top_geo, wall_material); this.top_mesh.position.z = game.opt.door_size*0.20; this.top_mesh.position.x = this.real_cube_width/2; this.top_mesh.position.y = this.cube_height*0.6; this.top_mesh.rotation.x = Math.radians(70); this.bottom_mesh = new THREE.Mesh(top_geo, wall_material); this.bottom_mesh.position.z = game.opt.door_size*0.20; this.bottom_mesh.position.x = this.real_cube_width/2; this.bottom_mesh.position.y = -this.cube_height*0.6; this.bottom_mesh.rotation.x = Math.radians(-70); this.angle = Math.radians(-30); this.container.position.x = current_x; this.container.position.y = 0; this.container.position.z = current_z; this.container.rotation.x = Math.radians(-90); this.container.rotation.z = this.angle; this.container.add(this.path_mesh); this.container.add(this.top_mesh); this.container.add(this.bottom_mesh); //this.container.add(this.bottom_mesh); game.scene.add(this.container); }; };