Не могу загрузить текстуру в Away3d мож кто имел с ним дело. выходит так Code: package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.geom.Vector3D; import flash.net.URLRequest; import flash.text.TextField; import away3d.cameras.Camera3D; import away3d.cameras.lenses.PerspectiveLens; import away3d.containers.View3D; import away3d.entities.Mesh; import away3d.events.LoaderEvent; import away3d.loaders.Loader3D; import away3d.loaders.parsers.Parsers; import away3d.materials.ColorMaterial; import away3d.materials.TextureMaterial; import away3d.materials.methods.EnvMapMethod; import away3d.primitives.CubeGeometry; import away3d.primitives.PlaneGeometry; import away3d.primitives.SkyBox; import away3d.primitives.SphereGeometry; import away3d.primitives.TorusGeometry; import away3d.textures.BitmapCubeTexture; import away3d.textures.BitmapTexture; import away3d.utils.Cast; [SWF(backgroundColor="#000000", frameRate="60", width="500", height="468")] public class Begin2 extends Sprite { private var _view:View3D; private var _skyBox:SkyBox; private var loader:Loader ; private var img:Bitmap; private var material:TextureMaterial; private var text:TextField; public function Begin2() { //stage.scaleMode = StageScaleMode.NO_SCALE; //stage.align = StageAlign.TOP_LEFT; _view = new View3D(); addChild(_view); text = new TextField(); text.backgroundColor = 0xffffff; stage.addChild(text); //setup the camera _view.camera.z = -600; _view.camera.y = 0; _view.camera.lookAt(new Vector3D()); //_view.camera.lens = new PerspectiveLens(90); //stage.addEventListener(Event.RESIZE, onResize); //onResize(); // var EnvPosX,EnvNegX,EnvPosY,EnvNegY,EnvPosZ,EnvNegZ:BitmapData; loadTexture(); loadModel(); /*var cubeTexture:BitmapCubeTexture = new BitmapCubeTexture(Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvNegX), Cast.bitmapData(EnvPosY), Cast.bitmapData(EnvNegY), Cast.bitmapData(EnvPosZ), Cast.bitmapData(EnvNegZ)); */ } private function loadTexture():void{ loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, TextureLoaded); loader.addEventListener(LoaderEvent.LOAD_ERROR, loadError); loader.load(new URLRequest("snow.jpg")); } protected function loadModel():void { /*Parsers.enableAllBundled(); var cubeTexture:BitmapCubeTexture = new BitmapCubeTexture(Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvPosX)); _skyBox = new SkyBox(cubeTexture); _view.scene.addChild(_skyBox);*/ var shera:CubeGeometry = new CubeGeometry(200,200,200); var mshera:Mesh = new Mesh(shera,material) mshera.rotationY=50; mshera.rotationX=50; mshera.rotationZ=5; _view.scene.addChild(mshera); this.addEventListener(Event.ENTER_FRAME, renders); /*var material:ColorMaterial = new ColorMaterial(); material.addMethod(new EnvMapMethod(cubeTexture, 1)); var torus:Mesh = new Mesh(new TorusGeometry(150, 60, 40, 20), material); _view.scene.addChild(torus);*/ } private function TextureLoaded(event:Event):void{ var bitImg:Bitmap = loader.content as Bitmap; var bit:BitmapTexture = new BitmapTexture(bitImg.bitmapData); text.text ="here how"; material = new TextureMaterial(bit); } private function loadError(evt:LoaderEvent):void { trace('cant load'); //loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETE, TextureLoaded); loader.removeEventListener(LoaderEvent.LOAD_ERROR, loadError); loader = null; } private function renders(e:Event):void { _view.rotationY+=1; _view.render(); } } }
Code: [Embed(source = "snow.jpg")] public static var Snow:Class; var shera:CubeGeometry = new CubeGeometry(200,200,200); material = new TextureMaterial(Cast.bitmapTexture(Snow)); var mshera:Mesh = new Mesh(shera,material) mshera.rotationY=50; mshera.rotationX=50; mshera.rotationZ=5; _view.scene.addChild(mshera); this.addEventListener(Event.ENTER_FRAME, renders); Грузит но надо через загрузку.