mirror of
https://github.com/overte-org/overte.git
synced 2025-07-04 16:09:23 +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;
|
var MIN_INTERVAL = 0.2;
|
||||||
|
|
||||||
function messageReceived(channel, message, sender) {
|
function messageReceived(channel, message, sender) {
|
||||||
|
print("EBL MESSAGE RECIEVED");
|
||||||
var entityID = JSON.parse(message).id;
|
var entityID = JSON.parse(message).id;
|
||||||
if (soundEntityMap[entityID]) {
|
if (soundEntityMap[entityID]) {
|
||||||
// We already have this entity in our sound map, so don't re-add
|
// 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();
|
EntityViewer.queryOctree();
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
handleIncomingEntity(entityID);
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleIncomingEntity(entityID) {
|
||||||
var soundData = getEntityCustomData(SOUND_DATA_KEY, entityID);
|
var soundData = getEntityCustomData(SOUND_DATA_KEY, entityID);
|
||||||
|
print("SOUND DATA " + JSON.stringify(soundData));
|
||||||
if (soundData && soundData.url) {
|
if (soundData && soundData.url) {
|
||||||
var soundProperties = {
|
var soundProperties = {
|
||||||
url: soundData.url,
|
url: soundData.url,
|
||||||
|
@ -80,6 +88,7 @@ function messageReceived(channel, message, sender) {
|
||||||
soundEntityMap[entityID] = soundProperties;
|
soundEntityMap[entityID] = soundProperties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(deltaTime) {
|
function update(deltaTime) {
|
||||||
|
@ -93,6 +102,7 @@ function update(deltaTime) {
|
||||||
var soundProperties = soundEntityMap[entity];
|
var soundProperties = soundEntityMap[entity];
|
||||||
if (soundProperties.readyToPlay) {
|
if (soundProperties.readyToPlay) {
|
||||||
var newPosition = Entities.getEntityProperties(entity, "position").position
|
var newPosition = Entities.getEntityProperties(entity, "position").position
|
||||||
|
print("EBL SHOULD BE PLAYING SOUND!")
|
||||||
Audio.playSound(soundProperties.sound, {
|
Audio.playSound(soundProperties.sound, {
|
||||||
volume: soundProperties.volume,
|
volume: soundProperties.volume,
|
||||||
position: newPosition,
|
position: newPosition,
|
||||||
|
|
|
@ -17,7 +17,7 @@ Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var SOUND_DATA_KEY = "soundKey";
|
var SOUND_DATA_KEY = "soundKey";
|
||||||
var MESSAGE_CHANNEL = "Hifi-Sound-Entity";
|
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 = {
|
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/dove.wav",
|
||||||
|
|
|
@ -24,10 +24,11 @@
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
var soundData = getEntityCustomData("soundKey", _this.entityID);
|
var soundData = getEntityCustomData("soundKey", _this.entityID);
|
||||||
// Just a hack for now until bug https://app.asana.com/0/26225263936266/86767805352289 is fixed
|
// 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({
|
Messages.sendMessage(_this.MESSAGE_CHANNEL, JSON.stringify({
|
||||||
id: _this.entityID
|
id: _this.entityID
|
||||||
}));
|
}));
|
||||||
}, 1000);
|
}, 2000);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// entity scripts always need to return a newly constructed object of our type
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
|
|
Loading…
Reference in a new issue