javascript 将 Geometry 转换为 BufferGeometry
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18262868/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Transforming Geometry to BufferGeometry
提问by Axiverse
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.
据我了解,Geometry 存储顶点和面的 javascript 对象结构,而 BufferGeometry 仅通过 Float32Arrays 等存储原始 gl 数据。
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?
有什么方法可以将标准几何图形转换为 BufferGeometry,它可以使用更少的对象获得更多的内存紧凑?例如,如果我创建一个新的 SphereGeometry,有没有办法轻松地将其转换为 BufferGeometry?
回答by WestLangley
You are in luck.
你很幸运。
var bufferGeometry = new THREE.BufferGeometry().fromGeometry( geometry );
EDIT: updated to three.js r.76
编辑:更新为three.js r.76