Skip to content

Geometries are not de-serialized in all cases #16340

@Temdog007

Description

@Temdog007
Description of the problem

Currently, there are geometries in THREE JS src that are not de-serializable.

  • EdgesGeometry
  • ParametricGeometry
  • TextGeometry
  • InstancedBufferGeometry
  • WireframeGeometry

There are 2 main reasons for this issue.

  • ObjectLoader doesn't handle these types. Every geometry has a type property which is the name of the geometry. ObjectLoader uses this to determine how to de-serialize the JSON.
  • Geometries are serialized differently if they contain a parameters property.

Based on @Mugen87's comment, it sounds like increasing the complexity of ObjectLoader is undesirable. However, these geometries are currently serialized in a way where they can't be de-serialized.

My suggestion would be one of the following:

  1. Make these geometries serialize as normal BufferGeometry and send a warning saying such.
EdgesBufferGeometry.prototype.toJSON = function () {

	console.warn("EdgesBufferGeometry is not serializable. It will be serialized as BufferGeometry.");
	var parameters = this.parameters;
	this.parameters = undefined;
	var data = BufferGeometry.prototype.toJSON.call( this );
	this.parameters = parameters;

	return data;

};
  1. Make these geometries not serializable and send a error saying such.

Example

EdgesBufferGeometry.prototype.toJSON = function () {

	console.error("EdgesBufferGeometry is not serializable. Convert this geometry to BufferGeometry and call .toJSON() on that");

};
  1. Make ObjectLoader handle these geometries

Related #16026, #16087, #14357

Three.js version
  • Dev
  • r104
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions