You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having trouble with Mouse.insideBounds when a light rotation is applied to the geometry.
I've tried to simplify the code as much as possible, below is an array of cards (set pixelZoom to 1 if your screen is too small) representing the hand of a player.
The cards change background to green when hovered over. The cards on the bottom right seem to work fine mostly, but the cards on the left not. You need to hover above them, at least their bottom half doesn't work.
If the rotation is removed (see comment in code), no issue at all.
import{useType,useNewComponent,useChild,Canvas,Vector,Geometry,Polygon,Mouse,useDraw,}from"@hex-engine/2d";exportdefaultfunctionRoot(){useType(Root);constcanvas=useNewComponent(()=>Canvas({backgroundColor: "#444"}));canvas.fullscreen({pixelZoom: 2});constcanvasCenter=newVector(canvas.element.width/2,canvas.element.height/2);for(leti=9;i>=0;i--){useChild(()=>Card(newVector(0,-800).rotateMutate(-(i-4.5)*0.04).addMutate(canvasCenter).addYMutate(950),(i-4.5)*0.03)// Set this to 0 and the problem disappears);}}functionCard(position: Vector,rotation: number){useType(Card);constgeo=useNewComponent(()=>Geometry({shape: Polygon.rectangle(newVector(40,60)),position: position.clone(),
rotation
}));constmouse=useNewComponent(Mouse);useDraw((context)=>{context.fillStyle="#6666ff";if(mouse.isInsideBounds){context.fillStyle="green";}context.strokeStyle="red";geo.shape.draw(context,"fill");geo.shape.draw(context,"stroke");});}
I'm a bit baffled, because the cards on the middle have a very low rotation of 0.015 and the problem still happens.
The text was updated successfully, but these errors were encountered:
That's very strange... thanks for the bug report. I'm able to reproduce it in your online demo, and I don't see anything odd in the code you posted. I'll try to investigate this soon.
I'm having trouble with
Mouse.insideBounds
when a light rotation is applied to the geometry.I've tried to simplify the code as much as possible, below is an array of cards (set
pixelZoom
to 1 if your screen is too small) representing the hand of a player.The cards change background to green when hovered over. The cards on the bottom right seem to work fine mostly, but the cards on the left not. You need to hover above them, at least their bottom half doesn't work.
If the rotation is removed (see comment in code), no issue at all.
I'm a bit baffled, because the cards on the middle have a very low rotation of
0.015
and the problem still happens.The text was updated successfully, but these errors were encountered: