Skip to content

Commit 8336ad2

Browse files
authored
Merge pull request #5795 from davepagurek/feat/rounded-rect-uvs
Add texture coordinates to WebGL rounded rects
2 parents 4232546 + d9d781c commit 8336ad2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/webgl/3d_primitives.js

+8
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,14 @@ p5.RendererGL.prototype.rect = function(args) {
13361336
} else {
13371337
this.vertex(x1, y1);
13381338
}
1339+
1340+
this.immediateMode.geometry.uvs.length = 0;
1341+
for (const vert of this.immediateMode.geometry.vertices) {
1342+
const u = (vert.x - x1) / width;
1343+
const v = (vert.y - y1) / height;
1344+
this.immediateMode.geometry.uvs.push(u, v);
1345+
}
1346+
13391347
this.endShape(constants.CLOSE);
13401348
}
13411349
return this;

0 commit comments

Comments
 (0)