Okay, I've spend quite some time to figure it out and came up with
nothing.

Once I load 3ds model, I can't add it to the scene. It seems only if I
add it before it loads, it works fine.
But I'd like to load models first, then let the user add them to the
scene.

Here's a source code, no errors appear.

package
{
        import away3d.cameras.HoverCamera3D;
        import away3d.containers.View3D;
        import away3d.events.Loader3DEvent;
        import away3d.loaders.Loader3D;
        import away3d.loaders.Max3DS;
        import flash.events.Event;
        import flash.events.MouseEvent;

        public class Main extends Sprite
        {


                private var view:View3D;
                private var camera:HoverCamera3D;
                private var model:Loader3D;

                public function Main():void
                {
                        if (stage) init();
                        else addEventListener(Event.ADDED_TO_STAGE, init);
                }

                private function init(e:Event = null):void
                {

                        view = new View3D();
                        addChild(view);

                        model = new Loader3D();
                        model.addEventListener(Loader3DEvent.LOAD_SUCCESS, 
onSuccess);
                        model.loadGeometry("./male_drzewko.3ds", new Max3DS());
                        view.scene.addChild(model);

                        camera = new HoverCamera3D({distance:2000, 
tiltAngle:10, steps:2});
                        view.camera = camera;

                        this.addEventListener(Event.ENTER_FRAME, rendering);
                        stage.addEventListener(MouseEvent.MOUSE_DOWN, click);
                }

                private function click(e:MouseEvent):void
                {
                                          // this part is not working:
(
                        view.scene.addChild(model);
                        var m = model.clone();
                        m.x = Math.random() * 500;
                        view.scene.addChild(m);
                }

                private function onSuccess(e:Loader3DEvent):void
                {
                        //
                }

                private function rendering(e:Event):void
                {
                        view.render();
                        camera.panAngle += 5;
                }

        }

}

Reply via email to