
I just can't figure this out. It works, but not perfect. (not on all faces)
theRay = mapScreenToWorldRay mouse.pos</br>
intersectArr = (intersectRayScene theRay)</br>
pos = intersectArr[intersectArr.count][2].pos</br>
dir = (intersectArr[intersectArr.count][2].dir)</br>
z=dir</br>
tempX=[1,0,0]</br>
y=normalize (cross z -tempX)</br>
x=normalize (cross y z)</br>
tm=matrix3 x y z theRay.pos</br>
rot = tm.rotation</br>
--also tested this line</br>
--rot = (quat dir.x dir.y dir.z 1</br>
obj.pos = pos obj.rotation = rot
any help appreciated!!
By jos · 2012-05-19