three.js: Sprite: Raycasting with offscreen sprites fails

Description of the problem

A user in the forum reported a bug in Sprite.raycast().

https://discourse.threejs.org/t/problematic-raycasting-of-offscreen-three-sprite-object/3644

The method depends on Object3D.modelViewMatrix. But this matrix is only updated if the sprite is actually rendered. If not, modelViewMatrix does not regard the actual object’s transformation. This means that Sprite.raycast() detects intersections of sprites outside the view frustum.

https://github.com/mrdoob/three.js/blob/1ffaa41a4b5f053ad62da1682844b53b041e63ca/src/objects/Sprite.js#L99

Three.js version
  • Dev
  • r95
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 20 (3 by maintainers)

Most upvoted comments

@06wj Do you want to propose a PR, since you have been working on this issue?