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

Update Line.js #29679

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Update Line.js #29679

wants to merge 2 commits into from

Conversation

hlfkyo
Copy link

@hlfkyo hlfkyo commented Oct 17, 2024

Modify a bug in ray intersection for line objects

Related issue: #If a sub object of a group object contains polylines, and the group object is scaled larger by the thi.scale parameter, the threshold parameter applied during ray intersection is not synchronously scaled larger, resulting in errors in ray intersection to many line segments.Sorry, my English is very poor.

Description
Calculate the correct threshold value using the scaling factor of the matrixWorld. Previously, we used the scaling factor of the local matrix, but there was no valid scaling factor for the children nodes in the local matrix. The original scaling calculation method was too rough and inaccurate:
'const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );'

The new way is:
const scaleMax = matrixWorld.getMaxScaleOnAxis();//
const localThreshold = threshold / scaleMax;

Use the world matrix and find the maximum coefficient

Modify a bug in ray intersection for line objects
Copy link

github-actions bot commented Oct 17, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 690.8
171.12
690.78
171.13
-23 B
+10 B
WebGPU 816.43
220.08
816.41
220.09
-23 B
+10 B
WebGPU Nodes 815.94
219.95
815.92
219.96
-23 B
+10 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 463.45
111.9
463.45
111.9
+0 B
+0 B
WebGPU 538.61
145.41
538.61
145.41
+0 B
+0 B
WebGPU Nodes 494.73
135.28
494.73
135.28
+0 B
+0 B

@hlfkyo
Copy link
Author

hlfkyo commented Oct 17, 2024

The modified content is:
modifyTo

Error examples:
微信图片_20241017165851

Modify spaces
@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 19, 2024

Do you mind sharing a fiddle that demonstrates the limitations of current approach?

@hlfkyo
Copy link
Author

hlfkyo commented Oct 30, 2024

Do you mind sharing a fiddle that demonstrates the limitations of current approach?

I'm not sure how to create a Fiddle. I'll write a code snippet for you, could you please run this snippet and check the results?

@WestLangley
Copy link
Collaborator

This may be related: #12520.

See the discussion -- particularly the comments regarding non-uniform scale.

@hlfkyo
Copy link
Author

hlfkyo commented Oct 31, 2024

This may be related: #12520.

See the discussion -- particularly the comments regarding non-uniform scale.

Yes, they are the same type of problem, and finding the average is not the most important. I would use the maximum value instead for more accuracy. If more precision is needed, the average can be calculated based on the weight of each axis. The most important thing is to consider the scaling of the parent node.

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.

3 participants