2

THREE.BufferGeometryThreeJSで 2 つのバッファ ジオメトリを 1 つにマージする方法は?

var modelGeometry = null;

geometry = new THREE.CylinderGeometry( 10, 10, 10 );

if (modelGeometry == null)
{
    modelGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
    console.log(modelGeometry);
}

bufGeometry = new THREE.SphereBufferGeometry( 20 , 20, 20 );

var mesh = new THREE.Mesh( bufGeometry, material );

modelGeometry.merge(mesh.geometry, mesh.matrix);

では何もしませんmodelGeometry。これらのジオメトリを正しくマージするにはどうすればよいですか?

4

2 に答える 2

2

私は一晩中踊ります。それをやった!

sumPosArr = new Float32Array(poslen);
sumNormArr = new Float32Array(normlen);
sumUvArr = new Float32Array(uvlen);

var postotalarr = new Array();

sumPosCursor = 0;
sumNormCursor = 0;
sumUvCursor = 0;

for (a = 0; a < objects.length; a++ )
{
    var posAttArr = objects[a].geometry.getAttribute('position').array;

    for (b = 0; b < posAttArr.length; b++)
    {
        sumPosArr[b + sumPosCursor] = posAttArr[b];
    }

    sumPosCursor += posAttArr.length;


    var numAttArr = objects[a].geometry.getAttribute('normal').array;

    for (b = 0; b < numAttArr.length; b++)
    {
        sumNormArr[b + sumNormCursor] = numAttArr[b];
    }

    sumNormCursor += numAttArr.length;


    var uvAttArr = objects[a].geometry.getAttribute('uv').array;

    for (b = 0; b < uvAttArr.length; b++)
    {
        sumUvArr[b + sumUvCursor] = uvAttArr[b];
    }

    sumUvCursor += uvAttArr.length;

}

modelGeometry.addAttribute('position', new THREE.BufferAttribute(sumPosArr, 3 ));
modelGeometry.addAttribute('normal', new THREE.BufferAttribute(sumNormArr, 3 ));
modelGeometry.addAttribute('uv', new THREE.BufferAttribute(sumUvArr, 2 ));
于 2016-04-06T22:03:53.100 に答える