I see from the TODO list in your script's comments that you're looking for some occlusion code for handling line-of-sight to the breadcrumbs. I do this for checking line-of-sight to traps in my It's A Trap script.
Check out the below snippet from It's A Trap:
...
/**
* Gets the tokens that a token has line of sight to.
* @private
* @param {Graphic} token
* @param {Graphic[]} otherTokens
* @param {number} [range=Infinity]
* The line-of-sight range in pixels.
* @param {boolean} [isSquareRange=false]
* @return {Graphic[]}
*/
function _getTokensInLineOfSight(token, otherTokens, range, isSquareRange) {
if(_.isUndefined(range))
range = Infinity;
var pageId = token.get('_pageid');
var tokenPt = [
token.get('left'),
token.get('top'),
1
];
var tokenRW = token.get('width')/2-1;
var tokenRH = token.get('height')/2-1;
var wallPaths = findObjs({
_type: 'path',
_pageid: pageId,
layer: 'walls'
});
var wallSegments = PathMath.toSegments(wallPaths);
return _.filter(otherTokens, other => {
var otherPt = [
other.get('left'),
other.get('top'),
1
];
var otherRW = other.get('width')/2;
var otherRH = other.get('height')/2;
// Skip tokens that are out of range.
if(isSquareRange && (
Math.abs(tokenPt[0]-otherPt[0]) >= range + otherRW + tokenRW ||
Math.abs(tokenPt[1]-otherPt[1]) >= range + otherRH + tokenRH))
return false
else if(!isSquareRange && VecMath.dist(tokenPt, otherPt) >= range + tokenRW + otherRW)
return false;
var segToOther = [tokenPt, otherPt];
return !_.find(wallSegments, wallSeg => {
return PathMath.segmentIntersection(segToOther, wallSeg);
});
});
}
...