Setting ambient value on light causes flicker at startup

Software: Away3D 4.x

Ontheronix, Jr. Member
Posted: 02 September 2012 12:36 PM   Total Posts: 37

The flicker appears on startup, and affects only the objects in my View3D.
It seems to be the lighting that changes for a splitsecond, it seems to initialize with the default light.ambient setting, and then changes to my brighter ‘0.9’.

Commenting

light.ambient 0.9

resolves the issue.

Example: (horizontal plane) http://mark.me/test/ (Refresh page to repeat if you didn’t see it)
(I use the latest version from Git)


Code:

package  {
 
 import flash
.display.MovieClip;
 
import away3d.entities.Mesh;
 
import away3d.containers.View3D;
 
import away3d.primitives.PlaneGeometry;
 
import away3d.materials.lightpickers.StaticLightPicker;
 
import away3d.lights.DirectionalLight;
 
import away3d.materials.methods.FilteredShadowMapMethod;
 
import flash.geom.Vector3D;
 
import flash.events.Event;
 
import away3d.materials.ColorMaterial;
 
import away3d.debug.AwayStats;
 
 public class 
Main extends MovieClip {
  
  
var view:View3D;
  public function 
Main() {
    view 
= new View3D();
    var 
light:DirectionalLight = new DirectionalLight();   
    
light.ambient 0.9;
    
    
    
view.scene.addChild(light);
    
view.camera.position=new Vector3D(0,50,-400);
    
view.backgroundColor 0xFFFFFF;
    
view.addEventListener(Event.ENTER_FRAME,entr);
    
    
      var 
_lightPicker:StaticLightPicker = new StaticLightPicker([light]);
    
    var 
_groundMaterial:ColorMaterial = new ColorMaterial(0xEEEEEE);
    
_groundMaterial.shadowMethod = new FilteredShadowMapMethod(light);
    
_groundMaterial.lightPicker _lightPicker;
    
    
    
    var 
msh:Mesh = new Mesh(new PlaneGeometry(400400),_groundMaterial);
    
view.scene.addChild(msh);
    
addChild(view);
    
    var 
stats:AwayStats = new AwayStats(view);
    
stage.addChild(stats);
  
}
  
function entr (e:Event{
     view
.render();  
  
}
 }
 
   

Avatar
loth, Sr. Member
Posted: 03 September 2012 02:54 PM   Total Posts: 236   [ # 1 ]

Try with that (add more time if don’t work)

import flash.events.TimerEvent;

        public function 
Main() {
            
if (stage)
                
setTimeout(init0);
            else
                
addEventListener(Event.ADDED_TO_STAGEinitfalse0true);
        
}

        
protected function init(e:Event=null):void {
            
if (eremoveEventListener(Event.ADDED_TO_STAGEinit);
       
// your code here
   

Ontheronix, Jr. Member
Posted: 09 September 2012 10:41 AM   Total Posts: 37   [ # 2 ]

This doesn’t work, even if I set the interval to 1000. It just takes longer for the view to appear, but when it appears, the short flicker is there again.

   

Ontheronix, Jr. Member
Posted: 09 September 2012 01:14 PM   Total Posts: 37   [ # 3 ]

I’d like to note that adding:

light.direction = new Vector3D(0, -10);
 
light.castsShadows true

does not make any difference.

Not setting a lightpicker to the material bypasses the problem. But hereby there is no more possibility to render shadows if I’m correct?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X