path_.js
// Find the cheapest path to a number of targets and return the target & path
Find the cheapest path to a number of targets and return the target & path
Find the cheapest path to a number of targets and return the target & path
function findNearest(start, targets, options) {
	options = options || {};
	options.strict = true;
	var positions = options.positions || targets.map(function(target) {
		return WorldPosition(target.pos);
	});
	options.targets = positions;
	var path = find(start, options);
	if (!path) {
		return;
	}
	var pos = path.path[path.length - 1];
	var ii = _.findIndex(positions, function(targetPosition) {
		return pos.isEqualTo(targetPosition);
	});
	return targets[ii] && {
		target: targets[ii],
		index: ii,
		path: path,
	};
}
function findNearest ( start , targets , options ) { options = options || { } ; options . strict = true ; var positions = options . positions || targets . map ( function ( target ) { return WorldPosition ( target . pos ) ; } ) ; options . targets = positions ; var path = find ( start , options ) ; if ( ! path ) { return ; } var pos = path . path [ path . length - 1 ] ; var ii = _ . findIndex ( positions , function ( targetPosition ) { return pos . isEqualTo ( targetPosition ) ; } ) ; return targets [ ii ] && { target : targets [ ii ] , index : ii , path : path , } ; }
Find the cheapest path to a number of targets and return the target & path
Find the cheapest path to a number of targets and return the target & path