more debugging

This commit is contained in:
Brad Hefta-Gaub 2015-09-29 15:45:29 -07:00
parent f83eae4d42
commit 90afeb4ce1

View file

@ -39,11 +39,13 @@ var ZERO_VEC = {
}; };
var totalTime = 0; var totalTime = 0;
var lastUpdate = 0;
var UPDATE_INTERVAL = 1 / 30; // 30fps
var MINIMUM_LIGHT_INTENSITY = 0.75; var MINIMUM_LIGHT_INTENSITY = 0.75;
var MAXIMUM_LIGHT_INTENSITY = 2.75; var MAXIMUM_LIGHT_INTENSITY = 2.75;
var LIGHT_INTENSITY_RANDOMNESS = 0.3; var LIGHT_INTENSITY_RANDOMNESS = 0.3;
var EPHEMERAL_LIFETIME = 60; // ephemeral entities will live for 60 seconds after script stops running var EPHEMERAL_LIFETIME = 10; // ephemeral entities will live for 60 seconds after script stops running
var LightMaker = { var LightMaker = {
light: null, light: null,
@ -74,17 +76,17 @@ function update(deltaTime) {
LightMaker.spawnLight(); LightMaker.spawnLight();
} else { } else {
totalTime += deltaTime; totalTime += deltaTime;
var intensity = (MINIMUM_LIGHT_INTENSITY + (MAXIMUM_LIGHT_INTENSITY + (Math.sin(totalTime) * MAXIMUM_LIGHT_INTENSITY)));
intensity += randFloat(-LIGHT_INTENSITY_RANDOMNESS, LIGHT_INTENSITY_RANDOMNESS); // We don't want to edit the entity EVERY update cycle, because that's just a lot
var properties = Entities.getEntityProperties(LightMaker.light, ["age", "lifetime"]); // of wasted bandwidth and extra effort on the server for very little visual gain
//print("props:" +JSON.stringify(properties)); if (totalTime - lastUpdate > UPDATE_INTERVAL) {
//print("deltaTime:" + deltaTime); var intensity = (MINIMUM_LIGHT_INTENSITY + (MAXIMUM_LIGHT_INTENSITY + (Math.sin(totalTime) * MAXIMUM_LIGHT_INTENSITY)));
//print("age:" + properties.age); intensity += randFloat(-LIGHT_INTENSITY_RANDOMNESS, LIGHT_INTENSITY_RANDOMNESS);
//print("lifetime:" + properties.lifetime); var properties = Entities.getEntityProperties(LightMaker.light, "age");
var newLifetime = properties.age + EPHEMERAL_LIFETIME; var newLifetime = properties.age + EPHEMERAL_LIFETIME;
//print("newLifetime:" + newLifetime); Entities.editEntity(LightMaker.light, { type: "Light", intensity: intensity, lifetime: newLifetime });
Entities.editEntity(LightMaker.light, { type: "Light", intensity: intensity, lifetime: newLifetime }); lastUpdate = totalTime;
//print("packetsToSendCount:" + Entities.packetsToSendCount()); }
} }
} }