javascript - Three.js move object to point along some line & lookAt -
i have cuboid (three.cubegeometry 1x1x10 example). here's i'm trying accomplish:
given point, want place cuboid distance away origin, along line formed origin , said point
rotate cuboid faces origin
i'm tried using
obj.lookat(new three.vector3(0, 0, 0));
but rotates object in such way side faces origin, instead of end.
as first step (finding point along line n units away origin), don't know start. did normalize vec point, [i think] gets me, essentially, line of length 1, (0, 0, 0) pointing towards point. move point want (n distance origin), can scale vector accordingly. not sure if makes sense...
edit
in answer 1 of comments saying how obj.lookat() should work, here's i'm getting, , i'd have instead:
how cuboid being drawn after position set point, lookat() invoked
note side of object looking @ origin (not want)
what i'd have object @ point end (i guess i'm 1 rotation away that, that's 1 rotation i'm not sure how calculate)
when call object.lookat( new three.vector3( 0, 0, 0 ) )
, object's local z-axis point toward origin.
so, if cuboid 1x1x10, long side parallel z-axis, should result want.
three.js r.65
Comments
Post a Comment