On Sat, 14 Apr 2001 13:49:32 +0100, "Colin Jack"
Quote:
>I have a question, I need to add animation to a piece of VRML and need some
>advice. I want to add interactivity to the VRML so that some objects on the
>scene follow the mouse cursor (or maybe moves to the position when the user
>clicks), I know this isnt directly possible in VRML but I believe it is if
>you combine VRML and JavaScript. Can I ask where I can find out about
>combining the two and if any of you have seen a similiar thing done in VRML
>?
The general principle's certainly possible using Javascript, sensors,
and Routing. No doubt someone can point you at a suitable tutorial.
I believe a TouchSensor is what you'd want here. That outputs
hitPoint_changed, being the point on the surface of the object the
sensor applies to that has a mouse pointer over it. Now use a script
to do sums to generate a position interpolator between where your
moving thing is and where the cursor is. And route the output of that
to a translation that contains the moving object.
But when I've tried it, it's been a bit more complicated than that,
trying to get all the events in the right order, and figuring out what
happens if the user moves before the interpolator's finished its job.
You might be better off moving towards a click. At least a click stays
put, if you see what I mean. Following a moving mouse pointer would be
non-stop processing.