Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final Project #238

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
119 changes: 119 additions & 0 deletions 02/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>CS460 Assignment 2</title>
<style>
body {
background-color: black;
color: white; /* font color */
font-family: sans-serif;
margin: 0;
padding: 0;
height: 100%;
overflow: hidden !important;
}

#logo {
position: absolute;
right: 10px;
top: 10px;
}
</style>

<script type="text/javascript" src="http://get.goXTK.com/xtk_edge.js"></script>

<script type="text/javascript">

window.onload = function() {

// this gets called when the site is ready

// create a new scene and renderer
r = new X.renderer3D();
r.init();

// create a cube and add it!
var c = {};

for (var x = 0; x < 7; x++) {
c[x] = new X.cube();
c[x].center = [x*25, 0, 0]
r.add(c[x])
}
for (var x = 0; x < 7; x++) {
c[x] = new X.cube();
c[x].center = [x*25, 25, 0]
r.add(c[x])
}
for (var x = 0; x < 7; x++) {
c[x] = new X.cube();
c[x].center = [x*25, 50, 0]
if (x > 0 && x < 3) {
c[x].color = [0,1,0];
}
if (x > 3 && x < 6) {
c[x].color = [0,1,0];
}
r.add(c[x])
}
for (var x = 0; x < 7; x++) {
c[x] = new X.cube();
c[x].center = [x*25, 75, 0]
c[x].color = [1,1,1];
r.add(c[x]);
}


for (var x = 5; x < 7; x++) {
c[x] = new X.cube();
c[x].center = [x*25, 100, 0]
r.add(c[x]);
}
for (var x = 0; x < 2; x++) {
c[x] = new X.cube();
c[x].center = [x*25, 100, 0]
r.add(c[x]);
}
for (var x = 1; x < 3; x++) {
c[x] = new X.cube();
c[x].center = [x*25, -25, 0]
r.add(c[x]);
}
for (var x = 4; x < 6; x++) {
c[x] = new X.cube();
c[x].center = [x*25, -25, 0]
r.add(c[x]);
}
c = new X.cube();
c.center = [75, -25, 0];
c.color = [1,0,0];
r.add(c);
for (var x = 2; x < 5; x++) {
c[x] = new X.cube();
c[x].center = [x*25, -50, 0]
r.add(c[x]);
}
c = new X.cube();
c.center = [150, 125, 0];
r.add(c);
c = new X.cube();
c.center = [0, 125, 0];
r.add(c);
c = new X.cube();
c.center =
// set camera further away!
r.camera.position = [0, 0, 1000];

// render everything!
r.render();

};

