Scaling a CubeGeometry without scaling its repeating TextureMaterial

Software: Away3D 4.x

Greeper, Newbie
Posted: 25 April 2013 01:43 AM   Total Posts: 3

I am building a small 3D-application where the user can scale a cube, which has a TextureMaterial applied, to any size.
Its a wall with a wood-like texture. But when the wall is scaled, the texture is scaling with the size of the CubeGeometry. But i like the texture to keep its original dimensions and just repeat on the surface when the size of the cube is beeing changed.


My question is:
Is there a build in way in away3d 4 which i can use to prevent the texturematerial from being scaled with its mesh? - and how?
... or do i have to scale the material down, as the mesh is being scaled up and how would i do that?


The Code looks like this:

[Embed(source="assets/wood_texture_01.png")]
private var Texture_01:Class;
  
var 
texture1:Texture2DBase = new BitmapTexture(new Texture_01().bitmapData);
var 
cubeMaterial:TextureMaterial = new TextureMaterial(texture1truetruetrue);
var 
wall:CubeGeometry = new CubeGeometry(10010010);
var 
newMesh:Mesh = new Mesh(wallcubeMaterial); 


thanks for your help in advance

 

   

Avatar
Fabrice Closier, Administrator
Posted: 25 April 2013 07:25 AM   Total Posts: 1265   [ # 1 ]

set the material repeat to true and scaleUVs the geometry accordingly.

   

Greeper, Newbie
Posted: 25 April 2013 09:35 AM   Total Posts: 3   [ # 2 ]

... and how would i do that? I can’t find an example or tutorial for using scaleUVs : (

   

Avatar
Fabrice Closier, Administrator
Posted: 25 April 2013 09:54 AM   Total Posts: 1265   [ # 3 ]

Reusing your example code:

the material
—> cubeMaterial.repeat = true;

the geometry
—> newMesh.geometry.scaleUV(2,2);

in your code all you have to do is calculate the ratio current scaleX, Y with the original/ideal ratio X, Y. if you says that at 1000x1000 the map is to be projected 1 on 1. then if the model would become 500x500, you would need to pass .5, .5.

You can use Prefab to see how it works. Just make a primitive or load a model. Open in mesh panel the mesh detail, change the u and v scalefactors.
and of course:  http://www.away3d.com/documentation

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X