mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-25 13:39:06 -05:00
change raycasting example events to enable use in tests
This commit is contained in:
parent
fd1a70ec7a
commit
10afaea8bc
1 changed files with 12 additions and 5 deletions
|
@ -68,14 +68,21 @@ Example.raycasting = function() {
|
||||||
Bodies.rectangle(0, 300, 50, 600, { isStatic: true })
|
Bodies.rectangle(0, 300, 50, 600, { isStatic: true })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
var collisions,
|
||||||
|
startPoint = { x: 400, y: 100 };
|
||||||
|
|
||||||
|
Events.on(engine, 'afterUpdate', function() {
|
||||||
|
var mouse = mouseConstraint.mouse,
|
||||||
|
bodies = Composite.allBodies(engine.world),
|
||||||
|
endPoint = mouse.position || { x: 100, y: 600 };
|
||||||
|
|
||||||
|
collisions = Query.ray(bodies, startPoint, endPoint);
|
||||||
|
});
|
||||||
|
|
||||||
Events.on(render, 'afterRender', function() {
|
Events.on(render, 'afterRender', function() {
|
||||||
var mouse = mouseConstraint.mouse,
|
var mouse = mouseConstraint.mouse,
|
||||||
context = render.context,
|
context = render.context,
|
||||||
bodies = Composite.allBodies(engine.world),
|
endPoint = mouse.position || { x: 100, y: 600 };
|
||||||
startPoint = { x: 400, y: 100 },
|
|
||||||
endPoint = mouse.position;
|
|
||||||
|
|
||||||
var collisions = Query.ray(bodies, startPoint, endPoint);
|
|
||||||
|
|
||||||
Render.startViewTransform(render);
|
Render.startViewTransform(render);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue