⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flexview3d.as

📁 这是一个flexAway3d的例子,适合初学flash actionscript的人学习。
💻 AS
字号:
package
{
  import away3d.core.material.BitmapFileMaterial;
  import away3d.core.math.Number3D;
  import away3d.core.scene.Light3D;
  import away3d.core.scene.View3D;
  import away3d.objects.Cube;
  
  import flash.events.Event;
  
  import mx.core.Application;
  import mx.core.UIComponent;

  public class FlexView3D extends UIComponent
  {
    private var view:View3D;
    private var sceneLight:Light3D;
    
    //Test
    private var testCube:Cube;
    
    public function FlexView3D()
    {
      super();
      this.addEventListener(Event.ENTER_FRAME, onFrameEnter);
    }
    
    override protected function createChildren():void
    {
      super.createChildren();
      
      if(!this.view)
      {
        this.view = new View3D();
        
        this.view.camera.moveTo(new Number3D(0, 0, -1500));
        this.view.camera.lookAt(new Number3D(0, 0, 0));
      }
      this.addChild(this.view);
      
      if(!this.testCube)
      {
        this.testCube = new Cube({name: "cube", size: 250, material: new BitmapFileMaterial(Application.application.parameters.textureUrl)});
      }
      this.view.scene.addChild(this.testCube);
    }
    
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    {
      super.updateDisplayList(unscaledWidth, unscaledHeight);
      
      if(this.width / 2 != this.view.x)
        this.view.x = this.width / 2;
      if(this.height / 2 != this.view.y)
        this.view.y = this.height / 2;
    }
    
    private function onFrameEnter(event:Event):void
    {
      if(this.view && this.view.stage)
      {
        this.testCube.rotationX += .7;
        this.testCube.rotationY += .5;
        this.testCube.rotationZ += .4;
        
        this.view.render();
      }
    } 
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -