code cleanup

This commit is contained in:
James B. Pollack 2016-02-26 10:42:45 -08:00
parent b0cb4b7199
commit 6c6ea3f0a7
2 changed files with 10 additions and 14 deletions

View file

@ -30,18 +30,18 @@ function findCells() {
var results = Entities.findEntities(basePosition, 60000); var results = Entities.findEntities(basePosition, 60000);
if (results.length === 0) { if (results.length === 0) {
// print('no entities found') // print('no entities found')
return; return;
} }
results.forEach(function(v) { results.forEach(function(v) {
var name = Entities.getEntityProperties(v, 'name').name; var name = Entities.getEntityProperties(v, 'name').name;
// print('name is:: ' + name) // print('name is:: ' + name)
if (name === 'Cell') { if (name === 'Cell') {
// print('found a cell!!' + v) // print('found a cell!!' + v)
Script.setTimeout(function() { Script.setTimeout(function() {
moveCell(v); moveCell(v);
}, Math.random() * THROTTLE_RATE) }, Math.random() * THROTTLE_RATE);
} }
}); });
} }
@ -51,7 +51,7 @@ var minAngularVelocity = 0.01;
var maxAngularVelocity = 0.03; var maxAngularVelocity = 0.03;
function moveCell(entityId) { function moveCell(entityId) {
// print('moving a cell! ' + entityId) // print('moving a cell! ' + entityId)
var magnitudeAV = maxAngularVelocity; var magnitudeAV = maxAngularVelocity;
@ -60,7 +60,7 @@ function moveCell(entityId) {
y: Math.random() - 0.5, y: Math.random() - 0.5,
z: Math.random() - 0.5 z: Math.random() - 0.5
}; };
// print("ROT magnitude is " + magnitudeAV + " and direction is " + directionAV.x); // print("ROT magnitude is " + magnitudeAV + " and direction is " + directionAV.x);
Entities.editEntity(entityId, { Entities.editEntity(entityId, {
angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV)) angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV))
}); });
@ -84,7 +84,7 @@ function update(deltaTime) {
if (THROTTLE === true) { if (THROTTLE === true) {
sinceLastUpdate = sinceLastUpdate + deltaTime * 1000; sinceLastUpdate = sinceLastUpdate + deltaTime * 1000;
if (sinceLastUpdate > THROTTLE_RATE) { if (sinceLastUpdate > THROTTLE_RATE) {
// print('SHOULD FIND CELLS!!!') // print('SHOULD FIND CELLS!!!')
sinceLastUpdate = 0; sinceLastUpdate = 0;
findCells(); findCells();
} else { } else {

View file

@ -30,18 +30,17 @@ function findVesicles() {
var results = Entities.findEntities(basePosition, 60000); var results = Entities.findEntities(basePosition, 60000);
if (results.length === 0) { if (results.length === 0) {
print('no entities found') // print('no entities found');
return; return;
} }
results.forEach(function(v) { results.forEach(function(v) {
var name = Entities.getEntityProperties(v, 'name').name; var name = Entities.getEntityProperties(v, 'name').name;
print('name is:: ' + name)
if (name === 'vesicle') { if (name === 'vesicle') {
// print('found a vesicle!!' + v) //print('found a vesicle!!' + v)
Script.setTimeout(function() { Script.setTimeout(function() {
moveVesicle(v); moveVesicle(v);
}, Math.random() * THROTTLE_RATE) }, Math.random() * THROTTLE_RATE);
} }
}); });
} }
@ -78,7 +77,6 @@ function moveVesicle(entityId) {
} }
function update(deltaTime) { function update(deltaTime) {
// print('deltaTime',deltaTime)
if (!initialized) { if (!initialized) {
print("checking for servers..."); print("checking for servers...");
if (Entities.serversExist() && Entities.canRez()) { if (Entities.serversExist() && Entities.canRez()) {
@ -93,11 +91,9 @@ function update(deltaTime) {
if (THROTTLE === true) { if (THROTTLE === true) {
sinceLastUpdate = sinceLastUpdate + deltaTime * 1000; sinceLastUpdate = sinceLastUpdate + deltaTime * 1000;
if (sinceLastUpdate > THROTTLE_RATE) { if (sinceLastUpdate > THROTTLE_RATE) {
// print('SHOULD FIND VESICLES!!!')
sinceLastUpdate = 0; sinceLastUpdate = 0;
findVesicles(); findVesicles();
} else { } else {
// print('returning in update ' + sinceLastUpdate)
return; return;
} }
} }