javascript - Three.js move object to point along some line & lookAt -


i have cuboid (three.cubegeometry 1x1x10 example). here's i'm trying accomplish:

  1. given point, want place cuboid distance away origin, along line formed origin , said point

  2. rotate cuboid faces origin

enter image description here

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 enter image description here

note side of object looking @ origin (not want) enter image description here

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) enter image description here

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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -