代码之家  ›  专栏  ›  技术社区  ›  Chuck

papervision3d;在相机视图中旋转子对象

  •  0
  • Chuck  · 技术社区  · 17 年前

    这是我第一次使用PaperVision3D,我制作了一个在Y轴上倾斜的图像幻灯片。左边是最小的照片,右边是增大的。所以它们从左到右,从最小到最大。

    我有一个工具提示,当你悬停在照片上时会弹出,但是工具提示也会与相机视图成比例地倾斜(倾斜)。我希望工具提示的角度独立于整个相机视图。

    知道如何独立于父对象的摄影机角度旋转对象吗?

    谢谢!

    2 回复  |  直到 15 年前
        1
  •  0
  •   user19670    17 年前

    my_obj=new displayobject3d(); my_plane=my_obj.addchild(新飞机(bla bla)); 我的眼睛(摄像机);

    你需要的是“看”的那一点。

        2
  •  0
  •   James Fassett    17 年前

    为什么不在2d中绘制工具提示呢?你可以得到图像的屏幕位置,然后画一个像这样的普通精灵:

    package 
    {
    import flash.display.Sprite;
    import flash.text.TextField;
    
    import org.papervision3d.events.InteractiveScene3DEvent;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.primitives.Plane;
    import org.papervision3d.typography.Text3D;
    import org.papervision3d.view.BasicView;
    
    public class PVTest extends Sprite
    {
        private var world:BasicView;
        private var text:Text3D;
        private var text2d:TextField;
    
        public function PVTest()
        {
            world = new BasicView(stage.width, stage.height, true, true);
    
            var colorMat:ColorMaterial = new ColorMaterial();
            colorMat.interactive = true;
    
            var planeContainer:DisplayObject3D = new DisplayObject3D();
            var plane:Plane;
            for(var i:int = 0; i < 11; i++)
            {
                plane= new Plane(
                    colorMat,
                    100, 100,
                    10);
                plane.x = (i * 105) - 500;
                plane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, handleMouseOver);
                plane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, handleMouseOut);
                planeContainer.addChild(plane);
            }
    
            planeContainer.rotationY = 10;
            world.scene.addChild(planeContainer);
    
            world.camera.z = -500;
    
            addChild(world);
            world.startRendering();
        }
    
        private function handleMouseOver(event:InteractiveScene3DEvent):void
        {
            var plane:Plane = Plane(event.displayObject3D);
            plane.calculateScreenCoords(world.camera);
    
            const OFFSET_X:int = -20;
            const OFFSET_Y:int = 30;
            text2d = new TextField();
            text2d.text = "toolTip";
            text2d.x = plane.screen.x + (stage.width/2) + OFFSET_X;
            text2d.y = plane.screen.y + (stage.height/2) + OFFSET_Y;
            addChild(text2d);
        }
    
        private function handleMouseOut(event:InteractiveScene3DEvent):void
        {
            removeChild(text2d);
        }
    }
    
    }
    

    即使在这个例子中,你也必须 y 工具提示的位置基于对象比例,但它可能比计算旋转更容易,并且是获得一致外观结果的最佳方法。

    推荐文章