Code viewer for World: EXP - FNL Wv0
class Node {
  constructor(world, idx, jdx) {
    this.world = world;
    this.GRID = world.GRID;
    this.idx = idx;
    this.jdx = jdx;

    this.columns = world.gridSize;
    this.rows = world.gridSize;
    this.squareSize = world.squareSize;

    this.calculatedTotal = 0; // f
    this.stepCost = 0; // g
    this.heuristicEstimate = 0; // h

    this.neighbours = [];
    this.previous = null;

    this.gridWall = false;
    this.mazeWall = false;

    this.isEmpty = false;

    this.tempCube = null;
    this.Cube = null;
  }
  
   addNeighbours() {
    if (this.idx < this.columns - 1) {
      this.neighbours.push(this.GRID[this.idx + 1][this.jdx]);
    }
    if (this.idx > 0) {
      this.neighbours.push(this.GRID[this.idx - 1][this.jdx]);
    }
    if (this.jdx < this.rows - 1) {
      this.neighbours.push(this.GRID[this.idx][this.jdx + 1]);
    }
    if (this.jdx > 0) {
      this.neighbours.push(this.GRID[this.idx][this.jdx - 1]);
    }
  }

  setAsGridWall() {
    this.gridWall = true;
  }

  setAsMazeWall() {
    this.mazeWall = true;
  }

  setAsEmpty() {
    this.isEmpty = true;
  }

  isWall() {
    return this.gridWall || this.mazeWall;
  }

  showTemperoryPath() {
    this.tempShape = new THREE.BoxGeometry(30, 30, 30);
    this.tempCube = new THREE.Mesh(this.tempShape);

    this.tempCube.material = new THREE.MeshBasicMaterial();

    this.tempCube.position.copy(this.translate(this.idx, this.jdx)); // translate my (i,j) grid coordinates to three.js (x,y,z) coordinates
    this.tempCube.material.color.setColorName("blue");
    this.tempCube.material.opacity = 0.25;
    ABWorld.scene.add(this.tempCube);
  }

  removeTemperoryPath() {
    ABWorld.scene.remove(this.tempCube);
    this.tempShape = null;
    this.tempCube = null;
  }

  showPermanentPath() {
    this.Shape = new THREE.BoxGeometry(30, 30, 30);
    this.Cube = new THREE.Mesh(this.Shape);

    this.Cube.material = new THREE.MeshBasicMaterial();

    this.Cube.position.copy(this.translate(this.idx, this.jdx)); // translate my (i,j) grid coordinates to three.js (x,y,z) coordinates
    this.Cube.material.color.setColorName("green");
    this.Cube.material.opacity = 0.25;
    ABWorld.scene.add(this.Cube);
  }

  removePermanentPath() {
    ABWorld.scene.remove(this.Cube);
    this.Shape = null;
    this.Cube = null;
  }

  translate(idx, jdx) {
    let vector = new THREE.Vector3();

    vector.y = 0;
    vector.x = idx * this.world.squareSize - this.world.MAXPOS / 2;
    vector.z = jdx * this.world.squareSize - this.world.MAXPOS / 2;

    return vector;
  }
}