Away3d 4.0.9gold learning note Loading Model (6)

Source: Internet
Author: User


Learning notes provide models and textures for commercial purposes.




 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; 8     import away3d.loaders.Loader3D; 9     import away3d.loaders.parsers.Max3DSParser;10     import template.AwayTemplate;11     import;12     import;13     import;14     import flash.geom.Vector3D;15     import;16     import flash.ui.Keyboard;17     public class ModelLoaderTest extends AwayTemplate18     {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):void30         {31             super.init(e);32    = 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             //;43             controler = new HoverController(;44             initEvents();45         }46         private function initEvents():void47         {48             stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);49             stage.addEventListener(MouseEvent.MOUSE_WHEEL, onWheel);50         }51         private function mouseDown(e:MouseEvent):void52         {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):void59         {60             controler.distance *= (; 61         }62         private function mouseUp(e:MouseEvent):void63         {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):void72         {73         }74         override protected function onEnter(e:Event):void75         {76             super.onEnter(e);77         }78     }79 }

Load model type:

Loader3d. enableparser (max3dsparser );








Provide models and textures:


Model: Download



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.