Loading object as Geometry instead of BufferGeometry in threejs

Flavio

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?

WestLangley

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.69

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ThreeJS geometry flipping

From Dev

Geometry subdivisions in threejs

From Dev

Export ThreeJS Geometry to JSON

From Dev

Object not loading with JSONLoader in ThreeJS: Cannot read property 'visible' of undefined

From Dev

threejs sketching tool with cube geometry

From Dev

ThreeJS font not loading

From Dev

ThreeJS bufferGeometry position attribute not updating when translation applied

From Dev

Does converting a Geometry to a BufferGeometry in Three.js increase the number of vertices?

From Dev

THREE.js OBJLoader - load to Geometry, manipulate, then save to BufferGeometry

From Dev

THREE.js OBJLoader - load to Geometry, manipulate, then save to BufferGeometry

From Dev

Threejs: Geometry vertices not updated when exported to stl

From Dev

Scaling a geometry in one direction with top as reference in threejs

From Dev

How to update the topology of a geometry efficiently in ThreeJS?

From Dev

Threejs: Geometry vertices not updated when exported to stl

From Dev

ThreeJS geometry data from Json not rendering

From Dev

Scaling a geometry in one direction with top as reference in threejs

From Dev

applying texture to custom plane geometry in Threejs

From Dev

threejs how to rotate around object's own center,instead of world center

From Dev

threejs get center of object

From Dev

threejs traverse an object onClick

From Dev

DAE file not loading multi texturing in threejs

From Dev

ThreeJS: loading OBJ files keeping quadrilateral faces

From Dev

ThreeJS: loading OBJ files keeping quadrilateral faces

From Dev

How to center and scale object threejs

From Dev

ThreeJs Create Object / Mesh On Click

From Dev

How to add reflectionMaterial for an object in threejs

From Dev

ThreeJs Create Object / Mesh On Click

From Dev

Move an object in a threejs scene with mouse

From Dev

Convert GeoJSON object to GML geometry

Related Related

  1. 1

    ThreeJS geometry flipping

  2. 2

    Geometry subdivisions in threejs

  3. 3

    Export ThreeJS Geometry to JSON

  4. 4

    Object not loading with JSONLoader in ThreeJS: Cannot read property 'visible' of undefined

  5. 5

    threejs sketching tool with cube geometry

  6. 6

    ThreeJS font not loading

  7. 7

    ThreeJS bufferGeometry position attribute not updating when translation applied

  8. 8

    Does converting a Geometry to a BufferGeometry in Three.js increase the number of vertices?

  9. 9

    THREE.js OBJLoader - load to Geometry, manipulate, then save to BufferGeometry

  10. 10

    THREE.js OBJLoader - load to Geometry, manipulate, then save to BufferGeometry

  11. 11

    Threejs: Geometry vertices not updated when exported to stl

  12. 12

    Scaling a geometry in one direction with top as reference in threejs

  13. 13

    How to update the topology of a geometry efficiently in ThreeJS?

  14. 14

    Threejs: Geometry vertices not updated when exported to stl

  15. 15

    ThreeJS geometry data from Json not rendering

  16. 16

    Scaling a geometry in one direction with top as reference in threejs

  17. 17

    applying texture to custom plane geometry in Threejs

  18. 18

    threejs how to rotate around object's own center,instead of world center

  19. 19

    threejs get center of object

  20. 20

    threejs traverse an object onClick

  21. 21

    DAE file not loading multi texturing in threejs

  22. 22

    ThreeJS: loading OBJ files keeping quadrilateral faces

  23. 23

    ThreeJS: loading OBJ files keeping quadrilateral faces

  24. 24

    How to center and scale object threejs

  25. 25

    ThreeJs Create Object / Mesh On Click

  26. 26

    How to add reflectionMaterial for an object in threejs

  27. 27

    ThreeJs Create Object / Mesh On Click

  28. 28

    Move an object in a threejs scene with mouse

  29. 29

    Convert GeoJSON object to GML geometry

HotTag

Archive