mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:10:15 +02:00
possible bug fix for sound not playing on avatar rentry
This commit is contained in:
parent
208007c9d8
commit
a5c037b23f
1 changed files with 14 additions and 4 deletions
|
@ -25,6 +25,8 @@ var EXPIRATION_TIME = 7000;
|
||||||
var soundEntityMap = {};
|
var soundEntityMap = {};
|
||||||
var soundUrls = {};
|
var soundUrls = {};
|
||||||
|
|
||||||
|
var avatarPositions = [];
|
||||||
|
|
||||||
print("EBL STARTING SCRIPT");
|
print("EBL STARTING SCRIPT");
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
|
@ -38,11 +40,16 @@ function update() {
|
||||||
}
|
}
|
||||||
EntityViewer.setPosition(avatarPosition);
|
EntityViewer.setPosition(avatarPosition);
|
||||||
EntityViewer.queryOctree();
|
EntityViewer.queryOctree();
|
||||||
Script.setTimeout(function() {
|
avatarPositions.push(avatarPosition);
|
||||||
var entities = Entities.findEntities(avatar.position, QUERY_RADIUS);
|
|
||||||
handleFoundSoundEntities(entities);
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
avatarPositions.forEach(function(avatarPosition) {
|
||||||
|
var entities = Entities.findEntities(avatarPosition, QUERY_RADIUS);
|
||||||
|
handleFoundSoundEntities(entities);
|
||||||
|
});
|
||||||
|
//Now wipe list for next query;
|
||||||
|
avatarPositions = [];
|
||||||
|
}, 1000);
|
||||||
handleActiveSoundEntities();
|
handleActiveSoundEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +73,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("PLAY first injector!!!")
|
||||||
soundProperties.soundInjector = Audio.playSound(soundProperties.sound, {
|
soundProperties.soundInjector = Audio.playSound(soundProperties.sound, {
|
||||||
volume: soundProperties.volume,
|
volume: soundProperties.volume,
|
||||||
position: newPosition,
|
position: newPosition,
|
||||||
|
@ -100,6 +108,7 @@ function handleFoundSoundEntities(entities) {
|
||||||
if (soundData && soundData.url) {
|
if (soundData && soundData.url) {
|
||||||
//check sound entities list- if it's not in, add it
|
//check sound entities list- if it's not in, add it
|
||||||
if (!soundEntityMap[entity]) {
|
if (!soundEntityMap[entity]) {
|
||||||
|
print("NEW SOUND!")
|
||||||
var soundProperties = {
|
var soundProperties = {
|
||||||
url: soundData.url,
|
url: soundData.url,
|
||||||
volume: soundData.volume || DEFAULT_SOUND_DATA.volume,
|
volume: soundData.volume || DEFAULT_SOUND_DATA.volume,
|
||||||
|
@ -134,6 +143,7 @@ function handleFoundSoundEntities(entities) {
|
||||||
// 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;
|
soundProperties.readyToPlay = true;
|
||||||
|
soundProperties.isDownloaded = true;
|
||||||
soundEntityMap[entity] = soundProperties;
|
soundEntityMap[entity] = soundProperties;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue