mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 20:29:10 +02:00
improved playSound.js to work if no spatial controller attached
This commit is contained in:
parent
f4c274dbe6
commit
ab80e3dc84
1 changed files with 6 additions and 6 deletions
|
@ -3,22 +3,22 @@
|
||||||
// examples
|
// examples
|
||||||
//
|
//
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
// This sample script loads a sound file and plays it at the 'fingertip' of the
|
// Plays a sample audio file at the avatar's current location
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
// First, load the clap sound from a URL
|
// First, load a sample sound from a URL
|
||||||
var clap = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/bushtit_1.raw");
|
var bird = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/bushtit_1.raw");
|
||||||
|
|
||||||
function maybePlaySound(deltaTime) {
|
function maybePlaySound(deltaTime) {
|
||||||
if (Math.random() < 0.01) {
|
if (Math.random() < 0.01) {
|
||||||
// Set the location and other info for the sound to play
|
// Set the location and other info for the sound to play
|
||||||
var options = new AudioInjectionOptions();
|
var options = new AudioInjectionOptions();
|
||||||
var palmPosition = Controller.getSpatialControlPosition(0);
|
var position = MyAvatar.position;
|
||||||
options.position = palmPosition;
|
options.position = position;
|
||||||
options.volume = 0.5;
|
options.volume = 0.5;
|
||||||
Audio.playSound(clap, options);
|
Audio.playSound(bird, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue