http://three-arena.com/examples/#simplest.js
Three Arena is an opiniated WebGL game framework to create 3D terrain-based games in an HTML context. It uses three.js 3D engine, machinejs behaviour trees, recastnavigation pathfinding system, knockoutjs dom binding system and other open source projects.
game.on('start', function)
game.on('set:terrain', function)
game.on('added:character', function)
character.on('hit', function)
character.on('death', function)
Some examples here three-arena.com/examples
Or run npm install && npm start
from the project root.
new Arena({
container: 'game-container', // the container DOM ID
cameraHeight: 80,
fog: { near: 20, far: 250 }, // configure fog
})
.setTerrain('/gamedata/maps/simplest.obj', { // use this .OBJ as terrain
map: '/path/to/terrain/texture.png' // the terrain texture
// other material options, like bumpMap, wireframe, etc..
})
.addCharacter(function(done){ // add a character
new Arena.Characters.Ogro({
name: 'Shrek', // the character name
image: '/gamedata/unknown.png', // its portrait
tomb: '/gamedata/models/rts_elements.dae', // use this model when it dies
life: 100, // start with 100 life points
onLoad: function(){
this.learnSpell(Arena.Spells.FireBullet); // learn a spell
done(this); // on scene !
}
});
});
The pathfinding is done via an javascript Emscripten-compiled interface above the c++ library recastnavigation. To add methods in this module, you need to code their javascript interface and rebuild the javascript module with
npm run recast
Or build a separated build with
cd recastnavigation/emscripten
./build.sh ../../lib/pathfinding/recast.js