【问题标题】:Papervision3D; rotate child objects within camera viewPapervision3D;在相机视图中旋转子对象
【发布时间】:2009-09-04 16:29:36
【问题描述】:

这是我第一次使用 Papervision3D,我创建了一个在 y 轴上倾斜的图像幻灯片。最小的照片在左边,它们的大小向右增加。所以他们从左到右,从小到大缩放。

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

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

谢谢!

【问题讨论】:

    标签: actionscript-3 flex3 papervision3d


    【解决方案1】:

    my_obj = new DisplayObject3D(); my_plane = my_obj.addChild(new Plane(bla bla)); my_obj.lookAt(相机);

    “lookAt”位是您所需要的。

    【讨论】:

    • lookAt,出于某种恼人的原因,使对象看起来 远离 相机(使用带有双面材料的文本对象来了解我的意思)。此外,文本将被绘制到与相机成一定角度的平面上,而不是在平行于平面附近的相机的平面上(这可能是他想要的)。
    【解决方案2】:

    为什么不在 2d 中绘制工具提示?您可以获取图像在屏幕上的位置,然后像这样绘制一个常规 Sprite:

    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 位置,但这可能比计算旋转更容易,并且是获得一致外观结果的最佳方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-04
      • 2018-06-14
      • 2018-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多