Property bitmapData not found

Software: Away3D 4.x

frogman_pep, Newbie
Posted: 03 July 2012 04:51 AM   Total Posts: 19

Following AFTC’s code for loading an OBJ model I was able to load my own model but couldn’t get the texture on him, and subsequently got the the error: Property bitmapData not found.  Tried to intertwine some code from these two posts 1 & 2, but couldn’t figure it out.

Tried uploading the project to the web with ‘View Source’ enabled but got an error, so here is all the code (figured it’s best to not omitt anything, as I’m still very green with Away3D):

package{
 import away3d
.core.base.SubMesh;
 
import away3d.entities.Mesh;
 
import away3d.events.AssetEvent;
 
import away3d.lights.DirectionalLight;
 
import away3d.loaders.Loader3D;
 
import away3d.loaders.misc.AssetLoaderContext;
 
import away3d.loaders.parsers.Parsers;
 
import away3d.materials.TextureMaterial;
 
import away3d.materials.lightpickers.StaticLightPicker;
 
import away3d.textures.BitmapTexture;
 
 
import com.darcey.debug.Ttrace;
 
import com.darcey.ui.FullScreenButton;
 
 
import flash.display.Sprite;
 
import flash.display.StageAlign;
 
import flash.display.StageScaleMode;
 
import flash.events.Event;
 
 public class 
RictorRotateTextured extends Sprite{
  
  
//Embedded assets
  
  
[Embed(source="/assets/Rictor_Textured06.obj"mimeType="application/octet-stream")]
  
private var RictorModel:Class;
  
  
[Embed(source="/assets/Rictor_Diffuse_map_1.jpg"mimeType="application/octet-stream")]
  
private var assetTexture:Class;
  
  private var 
t:Ttrace;
  private var 
away3DScene:Away3DScene;
  private var 
fullScreenButton:FullScreenButton;
  
  private var 
staticLightPicker:StaticLightPicker;
  private var 
directionalLight:DirectionalLight;
  
  private var 
rictorMaterial:TextureMaterial;
  private var 
loader:Loader3D;
  private var 
rictorMesh:Mesh;
  
  public function 
RictorRotateTextured(){
   
   t 
= new Ttrace(true);
   
t.ttrace("RictorRotateTextured()");
   
   
stage.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
   
   
away3DScene Away3DScene.getInstance();
   
away3DScene.init(truetrue);
   
addChild(away3DScene);
   
   
initScene();
  
}
  
  
private function initScene():void{
   
   t
.ttrace("RictorRotateTextured.initScene()");
   
   
fullScreenButton = new FullScreenButton();
   
addChild(fullScreenButton);
   
   
initLights();
   
initMaterials();
   
init3DObjects();
   
   
stage.addEventListener(Event.RESIZEresizeHandler);
   
   
resizeHandler();
   
   
stage.addEventListener(Event.ENTER_FRAMEenterFrameHandler);   
  
}
  
  
private function initLights():void{
   
   directionalLight 
= new DirectionalLight();
   
   
staticLightPicker = new StaticLightPicker([directionalLight]);
   
   
away3DScene.scene.addChild(directionalLight);
  
}
  
  
private function initMaterials():void{
   
   rictorMaterial 
= new TextureMaterial(new BitmapTexture(new assetTexture().bitmapData));
   
/*var assetLoaderContext:AssetLoaderContext = new AssetLoaderContext();
   assetLoaderContext.mapUrlToData("assets/Rictor_Diffuse_map_1.jpg", new myTexture());*/
   
  
}
  
  
private function init3DObjects():void{
   
   Parsers
.enableAllBundled();
   
   
loader = new Loader3D();
   
loader.scale(300);
   
loader.= -400;
   
   
loader.addEventListener(AssetEvent.ASSET_COMPLETEonModelParseComplete);
   
   
loader.loadData(new RictorModel());
   
   
away3DScene.scene.addChild(loader);
  
}
  
  
private function onModelParseComplete(e:AssetEvent):void{
   
   loader
.removeEventListener(AssetEvent.ASSET_COMPLETEonModelParseComplete);
   
   switch (
String(e.asset.assetType)){
    
    
case "mesh":
     
     
rictorMesh e.asset as Mesh;
     
     for 
each (var m:SubMesh in rictorMesh.subMeshes){
     
      m
.material rictorMaterial;
    
}
     
break;
    
    case 
"material":
     
     var 
textureMaterial:TextureMaterial e.asset as TextureMaterial;
     
textureMaterial.lightPicker staticLightPicker;
     
     break;
    
    default:
     
     
trace("UNHANDLED ASSET TYPE: "  e.asset.assetType);
     
     break;     
   
}
  }
  
  
private function resizeHandler(e:Event=null):void{
   
   fullScreenButton
.stage.stageWidth fullScreenButton.width 5;
   
fullScreenButton.5;
  
}
  
  
private function enterFrameHandler(e:Event):void{
   
   
if (rictorMesh){
    rictorMesh
.rotationY += 1;
   
}
  }
 }
   

frogman_pep, Newbie
Posted: 03 July 2012 09:23 AM   Total Posts: 19   [ # 1 ]

Not sure if it has the same solution, but I tried loading my model in the Basic_LoadOBJ file from the away3d examples and the error showed it was looking for a different texture than Rictor_Diffuse_Map_1, instead Rictor_D which MAX renames it to upon export.

Also the texture dimensions were 4096 x 4096. 

So after using the file names it was looking for and changing the dimension to 2048 x 2048 it worked. 

Haven’t tried in the original file cuz I’m calling it a night on a good note smile

   

Ivan Moreno, Newbie
Posted: 03 July 2012 11:35 AM   Total Posts: 22   [ # 2 ]

Hello!

I believe your problem is related with how you’re embedding the texture. As you show it in your code you have to replace the mimeType=“application/octet-stream” to mimeType=“image/jpeg” in your embed texture class. Currently you’re giving the wrong binary data definition to the bitmap texture class so that’s why it cannot find it.

Also try not to exceed 1024x1024, bigger than that would highly decrease the performance in small computers.

Best.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X