brianxu / GPUPicker

a GPU based picking class for ThreeJS lib
MIT License
79 stars 14 forks source link

Use this library with meshes #2

Closed Richacinas closed 6 years ago

Richacinas commented 6 years ago

Hi there,

I have around 20 meshes with img maps as a texture. All of them are a plane.

Could I use this library to detect intersections of the mouse as it moves, with all these meshes?

I made it work, but there is no way for me to find the Object that is "under" the mouse when an intersection happens.

I opened a question on Stackoverflow, and I come here asking for kind help because I have been stuck for days.

Thanks a lot,

https://stackoverflow.com/questions/48691642/three-js-raycaster-find-intersections-as-mouse-moves/48693593?noredirect=1#comment84413010_48693593

brianxu commented 6 years ago

hi @Richacinas can you show me what the intersect = gpuPicker.pick(mouse, raycaster); returns? also I haven't updated the library with latest THREEjs so it may not work if you are using the latest version.

P.S: you should find the intersect.object to be the object.

Richacinas commented 6 years ago

Hi again,

Yes, I was receiving data on the property object, however, it wasn't correct many times as it was giving me a different object... It looks like the positions are not right so maybe the problem was about that.

All my elements are inside a sphere where I'm rendering a texture.. it is like a 360 tour inside a famous building.

I don't think I can put a demo online because it would take me a long time.. If I can do it, I'll post the url here...

Richacinas commented 6 years ago

I created a demo:

https://jsfiddle.net/ggL3uemh/13/

On this demo, I'm not using your library. This is the way we are doing it right now, so hopefully you can take a look and find out how we could integrate with your library.

There is some code that is aimed to render a video texture on a sphere geometry (tex2, renderVideo, addVideoTexture...) so don't pay attention to that because I am unable to render the video texture from another host (cross origin).

Any help would be greatly appreciated,

Thanks a lot,

Ricardo

brianxu commented 6 years ago

have you tried to turn on the debug view like the example? it will show you the encoded rendering

brianxu commented 6 years ago

I have updated the library for THREEjs r92, hopefully it works for you now.

Richacinas commented 6 years ago

Thanks a lot. Eventually I will try. I couldn't solve this issue but I'm sure something was missing. Ended up using raycast + octrees and it improved performance and worked