this is a array object and how i call it我需要找到一种方法将包含方法的数组发送给Web worker,但我不需要方法来做我想做的事情,但是我仍然需要循环遍历数组在工人中。
postmessage(jsEngine.gameObjects)
- 为结构化克隆提供错误;
(JsEngine.gameObjects是一个充满其他对象作为其属性的对象)
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) {
}
}
}