PhysicsDebug.js 534 B

1234567891011121314
  1. "atomic component";
  2. //A PhysicsDebug component
  3. exports.component = function(self) {
  4. self.start = function() {
  5. //we get a debugRenderer from the scene, if scene doesn't have one, it won't work
  6. var debug = self.scene.getComponent("DebugRenderer");
  7. var world = self.scene.getComponent("PhysicsWorld2D");
  8. //we excecute drawDebugGeometry function to render world debug geometry
  9. self.subscribeToEvent("PostRenderUpdate",function(_) {
  10. world.drawDebugGeometry();
  11. });
  12. };
  13. };