I instantiated my camera in Game View, and I put variables such as
_camX, _camMode, etc, in Game Model.
Game View and Game Model were instantiated only once.
// this is my Game View
public class GameMediator extends Mediator implements IMediator
{
override public function onRegister():void
{
_gameProxy = (facade.retrieveProxy(GameProxy.NAME) as
GameProxy); //
get Game Model
_gameView = new GameView();
(viewComponent as Sprite).addChild(_gameView);
_away3DView = new ThreeDimentionView( (facade as
Game).config.STAGE_WIDTH,
(facade as Game).config.STAGE_HEIGHT);
_gameView.ingameLayer.addChild(_away3DView.view3D);
_away3DView.view3D.camera = new HoverCam(); // <<--- the camera
_away3DView.view3D.camera.target = new Cube();
_away3DView.view3D.camera.target.visible = false;
_away3DView.view3D.camera.target.x = _gameProxy.camX;
_away3DView.view3D.camera.target.y = _gameProxy.camY;
_away3DView.view3D.camera.target.z = _gameProxy.camZ;
(viewComponent as Sprite).addEventListener(Event.ENTER_FRAME,
update);
(viewComponent as
Sprite).stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
(viewComponent as
Sprite).stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
}
public function update(e:Event):void
{
if (_away3DView != null)
{
(_away3DView.view3D.camera.camera as HoverCam).hover();
_away3DView.view3D.render();
}
}
}
On Sep 6, 11:20 am, dp <[email protected]> wrote:
> Hi, that's good to hear.
>
> Well I know away3D works flawlessly for what I'm doing, since my
> original non design patterned projects work fine.
>
> Its only now since I've started with a very basic MVC structure. In
> the example I'm working with right now - basically the Frustum hotel
> room demo which now runs slowly.
>
> I guess one thing I'm not sure about is where do I instantiate the
> camera? in the model? and then reference this camera in the view and
> controller? or do I just store all the variables here such as
> _camX:Number? and initiate the camera only in the view?
>
> On Sep 5, 2:40 pm, Aji Pamungkas <[email protected]> wrote:
>
> > Hello dp, i'm using PureMVC. I'm doing the same things like you do,
> > but i don't have any problem with the performance.
> > I put all the data in Model parts, and I put all the view components
> > in View parts.
>
> > Usually, the performance will decrease because of too many polygons in
> > one screen that need to be rendered.
> > But... I also find out that, when I use Chrome and set camera lens to
> > PerspectiveLens, I will get 2 fps. But when i'm using Firefox or Flash
> > Player in desktop, I will get 22 fps, approximately to render 2000
> > polygons.
> > So... I just set my camera lens to the other lens in Away3D, and
> > everything works good. :D
>
> > On Sep 5, 2:46 pm, dp <[email protected]> wrote:
>
> > > I'm trying to improve my coding skills by implementing an MVC pattern
> > > for a simple 3D app I have made. I have the basics working, but have
> > > noticed a major performance decrease.
>
> > > Currently I have the controller handling the user input and computing
> > > all the camera parameters, then updates these values in the model,
> > > which notifys the view, which in turn requests the new data and
> > > renders the scene.
>
> > > am i going about this the wrong way? should all of this be kept in the
> > > view for performance reasons? any general pointers greatly
> > > appreciated. thanks.