Loading an object as geometry instead of BufferGeometry in threejs

I am trying to upload a .stl file to three.js file. Everything works fine, and I get the BufferGeometry model with 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 simplify further manipulation of the model, I would like to have the geometry as normal THREE.Geometry instead of THREE.BufferGeometry . Is it possible to either load .stl in such a way as to get it as THREE.Geometry or is it possible to convert from THREE.BufferGeometry to THREE.Geometry ? Or is it possible using a .obj file or something?

+6
source share
1 answer

STLLoader now returns a BufferGeometry object.

You can convert this to THREE.Geometry like this:

 var geometry = new THREE.Geometry().fromBufferGeometry( bufferGeometry ); 

three.js r.69

+16
source

Source: https://habr.com/ru/post/980372/


All Articles