TextureMaterial not working in Away3D 4 beta

Software: Away3D 4.x

Codeguy, Newbie
Posted: 21 February 2012 09:41 PM   Total Posts: 4

Creating a custom geometry with a color material works fine. But if I create it with a TextureMaterial it gives me this error.

TypeError: Error #2007: Parameter data must be non-null.

Here is the code I am using to create a custom geometry add it to a mesh and then to stage.

var geo:Geometry = new Geometry();
   var 
ioff:uint 0;
   var 
point:Vector3D = new Vector3D(0,0,0);
   var 
half:uint 10;
   var 
vertices:Vector.<Number> =  new Vector.<Number>();
   
vertices[ioff 0] point.half;  vertices[ioff 1] point.half;  vertices[ioff 2] point.half
   
vertices[ioff 3] point.+ -halfvertices[ioff 4] point.half;  vertices[ioff 5] point.half
   
vertices[ioff 6] point.+ -halfvertices[ioff 7] point.+ -halfvertices[ioff 8] point.half
   
vertices[ioff 9] point.half;  vertices[ioff 10] point.+ -halfvertices[ioff 11] point.half;
   var 
uvs:Vector.<Number> = Vector.<Number>([00101101]);
   
// indexes
   
var indexes:Vector.<uint> = Vector.<uint>([0,1,2,0,2,3]);
   var 
sg:SubGeometry = new SubGeometry();
   
sg.updateIndexData(indexes);
   
sg.updateVertexData(vertices);
   
sg.updateVertexNormalData(uvs);
   
   
geo.addSubGeometry(sg);
//   var mat:ColorMaterial = new ColorMaterial(0xFF6600);
   
var mi:MaterialIndex = new MaterialIndex();
   var 
mat:MaterialBase = new TextureMaterial(new BitmapTexture(mi.bitmaps[0]));
   
mat.lightPicker lightPicker;
//   mat.bothSides = true;
   
   
mesh = new Mesh(geomat);
//   mesh.castsShadows = true;
   
scene.addChild(mesh
   

Codeguy, Newbie
Posted: 21 February 2012 11:23 PM   Total Posts: 4   [ # 1 ]

Once I started using PlaneGeometry to generate each plane that I needed separate. Then it started working. So it must be something I am missing with the data I am providing.

   

Avatar
Greg Caldwell (Greg209), Administrator
Posted: 22 February 2012 11:56 AM   Total Posts: 45   [ # 2 ]

Hey,

Looking quickly at your code, it looks like you are making an incorrect method call. You are calling….

  sg.updateVertexNormalData(uvs);

rather than .....

  sg.updateUVData(uvs);

... and so your texture has no UV coordinates to map to.

Hope that’s it. Cheers

Greg209

 Signature 

Home page : http://www.geepers.co.uk
Mobile apps : Sum It All Up

   

Codeguy, Newbie
Posted: 22 February 2012 03:03 PM   Total Posts: 4   [ # 3 ]

Wow. I feel embarrassed. That was it. Thanks

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X