(panel)
| 190 | * @param {import("./index").DebugPanelPlugin} panel - the debug panel instance |
| 191 | */ |
| 192 | export function applyPatches(panel) { |
| 193 | // patch Renderable |
| 194 | plugin.patch(Renderable, "postDraw", function (renderer) { |
| 195 | // biome-ignore lint/complexity/noArguments: needed to forward all arguments to patched method |
| 196 | this._patched.apply(this, arguments); |
| 197 | |
| 198 | if (this.image !== undefined) { |
| 199 | panel.counters.inc("sprites"); |
| 200 | } |
| 201 | panel.counters.inc("bounds"); |
| 202 | if (this instanceof Container) { |
| 203 | panel.counters.inc("children"); |
| 204 | } |
| 205 | // `draws` mirrors what `Container.draw` does — count renderables |
| 206 | // that got past the world's viewport/floating gate, since postDraw |
| 207 | // only fires for children the world actually draws. |
| 208 | if (this.ancestor === game.world) { |
| 209 | panel.counters.inc("draws"); |
| 210 | } |
| 211 | |
| 212 | // Mesh under a Camera3d: draw the proper 3D bounding-box wireframe |
| 213 | // instead of the flat, oversized 2D getBounds() box (which can't |
| 214 | // describe 3D geometry). Under a Camera2d a mesh self-projects to 2D, |
| 215 | // so it falls through to the generic box below. |
| 216 | if (this instanceof Mesh && panel.options.hitbox) { |
| 217 | const cam = this.parentApp?.viewport ?? game.viewport; |
| 218 | if (cam instanceof Camera3d) { |
| 219 | strokeMeshWireframe(renderer, panel, this, cam); |
| 220 | return; |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | // skip types that have their own dedicated patches, or when no |
| 225 | // overlay is enabled (hitbox AND velocity both off ⇒ nothing |
| 226 | // would be drawn). Note that hitbox and velocity are now |
| 227 | // independent flags — flipping just velocity on will draw the |
| 228 | // blue arrow without any other overlays. The panel's *visible* |
| 229 | // state is NOT consulted: enabled overlays keep rendering even |
| 230 | // when the user closes the panel window, so the panel is a |
| 231 | // configuration UI rather than a master "everything off" switch. |
| 232 | if ( |
| 233 | (!panel.options.hitbox && !panel.options.velocity) || |
| 234 | this instanceof Entity || |
| 235 | this.ancestor instanceof Entity || |
| 236 | this instanceof Text || |
| 237 | this instanceof BitmapText || |
| 238 | this instanceof Camera2d || |
| 239 | this instanceof ImageLayer |
| 240 | ) { |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | const bounds = this.getBounds(); |
| 245 | if (!bounds.isFinite()) { |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | renderer.save(); |
no test coverage detected