This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > December 2003 > I need help (coordinate stuff with javascript)





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author I need help (coordinate stuff with javascript)
Scathen C

2003-12-10, 10:18 pm

Hey all,

Um here is my scenario.
I am making a web-page where you can load up any vrml model right (done that).
And I have a button called "Add Anchor," and I am trying to write a function
that puts an anchor on the first bit of geometry touched where the mouse is
clicked on the vrml model.

Right now I am using the mouseDown(x,y,button,shift) event to detect the mouse
click and now I have x and y for screen coordinated.
I was then trying to use the Cortona.Engine.PointTo3D(x,y,distance) function to
obtain some coordinates within the model world. I dont understand however how to
retrieve the coordinate data from the result of PointTo3D.

ie. if i put this
vec=Cortona.Engine.PointTo3D(x,y,0);
how do i extract x y and z from vec??
i've tried vec.x, vec.x(0), vec(0), vec[0], vec.x[0], vec.toString(),
vec.value....etc...can anyone tell me what i'm doing wrong.

Just a point to note, if I put this
vec=Cortona.Engine.CreateField("SFVec3f");
vec.x=5;
vec=Cortona.Engine.PointTo3D(x,y,10);
vec.x now become 'undefined'....<--huh?

PLEASE HELP,

thanks
Matt


O.L.

2003-12-13, 5:12 pm

"Scathen C" <s4043358@student.uq.edu.au> wrote in
news:br8k6k$5lv$1@bunyip.cc.uq.edu.au:
quote:

> ie. if i put this
> vec=Cortona.Engine.PointTo3D(x,y,0);



Are you sure that the PointTo3D function returns something ? Doesn't it do
something ?
quote:

> Just a point to note, if I put this
> vec=Cortona.Engine.CreateField("SFVec3f");
> vec.x=5;
> vec=Cortona.Engine.PointTo3D(x,y,10);
> vec.x now become 'undefined'....<--huh?



"vec" isn't a SFVec3f :)
Try to execute alert(vec); and alert(vec+''); and look at the alert box :
- no alert box => the variable isn't recognized
- "undefined" => the var/property has no value.
- [object] => it's a good sign ;)
- a value => huh ... it works

I'm not sure I helped you, but ... good luck !
O.L.
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews