Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transforming Geometry to BufferGeometry

As I understand it, Geometry stores a javascript object structure of the vertices and faces and BufferGeometry just stores the raw gl data via Float32Arrays, etc.

Is there any way to turn standard Geometry into BufferGeometry, which is a lot more memory compact with less objects? For example if I create a new SphereGeometry, is there a way to easily transform that to a BufferGeometry?

like image 383
Axiverse Avatar asked Aug 15 '13 22:08

Axiverse


People also ask

What is BufferGeometry?

This class is an efficient alternative to Geometry, because it stores all data, including vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers; this reduces the cost of passing all this data to the GPU.


1 Answers

You are in luck.

var bufferGeometry = new THREE.BufferGeometry().fromGeometry( geometry ); 

EDIT: updated to three.js r.76

like image 107
WestLangley Avatar answered Oct 03 '22 17:10

WestLangley