遇到交互式平面问题

时间:2009-08-25 17:48:34

标签: flash actionscript-3 actionscript 3d papervision3d

我在使用库中的MovieClip创建的交互式动画平面时遇到一些麻烦,无法显示任何类型的动画或接收任何鼠标事件。

具体来说,我遇到了MovieClip中Button实例的不同状态的问题。

以下是我正在测试的基本代码:

    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);
    }

2 个答案:

答案 0 :(得分:0)

我刚试过你的代码

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);
        }
    }
}

我的工作正常...我刚刚创建了一个名为 button 的虚拟剪辑并添加了:

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

我得到了痕迹,一切正常。 你使用什么papervision build? 在这台机器上我有一个较旧的机器 Papervision3D Public Beta 2.0 - Great White(20.08.25)

这是我使用的flaas文件。

答案 1 :(得分:0)

使用补丁更新VirtualMouse类以处理SimpleButton

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