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

218
Visualizações
Serializing and deserializing geometry in three.js using toJSON and BufferGeometryLoader. Transferring geometries as string

First of all - I'm a beginner in three.js and I just want to share my experience.
My task was to convert geometry into something and transfer it to another WebWorker(you cannot transfer all objects between workers, only structured cloneable datatypes. So I opened documentation and tried to use .toJSON and then BufferGeometryLoader(and many other approaches).

const box = new BoxBufferGeometry();
const geomJSON = box.toJSON();
const geometriesLoader = new THREE.BufferGeometryLoader();
const parsedGeom = geometriesLoader.parse(geomJSON);
const mesh = new Mesh(parsedGeom);
this.scene.add(mesh);

and I received this error:
enter image description here

Also, I tried other types of loaders, JSON.stringify, etc. But only packing meshes with geometries in the GLTF file and serializing it using callback seems to work(not very handy).

I asked holy Internet for help but he didn't hear me. And documentation says only:

.toJSON () : Object Convert the buffer geometry to three.js JSON Object/Scene format.

Three.js version: 0.135.0 and 0.136.0

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

0

So, I thought I will die, but then I accidentally found that function: .toNonIndexed().

const box = new BoxBufferGeometry();
const geomJSON = box.toNonIndexed().toJSON();
const geometriesLoader = new THREE.BufferGeometryLoader();
const parsedGeom = geometriesLoader.parse(geomJSON);
const mesh = new Mesh(parsedGeom);
this.scene.add(mesh);

I am not sure what it does, but at least it works now, and I can see my geometry after serialization. I am not sure that it doesn't cause other problems though.

If you are more experienced in three.js, then please, give me and other noobs more information about this issue and the purpose of .toJSON. Thanks.

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