Traviso is an open source JS engine that makes it easy to build isometric applications that run in a web browser. It aims maximum flexibility in order you to implement your own logic on top of it. Along with a set of optimised algorithms, Traviso is built on top of the awesomely fast pixi.js rendering engine.
If you’re interested, you can follow me on twitter (@axaq) or visit the website for more info.
You can find the documentation here
Do you want to contribute? That's awesome. You can either message me through Twitter (@axaq) or use the Traviso.js blog.
After cloning the repo, install the build dependencies using npm:
$> npm install
Then build:
$> npm run build
This will create browser, CommonJS, and ES module versions of the library under dist
folder. A minified version for browsers can be found at the same place.
// Here, we initialize the pixi application
var pixiRoot = new PIXI.Application({
width: 800,
height: 600,
backgroundColor: 0xffffff,
});
// add the renderer view element to the DOM
document.body.appendChild(pixiRoot.view);
// engine-instance configuration object
var instanceConfig = {
mapDataPath: 'mapData.json', // the path to the json file that defines map data, required
assetsToLoad: ['../assets/spritesheet.json', '../assets/house.png'], // array of paths to the assets that are desired to be loaded by traviso, no need to use if assets are already loaded to PIXI cache, default null
};
// initialize traviso instance and add it to the stage
var engine = TRAVISO.getEngineInstance(instanceConfig);
pixiRoot.stage.addChild(engine);
You can now also use traviso as a npm module:
$> npm install traviso.js
import * as TRAVISO from 'traviso.js';
var engine = TRAVISO.getEngineInstance(instanceConfig);
This content is released under the (http://opensource.org/licenses/MIT) MIT License.
column index of the column-row pair
row index of the column-row pair
Type declaration for reserved direction IDs
east
north
north-east
north-west
idle, no direction
south
south-east
south-west
west
Type declaration for engine-specific configuration.
Array of paths to the assets that are desired to be loaded by traviso, no need to use if assets are already loaded to PIXI cache, default null
Background color, if defined the engine will create a solid colored background for the map, default null
Make objects transparent when the controllable is behind them, default true
Looks for a path every time an object moves to a new tile (set to false if you don't have other moving objects on your map), default true
When a tile selected don't move the controllable immediately but still call 'tileSelectCallback', default false
Callback function that will be called once everything is loaded and engine instance is ready, default null
defines if the camera will follow the current controllable or not, default true
Highlight the path when the current controllable moves on the map, default true
Highlight the target tile when the current controllable moves on the map, default true
frame to position the engine, default { x : 0, y : 0, w : 800, h : 600 }
initial zoom level of the map, default 0
specifies whether the camera moves instantly or with a tween animation to the target location, default false
specifies whether to zoom instantly or with a tween animation, default false
specifies whether the map-objects will be moved to target location instantly or with an animation, default false
the angle between the top-left edge and the horizontal diagonal of a isometric quad, default 30
The path to the json file that defines map data, required
Enable dragging the map with touch-and-touchmove or mousedown-and-mousemove on the map, default true
maximum scale that the PIXI.Container for the map can get, default 1.5
maximum zoom level, engine defined
minimum scale that the PIXI.Container for the map can get, default 0.5
minimum zoom level, engine defined
used to calculate zoom increment, defined by user, default 5
Callback function that will be called when any moving object reaches its destination (call param will be the moving object itself), default null
Callback function that will be called when a tile with an interactive map-object on it is selected (call param will be the object selected), default null
Callback function that will be called every time an objects direction or position changed, default null
Callback function that will be called when any moving object is in move and there are other objects on the next tile, default null
whether to return the path to the closest node if the target is unreachable, default false
the type of path finding algorithm two use, default TRAVISO.PF_ALGORITHMS.ASTAR_ORTHOGONAL
height of a single isometric tile, default 74
Animate the tile highlights, default true
Alpha value for the tile highlight fill (this will be overridden if a highlight-image is defined), default 0.5
Color code for the tile highlight fill (this will be overridden if a highlight-image is defined), default 0x80d7ff
Alpha value for the tile highlight stroke (this will be overridden if a highlight-image is defined), default 1.0
Color code for the tile highlight stroke (this will be overridden if a highlight-image is defined), default 0xFFFFFF
Callback function that will be called when a tile is selected (call params will be the row and column indexes of the tile selected), default null
Creates a mask using the position frame defined by 'initialPositionFrame' property or the 'posFrame' parameter that is passed to 'repositionContent' method, default false
zoom increment amount calculated by the engine according to user settings, default 0.5
Type declaration for the IDs of available path finding algorithms
Type declaration for available path finding algorithms
Type declaration for position frame setting.
height of the frame
width of the frame
x position of the frame
y position of the frame
Type declaration for x-y position pair objects
x position of the pair
y position of the pair
Type declaration for global traviso configuration.
Determines if TRAVISO can log helper text.
The direction IDs to be used in the engine
The types of available path finding algorithms
String of the current TRAVISO version.
Produces dot product of two vectors.
first vector
second vector
dot product of two vectors
Determines if TRAVISO can log helper text.
enable logging or not, default true
logging enabled or not
Checks if the value existy.
value to check
if the value existy or not
Calculates the distance between two points.
first point
second point
the distance between two points
Creates and returns an isometric engine instance with the provided configuration. Also initializes traviso global settings if it hasn't been already.
Configuration object for the isometric instance, required
Configuration object for the traviso engine, default null
A new instance of the isometric engine
Produces unit vector of a given vector.
source vector
unit vector
Checks if the given point is the polygon defined by the vertices.
point to check
array containing the vertices of the polygon
if the point is inside the polygon
Linear maps a given number in a source range to a target range
value to map
minimum value of the source range
maximum value of the source range
minimum value of the target range
maximum value of the target range
If the outlier values won't be processed, default false
mapped value according to target range
Skips the hello message of renderers that are created after this is run.
Writes logs to the browser console
text to log
Type declaration for column-row pair objects