Pointlight gradient on camera distance change

Software: Away3D 4.x

Fab4ce, Jr. Member
Posted: 15 February 2013 03:21 PM   Total Posts: 44

Hi,

my point is the pointlight.
I´m trying to create a background in Away4 with radial gradient.
So I take a plane and a Pointlight.
First everything seems to work right. But as you can see in the attachments:
- “fromFar.jpg” shows the gradient how I want it… but I need to fill the stage. Here is the camera set to z -800
- “fromClose.jpg” shows the filled background with camera z position at -200

As you can see, I expect the gradient to fill the borders of the plane.

I tried many settings with the light, but I couldn´t achieve to have a bigger light radius at camera set to z -200 in my scene

Here is all my cleaned up code:

package 
{
import away3d
.containers.*;
import away3d.entities.*;
import away3d.materials.*;
import away3d.primitives.*;
import away3d.utils.*;
import away3d.lights.*;
import away3d.materials.lightpickers.StaticLightPicker;

import flash.display.*;
import flash.events.*;
import flash.geom.Vector3D;
import flash.geom.Point;

[SWF(backgroundColor="#000000"frameRate="60")]

public class ATest extends Sprite
{

private var _material:ColorMaterial;
private var 
_view:View3D = new View3D();
private var 
_plane:Mesh;
private var 
pointLight:PointLight = new PointLight();
private var 
lightPicker:StaticLightPicker;

public function 
ATest()
{
stage
.scaleMode StageScaleMode.NO_SCALE;
stage.align StageAlign.TOP_LEFT;

addChild(_view);
_view.scene.addChild(pointLight);

//setup the camera
_view.camera.= -800;

pointLight.specular 1;
pointLight.color 0x0099CC;
pointLight.= -1200;
trace(pointLight.bounds);

//setup the scene
lightPicker = new StaticLightPicker([pointLight]);
_material = new ColorMaterial(0x000000);
_material.lightPicker lightPicker;
_plane = new Mesh(new PlaneGeometry(stage.stageWidthstage.stageHeight), _material);
_plane.rotationX = -90;
_view.scene.addChild(_plane);

//setup the render loop
addEventListener(Event.ENTER_FRAME_onEnterFrame);
stage.addEventListener(Event.RESIZEonResize);
onResize();
}

private function _onEnterFrame(e:Event):void
{
//pointLight.z -= 5;
_view.render();
}

private function onResize(event:Event null):void
{
_view
.width stage.stageWidth;
_view.height stage.stageHeight;
}
}

 

   

Fab4ce, Jr. Member
Posted: 18 February 2013 09:03 PM   Total Posts: 44   [ # 1 ]

noone?
I hope that my explanation was clear?
I guess that my case has something to do with the bounds property of the pointlight?
See…all I want to have is a gradient of a size that reaches the borders of the stage.
I tried to move the camera, also I tried to use a bigger plane, move the light, change the properties and so on. I just can´t get it big enough.

Any ideas someone? Fabrice? Der Schmale?

   

César, Newbie
Posted: 18 February 2013 09:27 PM   Total Posts: 11   [ # 2 ]

Hmm, I think it’s normal because the blue is the specular and not the illumination of the plane, who is black, and the specular depend of the camera.

So try to put your plane white, move your light without specular near the plane, closer your camera and it should works.

//setup the camera
_view.camera.= -150;

pointLight.specular 0;
pointLight.ambient 0;
pointLight.diffuse 1;
pointLight.color 0x0099CC;
pointLight.= -10;
trace(pointLight.bounds);

//setup the scene
lightPicker = new StaticLightPicker([pointLight]);
_material = new ColorMaterial(0xffffff);
_material.lightPicker lightPicker;
_plane = new Mesh(new PlaneGeometry(stage.stageWidthstage.stageHeight), _material);
_plane.rotationX = -90;
_view.scene.addChild(_plane); 
   

Fab4ce, Jr. Member
Posted: 19 February 2013 10:49 AM   Total Posts: 44   [ # 3 ]

aahhhh….i see.
kind of tricky all this light setting.
thanks a lot!

   

John Brookes, Moderator
Posted: 19 February 2013 11:11 AM   Total Posts: 732   [ # 4 ]

If you want a static background that doesnt change with camera movement.

view.background = new BitmapTexture(yourBitmapData); 
   

Fab4ce, Jr. Member
Posted: 19 February 2013 12:14 PM   Total Posts: 44   [ # 5 ]

thanks. no, it has to be dynamic…color change etc.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X