Closed darkf closed 5 years ago
Can you please explain your use case?
Yes, my scene has a lightmap (and other textures in lightmap/UV2 space) which I want to sample and draw on as a result of the raycast, a la Tag, Portal 2, Splatoon, etc. For this I need the UV2 coordinates of where it hit -- and since Three already provides UV coordinates, I figure it should provide them on all layers anyway.
It would be fine (preferable even) if it were upon request instead, e.g. having a getTextureCoords method of some sort, that way unnecessary calculations are not being done every cast.
What is your current workaround?
Um, I guess the change in Mesh.raycast()
should be manageable to support this.
I think the OP should respond to my question so we can decide if the workaround is adequate for this edge case.
I don't have a workaround right now, hence the request. I typically use Three for my 3D needs, and I looked to see if it had it, which it did not. It seems like a reasonable feature to have (if you're going to return UVs it may as well be on all layers...).
if you're going to return UVs it may as well be on all layers It would be fine (preferable even) if it were upon request instead, e.g. having a getTextureCoords method of some sort
That does seem reasonable.
On the other hand, there has been no demand for this feature previously.
Another use case for this is looking up the texel in a lightmap raycasted below a character, as a quick and dirty query for "is this character in shadow and what color is the lighting here".. the resulting color of which you can then use to tint/shade the character. You can even use multiple casts to take samples from a few different directions. I've used this in PC and console games in the past and it can be a cheap and easy way to fake env based lighting for some setups. Alternatively, we could allow the retrieval of the second set of UVs to be a method on the collision result or something. Would be nice to to expose the barycentric UV calculation via some utility anyway.
Created a PR since I recently needed this feature^^
Description of the problem
The raycaster provides UV coordinates of the hit point, but not UV2 (second layer, i.e.
faceVertexUvs[1]
) coordinates.Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)