Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1K
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda