getTimesForAllAxes method

dynamic getTimesForAllAxes(
  1. Map curves
)

Implementation

getTimesForAllAxes( Map curves ) {

	var times = [];

	// first join together the times for each axis, if defined
	if ( curves["x"] != null ) times.addAll( curves["x"]["times"] );
	if ( curves["y"] != null ) times.addAll( curves["y"]["times"] );
	if ( curves["z"] != null ) times.addAll( curves["z"]["times"] );

	// then sort them
	times.sort( ( a, b ) {

		return a - b > 0 ? 1 : -1;

	} );

	// and remove duplicates
	if ( times.length > 1 ) {

		var targetIndex = 1;
		var lastValue = times[ 0 ];
		for ( var i = 1; i < times.length; i ++ ) {

			var currentValue = times[ i ];
			if ( currentValue != lastValue ) {

				times[ targetIndex ] = currentValue;
				lastValue = currentValue;
				targetIndex ++;

			}

		}

		times = times.sublist( 0, targetIndex );

	}

	return times;

}