wait for sound to download

This commit is contained in:
Howard Stearns 2016-02-12 17:42:44 -08:00
parent 25671fbefe
commit 9a3972c43f

View file

@ -28,9 +28,15 @@ var properties = {
var objectId = Entities.addEntity(properties);
var soundOptions = { position: orbitCenter, loop: true, volume: 0.5 };
var sound = Audio.playSound(soundClip, soundOptions);
var sound;
function update(deltaTime) {
function update(deltaTime) {
if (!soundClip.downloaded) {
return;
}
if (!sound) {
sound = Audio.playSound(soundClip, soundOptions); // Not until downloaded
}
time += deltaTime;
currentPosition = { x: orbitCenter.x + Math.cos(time * SPEED) * RADIUS, y: orbitCenter.y, z: orbitCenter.z + Math.sin(time * SPEED) * RADIUS };
trailingLoudness = 0.9 * trailingLoudness + 0.1 * sound.loudness;