-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Click/hit detection #15
Comments
Not yet, could be cool to play around with though - good idea! |
I drove myself potty trying isometric hit detection once. A depth buffer might do it, depends on your code :) sent from my mobile
|
@mcintyre321 any experience with depth buffering? #9 needs it big time. |
Whoops, accidentally deleted my comment. I'll attempt to remember it. "As you are using canvas fills, as opposed to per-pixel rendering, you could render shapes (in depth order) to a second canvas using a unique colour for the whole shape, creating a colour=>shape lookup table. To do mouse events, get pixel colour at a particular cell, and use it as a key for the lookup table" |
My edit was going to be: at some point you might just want to go with an orthographic projection in threejs under the hood, and use it's z-buffer facilities (assuming it has them :)) |
Wow that's super smart, thanks! And yeah, I'm not totally sure if I want to use Threejs or something else under the hood - the whole idea was to make something crazy small and portable that could be used for simple web graphics. I didn't intend it to be a super powerful graphics engine, just a simple one. |
Which is a commendable goal - I had a look at the code and it is crazy small! I'd like to be able to write simple web games using Isomer (hence the hit detection request), and there are a couple of other features that would be nice (e.g. removal of Shapes, a Camera class) - are these features likely to be on the roadmap? |
Yeah definitely. Keeping track of objects in the scene has a pretty big priority. |
Position seems more reliable than color |
What he means is drawing a flat color on a separate canvas - not shaded - so that it's easy to do a lookup based on mouse position. |
I get that part, but doesn't it seem like a roundabout way to keep track of the object, rather than relying on x,y and then checking what is the foremost z index object? |
Not totally sure I understand, sorry. |
Imagine, there is a flat plane with ( Now if we take the plane from being 2d and make it 3d, the Assuming that the higher the When you click with a mouse you get two coordinates ( Another way is to create a camera and a raycaster to get the intersection (which is basically what you are doing, is intersecting) Should you not be using a depth-coordinate at all, it will be a little easier as all you have to do is translate the mouse click to an absolute tile click. Imagine you are using same colors, or image tiles, or they are touching, you are screwed in a sense if you use colors. |
Pixel xy to object mapping is going to be tricky once you take into account Given that, I suspect any other methods will end up being equivalent to |
The flat color render on a separate canvas is a very clever idea, I guess, as it's not a canvas that will be displayed, you could just assign any color to each object so you would only run into trouble if you have over 16.5 million objects? |
@DaveKinsella the answer to your question could be: "Is javascript a good solution to render a canvas with 16.5 million objects?" |
I was recently stuck trying to bring hit detection to isomers cousin ( Obelisk.js) and no joke I almost drove myself potty as well. So what I hear you say, this is Isomer land, well, it works just as fine for Isomer, It might not scale and you might have some issues with overlapping geometry, but its a relatively painless way of adding some interactivity ( easel.js is something like 87k), Here's a very basic example: And the result: Cheers ! |
Is there any support for click/mouseover/hit detection, or is there any planned?
The text was updated successfully, but these errors were encountered: