question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sprite: Raycasting with offscreen sprites fails

See original GitHub issue
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, …)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
WestLangleycommented, May 11, 2019

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

0reactions
WestLangleycommented, Jun 6, 2019

Closing. Should be fixed in #16423.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problematic Raycasting of Offscreen THREE.Sprite object
Upon further research it seems like the raycaster responsible for emitting mouse events falsely detects intersections with offscreen THREE.Sprite objects.
Read more >
Implementing a Ray Caster Part 2: Sprite Rendering
We use sprites to render objects in worlds. Things like trees, pots, tables, and so on cannot be done well without sprites.
Read more >
Issue Raycasting Against Sprites - aframevr/aframe - GitHub
Raycasting against sprites fails with: THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.
Read more >
Making sprites smoothly exit the screen - A RokCoder Scratch ...
Scratch does not allow a sprite to move entirely off the edge of a screen in a smooth manner. This video shows a...
Read more >
A Look At The Nintendo's Off-Screen Sprite Rendering Glitches
With nowhere to place sprites off the screen, it presented a challenge to move them into view when scrolling. To get around this,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found