What is the proper way to apply material on loaded obj model?

Obj loads good, everything works OK. I'm loading material this way:

initO:Object = {useGroups:false};
var obj:Obj = new Obj(initO);
obj.material = new BitmapFileMaterial("res/uv.jpg"); //this is the
only one spot where the material can be applied

loader = new Loader3D();
loader.addOnSuccess(onSuccess);
loader.loadGeometry("res/my.obj", obj);

function onSuccess(event:Event):void {

  mesh = loader.handle as Mesh;
  mesh.scale(100);
  mesh.rotationY = 180;

  scene.addChild(mesh);
}

The only place (AFAIK) to apply material on loaded obj file is the var
obj:Obj parser. I tried to change material:

loader.handle.material = new WireframeMaterial(0xff0000);

But it does nothing.


I tried with:
function onSuccess(event:Event):void {
  initO:Object = {useGroups:true};
  var obj:ObjectContainer3D = (event.target.handle as
ObjectContainer3D);
  mesh = obj.children[0] as Mesh;
  mesh.material = new WireframeMaterial(0xff0000);
}

Nothing.


I also have tried this:
var meshfaces = _sceneMesh.faces;
for each (var i:Face in meshfaces.faces) {
        i.material = new ColorMaterial(0xFF00FF);
}

Still nothing.

I always used:

var _objLoader:Object3DLoader = Obj.load(_resourceURL,
{material:_material, name:"OBJ", scaling:10});

But now as I see its obsolete.
I cannot use AWD because client would like to add models on his own.

Regards
Paweł

Reply via email to