Halo
发布于 2023-09-28 / 167 阅读 / 0 评论 / 0 点赞

three.js获取模型所有子对象

new OBJLoader().load('dt.obj', function (object) {
  function getChildrenObj(object, resultMap) {
    object.traverse((v) => {
      if (v.isMesh && v.material) {
        v.castShadow = true;
        v.frustumCulled = false;
        const { name, color, map } = v.material;
        v.material = new THREE.MeshStandardMaterial({
          map,
          transparent: true,
          color,
          name
        });
        resultMap[v.name] = v;
      }
    });
  }
});

评论