I'm having my first go with Away3D and am having great difficulties in simply loading a 3D model at runtime.
I’m using AIR 4.0 and the latest Away3D Library.
The setup seems fine, I can compile without errors!!
I have tried all sorts I have found on the web but I’ll spare u my futile attempts. This is my latest one, what is missing to show the model? It seems to be loading according to the traces, but i can't get it to display!
If it helps I can show what else I’ve tried, but I doubt it will!
package {
//imports ...
public class Main extends MovieClip{
private var view:View3D;
private var scene:Scene3D;
private var cam:Camera3D;
private var _loader:Loader3D;
public function Main() {
trace("Main()");
initAway();
}
private function initAway():void
{
addChild(new AwayStats());
view = new View3D();
scene = new Scene3D();
cam = new Camera3D();
view.scene = scene;
view.camera = cam;
view.camera.lookAt(new Vector3D());
addChild(view);
Parsers.enableAllBundled();
_loader = new Loader3D();
_loader.load(new URLRequest('/assets/test.obj'));
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onSceneResourceComplete);
_loader.addEventListener(AssetEvent.ASSET_COMPLETE, onAssetComplete);
}
private function onAssetComplete(event:AssetEvent):void
{
trace("assetType = " + event.asset.assetType );
/*
OUTPUT:
assetType = geometry
assetType = mesh
assetType = material
assetType = material
*/
}
private function onSceneResourceComplete(event : LoaderEvent) : void {
trace("loaded " + event.currentTarget);
// OUTPUT: loaded [object Loader3D
//view.scene.addChild(_loader); //not working
var container : ObjectContainer3D = ObjectContainer3D(event.target);
view.scene.addChild(container);
}
}
}
In /assets there is a .obj and the coresponding .mtl file