var version = 188; var baseLocation = "http://dynamoidapps.com/HighFidelity/Cosm/"; var cellLayout; assignVariables(); var locations = { cellLayout:[{x:3000,y:13500,z:3000},{x:3276.6, y:13703.3, z:4405.6}, 1800], cells:[{x:13500,y:13500,z:13500},{x:13501,y:13501,z:13501}, 400], ribosome:[{x:13500, y:3000, z:3000},{x:13501, y:3001, z:3001}, 1000], hexokinase:[{x:3000, y:3000, z:13500},{x:3001, y:3500, z:13500}, 1000], mitochondria:[{x:3000, y:13500, z:3000},{x:3240, y:13519, z:3874}, 1000], translation:[{x:3000, y:13500, z:3000},{x:2962, y:13492, z:3342}, 1000] }; var scenes = [ { name:"Cells", objects:"", location: locations.cells[0], entryPoint: locations.cells[1], zone: { dimensions:{x:4000,y:4000,z:4000}, light:{r:255,g:200, b:200}, intensity:1.1, ambient: 0.7, sun:true, skybox: "cells_skybox_cross" }, instances:[{ model:"Cell", dimensions:{x:400,y:450,z:400}, offset:{x:0,y:0,z:0}, radius:500, number:10, script: "moveRandomly", visible:true }], boundary: { radius: locations.cells[2], center: locations.cells[0], location: locations.cellLayout[1], target: locations.cellLayout[0] } }, { name: "CellLayout", objects: cellLayout, location: locations.cellLayout[0], entryPoint: locations.cellLayout[1], zone: { dimensions:{x:4000,y:4000,z:4000}, light:{r:247,g:233,b:220}, intensity:2.3, ambient: 0.7, sun:true, skybox: "cosmos_skybox_blurred" }, instances:[ { model:"translation", dimensions:{x:10,y:16,z:10}, offset:{x:0,y:0,z:0}, radius:300, number:15, userData: JSON.stringify({ target:locations.ribosome[1], location:locations.ribosome[0], baseURL:baseLocation }), script:"zoom", visible:true }, { model:"vesicle", dimensions:{x:60,y:60,z:60}, randomSize: 10, offset:{x:0,y:0,z:0}, radius:1000, number:45, userData:"", script:"moveRandomly", visible:true }, {//golgi vesicles model:"vesicle", dimensions:{x:10,y:10,z:10}, randomSize: 10, offset:{x:-319,y:66,z:976}, radius:140, number:20, userData:"", script:"", visible:true }, {//golgi vesicles model:"vesicle", dimensions:{x:15,y:15,z:15}, randomSize: 10, offset:{x:-319,y:66,z:976}, radius:115, number:15, userData:"", script:"moveRandomly", visible:true }, { model:"vesicle", dimensions:{x:50,y:50,z:50}, randomSize: 10, offset:{x:0,y:0,z:0}, radius:600, number:30, userData:"", script:"", visible:true }, {//outer vesicles model:"vesicle", dimensions:{x:60,y:60,z:60}, randomSize: 10, offset:{x:0,y:0,z:0}, radius:1600, number:45, userData:"", script:"", visible:true }, {//outer vesicles model:"vesicle", dimensions:{x:40,y:40,z:40}, randomSize: 10, offset:{x:0,y:0,z:0}, radius:1400, number:45, userData:"", script:"moveRandomly", visible:true }, {//outer vesicles model:"vesicle", dimensions:{x:80,y:80,z:80}, randomSize: 10, offset:{x:0,y:0,z:0}, radius:1800, number:45, userData:"", script:"moveRandomly", visible:true }, // {//wigglies // model:"wiggly", // dimensions:{x:320,y:40,z:160}, // randomSize: 10, // offset:{x:0,y:0,z:0}, // radius:1800, // number:50, // userData:"", // script:"moveRandomly", // visible:true // }, //// {//wigglies // model:"wiggly", // dimensions:{x:640,y:80,z:320}, // randomSize: 10, // offset:{x:0,y:0,z:0}, // radius:2100, // number:50, // userData:"", // script:"moveRandomly", // visible:true // }, { model:"hexokinase", dimensions:{x:3,y:4,z:3}, randomSize: 10, offset:{x:236,y:8,z:771}, radius:80, number:15, userData: JSON.stringify({ target:locations.hexokinase[1], location:locations.hexokinase[0], baseURL:baseLocation }), script:"zoom", visible:true }, { model:"pfructo_kinase", dimensions:{x:3,y:4,z:3}, randomSize: 10, offset:{x:236,y:8,z:771}, radius:60, number:15, userData: "", script:"", visible:true }, { model:"glucose_isomerase", dimensions:{x:3,y:4,z:3}, randomSize: 10, offset:{x:236,y:8,z:771}, radius:70, number:15, userData: "", script:"", visible:true } // { // model:"NPC", // dimensions:{x:20,y:20,z:20}, // randomSize: 10, // offset:{x:208.593693,y:6.113100222,z:153.3202277}, // radius:520, // number:25, // userData: "", // script:"", // visible:true // } ], boundary: { radius: locations.cellLayout[2], center: locations.cellLayout[0], location: locations.cells[1], target: locations.cells[0] } }, { name:"Ribosome", objects:"", location: locations.ribosome[0], entryPoint: locations.ribosome[1], zone: { dimensions:{x:4000,y:4000,z:4000}, light:{r:255,g:255,b:255}, intensity:0.6, ambient: 0.4, sun:true, skybox: "ribosome_skybox" }, instances:[ { model:"translation_highres", dimensions:{x:3000,y:3000,z:1200}, offset:{x:0,y:0,z:0}, radius:0, number:1, userData:"", script: "", visible:true } ], boundary: { radius: locations.ribosome[2], center: locations.ribosome[0], location: locations.translation[1], target: locations.translation[0] } }, { name:"Hexokinase", objects:"", location: locations.hexokinase[0], entryPoint: locations.hexokinase[1], zone: { dimensions:{x:6000,y:6000,z:6000}, light:{r:255,g:255,b:255}, intensity:0.6, ambient: 0.4, sun:true, skybox: "hexokinase_skybox" }, instances:[ { model:"hexokinase_highres", dimensions:{x:1200,y:1200,z:1200}, offset:{x:0,y:0,z:0}, radius:0, number:1, userData:"", script: "moveRandomly", visible:true } ], boundary: { radius: locations.hexokinase[2], center: locations.hexokinase[0], location: locations.mitochondria[1], target: locations.mitochondria[0] } } ]; function ImportScene(scene) { var sceneDataLines = scene.objects.split(";"); for (var i = 1; i < sceneDataLines.length; i++) { var data = sceneDataLines[i].split(","); var posX = Number(data[1]) + scene.location.x; var posY = Number(data[2]) + scene.location.y; var posZ = Number(data[3]) + scene.location.z; var url = baseLocation + scene.name + "/" + data[0] + ".fbx?" + version; var position = {x:posX, y:posY, z:posZ}; var dimensions = {x:data[4], y:data[5], z:data[6]}; var rotation = Quat.fromPitchYawRollDegrees(data[7],data[8],data[9]); var name = data[0].replace(/[0-9]/g, ''); var labelDistance = (Number(data[4]) + Number(data[5]) + Number(data[6]))/3 + 50; var idDimensions = {x:Number(dimensions.x)+200, y:Number(dimensions.y)+200, z:Number(dimensions.z)+200}; //print ("Label distance is " + labelDistance + " for " + name); if (name != "" && name != "NPC" && name != "undefined" && name != "microtubule") CreateIdentification(name, position, {x:0, y:0, z:0}, idDimensions, labelDistance); CreateEntity(data[0], position, rotation, dimensions, url, "", "", true); } if (scene.name == "CellLayout") { MakeMTEnds(); MakeMTLabels(); } //create zone and instances CreateZone(scene); CreateInstances(scene); CreateBoundary(scene); CreateBackgroundAudio(scene.name, scene.location, scene.dimensions); print("done " + scene.name); } function CreateNavigationButton(scene, number){ Entities.addEntity({ type: "Sphere", name: scene.name + " navigation button", color: { red: 200, green: 0, blue: 0 }, dimensions: {x:10,y:10,z:10}, visible: false, userData: JSON.stringify({ name:scene.name, entryPoint: scene.entryPoint, target: scene.location, offset: number, baseURL: baseLocation }), script: baseLocation + "Scripts/navigationButton.js?" + version, ignoreForCollisions:true }); } function CreateBoundary (scene) { var pts = getEvenlyDistributedPointsOnSphere(80); for (var i = 0; i < pts.length; i++) { var boundPos = { x: scene.boundary.center.x + scene.boundary.radius * pts[i].x, y: scene.boundary.center.y + scene.boundary.radius * pts[i].y, z: scene.boundary.center.z + scene.boundary.radius * pts[i].z }; var script = "zoom.js?" + version; var dimensions = {x: 0.6 * scene.boundary.radius, y: 0.6 * scene.boundary.radius, z: 100}; var boundRot = getLookRotation(boundPos, scene.boundary.center); var data = JSON.stringify({ target:scene.boundary.target, location:scene.boundary.location, baseURL: baseLocation }); Entities.addEntity({ type: "Sphere", name: "boundary", color: { red: 200, green: 0, blue: 0 }, position: boundPos, rotation: boundRot, dimensions: dimensions, visible: false, userData: data, script: baseLocation + "Scripts/" + script, ignoreForCollisions:true }); } } function getLookRotation (loc, targetPos) { var direction = Vec3.normalize(Vec3.subtract(loc, targetPos)); var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, {x:1, y:0, z:0}); var yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * 180.0 / Math.PI, {x:0, y:1, z:0}); return Quat.multiply(yaw, pitch); } function getEvenlyDistributedPointsOnSphere (numPoints) { var points = []; var inc = Math.PI * (3 - Math.sqrt(5)); var off = 2 / numPoints; for (var i = 0; i < numPoints; i++) { var y = i * off - 1 + (off / 2); var r = Math.sqrt(1 - y * y); var phi = i * inc; points[i] = {x: Math.cos(phi) * r, y: y, z: Math.sin(phi) * r}; } return points; } function deleteAllInRadius (position, radius) { var n = 0; var arrayFound = Entities.findEntities(position, radius); for (var i = 0; i < arrayFound.length; i++) { Entities.deleteEntity(arrayFound[i]); Entities.deletingEntity(arrayFound[i]); } // print("deleted " + arrayFound.length + " entities"); } function CreateInstances(scene){ for (var i=0; i < scene.instances.length; i++){ for (var j=0; j