toJSON method
dynamic
toJSON(
- dynamic meta
Implementation
toJSON( meta ) {
var isRootObject = ( meta == null || meta is String );
if (!isRootObject && meta.images[uuid] != null) {
return meta.images[uuid];
}
var output = {
"uuid": uuid,
"url": ''
};
var data = this.data;
if ( data != null ) {
var url;
if ( data is List ) {
// cube texture
url = [];
for ( var i = 0, l = data.length; i < l; i ++ ) {
if ( data[ i ].isDataTexture ) {
url.add( serializeImage( data[ i ].image ) );
} else {
url.add( serializeImage( data[ i ] ) );
}
}
} else {
// texture
url = serializeImage( data );
}
output["url"] = url;
}
if ( ! isRootObject ) {
meta.images[uuid] = output;
}
return output;
}