animate light with tweenmax

Software: Away3D 4.x

Colir, Newbie
Posted: 29 November 2011 11:47 AM   Total Posts: 21

Hi,
i’ve a newbie issue…
I don’t understand how to move a light position with tweenmax.

i use some thing like this :

directLight = new DirectionalLight(-1, -11);
directLight.color 0xFFFFFF;
directLight.= -15000;
directLight.= -15000;
directLight.= -15000;
view.scene.addChild(directLight);


TweenMax.to(directLight,3,{x:"-2000",repeat:-1,yoyo:true}

but nothing append…my light is still fix…
i’ve also try with a point light with the same result…

can you help me please?
thanks

   

John Brookes, Moderator
Posted: 29 November 2011 12:41 PM   Total Posts: 732   [ # 1 ]

A directional light shines from every world position in the direction you set.
So just moving its position will not change the apperance of the light.

You need to also update the lights direction. (direction just sets a lookAt position for the light)

eg
in render loop
yourDirectionalLight.lookAt(new Vector3D())

   

Colir, Newbie
Posted: 30 November 2011 04:15 PM   Total Posts: 21   [ # 2 ]

Yes this just normal !
But what about the point light ?

My goal is to turn a light around a model with tweenmax…

thanks

   

Colir, Newbie
Posted: 30 November 2011 05:29 PM   Total Posts: 21   [ # 3 ]

well…i’m so sorry…all work fine…point light and directional light
i’m feel so stupid…

just one thing that doesn’t work as i except :
For directionnal light, i must tween a Vector3d object value, and assign this object on each render frame

directLightDirection = new Vector3D(0,0,0)
TweenMax.to(directLightDirection3{bezierThrough:[{x:-15000z:-15000}{x:-15000z:15000}{x:15000z:15000}{x:15000z:-15000}],repeat:-1ease:Linear.easeNone});

private function 
render(evt:Event):void{
     directLight
.direction directLightDirection
     view
.render();

this work fine !

i ‘ve also try to manipulate directly the direction but without effect, the light is not update

directLight.direction = new Vector3D(0,0,0)
TweenMax.to(directLight.direction3{bezierThrough:[{x:-15000z:-15000}{x:-15000z:15000}{x:15000z:15000}{x:15000z:-15000}],repeat:-1ease:Linear.easeNone}); 

This doesn’ t work ! i don’t understand why

Is that normal ?


ps: A little complementary question :
how to add a debugg box around a light ?

thanks again

   

John Brookes, Moderator
Posted: 30 November 2011 06:41 PM   Total Posts: 732   [ # 4 ]

It needs to update

private function movelight(e:MouseEvent):void 
{
directLightDirection 
= new Vector3D(000);
TweenMax.to(directLightDirection30{bezierThrough:[{x:-15000z:15000}{x:15000z:15000}{x:15000z:-15000}],repeat:-1ease:Linear.easeNoneonUpdate:updateMyDirectionalLight});
}

private function updateMyDirectionalLight():void 
{
 myDirectionalLight
.direction directLightDirection

 

Could just as easily do

TweenMax.to(myDirectionalLight30{rotationY:"360" ); 

For debug I usually add a sphere to the point lights and tridents for directional.

   

Colir, Newbie
Posted: 01 December 2011 09:40 AM   Total Posts: 21   [ # 5 ]

feel so stupid again…
thanks a lot for your help !

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X