mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 21:36:52 +02:00
Not adding deleted avatars to the list of avatars to use for querying
This commit is contained in:
parent
aa49db9992
commit
355f60f088
2 changed files with 37 additions and 11 deletions
|
@ -20,7 +20,7 @@ var DEFAULT_SOUND_DATA = {
|
||||||
var MIN_PLAY_INTERVAL = 0.2;
|
var MIN_PLAY_INTERVAL = 0.2;
|
||||||
|
|
||||||
var UPDATE_TIME = 2000;
|
var UPDATE_TIME = 2000;
|
||||||
var EXPIRATION_TIME = 5000;
|
var EXPIRATION_TIME = 7000;
|
||||||
|
|
||||||
var soundEntityMap = {};
|
var soundEntityMap = {};
|
||||||
var soundUrls = {};
|
var soundUrls = {};
|
||||||
|
@ -29,9 +29,15 @@ print("EBL STARTING SCRIPT");
|
||||||
|
|
||||||
function slowUpdate() {
|
function slowUpdate() {
|
||||||
var avatars = AvatarList.getAvatarIdentifiers();
|
var avatars = AvatarList.getAvatarIdentifiers();
|
||||||
|
print("CURRENT AVATAR LIST: " + JSON.stringify(avatars));
|
||||||
for (var i = 0; i < avatars.length; i++) {
|
for (var i = 0; i < avatars.length; i++) {
|
||||||
var avatar = AvatarList.getAvatar(avatars[i]);
|
var avatar = AvatarList.getAvatar(avatars[i]);
|
||||||
EntityViewer.setPosition(avatar.position);
|
var avatarPosition = avatar.position;
|
||||||
|
if (!avatarPosition) {
|
||||||
|
print("EBL This avatars been DELETED *******! Don't add it to list");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
EntityViewer.setPosition(avatarPosition);
|
||||||
EntityViewer.queryOctree();
|
EntityViewer.queryOctree();
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
var entities = Entities.findEntities(avatar.position, QUERY_RADIUS);
|
var entities = Entities.findEntities(avatar.position, QUERY_RADIUS);
|
||||||
|
@ -56,7 +62,7 @@ function handleActiveSoundEntities() {
|
||||||
print("NO AVATARS HAVE BEEN AROUND FOR A WHILE SO REMOVE THIS SOUND FROM SOUNDMAP!");
|
print("NO AVATARS HAVE BEEN AROUND FOR A WHILE SO REMOVE THIS SOUND FROM SOUNDMAP!");
|
||||||
// If the sound was looping, make sure to stop playing it
|
// If the sound was looping, make sure to stop playing it
|
||||||
if (soundProperties.loop) {
|
if (soundProperties.loop) {
|
||||||
print ("STOP SOUND INJECTOR!!");
|
print("STOP SOUND INJECTOR!!");
|
||||||
soundProperties.soundInjector.stop();
|
soundProperties.soundInjector.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +74,7 @@ function handleActiveSoundEntities() {
|
||||||
if (soundProperties.readyToPlay) {
|
if (soundProperties.readyToPlay) {
|
||||||
var newPosition = Entities.getEntityProperties(soundEntity, "position").position;
|
var newPosition = Entities.getEntityProperties(soundEntity, "position").position;
|
||||||
if (!soundProperties.soundInjector) {
|
if (!soundProperties.soundInjector) {
|
||||||
print("SOUND VOLUME " + soundProperties.volume)
|
print("PLAY SOUND! SOUND VOLUME " + soundProperties.volume)
|
||||||
soundProperties.soundInjector = Audio.playSound(soundProperties.sound, {
|
soundProperties.soundInjector = Audio.playSound(soundProperties.sound, {
|
||||||
volume: soundProperties.volume,
|
volume: soundProperties.volume,
|
||||||
position: newPosition,
|
position: newPosition,
|
||||||
|
@ -78,7 +84,7 @@ function handleActiveSoundEntities() {
|
||||||
soundProperties.soundInjector.restart();
|
soundProperties.soundInjector.restart();
|
||||||
}
|
}
|
||||||
soundProperties.readyToPlay = false;
|
soundProperties.readyToPlay = false;
|
||||||
} else if (soundProperties.loop === false && soundProperties.interval !== -1) {
|
} else if (soundProperties.sound && soundProperties.loop === false && soundProperties.interval !== -1) {
|
||||||
// We need to check all of our entities that are not looping but have an interval associated with them
|
// We need to check all of our entities that are not looping but have an interval associated with them
|
||||||
// to see if it's time for them to play again
|
// to see if it's time for them to play again
|
||||||
soundProperties.timeSinceLastPlay += UPDATE_TIME;
|
soundProperties.timeSinceLastPlay += UPDATE_TIME;
|
||||||
|
@ -108,7 +114,7 @@ function handleFoundSoundEntities(entities) {
|
||||||
loop: soundData.loop || DEFAULT_SOUND_DATA.loop,
|
loop: soundData.loop || DEFAULT_SOUND_DATA.loop,
|
||||||
interval: soundData.interval || DEFAULT_SOUND_DATA.interval,
|
interval: soundData.interval || DEFAULT_SOUND_DATA.interval,
|
||||||
intervalSpread: soundData.intervalSpread || DEFAULT_SOUND_DATA.intervalSpread,
|
intervalSpread: soundData.intervalSpread || DEFAULT_SOUND_DATA.intervalSpread,
|
||||||
readyToPlay: true,
|
readyToPlay: false,
|
||||||
position: Entities.getEntityProperties(entity, "position").position,
|
position: Entities.getEntityProperties(entity, "position").position,
|
||||||
timeSinceLastPlay: 0,
|
timeSinceLastPlay: 0,
|
||||||
timeWithoutAvatarInRange: 0
|
timeWithoutAvatarInRange: 0
|
||||||
|
@ -119,18 +125,22 @@ function handleFoundSoundEntities(entities) {
|
||||||
soundProperties.currentInterval = Math.max(MIN_PLAY_INTERVAL, soundProperties.currentInterval);
|
soundProperties.currentInterval = Math.max(MIN_PLAY_INTERVAL, soundProperties.currentInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
soundEntityMap[entity] = soundProperties;
|
||||||
if (!soundUrls[soundData.url]) {
|
if (!soundUrls[soundData.url]) {
|
||||||
// We need to download sound before we add it to our map
|
// We need to download sound before we add it to our map
|
||||||
var sound = SoundCache.getSound(soundData.url);
|
var sound = SoundCache.getSound(soundData.url);
|
||||||
soundUrls[soundData.url] = sound;
|
|
||||||
// Only add it to map once it's downloaded
|
// Only add it to map once it's downloaded
|
||||||
|
soundUrls[soundData.url] = sound;
|
||||||
sound.ready.connect(function() {
|
sound.ready.connect(function() {
|
||||||
|
print("ADD TO MAP!")
|
||||||
soundProperties.sound = sound;
|
soundProperties.sound = sound;
|
||||||
|
soundProperties.readyToPlay = true;
|
||||||
soundEntityMap[entity] = soundProperties;
|
soundEntityMap[entity] = soundProperties;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// We already have sound downloaded, so just add it to map right away
|
// We already have sound downloaded, so just add it to map right away
|
||||||
soundProperties.sound = soundUrls[soundData.url];
|
soundProperties.sound = soundUrls[soundData.url];
|
||||||
|
soundProperties.readyToPlay = true;
|
||||||
soundEntityMap[entity] = soundProperties;
|
soundEntityMap[entity] = soundProperties;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,15 +155,31 @@ function handleFoundSoundEntities(entities) {
|
||||||
|
|
||||||
function checkForSoundPropertyChanges(currentProps, newProps) {
|
function checkForSoundPropertyChanges(currentProps, newProps) {
|
||||||
var needsUpdate = false;
|
var needsUpdate = false;
|
||||||
if(currentProps.volume !== newProps.volume) {
|
if (currentProps.volume !== newProps.volume) {
|
||||||
print("VOLUME CHANGED!!");
|
print("VOLUME CHANGED!!");
|
||||||
currentProps.volume = newProps.volume;
|
currentProps.volume = newProps.volume;
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
}
|
}
|
||||||
|
if (currentProps.url !== newProps.url) {
|
||||||
|
currentProps.url = newProps.url;
|
||||||
|
if (!soundUrls[currentProps.url]) {
|
||||||
|
var sound = SoundCache.getSound(currentProps.url);
|
||||||
|
currentProps.sound = null;
|
||||||
|
currentProps.readyToPlay = false;
|
||||||
|
sound.ready.connect(function() {
|
||||||
|
print("Ready to play new sound!")
|
||||||
|
currentProps.soundInjector.restart();
|
||||||
|
currentProps.soundInjector.stop();
|
||||||
|
currentProps.sound = sound;
|
||||||
|
currentProps.soundInjector = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
if (needsUpdate && currentProps.loop) {
|
if (needsUpdate && currentProps.loop) {
|
||||||
print ("LOOP CHANGED!");
|
print("LOOP CHANGED!");
|
||||||
currentProps.loop = newProps.loop;
|
currentProps.loop = newProps.loop;
|
||||||
// If we were looping we need to stop that so new changes are applied
|
// If we were looping we need to stop that so new changes are applied
|
||||||
|
currentProps.soundInjector.restart();
|
||||||
currentProps.soundInjector.stop();
|
currentProps.soundInjector.stop();
|
||||||
currentProps.soundInjector = null;
|
currentProps.soundInjector = null;
|
||||||
currentProps.readyToPlay = true;
|
currentProps.readyToPlay = true;
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
// http://hifi-public.s3.amazonaws.com/ryan/demo/0619_Fireplace__Tree_B.L.wav
|
||||||
var SOUND_DATA_KEY = "soundKey";
|
var SOUND_DATA_KEY = "soundKey";
|
||||||
var userData = {
|
var userData = {
|
||||||
soundKey: {
|
soundKey: {
|
||||||
url: "https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/dove.wav",
|
url: "https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/dove2.wav",
|
||||||
volume: 0.3,
|
volume: 0.3,
|
||||||
loop: true,
|
loop: true,
|
||||||
interval: 2000,
|
interval: 2000,
|
||||||
|
|
Loading…
Reference in a new issue