Hey, I have a model that I am exporting from Away Builder and for some reason when I import it to away3d, the texture I made won’t load in. The texture shows up correctly in Away Builder, and material is correct based on the following trace statements:
trace(mesh.material.name); //prints: "MyMaterial"
trace(TextureMaterial(mesh.material).texture.name); //prints "defaultTexture"
I have also selected “embed textures” but with no luck.
Here is the loading code:
Loader3D.enableParser(AWDParser);//allow for awd import
this._roboLoader = new Loader3D(false);
this._roboLoader.addEventListener(AssetEvent.ASSET_COMPLETE, onAssetComplete);
this._roboLoader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
this._roboLoader.load(new URLRequest('Models/Robot/Robot.awd'), new AssetLoaderContext(false));
When asset loading is complete
private function onAssetComplete(ev : AssetEvent) : void
{
if (ev.asset.assetType == AssetType.MESH)
{
var mesh : Mesh;
var texMat : TextureMaterial;
mesh = Mesh(ev.asset);
texMat = mesh.material as TextureMaterial;
trace(mesh.material.name);
trace(TextureMaterial(mesh.material).texture.name);
if (mesh.material == null || (texMat && texMat.texture == null))
mesh.material = new ColorMaterial(Math.random() * 0xffffff);
else
trace("Did not apply Dummy material");
}
}
And when complete:
private function onResourceComplete(ev : LoaderEvent) : void
{
_view.scene.addChild(_roboLoader);
}
Am doing something wrong in Away Builder? If I embed the textures I shouldn’t have to load them separately right? If you need any more info let me know.
Thanks in advance.