From 3fdfa1b624580f9a9601558a1c6079cda0a424bf Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Mon, 11 Jan 2016 17:49:46 -0800 Subject: [PATCH] simpler loop --- examples/dropStuffNearMe.js | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/examples/dropStuffNearMe.js b/examples/dropStuffNearMe.js index 0b84490b4c..1c7c1f4f48 100644 --- a/examples/dropStuffNearMe.js +++ b/examples/dropStuffNearMe.js @@ -61,26 +61,25 @@ Script.setInterval(function () { } var numToCreate = RATE_PER_SECOND * (SCRIPT_INTERVAL / 1000.0); - for (var i = 0; i < numToCreate; i++) { + for (var i = 0; (i < numToCreate) && (totalCreated < NUMBER_TO_CREATE); i++) { var position = Vec3.sum(center, randomVector({ x: RANGE, y: RANGE, z: RANGE })); - if (totalCreated < NUMBER_TO_CREATE) { - Vec3.print("Position: ", position); - Entities.addEntity({ - type: TYPE, - modelURL: MODEL_URL, - name: "gridTest", - position: position, - dimensions: (TYPE == "Model") ? MODEL_DIMENSION : { x: SIZE, y: SIZE, z: SIZE }, - color: { red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255 }, - velocity: VELOCITY, - angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY), - damping: DAMPING, - angularDamping: ANGULAR_DAMPING, - gravity: (gravity ? GRAVITY : { x: 0, y: 0, z: 0}), - collisionsWillMove: collidable, - lifetime: LIFETIME - }); - } + + Vec3.print("Position: ", position); + Entities.addEntity({ + type: TYPE, + modelURL: MODEL_URL, + name: "gridTest", + position: position, + dimensions: (TYPE == "Model") ? MODEL_DIMENSION : { x: SIZE, y: SIZE, z: SIZE }, + color: { red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255 }, + velocity: VELOCITY, + angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY), + damping: DAMPING, + angularDamping: ANGULAR_DAMPING, + gravity: (gravity ? GRAVITY : { x: 0, y: 0, z: 0}), + collisionsWillMove: collidable, + lifetime: LIFETIME + }); totalCreated++; }