1

One of the examples in three simplify modifier found here https://github.com/mrdoob/three.js/blob/dev/examples/js/modifiers/SimplifyModifier.js

I understand it takes in a geometry, and simplifies it.

is there a way to do this with a gltf model?

8195mike
  • 90
  • 8

1 Answers1

5

Yes — refer to the simplifier example for full code, but the gist is that you can use SimplifyModifier as usual, except that you need to traverse the model in case it contains multiple meshes:

var loader = new THREE.GLTFLoader();
loader.load( 'foo.glb', function ( gltf ) {

  var model = gltf.scene;
  var modifer = new THREE.SimplifyModifier();

  model.traverse( function ( o ) {

    if ( o.isMesh ) {

      var numVertices = o.geometry.attributes.position.count;
      o.geometry = modifer.modify( o.geometry, Math.floor( numVertices * 0.9375 ) );

    }

  } );

  scene.add( model );

}, undefined, function ( e ) {

  console.error( e );

} );
Don McCurdy
  • 10,975
  • 2
  • 37
  • 75
  • That did the trick!, although im now having an issue with the texture's associated with the model, I opened up a new post for organization here https://stackoverflow.com/questions/52102935/a-frame-three-js-no-textures-simplified-gltfglb-models – 8195mike Aug 30 '18 at 18:00