# Sketch runs slow in P5.js WEBGL, (SOLVED by using P5.Geometry)

**URL:** <https://discourse.processing.org/t/sketch-runs-slow-in-p5-js-webgl-solved-by-using-p5-geometry/31990>\
**Category:** Coding Questions\
**Created:** [August 29, 2021, 2:33am UTC](https://discourse.processing.org/t/sketch-runs-slow-in-p5-js-webgl-solved-by-using-p5-geometry/31990 "2021-08-29T02:33:50Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [September 18, 2021, 8:42pm UTC](https://discourse.processing.org/t/sketch-runs-slow-in-p5-js-webgl-solved-by-using-p5-geometry/31990/21 "2021-09-18T20:42:41Z")

</div>

I thought this might interest you: Here’s an example I made for the article I’m writing. [This example](https://editor.p5js.org/Kumu-Paul/sketches/AnHr8yL2a) is designed to support variable `detailX`/`detailY` and leverage the built in capabilities of `computeFaces()` and `computeNormals()`:

https://preview.p5js.org/Kumu-Paul/embed/AnHr8yL2a

---

<div class="post-metadata">

**Author:** ![J\_Silva](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@J\_Silva](https://discourse.processing.org/u/J_Silva)\
**Post date:** [September 24, 2021, 8:40am UTC](https://discourse.processing.org/t/sketch-runs-slow-in-p5-js-webgl-solved-by-using-p5-geometry/31990/22 "2021-09-24T08:40:32Z")

</div>

Thanks, Paul. I knew I had to assign to each gid, but I tried

> this.gid = ‘nut’+str(id++);

instead of

> this.blendMesh.gid = ‘nut’+str(id++);

so that didn’t work. I have been ill for quite some days, but since yesterday I feel better and I decided to design “the enemy”, to look straight in its face. I used .obj files made by drawing vertexes in P5.java exporting them with a really good Processing library called OBJExport. Its not included in Processing’s “Contribution Manager”, but you can download it [here](https://n-e-r-v-o-u-s.com/tools/obj/). I used .obj because I thought that constructing the faces individually as I did with the ‘nut’ sketch would give tremendous work. But now I’ve read your last post, I see there is a method for it in the [p5.Geometry Class](https://github.com/processing/p5.js/blob/main/src/webgl/p5.Geometry.js) to compute them. I should have taken your advice to study this Class sooner. But this will be my next step. Writing the objects of this sketch in p5.Geometry.

https://preview.p5js.org/J_Silva/embed/3Oln0Ofgg

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 23, 2023, 11:56pm UTC](https://discourse.processing.org/t/sketch-runs-slow-in-p5-js-webgl-solved-by-using-p5-geometry/31990/23 "2023-02-23T23:56:02Z")

</div>

Thanks @KumuPaul !

> [@KumuPaul](#):
>
> Here’s an example I made for the article I’m writing

> **[Articles](https://www.paulwheeler.us/articles/custom-3d-geometry-in-p5js/)**
>
> A guide to creating custom, procedurally generated three-dimensional geometry in a way that renders performantly using the p5.Geometry class.

`:)`

[Previous page](https://discourse.processing.org/t/sketch-runs-slow-in-p5-js-webgl-solved-by-using-p5-geometry/31990.md?page=1)
