JavaScript
let grounds = [
{ x:-300, y: 0, z: -300},
{ x:-200, y: 0, z: -300},
{ x:-100, y: 0, z: -300},
{ x:0, y: 0, z: -300},
{ x:100, y: 0, z: -300},
{ x:200, y: 0, z: -300},
{ x:300, y: 0, z: -300},
{ x:-300, y: 0, z: -200},
{ x:-200, y: 0, z: -200},
{ x:-100, y: 0, z: -200},
{ x:0, y: 0, z: -200},
{ x:100, y: 0, z: -200},
{ x:200, y: 0, z: -200},
{ x:300, y: 0, z: -200},
{ x:-300, y: 0, z: -100},
{ x:-200, y: 0, z: -100},
{ x:-100, y: 0, z: -100},
{ x:0, y: 0, z: -100},
{ x:100, y: 0, z: -100},
{ x:200, y: 0, z: -100},
{ x:300, y: 0, z: -100},
{ x:-300, y: 0, z: 0},
{ x:-200, y: 0, z: 0},
{ x:-100, y: 0, z: 0},
{ x:0, y: 0, z: 0},
{ x:100, y: 0, z: 0},
{ x:200, y: 0, z: 0},
{ x:300, y: 0, z: 0},
{ x:-300, y: 0, z: 100},
{ x:-200, y: 0, z: 100},
{ x:-100, y: 0, z: 100},
{ x:0, y: 0, z: 100},
{ x:100, y: 0, z: 100},
{ x:200, y: 0, z: 100},
{ x:300, y: 0, z: 100},
{ x:-300, y: 0, z: 200},
{ x:-200, y: 0, z: 200},
{ x:-100, y: 0, z: 200},
{ x:0, y: 0, z: 200},
{ x:100, y: 0, z: 200},
{ x:200, y: 0, z: 200},
{ x:300, y: 0, z: 200},
{ x:-300, y: 0, z: 300},
{ x:-200, y: 0, z: 300},
{ x:-100, y: 0, z: 300},
{ x:0, y: 0, z: 300},
{ x:100, y: 0, z: 300},
{ x:200, y: 0, z: 300},
{ x:300, y: 0, z: 300}
];
function getClosestGround(gameplayerNodeposition){
let position = gameplayerNodeposition;
let items = grounds;
let l = items.length;
let rsh = 50;
let itemstoshow = [];
for (let i = 0; i < l; i++) {
let pos = items[i];
if ((position.x >= pos.x - rsh) && (position.x <= pos.x + rsh)) {
if ((position.z >= pos.z - rsh) && (position.z <= pos.z + rsh)) {
itemstoshow.push(pos);
break;
}
}
}
for (let i = 0; i < l; i++) {
let pos = items[i];
if(itemstoshow.indexOf(pos) < 0){
if ((position.x >= pos.x - rsh - rsh) && (position.x <= pos.x + rsh + rsh)) {
if...