From b08a9baa5ca9dd4280f1c596228b399c4f1c0f7c Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 8 Mar 2016 13:44:03 -0800 Subject: [PATCH] move cellscience --- .../CellScience/Scripts/navigationButton.js | 2 +- .../CellScience/importCellScience.js | 138 +++++++++++------- .../CellScience/motorProteinControllerAC.js | 48 ++++-- .../DomainContent/CellScience/moveCellsAC.js | 23 ++- .../CellScience/moveVesiclesAC.js | 23 ++- 5 files changed, 157 insertions(+), 77 deletions(-) diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/navigationButton.js b/unpublishedScripts/DomainContent/CellScience/Scripts/navigationButton.js index c1187bc6d5..b143678b42 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/navigationButton.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/navigationButton.js @@ -24,7 +24,7 @@ this.initialize = function(entityId) { var properties = Entities.getEntityProperties(entityId); - if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) { + if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false || properties.userData==="") { self.initTimeout = Script.setTimeout(function() { // print(' no user data yet, try again in one second') self.initialize(entityId); diff --git a/unpublishedScripts/DomainContent/CellScience/importCellScience.js b/unpublishedScripts/DomainContent/CellScience/importCellScience.js index 876df8adb1..97fbee5135 100644 --- a/unpublishedScripts/DomainContent/CellScience/importCellScience.js +++ b/unpublishedScripts/DomainContent/CellScience/importCellScience.js @@ -5,80 +5,115 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -var version = 1112; +var version = 1207; + +var WORLD_OFFSET = { + x: -6000, + y: -6000, + z: -6000 +} + +var WORLD_SCALE_AMOUNT = 1.0; + + +function offsetVectorToWorld(vector) { + var newVector; + + newVector = Vec3.sum(vector, WORLD_OFFSET); + + print('JBP NEW VECTOR IS:: ' + JSON.stringify(newVector)) + return newVector +} + +function scaleVectorToWorld(vector) { + var newVector; + + newVector = Vec3.multiply(vector, WORLD_SCALE_AMOUNT); + + return newVector +} + +function transformToSmallerWorld(vector) { + var newVector = offsetVectorToWorld(vector); + // newVector = scaleVectorToWorld(newVector); + return newVector; +} + var cellLayout; var baseLocation = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/"; var utilsScript = Script.resolvePath('Scripts/utils.js'); Script.include(utilsScript); -function makeUngrabbable(entityID) { - setEntityCustomData('grabbableKey', entityID, { - grabbable: false - }); -} +// function makeUngrabbable(entityID) { +// setEntityCustomData('grabbableKey', entityID, { +// grabbable: false +// }); +// } -Entities.addingEntity.connect(makeUngrabbable); +// Entities.addingEntity.connect(makeUngrabbable); assignVariables(); var locations = { - cellLayout: [{ + cellLayout: [offsetVectorToWorld({ x: 3000, - y: 13500, + y: 10500, z: 3000 - }, { + }), offsetVectorToWorld({ x: 3276.6, - y: 13703.3, + y: 10703.3, z: 4405.6 - }, 1800], - cells: [{ + }), 1800], + cells: [offsetVectorToWorld({ x: 13500, - y: 13500, + y: 10500, z: 13500 - }, { + }), offsetVectorToWorld({ x: 13501, - y: 13501, + y: 10501, z: 13501 - }, 400], - ribosome: [{ + }), 400], + ribosome: [offsetVectorToWorld({ x: 13500, y: 3000, z: 3000 - }, { + }), offsetVectorToWorld({ x: 13685, y: 3248, z: 2861 - }, 1000], - hexokinase: [{ + }), 1000], + hexokinase: [offsetVectorToWorld({ x: 3000, y: 3000, z: 13500 - }, { + }), offsetVectorToWorld({ x: 2755, y: 3121, z: 13501 - }, 2000], - mitochondria: [{ + }), 2000], + mitochondria: [offsetVectorToWorld({ x: 3000, - y: 13500, + y: 10500, z: 3000 - }, { + }), offsetVectorToWorld({ x: 3240, y: 13519, z: 3874 - }, 1000], - translation: [{ + }), 1000], + translation: [offsetVectorToWorld({ x: 3000, - y: 13500, + y: 10500, z: 3000 - }, { + }), offsetVectorToWorld({ x: 2962, - y: 13492, + y: 10492, z: 3342 - }, 1000] + }), 1000] }; +print('JBP locations locations' +JSON.stringify(locations)) + var scenes = [{ name: "Cells", objects: "", @@ -507,7 +542,6 @@ var scenes = [{ function ImportScene(scene) { - var sceneDataLines = scene.objects.split(";"); for (var i = 1; i < sceneDataLines.length; i++) { var data = sceneDataLines[i].split(","); @@ -565,27 +599,15 @@ function ImportScene(scene) { } -clearAllNav(); - -function clearAllNav() { - var result = Entities.findEntities(MyAvatar.position, 25000); - result.forEach(function(r) { - var properties = Entities.getEntityProperties(r, "name"); - if (properties.name.indexOf('navigation button') > -1) { - Entities.deleteEntity(r); - } - }) -} - function createLayoutLights() { Entities.addEntity({ type: "Light", name: "Cell layout light", - position: { + position:offsetVectorToWorld( { x: 3110, - y: 13660, + y: 10660, z: 3785 - }, + }), dimensions: { x: 1500, y: 1500, @@ -602,7 +624,8 @@ function createLayoutLights() { } function CreateNavigationButton(scene, number) { - Entities.addEntity({ + + var nav = Entities.addEntity({ type: "Box", name: scene.name + " navigation button", color: { @@ -634,7 +657,7 @@ function CreateNavigationButton(scene, number) { script: baseLocation + "Scripts/navigationButton.js?" + version, collisionless: true, }); - + print('JBP CREATE NAV AT::' +nav+" name: " + scene.name + ": " + JSON.stringify(scene.location)) } function CreateBoundary(scene) { @@ -8990,10 +9013,13 @@ function assignVariables() { for (var i = 0; i < scenes.length; i++) { // print('setting up scene. first, delete' + JSON.stringify(scenes[i])) - deleteAllInRadius(scenes[i].location, scenes[i].zone.dimensions.x); + // deleteAllInRadius(scenes[i].location, scenes[i].zone.dimensions.x); + CreateNavigationButton(scenes[i], i); + ImportScene(scenes[i]); // print('setting up scene. then import') - CreateNavigationButton(scenes[i], i); + + } createLayoutLights(); @@ -9002,7 +9028,7 @@ Script.scriptEnding.connect(function() { Entities.addingEntity.disconnect(makeUngrabbable); }); -Script.setTimeout(function() { - print('JBP stopping cell science import'); - Script.stop(); -}, 30000) \ No newline at end of file +// Script.setTimeout(function() { +// print('JBP stopping cell science import'); +// Script.stop(); +// }, 30000) \ No newline at end of file diff --git a/unpublishedScripts/DomainContent/CellScience/motorProteinControllerAC.js b/unpublishedScripts/DomainContent/CellScience/motorProteinControllerAC.js index 59577d49ba..bceed9153c 100644 --- a/unpublishedScripts/DomainContent/CellScience/motorProteinControllerAC.js +++ b/unpublishedScripts/DomainContent/CellScience/motorProteinControllerAC.js @@ -16,13 +16,32 @@ if (USE_LOCAL_HOST === true) { baseLocation = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/" } +var WORLD_OFFSET = { + x: -6000, + y: -6000, + z: -6000 +} + +var WORLD_SCALE_AMOUNT = 1.0; + +function offsetVectorToWorld(vector) { + var newVector; + + newVector = Vec3.sum(vector, WORLD_OFFSET); + + print('JBP NEW VECTOR IS:: ' + JSON.stringify(newVector)) + return newVector +} + var USE_LOCAL_HOST = false; -EntityViewer.setPosition({ +var basePosition = offsetVectorToWorld({ x: 3000, - y: 13500, + y: 10500, z: 3000 }); + +EntityViewer.setPosition(basePosition); EntityViewer.setKeyholeRadius(60000); var octreeQueryInterval = Script.setInterval(function() { EntityViewer.queryOctree(); @@ -44,11 +63,12 @@ var scriptURL = this.baseLocation + "Scripts/clickToRideAndLook.js?" + Math.rand var t = 0; var tInc = 0.001; -var sceneOffset = { +var sceneOffset = offsetVectorToWorld({ x: 3000, - y: 13500, + y: 10500, z: 3000 -}; +}); + var yOffset = { dynein: 16, kinesin: -28 @@ -60,11 +80,11 @@ var terms; var secondaryInit = false; function deleteAllMotorProteins() { - var position = { + var position = offsetVectorToWorld({ x: 3280, - y: 13703, + y: 10703, z: 4405 - }; + }); if (secondaryInit === true) { return; @@ -83,7 +103,7 @@ function deleteAllMotorProteins() { results.forEach(function(r) { var name = Entities.getEntityProperties(r, 'name').name; if (name.indexOf('Hifi-Motor-Protein-Anchor') > -1) { - // print('Script.clearTimeout DELETING A MOTOR PROTEIN::' + r) + // print('Script.clearTimeout DELETING A MOTOR PROTEIN::' + r) Entities.deleteEntity(r); } @@ -95,7 +115,7 @@ function deleteAllMotorProteins() { } function makeAll() { - // print('CREATING MOTOR PROTEINS') + // print('CREATING MOTOR PROTEINS') var segment; var segments = shuffleSegments(); var lastSegment = []; @@ -195,11 +215,11 @@ function update(deltaTime) { print("servers exist -- makeAll..."); Entities.setPacketsPerSecond(6000); print("PPS:" + Entities.getPacketsPerSecond()); - Script.setTimeout(function(){ + Script.setTimeout(function() { //print('SETTING TIMEOUT') - deleteAllMotorProteins() - },10000) - + deleteAllMotorProteins() + }, 10000) + initialized = true; } return; diff --git a/unpublishedScripts/DomainContent/CellScience/moveCellsAC.js b/unpublishedScripts/DomainContent/CellScience/moveCellsAC.js index cf35e081e0..c4ab9dbb5d 100644 --- a/unpublishedScripts/DomainContent/CellScience/moveCellsAC.js +++ b/unpublishedScripts/DomainContent/CellScience/moveCellsAC.js @@ -4,12 +4,29 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +var WORLD_OFFSET = { + x: -6000, + y: -6000, + z: -6000 +} -var basePosition = { +var WORLD_SCALE_AMOUNT = 1.0; + + +function offsetVectorToWorld(vector) { + var newVector; + + newVector = Vec3.sum(vector, WORLD_OFFSET); + + print('JBP NEW VECTOR IS:: ' + JSON.stringify(newVector)) + return newVector +} + +var basePosition = offsetVectorToWorld({ x: 3000, - y: 13500, + y: 10500, z: 3000 -}; +}, WORLD_OFFSET); var initialized = false; diff --git a/unpublishedScripts/DomainContent/CellScience/moveVesiclesAC.js b/unpublishedScripts/DomainContent/CellScience/moveVesiclesAC.js index 922f0d94cf..919d0b21df 100644 --- a/unpublishedScripts/DomainContent/CellScience/moveVesiclesAC.js +++ b/unpublishedScripts/DomainContent/CellScience/moveVesiclesAC.js @@ -4,12 +4,29 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +var WORLD_OFFSET = { + x: -6000, + y: -6000, + z: -6000 +} -var basePosition = { +var WORLD_SCALE_AMOUNT = 1.0; + +function offsetVectorToWorld(vector) { + var newVector; + + newVector = Vec3.sum(vector, WORLD_OFFSET); + + print('JBP NEW VECTOR IS:: ' + JSON.stringify(newVector)) + return newVector +} + +var basePosition = offsetVectorToWorld({ x: 3000, - y: 13500, + y: 10500, z: 3000 -}; +}, WORLD_OFFSET); + var initialized = false;