@defold-typescript/types 0.51.0 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/api-availability.json +4 -58
  2. package/api-signatures.json +2804 -3172
  3. package/api-targets.json +15 -5
  4. package/examples/translations.json +19 -71
  5. package/generated/b2d.d.ts +39 -39
  6. package/generated/b2d_body.d.ts +11 -11
  7. package/generated/b2d_chain.d.ts +3 -3
  8. package/generated/b2d_fixture.d.ts +5 -5
  9. package/generated/b2d_joint.d.ts +29 -29
  10. package/generated/b2d_shape.d.ts +13 -13
  11. package/generated/b2d_world.d.ts +15 -15
  12. package/generated/buffer.d.ts +10 -11
  13. package/generated/bullet3d.d.ts +6 -6
  14. package/generated/bullet3d_collision_object.d.ts +10 -10
  15. package/generated/bullet3d_constraint.d.ts +173 -71
  16. package/generated/bullet3d_rigid_body.d.ts +3 -3
  17. package/generated/bullet3d_shape.d.ts +11 -11
  18. package/generated/bullet3d_world.d.ts +20 -20
  19. package/generated/camera.d.ts +4 -4
  20. package/generated/collectionfactory.d.ts +2 -3
  21. package/generated/collectionproxy.d.ts +5 -5
  22. package/generated/compute.d.ts +5 -5
  23. package/generated/crash.d.ts +7 -7
  24. package/generated/editor-vm/http.d.ts +13 -13
  25. package/generated/editor-vm/image.d.ts +4 -4
  26. package/generated/editor-vm/json.d.ts +1 -1
  27. package/generated/editor-vm/tilemap_tiles.d.ts +9 -9
  28. package/generated/editor-vm/zip.d.ts +4 -4
  29. package/generated/editor.d.ts +183 -183
  30. package/generated/factory.d.ts +2 -3
  31. package/generated/font.d.ts +4 -4
  32. package/generated/go.d.ts +122 -230
  33. package/generated/graphics.d.ts +23 -25
  34. package/generated/gui.d.ts +186 -423
  35. package/generated/http.d.ts +3 -3
  36. package/generated/image.d.ts +63 -11
  37. package/generated/json.d.ts +4 -4
  38. package/generated/kinds/gui-script.d.ts +2 -0
  39. package/generated/kinds/render-script.d.ts +14 -15
  40. package/generated/label.d.ts +5 -5
  41. package/generated/liveupdate.d.ts +7 -3
  42. package/generated/material.d.ts +49 -49
  43. package/generated/model.d.ts +46 -14
  44. package/generated/particlefx.d.ts +24 -5
  45. package/generated/physics.d.ts +64 -20
  46. package/generated/profiler.d.ts +3 -5
  47. package/generated/render-script-modules/b2d.d.ts +711 -0
  48. package/generated/render-script-modules/bullet3d.d.ts +73 -0
  49. package/generated/render-script-modules/collectionfactory.d.ts +24 -0
  50. package/generated/render-script-modules/collectionproxy.d.ts +39 -0
  51. package/generated/render-script-modules/factory.d.ts +24 -0
  52. package/generated/render-script-modules/go.d.ts +434 -0
  53. package/generated/render-script-modules/label.d.ts +105 -0
  54. package/generated/render-script-modules/model.d.ts +121 -0
  55. package/generated/render-script-modules/particlefx.d.ts +59 -0
  56. package/generated/render-script-modules/physics.d.ts +333 -0
  57. package/generated/render-script-modules/resource.d.ts +1232 -0
  58. package/generated/render-script-modules/sound.d.ts +227 -0
  59. package/generated/render-script-modules/sprite.d.ts +68 -0
  60. package/generated/render-script-modules/tilemap.d.ts +43 -0
  61. package/generated/render.d.ts +172 -47
  62. package/generated/resource.d.ts +81 -61
  63. package/generated/socket.d.ts +18 -23
  64. package/generated/sound.d.ts +6 -6
  65. package/generated/sprite.d.ts +51 -3
  66. package/generated/sys.d.ts +87 -24
  67. package/generated/tilemap.d.ts +3 -3
  68. package/generated/timer.d.ts +3 -3
  69. package/generated/versions/defold-1.12.4/b2d.d.ts +2 -2
  70. package/generated/versions/defold-1.12.4/b2d_body.d.ts +2 -2
  71. package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
  72. package/generated/versions/defold-1.12.4/go.d.ts +117 -345
  73. package/generated/versions/defold-1.12.4/graphics.d.ts +2 -1
  74. package/generated/versions/defold-1.12.4/gui.d.ts +169 -532
  75. package/generated/versions/defold-1.12.4/http.d.ts +2 -2
  76. package/generated/versions/defold-1.12.4/image.d.ts +82 -2
  77. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  78. package/generated/versions/defold-1.12.4/label.d.ts +1 -1
  79. package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
  80. package/generated/versions/defold-1.12.4/model.d.ts +42 -10
  81. package/generated/versions/defold-1.12.4/particlefx.d.ts +23 -2
  82. package/generated/versions/defold-1.12.4/physics.d.ts +46 -2
  83. package/generated/versions/defold-1.12.4/render.d.ts +83 -7
  84. package/generated/versions/defold-1.12.4/resource.d.ts +50 -17
  85. package/generated/versions/defold-1.12.4/socket.d.ts +12 -12
  86. package/generated/versions/defold-1.12.4/sound.d.ts +1 -1
  87. package/generated/versions/defold-1.12.4/sprite.d.ts +59 -2
  88. package/generated/versions/defold-1.12.4/sys.d.ts +103 -8
  89. package/generated/versions/defold-1.12.4/tilemap.d.ts +1 -1
  90. package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
  91. package/generated/versions/defold-1.12.4/window.d.ts +3 -4
  92. package/generated/versions/defold-1.13.0/b2d.d.ts +2 -2
  93. package/generated/versions/defold-1.13.0/b2d_body.d.ts +2 -2
  94. package/generated/versions/defold-1.13.0/b2d_chain.d.ts +1 -1
  95. package/generated/versions/defold-1.13.0/b2d_joint.d.ts +1 -1
  96. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +1 -1
  97. package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
  98. package/generated/versions/defold-1.13.0/camera.d.ts +1 -1
  99. package/generated/versions/defold-1.13.0/go.d.ts +117 -372
  100. package/generated/versions/defold-1.13.0/graphics.d.ts +2 -1
  101. package/generated/versions/defold-1.13.0/gui.d.ts +169 -532
  102. package/generated/versions/defold-1.13.0/http.d.ts +2 -2
  103. package/generated/versions/defold-1.13.0/image.d.ts +82 -2
  104. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  105. package/generated/versions/defold-1.13.0/label.d.ts +1 -1
  106. package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
  107. package/generated/versions/defold-1.13.0/material.d.ts +3 -1
  108. package/generated/versions/defold-1.13.0/model.d.ts +42 -10
  109. package/generated/versions/defold-1.13.0/particlefx.d.ts +23 -2
  110. package/generated/versions/defold-1.13.0/physics.d.ts +46 -2
  111. package/generated/versions/defold-1.13.0/render.d.ts +147 -9
  112. package/generated/versions/defold-1.13.0/resource.d.ts +50 -17
  113. package/generated/versions/defold-1.13.0/socket.d.ts +12 -12
  114. package/generated/versions/defold-1.13.0/sound.d.ts +1 -1
  115. package/generated/versions/defold-1.13.0/sprite.d.ts +59 -2
  116. package/generated/versions/defold-1.13.0/sys.d.ts +103 -8
  117. package/generated/versions/defold-1.13.0/tilemap.d.ts +1 -1
  118. package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
  119. package/generated/versions/defold-1.13.0/window.d.ts +3 -4
  120. package/generated/versions/defold-1.13.1/b2d.d.ts +2 -2
  121. package/generated/versions/defold-1.13.1/b2d_body.d.ts +2 -2
  122. package/generated/versions/defold-1.13.1/b2d_chain.d.ts +1 -1
  123. package/generated/versions/defold-1.13.1/b2d_joint.d.ts +1 -1
  124. package/generated/versions/defold-1.13.1/b2d_shape.d.ts +1 -1
  125. package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
  126. package/generated/versions/defold-1.13.1/camera.d.ts +1 -1
  127. package/generated/versions/defold-1.13.1/go.d.ts +117 -372
  128. package/generated/versions/defold-1.13.1/graphics.d.ts +2 -1
  129. package/generated/versions/defold-1.13.1/gui.d.ts +169 -548
  130. package/generated/versions/defold-1.13.1/http.d.ts +2 -2
  131. package/generated/versions/defold-1.13.1/image.d.ts +82 -2
  132. package/generated/versions/defold-1.13.1/index.d.ts +2 -0
  133. package/generated/versions/defold-1.13.1/label.d.ts +1 -1
  134. package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
  135. package/generated/versions/defold-1.13.1/material.d.ts +3 -1
  136. package/generated/versions/defold-1.13.1/model.d.ts +42 -10
  137. package/generated/versions/defold-1.13.1/particlefx.d.ts +23 -2
  138. package/generated/versions/defold-1.13.1/physics.d.ts +46 -2
  139. package/generated/versions/defold-1.13.1/render.d.ts +147 -9
  140. package/generated/versions/defold-1.13.1/resource.d.ts +50 -17
  141. package/generated/versions/defold-1.13.1/socket.d.ts +12 -12
  142. package/generated/versions/defold-1.13.1/sound.d.ts +1 -1
  143. package/generated/versions/defold-1.13.1/sprite.d.ts +59 -2
  144. package/generated/versions/defold-1.13.1/sys.d.ts +103 -8
  145. package/generated/versions/defold-1.13.1/tilemap.d.ts +1 -1
  146. package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
  147. package/generated/versions/defold-1.13.1/window.d.ts +3 -4
  148. package/generated/versions/defold-1.13.2/b2d.d.ts +39 -39
  149. package/generated/versions/defold-1.13.2/b2d_body.d.ts +11 -11
  150. package/generated/versions/defold-1.13.2/b2d_chain.d.ts +3 -3
  151. package/generated/versions/defold-1.13.2/b2d_fixture.d.ts +5 -5
  152. package/generated/versions/defold-1.13.2/b2d_joint.d.ts +29 -29
  153. package/generated/versions/defold-1.13.2/b2d_shape.d.ts +13 -13
  154. package/generated/versions/defold-1.13.2/b2d_world.d.ts +15 -15
  155. package/generated/versions/defold-1.13.2/buffer.d.ts +10 -11
  156. package/generated/versions/defold-1.13.2/bullet3d.d.ts +6 -6
  157. package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +10 -10
  158. package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +173 -71
  159. package/generated/versions/defold-1.13.2/bullet3d_rigid_body.d.ts +3 -3
  160. package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +11 -11
  161. package/generated/versions/defold-1.13.2/bullet3d_world.d.ts +20 -20
  162. package/generated/versions/defold-1.13.2/camera.d.ts +4 -4
  163. package/generated/versions/defold-1.13.2/collectionfactory.d.ts +2 -3
  164. package/generated/versions/defold-1.13.2/collectionproxy.d.ts +5 -5
  165. package/generated/versions/defold-1.13.2/compute.d.ts +5 -5
  166. package/generated/versions/defold-1.13.2/crash.d.ts +7 -7
  167. package/generated/versions/defold-1.13.2/editor-vm/http.d.ts +13 -13
  168. package/generated/versions/defold-1.13.2/editor-vm/image.d.ts +4 -4
  169. package/generated/versions/defold-1.13.2/editor-vm/json.d.ts +1 -1
  170. package/generated/versions/defold-1.13.2/editor-vm/tilemap_tiles.d.ts +9 -9
  171. package/generated/versions/defold-1.13.2/editor-vm/zip.d.ts +4 -4
  172. package/generated/versions/defold-1.13.2/editor.d.ts +183 -183
  173. package/generated/versions/defold-1.13.2/factory.d.ts +2 -3
  174. package/generated/versions/defold-1.13.2/font.d.ts +4 -4
  175. package/generated/versions/defold-1.13.2/go.d.ts +122 -230
  176. package/generated/versions/defold-1.13.2/graphics.d.ts +22 -24
  177. package/generated/versions/defold-1.13.2/gui.d.ts +186 -423
  178. package/generated/versions/defold-1.13.2/http.d.ts +3 -3
  179. package/generated/versions/defold-1.13.2/image.d.ts +63 -11
  180. package/generated/versions/defold-1.13.2/index.d.ts +2 -0
  181. package/generated/versions/defold-1.13.2/json.d.ts +4 -4
  182. package/generated/versions/defold-1.13.2/label.d.ts +5 -5
  183. package/generated/versions/defold-1.13.2/liveupdate.d.ts +7 -3
  184. package/generated/versions/defold-1.13.2/material.d.ts +49 -49
  185. package/generated/versions/defold-1.13.2/model.d.ts +46 -14
  186. package/generated/versions/defold-1.13.2/particlefx.d.ts +24 -5
  187. package/generated/versions/defold-1.13.2/physics.d.ts +64 -20
  188. package/generated/versions/defold-1.13.2/profiler.d.ts +3 -5
  189. package/generated/versions/defold-1.13.2/render.d.ts +161 -46
  190. package/generated/versions/defold-1.13.2/resource.d.ts +81 -61
  191. package/generated/versions/defold-1.13.2/socket.d.ts +18 -23
  192. package/generated/versions/defold-1.13.2/sound.d.ts +6 -6
  193. package/generated/versions/defold-1.13.2/sprite.d.ts +51 -3
  194. package/generated/versions/defold-1.13.2/sys.d.ts +87 -24
  195. package/generated/versions/defold-1.13.2/tilemap.d.ts +3 -3
  196. package/generated/versions/defold-1.13.2/timer.d.ts +3 -3
  197. package/generated/versions/defold-1.13.2/vmath.d.ts +0 -25
  198. package/generated/versions/defold-1.13.2/window.d.ts +8 -10
  199. package/generated/vmath.d.ts +0 -25
  200. package/generated/window.d.ts +8 -10
  201. package/identity-vocabulary.json +86 -34
  202. package/index.d.ts +2 -0
  203. package/package.json +3 -1
  204. package/scripts/generate-api-availability.ts +10 -24
  205. package/scripts/generate-api-signatures.ts +75 -14
  206. package/scripts/materialize-version.ts +48 -7
  207. package/scripts/regen.ts +214 -19
  208. package/scripts/shared-handle-methods.ts +3 -2
  209. package/scripts/signature-store-fs.ts +1 -0
  210. package/scripts/target-version.ts +26 -0
  211. package/src/api-doc.ts +34 -0
  212. package/src/api-identity.ts +32 -1
  213. package/src/component-properties.d.ts +96 -7
  214. package/src/core-types.ts +71 -28
  215. package/src/doc-corrections.ts +62 -5
  216. package/src/emit-dts.ts +1423 -401
  217. package/src/engine-globals.d.ts +5 -1
  218. package/src/engine-type-name.ts +33 -0
  219. package/src/go-overloads.d.ts +74 -19
  220. package/src/gui-overloads.d.ts +489 -0
  221. package/src/gui-texture-removal.d.ts +41 -0
  222. package/src/index.ts +3 -0
  223. package/src/lifecycle.ts +32 -23
  224. package/src/msg-overloads.d.ts +25 -13
  225. package/src/signature-store.ts +50 -0
  226. package/src/socket-types.d.ts +3 -3
  227. package/src/timers.d.ts +2 -1
  228. package/src/vmath-overloads.d.ts +26 -0
@@ -1,5 +1,5 @@
1
1
  /** @noSelfInFile */
2
- import type { Hash } from "../../../src/core-types";
2
+ import type { Hash, Url } from "../../../src/core-types";
3
3
 
4
4
  declare global {
5
5
  /**
@@ -72,7 +72,7 @@ declare global {
72
72
  * });
73
73
  * ```
74
74
  */
75
- function request(url: string, method: string, callback: (self: unknown, id: Hash, response: { status: number; url: string; response?: string; headers?: LuaMap<string, string>; path?: string; error?: string; bytes_sent?: number; bytes_received?: number; bytes_total?: number; range_start?: number; range_end?: number; document_size?: number }) => void, headers?: LuaMap<string, string> | Record<string, string>, post_data?: string, options?: { timeout?: number; path?: string; ignore_cache?: boolean; chunked_transfer?: boolean; report_progress?: boolean }): void;
75
+ function request(url: string, method: string, callback: (self: unknown, id: Hash, response: { status: number; url: string; response?: string; headers?: LuaMap<string, string>; path?: string; error?: string; bytes_sent?: number; bytes_received?: number; bytes_total?: number; range_start?: number; range_end?: number; document_size?: number }, sender: Url) => void, headers?: LuaMap<string, string> | Record<string, string>, post_data?: string, options?: { timeout?: number; path?: string; ignore_cache?: boolean; chunked_transfer?: boolean; report_progress?: boolean }): void;
76
76
  }
77
77
  }
78
78
 
@@ -77,7 +77,87 @@ declare global {
77
77
  * });
78
78
  * ```
79
79
  */
80
- function load(buffer: string, options?: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: string } | undefined;
80
+ function load(buffer: string): { width: number; height: number; type: Opaque<"constant">; buffer: string } | undefined;
81
+ /**
82
+ * Load image (PNG or JPEG) from buffer.
83
+ *
84
+ * @param buffer - image data buffer
85
+ * @param options - An optional table containing parameters for loading the image. Supported entries:
86
+ *
87
+ * `premultiply_alpha`
88
+ * boolean True if alpha should be premultiplied into the color components. Defaults to `false`.
89
+ * `flip_vertically`
90
+ * boolean True if the image contents should be flipped vertically. Defaults to `false`.
91
+ * @returns object or `nil` if loading fails. The object is a table with the following fields:
92
+ *
93
+ * - number `width`: image width
94
+ * - number `height`: image height
95
+ * - constant `type`: image type
96
+ * - `image.TYPE_RGB`
97
+ * - `image.TYPE_RGBA`
98
+ * - `image.TYPE_LUMINANCE`
99
+ * - `image.TYPE_LUMINANCE_ALPHA`
100
+ * - string `buffer`: the raw image data
101
+ * @example
102
+ * ```ts
103
+ * // How to load an image from an URL and create a GUI texture from it:
104
+ * const imgurl = "http://www.site.com/image.png";
105
+ * http.request(imgurl, "GET", (self, id, response) => {
106
+ * const img = response.response !== undefined ? image.load(response.response) : undefined;
107
+ * if (img !== undefined) {
108
+ * const tx = gui.new_texture("image_node", img.width, img.height, img.type, img.buffer);
109
+ * }
110
+ * });
111
+ * ```
112
+ */
113
+ function load(buffer: string, options: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: string } | undefined;
114
+ /**
115
+ * Load image (PNG or JPEG) from a string buffer.
116
+ *
117
+ * @param buffer - image data buffer
118
+ * @param options - An optional table containing parameters for loading the image. Supported entries:
119
+ *
120
+ * `premultiply_alpha`
121
+ * boolean True if alpha should be premultiplied into the color components. Defaults to `false`.
122
+ * `flip_vertically`
123
+ * boolean True if the image contents should be flipped vertically. Defaults to `false`.
124
+ * @returns object or `nil` if loading fails. The object is a table with the following fields:
125
+ *
126
+ * - number `width`: image width
127
+ * - number `height`: image height
128
+ * - constant `type`: image type
129
+ * - `image.TYPE_RGB`
130
+ * - `image.TYPE_RGBA`
131
+ * - `image.TYPE_LUMINANCE`
132
+ * - `image.TYPE_LUMINANCE_ALPHA`
133
+ * - buffer `buffer`: the script buffer that holds the decompressed image data. See buffer.create how to use the buffer.
134
+ * @example
135
+ * ```ts
136
+ * // Load an image from an URL as a buffer and create a texture resource from it:
137
+ * const imgurl = "http://www.site.com/image.png";
138
+ * http.request(imgurl, "GET", (self, id, response) => {
139
+ * const img =
140
+ * response.response !== undefined
141
+ * ? image.load_buffer(response.response, { flip_vertically: true })
142
+ * : undefined;
143
+ * // the engine registers a texture format only when the driver supports it
144
+ * const format = graphics.TEXTURE_FORMAT_RGBA;
145
+ * if (img !== undefined && format !== undefined) {
146
+ * const tparams = {
147
+ * width: img.width,
148
+ * height: img.height,
149
+ * type: graphics.TEXTURE_TYPE_2D,
150
+ * format,
151
+ * };
152
+ *
153
+ * const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams, img.buffer);
154
+ * // Apply the texture to a model
155
+ * go.set("/go1#model", "texture0", my_texture_id);
156
+ * }
157
+ * });
158
+ * ```
159
+ */
160
+ function load_buffer(buffer: string): { width: number; height: number; type: Opaque<"constant">; buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> } } | undefined;
81
161
  /**
82
162
  * Load image (PNG or JPEG) from a string buffer.
83
163
  *
@@ -124,7 +204,7 @@ declare global {
124
204
  * });
125
205
  * ```
126
206
  */
127
- function load_buffer(buffer: string, options?: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: Opaque<"buffer"> } | undefined;
207
+ function load_buffer(buffer: string, options: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> } } | undefined;
128
208
  }
129
209
  }
130
210
 
@@ -52,6 +52,8 @@ import "../../../src/scene-addresses";
52
52
  import "../../../src/go-overloads";
53
53
  import "../../../src/component-properties";
54
54
  import "../../../src/render-overloads";
55
+ import "../../../src/gui-overloads";
56
+ import "../../../src/gui-texture-removal";
55
57
  import "../../../src/vmath-overloads";
56
58
  import "../../../src/sys-overloads";
57
59
 
@@ -39,7 +39,7 @@ declare global {
39
39
  * ```
40
40
  */
41
41
  function set_text(url: string | Hash | Url, text: string | number): void;
42
- interface properties {
42
+ interface Properties {
43
43
  /**
44
44
  * The color of the label. The type of the property is vector4.
45
45
  */
@@ -38,6 +38,10 @@ declare global {
38
38
  * Memory wasn't allocated
39
39
  */
40
40
  const LIVEUPDATE_MEM_ERROR: number & { readonly __brand: "liveupdate.LIVEUPDATE_MEM_ERROR" };
41
+ /**
42
+ * Live update is not initialized. `liveupdate.add_mount` and `liveupdate.remove_mount` return it while live update is disabled.
43
+ */
44
+ const LIVEUPDATE_NOT_INITIALIZED: number & { readonly __brand: "liveupdate.LIVEUPDATE_NOT_INITIALIZED" };
41
45
  /**
42
46
  * LIVEUPDATE_OK
43
47
  */
@@ -217,6 +217,8 @@ declare global {
217
217
  * - `graphics.TEXTURE_USAGE_FLAG_STORAGE`
218
218
  * - `graphics.TEXTURE_USAGE_FLAG_INPUT`
219
219
  * - `graphics.TEXTURE_USAGE_FLAG_COLOR`
220
+ *
221
+ * Keyed by sampler slot from 1; a slot with no texture has no entry, so iterate with `for (const [slot, info] of textures)`.
220
222
  * @example
221
223
  * ```ts
222
224
  * // Get the textures from a material specified as a resource property
@@ -231,7 +233,7 @@ declare global {
231
233
  * });
232
234
  * ```
233
235
  */
234
- function get_textures(path: Hash | string): { path: Hash; handle: Hash; width: number; height: number; depth: number; mipmaps: number; type: number; flags: number }[];
236
+ function get_textures(path: Hash | string): LuaMap<number, { path: Hash; handle: Hash; width: number; height: number; depth: number; mipmaps: number; type: number; flags: number }>;
235
237
  /**
236
238
  * Returns a table of all the vertex attributes in the material. This function will return all the vertex attributes
237
239
  * that are used in the vertex shader of the material.
@@ -174,7 +174,7 @@ declare global {
174
174
  * });
175
175
  * ```
176
176
  */
177
- function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: go.Playback, play_properties?: { blend_duration?: number; offset?: number; playback_rate?: number }, complete_function?: (self: unknown, message_id: Hash, message: BuiltinMessages["model_animation_done"]) => void): void;
177
+ function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: Exclude<go.Playback, typeof go.PLAYBACK_NONE>, play_properties?: { blend_duration?: number; offset?: number; playback_rate?: number }, complete_function?: (self: unknown, message_id: Hash, message: BuiltinMessages["model_animation_done"]) => void): void;
178
178
  /**
179
179
  * Resets a shader constant for a model component.
180
180
  * The constant must be defined in the material assigned to the model.
@@ -224,7 +224,7 @@ declare global {
224
224
  * ```
225
225
  */
226
226
  function set_mesh_enabled(url: string | Hash | Url, mesh_id: string | Hash, enabled: boolean): void;
227
- interface properties {
227
+ interface Properties {
228
228
  /**
229
229
  * The current animation set on the component. The type of the property is hash.
230
230
  */
@@ -239,37 +239,69 @@ declare global {
239
239
  */
240
240
  playback_rate: number;
241
241
  /**
242
- * The texture hash id of the model. Used for getting/setting model texture for unit 0-7
242
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
243
243
  */
244
244
  texture0: Hash;
245
245
  /**
246
- * The texture hash id of the model. Used for getting/setting model texture for unit 0-7
246
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
247
247
  */
248
248
  texture1: Hash;
249
249
  /**
250
- * The texture hash id of the model. Used for getting/setting model texture for unit 0-7
250
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
251
251
  */
252
252
  texture2: Hash;
253
253
  /**
254
- * The texture hash id of the model. Used for getting/setting model texture for unit 0-7
254
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
255
255
  */
256
256
  texture3: Hash;
257
257
  /**
258
- * The texture hash id of the model. Used for getting/setting model texture for unit 0-7
258
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
259
259
  */
260
260
  texture4: Hash;
261
261
  /**
262
- * The texture hash id of the model. Used for getting/setting model texture for unit 0-7
262
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
263
263
  */
264
264
  texture5: Hash;
265
265
  /**
266
- * The texture hash id of the model. Used for getting/setting model texture for unit 0-7
266
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
267
267
  */
268
268
  texture6: Hash;
269
269
  /**
270
- * The texture hash id of the model. Used for getting/setting model texture for unit 0-7
270
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
271
271
  */
272
272
  texture7: Hash;
273
+ /**
274
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
275
+ */
276
+ texture8: Hash;
277
+ /**
278
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
279
+ */
280
+ texture9: Hash;
281
+ /**
282
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
283
+ */
284
+ texture10: Hash;
285
+ /**
286
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
287
+ */
288
+ texture11: Hash;
289
+ /**
290
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
291
+ */
292
+ texture12: Hash;
293
+ /**
294
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
295
+ */
296
+ texture13: Hash;
297
+ /**
298
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
299
+ */
300
+ texture14: Hash;
301
+ /**
302
+ * The texture hash id of the model, read and written on the texture unit the key's number names (`texture3` is unit 3).
303
+ */
304
+ texture15: Hash;
273
305
  }
274
306
  }
275
307
  }
@@ -134,8 +134,29 @@ declare global {
134
134
  * });
135
135
  * ```
136
136
  */
137
- function stop(url: string | Hash | Url, options?: { clear?: boolean }): void;
138
- interface properties {
137
+ function stop(url: string | Hash | Url): void;
138
+ /**
139
+ * Stops a particle FX component from playing.
140
+ * Stopping a particle FX does not remove already spawned particles.
141
+ * Which particle FX to stop is identified by the URL.
142
+ *
143
+ * @param url - the particle fx that should stop playing
144
+ * @param options - Options when stopping the particle fx. Supported options:
145
+ *
146
+ * - boolean `clear`: instantly clear spawned particles
147
+ * @example
148
+ * ```ts
149
+ * // How to stop a particle fx when a game object is deleted and immediately also
150
+ * // clear any spawned particles:
151
+ * export default defineScript({
152
+ * final(self) {
153
+ * particlefx.stop("#particlefx", { clear: true });
154
+ * },
155
+ * });
156
+ * ```
157
+ */
158
+ function stop(url: string | Hash | Url, options: { clear?: boolean }): void;
159
+ interface Properties {
139
160
  /**
140
161
  * The animation used during rendering by an emitter in a particle FX component.
141
162
  * The property type is a hash and refers to a valid animation in an atlas or a tile source resource.
@@ -269,7 +269,51 @@ declare global {
269
269
  * });
270
270
  * ```
271
271
  */
272
- function raycast_async(from: Vector3, to: Vector3, groups: Hash[], request_id?: number): void;
272
+ function raycast_async(from: Vector3, to: Vector3, groups: Hash[]): void;
273
+ /**
274
+ * Ray casts are used to test for intersections against collision objects in the physics world.
275
+ * Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
276
+ * do not intersect with ray casts.
277
+ * Which collision objects to hit is filtered by their collision groups and can be configured
278
+ * through `groups`.
279
+ * The actual ray cast will be performed during the physics-update.
280
+ *
281
+ * - If an object is hit, the result will be reported via a ray_cast_response message.
282
+ * - If there is no object hit, the result will be reported via a ray_cast_missed message.
283
+ *
284
+ * NOTE: Ray casts will ignore collision objects that contain the starting point of the ray. This is a limitation in Box2D.
285
+ *
286
+ * @param from - the world position of the start of the ray
287
+ * @param to - the world position of the end of the ray
288
+ * @param groups - a lua table containing the hashed groups for which to test collisions against
289
+ * @param request_id - a number in range [0,255]. It will be sent back in the response for identification, 0 by default
290
+ * @example
291
+ * ```ts
292
+ * // How to perform a ray cast asynchronously:
293
+ * export default defineScript({
294
+ * init() {
295
+ * return { my_groups: [hash("my_group1"), hash("my_group2")] };
296
+ * },
297
+ *
298
+ * update(self, dt) {
299
+ * // request ray cast
300
+ * const my_start = go.get_world_position();
301
+ * const my_end = vmath.vector3(my_start.x, my_start.y - 100, my_start.z);
302
+ * physics.raycast_async(my_start, my_end, self.my_groups);
303
+ * },
304
+ *
305
+ * on_message(self, message_id, message, sender) {
306
+ * // check for the response
307
+ * if (message_id === hash("ray_cast_response")) {
308
+ * // act on the hit
309
+ * } else if (message_id === hash("ray_cast_missed")) {
310
+ * // act on the miss
311
+ * }
312
+ * },
313
+ * });
314
+ * ```
315
+ */
316
+ function raycast_async(from: Vector3, to: Vector3, groups: Hash[], request_id: number): void;
273
317
  /**
274
318
  * Only one physics world event listener can be set at a time.
275
319
  *
@@ -526,7 +570,7 @@ declare global {
526
570
  * ```
527
571
  */
528
572
  function wakeup(url: string | Hash | Url): void;
529
- interface properties {
573
+ interface Properties {
530
574
  /**
531
575
  * The angular damping value for the collision object. Setting this value alters the damping of
532
576
  * angular motion of the object (rotation). Valid values are between 0 (no damping) and 1 (full damping).
@@ -6,10 +6,11 @@ declare global {
6
6
  * Rendering API documentation
7
7
  */
8
8
  namespace render {
9
- type constant_buffer = Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> };
10
- type render_target = Opaque<"render_target">;
11
- type texture = Opaque<"texture">;
9
+ type ConstantBuffer = Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> };
10
+ type RenderTarget = Opaque<"render_target">;
11
+ type Texture = Opaque<"texture">;
12
12
  type ClearBufferKey = typeof graphics.BUFFER_TYPE_COLOR0_BIT | typeof graphics.BUFFER_TYPE_DEPTH_BIT | typeof graphics.BUFFER_TYPE_STENCIL_BIT;
13
+ type RenderTargetTextureType = typeof graphics.TEXTURE_TYPE_2D | typeof graphics.TEXTURE_TYPE_CUBE_MAP;
13
14
  type RenderTargetParams = Record<string | number, unknown>;
14
15
  /**
15
16
  * The rendering context was lost. Rendering is paused and all graphics resources become invalid. Passed to the `render.set_listener` callback.
@@ -177,7 +178,7 @@ declare global {
177
178
  * });
178
179
  * ```
179
180
  */
180
- function disable_state(state: graphics.State): void;
181
+ function disable_state(state: Exclude<graphics.State, typeof graphics.STATE_ALPHA_TEST_SUPPORTED | typeof graphics.STATE_SCISSOR_TEST>): void;
181
182
  /**
182
183
  * Disables a texture that has previourly been enabled.
183
184
  *
@@ -212,7 +213,7 @@ declare global {
212
213
  * });
213
214
  * ```
214
215
  */
215
- function disable_texture(binding: Opaque<"texture"> | string | Hash | number): void;
216
+ function disable_texture(binding: string | Hash | number): void;
216
217
  /**
217
218
  * Dispatches the currently enabled compute program. The dispatch call takes three arguments x,y,z which constitutes
218
219
  * the 'global working group' of the compute dispatch. Together with the 'local working group' specified in the compute shader
@@ -325,7 +326,69 @@ declare global {
325
326
  * }
326
327
  * ```
327
328
  */
328
- function draw(predicate: Opaque<"render_predicate">, options?: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> }; sort_order?: number }): void;
329
+ function draw(predicate: Opaque<"render_predicate">): void;
330
+ /**
331
+ * Draws all objects that match a specified predicate. An optional constant buffer can be
332
+ * provided to override the default constants. If no constants buffer is provided, a default
333
+ * system constants buffer is used containing constants as defined in materials and set through
334
+ * go.set (or particlefx.set_constant) on visual components.
335
+ *
336
+ * @param predicate - predicate to draw for
337
+ * @param options - optional table with properties:
338
+ *
339
+ * `frustum`
340
+ * matrix4 A frustum matrix used to cull renderable items. (E.g. `local frustum = proj * view`). default=nil
341
+ * `frustum_planes`
342
+ * int Determines which sides of the frustum will be used. Default is render.FRUSTUM_PLANES_SIDES.
343
+ *
344
+ * - render.FRUSTUM_PLANES_SIDES : The left, right, top and bottom sides of the frustum.
345
+ * - render.FRUSTUM_PLANES_ALL : All 6 sides of the frustum.
346
+ *
347
+ * `constants`
348
+ * constant_buffer optional constants to use while rendering
349
+ * `sort_order`
350
+ * int How to sort draw order for world-ordered entries. Default uses the renderer's preferred world sorting (back-to-front).
351
+ * @example
352
+ * ```ts
353
+ * export default defineRenderScript({
354
+ * init() {
355
+ * // define a predicate matching anything with material tag "my_tag"
356
+ * return { my_pred: render.predicate([hash("my_tag")]) };
357
+ * },
358
+ *
359
+ * update(self, dt) {
360
+ * // draw everything in the my_pred predicate
361
+ * render.draw(self.my_pred);
362
+ * },
363
+ * });
364
+ * ```
365
+ * @example
366
+ * Draw predicate with constants:
367
+ * ```ts
368
+ * function draw_tinted(self: { my_pred: Opaque<"render_predicate"> }) {
369
+ * const constants = render.constant_buffer();
370
+ * constants.tint = vmath.vector4(1, 1, 1, 1);
371
+ * render.draw(self.my_pred, { constants });
372
+ * }
373
+ * ```
374
+ * @example
375
+ * Draw with predicate and frustum culling (without near+far planes):
376
+ * ```ts
377
+ * function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
378
+ * const frustum = self.proj.mul(self.view);
379
+ * render.draw(self.my_pred, { frustum });
380
+ * }
381
+ * ```
382
+ * @example
383
+ * Draw with predicate and frustum culling (with near+far planes):
384
+ * ```ts
385
+ * function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
386
+ * const frustum = self.proj.mul(self.view);
387
+ * render.draw(self.my_pred, { frustum, frustum_planes: render.FRUSTUM_PLANES_ALL });
388
+ * }
389
+ * ```
390
+ */
391
+ function draw(predicate: Opaque<"render_predicate">, options: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> }; sort_order?: number }): void;
329
392
  /**
330
393
  * Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.
331
394
  *
@@ -400,7 +463,7 @@ declare global {
400
463
  * });
401
464
  * ```
402
465
  */
403
- function enable_state(state: graphics.State): void;
466
+ function enable_state(state: Exclude<graphics.State, typeof graphics.STATE_ALPHA_TEST_SUPPORTED | typeof graphics.STATE_SCISSOR_TEST>): void;
404
467
  /**
405
468
  * Sets the specified texture handle for a render target attachment or a regular texture
406
469
  * that should be used for rendering. The texture can be bound to either a texture unit
@@ -762,7 +825,7 @@ declare global {
762
825
  * render.set_blend_func_separate(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, graphics.BLEND_FACTOR_ONE, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
763
826
  * ```
764
827
  */
765
- function set_blend_func_separate(source_factor_color: number, destination_factor_color: number, source_factor_alpha: number, destination_factor_alpha: number): void;
828
+ function set_blend_func_separate(source_factor_color: graphics.BlendFactor, destination_factor_color: graphics.BlendFactor, source_factor_alpha: graphics.BlendFactor, destination_factor_alpha: graphics.BlendFactor): void;
766
829
  /**
767
830
  * Sets the current render camera to be used for rendering. If a render camera
768
831
  * has been set by the render script, the renderer will be using its projection and view matrix
@@ -1043,7 +1106,82 @@ declare global {
1043
1106
  * });
1044
1107
  * ```
1045
1108
  */
1046
- function set_render_target(render_target?: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT, options?: { transient?: graphics.BufferType[] }): void;
1109
+ function set_render_target(render_target?: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT): void;
1110
+ /**
1111
+ * Sets a render target. Subsequent draw operations will be to the
1112
+ * render target until it is replaced by a subsequent call to set_render_target.
1113
+ * This function supports render targets created by a render script, or a render target resource.
1114
+ *
1115
+ * @param render_target - render target to set. render.RENDER_TARGET_DEFAULT to set the default render target
1116
+ * @param options - optional table with behaviour parameters
1117
+ *
1118
+ * `transient`
1119
+ * table Transient frame buffer types are only valid while the render target is active, i.e becomes undefined when a new target is set by a subsequent call to set_render_target.
1120
+ * Default is all non-transient. Be aware that some hardware uses a combined depth stencil buffer and when this is the case both are considered non-transient if exclusively selected!
1121
+ * A buffer type defined that doesn't exist in the render target is silently ignored.
1122
+ *
1123
+ * - `graphics.BUFFER_TYPE_COLOR0_BIT`
1124
+ * - `graphics.BUFFER_TYPE_DEPTH_BIT`
1125
+ * - `graphics.BUFFER_TYPE_STENCIL_BIT`
1126
+ * @example
1127
+ * How to set a render target and draw to it and then switch back to the default render target
1128
+ * The render target defines the depth/stencil buffers as transient, when set_render_target is called the next time the buffers may be invalidated and allow for optimisations depending on driver support
1129
+ * ```ts
1130
+ * // How to set a render target and draw to it and then switch back to the default render target
1131
+ * // The render target defines the depth/stencil buffers as transient, when set_render_target is called the next time the buffers may be invalidated and allow for optimisations depending on driver support
1132
+ * export default defineRenderScript({
1133
+ * init() {
1134
+ * // the engine registers a texture format only when the driver supports it
1135
+ * const format = graphics.TEXTURE_FORMAT_RGBA;
1136
+ * if (format === undefined) return undefined;
1137
+ * const color_params = {
1138
+ * format,
1139
+ * width: render.get_window_width(),
1140
+ * height: render.get_window_height(),
1141
+ * };
1142
+ * return {
1143
+ * my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
1144
+ * my_pred: render.predicate([hash("my_tag")]),
1145
+ * };
1146
+ * },
1147
+ *
1148
+ * update(self, dt) {
1149
+ * if (self === undefined) return;
1150
+ * // set render target so all drawing is done to it
1151
+ * render.set_render_target(self.my_render_target, {
1152
+ * transient: [graphics.BUFFER_TYPE_DEPTH_BIT, graphics.BUFFER_TYPE_STENCIL_BIT],
1153
+ * });
1154
+ *
1155
+ * // draw a predicate to the render target
1156
+ * render.draw(self.my_pred);
1157
+ *
1158
+ * // set default render target. This also invalidates the depth and stencil buffers of the current target (self.my_render_target)
1159
+ * // which can be an optimisation on some hardware
1160
+ * render.set_render_target(render.RENDER_TARGET_DEFAULT);
1161
+ * },
1162
+ * });
1163
+ * ```
1164
+ * @example
1165
+ * ```ts
1166
+ * export default defineRenderScript({
1167
+ * init() {
1168
+ * return { my_pred: render.predicate([hash("my_tag")]) };
1169
+ * },
1170
+ *
1171
+ * update(self, dt) {
1172
+ * // set render target by a render target resource identifier
1173
+ * render.set_render_target("my_rt_resource");
1174
+ *
1175
+ * // draw a predicate to the render target
1176
+ * render.draw(self.my_pred);
1177
+ *
1178
+ * // reset the render target to the default backbuffer
1179
+ * render.set_render_target(render.RENDER_TARGET_DEFAULT);
1180
+ * },
1181
+ * });
1182
+ * ```
1183
+ */
1184
+ function set_render_target(render_target: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT | undefined, options: { transient?: graphics.BufferType[] }): void;
1047
1185
  /**
1048
1186
  * Sets the render target size for a render target created from
1049
1187
  * either a render script, or from a render target resource.