How to sample points on surface based on UV (MeshSurfaceSampler)?

Hey everyone,

So i’ve been using the MeshSurfaceSampler to sample points along my mesh’ surface, however, I want to sample points based on the Y-coordinates of the mesh’ faces. I UV unwrapped my mesh from a 2D view-perspective, so I can control the weightMap on the Y-coordinate perfectly together with a 2D canvas.

Although the setWeightAttribute, method doesnt do what I’d hoped. Instead of sampling the points along the faces of the UV coordinates with smooth interpolation, it samples the points till the nearest vertex when applying the weightMap, obviously the weight is applied to the vertices rather than the faces.

Unfortunately, I can’t afford to subdivide the mesh further.

Sandbox here.
Use the sampler sliders with the uvAlphaMap checked on and off to see what I mean. I want the points to follow the weighted faces, not the vertices.

You can try with three-mesh-bvh, you can cast the ray along any axis you need.

Here’s an excellent :ok_hand: implementation:

2 Likes

You can use your own logics to put point in different formations, writing the rules you want :thinking:

Picture:

Demo: https://codepen.io/prisoner849/full/zxYzQXJ

5 Likes

Thank you so much.

I was trying something like that, but I wasn’t being successful in implementing my logic and I’m not really that good at math. You seem to be really good at Three, hence i see your pen’s all the time.

If you don’t mind, I’d love to have someone else have a look at this. I’m basically trying to stack each ‘particle’ on top of each other, and to make it look realistic I need to;

Add some sort of self collission between each particle as well as the the jar itself.

I want to try and fake it using the MeshSurfaceSampler rather than using raytracing or some other expensive type of calculation, as I’m really in a fight with performance here. (I need the jar to be able to be fully filled with 7 different types of instances or sprites, each being different sizes and amounts)

I’m also doing the yValue calculation wrong, I think? There’s something strange going on at the top. The logic is at ./spice.js - #samplePoints.

1 Like

… massive understatement. :smiley:

… this thread has more goats than a petting zoo.

1 Like

lmao, I put goat first and then changed it be more ‘professional’

Everyone’s so good here, honestly it’s intimidating😭

1 Like