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

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

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 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