user9651431
user9651431

Reputation:

Difference between buffer geometry and geometry

I'm new to three JS where I have researched through all the topics such as camera, renderer, scene and geometry. Where coming through the geometry there are geometry and buffer geometry(say conebufferGeometry and coneGeometry).Where the features are same in both. So whats the difference between geometry and buffer geometry. Is that influence anything in performance or something

Upvotes: 21

Views: 7724

Answers (3)

corashina
corashina

Reputation: 1887

Geometry is converted to buffergeometry in the end so if you dont have any performance issues, stick to geometry if its convenient for you.

Here you can see that ConeGeometry calls CylinderGeometry constructor.

CylinderGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );

https://github.com/mrdoob/three.js/blob/dev/src/geometries/ConeGeometry.js

Then CylinderGeometry is created using CylinderBufferGeometry.

this.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );

https://github.com/mrdoob/three.js/blob/dev/src/geometries/CylinderGeometry.js

Upvotes: 3

chantey
chantey

Reputation: 5827

From 2021

This is now a moot point, geometry was removed from threejs in r125.

Geometry is now just an alias for BufferGeometry, source here.

export { BoxGeometry, BoxGeometry as BoxBufferGeometry };

Upvotes: 3

Alex Khoroshylov
Alex Khoroshylov

Reputation: 2334

The difference is essentially in underlying data structures (how geometry stores and handles vertices, faces etc in memory).

For learning purposes you should not care about it, just use ConeGeometry until you come across performance issues. Then come to the topic again, next time you will be more prepared to get the difference between two.

Please check BufferGeometry

An efficient 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.

To read and edit data in BufferGeometry attributes, see BufferAttribute documentation.

For a less efficient but easier-to-use representation of geometry, see Geometry.

On another side Geometry:

Geometry is a user-friendly alternative to BufferGeometry. Geometries store attributes (vertex positions, faces, colors, etc.) using objects like Vector3 or Color that are easier to read and edit, but less efficient than typed arrays.

Prefer BufferGeometry for large or serious projects.

BufferGeometry performance explained here: why-is-the-geometry-faster-than-buffergeometry

Upvotes: 14

Related Questions