mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 11:26:27 +02:00
cleanup and fix script paths to get random movement working again
This commit is contained in:
parent
0e036d3e2c
commit
514edee3f1
11 changed files with 190 additions and 220 deletions
|
@ -7,10 +7,18 @@ var spriteDimensions = {
|
||||||
var sprite;
|
var sprite;
|
||||||
var isMouseDown = false;
|
var isMouseDown = false;
|
||||||
var RAD_TO_DEG = 180.0 / Math.PI;
|
var RAD_TO_DEG = 180.0 / Math.PI;
|
||||||
var Y_AXIS = { x: 0, y: 1, z: 0 };
|
var Y_AXIS = {
|
||||||
var X_AXIS = { x: 1, y: 0, z: 0 };
|
x: 0,
|
||||||
|
y: 1,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
|
var X_AXIS = {
|
||||||
|
x: 1,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
|
|
||||||
function MakeSprite () {
|
function MakeSprite() {
|
||||||
sprite = Entities.addEntity({
|
sprite = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
name: "sprite",
|
name: "sprite",
|
||||||
|
@ -21,9 +29,9 @@ function MakeSprite () {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdateOrientation (event) {
|
function UpdateOrientation(event) {
|
||||||
if (isMouseDown && event.isRightButton) {
|
if (isMouseDown && event.isRightButton) {
|
||||||
|
|
||||||
var direction,
|
var direction,
|
||||||
yaw,
|
yaw,
|
||||||
pitch,
|
pitch,
|
||||||
|
@ -33,7 +41,7 @@ function UpdateOrientation (event) {
|
||||||
yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * RAD_TO_DEG, Y_AXIS);
|
yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * RAD_TO_DEG, Y_AXIS);
|
||||||
pitch = Quat.angleAxis(Math.asin(-direction.y) * RAD_TO_DEG, X_AXIS);
|
pitch = Quat.angleAxis(Math.asin(-direction.y) * RAD_TO_DEG, X_AXIS);
|
||||||
rot = Quat.multiply(yaw, pitch);
|
rot = Quat.multiply(yaw, pitch);
|
||||||
|
|
||||||
var avatar = Quat.safeEulerAngles(MyAvatar.orientation);
|
var avatar = Quat.safeEulerAngles(MyAvatar.orientation);
|
||||||
var printRot = Quat.safeEulerAngles(rot);
|
var printRot = Quat.safeEulerAngles(rot);
|
||||||
print("avatar = (" + avatar.x + ", " + avatar.y + ", " + avatar.z + ")");
|
print("avatar = (" + avatar.x + ", " + avatar.y + ", " + avatar.z + ")");
|
||||||
|
@ -55,4 +63,4 @@ function OnMouseUp(event) {
|
||||||
MakeSprite();
|
MakeSprite();
|
||||||
Controller.mouseMoveEvent.connect(UpdateOrientation);
|
Controller.mouseMoveEvent.connect(UpdateOrientation);
|
||||||
Controller.mousePressEvent.connect(OnMouseDown);
|
Controller.mousePressEvent.connect(OnMouseDown);
|
||||||
Controller.mouseReleaseEvent.connect(OnMouseUp);
|
Controller.mouseReleaseEvent.connect(OnMouseUp);
|
|
@ -9,7 +9,7 @@
|
||||||
var baseURL = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
|
var baseURL = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.preload = function(entityId) {
|
this.preload = function(entityId) {
|
||||||
|
|
||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
function deleteAllInRadius (r)
|
function deleteAllInRadius(r) {
|
||||||
{
|
var n = 0;
|
||||||
var n = 0;
|
|
||||||
var arrayFound = Entities.findEntities(MyAvatar.position, r);
|
var arrayFound = Entities.findEntities(MyAvatar.position, r);
|
||||||
for (var i = 0; i < arrayFound.length; i++) {
|
for (var i = 0; i < arrayFound.length; i++) {
|
||||||
Entities.deleteEntity(arrayFound[i]);
|
Entities.deleteEntity(arrayFound[i]);
|
||||||
}
|
}
|
||||||
print("deleted " + arrayFound.length + " entities");
|
print("deleted " + arrayFound.length + " entities");
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAllInRadius(100000);
|
deleteAllInRadius(100000);
|
|
@ -1,15 +1,14 @@
|
||||||
var scriptName = "Controller";
|
var scriptName = "Controller";
|
||||||
|
|
||||||
function findScriptsInRadius(r)
|
function findScriptsInRadius(r) {
|
||||||
{
|
var n = 0;
|
||||||
var n = 0;
|
|
||||||
var arrayFound = Entities.findEntities(MyAvatar.position, r);
|
var arrayFound = Entities.findEntities(MyAvatar.position, r);
|
||||||
for (var i = 0; i < arrayFound.length; i++) {
|
for (var i = 0; i < arrayFound.length; i++) {
|
||||||
if (Entities.getEntityProperties(arrayFound[i]).script.indexOf(scriptName) != -1) {
|
if (Entities.getEntityProperties(arrayFound[i]).script.indexOf(scriptName) != -1) {
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("found " + n + " copies of " + scriptName);
|
print("found " + n + " copies of " + scriptName);
|
||||||
}
|
}
|
||||||
|
|
||||||
findScriptsInRadius(100000);
|
findScriptsInRadius(100000);
|
|
@ -1,68 +1,76 @@
|
||||||
(function(){
|
(function() {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.preload = function(entityId) {
|
this.preload = function(entityId) {
|
||||||
|
|
||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
this.updateInterval = 100;
|
this.updateInterval = 100;
|
||||||
this.posFrame = 0;
|
this.posFrame = 0;
|
||||||
this.rotFrame = 0;
|
this.rotFrame = 0;
|
||||||
this.posInterval=100;
|
this.posInterval = 100;
|
||||||
this.rotInterval=100;
|
this.rotInterval = 100;
|
||||||
this.minVelocity = 1;
|
this.minVelocity = 1;
|
||||||
this.maxVelocity = 5;
|
this.maxVelocity = 5;
|
||||||
this.minAngularVelocity = 0.01;
|
this.minAngularVelocity = 0.01;
|
||||||
this.maxAngularVelocity = 0.03;
|
this.maxAngularVelocity = 0.03;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update = function(deltaTime) {
|
this.update = function(deltaTime) {
|
||||||
|
|
||||||
self.posFrame++;
|
self.posFrame++;
|
||||||
self.rotFrame++;
|
self.rotFrame++;
|
||||||
|
|
||||||
if (self.posFrame > self.posInterval) {
|
if (self.posFrame > self.posInterval) {
|
||||||
|
|
||||||
self.posInterval = 100 * Math.random() + 300;
|
self.posInterval = 100 * Math.random() + 300;
|
||||||
self.posFrame = 0;
|
self.posFrame = 0;
|
||||||
|
|
||||||
var magnitudeV = self.maxVelocity;
|
var magnitudeV = self.maxVelocity;
|
||||||
var directionV = {x: Math.random() - 0.5, y: Math.random() - 0.5, z: Math.random() - 0.5};
|
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);
|
// print("POS magnitude is " + magnitudeV + " and direction is " + directionV.x);
|
||||||
Entities.editEntity(self.entityId, {
|
Entities.editEntity(self.entityId, {
|
||||||
velocity: Vec3.multiply(magnitudeV, Vec3.normalize(directionV))
|
velocity: Vec3.multiply(magnitudeV, Vec3.normalize(directionV))
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.rotFrame > self.rotInterval) {
|
if (self.rotFrame > self.rotInterval) {
|
||||||
|
|
||||||
self.rotInterval = 100 * Math.random() +250;
|
self.rotInterval = 100 * Math.random() + 250;
|
||||||
self.rotFrame = 0;
|
self.rotFrame = 0;
|
||||||
|
|
||||||
var magnitudeAV = self.maxAngularVelocity;
|
var magnitudeAV = self.maxAngularVelocity;
|
||||||
|
|
||||||
var directionAV = {x: Math.random() - 0.5, y: Math.random() - 0.5, z: Math.random() - 0.5};
|
var directionAV = {
|
||||||
// print("ROT magnitude is " + magnitudeAV + " and direction is " + directionAV.x);
|
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, {
|
Entities.editEntity(self.entityId, {
|
||||||
angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV))
|
angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV))
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unload = function() {
|
this.unload = function() {
|
||||||
|
|
||||||
Script.update.disconnect(this.update);
|
Script.update.disconnect(this.update);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.update.connect(this.update);
|
Script.update.connect(this.update);
|
||||||
|
|
||||||
})
|
})
|
|
@ -1,49 +0,0 @@
|
||||||
(function(){
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.preload = function(entityId) {
|
|
||||||
|
|
||||||
this.entityId = entityId;
|
|
||||||
this.updateInterval = 30;
|
|
||||||
this.frame = 0;
|
|
||||||
|
|
||||||
this.minVelocity = 0.15;
|
|
||||||
this.maxVelocity = 0.35;
|
|
||||||
this.minAngularVelocity = 0.3;
|
|
||||||
this.maxAngularVelocity = 0.7;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.update = function(deltaTime) {
|
|
||||||
|
|
||||||
self.frame++;
|
|
||||||
|
|
||||||
if (self.frame > self.updateInterval) {
|
|
||||||
|
|
||||||
self.updateInterval = 20 * Math.random() + 0;
|
|
||||||
self.frame = 0;
|
|
||||||
|
|
||||||
var magnitudeV = (self.maxVelocity - self.minVelocity) * Math.random() + self.minVelocity;
|
|
||||||
var magnitudeAV = (self.maxAngularVelocity - self.minAngularVelocity) * Math.random() + self.minAngularVelocity;
|
|
||||||
var directionV = {x: Math.random() - 0.5, y: Math.random() - 0.5, z: Math.random() - 0.5};
|
|
||||||
var directionAV = {x: Math.random() - 0.5, y: Math.random() - 0.5, z: Math.random() - 0.5};
|
|
||||||
|
|
||||||
Entities.editEntity(self.entityId, {
|
|
||||||
velocity: Vec3.multiply(magnitudeV, Vec3.normalize(directionV)),
|
|
||||||
angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV))
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.unload = function() {
|
|
||||||
|
|
||||||
Script.update.disconnect(this.update);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Script.update.connect(this.update);
|
|
||||||
|
|
||||||
})
|
|
|
@ -1,5 +1,5 @@
|
||||||
(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";
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
stereo: true,
|
stereo: true,
|
||||||
loop: false,
|
loop: false,
|
||||||
localOnly: true,
|
localOnly: true,
|
||||||
volume:0.5
|
volume: 0.5
|
||||||
};
|
};
|
||||||
this.sound = SoundCache.getSound(this.soundURL);
|
this.sound = SoundCache.getSound(this.soundURL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
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 = 1;
|
||||||
this.preload = function(entityId) {
|
this.preload = function(entityId) {
|
||||||
this.soundPlaying=null;
|
this.soundPlaying = null;
|
||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
self.getUserData();
|
self.getUserData();
|
||||||
this.labelURL = baseURL + "GUI/labels_" + self.userData.name + ".png?" + version;
|
this.labelURL = baseURL + "GUI/labels_" + self.userData.name + ".png?" + version;
|
||||||
|
@ -119,7 +119,7 @@ var baseURL = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/"
|
||||||
|
|
||||||
this.unload = function() {
|
this.unload = function() {
|
||||||
Overlays.deleteOverlay(self.button);
|
Overlays.deleteOverlay(self.button);
|
||||||
if(this.soundPlaying!==null) {
|
if (this.soundPlaying !== null) {
|
||||||
this.soundPlaying.stop();
|
this.soundPlaying.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
setEntityUserData = function(id, data) {
|
setEntityUserData = function(id, data) {
|
||||||
var json = JSON.stringify(data)
|
var json = JSON.stringify(data)
|
||||||
Entities.editEntity(id, { userData: json });
|
Entities.editEntity(id, {
|
||||||
|
userData: json
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME do non-destructive modification of the existing user data
|
// FIXME do non-destructive modification of the existing user data
|
||||||
|
@ -10,7 +12,7 @@ getEntityUserData = function(id) {
|
||||||
if (properties.userData) {
|
if (properties.userData) {
|
||||||
try {
|
try {
|
||||||
results = JSON.parse(properties.userData);
|
results = JSON.parse(properties.userData);
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
logDebug(err);
|
logDebug(err);
|
||||||
logDebug(properties.userData);
|
logDebug(properties.userData);
|
||||||
}
|
}
|
||||||
|
@ -37,4 +39,4 @@ getEntityCustomData = function(customKey, id, defaultValue) {
|
||||||
} else {
|
} else {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,80 +1,85 @@
|
||||||
(function(){
|
(function() {
|
||||||
var teleport;
|
var teleport;
|
||||||
var portalDestination;
|
var portalDestination;
|
||||||
var animationURL;
|
var animationURL;
|
||||||
var self=this;
|
var self = this;
|
||||||
|
|
||||||
this.entered = true;
|
this.entered = true;
|
||||||
|
|
||||||
this.preload = function(entityID) {
|
this.preload = function(entityID) {
|
||||||
|
|
||||||
this.entityId = entityID;
|
this.entityId = entityID;
|
||||||
|
|
||||||
var properties = Entities.getEntityProperties(entityID);
|
var properties = Entities.getEntityProperties(entityID);
|
||||||
portalDestination = properties.userData;
|
portalDestination = properties.userData;
|
||||||
animationURL = properties.modelURL;
|
animationURL = properties.modelURL;
|
||||||
this.soundOptions = {
|
this.soundOptions = {
|
||||||
stereo: true,
|
stereo: true,
|
||||||
loop: false,
|
loop: false,
|
||||||
localOnly: false,
|
localOnly: false,
|
||||||
position:this.position,
|
position: this.position,
|
||||||
volume: 0.5
|
volume: 0.5
|
||||||
};
|
};
|
||||||
this.teleportSound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/whoosh.wav");
|
this.teleportSound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/whoosh.wav");
|
||||||
print('JBP PRELOADING A ZOOM ENTITY')
|
//print('JBP PRELOADING A ZOOM ENTITY')
|
||||||
print(" portal destination is " + portalDestination);
|
print(" portal destination is " + portalDestination);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.enterEntity = function(entityID) {
|
this.enterEntity = function(entityID) {
|
||||||
print('ENTERED A BOUNDARY ENTITY, SHOULD ZOOM', entityID)
|
print('JBP 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);
|
||||||
|
|
||||||
|
|
||||||
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) {
|
if (self.teleportSound.downloaded) {
|
||||||
//print("play sound");
|
//print("play sound");
|
||||||
Audio.playSound(self.teleportSound, self.soundOptions);
|
Audio.playSound(self.teleportSound, self.soundOptions);
|
||||||
} else {
|
} else {
|
||||||
//print("not downloaded");
|
//print("not downloaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lookAt(data.target, data.location);
|
this.lookAt(data.target, data.location);
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lookAt = function(targetPosition, avatarPosition) {
|
}
|
||||||
var direction = Vec3.normalize(Vec3.subtract(MyAvatar.position, targetPosition));
|
|
||||||
|
|
||||||
var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, {x:1, y:0, z:0});
|
this.lookAt = function(targetPosition, avatarPosition) {
|
||||||
var yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * 180.0 / Math.PI, {x:0, y:1, z:0});
|
var direction = Vec3.normalize(Vec3.subtract(MyAvatar.position, targetPosition));
|
||||||
|
|
||||||
// var rotation = Quat.multiply(yaw, pitch);
|
var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, {
|
||||||
// MyAvatar.orientation = rotation;
|
x: 1,
|
||||||
|
y: 0,
|
||||||
MyAvatar.goToLocation(avatarPosition, true, yaw);
|
z: 0
|
||||||
MyAvatar.headYaw = 0;
|
});
|
||||||
}
|
var yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * 180.0 / Math.PI, {
|
||||||
|
x: 0,
|
||||||
|
y: 1,
|
||||||
|
z: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
MyAvatar.goToLocation(avatarPosition, true, yaw);
|
||||||
|
MyAvatar.headYaw = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.leaveEntity = function(entityID) {
|
this.leaveEntity = function(entityID) {
|
||||||
Entities.editEntity(entityID, {
|
Entities.editEntity(entityID, {
|
||||||
animationURL: animationURL,
|
animationURL: animationURL,
|
||||||
animationSettings: '{ "frameIndex": 1, "running": false }'
|
animationSettings: '{ "frameIndex": 1, "running": false }'
|
||||||
});
|
});
|
||||||
this.entered = false;
|
this.entered = false;
|
||||||
//playSound();
|
//playSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hoverEnterEntity = function(entityID) {
|
this.hoverEnterEntity = function(entityID) {
|
||||||
Entities.editEntity(entityID, {
|
Entities.editEntity(entityID, {
|
||||||
animationURL: animationURL,
|
animationURL: animationURL,
|
||||||
animationSettings: '{ "fps": 24, "firstFrame": 1, "lastFrame": 25, "frameIndex": 1, "running": true, "hold": true }'
|
animationSettings: '{ "fps": 24, "firstFrame": 1, "lastFrame": 25, "frameIndex": 1, "running": true, "hold": true }'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -1,16 +1,18 @@
|
||||||
var version = 1001;
|
var version = 1003;
|
||||||
var cellLayout;
|
var cellLayout;
|
||||||
var baseLocation = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
|
var baseLocation = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
|
||||||
|
|
||||||
var utilsScript = Script.resolvePath('Scripts/utils.js');
|
var utilsScript = Script.resolvePath('Scripts/utils.js');
|
||||||
Script.include(utilsScript);
|
Script.include(utilsScript);
|
||||||
|
|
||||||
function makeUngrabbable(entityID){
|
function makeUngrabbable(entityID) {
|
||||||
setEntityCustomData('grabbableKey', entityID, {grabbable:false});
|
setEntityCustomData('grabbableKey', entityID, {
|
||||||
|
grabbable: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.addingEntity.connect(makeUngrabbable);
|
Entities.addingEntity.connect(makeUngrabbable);
|
||||||
|
|
||||||
assignVariables();
|
assignVariables();
|
||||||
|
|
||||||
var locations = {
|
var locations = {
|
||||||
|
@ -70,9 +72,7 @@ var locations = {
|
||||||
}, 1000]
|
}, 1000]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var scenes = [
|
var scenes = [
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "Cells",
|
name: "Cells",
|
||||||
objects: "",
|
objects: "",
|
||||||
|
@ -108,7 +108,7 @@ var scenes = [
|
||||||
},
|
},
|
||||||
radius: 500,
|
radius: 500,
|
||||||
number: 10,
|
number: 10,
|
||||||
script: "moveRandomly",
|
script: "moveRandomly.js?" + version,
|
||||||
visible: true
|
visible: true
|
||||||
}],
|
}],
|
||||||
boundary: {
|
boundary: {
|
||||||
|
@ -160,7 +160,7 @@ var scenes = [
|
||||||
location: locations.ribosome[0],
|
location: locations.ribosome[0],
|
||||||
baseURL: baseLocation
|
baseURL: baseLocation
|
||||||
}),
|
}),
|
||||||
script:"zoom.js?" + version,
|
script: "zoom.js?" + version,
|
||||||
visible: true
|
visible: true
|
||||||
}, {
|
}, {
|
||||||
model: "vesicle",
|
model: "vesicle",
|
||||||
|
@ -182,7 +182,7 @@ var scenes = [
|
||||||
grabbable: false
|
grabbable: false
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
script: "moveRandomly",
|
script: "moveRandomly.js?" + version,
|
||||||
visible: true
|
visible: true
|
||||||
}, { //golgi vesicles
|
}, { //golgi vesicles
|
||||||
model: "vesicle",
|
model: "vesicle",
|
||||||
|
@ -226,7 +226,7 @@ var scenes = [
|
||||||
grabbable: false
|
grabbable: false
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
script: "moveRandomly",
|
script: "moveRandomly.js?" + version,
|
||||||
visible: true
|
visible: true
|
||||||
}, {
|
}, {
|
||||||
model: "vesicle",
|
model: "vesicle",
|
||||||
|
@ -292,7 +292,7 @@ var scenes = [
|
||||||
grabbable: false
|
grabbable: false
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
script: "moveRandomly",
|
script: "moveRandomly.js?" + version,
|
||||||
visible: true
|
visible: true
|
||||||
}, { //outer vesicles
|
}, { //outer vesicles
|
||||||
model: "vesicle",
|
model: "vesicle",
|
||||||
|
@ -314,7 +314,7 @@ var scenes = [
|
||||||
grabbable: false
|
grabbable: false
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
script: "moveRandomly",
|
script: "moveRandomly.js?" + version,
|
||||||
visible: true
|
visible: true
|
||||||
},
|
},
|
||||||
// {//wigglies
|
// {//wigglies
|
||||||
|
@ -583,17 +583,18 @@ function ImportScene(scene) {
|
||||||
}
|
}
|
||||||
//create zone and instances
|
//create zone and instances
|
||||||
|
|
||||||
CreateZone(scene);
|
CreateZone(scene);
|
||||||
CreateInstances(scene);
|
CreateInstances(scene);
|
||||||
CreateBoundary(scene);
|
CreateBoundary(scene);
|
||||||
|
|
||||||
CreateBackgroundAudio(scene.name, scene.location, scene.dimensions);
|
CreateBackgroundAudio(scene.name, scene.location, scene.dimensions);
|
||||||
|
|
||||||
// print("done " + scene.name);
|
// print("done " + scene.name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAllNav();
|
clearAllNav();
|
||||||
|
|
||||||
function clearAllNav() {
|
function clearAllNav() {
|
||||||
// print('NAV CLEARING ALL NAV');
|
// print('NAV CLEARING ALL NAV');
|
||||||
var result = Entities.findEntities(MyAvatar.position, 25000);
|
var result = Entities.findEntities(MyAvatar.position, 25000);
|
||||||
|
@ -605,6 +606,31 @@ function clearAllNav() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createLayoutLights() {
|
||||||
|
Entities.addEntity({
|
||||||
|
type: "Light",
|
||||||
|
name: "Cell layout light",
|
||||||
|
position: {
|
||||||
|
x: locations.cellLayout[0] + 110,
|
||||||
|
y: locations.cellLayout[0] + 160,
|
||||||
|
z: locations.cellLayout[0] + 785
|
||||||
|
},
|
||||||
|
dimensions: {
|
||||||
|
x: 1500,
|
||||||
|
y: 1500,
|
||||||
|
z: 1500
|
||||||
|
},
|
||||||
|
intensity: 2,
|
||||||
|
color: {
|
||||||
|
red: 240,
|
||||||
|
green: 165,
|
||||||
|
blue: 240
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function CreateNavigationButton(scene, number) {
|
function CreateNavigationButton(scene, number) {
|
||||||
// print('NAV NAVIGATION CREATING NAV!!' +scene.name + " " + number)
|
// print('NAV NAVIGATION CREATING NAV!!' +scene.name + " " + number)
|
||||||
|
|
||||||
|
@ -634,7 +660,7 @@ function CreateNavigationButton(scene, number) {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
// position:{x:3000,y:13500,z:3000},
|
// position:{x:3000,y:13500,z:3000},
|
||||||
script: baseLocation + "Scripts/navigationButton.js?"+version ,
|
script: baseLocation + "Scripts/navigationButton.js?" + version,
|
||||||
collisionless: true,
|
collisionless: true,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -734,7 +760,7 @@ function deleteAllInRadius(position, radius) {
|
||||||
|
|
||||||
Entities.deleteEntity(arrayFound[i]);
|
Entities.deleteEntity(arrayFound[i]);
|
||||||
}
|
}
|
||||||
// print("deleted " + arrayFound.length + " entities");
|
// print("deleted " + arrayFound.length + " entities");
|
||||||
}
|
}
|
||||||
|
|
||||||
function CreateInstances(scene) {
|
function CreateInstances(scene) {
|
||||||
|
@ -744,7 +770,6 @@ function CreateInstances(scene) {
|
||||||
var point = getPointOnSphereOfRadius(scene.instances[i].radius, j + 2, scene.instances[i].number);
|
var point = getPointOnSphereOfRadius(scene.instances[i].radius, j + 2, scene.instances[i].number);
|
||||||
// print(scene.name + " point is " + point.x + " " + point.y + " " + point.z);
|
// print(scene.name + " point is " + point.x + " " + point.y + " " + point.z);
|
||||||
|
|
||||||
|
|
||||||
var posX = scene.location.x + point.x + scene.instances[i].offset.x + Math.random() * (scene.instances[i].radius / 10);
|
var posX = scene.location.x + point.x + scene.instances[i].offset.x + Math.random() * (scene.instances[i].radius / 10);
|
||||||
var posY = scene.location.y + point.y + scene.instances[i].offset.y + Math.random() * (scene.instances[i].radius / 10);
|
var posY = scene.location.y + point.y + scene.instances[i].offset.y + Math.random() * (scene.instances[i].radius / 10);
|
||||||
var posZ = scene.location.z + point.z + scene.instances[i].offset.z + Math.random() * (scene.instances[i].radius / 10);
|
var posZ = scene.location.z + point.z + scene.instances[i].offset.z + Math.random() * (scene.instances[i].radius / 10);
|
||||||
|
@ -754,13 +779,13 @@ function CreateInstances(scene) {
|
||||||
z: posZ
|
z: posZ
|
||||||
};
|
};
|
||||||
var url = baseLocation + "Instances/" + scene.instances[i].model + ".fbx?" + version;
|
var url = baseLocation + "Instances/" + scene.instances[i].model + ".fbx?" + version;
|
||||||
var script = scene.instances[i].script + ".js?" + version;
|
var script = scene.instances[i].script;
|
||||||
var rotX = 360 * Math.random() - 180;
|
var rotX = 360 * Math.random() - 180;
|
||||||
var rotY = 360 * Math.random() - 180;
|
var rotY = 360 * Math.random() - 180;
|
||||||
var rotZ = 360 * Math.random() - 180;
|
var rotZ = 360 * Math.random() - 180;
|
||||||
var rotation = Quat.fromPitchYawRollDegrees(rotX, rotY, rotZ);
|
var rotation = Quat.fromPitchYawRollDegrees(rotX, rotY, rotZ);
|
||||||
var dimensions;
|
var dimensions;
|
||||||
if (scene.instances[i].script == "") {
|
if (scene.instances[i].script === "") {
|
||||||
script = "";
|
script = "";
|
||||||
}
|
}
|
||||||
//is there a smarter way to randomize size?
|
//is there a smarter way to randomize size?
|
||||||
|
@ -780,7 +805,7 @@ function CreateInstances(scene) {
|
||||||
}, idBounds, 150);
|
}, idBounds, 150);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
print('JBP 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -876,12 +901,13 @@ function getPointOnSphereOfRadius(radius, number, totalNumber) {
|
||||||
|
|
||||||
function CreateEntity(name, position, rotation, dimensions, url, script, userData, visible) {
|
function CreateEntity(name, position, rotation, dimensions, url, script, userData, visible) {
|
||||||
var scriptLocation;
|
var scriptLocation;
|
||||||
if (script == "") {
|
if (script === "") {
|
||||||
scriptLocation = "";
|
scriptLocation = "";
|
||||||
} else {
|
} else {
|
||||||
scriptLocation = baseLocation + "Scripts/" + script;
|
scriptLocation = baseLocation + "Scripts/" + script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print('JBP SCRIPT LOCATION IN CREATE ENTITY' + scriptLocation)
|
||||||
Entities.addEntity({
|
Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
name: name,
|
name: name,
|
||||||
|
@ -9020,36 +9046,8 @@ for (var i = 0; i < scenes.length; i++) {
|
||||||
CreateNavigationButton(scenes[i], i);
|
CreateNavigationButton(scenes[i], i);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Entities.addEntity({
|
createLayoutLights();
|
||||||
// type: "Box",
|
|
||||||
// name: "motorProteinController",
|
|
||||||
// position: {x:4000, y:4000, z:4000},
|
|
||||||
// color: {red: 200, green: 0, blue: 0},
|
|
||||||
// script: baseLocation + "Scripts/motorProteinController.js?"+version,
|
|
||||||
// visible: false
|
|
||||||
//});
|
|
||||||
|
|
||||||
Entities.addEntity({
|
Script.scriptEnding.connect(function() {
|
||||||
type: "Light",
|
|
||||||
name: "Cell layout light",
|
|
||||||
position: {
|
|
||||||
x: locations.cellLayout[0] + 110,
|
|
||||||
y: locations.cellLayout[0] + 160,
|
|
||||||
z: locations.cellLayout[0] + 785
|
|
||||||
},
|
|
||||||
dimensions: {
|
|
||||||
x: 1500,
|
|
||||||
y: 1500,
|
|
||||||
z: 1500
|
|
||||||
},
|
|
||||||
intensity: 2,
|
|
||||||
color: {
|
|
||||||
red: 240,
|
|
||||||
green: 165,
|
|
||||||
blue: 240
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Script.scriptEnding.connect(function(){
|
|
||||||
Entities.addingEntity.disconnect(makeUngrabbable);
|
Entities.addingEntity.disconnect(makeUngrabbable);
|
||||||
});
|
});
|
Loading…
Reference in a new issue