Three.js - Using multiple textures in a single PointCloud

后端 未结 3 1108
庸人自扰
庸人自扰 2021-01-03 03:28

I\'m trying to use multiple textures in a single PointCloud using a ShaderMaterial. I\'m passing a texture array to the shader along with texture index attributes and select

3条回答
  •  醉梦人生
    2021-01-03 03:35

    The new version of Three.js doesn't support attributes in ShaderMaterial. We'll have to delete attributes: attributes in new THREE.ShaderMaterial and use geometry.addAttribute instead. Here's the code to define texIndex:

    var vIndex = new Float32Array( vertices.length );
    for ( var i = 0, l = vertices.length; i < l; i ++ ) {
            vIndex[i] = Math.random()*getTextures().length;
    }
    geometry.addAttribute( 'texIndex', new THREE.BufferAttribute( vIndex, 1 ) );
    

提交回复
热议问题