Some problem when using PointLight3D and WhiteShadingBitmapMaterial

Software: Away3D 3.x

pythonly, Newbie
Posted: 20 July 2011 04:47 AM   Total Posts: 1

Hello everybody,
I create a simple project using away3d framework, but I get some problems, that’s so cryptic.

First, when using PointLight3D together with PhongBitmapMaterial (BitmapMaterial is the same) then compile the project, I can not see any light rendered. But if I use WhiteShadingBitmapMaterial instead of PhongBitmapMaterial, the result is true. I don’t know the reason.

The second problem is if using PoinLight3D together with WhiteShadingBitmapMaterial, the application compiled run so slow, flash player crashed, the performance of CPU grow up to 80, 90%, why…

Below show my code.

Thanks.


public class Demo extends MovieClip
{
  [Embed(source = “assets/table.png”)] private var Table:Class;
  private var _bmpTable:Bitmap = new Table();
  [Embed(source = “assets/ball1.png”)] private var Ball1:Class;
  private var _bmpBall1:Bitmap = new Ball1();
  [Embed(source = “assets/ball2.png”)] private var Ball2:Class;
  private var _bmpBall2:Bitmap = new Ball2();
  [Embed(source = “assets/ball3.png”)] private var Ball3:Class;
  private var _bmpBall3:Bitmap = new Ball3();
  [Embed(source = “assets/ball4.png”)] private var Ball4:Class;
  private var _bmpBall4:Bitmap = new Ball4();
  [Embed(source = “assets/ball5.png”)] private var Ball5:Class;
  private var _bmpBall5:Bitmap = new Ball5();
  [Embed(source = “assets/ball6.png”)] private var Ball6:Class;
  private var _bmpBall6:Bitmap = new Ball6();
  [Embed(source = “assets/ball7.png”)] private var Ball7:Class;
  private var _bmpBall7:Bitmap = new Ball7();
  [Embed(source = “assets/ball8.png”)] private var Ball8:Class;
  private var _bmpBall8:Bitmap = new Ball8();
  [Embed(source = “assets/shadow.png”)] private var Shadow:Class;
  private var _bmpShadow:Bitmap = new Shadow();
 
  private static const CAMERA_ORBIT:Number = 700;
  private static const CAMERA_BITCH:Number = 700;
  private static const CAMERA_YAW:Number = 0;
  private static const CAMERA_ROLL:Number = 0;
 
  public var mcSceneFor3D:MovieClip;
  public var cbLightSources:ComboBox;
  public var cbShaders:ComboBox;
  public var cbMaterialTypes:ComboBox;
 
  public var slAmbient:Slider;
  public var slDiffuse:Slider;
  public var slSpecular:Slider;
 
  public var txtAmbient:TextField;
  public var txtDiffuse:TextField;
  public var txtSpecular:TextField;
 
  public var btnRender:Button;
 
  private var _scene:Scene3D;
  private var _camera:Camera3D;
  private var _view:View3D;
 
  private var _ambientLight:AmbientLight3D;
  private var _directionLight:DirectionalLight3D;
  private var _pointLight3D:PointLight3D;
 
  private var _group:ObjectContainer3D;
  private var _table:Plane;
  private var _balls:Vector.<Sphere>;
  private var _shadows:Vector.;
 
  ///////////////////////////////////////////////////////////////////////////////// access point
 
  public function Demo():void {
  if (stage) init();
  else stage.addEventListener(Event.ADDED_TO_STAGE, init);
  }
 
  private function init(ev:Event = null):void {
  initComponent();
  init3D();
  createScene3D();
  initEvents();
  }
 
  ///////////////////////////////////////////////////////////////////////////////// private method
 
  private function initComponent():void {
  initComboBox();
  initSlider();
  initButton();
  }
 
  private function init3D():void {
  createScene();
  createCamera();
  createLight();
  createView();
  }
 
  private function createScene3D():void {
  _group = new ObjectContainer3D();
  //_group.pushback = true;
  _scene.addChild(_group);
 
  createTable();
  createBalls();
  }
 
  private function initEvents():void {
  stage.addEventListener(Event.ENTER_FRAME, render);
  stage.addEventListener(KeyboardEvent.KEY_DOWN, rotationTable);
  }
 
  ///////////////////////////////////////////////////////////////////////////////// functions
 
  private function initComboBox():void {
  /*
  cbLightSources.addItem( { label:“AmbientLight3D ” } );
  cbLightSources.addItem( { label:“DirectionalLight3D” } );
  */
  cbLightSources.addItem( { label:“PointLight3D” } );
 
  cbLightSources.selectedItem = cbLightSources.getItemAt(0);
  cbLightSources.addEventListener(Event.CHANGE, onChangeLightSource);
 
  cbMaterialTypes.addItem( { label:“PhongBitmapMaterial” } );
  /*
  cbMaterialTypes.addItem( { label:“PhongMovieMaterial” } );
  cbMaterialTypes.addItem( { label:“PhongColorMaterial” } );
  cbMaterialTypes.addItem( { label:“EnviroBitmapMaterial” } );
  cbMaterialTypes.addItem( { label:“Dot3BitmapMaterial” } );
  cbMaterialTypes.addItem( { label:“Dot3MovieMaterial” } );
 
  cbMaterialTypes.addItem( { label:“ShadingColorMaterial” } );
  cbMaterialTypes.addItem( { label:“WhiteShadingBitmapMaterial” } );
  */
  cbMaterialTypes.selectedItem = cbMaterialTypes.getItemAt(0);
  cbMaterialTypes.addEventListener(Event.CHANGE, onChangeMaterialType);
 
  initCbShadersByMaterial(cbMaterialTypes.selectedLabel);
  cbShaders.addEventListener(Event.CHANGE, onChangeShader);
  }
 
  private function initCbShadersByMaterial(material:String):void {
  cbShaders.removeAll();
  switch (material) {
  case “PhongBitmapMaterial”:
    cbShaders.addItem( { label:“AmbientShader” } );
    cbShaders.addItem( { label:“DiffusePhongShader” } );
    cbShaders.addItem( { label:“SpecularPhongShader” } );
    break;
  case “PhongMovieMaterial”:
    cbShaders.addItem( { label:“AmbientShader” } );
    cbShaders.addItem( { label:“DiffusePhongShader” } );
    cbShaders.addItem( { label:“SpecularPhongShader” } );
    break;
  case “PhongColorMaterial”:
    cbShaders.addItem( { label:“AmbientShader” } );
    cbShaders.addItem( { label:“DiffusePhongShader” } );
    cbShaders.addItem( { label:“SpecularPhongShader” } );
    break;
  case “EnviroBitmapMaterial”:
    cbShaders.addItem( { label:“EnviroShader” } );
    break;
  case “Dot3BitmapMaterial”:
    cbShaders.addItem( { label:“AmbientShader” } );
    cbShaders.addItem( { label:“DiffuseDot3Shader” } );
    br

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X