MCPcopy Index your code
hub / github.com/processing/p5.js / computeFaces

Method computeFaces

src/webgl/p5.Geometry.js:825–840  ·  view source on GitHub ↗

* Computes the geometry's faces using its vertices. * * All 3D shapes are made by connecting sets of points called *vertices*. A * geometry's surface is formed by connecting vertices to form triangles that * are stitched together. Each triangular patch on the geometry's surface is * c

()

Source from the content-addressed store, hash-verified

823 * }
824 */
825 computeFaces() {
826 this.faces.length = 0;
827 const sliceCount = this.detailX + 1;
828 let a, b, c, d;
829 for (let i = 0; i < this.detailY; i++) {
830 for (let j = 0; j < this.detailX; j++) {
831 a = i * sliceCount + j; // + offset;
832 b = i * sliceCount + j + 1; // + offset;
833 c = (i + 1) * sliceCount + j + 1; // + offset;
834 d = (i + 1) * sliceCount + j; // + offset;
835 this.faces.push([a, b, d]);
836 this.faces.push([d, b, c]);
837 }
838 }
839 return this;
840 }
841
842 _getFaceNormal(faceId) {
843 //This assumes that vA->vB->vC is a counter-clockwise ordering

Callers 2

primitives3DFunction · 0.95
textFunction · 0.80

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected