This code doesn't work:
// Down ray
raycaster.drawLine([playerPosition[0], playerPosition[1] - 5],
[playerPosition[0], playerPosition[1] - 15], [1, 1, 1]);
const point1 = new b2Vec2(playerPosition[0] / pixelsPerMeter,
(playerPosition[1] - 5) / pixelsPerMeter);
const point2 = new b2Vec2(playerPosition[0] / pixelsPerMeter,
(playerPosition[1] - 15) / pixelsPerMeter);
// world.RayCast(downRayCallback, point1, point2);
const input = {
p1: point1,
p2: point2,
maxFraction: 1
};
const output = {
normal: new b2Vec2(0, 0),
fraction: 1
};
grounded = false;
for (let i = 0; i < fixtures.length; i++) {
grounded = fixtures[i].RayCast(input, output);
if (grounded)
break;
}
console.log(`grounded = ${grounded}`);
It prints grounded = false:
Example in Sandboxes:
Run in browser
GitHub Repository with sandboxes and instruction for Rollup.

I made this gif-animation to show that point1 and point2 are correct in this example:
// Down ray
raycaster.drawLine([playerPosition[0], playerPosition[1] - 5],
[playerPosition[0], playerPosition[1] - 15], [1, 1, 1]);
const point1 = new b2Vec2(playerPosition[0] / pixelsPerMeter,
(playerPosition[1] - 5) / pixelsPerMeter);
const point2 = new b2Vec2(playerPosition[0] / pixelsPerMeter,
(playerPosition[1] - 15) / pixelsPerMeter);
world.RayCast(downRayCallback, point1, point2);
world.RayCast works:

but fixtures[i].RayCast doesn't work.
This code doesn't work:
It prints
grounded = false:Example in Sandboxes:
Run in browser
GitHub Repository with sandboxes and instruction for Rollup.
I made this gif-animation to show that point1 and point2 are correct in this example:
world.RayCastworks:but
fixtures[i].RayCastdoesn't work.