import { LoaderEvent , Vector3D , AssetLibrary , IAsset , URLRequest , RequestAnimationFrame , Loader , Transform } from "@awayjs/core" ; import { BitmapImage2D , Image2DParser , ImageCubeParser , TextureAtlasParser } from "@awayjs/stage" ; import { ElementsType } from "@awayjs/graphics" ; import { BasicMaterial , ImageTexture2D } from "@awayjs/materials" ; import { Scene , Sprite , PrimitivePlanePrefab , DisplayObjectContainer } from "@awayjs/scene" ; import { View , BasicPartition } from "@awayjs/view" ; import { RenderGroup , RendererType , RendererBase } from "@awayjs/renderer" ; class Basic_View { private _view : View ; private _renderer : RendererBase ; private _root : DisplayObjectContainer ; private _planeMaterial : BasicMaterial ; private _plane : Sprite ; private _timer : RequestAnimationFrame ; /**
     * Constructor
     */ constructor ( ) { this . _view = new View ( ) ; this . _root = new DisplayObjectContainer ( ) ; this . _renderer = RenderGroup . getInstance ( this . _view , RendererType . DEFAULT ) . getRenderer ( new BasicPartition ( this . _root ) ) ; this . _root . partition = this . _renderer . partition ; this . _view . projection . transform = new Transform ( ) ; this . _view . projection . transform . moveTo ( 0 , 500 , - 600 ) ; this . _view . projection . transform . lookAt ( new Vector3D ( ) ) ; this . _planeMaterial = new BasicMaterial ( ) ; this . _plane = < Sprite > new PrimitivePlanePrefab ( this . _planeMaterial , ElementsType . TRIANGLE , 700 , 700 ) . getNewObject ( ) ; this . _root . addChild ( this . _plane ) ; window . onresize = ( event ) => this . onResize ( event ) ; this . onResize ( ) ; this . _timer = new RequestAnimationFrame ( this . onEnterFrame , this ) ; this . _timer . start ( ) ; AssetLibrary . addEventListener ( LoaderEvent . LOAD_COMPLETE , ( event ) => this . onResourceComplete ( event ) ) ; AssetLibrary . load ( new URLRequest ( "assets/floor_diffuse.jpg" ) ) ; } /**
     * render loop
     */ private onEnterFrame ( dt ) { this . _plane . rotationY += 1 ; this . _renderer . render ( ) ; } /**
     * Listener function for resource complete event on asset library
     */ private onResourceComplete ( event ) { var assets = event . assets ; var length = assets . length ; for ( var c = 0 ; c < length ; c ++ ) { var asset = assets [ c ] ; console . log ( asset . name , event . url ) ; switch ( event . url ) { case "assets/floor_diffuse.jpg" : this . _planeMaterial . texture = new ImageTexture2D ( < BitmapImage2D > asset ) ; break ; } } } /**
     * stage listener for resize events
     */ private onResize ( event = null ) { this . _view . y = 0 ; this . _view . x = 0 ; this . _view . width = window . innerWidth ; this . _view . height = window . innerHeight ; } } window . onload = function ( ) { new Basic_View ( ) ; } ;