Away3D (4.x Broomstick) - 如何设置加载 3DS 文件的材质的 Alpha?

发布于 2024-12-02 09:53:39 字数 762 浏览 1 评论 0原文

我已经使用 3DS 解析器加载了一个模型,该解析器已经链接到材质并且加载良好。我想让这个模型在部分时间但不是所有时间都是半透明的。我想只设置 alpha = .5,但是当我瞄准材料时,这不是一个选项。

这是代码和使用:

        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;

我尝试过

mesh.material.alpha = .5

但没有运气。有什么想法吗?

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 model 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初雪 2024-12-09 09:53:39

我想通了。我瞄准了加载网格的 BitmapMaterial 并从那里进行了修改。

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;

        });

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;

        });
荒路情人 2024-12-09 09:53:39

尝试一下:

var mesh:Mesh = [the mesh for changing]
for each (var item:SubMesh in mesh.subMeshes) {
item.material = null;
}
mesh.material = new ColorMaterial(0xFF00FF, ALPHA); 

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); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文