three.js icon indicating copy to clipboard operation
three.js copied to clipboard

Fix frustum intersectsSprite bug, fix #24822

Open 06wj opened this issue 3 years ago • 7 comments

Fixed #24822

06wj avatar Oct 21 '22 05:10 06wj

@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...

WestLangley avatar Oct 21 '22 13:10 WestLangley

@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.

WestLangley avatar Oct 22 '22 00:10 WestLangley

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.: image

Now, I simplify this to the bounding sphere by calculating the center point and scaling.

06wj avatar Oct 22 '22 02:10 06wj

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 ]?

WestLangley avatar Oct 22 '22 02:10 WestLangley

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

06wj avatar Oct 22 '22 02:10 06wj

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.

WestLangley avatar Oct 22 '22 02:10 WestLangley

https://user-images.githubusercontent.com/800043/197328086-11e0f73a-d257-4d09-b92b-cead87218dea.mov

Added visualization of bounding spheres.

06wj avatar Oct 22 '22 08:10 06wj

Closing in favor of #31307.

Mugen87 avatar Jun 25 '25 13:06 Mugen87