Skip to content

Commit 5080c9a

Browse files
authored
Merge pull request #2517 from Spongman/simplify-flat-primitives
webgl: Simplify flat primitives
2 parents e779144 + b5c6bb7 commit 5080c9a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/webgl/primitives.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,13 @@ p5.prototype.box = function(width, height, depth, detailX, detailY) {
130130
depth = height;
131131
}
132132

133+
var perPixelLighting =
134+
this._renderer.attributes && this._renderer.attributes.perPixelLighting;
133135
if (typeof detailX === 'undefined') {
134-
detailX = 4;
136+
detailX = perPixelLighting ? 1 : 4;
135137
}
136138
if (typeof detailY === 'undefined') {
137-
detailY = 4;
139+
detailY = perPixelLighting ? 1 : 4;
138140
}
139141

140142
var gId = 'box|' + detailX + '|' + detailY;
@@ -777,12 +779,13 @@ p5.RendererGL.prototype.ellipse = function(args) {
777779
};
778780

779781
p5.RendererGL.prototype.rect = function(args) {
782+
var perPixelLighting = this.attributes.perPixelLighting;
780783
var x = args[0];
781784
var y = args[1];
782785
var width = args[2];
783786
var height = args[3];
784-
var detailX = args[4] || 24;
785-
var detailY = args[5] || 16;
787+
var detailX = args[4] || (perPixelLighting ? 1 : 24);
788+
var detailY = args[5] || (perPixelLighting ? 1 : 16);
786789
var gId = 'rect|' + detailX + '|' + detailY;
787790
if (!this.geometryInHash(gId)) {
788791
var _rect = function() {

0 commit comments

Comments
 (0)