How to get coordinates when I hit the object in X3D?

1k Views Asked by At

I found that when I hit the object with mouse,I will receive coordinates in the console like this:

" INFO: Ray hit at position -0.8909352080500961 0.004276552687857628 -1.0112924948899256

INFO: Hit "Shape/ null"

INFO: Ray hit at position -0.8915609839018154 0.0019779635524881855 -1.0258166943957363

INFO: Hit "Shape/ null"

INFO: Ray hit at position -0.8910244952200963 -0.014531608631342386 -0.9694042420800579

INFO: Hit "Shape/ null" "

But I want to pass these coordinates as parameters of some functions,what should I do?

1

There are 1 best solutions below

0
On

In X3DOM:

Here is an example:

http://x3dom.org/x3dom/example/x3dom_onClickEvent.xhtml

The middle two objects access coordinates in JavaScript.

The coordinates will be in the event.hitPnt argument of the onclick callback.