Old stuff/old_sites/threejs/13_fighting/js/assets.js
(Deskargatu)
var Assets = function()
{
this.load = function()
{
var self=this;
var promises=[];
promises.push(new Promise(function(ok, reject)
{
var loader = new THREE.JSONLoader();
loader.load( "js/meshes/wall.js", function(geometry, mat)
{
self.wall_geo = geometry;
self.wall_mat = mat;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
var loader = new THREE.JSONLoader();
loader.load( "js/meshes/door.js", function(geometry, mat)
{
self.door_geo = geometry;
self.door_mat = mat;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
var loader = new THREE.JSONLoader();
loader.load( "js/meshes/dooropen.js", function(geometry, mat)
{
self.dooropen_geo = geometry;
self.dooropen_mat = mat;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
var loader = new THREE.JSONLoader();
loader.load( "blender/pingu_with_armature.json", function(geometry, mat)
{
self.perso_geo = geometry;
self.perso_mat = mat;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
var loader = new THREE.JSONLoader();
loader.load( "blender/pingu_with_armature.json", function(geometry, mat)
{
self.ennemy_geo = geometry;
self.ennemy_mat = mat;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
var loader = new THREE.JSONLoader();
loader.load( "blender/key.json", function(geometry, mat)
{
console.log('loaded ',geometry, mat);
self.key_geo = geometry;
self.key_mat = mat;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
var textureLoader = new THREE.TextureLoader();
textureLoader.load('textures/path_wall.jpg', function(tex)
{
self.path_wall_texture = tex;
self.path_wall_texture.wrapS = self.path_wall_texture.wrapT = THREE.RepeatWrapping;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
var textureLoader = new THREE.TextureLoader();
textureLoader.load('textures/path_wall_bump.jpg', function(tex)
{
self.path_wall_texture_bump = tex;
self.path_wall_texture_bump.wrapS = self.path_wall_texture_bump.wrapT = THREE.RepeatWrapping;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
var textureLoader = new THREE.TextureLoader();
textureLoader.load('textures/path_floor.jpg', function(tex)
{
self.path_floor_texture = tex;
self.path_floor_texture.wrapS = self.path_floor_texture.wrapT = THREE.RepeatWrapping;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
var textureLoader = new THREE.TextureLoader();
textureLoader.load('textures/path_floor_bump.jpg', function(tex)
{
self.path_floor_texture_bump = tex;
self.path_floor_texture_bump.wrapS = self.path_floor_texture_bump.wrapT = THREE.RepeatWrapping;
ok();
});
}));
promises.push(new Promise(function(ok, reject)
{
self.step_sound = new Audio('sounds/step.mp3');
self.step_sound.loop=true;
self.step_sound.load();
ok();
}));
return Promise.all(promises);
}
};