Old stuff/old_sites/threejs/12_game/js/path.js
(Deskargatu)
var Path = function(game, options)
{
this.path_length = 7;
this.get_start_pos = function()
{
return { x: options.x, z: options.z};
};
this.get_end_pos = function()
{
var angle = Math.radians(30);
return { x: options.x + Math.cos(angle)*this.cube_width, z: options.z + Math.sin(angle)*this.cube_width};
};
this.id = 'maze_'+Math.random()+'_'+Math.random();
this.load = function()
{
};
this.getObstacles = function()
{
return [this.container_mesh];
};
this.getCollisionCallbacks = function()
{
};
this.collisionCallbacks = function(perso,collisions)
{
if(collisions.length===0)
{
return;
}
};
this.build = function()
{
console.log('build path');
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.cube_height = game.opt.door_size*0.7;
var cube_material = new THREE.MeshBasicMaterial( { color: 0x3366bb, wireframe: game.opt.debug_level>1 } );
var cube_geo = new THREE.BoxGeometry(this.cube_width, this.cube_height, 1);
this.container_mesh = new THREE.Mesh(cube_geo, cube_material);
this.container_mesh.receiveShadow=true;
this.container_mesh.castShadow=true;
this.container.add(this.container_mesh);
this.container.position.x = current_x;
this.container.position.y = 0;
this.container.position.z = current_z;
this.container.rotation.x = Math.radians(90+180);
this.angle = Math.radians(270+60*1);
this.container.rotation.z = this.angle;
this.container_mesh.position.x = this.cube_width/2 - game.opt.door_size*0.4;
game.scene.add(this.container);
};
};