Away4 - BitmapTexture

Software: Away3D 4.x

Tempy111, Sr. Member
Posted: 23 August 2016 10:43 AM   Total Posts: 133

Back after being busy for some time, and i’m now (depending on the project) using FlashDevelop so I can use Away3D 4.

But.. i’m not getting the hang of something.. most guides I can find say i’m doing it right.. but it’s not doing it right so.. confused a bit ^_^; some simple error i’m sure.

I’ve created a plane via the mesh->planeGeometry option. When I give it a ColorMaterial, it displays fine, When I give it a TextureMaterial which is casted from an embedded jpg, it doesn’t display any polygons. Debug stats even go from 2 Polys to 0.

since bugger all has been done so far, here is the code (based on one tutorial) i’m using right now:

import away3d
import away3d.entities.*;
import away3d.materials.*;
import away3d.primitives.*;
import away3d.utils.*;
import away3d.debug.AwayStats;
import away3d.textures.*;
import flash.display.*;
import flash.geom.Vector3D;

public class Main extends Sprite
//plane texture
public static var GrassFloor:Class; 
//engine variables
private var _view:View3D;
//scene objects
private var _plane:Mesh;
  public function 
.scaleMode StageScaleMode.NO_SCALE;
stage.align StageAlign.TOP_LEFT;
//setup the view
_view = new View3D();
// add away3d debugger 
addChild(new AwayStats(_view)); 
//setup the camera -200;;// 500; Vector3D());
//setup the scene
   //var material:ColorMaterial = new ColorMaterial(0x009EE1);
var material:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(GrassFloor));
material.bothSides true;
_plane = new Mesh(new PlaneGeometry(200200), material);
//setup the render loop
   * render loop
private function _onEnterFrame(e:Event):void
.rotationY += 1;
   * stage listener for resize events
private function onResize(event:Event null):void
.width stage.stageWidth;
_view.height stage.stageHeight;

the Grass bitmap IS in the correct location, checked by embedded it via the embed code option so that’s all fine.

any idea what stupid thing I’ve done wrong?


Fabrice Closier, Administrator
Posted: 24 August 2016 03:59 PM   Total Posts: 1265   [ # 1 ]

var map:BitmapData = new BitmapData(128,128,0xff000);
var bt:BitmapTexture = new BitmapTexture(map);
var material:TextureMaterial = new TextureMaterial(bt);

if this shows a red plane, you need next to check your map or cast

then adapt your code for the map the “hard” way vs using Cast

private var ImageSRC: Class;

var map:BitmapData = Bitmap(new ImageSRC()).bitmapData;


Tempy111, Sr. Member
Posted: 24 August 2016 06:09 PM   Total Posts: 133   [ # 2 ]

Thanks ^_^

var map:BitmapData = new BitmapData(128,128,false,0xff000);

forgot the transparency Boolean ^_^


Shows .. green? RGB with only red filled in is green? weird..

still.. for some reason, doesn’t want to load..

extra information if useful, the debug stats say ‘DRIV: DirectX1’.. probably no use..

nothing appears wrong with the image file.. changed from png to jpg and same problems both ways… it’s 100x100 so fairly small but should be fine..


Fabrice Closier, Administrator
Posted: 25 August 2016 10:00 AM   Total Posts: 1265   [ # 3 ]

typed too fast, misses a zero for red… 0xFF0000

The prob is now explained in this reply: you say your image is 100x100.
and that’s probably where you forgot to say that you got error messages, assuming you compile in debug mode, that tells you that your image must be power of 2. So resize your image to 128, 256, 512, 1024, 2048. You can use size different per side, like 128x256.


Tempy111, Sr. Member
Posted: 25 August 2016 03:00 PM   Total Posts: 133   [ # 4 ]

bugger… Thanks!

Why do I always forgot power of 2… major blind spot.. works fine afterwords…

I did say it was something stupid ^_^;

I even started to think something to do with the image size but didn’t follow through on that..

Thanks again.. I’m sure something else will come up at some point.



Away3D Forum

Member Login