views:

240

answers:

2

I am having some trouble getting an interactive, animated plane created from a MovieClip in the Library to show any kind of animation or receive any mouse events.

Specifically, I am having issues with the different states of Button instances in the MovieClip.

Here's the basic code that I am testing with:

 private function init3D():void
 {
  viewport = new Viewport3D(1024, 768, false, true);
  addChild(viewport);

  camera = new Camera3D();
  camera.z = -500;
  camera.zoom = 1;
  camera.focus = 500;
  camera.target = DisplayObject3D.ZERO;

  scene = new Scene3D();
  renderer = new BasicRenderEngine();

  stage.addEventListener(Event.ENTER_FRAME, loop);
 }

 public function addChild3D(link:String):Plane
 {
  //var demoPlane:DemoPlane = new DemoPlane(link);
  //return scene.addChild(demoPlane.getPlane());

  var material:MovieAssetMaterial = new MovieAssetMaterial(link, false, true, false, false);
  material.interactive = true;
  //material.smooth = true;
  material.animated = true;

  var plane_mc:Plane = new Plane(material, 0, 0, 10, 10);
  scene.addChild(plane_mc);

 }

 private function loop(evt:Event):void
 {
  renderer.renderScene(scene, camera, viewport);
 }
A: 

I have just tried you code

package{

    import org.papervision3d.*;
    import org.papervision3d.view.*;
    import org.papervision3d.cameras.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.scenes.*;
    import org.papervision3d.render.*;

    import flash.display.*;
    import flash.events.*;

    public class PV3DPlane extends MovieClip{

     private var viewport:Viewport3D;
     private var camera:Camera3D;
     private var scene:Scene3D;
     private var renderer:BasicRenderEngine;
     private var plane:Plane;

     public function PV3DPlane(){
      init3D();
     }

     private function init3D():void
        {
                viewport = new Viewport3D(1024, 768, false, true);
                addChild(viewport);

                camera = new Camera3D();
                camera.z = -500;
                camera.zoom = 1;
                camera.focus = 500;
                camera.target = DisplayObject3D.ZERO;

                scene = new Scene3D();
                renderer = new BasicRenderEngine();


       plane = addChild3D('asset');

                stage.addEventListener(Event.ENTER_FRAME, loop);
        }

        public function addChild3D(link:String):Plane
        {
                var material:MovieAssetMaterial = new MovieAssetMaterial(link, false, true, false, false);
                material.interactive = true;
                //material.smooth = true;
                material.animated = true;
       material.doubleSided = true;

                var plane_mc:Plane = new Plane(material, 0, 0, 10, 10);
                scene.addChild(plane_mc);
       return plane_mc;
        }

        private function loop(evt:Event):void
        {
       plane.rotationY++;
                renderer.renderScene(scene, camera, viewport);
        }
    }
}

I works fine for me...I just created a dummy clip named button and added:

button.addEventListener('click', function(){trace('click')});

I get the trace, all works fine. What papervision build are you using ? On this machine I have an older one Papervision3D Public Beta 2.0 - Great White (20.08.25)

here is the fla and the as file I used.

George Profenza
I think the problem is that I am trying to use SimpleButtons and those aren't supported by PV3D.
Jeremy White
A: 

Update VirtualMouse class with patch to handle SimpleButton

http://code.google.com/p/papervision3d/issues/detail?id=169

Jeremy White