4

I am having trouble getting a BitmapTexture to tile, or, as another option, getting it to stretch. In both cases, the goal is to cover a mesh....

For example, a material and cylinder are created like this (assume preExistingBitmapData is a valid BitmapData):

poleMaterial = new TextureMaterial(new BitmapTexture(preExistingBitmapData),true, true);
poleMaterial.repeat = true;
poleMaterial.animateUVs = true;

var cG:CylinderGeometry = new CylinderGeometry(10, 10, 400);
var mesh:Mesh = new Mesh(cG, poleMaterial);

cG.topClosed = true;
cG.scaleUV(1, 2);

addChild(mesh); 

the .scaleUV part and .animateUVs are just a guess to try and fix the problem…

Any idea how to make the bitmap tile? When I leave out the scaleUV, it shows it once. when I put in the scaleUV(1,2) it does sort of tile, but at half the height and with gaps in between.

I just want it to tile smoothly. I can recreate the texture if necessary (right now it’s 64x64, but that’s arbitrary)

It also needs to tile smoothly even if the cylinderGeometry will change in height (this can happen as part of the game)

Same applies to stretching of course.

Thanks!

davidkomer
  • 3,020
  • 2
  • 23
  • 58

1 Answers1

0

You're close:

var plane = new Mesh(new PlaneGeometry(3000,3000,30,30),new         TextureMaterial(Cast.bitmapTexture(groundMaterial)));
plane.geometry.scaleUV(25, 25);  //  tiles my material of grass image 25x25
plane.material.repeat = true;   //repeats the my material
scene.addchild( plane );

Let me know if you have problems :) To add everytime you want to change the scale of the materials tiling/stretching re-add the material again to the object with its new properties.

Marty
  • 39,033
  • 19
  • 93
  • 162
joshua
  • 676
  • 1
  • 5
  • 19
  • Giving you the bonus since you're the only one who answered :) Truth is at the end, the problem was my texture- it wasn't exporting as a clean power of 2 from flash, so there were black pixels to fill the gap ;) – davidkomer Aug 29 '13 at 15:39
  • lol, it hurts when it was a simple solution, Away3d documentation could improve a little, i find tutorials and info always out dated or information like you experienced missing... – joshua Aug 29 '13 at 16:08