Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh raycast function problem #24083

Closed
cnywt opened this issue May 18, 2022 · 10 comments
Closed

Mesh raycast function problem #24083

cnywt opened this issue May 18, 2022 · 10 comments

Comments

@cnywt
Copy link

cnywt commented May 18, 2022

Describe the bug

When the BufferAttribute class uses the normalized attribute and is set to true; the raycast function of the Mesh class does not use the normalized Vector3 calculation synchronously
Describe the bug

To Reproduce
1、create a BufferGeometry width position attribute data not normailized
2、position BufferAttribute normalized attribute set to true;
3、render this geometry to scene and get it by Raycaster

@Mugen87
Copy link
Collaborator

Mugen87 commented May 18, 2022

Do you mind to properly fill out the issue template? Also please demonstrate the issue with a live example.

@cnywt
Copy link
Author

cnywt commented May 18, 2022

Sorry, my English is so bad; so I hope to describe the problem briefly and directly;
This problem was encountered by me helping a stranger solve the inaccurate location of the gltf model by clicking on it, so I don't have an online demo for the time being;

@cnywt
Copy link
Author

cnywt commented May 18, 2022

Please let me know if the issue has no value and I will close it;

@cnywt cnywt closed this as completed May 18, 2022
@cnywt cnywt reopened this May 18, 2022
@Mugen87
Copy link
Collaborator

Mugen87 commented May 18, 2022

create a BufferGeometry width position attribute data not normailized

What does that mean? How does the position data look like?

@cnywt
Copy link
Author

cnywt commented May 18, 2022

create a BufferGeometry width position attribute data not normailized

What does that mean? How does the position data look like?

sorry for disturbing your mind,This refers to any position data that is not normalized,like:
this triangle position const array= new Float32Array([100 ,100 ,100 ,100, 200,100 ,100, 100 ,200]);
if code like this :
geometry.attribute.set("position",new BufferAttribute(array ,3 ,true));
then :
If we obtain the mesh with this geometry through the ray, we will find that the obtained position is wrong

@Mugen87
Copy link
Collaborator

Mugen87 commented May 18, 2022

Your setup is actually not valid. The normalized attribute only applies to integer data, not float.

@cnywt
Copy link
Author

cnywt commented May 18, 2022

valid
I'm sorry, this was originally a problem in the gltf model. I used the wrong code for you to simulate. The InterleavedBufferAttribute is used in that gltf.

Your setup is actually not valid. The normalized attribute only applies to integer data, not float.
I'm sorry, this was originally a problem in the gltf model. I used the wrong code for you to simulate. The InterleavedBufferAttribute is used in that gltf.

@cnywt
Copy link
Author

cnywt commented May 18, 2022

Your setup is actually not valid. The normalized attribute only applies to integer data, not float.

And thank you for letting me learn something new

@gkjohnson
Copy link
Collaborator

I think this is related to #22874. It's not valid for float buffers but right now if a position or uv attribute are normalized with integer data then raycasting will not return a correct result. cc @donmccurdy.

@Mugen87
Copy link
Collaborator

Mugen87 commented May 19, 2022

Even if it's a PR, it's better to follow the discussion at #22874. Marking this as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants