Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including voxel-move with all npm packages installed. Try it out:

var voxelMove = require("voxel-move")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

voxel-move v0.1.0

Utility for rotation relative based movement in voxeljs

voxel-move

Utility for rotation relative based movement in voxel.js. This probably totally already exists but I needed it faster than I could google for voxel-drone.

example

var move = require('voxel-move')

// this would be our item in voxel.js
var item = {
  mesh: new game.THREE.Mesh( /* ... */ ),
  velocity: {x: 0, y: 0, z: 0}
}

// move it forward
move(item).front(0.5)

// rotate the item 90 degs
item.mesh.rotation.y = (Math.PI / 180) * 90

// now! move forward in the direction the item is facing
move(item).front(0.5)

All the methods are chainable. Only moves on XZ (maybe later if needed or if someone else cares we can add in Y).

move(item)
  .front(0.5)
  .back(0.5)
  .left(0.5)
  .right(0.5)
  .rotate(Math.PI / 180 * 90)

release history

  • 0.1.0 - initial release

license

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free