Merge pull request #7184 from imgntn/cellscience

Cellscience Updates
This commit is contained in:
Brad Hefta-Gaub 2016-02-26 16:53:00 -08:00
commit 70614aba90
11 changed files with 484 additions and 514 deletions

View file

@ -17,8 +17,8 @@ var SIZE = 10.0;
var SEPARATION = 20.0;
var ROWS_X = 30;
var ROWS_Z = 30;
var TYPE = "Sphere"; // Right now this can be "Box" or "Model" or "Sphere"
var MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/props/LowPolyIsland/CypressTreeGroup.fbx";
var TYPE = "Model"; // Right now this can be "Box" or "Model" or "Sphere"
var MODEL_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Instances/vesicle.fbx";
var MODEL_DIMENSION = { x: 33, y: 16, z: 49 };
var RATE_PER_SECOND = 1000; // The entity server will drop data if we create things too fast.
var SCRIPT_INTERVAL = 100;
@ -38,6 +38,7 @@ Script.setInterval(function () {
var numToCreate = RATE_PER_SECOND * (SCRIPT_INTERVAL / 1000.0);
for (var i = 0; i < numToCreate; i++) {
var position = { x: SIZE + (x * SEPARATION), y: SIZE, z: SIZE + (z * SEPARATION) };
print('position:'+JSON.stringify(position))
if (TYPE == "Model") {
Entities.addEntity({
type: TYPE,

View file

@ -1,182 +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;
this.preload = function(entityId) {
//print('preload move randomly')
this.isConnected = false;
this.entityId = entityId;
this.updateInterval = 100;
this.posFrame = 0;
this.rotFrame = 0;
this.posInterval = 100;
this.rotInterval = 100;
this.minVelocity = 1;
this.maxVelocity = 5;
this.minAngularVelocity = 0.01;
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) {
// 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;
};
// print('userdata is' + data)
//if the entity doesnt have an owner set yet
if (userData.hasOwnProperty('ownershipKey') !== true) {
//print('no movement owner yet')
return;
}
//print('owner is:::' + userData.ownershipKey.owner)
//get all the avatars to see if the owner is around
var avatars = AvatarList.getAvatarIdentifiers();
var ownerIsAround = false;
//if the current owner is not me...
if (userData.ownershipKey.owner !== MyAvatar.sessionUUID) {
//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;
};
}
//if the owner is not around, then take ownership
if (ownerIsAround === false) {
//print('taking ownership')
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() {
if (this.initTimeout !== null) {
Script.clearTimeout(this.initTimeout);
}
if (this.isConnected === true) {
Script.update.disconnect(this.update);
}
}
})

View file

@ -7,7 +7,7 @@
(function() {
var version = 11;
var version = 12;
var added = false;
this.frame = 0;
var utilsScript = Script.resolvePath('utils.js');
@ -23,22 +23,21 @@
}
this.initialize = function(entityId) {
print('JBP nav button should initialize' + entityId)
var properties = Entities.getEntityProperties(entityId);
if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) {
self.initTimeout = Script.setTimeout(function() {
print('JBP no user data yet, try again in one second')
// print(' no user data yet, try again in one second')
self.initialize(entityId);
}, 1000)
} else {
print('JBP userdata before parse attempt' + properties.userData)
// print('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);
// print(' error parsing json');
// print(' properties are:' + properties.userData);
return;
}
@ -46,9 +45,9 @@
var mySavedSettings = Settings.getValue(entityId);
if (mySavedSettings.buttons !== undefined) {
print('JBP preload buttons' + mySavedSettings.buttons)
// print(' preload buttons' + mySavedSettings.buttons)
mySavedSettings.buttons.forEach(function(b) {
print('JBP deleting button' + b)
// print(' deleting button' + b)
Overlays.deleteOverlay(b);
})
Settings.setValue(entityId, '')
@ -56,16 +55,15 @@
self.buttonImageURL = baseURL + "GUI/GUI_" + self.userData.name + ".png?" + version;
print('JBP BUTTON IMAGE URL:' + self.buttonImageURL)
// print(' BUTTON IMAGE URL:' + self.buttonImageURL)
if (self.button === undefined) {
// print('NAV NO BUTTON ADDING ONE!!')
// print(' NO BUTTON ADDING ONE!!')
self.button = true;
self.addButton();
} else {
// print('NAV SELF ALREADY HAS A BUTTON!!')
//print(' SELF ALREADY HAS A BUTTON!!')
}
}
}

View file

@ -36,8 +36,6 @@
return;
}
self.addButton();
self.buttonShowing = false;
self.showDistance = self.userData.showDistance;
@ -51,8 +49,6 @@
};
self.sound = SoundCache.getSound(this.soundURL);
}
this.addButton = function() {

View file

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

View file

@ -52,13 +52,7 @@
print("Teleporting to (" + data.location.x + ", " + data.location.y + ", " + data.location.z + ")");
MyAvatar.position = data.location;
// if (data.hasOwnProperty('entryPoint') && data.hasOwnProperty('target')) {
// this.lookAtTarget(data.entryPoint, data.target);
// }
// else{
// }
}
}
@ -103,10 +97,4 @@
}
}
this.hoverEnterEntity = function(entityID) {
Entities.editEntity(entityID, {
animationURL: animationURL,
animationSettings: '{ "fps": 24, "firstFrame": 1, "lastFrame": 25, "frameIndex": 1, "running": true, "hold": true }'
});
}
})

