# Viewport3D

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-media3d/struct-viewport3d/

**struct** · [`ferroui-media3d`](/docs/0.5.0/api/ferroui-media3d/) · v0.5.0

```rust
struct Viewport3D
```

WPF's `Viewport3D`: the scene of its `Camera` and `Children` (the visuals of a
[`Viewport3DVisual`](/docs/0.5.0/api/ferroui-media3d/struct-viewport3dvisual/), which this control hosts), drawn over its arranged bounds.

It draws nothing where no model is (it has no background), clips to its bounds by default
(`ClipToBounds` is true, as in WPF), and composes like any element under its transform,
clip, opacity and effects: it records one `DrawScene3D` operation with the snapshot of its
scene. Its desired size is zero unless a size is set, as WPF's.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L28)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`camera_property`](#function-camera_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`camera`](#function-camera)
- [`set_camera`](#function-set_camera)
- [`children`](#function-children)
- [`viewport_3d_visual`](#function-viewport_3d_visual)
- [`snapshot`](#function-snapshot)
- [`scene_changed`](#function-scene_changed)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L34)

<a id="function-to_ref"></a>

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<Viewport3D>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L34)

<a id="function-camera_property"></a>

### camera_property

```rust
fn camera_property() -> &'static StyledProperty<Option<Ref<Camera>>>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L83)

<a id="function-construct"></a>

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `ferroui_base::FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L95)

<a id="function-new"></a>

### new

```rust
fn new() -> Ref<Self>
```

An empty viewport without a camera.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L100)

<a id="function-camera"></a>

### camera

```rust
fn camera(self: &Self) -> Option<Ref<Camera>>
```

The camera of the scene.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L105)

<a id="function-set_camera"></a>

### set_camera

```rust
fn set_camera(self: &Self, value: Option<Ref<Camera>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L109)

<a id="function-children"></a>

### children

```rust
fn children(self: &Self) -> Visual3DCollection
```

The visuals of the scene (a shared handle to the collection).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L114)

<a id="function-viewport_3d_visual"></a>

### viewport_3d_visual

```rust
fn viewport_3d_visual(self: &Self) -> &Ref<Viewport3DVisual>
```

The scene this control hosts (WPF keeps it private; it is the way to its generations and
to the 3D hit testing).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L120)

<a id="function-snapshot"></a>

### snapshot

```rust
fn snapshot(self: &Self) -> Arc<Scene3DSnapshot>
```

The scene as it is drawn now.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L125)

<a id="function-scene_changed"></a>

### scene_changed

```rust
fn scene_changed(self: &Self, handler: impl Fn(Scene3DChange) -> () + 'static) -> Subscription
```

Calls `handler` on every change of the scene, until the returned guard is dropped.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/controls/viewport_3d.rs#L130)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- [`InputElementImplExt`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimplext/)
- [`InteractiveImplExt`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimplext/)
- [`LayoutableImplExt`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`StyledElementImplExt`](/docs/0.5.0/api/ferroui-base/trait-styledelementimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- [`VisualImplExt`](/docs/0.5.0/api/ferroui-base/trait-visualimplext/)
- `ErasedDestructor`
- `IntoEither`
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<Viewport3D>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
