Viewport3D.Camera 屬性

定義

取得或設定相機物件,將 的 Viewport3D 3D 內容投影到 的 Viewport3D 平面。

public:
 property System::Windows::Media::Media3D::Camera ^ Camera { System::Windows::Media::Media3D::Camera ^ get(); void set(System::Windows::Media::Media3D::Camera ^ value); };
public System.Windows.Media.Media3D.Camera Camera { get; set; }
member this.Camera : System.Windows.Media.Media3D.Camera with get, set
Public Property Camera As Camera

屬性值

Camera

將 3D 內容投影到平面的相機。

範例

下列範例示範如何使用程式碼設定 CameraViewport3D 屬性。 若要查看擷取此摘錄的完整程式碼,請參閱 如何:建立 3D 場景

// Defines the camera used to view the 3D object. In order to view the 3D object,
// the camera must be positioned and pointed such that the object is within view 
// of the camera.
PerspectiveCamera myPCamera = new PerspectiveCamera();

// Specify where in the 3D scene the camera is.
myPCamera.Position = new Point3D(0, 0, 2);

// Specify the direction that the camera is pointing.
myPCamera.LookDirection = new Vector3D(0, 0, -1);

// Define camera's horizontal field of view in degrees.
myPCamera.FieldOfView = 60;

// Asign the camera to the viewport
myViewport3D.Camera = myPCamera;
' Defines the camera used to view the 3D object. In order to view the 3D object,
' the camera must be positioned and pointed such that the object is within view 
' of the camera.
Dim myPCamera As New PerspectiveCamera()

' Specify where in the 3D scene the camera is.
myPCamera.Position = New Point3D(0, 0, 2)

' Specify the direction that the camera is pointing.
myPCamera.LookDirection = New Vector3D(0, 0, -1)

' Define camera's horizontal field of view in degrees.
myPCamera.FieldOfView = 60

' Asign the camera to the viewport
myViewport3D.Camera = myPCamera

下列範例示範 Camera 如何使用 Extensible Application Markup Language (XAML) 設定 的 Viewport3D 屬性。 若要查看擷取此摘錄的完整程式碼,請參閱 如何:建立 3D 場景

<!-- Add a camera. -->
<Viewport3D.Camera>
    <PerspectiveCamera FarPlaneDistance="20" LookDirection="5,-2,-3" UpDirection="0,1,0" NearPlaneDistance="1" Position="-5,2,3" FieldOfView="45" />
</Viewport3D.Camera>

備註

此屬性代表 3D 場景的檢視投影。

相依性屬性資訊

識別碼欄位 CameraProperty
中繼資料屬性設定為 true

注意

這個相依性屬性上的元資料類型是 PropertyMetadata ,而不是 FrameworkPropertyMetadata

適用於