Created
November 12, 2013 21:12
-
-
Save birarda/7438811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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