Solshine commited on
Commit
60dcb69
·
verified ·
1 Parent(s): fd6fc76

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. ShapeTessellationShader.js +8 -8
ShapeTessellationShader.js CHANGED
@@ -79,24 +79,24 @@ bool insidePolygon(vec2 p, int count) {
79
 
80
  // --- Map point inside polygon to unit disk ---
81
  vec2 mapToDisk(vec2 p, int count) {
82
- // Compute centroid
83
- vec2 centroid = vec2(0.0);
84
  for (int i = 0; i < 4; i++) {
85
  if (i >= count) break;
86
- centroid += u_vertices[i];
87
  }
88
- centroid /= float(count);
89
 
90
- // Find max distance from centroid to any vertex
91
  float maxDist = 0.0;
92
  for (int i = 0; i < 4; i++) {
93
  if (i >= count) break;
94
- float d = length(u_vertices[i] - centroid);
95
  if (d > maxDist) maxDist = d;
96
  }
97
 
98
- // Normalize: centroid -> origin, scale so vertices sit near disk edge
99
- vec2 offset = (p - centroid) / max(maxDist, 0.001);
100
 
101
  // Clamp to disk
102
  float r = length(offset);
 
79
 
80
  // --- Map point inside polygon to unit disk ---
81
  vec2 mapToDisk(vec2 p, int count) {
82
+ // Compute ctr
83
+ vec2 ctr = vec2(0.0);
84
  for (int i = 0; i < 4; i++) {
85
  if (i >= count) break;
86
+ ctr += u_vertices[i];
87
  }
88
+ ctr /= float(count);
89
 
90
+ // Find max distance from ctr to any vertex
91
  float maxDist = 0.0;
92
  for (int i = 0; i < 4; i++) {
93
  if (i >= count) break;
94
+ float d = length(u_vertices[i] - ctr);
95
  if (d > maxDist) maxDist = d;
96
  }
97
 
98
+ // Normalize: ctr -> origin, scale so vertices sit near disk edge
99
+ vec2 offset = (p - ctr) / max(maxDist, 0.001);
100
 
101
  // Clamp to disk
102
  float r = length(offset);