Problem tweening rotationY of character demo character.ghostObject

Software: Away3D 4.x

hfeist, Jr. Member
Posted: 12 March 2014 04:53 PM   Total Posts: 37

I’m using the code in the character demo as the starting point of a simulated first-person walkthrough of an art museum (image attached).

Everything works well so far but I’m having a problem finding a way to smoothly tween the camera’s rotation.

When visitors click on a painting I need them to tween x and z over to that location, be placed facing it and standing back a viewable distance. All of this has been worked out and works well except for one annoying problem.

If the painting is on a wall that is facing at right angles to the direction the visitor is facing when they click (as in the attached image), the camera sometimes ends up facing backwards or 180 degrees from the painting.

This tween gets the visitor to the right place in front of the painting:


Then the rotation tween code below works well some of the time but not always. Success seems to depend on whether the painting is facing north/south or east/west.

The var p is the character.ghostObject.rotationY needed to face the painting from that final position:

Tweener.addTween(character.ghostObject,{rotationY:p0,time:2transition:"easeout",onComplete:function():void { character.ghostObject.rotation = new Vector3D(1,p,0)}}); 

The onComplete function is there as a crude temporary solution to correct the rotation in cases where it’s wrong.

Any ideas how I might solve this?




Away3D Forum

Member Login