mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into orange
This commit is contained in:
commit
4bec6ddf52
19 changed files with 624 additions and 587 deletions
|
@ -277,14 +277,17 @@ void EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectio
|
|||
// set of stats to have, but we'd probably want a different data structure if we keep it very long.
|
||||
// Since this version uses a single shared QMap for all senders, there could be some lock contention
|
||||
// on this QWriteLocker
|
||||
void EntityServer::trackSend(const QUuid& dataID, quint64 dataLastEdited, const QUuid& viewerNode) {
|
||||
void EntityServer::trackSend(const QUuid& dataID, quint64 dataLastEdited, const QUuid& sessionID) {
|
||||
QWriteLocker locker(&_viewerSendingStatsLock);
|
||||
_viewerSendingStats[viewerNode][dataID] = { usecTimestampNow(), dataLastEdited };
|
||||
_viewerSendingStats[sessionID][dataID] = { usecTimestampNow(), dataLastEdited };
|
||||
}
|
||||
|
||||
void EntityServer::trackViewerGone(const QUuid& viewerNode) {
|
||||
void EntityServer::trackViewerGone(const QUuid& sessionID) {
|
||||
QWriteLocker locker(&_viewerSendingStatsLock);
|
||||
_viewerSendingStats.remove(viewerNode);
|
||||
_viewerSendingStats.remove(sessionID);
|
||||
if (_entitySimulation) {
|
||||
_entitySimulation->clearOwnership(sessionID);
|
||||
}
|
||||
}
|
||||
|
||||
QString EntityServer::serverSubclassStats() {
|
||||
|
|
|
@ -27,6 +27,8 @@ struct ViewerSendingStats {
|
|||
quint64 lastEdited;
|
||||
};
|
||||
|
||||
class SimpleEntitySimulation;
|
||||
|
||||
class EntityServer : public OctreeServer, public NewlyCreatedEntityHook {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -52,8 +54,8 @@ public:
|
|||
virtual void readAdditionalConfiguration(const QJsonObject& settingsSectionObject) override;
|
||||
virtual QString serverSubclassStats() override;
|
||||
|
||||
virtual void trackSend(const QUuid& dataID, quint64 dataLastEdited, const QUuid& viewerNode) override;
|
||||
virtual void trackViewerGone(const QUuid& viewerNode) override;
|
||||
virtual void trackSend(const QUuid& dataID, quint64 dataLastEdited, const QUuid& sessionID) override;
|
||||
virtual void trackViewerGone(const QUuid& sessionID) override;
|
||||
|
||||
public slots:
|
||||
void pruneDeletedEntities();
|
||||
|
@ -65,7 +67,7 @@ private slots:
|
|||
void handleEntityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
||||
|
||||
private:
|
||||
EntitySimulation* _entitySimulation;
|
||||
SimpleEntitySimulation* _entitySimulation;
|
||||
QTimer* _pruneDeletedEntitiesTimer = nullptr;
|
||||
|
||||
QReadWriteLock _viewerSendingStatsLock;
|
||||
|
|
|
@ -12,17 +12,23 @@
|
|||
|
||||
var APPARENT_2D_OVERLAY_DEPTH = 1.0;
|
||||
var APPARENT_MAXIMUM_DEPTH = 100.0; // this is a depth at which things all seem sufficiently distant
|
||||
var lastDepthCheckTime = 0;
|
||||
var lastDepthCheckTime = Date.now();
|
||||
var desiredDepth = APPARENT_2D_OVERLAY_DEPTH;
|
||||
var TIME_BETWEEN_DEPTH_CHECKS = 100;
|
||||
var MINIMUM_DEPTH_ADJUST = 0.01;
|
||||
var NON_LINEAR_DIVISOR = 2;
|
||||
|
||||
Script.update.connect(function(deltaTime) {
|
||||
var TIME_BETWEEN_DEPTH_CHECKS = 100;
|
||||
var timeSinceLastDepthCheck = Date.now() - lastDepthCheckTime;
|
||||
var now = Date.now();
|
||||
var timeSinceLastDepthCheck = now - lastDepthCheckTime;
|
||||
if (timeSinceLastDepthCheck > TIME_BETWEEN_DEPTH_CHECKS) {
|
||||
var newDesiredDepth = desiredDepth;
|
||||
lastDepthCheckTime = now;
|
||||
var reticlePosition = Reticle.position;
|
||||
|
||||
// first check the 2D Overlays
|
||||
if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(reticlePosition)) {
|
||||
Reticle.setDepth(APPARENT_2D_OVERLAY_DEPTH);
|
||||
newDesiredDepth = APPARENT_2D_OVERLAY_DEPTH;
|
||||
} else {
|
||||
var pickRay = Camera.computePickRay(reticlePosition.x, reticlePosition.y);
|
||||
|
||||
|
@ -37,11 +43,30 @@ Script.update.connect(function(deltaTime) {
|
|||
// If either the overlays or entities intersect, then set the reticle depth to
|
||||
// the distance of intersection
|
||||
if (result.intersects) {
|
||||
Reticle.setDepth(result.distance);
|
||||
newDesiredDepth = result.distance;
|
||||
} else {
|
||||
// if nothing intersects... set the depth to some sufficiently large depth
|
||||
Reticle.setDepth(APPARENT_MAXIMUM_DEPTH);
|
||||
newDesiredDepth = APPARENT_MAXIMUM_DEPTH;
|
||||
}
|
||||
}
|
||||
|
||||
// If the desired depth has changed, reset our fade start time
|
||||
if (desiredDepth != newDesiredDepth) {
|
||||
desiredDepth = newDesiredDepth;
|
||||
}
|
||||
}
|
||||
|
||||
// move the reticle toward the desired depth
|
||||
if (desiredDepth != Reticle.depth) {
|
||||
|
||||
// cut distance between desiredDepth and current depth in half until we're close enough
|
||||
var distanceToAdjustThisCycle = (desiredDepth - Reticle.depth) / NON_LINEAR_DIVISOR;
|
||||
if (Math.abs(distanceToAdjustThisCycle) < MINIMUM_DEPTH_ADJUST) {
|
||||
newDepth = desiredDepth;
|
||||
} else {
|
||||
newDepth = Reticle.depth + distanceToAdjustThisCycle;
|
||||
}
|
||||
|
||||
Reticle.setDepth(newDepth);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -400,7 +400,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
|||
frustum = qApp->getDisplayViewFrustum();
|
||||
}
|
||||
|
||||
if (frustum->sphereIntersectsFrustum(getPosition(), boundingRadius)) {
|
||||
if (!frustum->sphereIntersectsFrustum(getPosition(), boundingRadius)) {
|
||||
endRender();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ void ApplicationCompositor::displayOverlayTextureHmd(RenderArgs* renderArgs, int
|
|||
// look at borrowed from overlays
|
||||
float elevation = -asinf(relativePosition.y / glm::length(relativePosition));
|
||||
float azimuth = atan2f(relativePosition.x, relativePosition.z);
|
||||
glm::quat faceCamera = glm::quat(glm::vec3(elevation, azimuth, 0)) * quat(vec3(0, 0, -1)); // this extra *quat(vec3(0,0,-1)) was required to get the quad to flip this seems like we could optimize
|
||||
glm::quat faceCamera = glm::quat(glm::vec3(elevation, azimuth, 0)) * quat(vec3(0, -PI, 0)); // this extra *quat(vec3(0,-PI,0)) was required to get the quad to flip this seems like we could optimize
|
||||
|
||||
Transform transform;
|
||||
transform.setTranslation(relativePosition);
|
||||
|
|
|
@ -18,51 +18,69 @@
|
|||
#include "EntityItem.h"
|
||||
#include "EntitiesLogging.h"
|
||||
|
||||
const quint64 MIN_SIMULATION_OWNERSHIP_UPDATE_PERIOD = 2 * USECS_PER_SECOND;
|
||||
|
||||
void SimpleEntitySimulation::updateEntitiesInternal(const quint64& now) {
|
||||
if (_entitiesWithSimulator.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (now < _nextSimulationExpiry) {
|
||||
// nothing has expired yet
|
||||
return;
|
||||
}
|
||||
|
||||
// If an Entity has a simulation owner but there has been no update for a while: clear the owner.
|
||||
// If an Entity goes ownerless for too long: zero velocity and remove from _entitiesWithSimulator.
|
||||
_nextSimulationExpiry = now + MIN_SIMULATION_OWNERSHIP_UPDATE_PERIOD;
|
||||
const quint64 MAX_OWNERLESS_PERIOD = 2 * USECS_PER_SECOND;
|
||||
|
||||
void SimpleEntitySimulation::clearOwnership(const QUuid& ownerID) {
|
||||
QMutexLocker lock(&_mutex);
|
||||
SetOfEntities::iterator itemItr = _entitiesWithSimulator.begin();
|
||||
while (itemItr != _entitiesWithSimulator.end()) {
|
||||
SetOfEntities::iterator itemItr = _entitiesWithSimulationOwner.begin();
|
||||
while (itemItr != _entitiesWithSimulationOwner.end()) {
|
||||
EntityItemPointer entity = *itemItr;
|
||||
quint64 expiry = entity->getLastChangedOnServer() + MIN_SIMULATION_OWNERSHIP_UPDATE_PERIOD;
|
||||
if (expiry < now) {
|
||||
if (entity->getSimulatorID().isNull()) {
|
||||
// no simulators are volunteering
|
||||
// zero the velocity on this entity so that it doesn't drift far away
|
||||
entity->setVelocity(Vectors::ZERO);
|
||||
entity->setAngularVelocity(Vectors::ZERO);
|
||||
entity->setAcceleration(Vectors::ZERO);
|
||||
// remove from list
|
||||
itemItr = _entitiesWithSimulator.erase(itemItr);
|
||||
continue;
|
||||
} else {
|
||||
// the simulator has stopped updating this object
|
||||
// clear ownership and restart timer, giving nearby simulators time to volunteer
|
||||
qCDebug(entities) << "auto-removing simulation owner " << entity->getSimulatorID();
|
||||
entity->clearSimulationOwnership();
|
||||
if (entity->getSimulatorID() == ownerID) {
|
||||
// the simulator has abandonded this object --> remove from owned list
|
||||
qCDebug(entities) << "auto-removing simulation owner " << entity->getSimulatorID();
|
||||
itemItr = _entitiesWithSimulationOwner.erase(itemItr);
|
||||
|
||||
if (entity->getDynamic() && entity->hasLocalVelocity()) {
|
||||
// it is still moving dynamically --> add to orphaned list
|
||||
_entitiesThatNeedSimulationOwner.insert(entity);
|
||||
quint64 expiry = entity->getLastChangedOnServer() + MAX_OWNERLESS_PERIOD;
|
||||
if (expiry < _nextOwnerlessExpiry) {
|
||||
_nextOwnerlessExpiry = expiry;
|
||||
}
|
||||
}
|
||||
|
||||
// remove ownership and dirty all the tree elements that contain the it
|
||||
entity->clearSimulationOwnership();
|
||||
entity->markAsChangedOnServer();
|
||||
// dirty all the tree elements that contain the entity
|
||||
DirtyOctreeElementOperator op(entity->getElement());
|
||||
getEntityTree()->recurseTreeWithOperator(&op);
|
||||
} else if (expiry < _nextSimulationExpiry) {
|
||||
_nextSimulationExpiry = expiry;
|
||||
} else {
|
||||
++itemItr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleEntitySimulation::updateEntitiesInternal(const quint64& now) {
|
||||
if (now > _nextOwnerlessExpiry) {
|
||||
// search for ownerless objects that have expired
|
||||
QMutexLocker lock(&_mutex);
|
||||
_nextOwnerlessExpiry = -1;
|
||||
SetOfEntities::iterator itemItr = _entitiesThatNeedSimulationOwner.begin();
|
||||
while (itemItr != _entitiesThatNeedSimulationOwner.end()) {
|
||||
EntityItemPointer entity = *itemItr;
|
||||
quint64 expiry = entity->getLastChangedOnServer() + MAX_OWNERLESS_PERIOD;
|
||||
if (expiry < now) {
|
||||
// no simulators have volunteered ownership --> remove from list
|
||||
itemItr = _entitiesThatNeedSimulationOwner.erase(itemItr);
|
||||
|
||||
if (entity->getSimulatorID().isNull() && entity->getDynamic() && entity->hasLocalVelocity()) {
|
||||
// zero the derivatives
|
||||
entity->setVelocity(Vectors::ZERO);
|
||||
entity->setAngularVelocity(Vectors::ZERO);
|
||||
entity->setAcceleration(Vectors::ZERO);
|
||||
|
||||
// dirty all the tree elements that contain it
|
||||
entity->markAsChangedOnServer();
|
||||
DirtyOctreeElementOperator op(entity->getElement());
|
||||
getEntityTree()->recurseTreeWithOperator(&op);
|
||||
}
|
||||
} else {
|
||||
++itemItr;
|
||||
if (expiry < _nextOwnerlessExpiry) {
|
||||
_nextOwnerlessExpiry = expiry;
|
||||
}
|
||||
}
|
||||
}
|
||||
++itemItr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,26 +88,47 @@ void SimpleEntitySimulation::addEntityInternal(EntityItemPointer entity) {
|
|||
EntitySimulation::addEntityInternal(entity);
|
||||
if (!entity->getSimulatorID().isNull()) {
|
||||
QMutexLocker lock(&_mutex);
|
||||
_entitiesWithSimulator.insert(entity);
|
||||
_entitiesWithSimulationOwner.insert(entity);
|
||||
} else if (entity->getDynamic() && entity->hasLocalVelocity()) {
|
||||
QMutexLocker lock(&_mutex);
|
||||
_entitiesThatNeedSimulationOwner.insert(entity);
|
||||
quint64 expiry = entity->getLastChangedOnServer() + MAX_OWNERLESS_PERIOD;
|
||||
if (expiry < _nextOwnerlessExpiry) {
|
||||
_nextOwnerlessExpiry = expiry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleEntitySimulation::removeEntityInternal(EntityItemPointer entity) {
|
||||
EntitySimulation::removeEntityInternal(entity);
|
||||
QMutexLocker lock(&_mutex);
|
||||
_entitiesWithSimulator.remove(entity);
|
||||
_entitiesWithSimulationOwner.remove(entity);
|
||||
_entitiesThatNeedSimulationOwner.remove(entity);
|
||||
}
|
||||
|
||||
void SimpleEntitySimulation::changeEntityInternal(EntityItemPointer entity) {
|
||||
EntitySimulation::changeEntityInternal(entity);
|
||||
if (!entity->getSimulatorID().isNull()) {
|
||||
if (entity->getSimulatorID().isNull()) {
|
||||
QMutexLocker lock(&_mutex);
|
||||
_entitiesWithSimulator.insert(entity);
|
||||
_entitiesWithSimulationOwner.remove(entity);
|
||||
if (entity->getDynamic() && entity->hasLocalVelocity()) {
|
||||
_entitiesThatNeedSimulationOwner.insert(entity);
|
||||
quint64 expiry = entity->getLastChangedOnServer() + MAX_OWNERLESS_PERIOD;
|
||||
if (expiry < _nextOwnerlessExpiry) {
|
||||
_nextOwnerlessExpiry = expiry;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QMutexLocker lock(&_mutex);
|
||||
_entitiesWithSimulationOwner.insert(entity);
|
||||
_entitiesThatNeedSimulationOwner.remove(entity);
|
||||
}
|
||||
entity->clearDirtyFlags();
|
||||
}
|
||||
|
||||
void SimpleEntitySimulation::clearEntitiesInternal() {
|
||||
_entitiesWithSimulator.clear();
|
||||
QMutexLocker lock(&_mutex);
|
||||
_entitiesWithSimulationOwner.clear();
|
||||
_entitiesThatNeedSimulationOwner.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ public:
|
|||
SimpleEntitySimulation() : EntitySimulation() { }
|
||||
virtual ~SimpleEntitySimulation() { clearEntitiesInternal(); }
|
||||
|
||||
void clearOwnership(const QUuid& ownerID);
|
||||
|
||||
protected:
|
||||
virtual void updateEntitiesInternal(const quint64& now) override;
|
||||
virtual void addEntityInternal(EntityItemPointer entity) override;
|
||||
|
@ -28,8 +30,9 @@ protected:
|
|||
virtual void changeEntityInternal(EntityItemPointer entity) override;
|
||||
virtual void clearEntitiesInternal() override;
|
||||
|
||||
SetOfEntities _entitiesWithSimulator;
|
||||
quint64 _nextSimulationExpiry { 0 };
|
||||
SetOfEntities _entitiesWithSimulationOwner;
|
||||
SetOfEntities _entitiesThatNeedSimulationOwner;
|
||||
quint64 _nextOwnerlessExpiry { 0 };
|
||||
};
|
||||
|
||||
#endif // hifi_SimpleEntitySimulation_h
|
||||
|
|
|
@ -272,7 +272,7 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) {
|
|||
float dt = (float)(numSteps) * PHYSICS_ENGINE_FIXED_SUBSTEP;
|
||||
|
||||
if (_numInactiveUpdates > 0) {
|
||||
const uint8_t MAX_NUM_INACTIVE_UPDATES = 3;
|
||||
const uint8_t MAX_NUM_INACTIVE_UPDATES = 20;
|
||||
if (_numInactiveUpdates > MAX_NUM_INACTIVE_UPDATES) {
|
||||
// clear local ownership (stop sending updates) and let the server clear itself
|
||||
_entity->clearSimulationOwnership();
|
||||
|
@ -282,7 +282,7 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) {
|
|||
// until it is removed from the outgoing updates
|
||||
// (which happens when we don't own the simulation and it isn't touching our simulation)
|
||||
const float INACTIVE_UPDATE_PERIOD = 0.5f;
|
||||
return (dt > INACTIVE_UPDATE_PERIOD);
|
||||
return (dt > INACTIVE_UPDATE_PERIOD * (float)_numInactiveUpdates);
|
||||
}
|
||||
|
||||
if (!_body->isActive()) {
|
||||
|
@ -404,8 +404,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q
|
|||
assert(_entity);
|
||||
assert(entityTreeIsLocked());
|
||||
|
||||
bool active = _body->isActive();
|
||||
if (!active) {
|
||||
if (!_body->isActive()) {
|
||||
// make sure all derivatives are zero
|
||||
glm::vec3 zero(0.0f);
|
||||
_entity->setVelocity(zero);
|
||||
|
@ -495,16 +494,12 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q
|
|||
qCDebug(physics) << " lastSimulated:" << debugTime(lastSimulated, now);
|
||||
#endif //def WANT_DEBUG
|
||||
|
||||
if (sessionID == _entity->getSimulatorID()) {
|
||||
// we think we own the simulation
|
||||
if (!active) {
|
||||
// we own the simulation but the entity has stopped, so we tell the server that we're clearing simulatorID
|
||||
// but we remember that we do still own it... and rely on the server to tell us that we don't
|
||||
properties.clearSimulationOwner();
|
||||
_outgoingPriority = ZERO_SIMULATION_PRIORITY;
|
||||
}
|
||||
// else the ownership is not changing so we don't bother to pack it
|
||||
} else {
|
||||
if (_numInactiveUpdates > 0) {
|
||||
// we own the simulation but the entity has stopped, so we tell the server that we're clearing simulatorID
|
||||
// but we remember that we do still own it... and rely on the server to tell us that we don't
|
||||
properties.clearSimulationOwner();
|
||||
_outgoingPriority = ZERO_SIMULATION_PRIORITY;
|
||||
} else if (sessionID != _entity->getSimulatorID()) {
|
||||
// we don't own the simulation for this entity yet, but we're sending a bid for it
|
||||
properties.setSimulationOwner(sessionID, glm::max<uint8_t>(_outgoingPriority, VOLUNTEER_SIMULATION_PRIORITY));
|
||||
_nextOwnershipBid = now + USECS_BETWEEN_OWNERSHIP_BIDS;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
})
|
|
@ -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!!')
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 }'
|
||||
});
|
||||
}
|
||||
})
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
|
@ -18,8 +18,6 @@ if (USE_LOCAL_HOST === true) {
|
|||
|
||||
var USE_LOCAL_HOST = false;
|
||||
|
||||
Agent.isAvatar = true;
|
||||
|
||||
EntityViewer.setPosition({
|
||||
x: 3000,
|
||||
y: 13500,
|
||||
|
|
103
unpublishedScripts/DomainContent/CellScience/moveCellsAC.js
Normal file
103
unpublishedScripts/DomainContent/CellScience/moveCellsAC.js
Normal 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);
|
108
unpublishedScripts/DomainContent/CellScience/moveVesiclesAC.js
Normal file
108
unpublishedScripts/DomainContent/CellScience/moveVesiclesAC.js
Normal 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);
|
Loading…
Reference in a new issue