# Millions of facets with three.js?

**URL:** <https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799>\
**Category:** Discussion\
**Tags:** performance, geometry\
**Created:** [September 22, 2019, 10:13am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799 "2019-09-22T10:13:56Z")\
**Posts on this page:** 11\
**Page:** 2

<div class="post-metadata">

**Author:** ![Fyrestar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fyrestar/32/52793_2.png) [@Fyrestar](https://discourse.threejs.org/u/Fyrestar)\
**Post date:** [October 1, 2019, 6:59am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/21 "2019-10-01T06:59:44Z")

</div>

![faces](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/8/8bede93e79378aec0b260f1fa3f398abf9d91147.png)

---

<div class="post-metadata">

**Author:** ![EliasHasle](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/eliashasle/32/3010_2.png) [@EliasHasle](https://discourse.threejs.org/u/EliasHasle)\
**Post date:** [October 1, 2019, 5:08pm UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/22 "2019-10-01T17:08:43Z")

</div>

> **[Facet - 
        Entomologists' glossary - Amateur Entomologists'...](https://www.amentsoc.org/insects/glossary/terms/facet/)**
>
> Definition of 
> Facet: the hexagonal face on the ommatidia within a compound eye.

> **[Compound eye](https://en.wikipedia.org/wiki/Compound_eye)**
>
> A compound eye is a visual organ found in arthropods such as insects and crustaceans. It may consist of thousands of ommatidia, which are tiny independent photoreception units that consist of a cornea, lens, and photoreceptor cells which distinguish brightness and color. The image perceived by this arthropod eye is a combination of inputs from the numerous ommatidia, which are oriented to point in slightly different directions. Compared with single-aperture eyes, compound eyes have poor image Co...

> In the parabolic superposition compound eye type, seen in arthropods such as [mayflies](https://en.wikipedia.org/wiki/Mayfly), the parabolic surfaces of the inside of each facet focus light from a reflector to a sensor array.

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [October 2, 2019, 1:09am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/23 "2019-10-02T01:09:21Z")

</div>

Probably a fairer definition 😛

> In three-dimensional geometry a **facet** of a [polyhedron](https://en.m.wikipedia.org/wiki/Polyhedron) is any [polygon](https://en.m.wikipedia.org/wiki/Polygon) whose corners are vertices of the polyhedron, and is not a [face](https://en.m.wikipedia.org/wiki/Face_(geometry)).[[1]](https://en.m.wikipedia.org/wiki/Facet_(geometry)#cite_note-1)[[2]](https://en.m.wikipedia.org/wiki/Facet_(geometry)#cite_note-2)

> **[Facet (geometry)](https://en.m.wikipedia.org/wiki/Facet_(geometry))**
>
> In geometry, a facet is a feature of a polyhedron, polytope, or related geometric structure, generally of dimension one less than the structure itself. More specifically:
>  
> This polyhedron-related article is a stub. You can help Wikipedia by expanding it.

@Nicoco I think the term you should be taking here is ‘face’.

---

<div class="post-metadata">

**Author:** ![pailhead](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pailhead/32/85_2.png) [@pailhead](https://discourse.threejs.org/u/pailhead)\
**Post date:** [October 2, 2019, 1:12am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/24 "2019-10-02T01:12:50Z")

</div>

Agreed, a facet can mean an arbitrary number of triangles, i think the more common term is Ngon.

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [October 2, 2019, 1:28am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/25 "2019-10-02T01:28:32Z")

</div>

This definition from [mathworld](http://mathworld.wolfram.com/Facet.html) doesn’t have the stipulation that a facet is not a face though, I wonder if the wiki definition is non-standard?

> An (n-1)-dimensional face of an n-dimensional polytope.

According to this, in 3 dimensions the terms facets and faces are synonymous.

In any case, ‘face’ is certainly the standard term across all CG and geometry literature that I’ve read.

---

<div class="post-metadata">

**Author:** ![Fyrestar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fyrestar/32/52793_2.png) [@Fyrestar](https://discourse.threejs.org/u/Fyrestar)\
**Post date:** [October 2, 2019, 4:56am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/26 "2019-10-02T04:56:43Z")

</div>

Usually don’t hear the term facet in a professional context, rather in old fashioned explanations teachers still love to use.

---

<div class="post-metadata">

**Author:** ![EliasHasle](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/eliashasle/32/3010_2.png) [@EliasHasle](https://discourse.threejs.org/u/EliasHasle)\
**Post date:** [October 2, 2019, 7:16am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/27 "2019-10-02T07:16:52Z")

</div>

> [@looeee](#):
>
> This definition from [mathworld](http://mathworld.wolfram.com/Facet.html) doesn’t have the stipulation that a facet is not a face though, I wonder if the wiki definition is non-standard?

Ah, and the references are unavailable online…

Here is the [mathworld definition for Face](http://mathworld.wolfram.com/Face.html). “A zero-dimensional face is a vertex” etc… I think in general it is best to lean on mathematicians for definitions, as they tend to have a good eye for generalization, which both orders the existing knowledge and expands the horizons.

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [October 2, 2019, 9:01am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/28 "2019-10-02T09:01:02Z")

</div>

> [@EliasHasle](#):
>
> I think in general it is best to lean on mathematicians for definitions

Completely agree - however it’s important to stick with the conventions of our field as well, and remember that mathematical terms tend to be tweaked to suit each sub-field. So, for a mathematician discussing an n-dimensional polytope, a vertex is a face, an edge is a face, a polygon is a face. But as computer graphics engineers, we’d never refer to edges or vertices (or facets) as faces. Doing so might be technically correct, but it will still lead to confusion.

---

<div class="post-metadata">

**Author:** ![pailhead](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pailhead/32/85_2.png) [@pailhead](https://discourse.threejs.org/u/pailhead)\
**Post date:** [October 2, 2019, 10:58am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/29 "2019-10-02T10:58:13Z")

</div>

GPUs deal with triangles though, neither faces nor facets are applicable? No matter what you do, a triangle has to be rasterized.

---

<div class="post-metadata">

**Author:** ![Shane\_Brumback](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/shane_brumback/32/65134_2.png) [@Shane\_Brumback](https://discourse.threejs.org/u/Shane_Brumback)\
**Post date:** [May 22, 2022, 4:19am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/30 "2022-05-22T04:19:18Z")

</div>

Thanks for this post guys. I have been looking for a good example for handling tens of thousands of triangles. I modified the code a bit to incorporate 1-5 million and post processing with an audio analyzer for a demo.

> **[ThreeJS Post Processing 1 Million Polygons with Audio Analyser](https://www.shanebrumback.com/post-processing-1-million-polygons-threejs.html)**
>
> ThreeJS Post Processing 1 Million Polygons with Audio Analyser

 ![post-processing-1-million-polygons-threejs-shane-brumback](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/5/9/5914813d572482a395408378bac240aa34c61c56.jpeg)

---

<div class="post-metadata">

**Author:** ![trusktr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/trusktr/32/13726_2.png) [@trusktr](https://discourse.threejs.org/u/trusktr)\
**Post date:** [May 28, 2022, 2:44am UTC](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799/31 "2022-05-28T02:44:01Z")

</div>

@Nicoco Late reply, but what you describe sounds really great.

In a nutshell, it may be called “sub-object vertex culling” (Three.js culls only at the object level, not vertex level), with face sharing across objects (similar to instancing, if I understood correctly), adding the algorithms you used to make it fast (f.e. a dynamically sized “array” that grows only on the JavaScript side instead of passing to the native side for array growth, as if to implement your own C++ vector of sorts in JS).

What some folks above didn’t understand is that if you have 5 million triangles, they don’t all go to the GPU to be clipped by the vertex shader, they are clipped (culled) on the JS side, so if only 100k triangles are in the camera view, then only 100k triangles go to the shader (not 5 million) based on the double-index range you determine.

It would be _amazing_ if you could find the time to re-write this and publish it.

[Previous page](https://discourse.threejs.org/t/millions-of-facets-with-three-js/9799.md?page=1)
