Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1K
Views
¿Cómo puedo combinar o fusionar geometrías en Three.js?

¿Cómo puedo tomar 2 geometrías de búfer separadas y simplemente fusionarlas/combinarlas en una BufferGeometry en three.js que también puede transferir todos los atributos de piel, uvs, vértices, etc.?

He estado tratando de encontrar una solución a esto porque las herramientas predeterminadas en three.js parecen no funcionar o codifican ciertas partes de la geometría.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A lo largo de la historia de three.js, ha habido cambios en la clase de geometría predeterminada, lo que ha provocado discrepancias y problemas en la forma en que se utilizan las herramientas y las utilidades que las giran. En este momento, la última geometría es la clase BufferGeometry . Cuando la mayoría de las personas ven las BufferGeometry.merge() o BufferGeometryUtils.mergeBufferGeometries() , por lo general, todo lo que quieren hacer es simplemente combinar dos modelos en uno. Esto puede ser un poco dramático, pero puedo decir con orgullo que he creado una función que tomará todos los atributos de una geometría, ya sean pesos de piel, posiciones de vértice, uvs, etc. y los aplicará en la geometría fusionada de salida.

Advertencia: tenga en cuenta que si la geometría no está diseñada para una malla con piel, es posible que deba modificar la matriz de atributos para eliminar los innecesarios.

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!