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

Raycast on a WebGPU Line2 / Line2NodeMaterial breaks #29986

Closed
Samsy opened this issue Nov 28, 2024 · 6 comments · Fixed by #30016
Closed

Raycast on a WebGPU Line2 / Line2NodeMaterial breaks #29986

Samsy opened this issue Nov 28, 2024 · 6 comments · Fixed by #30016
Labels
Milestone

Comments

@Samsy
Copy link
Contributor

Samsy commented Nov 28, 2024

Description

Raycasting a Line2 imported from WebGPU + Line2NodeMaterialbreaks

Because Line2NodeMaterial.resolution does not exists

Live example

Live Fiddle Link

Screenshots

Screenshot 2024-11-28 at 13 43 15

Version

last

Device

Desktop

Browser

Chrome

OS

Windows, MacOS

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 28, 2024

Line2NodeMaterial does not have a resolution uniform so we may need a different approach for LineSegments2.raycast(). Maybe the resolution can be a parameter of the raycasting method?

@Mugen87 Mugen87 added the Addons label Nov 28, 2024
@gkjohnson
Copy link
Collaborator

The resolution is updated in the Mesh's onBeforeRender function but there's no reason that field has to be stored on the material. It could just as easily be stored on the LineSegments2 class itself:

onBeforeRender( renderer ) {

	renderer.getViewport( _viewport );
	this.resolution.set( _viewport.z, _viewport.w );

}

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 29, 2024

To clarify there is a WebGPU version of LineSegments2 because of the different material usage (LineMaterial vs Line2NodeMaterial). The following module needs an update:

https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/webgpu/LineSegments2.js

However, the idea of using onBeforeRender() to extract the resolution sounds good.

@Samsy
Copy link
Contributor Author

Samsy commented Dec 2, 2024

@Mugen87

This one works,

LineSegments2

Created a Vector2 on the LineSegments2 mesh,

vec2

Updated on onBeforeRender :

onBeforeRender

Is this what you meant with the onBeforeRender ?

Shall this vector2 be a property of the mesh ?

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 2, 2024

This looks good to me. Would like filing a PR?

@Samsy
Copy link
Contributor Author

Samsy commented Dec 2, 2024

@Mugen87 here :

PR

@Mugen87 Mugen87 added this to the r172 milestone Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants