mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2025-12-31 09:49:22 +03:00
92 lines
6.0 KiB
ReStructuredText
92 lines
6.0 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. _class_ViewportTexture:
|
||
|
||
ViewportTexture
|
||
===============
|
||
|
||
**Успадковує:** :ref:`Texture2D<class_Texture2D>` **<** :ref:`Texture<class_Texture>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
||
|
||
Забезпечує вміст ``Перегляд`` як динамічної текстури.
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
Опис
|
||
--------
|
||
|
||
A **ViewportTexture** provides the content of a :ref:`Viewport<class_Viewport>` as a dynamic :ref:`Texture2D<class_Texture2D>`. This can be used to combine the rendering of :ref:`Control<class_Control>`, :ref:`Node2D<class_Node2D>` and :ref:`Node3D<class_Node3D>` nodes. For example, you can use this texture to display a 3D scene inside a :ref:`TextureRect<class_TextureRect>`, or a 2D overlay in a :ref:`Sprite3D<class_Sprite3D>`.
|
||
|
||
To get a **ViewportTexture** in code, use the :ref:`Viewport.get_texture()<class_Viewport_method_get_texture>` method on the target viewport.
|
||
|
||
\ **Note:** A **ViewportTexture** is always local to its scene (see :ref:`Resource.resource_local_to_scene<class_Resource_property_resource_local_to_scene>`). If the scene root is not ready, it may return incorrect data (see :ref:`Node.ready<class_Node_signal_ready>`).
|
||
|
||
\ **Note:** Instantiating scenes containing a high-resolution **ViewportTexture** may cause noticeable stutter.
|
||
|
||
\ **Note:** When using a :ref:`Viewport<class_Viewport>` with :ref:`Viewport.use_hdr_2d<class_Viewport_property_use_hdr_2d>` set to ``true``, the returned texture will be an HDR image that uses linear encoding. This may look darker than normal when displayed directly on screen. To convert to nonlinear sRGB encoding, you can do the following:
|
||
|
||
::
|
||
|
||
img.convert(Image.FORMAT_RGBA8)
|
||
img.linear_to_srgb()
|
||
|
||
\ **Note:** Some nodes such as :ref:`Decal<class_Decal>`, :ref:`Light3D<class_Light3D>`, and :ref:`PointLight2D<class_PointLight2D>` do not support using **ViewportTexture** directly. To use texture data from a **ViewportTexture** in these nodes, you need to create an :ref:`ImageTexture<class_ImageTexture>` by calling :ref:`Texture2D.get_image()<class_Texture2D_method_get_image>` on the **ViewportTexture** and passing the result to :ref:`ImageTexture.create_from_image()<class_ImageTexture_method_create_from_image>`. This conversion is a slow operation, so it should not be performed every frame.
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
Посібники
|
||
------------------
|
||
|
||
- `Графічний інтерфейс у 3D Viewport Demo <https://godotengine.org/asset-library/asset/2807>`__
|
||
|
||
- `3D в 2D Viewport Демо <https://godotengine.org/asset-library/asset/2804>`__
|
||
|
||
- `2D в 3D Viewport Demo <https://godotengine.org/asset-library/asset/2803>`__
|
||
|
||
- `3D дозвіл Scaling демо <https://godotengine.org/asset-library/asset/2805>`__
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
Властивості
|
||
----------------------
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+---------------------------------+--------------------------------------------------------------------+------------------+
|
||
| :ref:`NodePath<class_NodePath>` | :ref:`viewport_path<class_ViewportTexture_property_viewport_path>` | ``NodePath("")`` |
|
||
+---------------------------------+--------------------------------------------------------------------+------------------+
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
Описи властивостей
|
||
------------------------------------
|
||
|
||
.. _class_ViewportTexture_property_viewport_path:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`NodePath<class_NodePath>` **viewport_path** = ``NodePath("")`` :ref:`🔗<class_ViewportTexture_property_viewport_path>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_viewport_path_in_scene**\ (\ value\: :ref:`NodePath<class_NodePath>`\ )
|
||
- :ref:`NodePath<class_NodePath>` **get_viewport_path_in_scene**\ (\ )
|
||
|
||
Шлях до вершини :ref:`Viewport<class_Viewport>` для відображення. Це відносно кореня локальної сцени (див. :ref:`Resource.get_local_scene()<class_Resource_method_get_local_scene>`), **not** до вузлів, які використовують цю текстуру.
|
||
|
||
\ **Примітка:** У редакторі цей шлях автоматично оновлюється, коли цільовий порт або один з його предків перейменований або переміщений. У режимі runtime цей шлях не може автоматично оновлюватися, якщо корінь сцени не знайдено.
|
||
|
||
.. |virtual| replace:: :abbr:`virtual (Зазвичай, цей метод перевизначається користувачем, щоб він мав вплив.)`
|
||
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
||
.. |const| replace:: :abbr:`const (Цей метод не має побічних ефектів. Не змінює ніяку змінну екземпляра об'єкта.)`
|
||
.. |vararg| replace:: :abbr:`vararg (Цей метод приймає будь-яке число аргументів після описаних тут.)`
|
||
.. |constructor| replace:: :abbr:`constructor (Цей метод використовується для побудови типів.)`
|
||
.. |static| replace:: :abbr:`static (Цей метод не потребує екземпляра для виклику, його можна викликати безпосередньо за допомогою назви класу.)`
|
||
.. |operator| replace:: :abbr:`operator (Цей метод описує дійсний оператор для взаємодії з цим типом як з лівим операндом.)`
|
||
.. |bitfield| replace:: :abbr:`BitField (Це значення є цілим числом, складеним у вигляді бітової маски з наступних прапорів.)`
|
||
.. |void| replace:: :abbr:`void (Значення не повертається.)`
|