Hello,
Firstly, thanks guys for being such a wonderful, hard-working team. I
have what I believe to be an ultra-simple conundrum.
I would like to change the material of a Loader3D asset. I'm stumped!
Using the most recent GIT version of away3d 4 broomstick, I am
successfully loading an embedded mesh into my scene and it properly
parses and triggers a LoaderEvent.RESOURCE_COMPLETE event. No errors:
it parses perfectly. It renders just fine in my scene, by the way -
just with a black and white checkered default material.
This object has zero for the numChildren property and so I cannot use:
private function onResourceRetrieved_tree(e:LoaderEvent) : void
{
for (var i : int = 0; i < tree1.numChildren; ++i) // has no
children!
{
mesh = Mesh(tree1.getChildAt(i));
mesh.material = treematerial;
}
}
I also cannot seem to cast a Loader3D to be a Mesh nor does it have a
material property, so neither of these two attempts works if added to
the above function:
Mesh(tree1).material = treematerial;
ObjectContainer3D(tree1).material = treematerial;
Just to help, here's the code that loads this tree mesh. I've tried
both 3ds and obj.
tree1 = new Loader3D(false);
tree1.addEventListener(LoaderEvent.LOAD_ERROR,
onResourceLoadingError_tree);
tree1.addEventListener(LoaderEvent.RESOURCE_COMPLETE,
onResourceRetrieved_tree);
tree1.parseData(new treedata(), new OBJParser(),new
AssetLoaderContext(false),null);
view.scene.addChild(tree1);
treematerial = new BitmapMaterial(new treeimage().bitmapData,true);
treematerial.lights = [mylight];
treematerial.ambientColor = 0x777777;
// I also tried AssetLoaderContext and mapUrlToData with no errors but
nothing happens.
This stuff really shouldn't be so hard. =( I feel pretty stupid
wasting 4 hours on this. Oh model loader code, why art thou so
complex and counterintuitive? I sure would like Loader3D.material =
to just automagically work.
I would be most grateful for any hints on setting the material of a
completely embedded model file that has no children meshes but renders
just fine. What prop lets me access the mesh in this case?
What I really want is a way to either cast Loader3D to Mesh or
ObjectContainer3D, or some way to change the material of a Loader3D
object.
THANK YOU VERY MUCH! I'm really grateful for any help.