mirror of
https://github.com/overte-org/overte.git
synced 2025-07-04 11:29:10 +02:00
fixed potential bug
This commit is contained in:
parent
a95176be8f
commit
03f90c2070
3 changed files with 14 additions and 3 deletions
|
@ -41,7 +41,7 @@ var DEFAULT_SOUND_DATA = {
|
|||
var MIN_INTERVAL = 0.2;
|
||||
|
||||
function messageReceived(channel, message, sender) {
|
||||
|
||||
print("EBL MESSAGE RECIEVED");
|
||||
var entityID = JSON.parse(message).id;
|
||||
if (soundEntityMap[entityID]) {
|
||||
// We already have this entity in our sound map, so don't re-add
|
||||
|
@ -49,7 +49,15 @@ function messageReceived(channel, message, sender) {
|
|||
}
|
||||
|
||||
EntityViewer.queryOctree();
|
||||
Script.setTimeout(function() {
|
||||
handleIncomingEntity(entityID);
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
function handleIncomingEntity(entityID) {
|
||||
var soundData = getEntityCustomData(SOUND_DATA_KEY, entityID);
|
||||
print("SOUND DATA " + JSON.stringify(soundData));
|
||||
if (soundData && soundData.url) {
|
||||
var soundProperties = {
|
||||
url: soundData.url,
|
||||
|
@ -80,6 +88,7 @@ function messageReceived(channel, message, sender) {
|
|||
soundEntityMap[entityID] = soundProperties;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update(deltaTime) {
|
||||
|
@ -93,6 +102,7 @@ function update(deltaTime) {
|
|||
var soundProperties = soundEntityMap[entity];
|
||||
if (soundProperties.readyToPlay) {
|
||||
var newPosition = Entities.getEntityProperties(entity, "position").position
|
||||
print("EBL SHOULD BE PLAYING SOUND!")
|
||||
Audio.playSound(soundProperties.sound, {
|
||||
volume: soundProperties.volume,
|
||||
position: newPosition,
|
||||
|
|
|
@ -17,7 +17,7 @@ Script.include("../../libraries/utils.js");
|
|||
|
||||
var SOUND_DATA_KEY = "soundKey";
|
||||
var MESSAGE_CHANNEL = "Hifi-Sound-Entity";
|
||||
var SCRIPT_URL = Script.resolvePath("soundEntityScript.js");
|
||||
var SCRIPT_URL = Script.resolvePath("soundEntityScript.js?v1" + Math.random());
|
||||
var userData = {
|
||||
soundKey: {
|
||||
url: "https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/dove.wav",
|
||||
|
|
|
@ -24,10 +24,11 @@
|
|||
Script.setTimeout(function() {
|
||||
var soundData = getEntityCustomData("soundKey", _this.entityID);
|
||||
// Just a hack for now until bug https://app.asana.com/0/26225263936266/86767805352289 is fixed
|
||||
print("EBL SEND MESSAGE");
|
||||
Messages.sendMessage(_this.MESSAGE_CHANNEL, JSON.stringify({
|
||||
id: _this.entityID
|
||||
}));
|
||||
}, 1000);
|
||||
}, 2000);
|
||||
},
|
||||
};
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
|
|
Loading…
Reference in a new issue