Invert sphere rotation so child always face camera

Software: Away3D 4.x

SamYStudiO, Newbie
Posted: 09 July 2012 04:32 PM   Total Posts: 4

Hey,

I got a sphere with planes added to it, i would like to rotate sphere and planes still face camera.

I first try to apply a negate rotation to planes

plane.rotationX = -sphere.rotationX

Works with x and y separately but once you apply both rotation it’s totally messed up

Then I try lookAt

plane.lookAtcamera.position ); 

Nothing actualy works as expected.
Sure there is an esay way but I don’t get it.

Any help?
Thanks

   

Avatar
Alexander Seifert, Moderator
Posted: 09 July 2012 04:42 PM   Total Posts: 129   [ # 1 ]

Hey,

did you already take a look at Sprite3D?
In essence, it is a plane that always faces the camera (aka. ‘billboard’). However, it can not be rotated along the camera view axis.

Cheers!

 Signature 
signature_image

http://www.deltastrike.org

   

SamYStudiO, Newbie
Posted: 09 July 2012 05:01 PM   Total Posts: 4   [ # 2 ]

sounds good with rotation problem but now messed up with my light and planes disapear when they pass behind the back side of the sphere.

Noway to achieve it keeping PlaneGeometry?

Anyway thx for your fast reply!

   

Richard Olsson, Administrator
Posted: 10 July 2012 06:47 AM   Total Posts: 1192   [ # 3 ]

Are the planes children of the sphere/container or of the scene directly? If you’re rotating the parent of the planes, their coordinate system will not match that in which the camera exists (which is scene space.) If this is the case you can’t just use lookAt() with the position of the camera, because the math assumes that the target position vector that you’re passing into lookAt() is in the same space as the object on which you’re executing it.

Try using the sceneTransform of the plane’s parent to transform the position of the camera into the same space as the planes.

var tf Matrix3D sphereContainer.inverseSceneTransform;
var 
localCamPos Vector3D tf.transformVector(camera.position);

// For each plane:
myPlane.lookAt(localCamPos); 
   

SamYStudiO, Newbie
Posted: 10 July 2012 12:19 PM   Total Posts: 4   [ # 4 ]

Hey,

can’t make it work either, but i found out some hack, here a solution for those who could get stuck.

I added invisible mesh plane into the sphere.
My visible planes are added into sphere parent and while rotating sphere i fetch invisible sphere plane coordinates and apply them to my visibles planes

Thx for your reply!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X