mirror of
https://github.com/overte-org/overte.git
synced 2025-06-18 21:20:38 +02:00
CR feedback
This commit is contained in:
parent
3f85daf276
commit
d8e7c60ce0
3 changed files with 95 additions and 96 deletions
|
@ -1,11 +1,11 @@
|
||||||
//
|
//
|
||||||
// lighteningEntity.js
|
// lightningEntity.js
|
||||||
// examples/entityScripts
|
// examples/entityScripts
|
||||||
//
|
//
|
||||||
// Created by Brad Hefta-Gaub on 3/1/16.
|
// Created by Brad Hefta-Gaub on 3/1/16.
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// This is an example of an entity script which will randomly create a flash of lightening and a thunder sound
|
// This is an example of an entity script which will randomly create a flash of lightning and a thunder sound
|
||||||
// effect, as well as a background rain sound effect. It can be applied to any entity, although it works best
|
// effect, as well as a background rain sound effect. It can be applied to any entity, although it works best
|
||||||
// on a zone entity.
|
// on a zone entity.
|
||||||
//
|
//
|
||||||
|
@ -21,31 +21,31 @@
|
||||||
//
|
//
|
||||||
// You can change these values to change some of the various effects of the rain storm.
|
// You can change these values to change some of the various effects of the rain storm.
|
||||||
// These values can also be controlled by setting user properties on the entity that you've attached this script to.
|
// These values can also be controlled by setting user properties on the entity that you've attached this script to.
|
||||||
// add a "lightening" section to a JSON encoded portion of the user data... for example:
|
// add a "lightning" section to a JSON encoded portion of the user data... for example:
|
||||||
// {
|
// {
|
||||||
// "lightening": {
|
// "lightning": {
|
||||||
// "flashMax": 20,
|
// "flashMax": 20,
|
||||||
// "flashMin": 0,
|
// "flashMin": 0,
|
||||||
// "flashMaxRandomness": 10,
|
// "flashMaxRandomness": 10,
|
||||||
// "flashIntensityStepRandomeness": 2,
|
// "flashIntensityStepRandomeness": 2,
|
||||||
// "averageLighteningStrikeGap": 120,
|
// "averageLighteningStrikeGap": 120,
|
||||||
// "extraRandomRangeLighteningStrikeGap": 10,
|
// "extraRandomRangeLightningStrikeGap": 10,
|
||||||
// "thunderURL": "atp:1336efe995398f5e0d46b37585785de8ba872fe9a9b718264db03748cd41c758.wav",
|
// "thunderURL": "atp:1336efe995398f5e0d46b37585785de8ba872fe9a9b718264db03748cd41c758.wav",
|
||||||
// "thunderVolume": 0.1,
|
// "thunderVolume": 0.1,
|
||||||
// "rainURL": "atp:e0cc7438aca776636f6e6f731685781d9999b961c945e4e5760d937be5beecdd.wav",
|
// "rainURL": "atp:e0cc7438aca776636f6e6f731685781d9999b961c945e4e5760d937be5beecdd.wav",
|
||||||
// "rainVolume": 0.05
|
// "rainVolume": 0.05
|
||||||
// }
|
// }
|
||||||
// // NOTE: you can have other user data here as well, so long as it's JSON encoded, it won't impact the lightening script
|
// // NOTE: you can have other user data here as well, so long as it's JSON encoded, it won't impact the lightning script
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var MAX_FLASH_INTENSITY = 20; // this controls how bright the lightening effect appears
|
var MAX_FLASH_INTENSITY = 20; // this controls how bright the lightning effect appears
|
||||||
var MIN_FLASH_INTENSITY = 0; // this is probably best at 0, but it could be higher, which will make the lightening not fade completely to darkness before going away.
|
var MIN_FLASH_INTENSITY = 0; // this is probably best at 0, but it could be higher, which will make the lightning not fade completely to darkness before going away.
|
||||||
var MAX_FLASH_INTENSITY_RANDOMNESS = 10; // this will add some randomness to the max brightness of the lightening
|
var MAX_FLASH_INTENSITY_RANDOMNESS = 10; // this will add some randomness to the max brightness of the lightning
|
||||||
var FLASH_INTENSITY_STEP_RANDOMNESS = 2; // as the lightening goes from min to max back to min, this will make it more random in it's brightness
|
var FLASH_INTENSITY_STEP_RANDOMNESS = 2; // as the lightning goes from min to max back to min, this will make it more random in it's brightness
|
||||||
var AVERAGE_LIGHTENING_STRIKE_GAP_IN_SECONDS = 120; // how long on average between lighting
|
var AVERAGE_LIGHTNING_STRIKE_GAP_IN_SECONDS = 120; // how long on average between lighting
|
||||||
var EXTRA_RANDOM_RANGE_LIGHTENING_STRIKE_GAP_IN_SECONDS = 10; // some randomness to the lightening gap
|
var EXTRA_RANDOM_RANGE_LIGHTNING_STRIKE_GAP_IN_SECONDS = 10; // some randomness to the lightning gap
|
||||||
var THUNDER_SOUND_URL = "https://s3.amazonaws.com/hifi-public/brad/rainstorm/thunder-48k.wav"; // thunder sound effect, must be 48k 16bit PCM
|
var THUNDER_SOUND_URL = "https://s3.amazonaws.com/hifi-public/brad/rainstorm/thunder-48k.wav"; // thunder sound effect, must be 48k 16bit PCM
|
||||||
var THUNDER_VOLUME = 1; // adjust the volume of the thunder sound effect
|
var THUNDER_VOLUME = 1; // adjust the volume of the thunder sound effect
|
||||||
var RAIN_SOUND_URL = "https://s3.amazonaws.com/hifi-public/brad/rainstorm/rain.wav"; // the background rain, this will loop
|
var RAIN_SOUND_URL = "https://s3.amazonaws.com/hifi-public/brad/rainstorm/rain.wav"; // the background rain, this will loop
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// the "constructor" for our class. pretty simple, it just sets our _this, so we can access it later.
|
// the "constructor" for our class. pretty simple, it just sets our _this, so we can access it later.
|
||||||
function Lightening() {
|
function Lightning() {
|
||||||
_this = this;
|
_this = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
// This is the class definition/prototype for our class. Funtions declared here will be accessible
|
// This is the class definition/prototype for our class. Funtions declared here will be accessible
|
||||||
// via the instance of the entity
|
// via the instance of the entity
|
||||||
//
|
//
|
||||||
Lightening.prototype = {
|
Lightning.prototype = {
|
||||||
|
|
||||||
// preload()
|
// preload()
|
||||||
// This is called by every viewer/interface instance that "sees" the entity you've attached this script to.
|
// This is called by every viewer/interface instance that "sees" the entity you've attached this script to.
|
||||||
|
@ -110,8 +110,8 @@
|
||||||
_this.lastStrike = now;
|
_this.lastStrike = now;
|
||||||
|
|
||||||
// some of our other state related items
|
// some of our other state related items
|
||||||
_this.lighteningID = false; // this will be the entityID for any lightening that we create
|
_this.lightningID = false; // this will be the entityID for any lightning that we create
|
||||||
_this.lighteningActive = false; // are we actively managing lightening
|
_this.lightningActive = false; // are we actively managing lightning
|
||||||
|
|
||||||
// Get the entities userData property, to see if someone has overridden any of our default settings
|
// Get the entities userData property, to see if someone has overridden any of our default settings
|
||||||
var userDataText = Entities.getEntityProperties(entityID, ["userData"]).userData;
|
var userDataText = Entities.getEntityProperties(entityID, ["userData"]).userData;
|
||||||
|
@ -119,21 +119,21 @@
|
||||||
if (userDataText !== "") {
|
if (userDataText !== "") {
|
||||||
userData = JSON.parse(userDataText);
|
userData = JSON.parse(userDataText);
|
||||||
}
|
}
|
||||||
var lighteningUserData = valueOrDefault(userData.lightening, {});
|
var lightningUserData = valueOrDefault(userData.lightning, {});
|
||||||
_this.flashIntensityStepRandomeness = valueOrDefault(lighteningUserData.flashIntensityStepRandomness, FLASH_INTENSITY_STEP_RANDOMNESS);
|
_this.flashIntensityStepRandomeness = valueOrDefault(lightningUserData.flashIntensityStepRandomness, FLASH_INTENSITY_STEP_RANDOMNESS);
|
||||||
_this.flashMax = valueOrDefault(lighteningUserData.flashMax, MAX_FLASH_INTENSITY);
|
_this.flashMax = valueOrDefault(lightningUserData.flashMax, MAX_FLASH_INTENSITY);
|
||||||
_this.flashMin = valueOrDefault(lighteningUserData.flashMin, MIN_FLASH_INTENSITY);
|
_this.flashMin = valueOrDefault(lightningUserData.flashMin, MIN_FLASH_INTENSITY);
|
||||||
_this.flashMaxRandomness = valueOrDefault(lighteningUserData.flashMaxRandomness, MAX_FLASH_INTENSITY_RANDOMNESS);
|
_this.flashMaxRandomness = valueOrDefault(lightningUserData.flashMaxRandomness, MAX_FLASH_INTENSITY_RANDOMNESS);
|
||||||
_this.averageLighteningStrikeGap = valueOrDefault(lighteningUserData.averageLighteningStrikeGap, AVERAGE_LIGHTENING_STRIKE_GAP_IN_SECONDS);
|
_this.averageLightningStrikeGap = valueOrDefault(lightningUserData.averageLightningStrikeGap, AVERAGE_LIGHTNING_STRIKE_GAP_IN_SECONDS);
|
||||||
_this.extraRandomRangeLighteningStrikeGap = valueOrDefault(lighteningUserData.extraRandomRangeLighteningStrikeGap, EXTRA_RANDOM_RANGE_LIGHTENING_STRIKE_GAP_IN_SECONDS);
|
_this.extraRandomRangeLightningStrikeGap = valueOrDefault(lightningUserData.extraRandomRangeLightningStrikeGap, EXTRA_RANDOM_RANGE_LIGHTNING_STRIKE_GAP_IN_SECONDS);
|
||||||
|
|
||||||
var thunderURL = valueOrDefault(lighteningUserData.thunderURL, THUNDER_SOUND_URL);
|
var thunderURL = valueOrDefault(lightningUserData.thunderURL, THUNDER_SOUND_URL);
|
||||||
_this.thunderSound = SoundCache.getSound(thunderURL); // start downloading the thunder into the cache in case we need it later
|
_this.thunderSound = SoundCache.getSound(thunderURL); // start downloading the thunder into the cache in case we need it later
|
||||||
_this.thunderVolume = valueOrDefault(lighteningUserData.thunderVolume, THUNDER_VOLUME);
|
_this.thunderVolume = valueOrDefault(lightningUserData.thunderVolume, THUNDER_VOLUME);
|
||||||
|
|
||||||
var rainURL = valueOrDefault(lighteningUserData.rainURL, RAIN_SOUND_URL);
|
var rainURL = valueOrDefault(lightningUserData.rainURL, RAIN_SOUND_URL);
|
||||||
_this.rainSound = SoundCache.getSound(rainURL); // start downloading the rain, we will be using it for sure
|
_this.rainSound = SoundCache.getSound(rainURL); // start downloading the rain, we will be using it for sure
|
||||||
_this.rainVolume = valueOrDefault(lighteningUserData.rainVolume, RAIN_VOLUME);
|
_this.rainVolume = valueOrDefault(lightningUserData.rainVolume, RAIN_VOLUME);
|
||||||
_this.rainPlaying = false;
|
_this.rainPlaying = false;
|
||||||
|
|
||||||
Script.update.connect(_this.onUpdate); // connect our onUpdate to a regular update signal from the interface
|
Script.update.connect(_this.onUpdate); // connect our onUpdate to a regular update signal from the interface
|
||||||
|
@ -167,17 +167,17 @@
|
||||||
_this.rainPlaying = true;
|
_this.rainPlaying = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// this handles a single "step" of the lightening flash effect. It assumes a light entity has already been created,
|
// this handles a single "step" of the lightning flash effect. It assumes a light entity has already been created,
|
||||||
// and all it really does is change the intensity of the light based on the settings that are part of this entity's
|
// and all it really does is change the intensity of the light based on the settings that are part of this entity's
|
||||||
// userData.
|
// userData.
|
||||||
flashLightening: function (lighteningID) {
|
flashLightning: function (lightningID) {
|
||||||
var lighteningProperties = Entities.getEntityProperties(lighteningID, ["userData", "intensity"]);
|
var lightningProperties = Entities.getEntityProperties(lightningID, ["userData", "intensity"]);
|
||||||
var lighteningParameters = JSON.parse(lighteningProperties.userData);
|
var lightningParameters = JSON.parse(lightningProperties.userData);
|
||||||
var currentIntensity = lighteningProperties.intensity;
|
var currentIntensity = lightningProperties.intensity;
|
||||||
var flashDirection = lighteningParameters.flashDirection;
|
var flashDirection = lightningParameters.flashDirection;
|
||||||
var flashMax = lighteningParameters.flashMax;
|
var flashMax = lightningParameters.flashMax;
|
||||||
var flashMin = lighteningParameters.flashMin;
|
var flashMin = lightningParameters.flashMin;
|
||||||
var flashIntensityStepRandomeness = lighteningParameters.flashIntensityStepRandomeness;
|
var flashIntensityStepRandomeness = lightningParameters.flashIntensityStepRandomeness;
|
||||||
var newIntensity = currentIntensity + flashDirection + randFloat(-flashIntensityStepRandomeness, flashIntensityStepRandomeness);
|
var newIntensity = currentIntensity + flashDirection + randFloat(-flashIntensityStepRandomeness, flashIntensityStepRandomeness);
|
||||||
|
|
||||||
if (flashDirection > 0) {
|
if (flashDirection > 0) {
|
||||||
|
@ -194,14 +194,14 @@
|
||||||
|
|
||||||
// if we reached 0 intensity, then we're done with this strike...
|
// if we reached 0 intensity, then we're done with this strike...
|
||||||
if (newIntensity === 0) {
|
if (newIntensity === 0) {
|
||||||
_this.lighteningActive = false;
|
_this.lightningActive = false;
|
||||||
Entities.deleteEntity(lighteningID);
|
Entities.deleteEntity(lightningID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME - we probably don't need to re-edit the userData of the light... we're only
|
// FIXME - we probably don't need to re-edit the userData of the light... we're only
|
||||||
// changing direction, the rest are the same... we could just store direction in our
|
// changing direction, the rest are the same... we could just store direction in our
|
||||||
// own local variable state
|
// own local variable state
|
||||||
var newLighteningParameters = JSON.stringify({
|
var newLightningParameters = JSON.stringify({
|
||||||
flashDirection: flashDirection,
|
flashDirection: flashDirection,
|
||||||
flashIntensityStepRandomeness: flashIntensityStepRandomeness,
|
flashIntensityStepRandomeness: flashIntensityStepRandomeness,
|
||||||
flashMax: flashMax,
|
flashMax: flashMax,
|
||||||
|
@ -209,31 +209,31 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// this is what actually creates the effect, changing the intensity of the light
|
// this is what actually creates the effect, changing the intensity of the light
|
||||||
Entities.editEntity(lighteningID, {intensity: newIntensity, userData: newLighteningParameters});
|
Entities.editEntity(lightningID, {intensity: newIntensity, userData: newLightningParameters});
|
||||||
},
|
},
|
||||||
|
|
||||||
// findMyLightening() is designed to make the script more robust. Since we're an open editable platform
|
// findMyLightning() is designed to make the script more robust. Since we're an open editable platform
|
||||||
// it's possible that from the time that we started the lightening effect until "now" when we're attempting
|
// it's possible that from the time that we started the lightning effect until "now" when we're attempting
|
||||||
// to change the light, some other client might have deleted our light. Before we proceed in editing
|
// to change the light, some other client might have deleted our light. Before we proceed in editing
|
||||||
// the light, we check to see if it exists.
|
// the light, we check to see if it exists.
|
||||||
findMyLightening: function () {
|
findMyLightning: function () {
|
||||||
if (_this.lighteningID !== false) {
|
if (_this.lightningID !== false) {
|
||||||
var lighteningName = Entities.getEntityProperties(_this.lighteningID, "name").name;
|
var lightningName = Entities.getEntityProperties(_this.lightningID, "name").name;
|
||||||
if (lighteningName !== undefined) {
|
if (lightningName !== undefined) {
|
||||||
return _this.lighteningID;
|
return _this.lightningID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
// findOtherLightening() is designed to allow this script to work in a "multi-user" environment, which we
|
// findOtherLightning() is designed to allow this script to work in a "multi-user" environment, which we
|
||||||
// must assume we are in. Since every user/viewer/client that connect to the domain and "sees" our entity
|
// must assume we are in. Since every user/viewer/client that connect to the domain and "sees" our entity
|
||||||
// is going to run this script, any of them could be in charge of flashing the lightening. So before we
|
// is going to run this script, any of them could be in charge of flashing the lightning. So before we
|
||||||
// start to flash the lightening, we will first check to see if someone else already is.
|
// start to flash the lightning, we will first check to see if someone else already is.
|
||||||
//
|
//
|
||||||
// returns true if some other lightening exists... likely because some other viewer is flashing it
|
// returns true if some other lightning exists... likely because some other viewer is flashing it
|
||||||
// returns false if no other lightening exists...
|
// returns false if no other lightning exists...
|
||||||
findOtherLightening: function () {
|
findOtherLightning: function () {
|
||||||
var myPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
var myPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||||
|
|
||||||
// find all entities near me...
|
// find all entities near me...
|
||||||
|
@ -245,20 +245,20 @@
|
||||||
checkEntityID = entities[entity];
|
checkEntityID = entities[entity];
|
||||||
checkProperties = Entities.getEntityProperties(checkEntityID, ["name", "type"]);
|
checkProperties = Entities.getEntityProperties(checkEntityID, ["name", "type"]);
|
||||||
|
|
||||||
// check to see if they are lightening
|
// check to see if they are lightning
|
||||||
if (checkProperties.type === "Light" && checkProperties.name === "lightening for creator:" + _this.entityID) {
|
if (checkProperties.type === "Light" && checkProperties.name === "lightning for creator:" + _this.entityID) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
// createNewLightening() actually creates new lightening and plays the thunder sound
|
// createNewLightning() actually creates new lightning and plays the thunder sound
|
||||||
createNewLightening: function () {
|
createNewLightning: function () {
|
||||||
var myPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
var myPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||||
_this.lighteningID = Entities.addEntity({
|
_this.lightningID = Entities.addEntity({
|
||||||
type: "Light",
|
type: "Light",
|
||||||
name: "lightening for creator:" + _this.entityID,
|
name: "lightning for creator:" + _this.entityID,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
flashDirection: 1,
|
flashDirection: 1,
|
||||||
flashIntensityStepRandomeness: _this.flashIntensityStepRandomeness,
|
flashIntensityStepRandomeness: _this.flashIntensityStepRandomeness,
|
||||||
|
@ -271,7 +271,7 @@
|
||||||
collisionless: true,
|
collisionless: true,
|
||||||
dimensions: {x: 1000, y: 1000, z: 1000},
|
dimensions: {x: 1000, y: 1000, z: 1000},
|
||||||
color: {red: 255, green: 255, blue: 255},
|
color: {red: 255, green: 255, blue: 255},
|
||||||
lifetime: 10 // lightening only lasts 10 seconds....
|
lifetime: 10 // lightning only lasts 10 seconds....
|
||||||
});
|
});
|
||||||
|
|
||||||
// play the thunder...
|
// play the thunder...
|
||||||
|
@ -280,11 +280,11 @@
|
||||||
volume: _this.thunderVolume
|
volume: _this.thunderVolume
|
||||||
});
|
});
|
||||||
|
|
||||||
return _this.lighteningID;
|
return _this.lightningID;
|
||||||
},
|
},
|
||||||
|
|
||||||
// onUpdate() this will be called regularly, approximately every frame of the simulation. We will use
|
// onUpdate() this will be called regularly, approximately every frame of the simulation. We will use
|
||||||
// it to determine if we need to do a lightening/thunder strike
|
// it to determine if we need to do a lightning/thunder strike
|
||||||
onUpdate: function () {
|
onUpdate: function () {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
|
||||||
|
@ -293,40 +293,40 @@
|
||||||
_this.playLocalRain();
|
_this.playLocalRain();
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: _this.lighteningActive will only be TRUE if we are the one who created
|
// NOTE: _this.lightningActive will only be TRUE if we are the one who created
|
||||||
// the lightening and we are in charge of flashing it...
|
// the lightning and we are in charge of flashing it...
|
||||||
if (_this.lighteningActive) {
|
if (_this.lightningActive) {
|
||||||
var lighteningID = _this.findMyLightening();
|
var lightningID = _this.findMyLightning();
|
||||||
// if for some reason our lightening is gone... then just return to non-active state
|
// if for some reason our lightning is gone... then just return to non-active state
|
||||||
if (lighteningID === false) {
|
if (lightningID === false) {
|
||||||
_this.lighteningActive = false;
|
_this.lightningActive = false;
|
||||||
_this.lighteningID = false;
|
_this.lightningID = false;
|
||||||
} else {
|
} else {
|
||||||
// otherwise, flash our lightening...
|
// otherwise, flash our lightning...
|
||||||
_this.flashLightening(lighteningID);
|
_this.flashLightning(lightningID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// whether or not it's time for us to strike, we always keep an eye out for anyone else
|
// whether or not it's time for us to strike, we always keep an eye out for anyone else
|
||||||
// striking... and if we see someone else striking, we will reset our lastStrike time
|
// striking... and if we see someone else striking, we will reset our lastStrike time
|
||||||
if (_this.findOtherLightening()) {
|
if (_this.findOtherLightning()) {
|
||||||
_this.lastStrike = now;
|
_this.lastStrike = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sinceLastStrike = now - _this.lastStrike;
|
var sinceLastStrike = now - _this.lastStrike;
|
||||||
var nextRandomStrikeTime = _this.averageLighteningStrikeGap
|
var nextRandomStrikeTime = _this.averageLightningStrikeGap
|
||||||
+ randFloat(-_this.extraRandomRangeLighteningStrikeGap,
|
+ randFloat(-_this.extraRandomRangeLightningStrikeGap,
|
||||||
_this.extraRandomRangeLighteningStrikeGap);
|
_this.extraRandomRangeLightningStrikeGap);
|
||||||
|
|
||||||
if (sinceLastStrike > nextRandomStrikeTime * MSECS_PER_SECOND) {
|
if (sinceLastStrike > nextRandomStrikeTime * MSECS_PER_SECOND) {
|
||||||
|
|
||||||
// so it's time for a strike... let's see if someone else has lightening...
|
// so it's time for a strike... let's see if someone else has lightning...
|
||||||
// if no one else is flashing lightening... then we create it...
|
// if no one else is flashing lightning... then we create it...
|
||||||
if (_this.findOtherLightening()) {
|
if (_this.findOtherLightning()) {
|
||||||
_this.lighteningActive = false;
|
_this.lightningActive = false;
|
||||||
_this.lighteningID = false;
|
_this.lightningID = false;
|
||||||
} else {
|
} else {
|
||||||
_this.createNewLightening();
|
_this.createNewLightning();
|
||||||
_this.lighteningActive = true;
|
_this.lightningActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_this.lastStrike = now;
|
_this.lastStrike = now;
|
||||||
|
@ -335,5 +335,5 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Lightening();
|
return new Lightning();
|
||||||
});
|
});
|
|
@ -2,7 +2,7 @@
|
||||||
// Turbulence and Day/Night cycle added by Michael Olson - OMGparticles/2015
|
// Turbulence and Day/Night cycle added by Michael Olson - OMGparticles/2015
|
||||||
// rain effect adapted from Rainy London by David Hoskins. - https://www.shadertoy.com/view/XdSGDc
|
// rain effect adapted from Rainy London by David Hoskins. - https://www.shadertoy.com/view/XdSGDc
|
||||||
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||||
#line 5
|
#line 6
|
||||||
const float PI = 3.14159;
|
const float PI = 3.14159;
|
||||||
uniform float rotationSpeed = 0.005;
|
uniform float rotationSpeed = 0.005;
|
||||||
uniform float gridLevel = 0.0;
|
uniform float gridLevel = 0.0;
|
||||||
|
@ -96,11 +96,10 @@ vec4 render( in vec3 ro, in vec3 rd )
|
||||||
|
|
||||||
// stars
|
// stars
|
||||||
float fStarContrib = clamp((fSunHeight - fDayHeight) * (-fInverseHL), 0.0, 1.0);
|
float fStarContrib = clamp((fSunHeight - fDayHeight) * (-fInverseHL), 0.0, 1.0);
|
||||||
|
if (fStarContrib > 0.0) {
|
||||||
vec3 vStarDir = rd;
|
vec3 vStarDir = rd;
|
||||||
|
|
||||||
col = mix(col, stars3(vStarDir), fStarContrib);
|
col = mix(col, stars3(vStarDir), fStarContrib);
|
||||||
col += stars3(vStarDir) * fStarContrib;
|
}
|
||||||
|
|
||||||
// Ten layers of rain sheets...
|
// Ten layers of rain sheets...
|
||||||
float rainBrightness = 0.15;
|
float rainBrightness = 0.15;
|
||||||
|
@ -118,7 +117,7 @@ vec4 render( in vec3 ro, in vec3 rd )
|
||||||
dis += 3.5;
|
dis += 3.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vec4( col, 1.0 );
|
return vec4(clamp(col,0.0,1.0), 1.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 getSkyboxColor() {
|
vec3 getSkyboxColor() {
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
{
|
{
|
||||||
"backgroundMode": "skybox",
|
"backgroundMode": "skybox",
|
||||||
"dimensions": {
|
"dimensions": {
|
||||||
"x": 30000,
|
"x": 10000,
|
||||||
"y": 30000,
|
"y": 10000,
|
||||||
"z": 30000
|
"z": 10000
|
||||||
},
|
},
|
||||||
"name": "Rainy Day/Night Cycle",
|
"name": "Rainy Day/Night Cycle",
|
||||||
"rotation": {
|
"rotation": {
|
||||||
|
@ -14,13 +14,13 @@
|
||||||
"y": 0,
|
"y": 0,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"script": "https://s3.amazonaws.com/hifi-public/brad/rainstorm/lighteningEntity.js",
|
"script": "https://s3.amazonaws.com/hifi-public/brad/rainstorm/lightningEntity.js",
|
||||||
"shapeType": "box",
|
"shapeType": "box",
|
||||||
"skybox": {
|
"skybox": {
|
||||||
"url": "https://hifi-public.s3.amazonaws.com/images/SkyboxTextures/CloudyDay1.jpg"
|
"url": "https://hifi-public.s3.amazonaws.com/images/SkyboxTextures/CloudyDay1.jpg"
|
||||||
},
|
},
|
||||||
"type": "Zone",
|
"type": "Zone",
|
||||||
"userData":"{\n\"ProceduralEntity\":{\n\"version\":2,\n\"shaderUrl\":\"https://s3.amazonaws.com/hifi-public/brad/rainstorm/rainyDayNightSkybox.fs\",\n\"channels\":[\n\"https://hifi-public.s3.amazonaws.com/austin/assets/images/skybox/starmap_8k.jpg\",\n\"https://hifi-public.s3.amazonaws.com/austin/assets/images/skybox/celestial_grid.jpg\",\n\"https://s3.amazonaws.com/hifi-public/brad/rainstorm/noise.jpg\",\n\"https://s3.amazonaws.com/hifi-public/brad/noise.jpg\"\n],\n\"uniforms\":{\n\"rotationSpeed\":0.001,\n\"uDayColor\":[0.4,0.3,0.3],\n\"constellationLevel\":0.0,\n\"constellationBoundaryLevel\":0.00,\n\"gridLevel\":0.0\n}\n},\n\"lightening\":{\n\"flashMax\":20,\n\"flashMin\":0,\n\"flashIntensityStepRandomeness\":2,\n\"flashMaxRandomness\":10,\n\"averageLighteningStrikeGap\":120,\n\"extraRandomRangeLighteningStrikeGap\":5,\n\"thunderURL\":\"https://s3.amazonaws.com/hifi-public/brad/rainstorm/thunder-48k.wav\",\n\"thunderVolume\":0.1,\n\"rainURL\":\"https://s3.amazonaws.com/hifi-public/brad/rainstorm/rain.wav\",\n\"rainVolume\":0.05\n}\n}"
|
"userData":"{\n\"ProceduralEntity\":{\n\"version\":2,\n\"shaderUrl\":\"https://s3.amazonaws.com/hifi-public/brad/rainstorm/rainyDayNightSkybox.fs\",\n\"channels\":[\n\"https://hifi-public.s3.amazonaws.com/austin/assets/images/skybox/starmap_8k.jpg\",\n\"https://hifi-public.s3.amazonaws.com/austin/assets/images/skybox/celestial_grid.jpg\",\n\"https://s3.amazonaws.com/hifi-public/brad/rainstorm/noise.jpg\",\n\"https://s3.amazonaws.com/hifi-public/brad/noise.jpg\"\n],\n\"uniforms\":{\n\"rotationSpeed\":0.001,\n\"uDayColor\":[0.4,0.3,0.3],\n\"constellationLevel\":0.0,\n\"constellationBoundaryLevel\":0.00,\n\"gridLevel\":0.0\n}\n},\n\"lightning\":{\n\"flashMax\":20,\n\"flashMin\":0,\n\"flashIntensityStepRandomeness\":2,\n\"flashMaxRandomness\":10,\n\"averageLightningStrikeGap\":120,\n\"extraRandomRangeLightningStrikeGap\":5,\n\"thunderURL\":\"https://s3.amazonaws.com/hifi-public/brad/rainstorm/thunder-48k.wav\",\n\"thunderVolume\":0.1,\n\"rainURL\":\"https://s3.amazonaws.com/hifi-public/brad/rainstorm/rain.wav\",\n\"rainVolume\":0.05\n}\n}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Version": 57
|
"Version": 57
|
||||||
|
|
Loading…
Reference in a new issue