js/environment.js
// don't want to lose your params.
don't want to lose your params.
don ' t want to lose your params .
function Wall(params) {
  Core.setDefaultProperties(params, WALL_DEFAULTS);
  this.type = "Wall";
  if (params.visible) {
    this.material = new THREE.MeshPhongMaterial({color: params.color})
  }
  else {
    this.material = new THREE.MeshPhongMaterial({color: params.color});
    this.material.transparent = true;
    this.material.opacity = 0;
    invisibleWalls.push(this);
  }
  this.speed = params.speed;
  this.unlockedBy = params.unlockedBy;
  if (params.cell) {
    params.position = params.cell.clone();
    this.geometry = new THREE.BoxGeometry(params.thickness, params.thickness, params.height);
    this.mesh = new THREE.Mesh(this.geometry, this.material);
    this.mesh.position.copy(params.position);
  }
  else if (params.start && params.end) {
    let startToEnd = params.end.clone().sub(params.start);
    let length = startToEnd.length();
    params.position = params.start.clone().lerp(params.end, 0.5);
    this.geometry = new THREE.BoxGeometry(length, params.thickness, params.height);
    this.mesh = new THREE.Mesh(this.geometry, this.material);
    this.mesh.position.copy(params.position);
    let x_axis = new THREE.Vector3(1,0,0);
    this.mesh.rotation.z = -startToEnd.angleTo(x_axis);
  }
  else {
    this.geometry = new THREE.BoxGeometry(params.length, params.thickness, params.height);
    this.mesh = new THREE.Mesh(this.geometry, this.material);
  }
  let offset = new THREE.Vector3(0,0,params.height/2);
  this.mesh.position.addVectors(params.position, offset);
}
function Wall ( params ) { Core . setDefaultProperties ( params , WALL_DEFAULTS ) ; this . type = "Wall" ; if ( params . visible ) { this . material = new THREE . MeshPhongMaterial ( { color : params . color } ) } else { this . material = new THREE . MeshPhongMaterial ( { color : params . color } ) ; this . material . transparent = true ; this . material . opacity = 0 ; invisibleWalls . push ( this ) ; } this . speed = params . speed ; this . unlockedBy = params . unlockedBy ; if ( params . cell ) { params . position = params . cell . clone ( ) ; this . geometry = new THREE . BoxGeometry ( params . thickness , params . thickness , params . height ) ; this . mesh = new THREE . Mesh ( this . geometry , this . material ) ; this . mesh . position . copy ( params . position ) ; } else if ( params . start && params . end ) { let startToEnd = params . end . clone ( ) . sub ( params . start ) ; let length = startToEnd . length ( ) ; params . position = params . start . clone ( ) . lerp ( params . end , 0.5 ) ; this . geometry = new THREE . BoxGeometry ( length , params . thickness , params . height ) ; this . mesh = new THREE . Mesh ( this . geometry , this . material ) ; this . mesh . position . copy ( params . position ) ; let x_axis = new THREE . Vector3 ( 1 , 0 , 0 ) ; this . mesh . rotation . z = - startToEnd . angleTo ( x_axis ) ; } else { this . geometry = new THREE . BoxGeometry ( params . length , params . thickness , params . height ) ; this . mesh = new THREE . Mesh ( this . geometry , this . material ) ; } let offset = new THREE . Vector3 ( 0 , 0 , params . height / 2 ) ; this . mesh . position . addVectors ( params . position , offset ) ; }
don't want to lose your params.
don ' t want to lose your params .
// Use the default height and thickness if undefined // Create the material // this.material = new THREE.ShadowMaterial(); // store a ref for later // Construct a single wall peg at the coords given by cell // Build geometry and mesh // Construct a wall from start to end, with optionally specified width, height // Find the length of the wall // Position the wall between the endpoints // Build the geometry and mesh // Construct a wall with whichever params are specified, using defaults where unspecified // Assuming we want walls to sit on the floor, we need to shift them up // a little bit (their position is in the center of box)