tweaks to editParticle example

This commit is contained in:
ZappoMan 2014-01-27 11:11:20 -08:00
parent c5ba92d73e
commit 13a92bc3c9

View file

@ -9,6 +9,9 @@
//
var count = 0;
var moveUntil = 2000;
var stopAfter = moveUntil + 100;
var expectedLifetime = (moveUntil/60) + 1; // 1 second after done moving...
var originalProperties = {
position: { x: 10,
@ -28,7 +31,9 @@ var originalProperties = {
color: { red: 0,
green: 255,
blue: 0 }
blue: 0 },
lifetime: expectedLifetime
};
@ -38,17 +43,17 @@ var positionDelta = { x: 0.05, y: 0, z: 0 };
var particleID = Particles.addParticle(originalProperties);
function moveParticle() {
if (count >= 100) {
if (count >= moveUntil) {
//Agent.stop();
// delete it...
if (count == 100) {
if (count == moveUntil) {
print("calling Particles.deleteParticle()");
Particles.deleteParticle(particleID);
}
// stop it...
if (count >= 200) {
if (count >= stopAfter) {
print("calling Agent.stop()");
Agent.stop();
}
@ -77,16 +82,6 @@ function moveParticle() {
print("newProperties.position = " + newProperties.position.x + "," + newProperties.position.y+ "," + newProperties.position.z);
Particles.editParticle(particleID, newProperties);
// also check to see if we can "find" particles...
var searchAt = { x: 9, y: 0, z: 0};
var searchRadius = 2;
var foundParticle = Particles.findClosestParticle(searchAt, searchRadius);
if (foundParticle.isKnownID) {
print("found particle:" + foundParticle.id);
} else {
print("could not find particle in or around x=9 to x=11:");
}
}