Update each engine object, remove destroyed objects, and update time * can be called manually if objects need to be updated outside of main loop * @memberof Engine
()
| 467 | * can be called manually if objects need to be updated outside of main loop |
| 468 | * @memberof Engine */ |
| 469 | function engineObjectsUpdate() |
| 470 | { |
| 471 | // get list of solid objects for physics optimization |
| 472 | engineObjectsCollide = engineObjects.filter(o=>o.collideSolidObjects); |
| 473 | |
| 474 | // recursive object update |
| 475 | function updateChildObject(o) |
| 476 | { |
| 477 | if (o.destroyed) return; |
| 478 | |
| 479 | o.update(); |
| 480 | for (const child of o.children) |
| 481 | updateChildObject(child); |
| 482 | } |
| 483 | for (const o of engineObjects) |
| 484 | { |
| 485 | if (o.parent || o.destroyed) continue; |
| 486 | |
| 487 | // update top level objects |
| 488 | o.update(); |
| 489 | o.updatePhysics(); |
| 490 | for (const child of o.children) |
| 491 | updateChildObject(child); |
| 492 | o.updateTransforms(); |
| 493 | } |
| 494 | |
| 495 | // remove destroyed objects |
| 496 | engineObjects = engineObjects.filter(o=>!o.destroyed); |
| 497 | } |
| 498 | |
| 499 | /** Destroy and remove all objects |
| 500 | * - This can be used to clear out all objects when restarting a level |
no test coverage detected