0 Replies Latest reply on Nov 19, 2009 11:35 AM by AdamDixon

    Papervision3D and Flash

    AdamDixon

      I have just started creating a basic papervision3D application, using its predefined class files and some basic AS3, that displays a sphere with a Earth texture mapped to it. I added some code to control the rotation of the camera so that the sphere has the illusion of rotating. But as it is the camera that is moving the sphere is made larger and smaller when the camera moves which is not what i want.

       

      What I think it is doing is, instead of rotating the sphere, it is keeping that static and moving the camera in and out of the z-axis so that the sphere looks as thought it is getting smaller and larger rather than simply rotating.

       

      I have tried altering the code so that it doesn't but nothing i do seems to stop the sphere from resizing. I was wondering if anyone has had the same problem and if so how did they fix it. Below is the code i have used and everything else is just the papervision3D classes and I have attached the .fla file and the jpg I used as the texture.

       

      import org.papervision3d.scenes.*;
      import org.papervision3d.cameras.*;
      import org.papervision3d.objects.*;
      import org.papervision3d.materials.*;

      var container:Sprite = new Sprite();
      container.x = stage.stageWidth * 0.5;

      container.y = stage.stageHeight * 0.5;

      addChild(container);

      var scene:Scene3D = new Scene3D(container);
      var camera:Camera3D = new Camera3D();
      camera.zoom = 5;

      var bam:BitmapAssetMaterial = new BitmapAssetMaterial("FlashIcon");
      bam.oneSide = false;
      bam.smooth = true

      for(var i:uint=0; i<1; i++)
      {
          var p:Sphere = new Sphere(bam, 750, 32, 32);
          scene.addChild(p);
          //p.x = Math.random() * 1000 - 500;
          //p.y = Math.random() * 1000 - 500;
          //p.z = Math.random() * 1000 - 500;
          //p.rotationY = Math.random() * 360;
      }

      this.addEventListener(Event.ENTER_FRAME, render);
      function render(e:Event):void
      {
          camera.x += stage.mouseX - (stage.stageWidth * 0.5);
          camera.y += stage.mouseY - (stage.stageHeight * 0.5);
          scene.renderCamera(camera);
      }