提交 7d724b9d 编写于 作者: A Augustin Trancart

Fix Object3D, Material and Texture toJSON method

This makes their toJSON method compatible with JSON.stringify.

Fixes #8581.
上级 12f4ac35
......@@ -591,8 +591,8 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
toJSON: function ( meta ) {
// meta is '' when called from JSON.stringify
var isRootObject = ( meta === undefined || meta === '' );
// meta is a string when called from JSON.stringify
var isRootObject = ( meta === undefined || typeof meta === 'string' );
var output = {};
......
......@@ -131,7 +131,7 @@ Object.assign( Material.prototype, EventDispatcher.prototype, {
toJSON: function ( meta ) {
var isRoot = meta === undefined;
var isRoot = ( meta === undefined || typeof meta === 'string' );
if ( isRoot ) {
......
......@@ -126,7 +126,9 @@ Object.assign( Texture.prototype, EventDispatcher.prototype, {
toJSON: function ( meta ) {
if ( meta.textures[ this.uuid ] !== undefined ) {
var isRootObject = ( meta === undefined || typeof meta === 'string' );
if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {
return meta.textures[ this.uuid ];
......@@ -210,7 +212,7 @@ Object.assign( Texture.prototype, EventDispatcher.prototype, {
}
if ( meta.images[ image.uuid ] === undefined ) {
if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {
meta.images[ image.uuid ] = {
uuid: image.uuid,
......@@ -223,7 +225,11 @@ Object.assign( Texture.prototype, EventDispatcher.prototype, {
}
meta.textures[ this.uuid ] = output;
if ( ! isRootObject ) {
meta.textures[ this.uuid ] = output;
}
return output;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册