Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js - Questions about (the use of) THREE.BufferGeometry

As I understood using buffer geometries will increase performance and decrease memory usage because it reduces the cost of passing all this data to the GPU.

And as I understood from @WestLangley his post here:

THREE.BufferGeometry is slowly replacing THREE.Geometry as it is computationally more efficient.

I am currently using three.js - r72.
When I draw my geometries make meshes and add them to the scene I see that there are two properties inside my geomtries __directGeometry and _bufferGeometry.

Here in a THREE.BoxGeometry:

enter image description here

Here in a THREE.Geometry:

enter image description here

Here in a THREE.ShapeGeometry:

enter image description here

My questions:

  1. What is a THREE.DirectGeometry and what does it do? (I cannot seem to find any documentation on this)
  2. Is this THREE.BufferGeometry stored in _bufferGeometry already automatically used? If not, can I simply use it instead of my geometry to boost performance?
  3. There are conversion methods: THREE.BufferGeometry has toGeometry and THREE.Geometry has toBufferGeometry. If I convert all my normal geometries to buffer geometries using this method, will it give me the same performance increase compared to drawing them as a THREE.BufferGeometry from the start?
  4. How and when should I use THREE.BufferGeometry?
  5. When will three.js stop supporting THREE.Geometry in favor of THREE.BufferGeometry?

NOTE: I couldn't find detailed information on when and how to use buffer geometries or when it is going to be replacing THREE.Geometry. But if someone has a good source or reference please leave a comment.

like image 344
Wilt Avatar asked Jan 28 '16 10:01

Wilt


People also ask

What is Buffergeometry?

A representation of mesh, line, or point geometry. Includes vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers, reducing the cost of passing all this data to the GPU.


1 Answers

  1. __directGeometry is an internal data structure used to transition between THREE.Geometry and THREE.BufferGeometry. Do not mess with it.
  2. THREE.BufferGeometry.toGeometry() and THREE.Geometry.toBufferGeometry() are convenience methods. The first one is helpful if your model loads as BufferGeometry and you feel more comfortable manipulating Geometry. If you want answers regarding performance, you need to do a test. Buffer geometries definitely load faster.
  3. There are many examples showing the use of BufferGeometry. It would be wise if you understood the difference between "indexed" and "non-indexed" BufferGeometry. BufferGeometry with the index attribute defined allows for the sharing of vertices. Non-Indexed BufferGeometry is what we call "triangle soup".
  4. THREE.Geometry will remain for the foreseeable future.

three.js r.73

like image 158
WestLangley Avatar answered Oct 16 '22 12:10

WestLangley