mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 18:56:55 +02:00
cleanup pass
This commit is contained in:
parent
c9fd650e70
commit
827aa68d3f
1 changed files with 9 additions and 14 deletions
|
@ -45,25 +45,25 @@
|
||||||
var entity;
|
var entity;
|
||||||
var ambientSound;
|
var ambientSound;
|
||||||
var center;
|
var center;
|
||||||
var soundPlaying;
|
var soundPlaying = false;
|
||||||
var checkTimer = false;
|
var checkTimer = false;
|
||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
var COLOR_OFF = { red: 128, green: 128, blue: 128 };
|
var COLOR_OFF = { red: 128, green: 128, blue: 128 };
|
||||||
var COLOR_ON = { red: 255, green: 0, blue: 0 };
|
var COLOR_ON = { red: 255, green: 0, blue: 0 };
|
||||||
|
|
||||||
var WANT_DEBUG = true;
|
var WANT_DEBUG = false;
|
||||||
function debugPrint(string) {
|
function debugPrint(string) {
|
||||||
if (WANT_DEBUG) {
|
if (WANT_DEBUG) {
|
||||||
print("ambientSound | " + string);
|
print("ambientSound | " + string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var WANT_DEBUG_BROADCASTS = "ambientSound.js";
|
|
||||||
var WANT_DEBUG_OVERLAY = false;
|
var WANT_DEBUG_OVERLAY = false;
|
||||||
var LINEHEIGHT = 0.1;
|
var LINEHEIGHT = 0.1;
|
||||||
// Optionally enable debug overlays using a Settings value
|
// Optionally enable debug overlays using a Settings value
|
||||||
WANT_DEBUG_OVERLAY = WANT_DEBUG_OVERLAY || /ambientSound/.test(Settings.getValue("WANT_DEBUG_OVERLAY"));
|
WANT_DEBUG_OVERLAY = WANT_DEBUG_OVERLAY || /ambientSound/.test(Settings.getValue("WANT_DEBUG_OVERLAY"));
|
||||||
|
var WANT_DEBUG_BROADCASTS = WANT_DEBUG_OVERLAY && "ambientSound.js";
|
||||||
|
|
||||||
this.updateSettings = function() {
|
this.updateSettings = function() {
|
||||||
// Check user data on the entity for any changes
|
// Check user data on the entity for any changes
|
||||||
|
@ -95,10 +95,6 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*if ("loop" in data && !(soundOptions.loop === data.loop)) {
|
|
||||||
soundOptions.loop = data.loop;
|
|
||||||
debugPrint("Read ambient loop state: " + soundOptions.loop);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
if (!(soundURL === oldSoundURL) || (soundURL === "")) {
|
if (!(soundURL === oldSoundURL) || (soundURL === "")) {
|
||||||
if (soundURL) {
|
if (soundURL) {
|
||||||
|
@ -135,7 +131,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clickDownOnEntity = function(entityID, mouseEvent) {
|
this.clickDownOnEntity = function(entityID, mouseEvent) {
|
||||||
print("click");
|
|
||||||
if (mouseEvent.isPrimaryButton) {
|
if (mouseEvent.isPrimaryButton) {
|
||||||
this._toggle("primary click");
|
this._toggle("primary click");
|
||||||
}
|
}
|
||||||
|
@ -158,7 +153,7 @@
|
||||||
var oldState = _debugState;
|
var oldState = _debugState;
|
||||||
|
|
||||||
if (WANT_DEBUG_BROADCASTS) {
|
if (WANT_DEBUG_BROADCASTS) {
|
||||||
Messages.sendMessage(WANT_DEBUG_BROADCASTS /*entity*/, JSON.stringify({ palName: MyAvatar.sessionDisplayName, soundName: soundName, hint: hint, scriptTimestamp: props.scriptTimestamp, oldState: oldState, newState: _debugState, age: props.age }));
|
Messages.sendMessage(WANT_DEBUG_BROADCASTS, JSON.stringify({ palName: MyAvatar.sessionDisplayName, soundName: soundName, hint: hint, scriptTimestamp: props.scriptTimestamp, oldState: oldState, newState: _debugState, age: props.age }));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cleanup();
|
this.cleanup();
|
||||||
|
@ -218,7 +213,7 @@
|
||||||
// and might indicate a bug where an Entity can become unreachable without `unload` having been called..
|
// and might indicate a bug where an Entity can become unreachable without `unload` having been called..
|
||||||
print("FIXME: ambientSound.js -- expected Entity unavailable!")
|
print("FIXME: ambientSound.js -- expected Entity unavailable!")
|
||||||
if (WANT_DEBUG_BROADCASTS) {
|
if (WANT_DEBUG_BROADCASTS) {
|
||||||
Messages.sendMessage(WANT_DEBUG_BROADCASTS /*entity*/, JSON.stringify({ palName: MyAvatar.sessionDisplayName, soundName: soundName, hint: "FIXME: maybeUpdate", oldState: _debugState }));
|
Messages.sendMessage(WANT_DEBUG_BROADCASTS, JSON.stringify({ palName: MyAvatar.sessionDisplayName, soundName: soundName, hint: "FIXME: maybeUpdate", oldState: _debugState }));
|
||||||
}
|
}
|
||||||
return _this.cleanup();
|
return _this.cleanup();
|
||||||
}
|
}
|
||||||
|
@ -227,7 +222,7 @@
|
||||||
var distance = Vec3.length(Vec3.subtract(MyAvatar.position, center));
|
var distance = Vec3.length(Vec3.subtract(MyAvatar.position, center));
|
||||||
if (distance <= range) {
|
if (distance <= range) {
|
||||||
var volume = (1.0 - distance / range) * maxVolume;
|
var volume = (1.0 - distance / range) * maxVolume;
|
||||||
soundOptions.orientation = Quat.rotation;
|
soundOptions.orientation = rotation;
|
||||||
soundOptions.volume = volume;
|
soundOptions.volume = volume;
|
||||||
if (!soundPlaying && ambientSound && ambientSound.downloaded) {
|
if (!soundPlaying && ambientSound && ambientSound.downloaded) {
|
||||||
debugState("playing", "Starting ambient sound: " + soundName + " (duration: " + ambientSound.duration + ")");
|
debugState("playing", "Starting ambient sound: " + soundName + " (duration: " + ambientSound.duration + ")");
|
||||||
|
@ -249,7 +244,7 @@
|
||||||
debugPrint("Ambient sound unload ");
|
debugPrint("Ambient sound unload ");
|
||||||
if (WANT_DEBUG_BROADCASTS) {
|
if (WANT_DEBUG_BROADCASTS) {
|
||||||
var offset = ambientSound && (new Date - startTime)/1000 % ambientSound.duration;
|
var offset = ambientSound && (new Date - startTime)/1000 % ambientSound.duration;
|
||||||
Messages.sendMessage(WANT_DEBUG_BROADCASTS /*entity*/, JSON.stringify({ palName: MyAvatar.sessionDisplayName, soundName: soundName, hint: "unload", oldState: _debugState, offset: offset }));
|
Messages.sendMessage(WANT_DEBUG_BROADCASTS, JSON.stringify({ palName: MyAvatar.sessionDisplayName, soundName: soundName, hint: "unload", oldState: _debugState, offset: offset }));
|
||||||
}
|
}
|
||||||
if (WANT_DEBUG_OVERLAY) {
|
if (WANT_DEBUG_OVERLAY) {
|
||||||
_removeDebugOverlays();
|
_removeDebugOverlays();
|
||||||
|
@ -290,8 +285,8 @@
|
||||||
}
|
}
|
||||||
updateDebugOverlay();
|
updateDebugOverlay();
|
||||||
if (WANT_DEBUG_BROADCASTS) {
|
if (WANT_DEBUG_BROADCASTS) {
|
||||||
// Broadcast state changes to an implicit entity channel, making multi-user scenarios easier to verify from a single console
|
// Broadcast state changes to make multi-user scenarios easier to verify from a single console
|
||||||
Messages.sendMessage(WANT_DEBUG_BROADCASTS /*entity*/, JSON.stringify({ palName: MyAvatar.sessionDisplayName, soundName: soundName, state: state }));
|
Messages.sendMessage(WANT_DEBUG_BROADCASTS, JSON.stringify({ palName: MyAvatar.sessionDisplayName, soundName: soundName, state: state }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue