I have loaded a model using the 3DS parser that is already linked to a material and loads fine. I would like to make this mode开发者_JS百科l semi-transparent part of the time but not all of the time. I would like to just set alpha = .5 but when I target the materal that is not an option.
Here is the code and using:
var slingPar:Max3DSParser = new Max3DSParser();
var slingLoader:Loader3D = new Loader3D();
sling = new ObjectContainer3D();
slingLoader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, function(e:LoaderEvent):void
{
var mesh:Mesh = Mesh(sling.getChildAt(0));
mesh.material.lights = [light1, light2, light3];
mesh.rotationY = 180;
});
slingLoader.load(new URLRequest("assets/game/slingCup.3DS"),slingPar);
sling = slingLoader;
I tried
mesh.material.alpha = .5
But had no luck. Any Ideas?
I figured it out. I targeted the BitmapMaterial of the loaded mesh and modified from there.
slingLoader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, function(e:LoaderEvent):void
{
var mesh:Mesh = Mesh(sling.getChildAt(0));
var map:BitmapMaterial = mesh.material as BitmapMaterial;
map.ambient = .5;
map.specular = .5;
map.alpha = .8;
map.lights = [light1, light2, light3];
map.repeat = true;
map.smooth = true;
map.bothSides = false;
});
Try it:
var mesh:Mesh = [the mesh for changing]
for each (var item:SubMesh in mesh.subMeshes) {
item.material = null;
}
mesh.material = new ColorMaterial(0xFF00FF, ALPHA);
精彩评论