Skip to content

Commit de2550c

Browse files
committed
Add WebGL specific 3D cases
1 parent dc52d1b commit de2550c

File tree

17 files changed

+144
-0
lines changed

17 files changed

+144
-0
lines changed

test/unit/visual/cases/shapes.js

+120
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,126 @@ visualSuite('Shape drawing', function() {
167167
p5.endShape();
168168
screenshot();
169169
});
170+
171+
if (mode === 'WebGL') {
172+
visualTest('3D vertex coordinates', function(p5, screenshot) {
173+
setup(p5);
174+
175+
p5.beginShape(p5.QUAD_STRIP);
176+
p5.vertex(10, 10, 0);
177+
p5.vertex(10, 40, -150);
178+
p5.vertex(40, 10, 150);
179+
p5.vertex(40, 40, 200);
180+
p5.endShape();
181+
182+
screenshot();
183+
});
184+
185+
visualTest('3D quadratic coordinates', function(p5, screenshot) {
186+
setup(p5);
187+
188+
p5.beginShape();
189+
p5.vertex(10, 10, 0);
190+
p5.vertex(10, 40, -150);
191+
p5.quadraticVertex(40, 40, 200, 40, 10, 150);
192+
p5.endShape(p5.CLOSE);
193+
194+
screenshot();
195+
});
196+
197+
visualTest('3D cubic coordinates', function(p5, screenshot) {
198+
setup(p5);
199+
200+
p5.beginShape();
201+
p5.vertex(10, 10, 0);
202+
p5.vertex(10, 40, -150);
203+
p5.bezierVertex(40, 40, 200, 40, 10, 150, 10, 10, 0);
204+
p5.endShape();
205+
206+
screenshot();
207+
});
208+
209+
visualTest('Texture coordinates', async function(p5, screenshot) {
210+
setup(p5);
211+
const tex = await p5.loadImage('/unit/assets/cat.jpg');
212+
213+
p5.texture(tex);
214+
p5.beginShape(p5.QUAD_STRIP);
215+
p5.vertex(10, 10, 0, 0, 0);
216+
p5.vertex(45, 5, 0, tex.width, 0);
217+
p5.vertex(15, 35, 0, 0, tex.height);
218+
p5.vertex(40, 45, 0, tex.width, tex.height);
219+
p5.endShape();
220+
221+
screenshot();
222+
});
223+
224+
visualTest('Normalized texture coordinates', async function(p5, screenshot) {
225+
setup(p5);
226+
const tex = await p5.loadImage('/unit/assets/cat.jpg');
227+
228+
p5.texture(tex);
229+
p5.textureMode(p5.NORMAL);
230+
p5.beginShape(p5.QUAD_STRIP);
231+
p5.vertex(10, 10, 0, 0, 0);
232+
p5.vertex(45, 5, 0, 1, 0);
233+
p5.vertex(15, 35, 0, 0, 1);
234+
p5.vertex(40, 45, 0, 1, 1);
235+
p5.endShape();
236+
237+
screenshot();
238+
});
239+
240+
visualTest('Per-vertex fills', async function(p5, screenshot) {
241+
setup(p5);
242+
p5.beginShape(p5.QUAD_STRIP);
243+
p5.fill(0);
244+
p5.vertex(10, 10);
245+
p5.fill(255, 0, 0);
246+
p5.vertex(45, 5);
247+
p5.fill(0, 255, 0);
248+
p5.vertex(15, 35);
249+
p5.fill(255, 255, 0);
250+
p5.vertex(40, 45);
251+
p5.endShape();
252+
253+
screenshot();
254+
});
255+
256+
visualTest('Per-vertex strokes', async function(p5, screenshot) {
257+
setup(p5);
258+
p5.strokeWeight(5);
259+
p5.beginShape(p5.QUAD_STRIP);
260+
p5.stroke(0);
261+
p5.vertex(10, 10);
262+
p5.stroke(255, 0, 0);
263+
p5.vertex(45, 5);
264+
p5.stroke(0, 255, 0);
265+
p5.vertex(15, 35);
266+
p5.stroke(255, 255, 0);
267+
p5.vertex(40, 45);
268+
p5.endShape();
269+
270+
screenshot();
271+
});
272+
273+
visualTest('Per-vertex normals', async function(p5, screenshot) {
274+
setup(p5);
275+
p5.normalMaterial();
276+
p5.beginShape(p5.QUAD_STRIP);
277+
p5.normal(-1, -1, 1);
278+
p5.vertex(10, 10);
279+
p5.normal(1, -1, 1);
280+
p5.vertex(45, 5);
281+
p5.normal(-1, 1, 1);
282+
p5.vertex(15, 35);
283+
p5.normal(1, 1, 1);
284+
p5.vertex(40, 45);
285+
p5.endShape();
286+
287+
screenshot();
288+
});
289+
}
170290
});
171291
}
172292
});
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}

0 commit comments

Comments
 (0)