39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
var sound = SoundCache.getSound("http://hifi-content.s3.amazonaws.com/howard/sounds/piano1.wav");
|
|
|
|
var ANIMATION_URL = "http://hifi-content.s3.amazonaws.com/howard/resources/avatar/animations/idle.fbx";
|
|
var AVATAR_MODEL = "http://hifi-content.s3.amazonaws.com/howard/resources/meshes/defaultAvatar_full.fst";
|
|
var POLL_INTERVAL = 500; // ms
|
|
var SPREAD_MAX = 2;
|
|
var SPREAD_MIN = 0;
|
|
var SOUND_PAUSE_MAX = 10000;
|
|
var SOUND_PAUSE_MIN = 2000;
|
|
|
|
function randInterval(min, max) {
|
|
return min + Math.random()*(max-min);
|
|
}
|
|
|
|
Agent.isAvatar = true;
|
|
Agent.isListening = true;
|
|
|
|
Avatar.skeletonModelURL = AVATAR_MODEL;
|
|
Avatar.position = { x: randInterval(SPREAD_MIN, SPREAD_MAX),
|
|
y: randInterval(SPREAD_MIN, SPREAD_MAX),
|
|
z: randInterval(SPREAD_MIN, SPREAD_MAX)
|
|
};
|
|
|
|
Avatar.startAnimation(ANIMATION_URL, 30, 1.0, true, false, 0, 300);
|
|
|
|
var soundInterval = Script.setInterval(function () {
|
|
if (sound.downloaded) {
|
|
Script.clearInterval(soundInterval);
|
|
print("sound downloaded");
|
|
// now play it in a loop until the end of time
|
|
Script.setInterval(function() {
|
|
print("playing sound");
|
|
Agent.playAvatarSound(sound);
|
|
}, sound.duration + randInterval(SOUND_PAUSE_MIN, SOUND_PAUSE_MAX));
|
|
} else {
|
|
print("waiting for sound to download...");
|
|
}
|
|
}, POLL_INTERVAL);
|
|
|