three.js
three.js copied to clipboard
Fix frustum intersectsSprite bug, fix #24822
Fixed #24822
@06wj Thank you for this PR.
But remember, this does not have to be a pixel-perfect calculation. It is OK for the bounding sphere to be conservative (i.e., oversized).
Perhaps something less-computational may be preferable...
@06wj For example, the sphere center can remain at zero. Maybe it is sufficient to simply increase (double?) the radius to account for the worst-case center offset.
By changing the center and rotation, the sprite may be far away from the origin, so it is difficult to achieve this function by simple calculation.
e.g.:

Now, I simplify this to the bounding sphere by calculating the center point and scaling.
By changing the center and rotation, the sprite may be far away from the origin
this.center = new Vector2( 0.5, 0.5 ); // should be between 0 and 1
See #12931.
Do we need to support centers outside of [ 0, 1 ]?
By changing the center and rotation, the sprite may be far away from the origin
this.center = new Vector2( 0.5, 0.5 ); // should be between 0 and 1
This restriction is not found in the documentation or in the code
Even if centers outside [ 0, 1 ] are supported, I think the PR only requires changing the sphere radius.
I think a sufficient radius can be computed given the center coordinates.
https://user-images.githubusercontent.com/800043/197328086-11e0f73a-d257-4d09-b92b-cead87218dea.mov
Added visualization of bounding spheres.
Closing in favor of #31307.