Skip to content

Conversation

@06wj
Copy link
Contributor

@06wj 06wj commented Sep 19, 2018

Fixed #14934

demo

If using an orthographic camera the results is wrong.

@06wj
Copy link
Contributor Author

06wj commented Sep 19, 2018

#14636

@WestLangley
Copy link
Collaborator

Thanks!

What happens if the camera is orthographic?

@06wj
Copy link
Contributor Author

06wj commented Sep 19, 2018

If the camera is orthographic, the sizeAttenuation has no effect on render result, we should not do worldScale.multiplyScalar( - mvPosition.z );.

I can't judge what type of camera he is.

@WestLangley
Copy link
Collaborator

I can't check if it is the camera is orthographic.

Right. That is what I was afraid of...

@06wj
Copy link
Contributor Author

06wj commented Sep 19, 2018

Maybe we should add a note if the camera is orthographic do not set sizeAttenuation of the sprite

@WestLangley
Copy link
Collaborator

The user could be using a custom ShaderMaterial or SpriteMaterial.
The material may, or may not, have a sizeAttenuation property (undefined, true, or false).
The user may, or may not, be using an orthographic camera when raycasting.
There are 2 x 3 x 2 = 12 cases.

@06wj
Copy link
Contributor Author

06wj commented Sep 22, 2018

#14888 Maybe this is a solution.

@WestLangley
Copy link
Collaborator

A raycast can emanate from any point, in any direction -- it does not have to emanate from a camera.

Consequently, raycasting against a Sprite that is camera-dependent and sized in screen-space does not necessarily make sense.

@06wj
Copy link
Contributor Author

06wj commented Sep 22, 2018

Sprite is a 3d object that is always facing the camera(This is the main reason raycast relies on cameras).

We can do this by dynamically setting the vertices in js or using shader.Just because we chose shader for performance reasons makes raycast implementation difficult, I don't think Sprite raycast is meaningless.

@WestLangley
Copy link
Collaborator

Sprite is a 3d object that is always facing the camera

Sprite is a 2D object, actually.

This is the main reason raycast relies on cameras

Raycasting does not require a camera. It is the sprite that is camera-dependent.

I don't think Sprite raycast is meaningless

Raycasting against a sprite using a ray that does not emanate from a camera is pretty meaningless because there is no way to determine how big the sprite should be, or how it should be oriented.

@mrdoob mrdoob modified the milestones: r99, r100 Nov 25, 2018
@mrdoob mrdoob modified the milestones: r100, r101 Dec 31, 2018
@06wj 06wj force-pushed the patch0 branch 3 times, most recently from 713ecc7 to d352c9e Compare January 23, 2019 16:04
@mrdoob mrdoob modified the milestones: r101, r102 Jan 31, 2019
@mrdoob mrdoob modified the milestones: r102, r103 Feb 28, 2019
@mrdoob mrdoob modified the milestones: r103, r104 Mar 27, 2019
@mrdoob mrdoob removed this from the r104 milestone Apr 24, 2019
@mrdoob mrdoob added this to the r105 milestone Apr 24, 2019
@06wj
Copy link
Contributor Author

06wj commented May 18, 2019

Fixed in #16423, so close it.

@06wj 06wj closed this May 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raycast problem with SpriteMaterial.sizeAttenuation set to false

3 participants