content/hifi-public/alan/lightOnlyAC.js
Dale Glass 0d14e5a379 Initial data.
Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them
has been replaced with a symlink.

Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still
be present.
2022-02-13 18:59:11 +01:00

119 lines
No EOL
2.2 KiB
JavaScript

randFloat = function(low, high) {
return low + Math.random() * (high - low);
}
randInt = function(low, high) {
return Math.floor(randFloat(low, high));
}
print('STARTING AC LOAD');
var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
var LIGHT_POSITION = {
x: 4110.80,
y: 2556.00,
z: 6663.30
};
var LIGHT_COLOR = {
red: 255,
green: 100,
blue: 28
};
var ZERO_VEC = {
x: 0,
y: 0,
z: 0
};
var totalTime = 0;
var minLightIntensity = 1;
var maxLightIntensity = 4;
var minTimeFactor = 0.1;
var maxTimeFactor = 1;
var animationSettings = JSON.stringify({
fps: 30,
running: true,
loop: true,
firstFrame: 1,
lastFrame: 10000
});
var LightMaker = {
light: null,
spawnLight: function() {
print('CREATING LIGHT')
var _t = this;
_t.light = Entities.addEntity({
type: "Light",
position: LIGHT_POSITION,
dimensions: {
x: 12,
y: 12,
z: 12
},
color: LIGHT_COLOR
});
},
spawnBox: function() {
var _t = this;
_t.box = Entities.addEntity({
type: "Box",
position: LIGHT_POSITION,
dimensions: {
x: 5,
y: 5,
z: 5
},
color: LIGHT_COLOR
});
}
}
var hasSpawned = false;
function update(deltaTime) {
if (!Entities.serversExist() || !Entities.canRez()) {
return;
}
if (hasSpawned === false) {
// print('IN UPDATE LOOP CONDITION 2')
hasSpawned = true;
LightMaker.spawnLight();
// LightMaker.spawnBox();
return
}
totalTime += deltaTime
var intensity = (minLightIntensity + (maxLightIntensity / 4 + (Math.sin(totalTime) * maxLightIntensity / 4)));
intensity += randFloat(-0.3, 0.3);
//print('intensity::: ' + intensity)
Entities.editEntity(LightMaker.light, {
intensity: intensity
})
}
function scriptEnding() {
Entities.deleteEntity(LightMaker.light)
};
//LightMaker.spawnLight();
Script.update.connect(update);
Script.scriptEnding.connect(scriptEnding);