Hit test for Sketch objects...

Anthony Palomba's icon

I would like to create an interface that has objects (spheres)
that I can click on. With screentoworld() I can convert the
mouse click point to world coordinates. The question is
how can I test to see if my world coordinates are in a drawn
object?

pixelmechanic's icon

Hi Anthony

Funnily enough I've been revisiting my xy_lcd patches that you were so kind about quite some time ago.

I've rebuilt the pseudogravity patch using jitter objects and javascript.

The js includes some routines for hit detection per object, it needs to be updated to use pythagoras theorem to better detect hit inside a circle...

The attached file might help you get started

Cheers

Jules

PS I guess you've seen 47jJitterListener.pat in the jitter tutorials.

Anthony Palomba's icon

Thanks Jules, I will take a look at it.

oli larkin's icon

have a look at i_ispace.js in the int.lib source, which does just this

oli

Anthony Palomba's icon

Actually I did look at your source. You are using
"jit.gl.render". I am familiar with doing hit detection using
jitter. I am using the jsui sketch object. I believe (as far as
I know) jsui sketch does not support JitterListener events.
Someone please correct me if I am wrong...