Hello folks,
I’m looking to implement a simple sort interactive painting thing for a single mesh, as in, a user would click and drag, and paint would be applied to the meshes’ texture at the mouse position in a circular shape.
Should be straightforward to do a raycast from the camera to the object with the mesh, and from there get the corresponding uv coordinate on the texture, that’s the easy part I suppose.
Now I could just draw a circle directly on the texture, centered at that uv position, I think that’s how the people who made this example did it:
http://www.cartelle.nl/deathpaint/
However of course the circle would be distorted, because it is not actually being projected onto the mesh before being applied to the texture.
So I’ve looked into a couple threads on this forum about projecting textures on meshes, like this one for example: Texture Projection
However they all seem to be about doing this projection ‘at render time’ by using a shader, which makes sense but doesn’t really match my usecase, I’d like to calculate the projection once when the user clicks to draw, and then apply it directly to the texture every time – I can’t figure out a great way to do this, does someone have any ideas? Would appreciate it
I’ve also looked at https://threejs.org/docs/#examples/en/geometries/DecalGeometry which looks interesting, but I’d have to create a new DecalGeometry on every brushstroke, which Ideally I would like to avoid