Ok nevermind... I started over again and now it seems to work :P

On Jan 11, 9:35 am, Mech7 <[email protected]> wrote:
> I don't understand this.. If I dont add any camera movepivot seems to
> work normally... but when I add the hovercam it rotates the object?
>
> page.movePivot(-(page.width / 2),0,0);
>
> Complete source..
>
> package
> {
>         import away3d.cameras.HoverCamera3D;
>         import away3d.cameras.TargetCamera3D;
>         import away3d.core.utils.Cast;
>         import away3d.containers.View3D;
>         import away3d.core.base.Vertex;
>         import away3d.materials.WireColorMaterial;
>         import away3d.materials.BitmapMaterial;
>         import away3d.primitives.Plane;
>         import away3d.events.MouseEvent3D;
>
>         import com.as3dmod.ModifierStack;
>         import com.as3dmod.modifiers.Bend;
>         import com.as3dmod.modifiers.Perlin;
>         import com.as3dmod.plugins.away3d.LibraryAway3d;
>         import com.as3dmod.util.ModConstant;
>
>         import flash.display.Bitmap;
>         import flash.display.Sprite;
>         import flash.display.StageAlign;
>         import flash.display.StageQuality;
>         import flash.display.StageScaleMode;
>         import flash.display.Bitmap;
>         import flash.events.Event;
>         import flash.events.MouseEvent;
>
>         import caurina.transitions.Tweener;
>
>         /**
>          * ...
>          * @author Chris de Kok
>          */
>         [SWF(width="800", height="600", frameRate="30",
> backgroundColor="#FFFFFF")]
>         public class Main extends Sprite
>         {
>                 private var view:View3D;
>                 private var cam:HoverCamera3D;
>                 private var page:Plane;
>                 private var mstack:ModifierStack;
>                 private var bend:Bend;
>
>                 [Embed (source="assets/front.jpg")]
>                 private var FrontMaterialJPG:Class;
>                 private var frontMaterial:BitmapMaterial;
>
>                 [Embed (source="assets/back.jpg")]
>                 private var BackMaterialJPG:Class;
>                 private var backMaterial:BitmapMaterial;
>
>                 public function Main():void
>                 {
>                         if (stage) init();
>                         else addEventListener(Event.ADDED_TO_STAGE, init);
>                 }
>
>                 private function init(e:Event = null):void
>                 {
>                         removeEventListener(Event.ADDED_TO_STAGE, init);
>                         // entry point
>
>                         //Configure stage
>                         stage.quality = StageQuality.HIGH;
>                         stage.align = StageAlign.TOP_LEFT;
>                         stage.scaleMode = StageScaleMode.NO_SCALE;
>
>                         // create a basic camera
>                         cam = new HoverCamera3D();
>                         cam.z = 0; // make sure it's positioned away from the 
> default 0,0,0
> coordinate
>                         cam.panangle = 0;
>                         cam.tiltangle = 0;
>                         cam.targetpanangle = 0;
>                         cam.targettiltangle = 0;
>                         cam.mintiltangle = -90;
>
>                         // Create the view
>                         view = new View3D({camera:cam});
>                         view.x = (stage.stageWidth / 2);
>                         view.y = (stage.stageHeight / 2);
>
>                         addChild(view);
>
>                         // Setup everything
>                         initObjects();
>                         initListeners();
>                 }
>
>                 private function initListeners():void {
>                         this.addEventListener(Event.ENTER_FRAME, render);
>                         page.addEventListener(MouseEvent3D.MOUSE_DOWN, 
> turnPage);
>                 }
>
>                 private function initObjects():void {
>                         // Material
>                         var mat:WireColorMaterial = new WireColorMaterial();
>                         mat.color = 0xFFFFFF;
>                         mat.wirecolor = 0x000000;
>                         frontMaterial = new 
> BitmapMaterial(Cast.bitmap(FrontMaterialJPG));
>                         backMaterial = new 
> BitmapMaterial(Cast.bitmap(BackMaterialJPG));
>
>                         // Create the page
>                         page = new Plane();
>                         page.width = 200;
>                         page.height = 300;
>                         page.material = frontMaterial
>                         page.back = backMaterial;
>                         page.bothsides = true;
>                         page.segmentsH = 6;
>                         page.segmentsW = 6;
>                         //page.rotationX = 90;
>
>                         view.scene.addChild(page);
>
>                         cam.target = page;
>
>                         mstack = new ModifierStack(new LibraryAway3d(), page);
>                 }
>
>                 private function render(event:Event):void {
>                         mstack.apply();
>                         view.render();
>                 }
>
>                 private function dragPage(event:MouseEvent3D):void {
>                         trace(event);
>                 }
>
>                 private function turnPage(event:MouseEvent3D):void {
>
>                         if (Tweener.isTweening(page) == false) {
>                                 bend = new Bend(-2, 0, 1.5707963);
>                                 bend.constraint = ModConstant.RIGHT;
>                                 mstack.addModifier(bend);
>
>                                 if (page.rotationZ == 180) {
>                                         page.rotationZ = 0;
>                                 }
>                                 Tweener.addTween(page, { rotationZ:180, 
> time:2,
> transition:'easeInOutSine' } );
>                                 Tweener.addTween(bend, { force: 0, angle:0, 
> time:2,
> transition:'easeInOutSine' } );
>
>                         }
>                 }
>
>         }
>
>
>
> }

Reply via email to