Allow Tube Geometry to be serialized and loaded
@@ -219,5 +219,14 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
TubeBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
TubeBufferGeometry.prototype.constructor = TubeBufferGeometry;
+TubeBufferGeometry.prototype.toJSON = function () {
+
+ var data = BufferGeometry.prototype.toJSON.call( this );
+ data.path = this.parameters.path.toJSON();
+ return data;
+};
export { TubeGeometry, TubeBufferGeometry };
@@ -341,6 +341,21 @@ Object.assign( ObjectLoader.prototype, {
break;
+ case 'TubeGeometry':
+ case 'TubeBufferGeometry':
+ // This only works for built-in curves (e.g. CatmullRomCurve3).
+ // User defined curves or instances of CurvePath will not be deserialized.
+ geometry = new Geometries[ data.type ](
+ new Curves[ data.path.type ]().fromJSON( data.path ),
+ data.tubularSegments,
+ data.radius,
+ data.radialSegments,
+ data.closed
+ );
+ break;
case 'LatheGeometry':
case 'LatheBufferGeometry':