Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top