class Sensor{ constructor(){ this.rayCount=5; this.rayLength=150; this.raySpread=Math.PI/4; this.rays=[]; this.readings=[]; } update(x,y,angle,roadBorders,traffic){ this.#castRays(x,y,angle); this.readings=[]; for(let i=0;i { for(let i=1;ie.offset); const minOffset=Math.min(...offsets); return touches.find(e=>e.offset==minOffset); } } #castRays(x,y,angle){ this.rays=[]; for(let i=0;i