I’ve been trying to load a .3DS model into an Away3D 4 project, but I am not able to load the texture from the model itself. I’ve seen a few posts regarding AssetLibrary, but those approaches have not worked for me. I’m able to load the .3DS model using the code below, but the model appears with a green color texture.
_loader = new Loader3D();
_loader.addEventListener(AssetEvent.ASSET_COMPLETE, onAssetComplete);
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
_loader.load(new URLRequest('assets/skeleton.3DS'));
private function onAssetComplete(event:AssetEvent): void {
var newMaterial:ColorMaterial = new ColorMaterial(0xFF000);
var mesh:Mesh = event.asset as Mesh;
mesh.material = newMaterial;
mesh.scale(.25);
mesh.rotationY = 90;
}
private function onResourceComplete(ev:LoaderEvent): void {
view.scene.addChild(_loader);
}
I’ve also tried something like the code below within the onAssetComplete function, but I get a “Bad Input” error and a “A texture is bound on sampler 0 but not used by the fragment program.” error.
if (event.asset.assetType == AssetType.MESH) {
mesh = Mesh(event.asset);
//mesh.material = newMaterial;
mesh.scale(3);
mesh.rotationY = 90;
view.scene.addChild(mesh);
}
else if(event.asset.assetType == AssetType.MATERIAL) {
mat = ColorMaterial(event.asset);
//mesh.material = mat;
}
Any ideas?