</script>
</head>
<body>
<h1>CS460 Assignment 2</h1>
<div id="logo"><img style="height:60px" src="gfx/cs460.png"></div>
</body>
</html>
Binary file added 03/CS460_Assignment_03__Copy_ (1).pdf
Binary file not shown.
169 changes: 169 additions & 0 deletions 03/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<html>
<head>
<meta charset="UTF-8" />
<style>
html, body {
background-color:#000;
margin: 0;
padding: 0;
height: 100%;
overflow: hidden !important;
}
</style>
<script src="https://threejs.org/build/three.min.js" type="text/javascript"></script>
<script src="https://threejs.org/examples/js/controls/TrackballControls.js" type="text/javascript"></script>
<script>
window.onload = function() {

scene = new THREE.Scene();

fov = 75;
ratio = window.innerWidth / window.innerHeight;
zNear = 1;
zFar = 10000;
// console.log(ratio);
camera = new THREE.PerspectiveCamera(fov, ratio, zNear, zFar);
camera.position.set( 0, 0, 100);

renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

ambientLight = new THREE.AmbientLight();
scene.add( ambientLight );

light = new THREE.DirectionalLight( 0xffffff, 5.0 );
light.position.set( 10, 100, 10 );
scene.add( light );


// now we add the cube
// geometry = new THREE.BoxBufferGeometry( 20, 20, 20);
// material = new THREE.MeshStandardMaterial({ color: 0xffffff });
// cube = new THREE.Mesh( geometry, material);
// scene.add(cube);


//
// The invisible plane
//
geometry = new THREE.PlaneBufferGeometry( 10000, 10000 );
material = new THREE.MeshBasicMaterial( {
visible: false
});

invisible_plane = new THREE.Mesh( geometry, material );

scene.add( invisible_plane );
//
//
//



controls = new THREE.TrackballControls( camera );

animate();


//
// ACTION!
//

renderer.domElement.onclick = function(e) {

if (!e.shiftKey) {
e.preventDefault();
return false;
}

console.log('yes! you clicked!');

pixel_coords = new THREE.Vector2( e.clientX, e.clientY );

console.log('Pixel coordinates', pixel_coords);

vp_coords = new THREE.Vector2( ( pixel_coords.x / window.innerWidth ) * 2 - 1,
-( pixel_coords.y / window.innerHeight ) * 2 + 1);

console.log('Viewport coordinates', vp_coords);

vp_coords_near = new THREE.Vector3( vp_coords.x, vp_coords.y, 0);

raycaster = new THREE.Raycaster();
raycaster.setFromCamera(vp_coords_near, camera);
intersects = raycaster.intersectObject(invisible_plane);

console.log('Ray to Invisible Plane', intersects[0].point);

var x = (Math.floor(Math.random() * 5));

if (x = 0) {
var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 );
var colorstr = '#'+Math.floor(Math.random()*16777215).toString(16);
var material = new THREE.MeshBasicMaterial( {color: colorstr});
var cube = new THREE.Mesh( geometry, material );
cube.center = [e.clientX, e.clientY, 0];
scene.add( cube );
}
if (x = 1) {
var geometry = new THREE.TorusKnotGeometry( 10, 3, 100, 16 );
var colorstr = '#'+Math.floor(Math.random()*16777215).toString(16);
var material = new THREE.MeshBasicMaterial( {color: colorstr});
var torusKnot = new THREE.Mesh( geometry, material);
torusKnot.center = [e.clientX, e.clientY, 0];
scene.add( torusKnot );
}
if (x = 2) {
var geometry = new THREE.SphereBufferGeometry( 5, 32, 32 );
var colorstr = '#'+Math.floor(Math.random()*16777215).toString(16);
var material = new THREE.MeshBasicMaterial( {color: colorstr});
var sphere = new THREE.Mesh( geometry, material );
sphere.center = [e.clientX, e.clientY, 0];
scene.add( sphere );
}
if (x = 3) {
var geometry = new THREE.OctahedronBufferGeometry(1, 0);
var colorstr = '#'+Math.floor(Math.random()*16777215).toString(16);
var material = new THREE.MeshBasicMaterial( {color: colorstr});
var octo = new THREE.Mesh(geometry, material );
octo.center = [e.clientX, e.clientY, 0];
scene.add(octo);
}
if (x = 4) {
var geometry = new THREE.ConeBufferGeometry( 5, 20, 32 );
var colorstr = '#'+Math.floor(Math.random()*16777215).toString(16);
var material = new THREE.MeshBasicMaterial( {color: colorstr});
var cone = new THREE.Mesh( geometry, material );
cone.center = [e.clientX, e.clientY, 0];
scene.add( cone );
}
if (x = 5) {
var geometry = new THREE.RingBufferGeometry( 1, 5, 32 );
var colorstr = '#'+Math.floor(Math.random()*16777215).toString(16);
var material = new THREE.MeshBasicMaterial( {color: colorstr});
var mesh = new THREE.Mesh( geometry, material );
mesh.center = [e.clientX, e.clientY, 0];
scene.add( mesh );
}

}




};

function animate() {

requestAnimationFrame( animate );

controls.update();
renderer.render( scene, camera );

};

</script>
</head>
<body></body>
</html>
Binary file added 04/CS460_Assignment_04__Copy_ (1).pdf
Binary file not shown.
Loading