Drawing on a mesh using dynamic texture

Here is a fix :

  • You detect that there is a jump (distance from two points which use to be a few pixels, is suddently about 512 …
  • You sort the points along X
  • You create the middle points a the limits : A2 and B2
  • You paint the 2 new strokes, in Green :
var pts = [lastPoint, currentPoint];
pts.sort((a,b) => {
    return b.x-a.x;
})
var ptA1 = pts[0];
var ptA2 = {x:512, y:0.5*(pts[0].y+pts[1].y)}
var ptB2 = {x:0, y:0.5*(pts[0].y+pts[1].y)}
var ptB1 = pts[1];
paint(ptA1, ptA2);
paint(ptB2, ptB1);

Here you go : Playground

++
Tricotou

4 Likes