未验证 提交 d16f875b 编写于 作者: M Michael Herzog 提交者: GitHub

Merge pull request #17739 from Mugen87/dev11

ParametricGeometry: Added serialization/deserialization support.
......@@ -33,6 +33,16 @@ function ParametricGeometry( func, slices, stacks ) {
ParametricGeometry.prototype = Object.create( Geometry.prototype );
ParametricGeometry.prototype.constructor = ParametricGeometry;
ParametricGeometry.prototype.toJSON = function () {
var data = Geometry.prototype.toJSON.call( this );
data.func = this.parameters.func.toString();
return data;
};
// ParametricBufferGeometry
function ParametricBufferGeometry( func, slices, stacks ) {
......@@ -159,5 +169,14 @@ function ParametricBufferGeometry( func, slices, stacks ) {
ParametricBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
ParametricBufferGeometry.prototype.constructor = ParametricBufferGeometry;
ParametricBufferGeometry.prototype.toJSON = function () {
var data = BufferGeometry.prototype.toJSON.call( this );
data.func = this.parameters.func.toString();
return data;
};
export { ParametricGeometry, ParametricBufferGeometry };
......@@ -408,6 +408,19 @@ ObjectLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
break;
case 'ParametricGeometry':
case 'ParametricBufferGeometry':
var func = new Function( 'return ' + data.func )();
geometry = new Geometries[ data.type ](
func,
data.slices,
data.stacks
);
break;
case 'BufferGeometry':
case 'InstancedBufferGeometry':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册