Changing texture and color on Three.js collada object

前端 未结 4 1320
栀梦
栀梦 2021-01-12 00:48

I recently got three.js example from the official site working with my collada objects (.dae) using the ColladaLoader.js. Now my question is, how do i change t

4条回答
  •  抹茶落季
    2021-01-12 01:34

    You can override your collada scene materials recursively with this kind of function. It goes through the whole hierarchy and assigns a material.

    var setMaterial = function(node, material) {
      node.material = material;
      if (node.children) {
        for (var i = 0; i < node.children.length; i++) {
          setMaterial(node.children[i], material);
        }
      }
    }
    

    Use it like setMaterial(dae, new THREE.MeshBasicMaterial({color: 0xff0000}));

    You could probably adapt that to modify the existing material properties instead of assigning a new one, if needed.

提交回复
热议问题