View file

@ -7,7 +7,7 @@ var soundMap = [{
y: 15850,
z: 15850
},
volume: 0.1,
volume: 0.03,
loop: true
}
}, {
@ -19,7 +19,7 @@ var soundMap = [{
y: 15950,
z: 15950
},
volume: 0.1,
volume: 0.03,
loop: true
}
}, {
@ -31,7 +31,7 @@ var soundMap = [{
y: 15650,
z: 15650
},
volume: 0.1,
volume: 0.03,
loop: true
}
}, {
@ -43,7 +43,7 @@ var soundMap = [{
y: 15750,
z: 15750
},
volume: 0.1,
volume: 0.03,
loop: true
}
}

View file

@ -5,7 +5,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var version = 1035;
var version = 1112;
var cellLayout;
var baseLocation = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/";
@ -103,9 +103,9 @@ var scenes = [{
instances: [{
model: "Cell",
dimensions: {
x: 550,
y: 620,
z: 550
x: 500,
y: 570,
z: 500
},
offset: {
x: 0,
@ -151,294 +151,253 @@ var scenes = [{
skybox: "cosmos_skybox_blurred"
},
instances: [{
model: "translation",
dimensions: {
x: 10,
y: 16,
z: 10
},
offset: {
x: 0,
y: 0,
z: 0
},
radius: 300,
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,
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: 10,
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: 7,
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: 15,
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: 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
model: "translation",
dimensions: {
x: 10,
y: 16,
z: 10
},
// {//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
offset: {
x: 0,
y: 0,
z: 0
},
radius: 300,
number: 7,
userData: JSON.stringify({
grabbableKey: {
grabbable: false
},
randomSize: 10,
offset: {
x: 236,
y: 8,
z: 771
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
}
}),
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: 10,
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: 7,
userData: JSON.stringify({
grabbableKey: {
grabbable: false
}
}),
visible: true
}, {
model: "vesicle",
dimensions: {
x: 50,
y: 50,
z: 50
},
randomSize: 10,
offset: {
x: 0,
y: 0,
z: 0
},
radius: 600,
number: 15,
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: 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
}
}),
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
}
}),
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
},
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
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
},
randomSize: 10,
offset: {
x: 236,
y: 8,
z: 771
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
},
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
// }
],
target: locations.hexokinase[1],
location: locations.hexokinase[0],
}),
script: "zoom.js?" + version,
visible: true
}],
boundary: {
radius: locations.cellLayout[2],
center: locations.cellLayout[0],
@ -600,7 +559,7 @@ function ImportScene(scene) {
CreateZone(scene);
CreateInstances(scene);
CreateBoundary(scene);
// CreateBoundary(scene);
// print("done " + scene.name);
@ -609,12 +568,10 @@ function ImportScene(scene) {
clearAllNav();
function clearAllNav() {
// print('NAV CLEARING ALL NAV');
var result = Entities.findEntities(MyAvatar.position, 25000);
result.forEach(function(r) {
var properties = Entities.getEntityProperties(r, "name");
if (properties.name.indexOf('navigation button') > -1) {
// print('NAV DELETING NAV BUTTON AT START:: '+r)
Entities.deleteEntity(r);
}
})
@ -645,9 +602,6 @@ function createLayoutLights() {
}
function CreateNavigationButton(scene, number) {
// print('NAV NAVIGATION CREATING NAV!!' +scene.name + " " + number)
Entities.addEntity({
type: "Box",
name: scene.name + " navigation button",
@ -818,7 +772,7 @@ function CreateInstances(scene) {
x: 0,
y: 0,
z: 0
}, idBounds, 150);
}, idBounds, 150, scene.instances[i]);
}
//print('SCRIPT AT CREATE ENTITY: ' + script)
@ -831,6 +785,7 @@ function CreateInstances(scene) {
function CreateIdentification(name, position, rotation, dimensions, showDistance) {
//print ("creating ID for " + name);
Entities.addEntity({
type: "Sphere",
name: "ID for " + name,
@ -9045,4 +9000,9 @@ createLayoutLights();
Script.scriptEnding.connect(function() {
Entities.addingEntity.disconnect(makeUngrabbable);
});
});
Script.setTimeout(function() {
print('JBP stopping cell science import');
Script.stop();
}, 30000)

View file

@ -18,8 +18,6 @@ if (USE_LOCAL_HOST === true) {
var USE_LOCAL_HOST = false;
Agent.isAvatar = true;
EntityViewer.setPosition({
x: 3000,
y: 13500,

View file

@ -0,0 +1,103 @@
// 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 basePosition = {
x: 3000,
y: 13500,
z: 3000
};
var initialized = false;
EntityViewer.setPosition(basePosition);
EntityViewer.setKeyholeRadius(60000);
var octreeQueryInterval = Script.setInterval(function() {
EntityViewer.queryOctree();
}, 200);
var THROTTLE = true;
var THROTTLE_RATE = 5000;
var sinceLastUpdate = 0;
//print('cells script')
function findCells() {
var results = Entities.findEntities(basePosition, 60000);
if (results.length === 0) {
// print('no entities found')
return;
}
results.forEach(function(v) {
var name = Entities.getEntityProperties(v, 'name').name;
// print('name is:: ' + name)
if (name === 'Cell') {
// print('found a cell!!' + v)
Script.setTimeout(function() {
moveCell(v);
}, Math.random() * THROTTLE_RATE);
}
});
}
var minAngularVelocity = 0.01;
var maxAngularVelocity = 0.03;
function moveCell(entityId) {
// print('moving a cell! ' + entityId)
var magnitudeAV = 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(entityId, {
angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV))
});
}
function update(deltaTime) {
// print('deltaTime',deltaTime)
if (!initialized) {
print("checking for servers...");
if (Entities.serversExist() && Entities.canRez()) {
print("servers exist -- makeAll...");
Entities.setPacketsPerSecond(6000);
print("PPS:" + Entities.getPacketsPerSecond());
initialized = true;
}
return;
}
if (THROTTLE === true) {
sinceLastUpdate = sinceLastUpdate + deltaTime * 1000;
if (sinceLastUpdate > THROTTLE_RATE) {
// print('SHOULD FIND CELLS!!!')
sinceLastUpdate = 0;
findCells();
} else {
// print('returning in update ' + sinceLastUpdate)
return;
}
}
}
function unload() {
Script.update.disconnect(update);
}
Script.update.connect(update);
Script.scriptEnding.connect(unload);

View file

@ -0,0 +1,108 @@
// 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 basePosition = {
x: 3000,
y: 13500,
z: 3000
};
var initialized = false;
EntityViewer.setPosition(basePosition);
EntityViewer.setKeyholeRadius(60000);
var octreeQueryInterval = Script.setInterval(function() {
EntityViewer.queryOctree();
}, 200);
var THROTTLE = true;
var THROTTLE_RATE = 5000;
var sinceLastUpdate = 0;
//print('vesicle script')
function findVesicles() {
var results = Entities.findEntities(basePosition, 60000);
if (results.length === 0) {
// print('no entities found');
return;
}
results.forEach(function(v) {
var name = Entities.getEntityProperties(v, 'name').name;
if (name === 'vesicle') {
//print('found a vesicle!!' + v)
Script.setTimeout(function() {
moveVesicle(v);
}, Math.random() * THROTTLE_RATE);
}
});
}
var minVelocity = 1;
var maxVelocity = 5;
var minAngularVelocity = 0.01;
var maxAngularVelocity = 0.03;
function moveVesicle(entityId) {
// print('moving a vesicle! ' + entityId)
var magnitudeV = 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);
var magnitudeAV = 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(entityId, {
velocity: Vec3.multiply(magnitudeV, Vec3.normalize(directionV)),
angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV))
});
}
function update(deltaTime) {
if (!initialized) {
print("checking for servers...");
if (Entities.serversExist() && Entities.canRez()) {
print("servers exist -- makeAll...");
Entities.setPacketsPerSecond(6000);
print("PPS:" + Entities.getPacketsPerSecond());
initialized = true;
}
return;
}
if (THROTTLE === true) {
sinceLastUpdate = sinceLastUpdate + deltaTime * 1000;
if (sinceLastUpdate > THROTTLE_RATE) {
sinceLastUpdate = 0;
findVesicles();
} else {
return;
}
}
}
function unload() {
Script.update.disconnect(update);
}
Script.update.connect(update);
Script.scriptEnding.connect(unload);