下面我故意制作了一个测试脚本:你可以在www.parele.com/plane.html看到它 所有源代码都在下面,我试图做的是改变我的网格...请注意:我想要将我的模型网格的材质更改为另一种颜色,任何颜色都不会创建新的平面,因为此示例是一个示例来测试这不是我的实际爱好项目,任何文件或信息需要我很乐意提供..我已经在这里停留了整整20多个小时,它杀了我
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.containers.ObjectContainer3D;
import away3d.debug.AwayStats;
import away3d.entities.Mesh;
import away3d.containers.ObjectContainer3D;
import away3d.loaders.Loader3D;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import away3d.*;
import away3d.materials.ColorMaterial;
import away3d.materials.TextureMaterial;
import away3d.textures.BitmapTexture;
import sunag.animation.AnimationTarget;
import sunag.events.SEAEvent;
import sunag.sea3d.SEA3D;
import away3d.materials.methods.*;
import away3d.primitives.*;
import away3d.textures.*;
import away3d.utils.*;
import away3d.events.*;
[SWF(width = "955",height = "600",frameRate = "50")]
var view:View3D;
var scene:Scene3D;
var sea3d:SEA3D;
var _container:ObjectContainer3D = new ObjectContainer3D();
[Embed(source = "Models/plane.sea",mimeType = "application/octet-stream")]
var homepage:Class;
stage.stageFocusRect = false;
stage.showDefaultContextMenu = false;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
scene = new Scene3D();
view = new View3D(scene);
view.backgroundColor = stage.color;
view.antiAlias = 4;
var dat:BitmapData = new BitmapData(256, 256, false, WHATEVERCOLOUR);
var mMaterial = new TextureMaterial(new BitmapTexture(dat));
scene.addChild(_container);
addChild(view);
sea3d = new SEA3D();
view.blendMode = BlendMode.NORMAL;
sea3d.addEventListener(SEAEvent.COMPLETE, onComplete);
sea3d.loadBytes(new homepage());
function onEnterFrame(e:Event):void
{
var body1:Mesh = sea3d.getMesh("body");
body1.material = mMaterial;
view.render();
}
function onComplete(e:SEAEvent):void
{
view.camera = sea3d.getCamera("Camera001");
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
scene.addChild(sea3d.container);
}
答案 0 :(得分:1)
我相信这就是您所寻找的:SubMeshes
从模型中提取的网格通常至少由SubMesh构成,但可以包含多个网格。更改“根”网格对象上的材质不会传播到其子网格。您需要遍历其SubMeshes并更改其材质。
第h。