Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// listen to the orbit controls to disable the raycaster while user adjusts the view
scene.controls.addEventListener('wheel', onControlWheel);
var grid = new vg.HexGrid({
rings: 5,
cellSize: 10
});
var board = new vg.Board(grid);
var mouse = new vg.MouseCaster(board.group, scene.camera, canvas);
var input = new Input(board.group, mouse);
var plane = new EditorPlane(board.group, grid, mouse);
nexus.input = input;
nexus.plane = plane;
nexus.board = board;
nexus.grid = grid;
nexus.scene = scene;
nexus.mouse = mouse;
var boardSize = 20; // TODO: get from settings
plane.generatePlane(boardSize * boardSize * 1.8, boardSize * boardSize * 1.8);
plane.addHoverMeshToGroup(scene.container);
board.generateOverlay(boardSize);
tower.tileAction.add(onMapChange, this);
// scene.add(board.group);
scene.focusOn(board.group);
if (map) {
function addTile(cell) {
if (!cell || nexus.board.getTileAtCell(cell)) return;
var newCell = new vg.Cell();
newCell.copy(cell);
newCell.h = Math.abs(nexus.mouse.wheel * nexus.board.tileHeightStep);
var newTile = tilemaker.getTile(newCell, ui.activeTile.slotid);
nexus.board.addTile(newTile);
tower.tileAction.dispatch(tower.TILE_ADD, newTile);
return newTile;
}
function addTile(cell) {
if (!cell || nexus.board.getTileAtCell(cell)) return;
var newCell = new vg.Cell();
newCell.copy(cell);
newCell.h = Math.abs(nexus.mouse.wheel * heightStep);
var newTile = nexus.grid.generateTile(newCell, 0.95);
nexus.board.addTile(newTile);
tower.tileAction.dispatch(tower.TILE_ADD, newTile);
return newTile;
}
function addTile(cell) {
if (!cell || nexus.board.getTileAtCell(cell)) return;
var newCell = new vg.Cell();
newCell.copy(cell);
newCell.h = Math.abs(nexus.mouse.wheel * nexus.board.tileHeightStep);
var newTile = tilemaker.getTile(newCell, ui.activeTile.slotid);
nexus.board.addTile(newTile);
tower.tileAction.dispatch(tower.TILE_ADD, newTile);
return newTile;
}
t.material = mat;
t.mesh.material = mat;
t.cell = cell;
cell.tile = t;
t.position.copy(nexus.grid.cellToPixel(cell));
t.position.y = t.cell.h * nexus.board.tileHeightStep;
}
else {
t = new vg.Tile({
cell: cell,
geometry: map.mesh || nexus.gen.geoGen.tileGeo,
material: materials[matid]
});
}
nexus.board.addTile(t);
return t;
}
function addTile(cell) {
if (!cell || nexus.board.getTileAtCell(cell)) return;
var newCell = new vg.Cell();
newCell.copy(cell);
newCell.h = Math.abs(nexus.mouse.wheel * heightStep);
var newTile = nexus.grid.generateTile(newCell, 0.95);
nexus.board.addTile(newTile);
tower.tileAction.dispatch(tower.TILE_ADD, newTile);
return newTile;
}
function addTile(cell) {
if (!cell || nexus.board.getTileAtCell(cell)) return;
var newCell = new vg.Cell();
newCell.copy(cell);
newCell.h = Math.abs(nexus.mouse.wheel * heightStep);
var newTile = nexus.grid.generateTile(newCell, 0.95);
nexus.board.addTile(newTile);
tower.tileAction.dispatch(tower.TILE_ADD, newTile);
return newTile;
}
function addTile(cell) {
if (!cell || nexus.board.getTileAtCell(cell)) return;
var newCell = new vg.Cell();
newCell.copy(cell);
newCell.h = Math.abs(nexus.mouse.wheel * heightStep);
var newTile = nexus.grid.generateTile(newCell, 0.95);
nexus.board.addTile(newTile);
tower.tileAction.dispatch(tower.TILE_ADD, newTile);
return newTile;
}
function resetHeightStep(newHeightStep) {
if (!nexus.board) return;
var i, t;
var step = newHeightStep || nexus.board.tileHeightStep;
for (i = 0; t = nexus.board.tiles[i]; i++) {
t.position.y = t.cell.h * step;
}
}