From 03bfaa4869821481ac29c364d305d287bef9447a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 19 Nov 2014 12:20:12 -0800 Subject: [PATCH 1/5] handle RAW stereo audio files by using stereo.raw extension --- examples/acScripts/ambiance.js | 5 ++--- examples/radio.js | 5 ++--- libraries/audio/src/AudioInjector.cpp | 2 ++ libraries/audio/src/AudioInjectorLocalBuffer.h | 1 + libraries/audio/src/AudioInjectorOptions.cpp | 13 +++++++------ libraries/audio/src/AudioInjectorOptions.h | 1 + libraries/audio/src/AudioScriptingInterface.cpp | 6 +++++- libraries/audio/src/Sound.cpp | 17 +++++++++++++---- libraries/audio/src/Sound.h | 2 +- 9 files changed, 34 insertions(+), 18 deletions(-) diff --git a/examples/acScripts/ambiance.js b/examples/acScripts/ambiance.js index 0149d5d3ff..fcc3ba0d80 100644 --- a/examples/acScripts/ambiance.js +++ b/examples/acScripts/ambiance.js @@ -14,11 +14,10 @@ var position = { x: 700, y: 25, z: 725 }; var audioOptions = { position: position, volume: 0.4, - loop: true, - stereo: false + loop: true }; -var sound = SoundCache.getSound(soundURL, audioOptions.isStereo); +var sound = SoundCache.getSound(soundURL); var injector = null; var count = 100; diff --git a/examples/radio.js b/examples/radio.js index 0b62d78b0e..e8300c00b5 100644 --- a/examples/radio.js +++ b/examples/radio.js @@ -12,13 +12,12 @@ Script.include("libraries/globals.js"); var modelURL = HIFI_PUBLIC_BUCKET + "models/entities/radio/Speakers.fbx"; -var soundURL = HIFI_PUBLIC_BUCKET + "sounds/FamilyStereo.raw"; +var soundURL = HIFI_PUBLIC_BUCKET + "sounds/family.stereo.raw"; var AudioRotationOffset = Quat.fromPitchYawRollDegrees(0, -90, 0); var audioOptions = { volume: 0.5, - loop: true, - stereo: true + loop: true } var injector = null; diff --git a/libraries/audio/src/AudioInjector.cpp b/libraries/audio/src/AudioInjector.cpp index 1c9c93c00e..979bf70533 100644 --- a/libraries/audio/src/AudioInjector.cpp +++ b/libraries/audio/src/AudioInjector.cpp @@ -89,10 +89,12 @@ void AudioInjector::injectLocally() { bool success = false; if (_localAudioInterface) { if (_audioData.size() > 0) { + _localBuffer = new AudioInjectorLocalBuffer(_audioData, this); _localBuffer->open(QIODevice::ReadOnly); _localBuffer->setShouldLoop(_options.loop); + QMetaObject::invokeMethod(_localAudioInterface, "outputLocalInjector", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, success), diff --git a/libraries/audio/src/AudioInjectorLocalBuffer.h b/libraries/audio/src/AudioInjectorLocalBuffer.h index 8b32c6fbc7..92409617f6 100644 --- a/libraries/audio/src/AudioInjectorLocalBuffer.h +++ b/libraries/audio/src/AudioInjectorLocalBuffer.h @@ -26,6 +26,7 @@ public: void setShouldLoop(bool shouldLoop) { _shouldLoop = shouldLoop; } + void setCurrentOffset(int currentOffset) { _currentOffset = currentOffset; } private: qint64 recursiveReadFromFront(char* data, qint64 maxSize); diff --git a/libraries/audio/src/AudioInjectorOptions.cpp b/libraries/audio/src/AudioInjectorOptions.cpp index df435cf2cc..824a816382 100644 --- a/libraries/audio/src/AudioInjectorOptions.cpp +++ b/libraries/audio/src/AudioInjectorOptions.cpp @@ -20,7 +20,8 @@ AudioInjectorOptions::AudioInjectorOptions() : orientation(glm::vec3(0.0f, 0.0f, 0.0f)), stereo(false), ignorePenumbra(false), - localOnly(false) + localOnly(false), + secondOffset(0.0) { } @@ -31,9 +32,9 @@ QScriptValue injectorOptionsToScriptValue(QScriptEngine* engine, const AudioInje obj.setProperty("volume", injectorOptions.volume); obj.setProperty("loop", injectorOptions.loop); obj.setProperty("orientation", quatToScriptValue(engine, injectorOptions.orientation)); - obj.setProperty("stereo", injectorOptions.stereo); obj.setProperty("ignorePenumbra", injectorOptions.ignorePenumbra); obj.setProperty("localOnly", injectorOptions.localOnly); + obj.setProperty("secondOffset", injectorOptions.secondOffset); return obj; } @@ -54,10 +55,6 @@ void injectorOptionsFromScriptValue(const QScriptValue& object, AudioInjectorOpt quatFromScriptValue(object.property("orientation"), injectorOptions.orientation); } - if (object.property("stereo").isValid()) { - injectorOptions.stereo = object.property("stereo").toBool(); - } - if (object.property("ignorePenumbra").isValid()) { injectorOptions.ignorePenumbra = object.property("ignorePenumbra").toBool(); } @@ -65,4 +62,8 @@ void injectorOptionsFromScriptValue(const QScriptValue& object, AudioInjectorOpt if (object.property("localOnly").isValid()) { injectorOptions.localOnly = object.property("localOnly").toBool(); } + + if (object.property("secondOffset").isValid()) { + injectorOptions.secondOffset = object.property("secondOffset").toNumber(); + } } \ No newline at end of file diff --git a/libraries/audio/src/AudioInjectorOptions.h b/libraries/audio/src/AudioInjectorOptions.h index 4fd3a0b7ae..d06dc9eb63 100644 --- a/libraries/audio/src/AudioInjectorOptions.h +++ b/libraries/audio/src/AudioInjectorOptions.h @@ -27,6 +27,7 @@ public: bool stereo; bool ignorePenumbra; bool localOnly; + float secondOffset; }; Q_DECLARE_METATYPE(AudioInjectorOptions); diff --git a/libraries/audio/src/AudioScriptingInterface.cpp b/libraries/audio/src/AudioScriptingInterface.cpp index 35a11f4dd4..b604e2825b 100644 --- a/libraries/audio/src/AudioScriptingInterface.cpp +++ b/libraries/audio/src/AudioScriptingInterface.cpp @@ -44,7 +44,11 @@ void AudioScriptingInterface::stopAllInjectors() { AudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjectorOptions& injectorOptions) { if (sound) { - AudioInjector* injector = new AudioInjector(sound, injectorOptions); + // stereo option isn't set from script, this comes from sound metadata or filename + AudioInjectorOptions optionsCopy = injectorOptions; + optionsCopy.stereo = sound->isStereo(); + + AudioInjector* injector = new AudioInjector(sound, optionsCopy); injector->setLocalAudioInterface(_localAudioInterface); QThread* injectorThread = new QThread(); diff --git a/libraries/audio/src/Sound.cpp b/libraries/audio/src/Sound.cpp index ff54e262f8..2608c333d6 100644 --- a/libraries/audio/src/Sound.cpp +++ b/libraries/audio/src/Sound.cpp @@ -64,7 +64,14 @@ void Sound::downloadFinished(QNetworkReply* reply) { interpretAsWav(rawAudioByteArray, outputAudioByteArray); downSample(outputAudioByteArray); } else { - // Process as RAW file + // check if this was a stereo raw file + // since it's raw the only way for us to know that is if the file was called .stereo.raw + if (reply->url().fileName().toLower().endsWith("stereo.raw")) { + _isStereo = true; + qDebug() << "Processing sound from" << reply->url() << "as stereo audio file."; + } + + // Process as RAW file downSample(rawAudioByteArray); } trimFrames(); @@ -206,10 +213,12 @@ void Sound::interpretAsWav(const QByteArray& inputAudioByteArray, QByteArray& ou qDebug() << "Currently not supporting non PCM audio files."; return; } - if (qFromLittleEndian(fileHeader.wave.numChannels) != 1) { - qDebug() << "Currently not supporting stereo audio files."; - return; + if (qFromLittleEndian(fileHeader.wave.numChannels) == 2) { + _isStereo = true; + } else if (qFromLittleEndian(fileHeader.wave.numChannels) > 2) { + qDebug() << "Currently not support audio files with more than 2 channels."; } + if (qFromLittleEndian(fileHeader.wave.bitsPerSample) != 16) { qDebug() << "Currently not supporting non 16bit audio files."; return; diff --git a/libraries/audio/src/Sound.h b/libraries/audio/src/Sound.h index c78bf72ff7..02b75417e8 100644 --- a/libraries/audio/src/Sound.h +++ b/libraries/audio/src/Sound.h @@ -25,7 +25,7 @@ class Sound : public Resource { public: Sound(const QUrl& url, bool isStereo = false); - bool isStereo() const { return _isStereo; } + bool isStereo() const { return _isStereo; } bool isReady() const { return _isReady; } const QByteArray& getByteArray() { return _byteArray; } From 81c5f9ba5a1e59033984eb92dcaae2bbd444889b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 19 Nov 2014 13:36:27 -0800 Subject: [PATCH 2/5] inject lobby music at a random starting point --- examples/lobby.js | 18 ++++++++++++++---- libraries/audio/src/AudioInjector.cpp | 13 +++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index bb033971b3..9b4a81c7cd 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -39,13 +39,15 @@ var ORB_SHIFT = { x: 0, y: -1.4, z: -0.8}; var HELMET_ATTACHMENT_URL = HIFI_PUBLIC_BUCKET + "models/attachments/IronManMaskOnly.fbx" -var droneSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/drone.raw") +var droneSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/drone.stereo.raw") var currentDrone = null; -var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.raw") -var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.raw") +var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.stereo.raw") +var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.stereo.raw") var currentMusak = null; +var firstMusakPlay = true; + function reticlePosition() { var RETICLE_DISTANCE = 1; return Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), RETICLE_DISTANCE)); @@ -137,7 +139,15 @@ function playRandomMusak() { } if (chosenSound) { - currentMusak = Audio.playSound(chosenSound, { stereo: true, localOnly: true }) + if (firstMusakPlay) { + // pick a random number of seconds from 0-10 to offset the muzak + var secondOffset = Math.random() * 10; + firstMusakPlay = false; + } else { + var secondOffset = 0.0; + } + + currentMusak = Audio.playSound(chosenSound, { localOnly: true, secondOffset: secondOffset, volume: 0.5 }) } else { currentMusak = null; } diff --git a/libraries/audio/src/AudioInjector.cpp b/libraries/audio/src/AudioInjector.cpp index 979bf70533..1775099e8a 100644 --- a/libraries/audio/src/AudioInjector.cpp +++ b/libraries/audio/src/AudioInjector.cpp @@ -94,6 +94,19 @@ void AudioInjector::injectLocally() { _localBuffer->open(QIODevice::ReadOnly); _localBuffer->setShouldLoop(_options.loop); + // check if we need to offset the sound by some number of seconds + if (_options.secondOffset > 0.0f) { + + qDebug() << "injector wants a sound offset of" << _options.secondOffset; + // convert the offset into a number of bytes + int byteOffset = (int) floorf(SAMPLE_RATE * _options.secondOffset * (_options.stereo ? 2.0f : 1.0f)); + byteOffset *= sizeof(int16_t); + + qDebug() << "that gives us" << byteOffset << "bytes"; + + // give that byte offset to our local buffer + _localBuffer->setCurrentOffset(byteOffset); + } QMetaObject::invokeMethod(_localAudioInterface, "outputLocalInjector", Qt::BlockingQueuedConnection, From 45450c4fe3be73d116b661007462f4f033ee5494 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 19 Nov 2014 13:42:24 -0800 Subject: [PATCH 3/5] handle offset passed in AudioInjectorOptions for mixer injections --- examples/lobby.js | 14 +++----------- libraries/audio/src/AudioInjector.cpp | 28 ++++++++++++++------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index 9b4a81c7cd..3e74cb0136 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -46,8 +46,6 @@ var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.st var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.stereo.raw") var currentMusak = null; -var firstMusakPlay = true; - function reticlePosition() { var RETICLE_DISTANCE = 1; return Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), RETICLE_DISTANCE)); @@ -138,15 +136,9 @@ function playRandomMusak() { chosenSound = elevatorSound; } - if (chosenSound) { - if (firstMusakPlay) { - // pick a random number of seconds from 0-10 to offset the muzak - var secondOffset = Math.random() * 10; - firstMusakPlay = false; - } else { - var secondOffset = 0.0; - } - + if (chosenSound) { + // pick a random number of seconds from 0-10 to offset the muzak + var secondOffset = Math.random() * 10; currentMusak = Audio.playSound(chosenSound, { localOnly: true, secondOffset: secondOffset, volume: 0.5 }) } else { currentMusak = null; diff --git a/libraries/audio/src/AudioInjector.cpp b/libraries/audio/src/AudioInjector.cpp index 1775099e8a..d5f82bbdd4 100644 --- a/libraries/audio/src/AudioInjector.cpp +++ b/libraries/audio/src/AudioInjector.cpp @@ -78,6 +78,19 @@ float AudioInjector::getLoudness() { } void AudioInjector::injectAudio() { + + // check if we need to offset the sound by some number of seconds + if (_options.secondOffset > 0.0f) { + + // convert the offset into a number of bytes + int byteOffset = (int) floorf(SAMPLE_RATE * _options.secondOffset * (_options.stereo ? 2.0f : 1.0f)); + byteOffset *= sizeof(int16_t); + + qDebug() << "Changing current send position to" << byteOffset; + + _currentSendPosition = byteOffset; + } + if (_options.localOnly) { injectLocally(); } else { @@ -94,19 +107,8 @@ void AudioInjector::injectLocally() { _localBuffer->open(QIODevice::ReadOnly); _localBuffer->setShouldLoop(_options.loop); - // check if we need to offset the sound by some number of seconds - if (_options.secondOffset > 0.0f) { - - qDebug() << "injector wants a sound offset of" << _options.secondOffset; - // convert the offset into a number of bytes - int byteOffset = (int) floorf(SAMPLE_RATE * _options.secondOffset * (_options.stereo ? 2.0f : 1.0f)); - byteOffset *= sizeof(int16_t); - - qDebug() << "that gives us" << byteOffset << "bytes"; - - // give that byte offset to our local buffer - _localBuffer->setCurrentOffset(byteOffset); - } + // give our current send position to the local buffer + _localBuffer->setCurrentOffset(_currentSendPosition); QMetaObject::invokeMethod(_localAudioInterface, "outputLocalInjector", Qt::BlockingQueuedConnection, From 987b75d8f7181e6e82ff7929afb18c881d6656db Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 19 Nov 2014 14:52:57 -0800 Subject: [PATCH 4/5] switch to next musak when finished --- examples/lobby.js | 55 ++++++++++++++----- libraries/audio/src/AudioInjector.cpp | 5 +- .../audio/src/AudioInjectorLocalBuffer.cpp | 5 ++ .../audio/src/AudioInjectorLocalBuffer.h | 2 + 4 files changed, 49 insertions(+), 18 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index 3e74cb0136..2e7949a110 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -44,7 +44,8 @@ var currentDrone = null; var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.stereo.raw") var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.stereo.raw") -var currentMusak = null; +var currentMusakInjector = null; +var currentSound = null; function reticlePosition() { var RETICLE_DISTANCE = 1; @@ -125,23 +126,42 @@ function changeLobbyTextures() { Overlays.editOverlay(panelWall, textureProp); } +var MUSAK_VOLUME = 0.5; + +function playNextMusak() { + if (panelWall) { + print("PLAYING THE NEXT MUSAK!"); + if (currentSound == latinSound) { + if (elevatorSound.downloaded) { + currentSound = elevatorSound; + } + } else if (currentSound == elevatorSound) { + if (latinSound.downloaded) { + currentSound = latinSound; + } + } + + currentMusakInjector = Audio.playSound(currentSound, { localOnly: true, volume: MUSAK_VOLUME }); + } +} + function playRandomMusak() { - chosenSound = null; + currentSound = null; if (latinSound.downloaded && elevatorSound.downloaded) { - chosenSound = Math.random < 0.5 ? latinSound : elevatorSound; + currentSound = Math.random() < 0.5 ? latinSound : elevatorSound; } else if (latinSound.downloaded) { - chosenSound = latinSound; + currentSound = latinSound; } else if (elevatorSound.downloaded) { - chosenSound = elevatorSound; + currentSound = elevatorSound; } - if (chosenSound) { - // pick a random number of seconds from 0-10 to offset the muzak + if (currentSound) { + // pick a random number of seconds from 0-10 to offset the musak var secondOffset = Math.random() * 10; - currentMusak = Audio.playSound(chosenSound, { localOnly: true, secondOffset: secondOffset, volume: 0.5 }) + currentMusakInjector = Audio.playSound(currentSound, { localOnly: true, secondOffset: secondOffset, volume: MUSAK_VOLUME }); } else { - currentMusak = null; + currentMusakInjector = null; } } @@ -150,16 +170,16 @@ function cleanupLobby() { Overlays.deleteOverlay(orbShell); Overlays.deleteOverlay(reticle); - Audio.stopInjector(currentDrone); - currentDrone = null; - - Audio.stopInjector(currentMusak); - currentMusak = null; - panelWall = false; orbShell = false; reticle = false; + Audio.stopInjector(currentDrone); + currentDrone = null; + + Audio.stopInjector(currentMusakInjector); + currentMusakInjector = null; + locations = {}; toggleEnvironmentRendering(true); @@ -224,6 +244,11 @@ function update(deltaTime) { Overlays.editOverlay(reticle, { position: reticlePosition() }); + + // if the reticle is up then we may need to play the next musak + if (!Audio.isInjectorPlaying(currentMusakInjector)) { + playNextMusak(); + } } } diff --git a/libraries/audio/src/AudioInjector.cpp b/libraries/audio/src/AudioInjector.cpp index d5f82bbdd4..d31ab83976 100644 --- a/libraries/audio/src/AudioInjector.cpp +++ b/libraries/audio/src/AudioInjector.cpp @@ -86,8 +86,6 @@ void AudioInjector::injectAudio() { int byteOffset = (int) floorf(SAMPLE_RATE * _options.secondOffset * (_options.stereo ? 2.0f : 1.0f)); byteOffset *= sizeof(int16_t); - qDebug() << "Changing current send position to" << byteOffset; - _currentSendPosition = byteOffset; } @@ -117,7 +115,8 @@ void AudioInjector::injectLocally() { Q_ARG(qreal, _options.volume), Q_ARG(AudioInjector*, this)); - + // if we're not looping and the buffer tells us it is empty then emit finished + connect(_localBuffer, &AudioInjectorLocalBuffer::bufferEmpty, this, &AudioInjector::stop); if (!success) { qDebug() << "AudioInjector::injectLocally could not output locally via _localAudioInterface"; diff --git a/libraries/audio/src/AudioInjectorLocalBuffer.cpp b/libraries/audio/src/AudioInjectorLocalBuffer.cpp index bdf084091d..a58d686498 100644 --- a/libraries/audio/src/AudioInjectorLocalBuffer.cpp +++ b/libraries/audio/src/AudioInjectorLocalBuffer.cpp @@ -47,6 +47,11 @@ qint64 AudioInjectorLocalBuffer::readData(char* data, qint64 maxSize) { _currentOffset += bytesRead; } + if (!_shouldLoop && bytesRead == bytesToEnd) { + // we hit the end of the buffer, emit a signal + emit bufferEmpty(); + } + return bytesRead; } else { return 0; diff --git a/libraries/audio/src/AudioInjectorLocalBuffer.h b/libraries/audio/src/AudioInjectorLocalBuffer.h index 92409617f6..399c7515ec 100644 --- a/libraries/audio/src/AudioInjectorLocalBuffer.h +++ b/libraries/audio/src/AudioInjectorLocalBuffer.h @@ -27,6 +27,8 @@ public: void setShouldLoop(bool shouldLoop) { _shouldLoop = shouldLoop; } void setCurrentOffset(int currentOffset) { _currentOffset = currentOffset; } +signals: + void bufferEmpty(); private: qint64 recursiveReadFromFront(char* data, qint64 maxSize); From afe4a4e432b1e23b98cad622cf407cedd9ca36f1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 19 Nov 2014 15:26:18 -0800 Subject: [PATCH 5/5] don't show reticle if not wearing HMD, reset panel textures --- examples/lobby.js | 58 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index 2e7949a110..437cfe40f3 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -47,11 +47,15 @@ var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/eleva var currentMusakInjector = null; var currentSound = null; +var inOculusMode = Menu.isOptionChecked("EnableVRMode"); + function reticlePosition() { var RETICLE_DISTANCE = 1; return Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), RETICLE_DISTANCE)); } +var MAX_NUM_PANELS = 21; + function drawLobby() { if (!panelWall) { print("Adding overlays for the lobby panel wall and orb shell."); @@ -65,7 +69,7 @@ function drawLobby() { url: HIFI_PUBLIC_BUCKET + "models/sets/Lobby/LobbyPrototype/Lobby5_PanelsWithFrames.fbx", position: Vec3.sum(orbPosition, Vec3.multiplyQbyV(towardsMe, panelsCenterShift)), rotation: towardsMe, - dimensions: panelsDimensions + dimensions: panelsDimensions, }; var orbShellProps = { @@ -78,21 +82,23 @@ function drawLobby() { avatarStickPosition = MyAvatar.position; - panelWall = Overlays.addOverlay("model", panelWallProps); + panelWall = Overlays.addOverlay("model", panelWallProps); orbShell = Overlays.addOverlay("model", orbShellProps); // for HMD wearers, create a reticle in center of screen - var CURSOR_SCALE = 0.025; - - reticle = Overlays.addOverlay("billboard", { - url: HIFI_PUBLIC_BUCKET + "images/cursor.svg", - position: reticlePosition(), - ignoreRayIntersection: true, - isFacingAvatar: true, - alpha: 1.0, - scale: CURSOR_SCALE - }); + if (inOculusMode) { + var CURSOR_SCALE = 0.025; + reticle = Overlays.addOverlay("billboard", { + url: HIFI_PUBLIC_BUCKET + "images/cursor.svg", + position: reticlePosition(), + ignoreRayIntersection: true, + isFacingAvatar: true, + alpha: 1.0, + scale: CURSOR_SCALE + }); + } + // add an attachment on this avatar so other people see them in the lobby MyAvatar.attach(HELMET_ATTACHMENT_URL, "Neck", {x: 0, y: 0, z: 0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.15); @@ -130,7 +136,6 @@ var MUSAK_VOLUME = 0.5; function playNextMusak() { if (panelWall) { - print("PLAYING THE NEXT MUSAK!"); if (currentSound == latinSound) { if (elevatorSound.downloaded) { currentSound = elevatorSound; @@ -166,9 +171,23 @@ function playRandomMusak() { } function cleanupLobby() { + + // for each of the 21 placeholder textures, set them back to default so the cached model doesn't have changed textures + var panelTexturesReset = {}; + panelTexturesReset["textures"] = {}; + + for (var j = 0; j < MAX_NUM_PANELS; j++) { + panelTexturesReset["textures"]["file" + (j + 1)] = HIFI_PUBLIC_BUCKET + "models/sets/Lobby/LobbyPrototype/Texture.jpg"; + }; + + Overlays.editOverlay(panelWall, panelTexturesReset); + Overlays.deleteOverlay(panelWall); Overlays.deleteOverlay(orbShell); - Overlays.deleteOverlay(reticle); + + if (reticle) { + Overlays.deleteOverlay(reticle); + } panelWall = false; orbShell = false; @@ -240,10 +259,13 @@ function toggleEnvironmentRendering(shouldRender) { function update(deltaTime) { maybeCleanupLobby(); - if (reticle) { - Overlays.editOverlay(reticle, { - position: reticlePosition() - }); + if (panelWall) { + + if (reticle) { + Overlays.editOverlay(reticle, { + position: reticlePosition() + }); + } // if the reticle is up then we may need to play the next musak if (!Audio.isInjectorPlaying(currentMusakInjector)) {