Template:Team:UC Davis/MutantWidget

From 2011.igem.org

(Difference between revisions)
Line 5: Line 5:
//Painstakingly coded by Keegan Owsley. Feel free to use it, but it might burn your house down.
//Painstakingly coded by Keegan Owsley. Feel free to use it, but it might burn your house down.
 +
function rerender()
 +
{
 +
 +
            camera.position.x = 250*Math.cos(theta);
 +
    camera.position.y = 250*Math.sin(theta);
 +
            if(phi < Math.PI/2)
 +
            {
 +
                phi = Math.PI/2;
 +
            }
 +
            if(phi > 3*Math.PI/4)
 +
            {
 +
                phi = 3*Math.PI/4;
 +
            }
 +
            camera.position.z = -250*Math.cos(phi);
 +
zaxislabel.rotation.y = Math.PI/2 - Math.atan2((zaxislabel.position.y-camera.position.y),(zaxislabel.position.x-camera.position.x));
 +
for(var i =0; i < yticklabels.length;i++)
 +
{
 +
yticklabels[i].rotation.y = -Math.PI/2 + Math.atan2((yticklabels[i].position.y-camera.position.y),(yticklabels[i].position.x-camera.position.x));
 +
}
 +
for(var i =0; i < xticklabels.length;i++)
 +
{
 +
xticklabels[i].rotation.y = -Math.PI/2 + Math.atan2((xticklabels[i].position.y-camera.position.y),(xticklabels[i].position.x-camera.position.x));
 +
}
 +
 +
 +
//renderer.clear();
 +
            renderer.render(scene, camera);
 +
}
function update3DPlotMeshes()
function update3DPlotMeshes()
Line 776: Line 804:
         {
         {
theta += (lastMouseX - event.pageX)/70
theta += (lastMouseX - event.pageX)/70
-
phi -= (lastMouseY - event.pageY)/70
+
phi -= (lastMouseY - event.pageY)/70;
-
            camera.position.x = 250*Math.cos(theta);
+
-
    camera.position.y = 250*Math.sin(theta);
+
-
            if(phi < Math.PI/2)
+
-
            {
+
-
                phi = Math.PI/2;
+
-
            }
+
-
            if(phi > 3*Math.PI/4)
+
-
            {
+
-
                phi = 3*Math.PI/4;
+
-
            }
+
-
            camera.position.z = -250*Math.cos(phi);
+
             lastMouseX = event.pageX;
             lastMouseX = event.pageX;
             lastMouseY = event.pageY;
             lastMouseY = event.pageY;
-
zaxislabel.rotation.y = Math.PI/2 - Math.atan2((zaxislabel.position.y-camera.position.y),(zaxislabel.position.x-camera.position.x));
+
rerender();
-
for(var i =0; i < yticklabels.length;i++)
+
-
{
+
-
yticklabels[i].rotation.y = -Math.PI/2 + Math.atan2((yticklabels[i].position.y-camera.position.y),(yticklabels[i].position.x-camera.position.x));
+
-
}
+
-
for(var i =0; i < xticklabels.length;i++)
+
-
{
+
-
xticklabels[i].rotation.y = -Math.PI/2 + Math.atan2((xticklabels[i].position.y-camera.position.y),(xticklabels[i].position.x-camera.position.x));
+
-
}
+
-
 
+
-
 
+
-
//renderer.clear();
+
-
            renderer.render(scene, camera);
+
         });
         });
     });
     });

Revision as of 03:33, 29 September 2011