Skip to content

shama/voxel-trajectory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

voxel-trajectory

Calculate trajectories in voxel.js.

View the voxel-throw example

example

Create a trajectory to throw an item based on the direction the camera is facing:

var trajectory = require('voxel-trajectory');

// x,y of voxel.js camera
var camera = game.cameraRotation();

// rotate the axis -90 degs to throw forward
camera[0] -= Math.PI / 2;

// create an item with a velocity of 2 towards trajectory
var item = {
  velocity: trajectory(2, camera),
  mesh: /* ... */,
  size: game.cubeSize,
  resting: false
};
game.addItem(item);

The trajectory can be from anywhere, such as a meteor:

var meteor = {
  velocity: trajectory({
    // pretty fast
    velocity: 5,
    // 45 degrees
    rotation: [Math.PI / 180 * 45, Math.PI / 180 * 45, 0],
    // from the sky
    origin:   [1000, 5000, 1000]
  })
};

api

trajectory([velocity:number, rotation:[x, y, z], origin:[x, y, z]])

install

With npm do:

npm install voxel-trajectory

Use browserify to require('voxel-trajectory').

release history

  • 0.2.0 - update to use arrays
  • 0.1.0 - initial release

license

Copyright (c) 2013 Kyle Robinson Young
Licensed under the MIT license.

About

Calculate trajectories in voxel.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published