Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1K
Visualizações
How can I actually combine or merge geometries in Three.js?

How can I take 2 separate buffer geometries, and simply merge/combine them into one BufferGeometry in three.js which can also carry over all of the skinned attributes, uvs, vertices, etc?

I've been trying to find a solution to this because the default tools in three.js seem not to work, or they scramble certain parts of the geometry.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Throughout the history of three.js, there have been changes in the default geometry class, causing discrepancies and problems in how the tools and utils revolving them are used. At this time, the latest geometry is the BufferGeometry class. When most people see the BufferGeometry.merge() or BufferGeometryUtils.mergeBufferGeometries() functions, usually, all they want to do is simply combine two models into one. This may be a little dramatic, but I can proudly say that I have created a function which will take all of the attributes of a geometry whether it be skin weights, vertex positions, uvs, etc. and apply them in the output merged geometry.

Warning: Keep in mind that if the geometry is not designed for a skinned mesh, you may have to alter the array of attributes to remove unneeded ones.

MergeGeometry(geo1, geo2) {
        var attributes = ["normal", "position", "skinIndex", "skinWeight"];
        var dataLengths = [3, 3, 4, 4];
        var geo = new THREE.BufferGeometry();
        for (var attIndex = 0; attIndex < attributes.length; attIndex++) {
            var currentAttribute = attributes[attIndex];
            var geo1Att = geo1.getAttribute(currentAttribute);
            var geo2Att = geo2.getAttribute(currentAttribute);
            var currentArray = null;
            if (currentAttribute == "skinIndex") currentArray = new Uint16Array(geo1Att.array.length + geo2Att.array.length)
            else currentArray = new Float32Array(geo1Att.array.length + geo2Att.array.length)
            var innerCount = 0;
            geo1Att.array.map((item) => {
                currentArray[innerCount] = item;
                innerCount++;
            });
            geo2Att.array.map((item) => {
                currentArray[innerCount] = item;
                innerCount++;
            });
            geo1Att.array = currentArray;
            geo1Att.count = currentArray.length / dataLengths[attIndex];
            geo.setAttribute(currentAttribute, geo1Att);
        }
        return geo;
    }


about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda