class_spritebase3d.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the SpriteBase3D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_SpriteBase3D:
  6. SpriteBase3D
  7. ============
  8. **Inherits:** :ref:`GeometryInstance3D<class_GeometryInstance3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`AnimatedSprite3D<class_AnimatedSprite3D>`, :ref:`Sprite3D<class_Sprite3D>`
  10. 2D sprite node in 3D environment.
  11. Description
  12. -----------
  13. A node that displays 2D texture information in a 3D environment. See also :ref:`Sprite3D<class_Sprite3D>` where many other properties are defined.
  14. Properties
  15. ----------
  16. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  17. | :ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>` | :ref:`alpha_cut<class_SpriteBase3D_property_alpha_cut>` | ``0`` |
  18. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  19. | Vector3.Axis | :ref:`axis<class_SpriteBase3D_property_axis>` | ``2`` |
  20. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  21. | :ref:`BillboardMode<enum_BaseMaterial3D_BillboardMode>` | :ref:`billboard<class_SpriteBase3D_property_billboard>` | ``0`` |
  22. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  23. | :ref:`bool<class_bool>` | :ref:`centered<class_SpriteBase3D_property_centered>` | ``true`` |
  24. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  25. | :ref:`bool<class_bool>` | :ref:`double_sided<class_SpriteBase3D_property_double_sided>` | ``true`` |
  26. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  27. | :ref:`bool<class_bool>` | :ref:`flip_h<class_SpriteBase3D_property_flip_h>` | ``false`` |
  28. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  29. | :ref:`bool<class_bool>` | :ref:`flip_v<class_SpriteBase3D_property_flip_v>` | ``false`` |
  30. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  31. | :ref:`Color<class_Color>` | :ref:`modulate<class_SpriteBase3D_property_modulate>` | ``Color(1, 1, 1, 1)`` |
  32. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  33. | :ref:`Vector2<class_Vector2>` | :ref:`offset<class_SpriteBase3D_property_offset>` | ``Vector2(0, 0)`` |
  34. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  35. | :ref:`float<class_float>` | :ref:`pixel_size<class_SpriteBase3D_property_pixel_size>` | ``0.01`` |
  36. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  37. | :ref:`bool<class_bool>` | :ref:`shaded<class_SpriteBase3D_property_shaded>` | ``false`` |
  38. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  39. | :ref:`bool<class_bool>` | :ref:`transparent<class_SpriteBase3D_property_transparent>` | ``true`` |
  40. +---------------------------------------------------------+---------------------------------------------------------------+-----------------------+
  41. Methods
  42. -------
  43. +-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`TriangleMesh<class_TriangleMesh>` | :ref:`generate_triangle_mesh<class_SpriteBase3D_method_generate_triangle_mesh>` **(** **)** |const| |
  45. +-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`get_draw_flag<class_SpriteBase3D_method_get_draw_flag>` **(** :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` flag **)** |const| |
  47. +-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Rect2<class_Rect2>` | :ref:`get_item_rect<class_SpriteBase3D_method_get_item_rect>` **(** **)** |const| |
  49. +-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_draw_flag<class_SpriteBase3D_method_set_draw_flag>` **(** :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` flag, :ref:`bool<class_bool>` enabled **)** |
  51. +-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. Enumerations
  53. ------------
  54. .. _enum_SpriteBase3D_DrawFlags:
  55. .. _class_SpriteBase3D_constant_FLAG_TRANSPARENT:
  56. .. _class_SpriteBase3D_constant_FLAG_SHADED:
  57. .. _class_SpriteBase3D_constant_FLAG_DOUBLE_SIDED:
  58. .. _class_SpriteBase3D_constant_FLAG_MAX:
  59. enum **DrawFlags**:
  60. - **FLAG_TRANSPARENT** = **0** --- If set, the texture's transparency and the opacity are used to make those parts of the sprite invisible.
  61. - **FLAG_SHADED** = **1** --- If set, lights in the environment affect the sprite.
  62. - **FLAG_DOUBLE_SIDED** = **2** --- If set, texture can be seen from the back as well. If not, the texture is invisible when looking at it from behind.
  63. - **FLAG_MAX** = **3** --- Represents the size of the :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` enum.
  64. ----
  65. .. _enum_SpriteBase3D_AlphaCutMode:
  66. .. _class_SpriteBase3D_constant_ALPHA_CUT_DISABLED:
  67. .. _class_SpriteBase3D_constant_ALPHA_CUT_DISCARD:
  68. .. _class_SpriteBase3D_constant_ALPHA_CUT_OPAQUE_PREPASS:
  69. enum **AlphaCutMode**:
  70. - **ALPHA_CUT_DISABLED** = **0** --- This mode performs standard alpha blending. It can display translucent areas, but transparency sorting issues may be visible when multiple transparent materials are overlapping.
  71. - **ALPHA_CUT_DISCARD** = **1** --- This mode only allows fully transparent or fully opaque pixels. Harsh edges will be visible unless some form of screen-space antialiasing is enabled (see :ref:`ProjectSettings.rendering/anti_aliasing/quality/screen_space_aa<class_ProjectSettings_property_rendering/anti_aliasing/quality/screen_space_aa>`). On the bright side, this mode doesn't suffer from transparency sorting issues when multiple transparent materials are overlapping. This mode is also known as *alpha testing* or *1-bit transparency*.
  72. - **ALPHA_CUT_OPAQUE_PREPASS** = **2** --- This mode draws fully opaque pixels in the depth prepass. This is slower than :ref:`ALPHA_CUT_DISABLED<class_SpriteBase3D_constant_ALPHA_CUT_DISABLED>` or :ref:`ALPHA_CUT_DISCARD<class_SpriteBase3D_constant_ALPHA_CUT_DISCARD>`, but it allows displaying translucent areas and smooth edges while using proper sorting.
  73. Property Descriptions
  74. ---------------------
  75. .. _class_SpriteBase3D_property_alpha_cut:
  76. - :ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>` **alpha_cut**
  77. +-----------+---------------------------+
  78. | *Default* | ``0`` |
  79. +-----------+---------------------------+
  80. | *Setter* | set_alpha_cut_mode(value) |
  81. +-----------+---------------------------+
  82. | *Getter* | get_alpha_cut_mode() |
  83. +-----------+---------------------------+
  84. The alpha cutting mode to use for the sprite. See :ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>` for possible values.
  85. ----
  86. .. _class_SpriteBase3D_property_axis:
  87. - Vector3.Axis **axis**
  88. +-----------+-----------------+
  89. | *Default* | ``2`` |
  90. +-----------+-----------------+
  91. | *Setter* | set_axis(value) |
  92. +-----------+-----------------+
  93. | *Getter* | get_axis() |
  94. +-----------+-----------------+
  95. The direction in which the front of the texture faces.
  96. ----
  97. .. _class_SpriteBase3D_property_billboard:
  98. - :ref:`BillboardMode<enum_BaseMaterial3D_BillboardMode>` **billboard**
  99. +-----------+---------------------------+
  100. | *Default* | ``0`` |
  101. +-----------+---------------------------+
  102. | *Setter* | set_billboard_mode(value) |
  103. +-----------+---------------------------+
  104. | *Getter* | get_billboard_mode() |
  105. +-----------+---------------------------+
  106. The billboard mode to use for the sprite. See :ref:`BillboardMode<enum_BaseMaterial3D_BillboardMode>` for possible values.
  107. ----
  108. .. _class_SpriteBase3D_property_centered:
  109. - :ref:`bool<class_bool>` **centered**
  110. +-----------+---------------------+
  111. | *Default* | ``true`` |
  112. +-----------+---------------------+
  113. | *Setter* | set_centered(value) |
  114. +-----------+---------------------+
  115. | *Getter* | is_centered() |
  116. +-----------+---------------------+
  117. If ``true``, texture will be centered.
  118. ----
  119. .. _class_SpriteBase3D_property_double_sided:
  120. - :ref:`bool<class_bool>` **double_sided**
  121. +-----------+----------------------+
  122. | *Default* | ``true`` |
  123. +-----------+----------------------+
  124. | *Setter* | set_draw_flag(value) |
  125. +-----------+----------------------+
  126. | *Getter* | get_draw_flag() |
  127. +-----------+----------------------+
  128. If ``true``, texture can be seen from the back as well, if ``false``, it is invisible when looking at it from behind.
  129. ----
  130. .. _class_SpriteBase3D_property_flip_h:
  131. - :ref:`bool<class_bool>` **flip_h**
  132. +-----------+-------------------+
  133. | *Default* | ``false`` |
  134. +-----------+-------------------+
  135. | *Setter* | set_flip_h(value) |
  136. +-----------+-------------------+
  137. | *Getter* | is_flipped_h() |
  138. +-----------+-------------------+
  139. If ``true``, texture is flipped horizontally.
  140. ----
  141. .. _class_SpriteBase3D_property_flip_v:
  142. - :ref:`bool<class_bool>` **flip_v**
  143. +-----------+-------------------+
  144. | *Default* | ``false`` |
  145. +-----------+-------------------+
  146. | *Setter* | set_flip_v(value) |
  147. +-----------+-------------------+
  148. | *Getter* | is_flipped_v() |
  149. +-----------+-------------------+
  150. If ``true``, texture is flipped vertically.
  151. ----
  152. .. _class_SpriteBase3D_property_modulate:
  153. - :ref:`Color<class_Color>` **modulate**
  154. +-----------+-----------------------+
  155. | *Default* | ``Color(1, 1, 1, 1)`` |
  156. +-----------+-----------------------+
  157. | *Setter* | set_modulate(value) |
  158. +-----------+-----------------------+
  159. | *Getter* | get_modulate() |
  160. +-----------+-----------------------+
  161. A color value used to *multiply* the texture's colors. Can be used for mood-coloring or to simulate the color of light.
  162. \ **Note:** If a :ref:`GeometryInstance3D.material_override<class_GeometryInstance3D_property_material_override>` is defined on the ``SpriteBase3D``, the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in :ref:`modulate<class_SpriteBase3D_property_modulate>` will be ignored. For a :ref:`BaseMaterial3D<class_BaseMaterial3D>`, :ref:`BaseMaterial3D.vertex_color_use_as_albedo<class_BaseMaterial3D_property_vertex_color_use_as_albedo>` must be ``true``. For a :ref:`ShaderMaterial<class_ShaderMaterial>`, ``ALBEDO *= COLOR.rgb;`` must be inserted in the shader's ``fragment()`` function.
  163. ----
  164. .. _class_SpriteBase3D_property_offset:
  165. - :ref:`Vector2<class_Vector2>` **offset**
  166. +-----------+-------------------+
  167. | *Default* | ``Vector2(0, 0)`` |
  168. +-----------+-------------------+
  169. | *Setter* | set_offset(value) |
  170. +-----------+-------------------+
  171. | *Getter* | get_offset() |
  172. +-----------+-------------------+
  173. The texture's drawing offset.
  174. ----
  175. .. _class_SpriteBase3D_property_pixel_size:
  176. - :ref:`float<class_float>` **pixel_size**
  177. +-----------+-----------------------+
  178. | *Default* | ``0.01`` |
  179. +-----------+-----------------------+
  180. | *Setter* | set_pixel_size(value) |
  181. +-----------+-----------------------+
  182. | *Getter* | get_pixel_size() |
  183. +-----------+-----------------------+
  184. The size of one pixel's width on the sprite to scale it in 3D.
  185. ----
  186. .. _class_SpriteBase3D_property_shaded:
  187. - :ref:`bool<class_bool>` **shaded**
  188. +-----------+----------------------+
  189. | *Default* | ``false`` |
  190. +-----------+----------------------+
  191. | *Setter* | set_draw_flag(value) |
  192. +-----------+----------------------+
  193. | *Getter* | get_draw_flag() |
  194. +-----------+----------------------+
  195. If ``true``, the :ref:`Light3D<class_Light3D>` in the :ref:`Environment<class_Environment>` has effects on the sprite.
  196. ----
  197. .. _class_SpriteBase3D_property_transparent:
  198. - :ref:`bool<class_bool>` **transparent**
  199. +-----------+----------------------+
  200. | *Default* | ``true`` |
  201. +-----------+----------------------+
  202. | *Setter* | set_draw_flag(value) |
  203. +-----------+----------------------+
  204. | *Getter* | get_draw_flag() |
  205. +-----------+----------------------+
  206. If ``true``, the texture's transparency and the opacity are used to make those parts of the sprite invisible.
  207. Method Descriptions
  208. -------------------
  209. .. _class_SpriteBase3D_method_generate_triangle_mesh:
  210. - :ref:`TriangleMesh<class_TriangleMesh>` **generate_triangle_mesh** **(** **)** |const|
  211. Returns a :ref:`TriangleMesh<class_TriangleMesh>` with the sprite's vertices following its current configuration (such as its :ref:`axis<class_SpriteBase3D_property_axis>` and :ref:`pixel_size<class_SpriteBase3D_property_pixel_size>`).
  212. ----
  213. .. _class_SpriteBase3D_method_get_draw_flag:
  214. - :ref:`bool<class_bool>` **get_draw_flag** **(** :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` flag **)** |const|
  215. Returns the value of the specified flag.
  216. ----
  217. .. _class_SpriteBase3D_method_get_item_rect:
  218. - :ref:`Rect2<class_Rect2>` **get_item_rect** **(** **)** |const|
  219. Returns the rectangle representing this sprite.
  220. ----
  221. .. _class_SpriteBase3D_method_set_draw_flag:
  222. - void **set_draw_flag** **(** :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` flag, :ref:`bool<class_bool>` enabled **)**
  223. If ``true``, the specified flag will be enabled. See :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` for a list of flags.
  224. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  225. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  226. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  227. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  228. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  229. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`