A-Frame / THREE.js,在gltf [glb]模型上简化修饰符 [英] A-Frame / THREE.js, Simplify modifier on gltf[glb] models

查看:358
本文介绍了A-Frame / THREE.js,在gltf [glb]模型上简化修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可在此处找到的三个简化修饰符中的一个示例
https://github.com/mrdoob/three.js/blob/dev/examples/js/modifiers/SimplifyModifier.js

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.

是否可以使用gltf模型来做到这一点?

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

推荐答案

是-请参考 simplifier example 以获得完整代码,但要点是,您可以照常使用SimplifyModifier,不同的是,如果模型包含多个网格,则需要遍历该模型:

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 );

} );

这篇关于A-Frame / THREE.js,在gltf [glb]模型上简化修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