admin管理员组文章数量:1202791
I'm trying to load an .stl
file into three.js. Everything works fine and I get the model as BufferGeometry using this code:
var loader = new THREE.STLLoader();
loader.addEventListener( 'load', function ( event )
{
var material = new THREE.MeshLambertMaterial({
color: 0x888888,
side: THREE.DoubleSide
});
var bufferGeometry = event.content;
var mesh = new THREE.Mesh(geometry, material);
scene.add( mesh );
});
loader.load( 'model.stl' );
To make it easier to further manipulate the model I would like to have the geometry as regular THREE.Geometry
instead of THREE.BufferGeometry
. Is it possible to either load the .stl
in a way so I receive it as a THREE.Geometry
or is it possible to convert from THREE.BufferGeometry
to THREE.Geometry
? Or is this possible using a .obj
file or sth else?
I'm trying to load an .stl
file into three.js. Everything works fine and I get the model as BufferGeometry using this code:
var loader = new THREE.STLLoader();
loader.addEventListener( 'load', function ( event )
{
var material = new THREE.MeshLambertMaterial({
color: 0x888888,
side: THREE.DoubleSide
});
var bufferGeometry = event.content;
var mesh = new THREE.Mesh(geometry, material);
scene.add( mesh );
});
loader.load( 'model.stl' );
To make it easier to further manipulate the model I would like to have the geometry as regular THREE.Geometry
instead of THREE.BufferGeometry
. Is it possible to either load the .stl
in a way so I receive it as a THREE.Geometry
or is it possible to convert from THREE.BufferGeometry
to THREE.Geometry
? Or is this possible using a .obj
file or sth else?
1 Answer
Reset to default 25This answer only applies to versions of three.js prior to r.125.
STLLoader
now returns a BufferGeometry
object.
You can convert that to a THREE.Geometry
like so:
var geometry = new THREE.Geometry().fromBufferGeometry( bufferGeometry );
three.js r.124
本文标签: javascriptLoading object as Geometry instead of BufferGeometry in threejsStack Overflow
版权声明:本文标题:javascript - Loading object as Geometry instead of BufferGeometry in threejs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738602773a2102168.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论