this is a array object and how i call itI need to find a way to send an array containing methods to a web worker , but I do not need the methods to do what I want to do , however I do still need to loop through the array in the worker.
postmessage(jsEngine.gameObjects)
- gives error for structured cloning;
(JsEngine.gameObjects is a object filled with other objects as its properties)
onRadar() {
let otherKey = Object.keys(jsEngine.gameObjects);
for (let i = 0; i < otherKey.length; i++) {
// let otherObjectnames = otherKey[i];
let otherObject = jsEngine.gameObjects[otherKey[i]];
if (this.name === otherObject.name)
continue;
if (otherObject === undefined)
continue;
// Check if the other object is in the vicinity of this one
let distance = calc_distance(this.transform, otherObject.transform);
if (distance <= this.sensorRange && distance <= this.sensorRange) {
}
}
}