function filter(p) { /* Filter in which you define a zone that no entites can enter */ /* Default box coordinates correspond to stage area in dev-demo */ if (p.position) { /* Define the points that create the "NO ENTITIES ALLOWED" box */ var BigStageMin = {x: 90, y: -1, z: 23}; var BigStageMax = {x: 109, y: 10, z: 30}; var ProceniumMin = {x: 97.5, y: -1, z: 30}; var ProceniumMax = {x: 102, y: 5, z: 33.5}; /* Define the point that you want entites that enter the box to appear */ var resetPoint = {x: Math.random() * (103.6 - 95.4) + 95.4, y: 2.5, z: 38.1557}; /* Random near-zero value used as "zero" to prevent two sequential updates from being exactly the same (which would cause them to be ignored) */ var x = p.position.x; var y = p.position.y; var z = p.position.z; if (((x > BigStageMin.x && x < BigStageMax.x) && (y > BigStageMin.y && y < BigStageMax.y) && (z > BigStageMin.z && z < BigStageMax.z)) || ((x > ProceniumMin.x && x < ProceniumMax.x) && (y > ProceniumMin.y && y < ProceniumMax.y) && (z > ProceniumMin.z && z < ProceniumMax.z))) { p.position = resetPoint; if (p.velocity) { p.velocity = {x: 0, y: 0, z: 0}; } if (p.acceleration) { p.acceleration = {x: 0, y: 0, z: 0}; } } } return p; }