• away3d 4.0.9Gold 学习笔记 加载模型(6)


    学习笔记提供模型和贴图请勿用于商业用途。

     1 package
     2 {
     3     import away3d.containers.ObjectContainer3D;
     4     import away3d.controllers.FirstPersonController;
     5     import away3d.controllers.HoverController;
     6     import away3d.controllers.LookAtController;
     7     import away3d.events.AssetEvent;
     8     import away3d.loaders.Loader3D;
     9     import away3d.loaders.parsers.Max3DSParser;
    10     import template.AwayTemplate;
    11     import flash.events.Event;
    12     import flash.events.KeyboardEvent;
    13     import flash.events.MouseEvent;
    14     import flash.geom.Vector3D;
    15     import flash.net.URLRequest;
    16     import flash.ui.Keyboard;
    17     public class ModelLoaderTest extends AwayTemplate
    18     {
    19         private var loader:Loader3D;
    20         private var controler:HoverController;
    21         private var step:Number=5;
    22         //private var placeHolder:ObjectContainer3D;
    23         private var stageMouseX:Number;
    24         private var stageMouseY:Number;
    25         public function ModelLoaderTest()
    26         {
    27             super();
    28         }
    29         override protected function init(e:Event=null):void
    30         {
    31             super.init(e);
    32             _view.camera.y = 500;
    33             loader = new Loader3D();
    34             Loader3D.enableParser(Max3DSParser);
    35             loader.addEventListener(AssetEvent.ASSET_COMPLETE, onAssetComplete);
    36             loader.load(new URLRequest("assets/hero.3ds"));
    37             loader.scale(10);
    38             _view.scene.addChild(loader);
    39             //placeHolder = new ObjectContainer3D();
    40             //placeHolder.y = 100;
    41             //placeHolder.x = - 100;
    42             //_view.camera.addChild(placeHolder);
    43             controler = new HoverController(_view.camera);
    44             initEvents();
    45         }
    46         private function initEvents():void
    47         {
    48             stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
    49             stage.addEventListener(MouseEvent.MOUSE_WHEEL, onWheel);
    50         }
    51         private function mouseDown(e:MouseEvent):void
    52         {
    53             stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
    54             stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
    55             stageMouseX = stage.mouseX;
    56             stageMouseY = stage.mouseY;
    57         }
    58         private function onWheel(e:MouseEvent):void
    59         {
    60             controler.distance *= (1+e.delta/100); 
    61         }
    62         private function mouseUp(e:MouseEvent):void
    63         {
    64             stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUp);
    65             stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
    66             var deltaX:Number = stage.mouseX - stageMouseX;
    67             var deltaY:Number = stage.mouseY - stageMouseY;
    68             controler.panAngle = 0.5*deltaX+controler.panAngle;
    69             controler.tiltAngle = 0.5*deltaY+controler.tiltAngle;
    70         }
    71         private function onAssetComplete(e:AssetEvent):void
    72         {
    73         }
    74         override protected function onEnter(e:Event):void
    75         {
    76             super.onEnter(e);
    77         }
    78     }
    79 }

    加载模型类型: 

     Loader3D.enableParser(Max3DSParser);

    详解:

    HoverController;
    LookAtController;

    提供模型和贴图:

    模型:下载

  • 相关阅读:
    Gray Code
    Search a 2D Matrix
    Find Minimum in Rotated Sorted Array
    Feign理解
    Ribbon描述
    eureka自定义instance Id
    eureka开启用户认证
    idea创建Eureka consumer入门实例
    eureka描述
    activeMq的安全机制
  • 原文地址:https://www.cnblogs.com/bulolo/p/2710675.html
Copyright © 2020-2023  润新知