Skip to content

Commit 1d71dfe

Browse files
committed
Expose makeEdgesFromFaces now that this doesn't happen automatically
1 parent 2890d64 commit 1d71dfe

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/webgl/p5.Geometry.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,51 @@ class Geometry {
13451345
return this;
13461346
}
13471347

1348+
/**
1349+
* @example
1350+
* <div>
1351+
* <code>
1352+
* let tetrahedron;
1353+
* function setup() {
1354+
* createCanvas(200, 200, WEBGL);
1355+
* describe('A rotating tetrahedron');
1356+
*
1357+
* tetrahedron = new p5.Geometry();
1358+
*
1359+
* // Give each geometry a unique gid
1360+
* tetrahedron.gid = 'tetrahedron';
1361+
*
1362+
* // Add four points of the tetrahedron
1363+
*
1364+
* let radius = 50;
1365+
* // A 2D triangle:
1366+
* tetrahedron.vertices.push(createVector(radius, 0, 0));
1367+
* tetrahedron.vertices.push(createVector(radius, 0, 0).rotate(TWO_PI / 3));
1368+
* tetrahedron.vertices.push(createVector(radius, 0, 0).rotate(TWO_PI * 2 / 3));
1369+
* // Add a tip in the z axis:
1370+
* tetrahedron.vertices.push(createVector(0, 0, radius));
1371+
*
1372+
* // Create the four faces by connecting the sets of three points
1373+
* tetrahedron.faces.push([0, 1, 2]);
1374+
* tetrahedron.faces.push([0, 1, 3]);
1375+
* tetrahedron.faces.push([0, 2, 3]);
1376+
* tetrahedron.faces.push([1, 2, 3]);
1377+
* tetrahedron.makeEdgesFromFaces();
1378+
* }
1379+
* function draw() {
1380+
* background(200);
1381+
* strokeWeight(2);
1382+
* orbitControl();
1383+
* rotateY(millis() * 0.001);
1384+
* model(tetrahedron);
1385+
* }
1386+
* </code>
1387+
* </div>
1388+
*/
1389+
makeEdgesFromFaces() {
1390+
this._makeTriangleEdges();
1391+
}
1392+
13481393
/**
13491394
* Converts each line segment into the vertices and vertex attributes needed
13501395
* to turn the line into a polygon on screen. This will include:

0 commit comments

Comments
 (0)