toJson method

Map<String, dynamic> toJson(
  1. dynamic meta
)

meta - optional object containing metadata.

Convert the data source to three.js JSON Object/Scene format.

Implementation

Map<String,dynamic> toJson(meta) {
		final isRootObject = ( meta == null || meta is String );

  if (!isRootObject && meta.images[uuid] != null) {
    return meta.images[uuid];
		}

		final output = {
			"uuid": uuid,
			"url": ''
		};

		final data = this.data;

		if ( data != null ) {
			dynamic url;

			if ( data is List ) {
				url = [];

				for ( int 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 {
				url = serializeImage( data );
			}

			output["url"] = url;
		}

		if(!isRootObject){
    meta.images[uuid] = output;
		}

		return output;
	}