使用Javascript将对象数组发送给Web worker

时间:2017-09-21 00:44:03

标签: javascript arrays web-worker

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) {
    }
  }
}

0 个答案:

没有答案