This commit is contained in:
James B. Pollack 2016-02-08 13:15:49 -08:00
parent 720175f862
commit a80641a2c4
5 changed files with 112 additions and 16 deletions

View file

@ -7,7 +7,7 @@
(function() {
var version = 10;
var version = 11;
var added = false;
this.frame = 0;
var utilsScript = Script.resolvePath('utils.js');

View file

@ -8,7 +8,7 @@
(function() {
var self = this;
var baseURL = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
var version = 10;
var version = 11;
this.preload = function(entityId) {
self.soundPlaying = false;
self.entityId = entityId;

View file

@ -10,7 +10,7 @@
var self = this;
var baseURL = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
var version = 1;
var version = 2;
this.preload = function(entityId) {
this.soundPlaying = null;
this.entityId = entityId;
@ -21,7 +21,7 @@
}
this.initialize = function(entityId) {
print(' should initialize' + entityId)
//print(' should initialize' + entityId)
var properties = Entities.getEntityProperties(entityId);
if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) {
self.initTimeout = Script.setTimeout(function() {

View file

@ -0,0 +1,97 @@
var soundMap = [{
name: 'Cells',
url: "http://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/Cells.wav",
audioOptions: {
position: {
x: 15850,
y: 15850,
z: 15850
},
volume: 0.4,
loop: true
}
}, {
name: 'Cell Layout',
url: "http://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/CellLayout.wav",
audioOptions: {
position: {
x: 15950,
y: 15950,
z: 15950
},
volume: 0.4,
loop: true
}
}, {
name: 'Ribsome',
url: "http://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/Ribosome.wav",
audioOptions: {
position: {
x: 15650,
y: 15650,
z: 15650
},
volume: 0.4,
loop: true
}
}, {
name: 'Hexokinase',
url: "http://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/Hexokinase.wav",
audioOptions: {
position: {
x: 15750,
y: 15750,
z: 15750
},
volume: 0.4,
loop: true
}
}
];
function loadSounds() {
soundMap.forEach(function(soundData) {
soundData.sound = SoundCache.getSound(soundData.url);
});
}
function playSound(soundData) {
if (soundData.injector) {
// try/catch in case the injector QObject has been deleted already
try {
soundData.injector.stop();
} catch (e) {
print('error playing sound' + e)
}
}
soundData.injector = Audio.playSound(soundData.sound, soundData.audioOptions);
}
function checkDownloaded(soundData) {
if (soundData.sound.downloaded) {
Script.clearInterval(soundData.downloadTimer);
if (soundData.hasOwnProperty('playAtInterval')) {
soundData.playingInterval = Script.setInterval(function() {
playSound(soundData)
}, soundData.playAtInterval);
} else {
playSound(soundData);
}
}
}
function startCheckDownloadedTimers() {
soundMap.forEach(function(soundData) {
soundData.downloadTimer = Script.setInterval(function() {
checkDownloaded(soundData);
}, 1000);
});
}
loadSounds();
startCheckDownloadedTimers();

View file

@ -5,7 +5,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var version = 1015;
var version = 1016;
var cellLayout;
var baseLocation = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
@ -115,8 +115,7 @@ var scenes = [{
radius: 500,
number: 10,
userData: JSON.stringify({
target: locations.cellLayout[1],
location: locations.cellLayout[0],
location: locations.cellLayout[1],
baseURL: baseLocation
}),
script: "zoom.js?" + version,
@ -597,7 +596,7 @@ function ImportScene(scene) {
CreateInstances(scene);
CreateBoundary(scene);
CreateBackgroundAudio(scene.name, scene.location, scene.dimensions);
// CreateBackgroundAudio(scene.name, scene.location, scene.dimensions);
// print("done " + scene.name);
@ -654,9 +653,9 @@ function CreateNavigationButton(scene, number) {
blue: 0
},
dimensions: {
x: 10,
y: 10,
z: 10
x: 16000,
y: 16000,
z: 16000
},
visible: false,
userData: JSON.stringify({
@ -669,7 +668,7 @@ function CreateNavigationButton(scene, number) {
grabbable: false
}
}),
// position:{x:3000,y:13500,z:3000},
position:{x:0,y:0,z:0},
script: baseLocation + "Scripts/navigationButton.js?" + version,
collisionless: true,
@ -853,10 +852,10 @@ function CreateBackgroundAudio(name, position) {
Entities.addEntity({
type: "Sphere",
name: "Location " + name + " background audio",
dimensions: {
x: 4000,
y: 4000,
z: 4000
dimensions: {
x: 16000,
y: 16000,
z: 16000
},
position: position,
visible: false,