function checkInside(){
        var piece = selectedPiece.pieceObj;
        var length = piece.type;
        var orientation = piece.orientation;
        var pos = piece.pos;

        if(orientation === 0){
            if(pos[1] < 0){
                pos[1] = 0;
                selectedPiece.obj.position.z = squareSize * length / 2;
            } else if(pos[1] + length >= board.length){
                pos[1] = board.length - length;
                selectedPiece.obj.position.z = (board.length - length / 2) * squareSize;
            }
        } else {
            if(pos[0] < 0){
                pos[0] = 0;
                selectedPiece.obj.position.x = squareSize * length / 2;
            } else if(pos[0] + length >= board.length){
                pos[0] = board.length - length;
                selectedPiece.obj.position.x = (board.length - length / 2) * squareSize;
            }
        }    
    }
/**
     * Checks whether the piece is outside the board and resets the coordinates so that it is inside.
     */
Checks whether the piece is outside the board and resets the coordinates so that it is inside.
Checks whether the piece is outside the board and resets the coordinates so that it is inside .
function checkInside(){
        var piece = selectedPiece.pieceObj;
        var length = piece.type;
        var orientation = piece.orientation;
        var pos = piece.pos;
        if(orientation === 0){
            if(pos[1] < 0){
                pos[1] = 0;
                selectedPiece.obj.position.z = squareSize * length / 2;
            } else if(pos[1] + length >= board.length){
                pos[1] = board.length - length;
                selectedPiece.obj.position.z = (board.length - length / 2) * squareSize;
            }
        } else {
            if(pos[0] < 0){
                pos[0] = 0;
                selectedPiece.obj.position.x = squareSize * length / 2;
            } else if(pos[0] + length >= board.length){
                pos[0] = board.length - length;
                selectedPiece.obj.position.x = (board.length - length / 2) * squareSize;
            }
        }    
    }
function checkInside ( ) { var piece = selectedPiece . pieceObj ; var length = piece . type ; var orientation = piece . orientation ; var pos = piece . pos ; if ( orientation === 0 ) { if ( pos [ 1 ] < 0 ) { pos [ 1 ] = 0 ; selectedPiece . obj . position . z = squareSize * length / 2 ; } else if ( pos [ 1 ] + length >= board . length ) { pos [ 1 ] = board . length - length ; selectedPiece . obj . position . z = ( board . length - length / 2 ) * squareSize ; } } else { if ( pos [ 0 ] < 0 ) { pos [ 0 ] = 0 ; selectedPiece . obj . position . x = squareSize * length / 2 ; } else if ( pos [ 0 ] + length >= board . length ) { pos [ 0 ] = board . length - length ; selectedPiece . obj . position . x = ( board . length - length / 2 ) * squareSize ; } } }
Checks whether the piece is outside the board and resets the coordinates so that it is inside.
Checks whether the piece is outside the board and resets the coordinates so that it is inside .