MCPcopy
hub / github.com/KilledByAPixel/LittleJS / engineObjectsRaycast

Function engineObjectsRaycast

src/engine.js:563–577  ·  view source on GitHub ↗

Return a list of objects intersecting a ray * @param {Vector2} start * @param {Vector2} end * @param {Array } [objects=engineObjects] - List of objects to check * @return {Array } - List of objects hit * @memberof Engine

(start, end, objects=engineObjects)

Source from the content-addressed store, hash-verified

561 * @return {Array<EngineObject>} - List of objects hit
562 * @memberof Engine */
563function engineObjectsRaycast(start, end, objects=engineObjects)
564{
565 const hitObjects = [];
566 for (const o of objects)
567 {
568 if (o.collideRaycast && isIntersecting(start, end, o.pos, o.size))
569 {
570 debugRaycast && debugRect(o.pos, o.size, '#f00');
571 hitObjects.push(o);
572 }
573 }
574
575 debugRaycast && debugLine(start, end, hitObjects.length ? '#f00' : '#00f', .02);
576 return hitObjects;
577}

Callers 1

gameRenderPostFunction · 0.85

Calls 3

isIntersectingFunction · 0.85
debugRectFunction · 0.70
debugLineFunction · 0.70

Tested by

no test coverage detected