Commit b7a0836
fix: PR #1464 review round 4 — three more bugs
**Camera3d.isVisible bounding-sphere radius was inradius, not circumradius**
The frustum-sphere test used `max(width, height) * 0.5` for the
renderable's culling radius, which is the inradius of the bounds
rect — smaller than the distance from center to a corner. Sprites
near a frustum edge could be marked invisible while a corner was
still on-screen. Switched to `√(w² + h²) / 2` (the circumradius);
the sphere now always encloses every corner of the bounds rect.
**Stage.reset read `settings.cameras[0]` for sortOn, not the
camera registered as "default"**
A split-screen / minimap stage can list a non-default Camera2d
BEFORE its main Camera3d in the cameras array (e.g.
`new Stage({ cameras: [minimap2d, main3d] })`), and the previous
code would pick the minimap's Camera2d class — leaving
`world.sortOn = "z"` while the perspective view needed "depth".
Switched to `this.cameras.get("default")?.constructor`, gated on
`settings.cameras.length > 0` so the singleton fallback case
(no class declared anywhere) still leaves `world.sortOn`
untouched.
Regression test in `camera3d_integration.spec.js`.
**MaterialBatcher GPU_TEXTURE_CACHE_RESET subscription leaked
across renderer disposal**
`MaterialBatcher.destroy()` unsubscribed from `event.on(...)` but
nothing called it — neither `WebGLRenderer` nor `Application`
walked the batchers on teardown. Every discarded renderer kept
its batchers (and itself) alive via the listener, and future
cache-reset events fired into dead renderers.
Added `WebGLRenderer.destroy()` that walks `this.batchers` and
calls each one's `destroy()`. `Application.destroy()` now invokes
`this.renderer?.destroy?.()` so the chain is wired end-to-end.
3768 tests pass (+1 new regression test).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2669c13 commit b7a0836
5 files changed
Lines changed: 72 additions & 3 deletions
File tree
- packages/melonjs
- src
- application
- camera
- state
- video/webgl
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
652 | 660 | | |
653 | 661 | | |
654 | 662 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
567 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
568 | 575 | | |
569 | 576 | | |
570 | 577 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
213 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
214 | 228 | | |
215 | 229 | | |
216 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
365 | 381 | | |
366 | 382 | | |
367 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
310 | 334 | | |
311 | 335 | | |
312 | 336 | | |
| |||
0 commit comments