Skip to content

Instantly share code, notes, and snippets.

@PhilipRosedale
Forked from birarda/gist:7438811
Created November 12, 2013 21:48
Show Gist options
  • Save PhilipRosedale/7439396 to your computer and use it in GitHub Desktop.
Save PhilipRosedale/7439396 to your computer and use it in GitHub Desktop.
var PLANE_MAX_HEIGHT = 500.0;
var METER = 1.0 / TREE_SCALE;
var ORB_METERS = 8;
var ORB_UNITS = ORB_METERS * METER;
var orbHeight = 200 * METER;
var lastOrbPosition = { x: 256 * METER, y: 256 * METER};
var currentIteration = 0;
var NUM_ITERATIONS_BEFORE_SEND = 4;
function voxelOrb() {
if (currentIteration++ % NUM_ITERATIONS_BEFORE_SEND === 0) {
var newOrbPosition = { x: Agent.screenX * 512 * METER, y: Agent.screenY * 512 * METER };
if (lastOrbPosition.x != newOrbPosition.x || lastOrbPosition.y != newOrbPosition.y) {
Voxels.queueVoxelDelete(lastOrbPosition.x, orbHeight, lastOrbPosition.y, ORB_UNITS);
lastOrbPosition = newOrbPosition;
}
Voxels.queueDestructiveVoxelAdd(lastOrbPosition.x, orbHeight, lastOrbPosition.y, ORB_UNITS, 255, (Agent.buttonState * 255), 0);
}
}
// register the call back so it fires before each data send
Agent.willSendVisualDataCallback.connect(voxelOrb);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment