0

カメラを動かしている間、オブジェクトが同じ場所に留まっているように見せたいです。

このスクリプトhttp://pv3d.org/2008/11/19/dragging-mouse-for-camera-orbit/を使用して、マウスのドラッグを使用してオブジェクトを周回します。しかし、静止させておきたいオブジェクトがシーンにあります。これを行うにはどうすればよいですか?

ありがとう、ジョシュ

4

1 に答える 1

2

OK、Papervision で Camera3D ソースを参照しました。軌道の実装は次のとおりです。

            /**
             * Orbits the camera around the specified target. If no target is specified the 
             * camera's #target property is used. If this camera's #target property equals null
             * the camera orbits the origin (0, 0, 0).
             * 
             * @param       pitch   Rotation around X=axis (looking up or down).
             * @param       yaw             Rotation around Y-axis (looking left or right).
             * @param       useDegrees      Whether to use degrees for pitch and yaw (defaults to 'true').
             * @param       target  An optional target to orbit around.
             */ 
            public override function orbit(pitch:Number, yaw:Number, useDegrees:Boolean=true, target:DisplayObject3D=null):void
            {
                    target = target || _target;
                    target = target || DisplayObject3D.ZERO;

                    if(useDegrees)
                    {
                            pitch *= (Math.PI/180);
                            yaw *= (Math.PI/180);
                    }

                    // Number3D.sub
                    var dx                  :Number = target.world.n14 - this.x;
                    var dy                  :Number = target.world.n24 - this.y;
                    var dz                  :Number = target.world.n34 - this.z;

                    // Number3D.modulo
                    var distance    :Number = Math.sqrt(dx*dx+dy*dy+dz*dz);

                    // Rotations
                    var rx :Number = Math.cos(yaw) * Math.sin(pitch);
                    var rz :Number = Math.sin(yaw) * Math.sin(pitch);
                    var ry :Number = Math.cos(pitch);

                    // Move to specified location
                    this.x = target.world.n14 + (rx * distance);
                    this.y = target.world.n24 + (ry * distance);
                    this.z = target.world.n34 + (rz * distance);

                    this.lookAt(target);
            }

これを静止させたいオブジェクトのヘルパー関数として実装できます。この関数に含まれるカメラ固有のコードは、lookAt() 関数だけだと思います。

これを mouseMove ハンドラーの camera.orbit() の前に追加すると、カメラで静止したままになります。

于 2010-03-08T18:34:15.297 に答える