hw7 parts

by Perry Keh

HTML

<div id="info">hw7 parts<br/>Basics</div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r70/three.min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/3587259/Code/Threejs/OrbitControls.js">
    
</script>

CSS

#info {
    position: absolute;
    top: 0px;
    width: 100%;
    padding: 10px;
    text-align: center;
    color: #ffff00
}
body {
    overflow: hidden;
}

JavaScript

var camera, scene, renderer, geometry, geometry2, material, material2, mesh, controls;
var pos, vel, pColor;
var clock = new THREE.Clock();
var puck, puck2;
var plane;
var pointLight;
var playmesh, lwall, rwall;
var mouse = new THREE.Vector3();


init();
animate();

function init() {

    var width = window.innerWidth;
	var height = window.innerHeight;
    scene = new THREE.Scene();
    var Puck = function(){
    this.pos = new THREE.Vector3();
    this.vel = new THREE.Vector3();
    this.pColor = new THREE.Color();
    this.pColor.setHSL(Math.random(), Math.random(), Math.random());
    this.mesh = new THREE.Mesh(new THREE.CylinderGeometry(5, 5, 2, 20),
    new THREE.MeshBasicMaterial());
  
    };
    
    Puck.prototype.update = function(dt){
        this.pos.add(this.vel.clone().multiplyScalar(dt));
        this.mesh.position.copy(this.pos);
 //       this.pointLight.position.set(this.pos.x, 10, this.pos.z);
 //       this.pointLight.color = this.pColor;
        this.mesh.material.color = this.pColor;
    };
    
    Puck.prototype.collision = function(){
    if (this.pos.x > 95) {    //x side bump    
        this.pos.x = 95;
        this.vel.set(-this.vel.x, 0, this.vel.z);
        this.pColor.setHSL(Math.random(), Math.random(), Math.random() / 2 + 0.5);
        
    
    } else if (this.pos.x < -95) {
        this.pos.x = -95;
        this.vel.set(- this.vel.x, 0,  this.vel.z);
        this.pColor.setHSL(Math.random(), Math.random(), Math.random() / 2 + 0.5);
    }
    if ( this.pos.z > 95) {     //z side bump
        if(this.pos.x > 50 || this.pos.x < -50||(this.pos.x < mouse.x+0.2 && this.pos.x >= mouse.x-0.2)){ 
        this.pos.z = 95;
         this.vel.set( this.vel.x, 0, - this.vel.z);
         this.pColor.setHSL(Math.random(), Math.random(), Math.random() / 2 + 0.5);
        }
        else{}
    }
        else if ( this.pos.z < -95) {
        if(this.pos.x > 50 || this.pos.x < -50||(this.pos.x <= mouse.x+0.2 && this.pos.x >= mouse.x-0.2)){
        ...