Skip to content
three.js获取模型所有子对象
2025年3月13日 root
javascript
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;
      }
    });
  }
});

Last updated: