mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
simpler loop
This commit is contained in:
parent
40aecf3bf4
commit
3fdfa1b624
1 changed files with 18 additions and 19 deletions
|
@ -61,26 +61,25 @@ Script.setInterval(function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
var numToCreate = RATE_PER_SECOND * (SCRIPT_INTERVAL / 1000.0);
|
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 }));
|
var position = Vec3.sum(center, randomVector({ x: RANGE, y: RANGE, z: RANGE }));
|
||||||
if (totalCreated < NUMBER_TO_CREATE) {
|
|
||||||
Vec3.print("Position: ", position);
|
Vec3.print("Position: ", position);
|
||||||
Entities.addEntity({
|
Entities.addEntity({
|
||||||
type: TYPE,
|
type: TYPE,
|
||||||
modelURL: MODEL_URL,
|
modelURL: MODEL_URL,
|
||||||
name: "gridTest",
|
name: "gridTest",
|
||||||
position: position,
|
position: position,
|
||||||
dimensions: (TYPE == "Model") ? MODEL_DIMENSION : { x: SIZE, y: SIZE, z: SIZE },
|
dimensions: (TYPE == "Model") ? MODEL_DIMENSION : { x: SIZE, y: SIZE, z: SIZE },
|
||||||
color: { red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255 },
|
color: { red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255 },
|
||||||
velocity: VELOCITY,
|
velocity: VELOCITY,
|
||||||
angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY),
|
angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY),
|
||||||
damping: DAMPING,
|
damping: DAMPING,
|
||||||
angularDamping: ANGULAR_DAMPING,
|
angularDamping: ANGULAR_DAMPING,
|
||||||
gravity: (gravity ? GRAVITY : { x: 0, y: 0, z: 0}),
|
gravity: (gravity ? GRAVITY : { x: 0, y: 0, z: 0}),
|
||||||
collisionsWillMove: collidable,
|
collisionsWillMove: collidable,
|
||||||
lifetime: LIFETIME
|
lifetime: LIFETIME
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
totalCreated++;
|
totalCreated++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue