mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 23:03:12 +02:00
Merge pull request #7041 from imgntn/cellscience
Change the way cellscience entities intitialize & audio plays
This commit is contained in:
commit
5dd044dc29
12 changed files with 1006 additions and 785 deletions
|
@ -18,21 +18,46 @@
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.preload = function(entityId) {
|
this.preload = function(entityId) {
|
||||||
|
|
||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
this.data = JSON.parse(Entities.getEntityProperties(this.entityId, "userData").userData);
|
this.initialize(entityId);
|
||||||
this.buttonImageURL = baseURL + "GUI/GUI_jump_off.png";
|
self.initTimeout = null;
|
||||||
this.addExitButton();
|
|
||||||
this.isRiding = false;
|
|
||||||
|
|
||||||
if (this.data && this.data.isDynein) {
|
|
||||||
this.rotation = 180;
|
|
||||||
} else {
|
|
||||||
this.rotation = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.initialize = function(entityId) {
|
||||||
|
//print(' should initialize' + entityId)
|
||||||
|
var properties = Entities.getEntityProperties(entityId);
|
||||||
|
if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) {
|
||||||
|
self.initTimeout = Script.setTimeout(function() {
|
||||||
|
//print(' no user data yet, try again in one second')
|
||||||
|
self.initialize(entityId);
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//print(' userdata before parse attempt' + properties.userData)
|
||||||
|
self.userData = null;
|
||||||
|
try {
|
||||||
|
self.userData = JSON.parse(properties.userData);
|
||||||
|
} catch (err) {
|
||||||
|
//print(' error parsing json');
|
||||||
|
//print(' properties are:' + properties.userData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.data = self.userData;
|
||||||
|
self.buttonImageURL = baseURL + "GUI/GUI_jump_off.png";
|
||||||
|
self.addExitButton();
|
||||||
|
self.isRiding = false;
|
||||||
|
self.mouseIsConnected = false;
|
||||||
|
if (self.data && self.data.isDynein) {
|
||||||
|
self.rotation = 180;
|
||||||
|
} else {
|
||||||
|
self.rotation = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.addExitButton = function() {
|
this.addExitButton = function() {
|
||||||
this.windowDimensions = Controller.getViewportDimensions();
|
this.windowDimensions = Controller.getViewportDimensions();
|
||||||
this.buttonWidth = 75;
|
this.buttonWidth = 75;
|
||||||
|
@ -53,19 +78,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clickReleaseOnEntity = function(entityId, mouseEvent) {
|
this.clickReleaseOnEntity = function(entityId, mouseEvent) {
|
||||||
// print('CLICKED ON MOTOR PROTEIN')
|
|
||||||
|
//print('CLICKED ON MOTOR PROTEIN')
|
||||||
|
return;
|
||||||
if (mouseEvent.isLeftButton && !self.isRiding) {
|
if (mouseEvent.isLeftButton && !self.isRiding) {
|
||||||
print("GET ON");
|
//print("GET ON");
|
||||||
self.isRiding = true;
|
self.isRiding = true;
|
||||||
if (!self.entityId) {
|
if (!self.entityId) {
|
||||||
self.entityId = entityId;
|
self.entityId = entityId;
|
||||||
}
|
}
|
||||||
self.entityLocation = Entities.getEntityProperties(this.entityId, "position").position;
|
self.entityLocation = Entities.getEntityProperties(self.entityId, "position").position;
|
||||||
self.targetLocation = Vec3.sum(self.entityLocation, TARGET_OFFSET);
|
self.targetLocation = Vec3.sum(self.entityLocation, TARGET_OFFSET);
|
||||||
Overlays.editOverlay(self.exitButton, {
|
Overlays.editOverlay(self.exitButton, {
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
Controller.mousePressEvent.connect(this.onMousePress);
|
Controller.mousePressEvent.connect(this.onMousePress);
|
||||||
|
self.mouseIsConnected = true;
|
||||||
Script.update.connect(this.update);
|
Script.update.connect(this.update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +144,7 @@
|
||||||
y: event.y
|
y: event.y
|
||||||
});
|
});
|
||||||
if (event.isLeftButton && clickedOverlay === self.exitButton) {
|
if (event.isLeftButton && clickedOverlay === self.exitButton) {
|
||||||
print("GET OFF");
|
//print("GET OFF");
|
||||||
Script.update.disconnect(this.update);
|
Script.update.disconnect(this.update);
|
||||||
self.reset();
|
self.reset();
|
||||||
}
|
}
|
||||||
|
@ -136,8 +164,12 @@
|
||||||
// print("unload");
|
// print("unload");
|
||||||
self.reset();
|
self.reset();
|
||||||
|
|
||||||
Controller.mousePressEvent.disconnect(this.onMousePress);
|
if (self.mouseIsConnected === true) {
|
||||||
|
Controller.mousePressEvent.disconnect(self.onMousePress);
|
||||||
|
}
|
||||||
|
if (self.initTimeout !== null) {
|
||||||
|
Script.clearTimeout(self.initTimeout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
|
@ -1,17 +0,0 @@
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
function deleteAllInRadius(r) {
|
|
||||||
var n = 0;
|
|
||||||
var arrayFound = Entities.findEntities(MyAvatar.position, r);
|
|
||||||
for (var i = 0; i < arrayFound.length; i++) {
|
|
||||||
Entities.deleteEntity(arrayFound[i]);
|
|
||||||
}
|
|
||||||
print("deleted " + arrayFound.length + " entities");
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteAllInRadius(100000);
|
|
|
@ -1,21 +0,0 @@
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
var scriptName = "Controller";
|
|
||||||
|
|
||||||
function findScriptsInRadius(r) {
|
|
||||||
var n = 0;
|
|
||||||
var arrayFound = Entities.findEntities(MyAvatar.position, r);
|
|
||||||
for (var i = 0; i < arrayFound.length; i++) {
|
|
||||||
if (Entities.getEntityProperties(arrayFound[i]).script.indexOf(scriptName) != -1) {
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print("found " + n + " copies of " + scriptName);
|
|
||||||
}
|
|
||||||
|
|
||||||
findScriptsInRadius(100000);
|
|
|
@ -9,7 +9,8 @@
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.preload = function(entityId) {
|
this.preload = function(entityId) {
|
||||||
|
//print('preload move randomly')
|
||||||
|
this.isConnected = false;
|
||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
this.updateInterval = 100;
|
this.updateInterval = 100;
|
||||||
this.posFrame = 0;
|
this.posFrame = 0;
|
||||||
|
@ -21,62 +22,161 @@
|
||||||
this.minAngularVelocity = 0.01;
|
this.minAngularVelocity = 0.01;
|
||||||
this.maxAngularVelocity = 0.03;
|
this.maxAngularVelocity = 0.03;
|
||||||
|
|
||||||
|
this.initialize(entityId);
|
||||||
|
this.initTimeout = null;
|
||||||
|
|
||||||
|
|
||||||
|
var userData = {
|
||||||
|
ownershipKey: {
|
||||||
|
owner: MyAvatar.sessionUUID
|
||||||
|
},
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Entities.editEntity(entityId, {
|
||||||
|
userData: JSON.stringify(userData)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initialize = function(entityId) {
|
||||||
|
//print('move randomly should initialize' + entityId)
|
||||||
|
var properties = Entities.getEntityProperties(entityId);
|
||||||
|
if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) {
|
||||||
|
self.initTimeout = Script.setTimeout(function() {
|
||||||
|
//print('no user data yet, try again in one second')
|
||||||
|
self.initialize(entityId);
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//print('userdata before parse attempt' + properties.userData)
|
||||||
|
self.userData = null;
|
||||||
|
try {
|
||||||
|
self.userData = JSON.parse(properties.userData);
|
||||||
|
} catch (err) {
|
||||||
|
//print('error parsing json');
|
||||||
|
//print('properties are:' + properties.userData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Script.update.connect(self.update);
|
||||||
|
this.isConnected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update = function(deltaTime) {
|
this.update = function(deltaTime) {
|
||||||
|
// print('jbp in update')
|
||||||
|
var data = Entities.getEntityProperties(self.entityId, 'userData').userData;
|
||||||
|
var userData;
|
||||||
|
try {
|
||||||
|
userData = JSON.parse(data)
|
||||||
|
} catch (e) {
|
||||||
|
//print('error parsing json' + data)
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
self.posFrame++;
|
// print('userdata is' + data)
|
||||||
self.rotFrame++;
|
//if the entity doesnt have an owner set yet
|
||||||
|
if (userData.hasOwnProperty('ownershipKey') !== true) {
|
||||||
if (self.posFrame > self.posInterval) {
|
//print('no movement owner yet')
|
||||||
|
return;
|
||||||
self.posInterval = 100 * Math.random() + 300;
|
|
||||||
self.posFrame = 0;
|
|
||||||
|
|
||||||
var magnitudeV = self.maxVelocity;
|
|
||||||
var directionV = {
|
|
||||||
x: Math.random() - 0.5,
|
|
||||||
y: Math.random() - 0.5,
|
|
||||||
z: Math.random() - 0.5
|
|
||||||
};
|
|
||||||
|
|
||||||
// print("POS magnitude is " + magnitudeV + " and direction is " + directionV.x);
|
|
||||||
Entities.editEntity(self.entityId, {
|
|
||||||
velocity: Vec3.multiply(magnitudeV, Vec3.normalize(directionV))
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.rotFrame > self.rotInterval) {
|
//print('owner is:::' + userData.ownershipKey.owner)
|
||||||
|
//get all the avatars to see if the owner is around
|
||||||
|
var avatars = AvatarList.getAvatarIdentifiers();
|
||||||
|
var ownerIsAround = false;
|
||||||
|
|
||||||
self.rotInterval = 100 * Math.random() + 250;
|
//if the current owner is not me...
|
||||||
self.rotFrame = 0;
|
if (userData.ownershipKey.owner !== MyAvatar.sessionUUID) {
|
||||||
|
|
||||||
var magnitudeAV = self.maxAngularVelocity;
|
//look to see if the current owner is around anymore
|
||||||
|
for (var i = 0; i < avatars.length; i++) {
|
||||||
|
if (avatars[i] === userData.ownershipKey.owner) {
|
||||||
|
ownerIsAround = true
|
||||||
|
//the owner is around
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var directionAV = {
|
//if the owner is not around, then take ownership
|
||||||
x: Math.random() - 0.5,
|
if (ownerIsAround === false) {
|
||||||
y: Math.random() - 0.5,
|
//print('taking ownership')
|
||||||
z: Math.random() - 0.5
|
|
||||||
};
|
|
||||||
// print("ROT magnitude is " + magnitudeAV + " and direction is " + directionAV.x);
|
|
||||||
Entities.editEntity(self.entityId, {
|
|
||||||
angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV))
|
|
||||||
|
|
||||||
});
|
var userData = {
|
||||||
|
ownershipKey: {
|
||||||
|
owner: MyAvatar.sessionUUID
|
||||||
|
},
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Entities.editEntity(self.entityId, {
|
||||||
|
userData: JSON.stringify(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//but if the current owner IS me, then move it
|
||||||
|
else {
|
||||||
|
//print('jbp im the owner so move it')
|
||||||
|
self.posFrame++;
|
||||||
|
self.rotFrame++;
|
||||||
|
|
||||||
|
if (self.posFrame > self.posInterval) {
|
||||||
|
|
||||||
|
self.posInterval = 100 * Math.random() + 300;
|
||||||
|
self.posFrame = 0;
|
||||||
|
|
||||||
|
var magnitudeV = self.maxVelocity;
|
||||||
|
var directionV = {
|
||||||
|
x: Math.random() - 0.5,
|
||||||
|
y: Math.random() - 0.5,
|
||||||
|
z: Math.random() - 0.5
|
||||||
|
};
|
||||||
|
|
||||||
|
//print("POS magnitude is " + magnitudeV + " and direction is " + directionV.x);
|
||||||
|
Entities.editEntity(self.entityId, {
|
||||||
|
velocity: Vec3.multiply(magnitudeV, Vec3.normalize(directionV))
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.rotFrame > self.rotInterval) {
|
||||||
|
|
||||||
|
self.rotInterval = 100 * Math.random() + 250;
|
||||||
|
self.rotFrame = 0;
|
||||||
|
|
||||||
|
var magnitudeAV = self.maxAngularVelocity;
|
||||||
|
|
||||||
|
var directionAV = {
|
||||||
|
x: Math.random() - 0.5,
|
||||||
|
y: Math.random() - 0.5,
|
||||||
|
z: Math.random() - 0.5
|
||||||
|
};
|
||||||
|
//print("ROT magnitude is " + magnitudeAV + " and direction is " + directionAV.x);
|
||||||
|
Entities.editEntity(self.entityId, {
|
||||||
|
angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV))
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unload = function() {
|
this.unload = function() {
|
||||||
|
if (this.initTimeout !== null) {
|
||||||
|
Script.clearTimeout(this.initTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
Script.update.disconnect(this.update);
|
if (this.isConnected === true) {
|
||||||
|
Script.update.disconnect(this.update);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.update.connect(this.update);
|
|
||||||
|
|
||||||
})
|
})
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -8,7 +7,7 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var version = 1;
|
var version = 11;
|
||||||
var added = false;
|
var added = false;
|
||||||
this.frame = 0;
|
this.frame = 0;
|
||||||
var utilsScript = Script.resolvePath('utils.js');
|
var utilsScript = Script.resolvePath('utils.js');
|
||||||
|
@ -19,35 +18,61 @@
|
||||||
|
|
||||||
this.preload = function(entityId) {
|
this.preload = function(entityId) {
|
||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
var mySavedSettings = Settings.getValue(entityId);
|
this.initialize(entityId);
|
||||||
|
this.initTimeout = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (mySavedSettings.buttons !== undefined) {
|
this.initialize = function(entityId) {
|
||||||
// print('NAV preload buttons'+ mySavedSettings.buttons)
|
print('JBP nav button should initialize' + entityId)
|
||||||
mySavedSettings.buttons.forEach(function(b) {
|
var properties = Entities.getEntityProperties(entityId);
|
||||||
// print('NAV deleting button'+ b)
|
if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) {
|
||||||
Overlays.deleteOverlay(b);
|
self.initTimeout = Script.setTimeout(function() {
|
||||||
})
|
print('JBP no user data yet, try again in one second')
|
||||||
Settings.setValue(entityId,'')
|
self.initialize(entityId);
|
||||||
}
|
}, 1000)
|
||||||
|
|
||||||
|
|
||||||
self.getUserData();
|
|
||||||
this.buttonImageURL = baseURL + "GUI/GUI_" + self.userData.name + ".png?" + version;
|
|
||||||
if (self.button === undefined) {
|
|
||||||
// print('NAV NO BUTTON ADDING ONE!!')
|
|
||||||
self.button = true;
|
|
||||||
self.addButton();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// print('NAV SELF ALREADY HAS A BUTTON!!')
|
print('JBP userdata before parse attempt' + properties.userData)
|
||||||
}
|
self.userData = null;
|
||||||
|
try {
|
||||||
|
self.userData = JSON.parse(properties.userData);
|
||||||
|
} catch (err) {
|
||||||
|
print('JBP error parsing json');
|
||||||
|
print('JBP properties are:' + properties.userData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var mySavedSettings = Settings.getValue(entityId);
|
||||||
|
|
||||||
|
if (mySavedSettings.buttons !== undefined) {
|
||||||
|
print('JBP preload buttons' + mySavedSettings.buttons)
|
||||||
|
mySavedSettings.buttons.forEach(function(b) {
|
||||||
|
print('JBP deleting button' + b)
|
||||||
|
Overlays.deleteOverlay(b);
|
||||||
|
})
|
||||||
|
Settings.setValue(entityId, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
self.buttonImageURL = baseURL + "GUI/GUI_" + self.userData.name + ".png?" + version;
|
||||||
|
print('JBP BUTTON IMAGE URL:' + self.buttonImageURL)
|
||||||
|
if (self.button === undefined) {
|
||||||
|
// print('NAV NO BUTTON ADDING ONE!!')
|
||||||
|
self.button = true;
|
||||||
|
self.addButton();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// print('NAV SELF ALREADY HAS A BUTTON!!')
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.addButton = function() {
|
this.addButton = function() {
|
||||||
|
|
||||||
|
|
||||||
self.getUserData();
|
|
||||||
this.windowDimensions = Controller.getViewportDimensions();
|
this.windowDimensions = Controller.getViewportDimensions();
|
||||||
this.buttonWidth = 150;
|
this.buttonWidth = 150;
|
||||||
this.buttonHeight = 50;
|
this.buttonHeight = 50;
|
||||||
|
@ -87,7 +112,7 @@
|
||||||
if (self.frame < 10) {
|
if (self.frame < 10) {
|
||||||
self.frame++;
|
self.frame++;
|
||||||
} else {
|
} else {
|
||||||
// this.lookAt(this.userData.target);
|
// this.lookAt(this.userData.target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +132,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lookAtTarget = function() {
|
this.lookAtTarget = function() {
|
||||||
self.getUserData();
|
|
||||||
var direction = Vec3.normalize(Vec3.subtract(self.userData.entryPoint, self.userData.target));
|
var direction = Vec3.normalize(Vec3.subtract(self.userData.entryPoint, self.userData.target));
|
||||||
var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, {
|
var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, {
|
||||||
x: 1,
|
x: 1,
|
||||||
|
@ -125,16 +150,6 @@
|
||||||
MyAvatar.headYaw = 0;
|
MyAvatar.headYaw = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getUserData = function() {
|
|
||||||
this.properties = Entities.getEntityProperties(this.entityId);
|
|
||||||
if (self.properties.userData) {
|
|
||||||
this.userData = JSON.parse(this.properties.userData);
|
|
||||||
} else {
|
|
||||||
this.userData = {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var buttonDeleter;
|
var buttonDeleter;
|
||||||
var deleterCount = 0;
|
var deleterCount = 0;
|
||||||
this.unload = function() {
|
this.unload = function() {
|
||||||
|
@ -144,6 +159,11 @@
|
||||||
|
|
||||||
Controller.mousePressEvent.disconnect(this.onClick);
|
Controller.mousePressEvent.disconnect(this.onClick);
|
||||||
// Script.update.disconnect(this.update);
|
// Script.update.disconnect(this.update);
|
||||||
|
|
||||||
|
|
||||||
|
if (this.initTimeout !== null) {
|
||||||
|
Script.clearTimeout(this.initTimeout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(this.onClick);
|
Controller.mousePressEvent.connect(this.onClick);
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var self = this;
|
|
||||||
var baseURL = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
|
|
||||||
var version = 9;
|
|
||||||
this.preload = function(entityId) {
|
|
||||||
self.soundPlaying = false;
|
|
||||||
self.entityId = entityId;
|
|
||||||
self.getUserData();
|
|
||||||
self.soundURL = baseURL + "Audio/" + self.userData.name + ".wav?" + version;
|
|
||||||
print("Script.clearTimeout creating WAV name location is " + baseURL + "Audio/" + self.userData.name + ".wav");
|
|
||||||
|
|
||||||
self.soundOptions = {
|
|
||||||
stereo: true,
|
|
||||||
loop: true,
|
|
||||||
localOnly: true,
|
|
||||||
volume: 0.035
|
|
||||||
};
|
|
||||||
|
|
||||||
this.sound = SoundCache.getSound(self.soundURL);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.getUserData = function() {
|
|
||||||
self.properties = Entities.getEntityProperties(self.entityId);
|
|
||||||
if (self.properties.userData) {
|
|
||||||
self.userData = JSON.parse(this.properties.userData);
|
|
||||||
} else {
|
|
||||||
self.userData = {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.enterEntity = function(entityID) {
|
|
||||||
print("entering audio zone");
|
|
||||||
if (self.sound.downloaded) {
|
|
||||||
print("playing background audio named " + self.userData.name + "which has been downloaded");
|
|
||||||
this.soundPlaying = Audio.playSound(self.sound, self.soundOptions);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print("sound is not downloaded");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
this.leaveEntity = function(entityID) {
|
|
||||||
print("leaving audio area " + self.userData.name);
|
|
||||||
if (self.soundPlaying !== false) {
|
|
||||||
print("not null");
|
|
||||||
print("Stopped sound " + self.userData.name);
|
|
||||||
self.soundPlaying.stop();
|
|
||||||
} else {
|
|
||||||
print("Sound not playing");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
|
@ -6,97 +6,117 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var baseURL = "https://hifi-content.s3.amazonaws.com/hifi-content/DomainContent/CellScience/";
|
var baseURL = "https://hifi-content.s3.amazonaws.com/hifi-content/DomainContent/CellScience/";
|
||||||
var self = this;
|
var self = this;
|
||||||
this.buttonImageURL = baseURL + "GUI/play_audio.svg?2";
|
this.buttonImageURL = baseURL + "GUI/play_audio.svg?2";
|
||||||
|
|
||||||
|
this.preload = function(entityId) {
|
||||||
|
this.entityId = entityId;
|
||||||
this.preload = function(entityId) {
|
this.initialize(entityId)
|
||||||
this.entityId = entityId;
|
this.initTimeout = null;
|
||||||
self.addButton();
|
|
||||||
this.buttonShowing = false;
|
|
||||||
self.getUserData();
|
|
||||||
this.showDistance = self.userData.showDistance;
|
|
||||||
this.soundURL = baseURL + "Audio/" + self.userData.soundName + ".wav";
|
|
||||||
print("distance = " + self.userData.showDistance + ", sound = " + this.soundURL);
|
|
||||||
this.soundOptions = {
|
|
||||||
stereo: true,
|
|
||||||
loop: false,
|
|
||||||
localOnly: true,
|
|
||||||
volume: 0.035
|
|
||||||
};
|
|
||||||
this.sound = SoundCache.getSound(this.soundURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.addButton = function() {
|
|
||||||
this.windowDimensions = Controller.getViewportDimensions();
|
|
||||||
this.buttonWidth = 100;
|
|
||||||
this.buttonHeight = 100;
|
|
||||||
this.buttonPadding = 0;
|
|
||||||
|
|
||||||
this.buttonPositionX = (self.windowDimensions.x - self.buttonPadding) / 2 - self.buttonWidth;
|
|
||||||
this.buttonPositionY = (self.windowDimensions.y - self.buttonHeight) - (self.buttonHeight + self.buttonPadding);
|
|
||||||
this.button = Overlays.addOverlay("image", {
|
|
||||||
x: self.buttonPositionX,
|
|
||||||
y: self.buttonPositionY,
|
|
||||||
width: self.buttonWidth,
|
|
||||||
height: self.buttonHeight,
|
|
||||||
imageURL: self.buttonImageURL,
|
|
||||||
visible: false,
|
|
||||||
alpha: 1.0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.getUserData = function() {
|
|
||||||
this.properties = Entities.getEntityProperties(this.entityId);
|
|
||||||
if (self.properties.userData) {
|
|
||||||
this.userData = JSON.parse(this.properties.userData);
|
|
||||||
} else {
|
|
||||||
this.userData = {};
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.update = function(deltaTime) {
|
this.initialize = function(entityId) {
|
||||||
|
//print(' should initialize' + entityId)
|
||||||
|
var properties = Entities.getEntityProperties(entityId);
|
||||||
|
if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) {
|
||||||
|
self.initTimeout = Script.setTimeout(function() {
|
||||||
|
// print(' no user data yet, try again in one second')
|
||||||
|
self.initialize(entityId);
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
self.distance = Vec3.distance(MyAvatar.position, Entities.getEntityProperties(self.entityId).position);
|
|
||||||
//print(self.distance);
|
|
||||||
if (!self.buttonShowing && self.distance < self.userData.showDistance) {
|
|
||||||
self.buttonShowing = true;
|
|
||||||
Overlays.editOverlay(self.button, {
|
|
||||||
visible: true
|
|
||||||
});
|
|
||||||
} else if (self.buttonShowing && self.distance > self.userData.showDistance) {
|
|
||||||
self.buttonShowing = false;
|
|
||||||
Overlays.editOverlay(self.button, {
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onClick = function(event) {
|
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({
|
|
||||||
x: event.x,
|
|
||||||
y: event.y
|
|
||||||
});
|
|
||||||
if (clickedOverlay === self.button) {
|
|
||||||
print("button was clicked");
|
|
||||||
if (self.sound.downloaded) {
|
|
||||||
print("play sound");
|
|
||||||
Audio.playSound(self.sound, self.soundOptions);
|
|
||||||
} else {
|
} else {
|
||||||
print("not downloaded");
|
//print(' userdata before parse attempt' + properties.userData)
|
||||||
|
self.userData = null;
|
||||||
|
try {
|
||||||
|
self.userData = JSON.parse(properties.userData);
|
||||||
|
} catch (err) {
|
||||||
|
// print(' error parsing json');
|
||||||
|
// print(' properties are:' + properties.userData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
self.addButton();
|
||||||
|
self.buttonShowing = false;
|
||||||
|
self.showDistance = self.userData.showDistance;
|
||||||
|
self.soundURL = baseURL + "Audio/" + self.userData.soundName + ".wav";
|
||||||
|
// print("distance = " + self.userData.showDistance + ", sound = " + self.soundURL);
|
||||||
|
self.soundOptions = {
|
||||||
|
stereo: true,
|
||||||
|
loop: false,
|
||||||
|
localOnly: true,
|
||||||
|
volume: 1
|
||||||
|
};
|
||||||
|
self.sound = SoundCache.getSound(this.soundURL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.unload = function() {
|
this.addButton = function() {
|
||||||
Overlays.deleteOverlay(self.button);
|
this.windowDimensions = Controller.getViewportDimensions();
|
||||||
Controller.mousePressEvent.disconnect(this.onClick);
|
this.buttonWidth = 100;
|
||||||
Script.update.disconnect(this.update);
|
this.buttonHeight = 100;
|
||||||
}
|
this.buttonPadding = 0;
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(this.onClick);
|
this.buttonPositionX = (self.windowDimensions.x - self.buttonPadding) / 2 - self.buttonWidth;
|
||||||
Script.update.connect(this.update);
|
this.buttonPositionY = (self.windowDimensions.y - self.buttonHeight) - (self.buttonHeight + self.buttonPadding);
|
||||||
|
this.button = Overlays.addOverlay("image", {
|
||||||
|
x: self.buttonPositionX,
|
||||||
|
y: self.buttonPositionY,
|
||||||
|
width: self.buttonWidth,
|
||||||
|
height: self.buttonHeight,
|
||||||
|
imageURL: self.buttonImageURL,
|
||||||
|
visible: false,
|
||||||
|
alpha: 1.0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
this.update = function(deltaTime) {
|
||||||
|
|
||||||
|
self.distance = Vec3.distance(MyAvatar.position, Entities.getEntityProperties(self.entityId).position);
|
||||||
|
//print(self.distance);
|
||||||
|
if (!self.buttonShowing && self.distance < self.userData.showDistance) {
|
||||||
|
self.buttonShowing = true;
|
||||||
|
Overlays.editOverlay(self.button, {
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
} else if (self.buttonShowing && self.distance > self.userData.showDistance) {
|
||||||
|
self.buttonShowing = false;
|
||||||
|
Overlays.editOverlay(self.button, {
|
||||||
|
visible: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onClick = function(event) {
|
||||||
|
var clickedOverlay = Overlays.getOverlayAtPoint({
|
||||||
|
x: event.x,
|
||||||
|
y: event.y
|
||||||
|
});
|
||||||
|
if (clickedOverlay === self.button) {
|
||||||
|
//print("button was clicked");
|
||||||
|
if (self.sound.downloaded) {
|
||||||
|
//print("play sound");
|
||||||
|
Audio.playSound(self.sound, self.soundOptions);
|
||||||
|
} else {
|
||||||
|
//print("not downloaded");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.unload = function() {
|
||||||
|
Overlays.deleteOverlay(self.button);
|
||||||
|
Controller.mousePressEvent.disconnect(this.onClick);
|
||||||
|
Script.update.disconnect(this.update);
|
||||||
|
if (this.initTimeout !== null) {
|
||||||
|
Script.clearTimeout(this.initTimeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.mousePressEvent.connect(this.onClick);
|
||||||
|
Script.update.connect(this.update);
|
||||||
|
|
||||||
|
});
|
|
@ -10,24 +10,51 @@
|
||||||
var self = this;
|
var self = this;
|
||||||
var baseURL = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
|
var baseURL = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
|
||||||
|
|
||||||
var version = 1;
|
var version = 2;
|
||||||
this.preload = function(entityId) {
|
this.preload = function(entityId) {
|
||||||
this.soundPlaying = null;
|
this.soundPlaying = null;
|
||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
self.getUserData();
|
self.initTimeout = null;
|
||||||
this.labelURL = baseURL + "GUI/labels_" + self.userData.name + ".png?" + version;
|
this.initialize(entityId);
|
||||||
this.showDistance = self.userData.showDistance;
|
|
||||||
this.soundURL = baseURL + "Audio/" + self.userData.name + ".wav";
|
|
||||||
this.soundOptions = {
|
}
|
||||||
stereo: true,
|
|
||||||
loop: false,
|
this.initialize = function(entityId) {
|
||||||
localOnly: true,
|
//print(' should initialize' + entityId)
|
||||||
volume: 0.035,
|
var properties = Entities.getEntityProperties(entityId);
|
||||||
position: this.position
|
if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) {
|
||||||
};
|
self.initTimeout = Script.setTimeout(function() {
|
||||||
this.sound = SoundCache.getSound(this.soundURL);
|
//print(' no user data yet, try again in one second')
|
||||||
this.buttonImageURL = baseURL + "GUI/GUI_audio.png?" + version;
|
self.initialize(entityId);
|
||||||
self.addButton();
|
}, 1000)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//print(' userdata before parse attempt' + properties.userData)
|
||||||
|
self.userData = null;
|
||||||
|
try {
|
||||||
|
self.userData = JSON.parse(properties.userData);
|
||||||
|
} catch (err) {
|
||||||
|
//print(' error parsing json');
|
||||||
|
//print(' properties are:' + properties.userData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.labelURL = baseURL + "GUI/labels_" + self.userData.name + ".png?" + version;
|
||||||
|
self.showDistance = self.userData.showDistance;
|
||||||
|
self.soundURL = baseURL + "Audio/" + self.userData.name + ".wav";
|
||||||
|
self.soundOptions = {
|
||||||
|
stereo: true,
|
||||||
|
loop: false,
|
||||||
|
localOnly: true,
|
||||||
|
volume: 0.035,
|
||||||
|
position: properties.position
|
||||||
|
};
|
||||||
|
self.sound = SoundCache.getSound(self.soundURL);
|
||||||
|
self.buttonImageURL = baseURL + "GUI/GUI_audio.png?" + version;
|
||||||
|
self.addButton();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addButton = function() {
|
this.addButton = function() {
|
||||||
|
@ -78,9 +105,8 @@
|
||||||
|
|
||||||
this.enterEntity = function(entityID) {
|
this.enterEntity = function(entityID) {
|
||||||
|
|
||||||
// self.getUserData();
|
// print("entering entity and showing" + self.labelURL);
|
||||||
print("entering entity and showing" + self.labelURL);
|
|
||||||
//self.buttonShowing = true;
|
|
||||||
Overlays.editOverlay(self.button, {
|
Overlays.editOverlay(self.button, {
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
|
@ -92,9 +118,8 @@
|
||||||
|
|
||||||
|
|
||||||
this.leaveEntity = function(entityID) {
|
this.leaveEntity = function(entityID) {
|
||||||
// self.getUserData();
|
// print("leaving entity " + self.userData.name);
|
||||||
// print("leaving entity " + self.userData.name);
|
|
||||||
//self.buttonShowing = false;
|
|
||||||
print(Overlays);
|
print(Overlays);
|
||||||
Overlays.editOverlay(self.button, {
|
Overlays.editOverlay(self.button, {
|
||||||
visible: false
|
visible: false
|
||||||
|
@ -110,16 +135,16 @@
|
||||||
y: event.y
|
y: event.y
|
||||||
});
|
});
|
||||||
if (clickedOverlay == self.button) {
|
if (clickedOverlay == self.button) {
|
||||||
print("button was clicked");
|
//print("button was clicked");
|
||||||
if (self.sound.downloaded) {
|
if (self.sound.downloaded) {
|
||||||
print("play sound");
|
// print("play sound");
|
||||||
|
|
||||||
Overlays.editOverlay(self.button, {
|
Overlays.editOverlay(self.button, {
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
this.soundPlaying = Audio.playSound(self.sound, self.soundOptions);
|
this.soundPlaying = Audio.playSound(self.sound, self.soundOptions);
|
||||||
} else {
|
} else {
|
||||||
print("not downloaded");
|
// print("not downloaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +154,9 @@
|
||||||
if (this.soundPlaying !== null) {
|
if (this.soundPlaying !== null) {
|
||||||
this.soundPlaying.stop();
|
this.soundPlaying.stop();
|
||||||
}
|
}
|
||||||
|
if (self.initTimeout !== null) {
|
||||||
|
Script.clearTimeout(self.initTimeout);
|
||||||
|
}
|
||||||
Controller.mousePressEvent.disconnect(this.onClick);
|
Controller.mousePressEvent.disconnect(this.onClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ getEntityUserData = function(id) {
|
||||||
try {
|
try {
|
||||||
results = JSON.parse(properties.userData);
|
results = JSON.parse(properties.userData);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logDebug(err);
|
// print('error parsing json');
|
||||||
logDebug(properties.userData);
|
// print('properties are:'+ properties.userData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results ? results : {};
|
return results ? results : {};
|
||||||
|
|
|
@ -14,50 +14,58 @@
|
||||||
this.entered = true;
|
this.entered = true;
|
||||||
|
|
||||||
this.preload = function(entityID) {
|
this.preload = function(entityID) {
|
||||||
|
|
||||||
this.entityId = entityID;
|
this.entityId = entityID;
|
||||||
|
this.initialize(entityID);
|
||||||
|
this.initTimeout = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initialize = function(entityID) {
|
||||||
|
// print(' should initialize')
|
||||||
var properties = Entities.getEntityProperties(entityID);
|
var properties = Entities.getEntityProperties(entityID);
|
||||||
portalDestination = properties.userData;
|
if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) {
|
||||||
animationURL = properties.modelURL;
|
self.initTimeout = Script.setTimeout(function() {
|
||||||
this.soundOptions = {
|
// print(' no user data yet, try again in one second')
|
||||||
stereo: true,
|
self.initialize(entityID);
|
||||||
loop: false,
|
}, 1000)
|
||||||
localOnly: false,
|
} else {
|
||||||
position: this.position,
|
// print(' has userData')
|
||||||
volume: 0.035
|
self.portalDestination = properties.userData;
|
||||||
};
|
animationURL = properties.modelURL;
|
||||||
|
self.soundOptions = {
|
||||||
this.teleportSound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/whoosh.wav");
|
stereo: true,
|
||||||
//print('Script.clearTimeout PRELOADING A ZOOM ENTITY')
|
loop: false,
|
||||||
print(" portal destination is " + portalDestination);
|
localOnly: false,
|
||||||
|
position: properties.position,
|
||||||
|
volume: 0.5
|
||||||
|
};
|
||||||
|
|
||||||
|
self.teleportSound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/whoosh.wav");
|
||||||
|
// print(" portal destination is " + self.portalDestination);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.enterEntity = function(entityID) {
|
this.enterEntity = function(entityID) {
|
||||||
print('Script.clearTimeout ENTERED A BOUNDARY ENTITY, SHOULD ZOOM', entityID)
|
//print('ENTERED A BOUNDARY ENTITY, SHOULD ZOOM', entityID)
|
||||||
|
|
||||||
var data = JSON.parse(Entities.getEntityProperties(this.entityId).userData);
|
var data = JSON.parse(Entities.getEntityProperties(this.entityId).userData);
|
||||||
|
//print('DATA IS::' + data)
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
print("Teleporting to (" + data.location.x + ", " + data.location.y + ", " + data.location.z + ")");
|
print("Teleporting to (" + data.location.x + ", " + data.location.y + ", " + data.location.z + ")");
|
||||||
if (self.teleportSound.downloaded) {
|
|
||||||
//print("play sound");
|
|
||||||
Audio.playSound(self.teleportSound, self.soundOptions);
|
|
||||||
} else {
|
|
||||||
//print("not downloaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.lookAt(data.target, data.location);
|
|
||||||
|
|
||||||
|
MyAvatar.position = data.location;
|
||||||
|
|
||||||
|
// if (data.hasOwnProperty('entryPoint') && data.hasOwnProperty('target')) {
|
||||||
|
// this.lookAtTarget(data.entryPoint, data.target);
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lookAt = function(targetPosition, avatarPosition) {
|
this.lookAtTarget = function(entryPoint,target) {
|
||||||
var direction = Vec3.normalize(Vec3.subtract(MyAvatar.position, targetPosition));
|
//print('SHOULD LOOK AT TARGET')
|
||||||
|
var direction = Vec3.normalize(Vec3.subtract(entryPoint, target));
|
||||||
var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, {
|
var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, {
|
||||||
x: 1,
|
x: 1,
|
||||||
y: 0,
|
y: 0,
|
||||||
|
@ -69,8 +77,10 @@
|
||||||
z: 0
|
z: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
MyAvatar.goToLocation(avatarPosition, true, yaw);
|
MyAvatar.goToLocation(entryPoint, true, yaw);
|
||||||
|
|
||||||
MyAvatar.headYaw = 0;
|
MyAvatar.headYaw = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,9 +91,18 @@
|
||||||
animationSettings: '{ "frameIndex": 1, "running": false }'
|
animationSettings: '{ "frameIndex": 1, "running": false }'
|
||||||
});
|
});
|
||||||
this.entered = false;
|
this.entered = false;
|
||||||
|
if (this.initTimeout !== null) {
|
||||||
|
Script.clearTimeout(this.initTimeout);
|
||||||
|
}
|
||||||
//playSound();
|
//playSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.unload = function() {
|
||||||
|
if (this.initTimeout !== null) {
|
||||||
|
Script.clearTimeout(this.initTimeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.hoverEnterEntity = function(entityID) {
|
this.hoverEnterEntity = function(entityID) {
|
||||||
Entities.editEntity(entityID, {
|
Entities.editEntity(entityID, {
|
||||||
animationURL: animationURL,
|
animationURL: animationURL,
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
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.1,
|
||||||
|
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.1,
|
||||||
|
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.1,
|
||||||
|
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.1,
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(function() {
|
||||||
|
soundMap.forEach(function(soundData) {
|
||||||
|
|
||||||
|
if (soundData.hasOwnProperty("injector")) {
|
||||||
|
soundData.injector.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soundData.hasOwnProperty("downloadTimer")) {
|
||||||
|
Script.clearInterval(soundData.downloadTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soundData.hasOwnProperty("playingInterval")) {
|
||||||
|
Script.clearInterval(soundData.playingInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
loadSounds();
|
||||||
|
startCheckDownloadedTimers();
|
|
@ -5,7 +5,7 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
|
|
||||||
var version = 1004;
|
var version = 1035;
|
||||||
var cellLayout;
|
var cellLayout;
|
||||||
var baseLocation = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
|
var baseLocation = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
|
||||||
|
|
||||||
|
@ -79,398 +79,138 @@ var locations = {
|
||||||
}, 1000]
|
}, 1000]
|
||||||
};
|
};
|
||||||
|
|
||||||
var scenes = [
|
var scenes = [{
|
||||||
{
|
name: "Cells",
|
||||||
name: "Cells",
|
objects: "",
|
||||||
objects: "",
|
location: locations.cells[0],
|
||||||
location: locations.cells[0],
|
entryPoint: locations.cells[1],
|
||||||
entryPoint: locations.cells[1],
|
zone: {
|
||||||
zone: {
|
dimensions: {
|
||||||
dimensions: {
|
x: 4000,
|
||||||
x: 4000,
|
y: 4000,
|
||||||
y: 4000,
|
z: 4000
|
||||||
z: 4000
|
|
||||||
},
|
|
||||||
light: {
|
|
||||||
r: 255,
|
|
||||||
g: 200,
|
|
||||||
b: 200
|
|
||||||
},
|
|
||||||
intensity: 1.1,
|
|
||||||
ambient: 0.7,
|
|
||||||
sun: true,
|
|
||||||
skybox: "cells_skybox_cross"
|
|
||||||
},
|
},
|
||||||
instances: [{
|
light: {
|
||||||
model: "Cell",
|
r: 255,
|
||||||
|
g: 200,
|
||||||
|
b: 200
|
||||||
|
},
|
||||||
|
intensity: 1.1,
|
||||||
|
ambient: 0.7,
|
||||||
|
sun: true,
|
||||||
|
skybox: "cells_skybox_cross"
|
||||||
|
},
|
||||||
|
instances: [{
|
||||||
|
model: "Cell",
|
||||||
|
dimensions: {
|
||||||
|
x: 550,
|
||||||
|
y: 620,
|
||||||
|
z: 550
|
||||||
|
},
|
||||||
|
offset: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
radius: 500,
|
||||||
|
number: 10,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
entryPoint: locations.cellLayout[1],
|
||||||
|
target: locations.cellLayout[1],
|
||||||
|
location: locations.cellLayout[1],
|
||||||
|
baseURL: baseLocation
|
||||||
|
}),
|
||||||
|
script: "zoom.js?" + version,
|
||||||
|
visible: true
|
||||||
|
}],
|
||||||
|
boundary: {
|
||||||
|
radius: locations.cells[2],
|
||||||
|
center: locations.cells[0],
|
||||||
|
location: locations.cellLayout[1],
|
||||||
|
target: locations.cellLayout[0]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: "CellLayout",
|
||||||
|
objects: cellLayout,
|
||||||
|
location: locations.cellLayout[0],
|
||||||
|
entryPoint: locations.cellLayout[1],
|
||||||
|
zone: {
|
||||||
|
dimensions: {
|
||||||
|
x: 4000,
|
||||||
|
y: 4000,
|
||||||
|
z: 4000
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
r: 247,
|
||||||
|
g: 233,
|
||||||
|
b: 220
|
||||||
|
},
|
||||||
|
intensity: 2.3,
|
||||||
|
ambient: 0.7,
|
||||||
|
sun: true,
|
||||||
|
skybox: "cosmos_skybox_blurred"
|
||||||
|
},
|
||||||
|
instances: [{
|
||||||
|
model: "translation",
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 550,
|
x: 10,
|
||||||
y: 620,
|
y: 16,
|
||||||
z: 550
|
z: 10
|
||||||
},
|
},
|
||||||
offset: {
|
offset: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
z: 0
|
z: 0
|
||||||
},
|
},
|
||||||
radius: 500,
|
radius: 300,
|
||||||
number: 10,
|
number: 7,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
},
|
||||||
|
target: locations.ribosome[1],
|
||||||
|
location: locations.ribosome[0],
|
||||||
|
baseURL: baseLocation
|
||||||
|
}),
|
||||||
|
script: "zoom.js?" + version,
|
||||||
|
visible: true
|
||||||
|
}, {
|
||||||
|
model: "vesicle",
|
||||||
|
dimensions: {
|
||||||
|
x: 60,
|
||||||
|
y: 60,
|
||||||
|
z: 60
|
||||||
|
},
|
||||||
|
randomSize: 10,
|
||||||
|
offset: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
radius: 1000,
|
||||||
|
number: 22,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
script: "moveRandomly.js?" + version,
|
script: "moveRandomly.js?" + version,
|
||||||
visible: true
|
visible: true
|
||||||
}],
|
}, { //golgi vesicles
|
||||||
boundary: {
|
model: "vesicle",
|
||||||
radius: locations.cells[2],
|
|
||||||
center: locations.cells[0],
|
|
||||||
location: locations.cellLayout[1],
|
|
||||||
target: locations.cellLayout[0]
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
name: "CellLayout",
|
|
||||||
objects: cellLayout,
|
|
||||||
location: locations.cellLayout[0],
|
|
||||||
entryPoint: locations.cellLayout[1],
|
|
||||||
zone: {
|
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 4000,
|
x: 10,
|
||||||
y: 4000,
|
y: 10,
|
||||||
z: 4000
|
z: 10
|
||||||
},
|
|
||||||
light: {
|
|
||||||
r: 247,
|
|
||||||
g: 233,
|
|
||||||
b: 220
|
|
||||||
},
|
|
||||||
intensity: 2.3,
|
|
||||||
ambient: 0.7,
|
|
||||||
sun: true,
|
|
||||||
skybox: "cosmos_skybox_blurred"
|
|
||||||
},
|
|
||||||
instances: [{
|
|
||||||
model: "translation",
|
|
||||||
dimensions: {
|
|
||||||
x: 10,
|
|
||||||
y: 16,
|
|
||||||
z: 10
|
|
||||||
},
|
|
||||||
offset: {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: 0
|
|
||||||
},
|
|
||||||
radius: 300,
|
|
||||||
number: 15,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
},
|
|
||||||
target: locations.ribosome[1],
|
|
||||||
location: locations.ribosome[0],
|
|
||||||
baseURL: baseLocation
|
|
||||||
}),
|
|
||||||
script: "zoom.js?" + version,
|
|
||||||
visible: true
|
|
||||||
}, {
|
|
||||||
model: "vesicle",
|
|
||||||
dimensions: {
|
|
||||||
x: 60,
|
|
||||||
y: 60,
|
|
||||||
z: 60
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: 0
|
|
||||||
},
|
|
||||||
radius: 1000,
|
|
||||||
number: 45,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
script: "moveRandomly.js?" + version,
|
|
||||||
visible: true
|
|
||||||
}, { //golgi vesicles
|
|
||||||
model: "vesicle",
|
|
||||||
dimensions: {
|
|
||||||
x: 10,
|
|
||||||
y: 10,
|
|
||||||
z: 10
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: -319,
|
|
||||||
y: 66,
|
|
||||||
z: 976
|
|
||||||
},
|
|
||||||
radius: 140,
|
|
||||||
number: 20,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
script: "",
|
|
||||||
visible: true
|
|
||||||
}, { //golgi vesicles
|
|
||||||
model: "vesicle",
|
|
||||||
dimensions: {
|
|
||||||
x: 15,
|
|
||||||
y: 15,
|
|
||||||
z: 15
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: -319,
|
|
||||||
y: 66,
|
|
||||||
z: 976
|
|
||||||
},
|
|
||||||
radius: 115,
|
|
||||||
number: 15,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
script: "moveRandomly.js?" + version,
|
|
||||||
visible: true
|
|
||||||
}, {
|
|
||||||
model: "vesicle",
|
|
||||||
dimensions: {
|
|
||||||
x: 50,
|
|
||||||
y: 50,
|
|
||||||
z: 50
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: 0
|
|
||||||
},
|
|
||||||
radius: 600,
|
|
||||||
number: 30,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
script: "",
|
|
||||||
visible: true
|
|
||||||
}, { //outer vesicles
|
|
||||||
model: "vesicle",
|
|
||||||
dimensions: {
|
|
||||||
x: 60,
|
|
||||||
y: 60,
|
|
||||||
z: 60
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: 0
|
|
||||||
},
|
|
||||||
radius: 1600,
|
|
||||||
number: 45,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
script: "",
|
|
||||||
visible: true
|
|
||||||
}, { //outer vesicles
|
|
||||||
model: "vesicle",
|
|
||||||
dimensions: {
|
|
||||||
x: 40,
|
|
||||||
y: 40,
|
|
||||||
z: 40
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: 0
|
|
||||||
},
|
|
||||||
radius: 1400,
|
|
||||||
number: 45,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
script: "moveRandomly.js?" + version,
|
|
||||||
visible: true
|
|
||||||
}, { //outer vesicles
|
|
||||||
model: "vesicle",
|
|
||||||
dimensions: {
|
|
||||||
x: 80,
|
|
||||||
y: 80,
|
|
||||||
z: 80
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: 0
|
|
||||||
},
|
|
||||||
radius: 1800,
|
|
||||||
number: 45,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
script: "moveRandomly.js?" + version,
|
|
||||||
visible: true
|
|
||||||
},
|
|
||||||
// {//wigglies
|
|
||||||
// model:"wiggly",
|
|
||||||
// dimensions:{x:320,y:40,z:160},
|
|
||||||
// randomSize: 10,
|
|
||||||
// offset:{x:0,y:0,z:0},
|
|
||||||
// radius:1800,
|
|
||||||
// number:50,
|
|
||||||
// userData:"",
|
|
||||||
// script:"moveRandomly",
|
|
||||||
// visible:true
|
|
||||||
// },
|
|
||||||
//// {//wigglies
|
|
||||||
// model:"wiggly",
|
|
||||||
// dimensions:{x:640,y:80,z:320},
|
|
||||||
// randomSize: 10,
|
|
||||||
// offset:{x:0,y:0,z:0},
|
|
||||||
// radius:2100,
|
|
||||||
// number:50,
|
|
||||||
// userData:"",
|
|
||||||
// script:"moveRandomly",
|
|
||||||
// visible:true
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
model: "hexokinase",
|
|
||||||
dimensions: {
|
|
||||||
x: 3,
|
|
||||||
y: 4,
|
|
||||||
z: 3
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: 236,
|
|
||||||
y: 8,
|
|
||||||
z: 771
|
|
||||||
},
|
|
||||||
radius: 80,
|
|
||||||
number: 15,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
},
|
|
||||||
target: locations.hexokinase[1],
|
|
||||||
location: locations.hexokinase[0],
|
|
||||||
baseURL: baseLocation
|
|
||||||
}),
|
|
||||||
script: "zoom.js?" + version,
|
|
||||||
visible: true
|
|
||||||
}, {
|
|
||||||
model: "pfructo_kinase",
|
|
||||||
dimensions: {
|
|
||||||
x: 3,
|
|
||||||
y: 4,
|
|
||||||
z: 3
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: 236,
|
|
||||||
y: 8,
|
|
||||||
z: 771
|
|
||||||
},
|
|
||||||
radius: 60,
|
|
||||||
number: 15,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
script: "",
|
|
||||||
visible: true
|
|
||||||
}, {
|
|
||||||
model: "glucose_isomerase",
|
|
||||||
dimensions: {
|
|
||||||
x: 3,
|
|
||||||
y: 4,
|
|
||||||
z: 3
|
|
||||||
},
|
|
||||||
randomSize: 10,
|
|
||||||
offset: {
|
|
||||||
x: 236,
|
|
||||||
y: 8,
|
|
||||||
z: 771
|
|
||||||
},
|
|
||||||
radius: 70,
|
|
||||||
number: 15,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
script: "",
|
|
||||||
visible: true
|
|
||||||
}
|
|
||||||
// {
|
|
||||||
// model:"NPC",
|
|
||||||
// dimensions:{x:20,y:20,z:20},
|
|
||||||
// randomSize: 10,
|
|
||||||
// offset:{x:208.593693,y:6.113100222,z:153.3202277},
|
|
||||||
// radius:520,
|
|
||||||
// number:25,
|
|
||||||
// userData: "",
|
|
||||||
// script:"",
|
|
||||||
// visible:true
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
],
|
|
||||||
boundary: {
|
|
||||||
radius: locations.cellLayout[2],
|
|
||||||
center: locations.cellLayout[0],
|
|
||||||
location: locations.cells[1],
|
|
||||||
target: locations.cells[0]
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
name: "Ribosome",
|
|
||||||
objects: "",
|
|
||||||
location: locations.ribosome[0],
|
|
||||||
entryPoint: locations.ribosome[1],
|
|
||||||
zone: {
|
|
||||||
dimensions: {
|
|
||||||
x: 4000,
|
|
||||||
y: 4000,
|
|
||||||
z: 4000
|
|
||||||
},
|
|
||||||
light: {
|
|
||||||
r: 250,
|
|
||||||
g: 185,
|
|
||||||
b: 182
|
|
||||||
},
|
|
||||||
intensity: 0.6,
|
|
||||||
ambient: 2.9,
|
|
||||||
sun: true,
|
|
||||||
skybox: "ribosome_skybox"
|
|
||||||
},
|
|
||||||
instances: [{
|
|
||||||
model: "translation_highres",
|
|
||||||
dimensions: {
|
|
||||||
x: 500,
|
|
||||||
y: 500,
|
|
||||||
z: 200
|
|
||||||
},
|
},
|
||||||
|
randomSize: 10,
|
||||||
offset: {
|
offset: {
|
||||||
x: 0,
|
x: -319,
|
||||||
y: 0,
|
y: 66,
|
||||||
z: 0
|
z: 976
|
||||||
},
|
},
|
||||||
radius: 1,
|
radius: 140,
|
||||||
number: 1,
|
number: 10,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
grabbable: false
|
grabbable: false
|
||||||
|
@ -478,48 +218,43 @@ var scenes = [
|
||||||
}),
|
}),
|
||||||
script: "",
|
script: "",
|
||||||
visible: true
|
visible: true
|
||||||
}],
|
}, { //golgi vesicles
|
||||||
boundary: {
|
model: "vesicle",
|
||||||
radius: locations.ribosome[2],
|
|
||||||
center: locations.ribosome[0],
|
|
||||||
location: locations.translation[1],
|
|
||||||
target: locations.translation[0]
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
name: "Hexokinase",
|
|
||||||
objects: "",
|
|
||||||
location: locations.hexokinase[0],
|
|
||||||
entryPoint: locations.hexokinase[1],
|
|
||||||
zone: {
|
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 4000,
|
x: 15,
|
||||||
y: 4000,
|
y: 15,
|
||||||
z: 4000
|
z: 15
|
||||||
},
|
},
|
||||||
light: {
|
randomSize: 10,
|
||||||
r: 255,
|
offset: {
|
||||||
g: 255,
|
x: -319,
|
||||||
b: 255
|
y: 66,
|
||||||
|
z: 976
|
||||||
},
|
},
|
||||||
intensity: 0.6,
|
radius: 115,
|
||||||
ambient: 0.6,
|
number: 7,
|
||||||
sun: true,
|
userData: JSON.stringify({
|
||||||
skybox: "hexokinase_skybox"
|
grabbableKey: {
|
||||||
},
|
grabbable: false
|
||||||
instances: [{
|
}
|
||||||
model: "hexokinase_highres",
|
}),
|
||||||
|
script: "moveRandomly.js?" + version,
|
||||||
|
visible: true
|
||||||
|
}, {
|
||||||
|
model: "vesicle",
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 600,
|
x: 50,
|
||||||
y: 600,
|
y: 50,
|
||||||
z: 600
|
z: 50
|
||||||
},
|
},
|
||||||
|
randomSize: 10,
|
||||||
offset: {
|
offset: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
z: 0
|
z: 0
|
||||||
},
|
},
|
||||||
radius: 1,
|
radius: 600,
|
||||||
number: 1,
|
number: 15,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
grabbable: false
|
grabbable: false
|
||||||
|
@ -527,15 +262,288 @@ var scenes = [
|
||||||
}),
|
}),
|
||||||
script: "",
|
script: "",
|
||||||
visible: true
|
visible: true
|
||||||
}],
|
}, { //outer vesicles
|
||||||
boundary: {
|
model: "vesicle",
|
||||||
radius: locations.hexokinase[2],
|
dimensions: {
|
||||||
center: locations.hexokinase[0],
|
x: 60,
|
||||||
location: locations.mitochondria[1],
|
y: 60,
|
||||||
target: locations.mitochondria[0]
|
z: 60
|
||||||
|
},
|
||||||
|
randomSize: 10,
|
||||||
|
offset: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
radius: 1600,
|
||||||
|
number: 22,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
script: "",
|
||||||
|
visible: true
|
||||||
|
}, { //outer vesicles
|
||||||
|
model: "vesicle",
|
||||||
|
dimensions: {
|
||||||
|
x: 40,
|
||||||
|
y: 40,
|
||||||
|
z: 40
|
||||||
|
},
|
||||||
|
randomSize: 10,
|
||||||
|
offset: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
radius: 1400,
|
||||||
|
number: 22,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
script: "moveRandomly.js?" + version,
|
||||||
|
visible: true
|
||||||
|
}, { //outer vesicles
|
||||||
|
model: "vesicle",
|
||||||
|
dimensions: {
|
||||||
|
x: 80,
|
||||||
|
y: 80,
|
||||||
|
z: 80
|
||||||
|
},
|
||||||
|
randomSize: 10,
|
||||||
|
offset: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
radius: 1800,
|
||||||
|
number: 22,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
script: "moveRandomly.js?" + version,
|
||||||
|
visible: true
|
||||||
|
},
|
||||||
|
// {//wigglies
|
||||||
|
// model:"wiggly",
|
||||||
|
// dimensions:{x:320,y:40,z:160},
|
||||||
|
// randomSize: 10,
|
||||||
|
// offset:{x:0,y:0,z:0},
|
||||||
|
// radius:1800,
|
||||||
|
// number:50,
|
||||||
|
// userData:"",
|
||||||
|
// script:"moveRandomly",
|
||||||
|
// visible:true
|
||||||
|
// },
|
||||||
|
//// {//wigglies
|
||||||
|
// model:"wiggly",
|
||||||
|
// dimensions:{x:640,y:80,z:320},
|
||||||
|
// randomSize: 10,
|
||||||
|
// offset:{x:0,y:0,z:0},
|
||||||
|
// radius:2100,
|
||||||
|
// number:50,
|
||||||
|
// userData:"",
|
||||||
|
// script:"moveRandomly",
|
||||||
|
// visible:true
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
model: "hexokinase",
|
||||||
|
dimensions: {
|
||||||
|
x: 3,
|
||||||
|
y: 4,
|
||||||
|
z: 3
|
||||||
|
},
|
||||||
|
randomSize: 10,
|
||||||
|
offset: {
|
||||||
|
x: 236,
|
||||||
|
y: 8,
|
||||||
|
z: 771
|
||||||
|
},
|
||||||
|
radius: 80,
|
||||||
|
number: 7,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
},
|
||||||
|
target: locations.hexokinase[1],
|
||||||
|
location: locations.hexokinase[0],
|
||||||
|
baseURL: baseLocation
|
||||||
|
}),
|
||||||
|
script: "zoom.js?" + version,
|
||||||
|
visible: true
|
||||||
|
}, {
|
||||||
|
model: "pfructo_kinase",
|
||||||
|
dimensions: {
|
||||||
|
x: 3,
|
||||||
|
y: 4,
|
||||||
|
z: 3
|
||||||
|
},
|
||||||
|
randomSize: 10,
|
||||||
|
offset: {
|
||||||
|
x: 236,
|
||||||
|
y: 8,
|
||||||
|
z: 771
|
||||||
|
},
|
||||||
|
radius: 60,
|
||||||
|
number: 7,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
},
|
||||||
|
target: locations.hexokinase[1],
|
||||||
|
location: locations.hexokinase[0],
|
||||||
|
}),
|
||||||
|
script: "zoom.js?" + version,
|
||||||
|
visible: true
|
||||||
|
}, {
|
||||||
|
model: "glucose_isomerase",
|
||||||
|
dimensions: {
|
||||||
|
x: 3,
|
||||||
|
y: 4,
|
||||||
|
z: 3
|
||||||
|
},
|
||||||
|
randomSize: 10,
|
||||||
|
offset: {
|
||||||
|
x: 236,
|
||||||
|
y: 8,
|
||||||
|
z: 771
|
||||||
|
},
|
||||||
|
radius: 70,
|
||||||
|
number: 7,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
},
|
||||||
|
target: locations.hexokinase[1],
|
||||||
|
location: locations.hexokinase[0],
|
||||||
|
}),
|
||||||
|
script: "zoom.js?" + version,
|
||||||
|
visible: true
|
||||||
}
|
}
|
||||||
|
// {
|
||||||
|
// model:"NPC",
|
||||||
|
// dimensions:{x:20,y:20,z:20},
|
||||||
|
// randomSize: 10,
|
||||||
|
// offset:{x:208.593693,y:6.113100222,z:153.3202277},
|
||||||
|
// radius:520,
|
||||||
|
// number:25,
|
||||||
|
// userData: "",
|
||||||
|
// script:"",
|
||||||
|
// visible:true
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
boundary: {
|
||||||
|
radius: locations.cellLayout[2],
|
||||||
|
center: locations.cellLayout[0],
|
||||||
|
location: locations.cells[1],
|
||||||
|
target: locations.cells[0]
|
||||||
}
|
}
|
||||||
];
|
}, {
|
||||||
|
name: "Ribosome",
|
||||||
|
objects: "",
|
||||||
|
location: locations.ribosome[0],
|
||||||
|
entryPoint: locations.ribosome[1],
|
||||||
|
zone: {
|
||||||
|
dimensions: {
|
||||||
|
x: 4000,
|
||||||
|
y: 4000,
|
||||||
|
z: 4000
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
r: 250,
|
||||||
|
g: 185,
|
||||||
|
b: 182
|
||||||
|
},
|
||||||
|
intensity: 0.6,
|
||||||
|
ambient: 2.9,
|
||||||
|
sun: true,
|
||||||
|
skybox: "ribosome_skybox"
|
||||||
|
},
|
||||||
|
instances: [{
|
||||||
|
model: "translation_highres",
|
||||||
|
dimensions: {
|
||||||
|
x: 500,
|
||||||
|
y: 500,
|
||||||
|
z: 200
|
||||||
|
},
|
||||||
|
offset: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
radius: 1,
|
||||||
|
number: 1,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
script: "",
|
||||||
|
visible: true
|
||||||
|
}],
|
||||||
|
boundary: {
|
||||||
|
radius: locations.ribosome[2],
|
||||||
|
center: locations.ribosome[0],
|
||||||
|
location: locations.translation[1],
|
||||||
|
target: locations.translation[0]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: "Hexokinase",
|
||||||
|
objects: "",
|
||||||
|
location: locations.hexokinase[0],
|
||||||
|
entryPoint: locations.hexokinase[1],
|
||||||
|
zone: {
|
||||||
|
dimensions: {
|
||||||
|
x: 4000,
|
||||||
|
y: 4000,
|
||||||
|
z: 4000
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
r: 255,
|
||||||
|
g: 255,
|
||||||
|
b: 255
|
||||||
|
},
|
||||||
|
intensity: 0.6,
|
||||||
|
ambient: 0.6,
|
||||||
|
sun: true,
|
||||||
|
skybox: "hexokinase_skybox"
|
||||||
|
},
|
||||||
|
instances: [{
|
||||||
|
model: "hexokinase_highres",
|
||||||
|
dimensions: {
|
||||||
|
x: 600,
|
||||||
|
y: 600,
|
||||||
|
z: 600
|
||||||
|
},
|
||||||
|
offset: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
radius: 1,
|
||||||
|
number: 1,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
script: "",
|
||||||
|
visible: true
|
||||||
|
}],
|
||||||
|
boundary: {
|
||||||
|
radius: locations.hexokinase[2],
|
||||||
|
center: locations.hexokinase[0],
|
||||||
|
location: locations.mitochondria[1],
|
||||||
|
target: locations.mitochondria[0]
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
function ImportScene(scene) {
|
function ImportScene(scene) {
|
||||||
|
@ -594,8 +602,6 @@ function ImportScene(scene) {
|
||||||
CreateInstances(scene);
|
CreateInstances(scene);
|
||||||
CreateBoundary(scene);
|
CreateBoundary(scene);
|
||||||
|
|
||||||
CreateBackgroundAudio(scene.name, scene.location, scene.dimensions);
|
|
||||||
|
|
||||||
// print("done " + scene.name);
|
// print("done " + scene.name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -637,12 +643,13 @@ function createLayoutLights() {
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CreateNavigationButton(scene, number) {
|
function CreateNavigationButton(scene, number) {
|
||||||
// print('NAV NAVIGATION CREATING NAV!!' +scene.name + " " + number)
|
// print('NAV NAVIGATION CREATING NAV!!' +scene.name + " " + number)
|
||||||
|
|
||||||
|
|
||||||
Entities.addEntity({
|
Entities.addEntity({
|
||||||
type: "Sphere",
|
type: "Box",
|
||||||
name: scene.name + " navigation button",
|
name: scene.name + " navigation button",
|
||||||
color: {
|
color: {
|
||||||
red: 200,
|
red: 200,
|
||||||
|
@ -650,9 +657,9 @@ function CreateNavigationButton(scene, number) {
|
||||||
blue: 0
|
blue: 0
|
||||||
},
|
},
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 10,
|
x: 16000,
|
||||||
y: 10,
|
y: 16000,
|
||||||
z: 10
|
z: 16000
|
||||||
},
|
},
|
||||||
visible: false,
|
visible: false,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
|
@ -665,10 +672,13 @@ function CreateNavigationButton(scene, number) {
|
||||||
grabbable: false
|
grabbable: false
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
// position:{x:3000,y:13500,z:3000},
|
position: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
script: baseLocation + "Scripts/navigationButton.js?" + version,
|
script: baseLocation + "Scripts/navigationButton.js?" + version,
|
||||||
collisionless: true,
|
collisionless: true,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -811,7 +821,7 @@ function CreateInstances(scene) {
|
||||||
}, idBounds, 150);
|
}, idBounds, 150);
|
||||||
|
|
||||||
}
|
}
|
||||||
print('Script.clearTimeout SCRIPT AT CREATE ENTITY: ' + script)
|
//print('SCRIPT AT CREATE ENTITY: ' + script)
|
||||||
CreateEntity(scene.instances[i].model, position, rotation, scene.instances[i].dimensions, url, script, scene.instances[i].userData, scene.instances[i].visible);
|
CreateEntity(scene.instances[i].model, position, rotation, scene.instances[i].dimensions, url, script, scene.instances[i].userData, scene.instances[i].visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,27 +855,6 @@ function CreateIdentification(name, position, rotation, dimensions, showDistance
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CreateBackgroundAudio(name, position) {
|
|
||||||
Entities.addEntity({
|
|
||||||
type: "Sphere",
|
|
||||||
name: "Location " + name + " background audio",
|
|
||||||
dimensions: {
|
|
||||||
x: 4000,
|
|
||||||
y: 4000,
|
|
||||||
z: 4000
|
|
||||||
},
|
|
||||||
position: position,
|
|
||||||
visible: false,
|
|
||||||
userData: JSON.stringify({
|
|
||||||
name: name,
|
|
||||||
baseURL: baseLocation
|
|
||||||
}),
|
|
||||||
script: baseLocation + "Scripts/playBackgroundAudio.js?" + version,
|
|
||||||
collisionless: true,
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPointOnSphereOfRadius(radius, number, totalNumber) {
|
function getPointOnSphereOfRadius(radius, number, totalNumber) {
|
||||||
|
|
||||||
|
@ -890,7 +879,7 @@ function getPointOnSphereOfRadius(radius, number, totalNumber) {
|
||||||
// print("inc " + inc + " off " + off + " y " + y + " r " + r + " phi " + phi);
|
// print("inc " + inc + " off " + off + " y " + y + " r " + r + " phi " + phi);
|
||||||
|
|
||||||
if (isNaN(r)) {
|
if (isNaN(r)) {
|
||||||
print("r is not a number");
|
//print("r is not a number");
|
||||||
r = 1;
|
r = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -913,7 +902,7 @@ function CreateEntity(name, position, rotation, dimensions, url, script, userDat
|
||||||
scriptLocation = baseLocation + "Scripts/" + script;
|
scriptLocation = baseLocation + "Scripts/" + script;
|
||||||
}
|
}
|
||||||
|
|
||||||
print('Script.clearTimeout SCRIPT LOCATION IN CREATE ENTITY' + scriptLocation)
|
//print(' SCRIPT LOCATION IN CREATE ENTITY' + scriptLocation)
|
||||||
Entities.addEntity({
|
Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
name: name,
|
name: name,
|
||||||
|
|
Loading…
Reference in a new issue