0.2.0 • Published 11 years ago

voxel-trajectory v0.2.0

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

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.x -= 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: {x: Math.PI / 180 * 45, y: Math.PI / 180 * 45},
    // from the sky
    origin:   {x: 1000, y: 5000, z: 1000}
  })
};

api

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

install

With npm do:

npm install voxel-trajectory

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

release history

  • 0.1.0 - initial release

license

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

0.2.0

11 years ago

0.1.0

11 years ago