@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
@@ -0,0 +1,1232 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Opaque } from "../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions and constants to access resources.
7
+ */
8
+ namespace resource {
9
+ /**
10
+ * Animation data accepted when creating or updating an atlas. Specify either
11
+ * `frames`, or both `frame_start` and `frame_end`.
12
+ */
13
+ interface Animation {
14
+ /**
15
+ * Animation id.
16
+ */
17
+ id: string;
18
+ /**
19
+ * Animation width.
20
+ */
21
+ width: number;
22
+ /**
23
+ * Animation height.
24
+ */
25
+ height: number;
26
+ /**
27
+ * Geometry indices for the animation frames.
28
+ */
29
+ frames?: number[];
30
+ /**
31
+ * First geometry index for the legacy contiguous frame range.
32
+ */
33
+ frame_start?: number;
34
+ /**
35
+ * Non-inclusive last geometry index for the legacy contiguous frame range.
36
+ */
37
+ frame_end?: number;
38
+ /**
39
+ * Playback mode. The default is `go.PLAYBACK_ONCE_FORWARD`.
40
+ */
41
+ playback?: go.Playback;
42
+ /**
43
+ * Animation frame rate. The default is 30.
44
+ */
45
+ fps?: number;
46
+ /**
47
+ * Whether to flip the animation vertically. The default is false.
48
+ */
49
+ flip_vertical?: boolean;
50
+ /**
51
+ * Whether to flip the animation horizontally. The default is false.
52
+ */
53
+ flip_horizontal?: boolean;
54
+ }
55
+ /**
56
+ * Animation data returned by resource.get_atlas.
57
+ */
58
+ interface AnimationData {
59
+ /**
60
+ * Animation id.
61
+ */
62
+ id: string;
63
+ /**
64
+ * Animation width.
65
+ */
66
+ width: number;
67
+ /**
68
+ * Animation height.
69
+ */
70
+ height: number;
71
+ /**
72
+ * Geometry indices for the animation frames.
73
+ */
74
+ frames: number[];
75
+ /**
76
+ * Playback mode.
77
+ */
78
+ playback: go.Playback;
79
+ /**
80
+ * Animation frame rate.
81
+ */
82
+ fps: number;
83
+ /**
84
+ * Whether the animation is flipped vertically.
85
+ */
86
+ flip_vertical: boolean;
87
+ /**
88
+ * Whether the animation is flipped horizontally.
89
+ */
90
+ flip_horizontal: boolean;
91
+ }
92
+ /**
93
+ * Data accepted by resource.create_atlas and resource.set_atlas.
94
+ */
95
+ interface Atlas {
96
+ /**
97
+ * Path to the texture resource, for example `"/main/my_texture.texturec"`.
98
+ */
99
+ texture: string | Hash;
100
+ /**
101
+ * Animations in the atlas.
102
+ */
103
+ animations: [Omit<resource.Animation, "frame_start" | "frame_end"> & ({ frames: [number, ...number[]] } | { frame_start: number; frame_end: number }), ...(Omit<resource.Animation, "frame_start" | "frame_end"> & ({ frames: [number, ...number[]] } | { frame_start: number; frame_end: number }))[]];
104
+ /**
105
+ * Geometries that map to the texture data.
106
+ */
107
+ geometries: [resource.Geometry, ...resource.Geometry[]];
108
+ }
109
+ /**
110
+ * Data returned by resource.get_atlas.
111
+ */
112
+ interface AtlasData {
113
+ /**
114
+ * Path to the texture resource.
115
+ */
116
+ texture: string | Hash;
117
+ /**
118
+ * Animations in the atlas.
119
+ */
120
+ animations: resource.AnimationData[];
121
+ /**
122
+ * Geometries that map to the texture data.
123
+ */
124
+ geometries: resource.GeometryData[];
125
+ }
126
+ /**
127
+ * Buffer-resource creation parameters
128
+ */
129
+ interface BufferCreationParams {
130
+ /**
131
+ * Buffer to bind to the resource.
132
+ */
133
+ buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> };
134
+ /**
135
+ * Whether the resource takes ownership of the buffer. The default is true.
136
+ */
137
+ transfer_ownership?: boolean;
138
+ }
139
+ /**
140
+ * Buffer-resource update options
141
+ */
142
+ interface BufferUpdateOptions {
143
+ /**
144
+ * Whether the resource takes ownership of the buffer. The default is false.
145
+ */
146
+ transfer_ownership?: boolean;
147
+ }
148
+ /**
149
+ * Geometry data accepted when creating or updating an atlas. Vertex, UV, and
150
+ * index values are zero-based.
151
+ */
152
+ interface Geometry {
153
+ /**
154
+ * Geometry name, used when matching animations between atlases.
155
+ */
156
+ id?: string;
157
+ /**
158
+ * Width of the image represented by the geometry. If omitted, it is calculated from the vertices.
159
+ */
160
+ width?: number;
161
+ /**
162
+ * Height of the image represented by the geometry. If omitted, it is calculated from the vertices.
163
+ */
164
+ height?: number;
165
+ /**
166
+ * Horizontal pivot in unit coordinates. The default is 0.5.
167
+ */
168
+ pivot_x?: number;
169
+ /**
170
+ * Vertical pivot in unit coordinates. The default is 0.5.
171
+ */
172
+ pivot_y?: number;
173
+ /**
174
+ * Whether the image is rotated 90 degrees counter-clockwise in the atlas.
175
+ */
176
+ rotated?: boolean;
177
+ /**
178
+ * Vertex coordinates in image space as `{px0, py0, px1, py1, ...}`.
179
+ */
180
+ vertices: number[];
181
+ /**
182
+ * UV coordinates in image space as `{u0, v0, u1, v1, ...}`.
183
+ */
184
+ uvs: number[];
185
+ /**
186
+ * Geometry indices where each group of three entries represents a triangle.
187
+ */
188
+ indices: number[];
189
+ }
190
+ /**
191
+ * Geometry data returned by resource.get_atlas.
192
+ */
193
+ interface GeometryData {
194
+ /**
195
+ * Width of the image represented by the geometry.
196
+ */
197
+ width: number;
198
+ /**
199
+ * Height of the image represented by the geometry.
200
+ */
201
+ height: number;
202
+ /**
203
+ * Horizontal pivot in unit coordinates.
204
+ */
205
+ pivot_x: number;
206
+ /**
207
+ * Vertical pivot in unit coordinates.
208
+ */
209
+ pivot_y: number;
210
+ /**
211
+ * Whether the image is rotated 90 degrees counter-clockwise in the atlas.
212
+ */
213
+ rotated: boolean;
214
+ /**
215
+ * Vertex coordinates in image space as `{px0, py0, px1, py1, ...}`.
216
+ */
217
+ vertices: number[];
218
+ /**
219
+ * UV coordinates in image space as `{u0, v0, u1, v1, ...}`.
220
+ */
221
+ uvs: number[];
222
+ /**
223
+ * Geometry indices where each group of three entries represents a triangle.
224
+ */
225
+ indices: number[];
226
+ }
227
+ /**
228
+ * Render target attachment information
229
+ */
230
+ interface RenderTargetAttachmentInfo {
231
+ /**
232
+ * Opaque texture handle.
233
+ */
234
+ handle: Opaque<"texture">;
235
+ /**
236
+ * Texture width.
237
+ */
238
+ width: number;
239
+ /**
240
+ * Texture height.
241
+ */
242
+ height: number;
243
+ /**
244
+ * Texture depth or layer count.
245
+ */
246
+ depth: number;
247
+ /**
248
+ * Texture page count.
249
+ */
250
+ page_count: number;
251
+ /**
252
+ * Number of mipmaps.
253
+ */
254
+ mipmaps: number;
255
+ /**
256
+ * Texture usage flags.
257
+ */
258
+ flags: graphics.TextureUsageFlag | number;
259
+ /**
260
+ * Texture type.
261
+ */
262
+ type: graphics.TextureType;
263
+ /**
264
+ * Render-target buffer type.
265
+ */
266
+ buffer_type: graphics.BufferType;
267
+ /**
268
+ * Backing texture resource, when present.
269
+ */
270
+ texture?: Hash;
271
+ }
272
+ /**
273
+ * Render target information
274
+ */
275
+ interface RenderTargetInfo {
276
+ /**
277
+ * Opaque render-target handle.
278
+ */
279
+ handle: Opaque<"render_target">;
280
+ /**
281
+ * Effective sample count shared by all render-target attachments.
282
+ */
283
+ sample_count: number;
284
+ /**
285
+ * Render-target attachments.
286
+ */
287
+ attachments: resource.RenderTargetAttachmentInfo[];
288
+ }
289
+ /**
290
+ * Sound-data creation options
291
+ */
292
+ interface SoundDataOptions {
293
+ /**
294
+ * Raw sound file data, including the file header.
295
+ */
296
+ data: string | Opaque<"buffer">;
297
+ /**
298
+ * Complete file size when `data` is partial.
299
+ */
300
+ filesize?: number;
301
+ /**
302
+ * Whether `data` contains only the initial file chunk.
303
+ */
304
+ partial?: boolean;
305
+ }
306
+ /**
307
+ * Text metrics
308
+ */
309
+ interface TextMetrics {
310
+ /**
311
+ * Text width.
312
+ */
313
+ width: number;
314
+ /**
315
+ * Text height.
316
+ */
317
+ height: number;
318
+ /**
319
+ * Maximum ascent.
320
+ */
321
+ max_ascent: number;
322
+ /**
323
+ * Maximum descent.
324
+ */
325
+ max_descent: number;
326
+ }
327
+ /**
328
+ * Text metric options
329
+ */
330
+ interface TextMetricsOptions {
331
+ /**
332
+ * Text-field width; unused when `line_break` is false.
333
+ */
334
+ width?: number;
335
+ /**
336
+ * Line leading. The default is 1.
337
+ */
338
+ leading?: number;
339
+ /**
340
+ * Character tracking. The default is 0.
341
+ */
342
+ tracking?: number;
343
+ /**
344
+ * Whether to account for line breaks. The default is false.
345
+ */
346
+ line_break?: boolean;
347
+ }
348
+ /**
349
+ * Texture creation parameters
350
+ */
351
+ interface TextureCreationParams {
352
+ /**
353
+ * Texture type.
354
+ */
355
+ type: graphics.TextureType;
356
+ /**
357
+ * Texture width in pixels; must be greater than zero.
358
+ */
359
+ width: number;
360
+ /**
361
+ * Texture height in pixels; must be greater than zero.
362
+ */
363
+ height: number;
364
+ /**
365
+ * Texture depth; used by 3D texture types and must be greater than zero.
366
+ */
367
+ depth?: number;
368
+ /**
369
+ * Number of pages for a 2D array texture.
370
+ */
371
+ page_count?: number;
372
+ /**
373
+ * Texture format. Device-specific unsupported constants evaluate to `nil`.
374
+ */
375
+ format: graphics.TextureFormat;
376
+ /**
377
+ * Creation-usage hints. The default is graphics.TEXTURE_USAGE_FLAG_SAMPLE.
378
+ */
379
+ flags?: graphics.TextureUsageFlag | number;
380
+ /**
381
+ * Maximum mipmap count. The default is zero.
382
+ */
383
+ max_mipmaps?: number;
384
+ /**
385
+ * Compression used by the supplied buffer. The default is graphics.COMPRESSION_TYPE_DEFAULT.
386
+ */
387
+ compression_type?: graphics.CompressionType;
388
+ }
389
+ /**
390
+ * Asynchronous texture creation result
391
+ */
392
+ interface TextureCreationResult {
393
+ /**
394
+ * Created texture resource path.
395
+ */
396
+ path: Hash;
397
+ }
398
+ /**
399
+ * Texture information
400
+ */
401
+ interface TextureInfo {
402
+ /**
403
+ * Opaque texture handle.
404
+ */
405
+ handle: Opaque<"texture">;
406
+ /**
407
+ * Texture width.
408
+ */
409
+ width: number;
410
+ /**
411
+ * Texture height.
412
+ */
413
+ height: number;
414
+ /**
415
+ * Texture depth or layer count.
416
+ */
417
+ depth: number;
418
+ /**
419
+ * Texture page count.
420
+ */
421
+ page_count: number;
422
+ /**
423
+ * Number of mipmaps.
424
+ */
425
+ mipmaps: number;
426
+ /**
427
+ * Texture usage flags.
428
+ */
429
+ flags: graphics.TextureUsageFlag | number;
430
+ /**
431
+ * Texture type.
432
+ */
433
+ type: graphics.TextureType;
434
+ }
435
+ /**
436
+ * Texture update parameters
437
+ */
438
+ interface TextureUpdateParams {
439
+ /**
440
+ * Texture type.
441
+ */
442
+ type: graphics.TextureType;
443
+ /**
444
+ * Update width in pixels.
445
+ */
446
+ width: number;
447
+ /**
448
+ * Update height in pixels.
449
+ */
450
+ height: number;
451
+ /**
452
+ * Update depth for a 3D texture.
453
+ */
454
+ depth?: number;
455
+ /**
456
+ * Texture format. Device-specific unsupported constants evaluate to `nil`.
457
+ */
458
+ format: graphics.TextureFormat;
459
+ /**
460
+ * X offset in pixels.
461
+ */
462
+ x?: number;
463
+ /**
464
+ * Y offset in pixels.
465
+ */
466
+ y?: number;
467
+ /**
468
+ * Z offset for a 3D texture.
469
+ */
470
+ z?: number;
471
+ /**
472
+ * Zero-based page of a 2D array texture.
473
+ */
474
+ page?: number;
475
+ /**
476
+ * Mipmap level to update.
477
+ */
478
+ mipmap?: number;
479
+ /**
480
+ * Compression used by the supplied buffer. The default is graphics.COMPRESSION_TYPE_DEFAULT.
481
+ */
482
+ compression_type?: graphics.CompressionType;
483
+ }
484
+ /**
485
+ * Constructor-like function with two purposes:
486
+ *
487
+ * - Load the specified resource as part of loading the script
488
+ * - Create a resource reference that resolves to the hashed path of the run-time resource
489
+ *
490
+ * This function can only be called within go.property function calls.
491
+ *
492
+ * @param path - optional resource path string to the resource
493
+ * @returns a reference to the binary version of the resource
494
+ * @example
495
+ * Load an atlas and set it to a sprite:
496
+ * ```ts
497
+ * // Load an atlas and set it to a sprite:
498
+ * export default defineScript({
499
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
500
+ * // registration from this field, and only this field types the property onto `self`.
501
+ * properties: { my_atlas: resource.atlas("/atlas.atlas") },
502
+ *
503
+ * init(self) {
504
+ * go.set("#sprite", "image", self.my_atlas);
505
+ * },
506
+ * });
507
+ * ```
508
+ * @example
509
+ * Load an atlas and set it to a gui:
510
+ * ```ts
511
+ * // Load an atlas and set it to a gui:
512
+ * export default defineScript({
513
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
514
+ * // registration from this field, and only this field types the property onto `self`.
515
+ * properties: { my_atlas: resource.atlas("/atlas.atlas") },
516
+ *
517
+ * init(self) {
518
+ * go.set("#gui", "textures", self.my_atlas, { key: "my_atlas" });
519
+ * },
520
+ * });
521
+ * ```
522
+ */
523
+ function atlas(path?: string): Hash;
524
+ /**
525
+ * Constructor-like function with two purposes:
526
+ *
527
+ * - Load the specified resource as part of loading the script
528
+ * - Create a resource reference that resolves to the hashed path of the run-time resource
529
+ *
530
+ * This function can only be called within go.property function calls.
531
+ *
532
+ * @param path - optional resource path string to the resource
533
+ * @returns a reference to the binary version of the resource
534
+ * @example
535
+ * ```ts
536
+ * // Set a unique buffer it to a sprite:
537
+ * export default defineScript({
538
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
539
+ * // registration from this field, and only this field types the property onto `self`.
540
+ * properties: { my_buffer: resource.buffer("/cube.buffer") },
541
+ *
542
+ * init(self) {
543
+ * go.set("#mesh", "vertices", self.my_buffer);
544
+ * },
545
+ * });
546
+ * ```
547
+ */
548
+ function buffer(path?: string): Hash;
549
+ /**
550
+ * Constructor-like function with two purposes:
551
+ *
552
+ * - Load the specified resource as part of loading the script
553
+ * - Create a resource reference that resolves to the hashed path of the run-time resource
554
+ *
555
+ * This function can only be called within go.property function calls.
556
+ *
557
+ * @param path - optional resource path string to the resource
558
+ * @returns a reference to the binary version of the resource
559
+ * @example
560
+ * Load a font and set it to a label:
561
+ * ```ts
562
+ * // Load a font and set it to a label:
563
+ * export default defineScript({
564
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
565
+ * // registration from this field, and only this field types the property onto `self`.
566
+ * properties: { my_font: resource.font("/font.font") },
567
+ *
568
+ * init(self) {
569
+ * go.set("#label", "font", self.my_font);
570
+ * },
571
+ * });
572
+ * ```
573
+ * @example
574
+ * Load a font and set it to a gui:
575
+ * ```ts
576
+ * // Load a font and set it to a gui:
577
+ * export default defineScript({
578
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
579
+ * // registration from this field, and only this field types the property onto `self`.
580
+ * properties: { my_font: resource.font("/font.font") },
581
+ *
582
+ * init(self) {
583
+ * go.set("#gui", "fonts", self.my_font, { key: "my_font" });
584
+ * },
585
+ * });
586
+ * ```
587
+ */
588
+ function font(path?: string): Hash;
589
+ /**
590
+ * Returns the atlas data for an atlas
591
+ *
592
+ * @param path - The path to the atlas resource
593
+ * @returns atlas data. **⚠️ `frames` is 1-based; passed to Defold unchanged.** **0️⃣ `indices` is 0-based; passed to Defold unchanged.**
594
+ */
595
+ function get_atlas(path: Hash | string): resource.AtlasData;
596
+ /**
597
+ * gets the buffer from a resource
598
+ *
599
+ * @param path - The path to the resource
600
+ * @returns The resource buffer
601
+ * @example
602
+ * ```ts
603
+ * // How to get the data from a buffer
604
+ * export default defineScript({
605
+ * init() {
606
+ * const res_path = go.get<mesh.Properties>()("#mesh", "vertices");
607
+ * const buf = resource.get_buffer(res_path);
608
+ * const stream_positions = buffer.get_stream(buf, "position");
609
+ *
610
+ * for (let i = 0; i < stream_positions.length(); i++) {
611
+ * print(i, stream_positions[i]);
612
+ * }
613
+ * },
614
+ * });
615
+ * ```
616
+ */
617
+ function get_buffer(path: Hash | string): Opaque<"buffer"> & { length: LuaLengthMethod<number> };
618
+ /**
619
+ * Gets render target info from a render target resource path or a render target handle
620
+ *
621
+ * @param path - The path to the resource or a render target handle
622
+ * @returns render-target information
623
+ * @example
624
+ * Get the metadata from a render target resource
625
+ * ```ts
626
+ * // Get the metadata from a render target resource
627
+ * export default defineScript({
628
+ * init() {
629
+ * const info = resource.get_render_target_info("/my_render_target.render_targetc");
630
+ * // the info table contains meta data about all the render target attachments
631
+ * // so it's not necessary to use resource.get_texture here, but we do it here
632
+ * // just to show that it's possible:
633
+ * const info_attachment_1 = resource.get_texture_info(info.attachments[0]!.handle);
634
+ * },
635
+ * });
636
+ * ```
637
+ * @example
638
+ * Get a texture attachment from a render target and set it on a model component
639
+ * ```ts
640
+ * // Get a texture attachment from a render target and set it on a model component
641
+ * export default defineScript({
642
+ * init() {
643
+ * const info = resource.get_render_target_info("/my_render_target.render_targetc");
644
+ * const attachment = info.attachments[0]!.texture!;
645
+ * // you can also get texture info from the 'texture' field, since it's a resource hash
646
+ * const texture_info = resource.get_texture_info(attachment);
647
+ * go.set("#model", "texture0", attachment);
648
+ * },
649
+ * });
650
+ * ```
651
+ */
652
+ function get_render_target_info(path: Hash | string | Opaque<"render_target"> | number): resource.RenderTargetInfo;
653
+ /**
654
+ * Gets the text metrics from a font. Rich text markup is measured using its
655
+ * visible text and font sizes. If markup cannot be parsed, the text is measured literally.
656
+ * Inline sprites reserve their specified dimensions, or one em by default.
657
+ *
658
+ * @param url - the font to get the (unscaled) metrics from
659
+ * @param text - text to measure
660
+ * @param options - optional text-metric options
661
+ * @returns measured text metrics
662
+ * @example
663
+ * ```ts
664
+ * export default defineScript({
665
+ * init() {
666
+ * const font = go.get<label.Properties>()("#label", "font");
667
+ * const metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog");
668
+ * pprint(metrics);
669
+ * },
670
+ * });
671
+ * ```
672
+ */
673
+ function get_text_metrics(url: Hash | string, text: string): resource.TextMetrics;
674
+ /**
675
+ * Gets the text metrics from a font. Rich text markup is measured using its
676
+ * visible text and font sizes. If markup cannot be parsed, the text is measured literally.
677
+ * Inline sprites reserve their specified dimensions, or one em by default.
678
+ *
679
+ * @param url - the font to get the (unscaled) metrics from
680
+ * @param text - text to measure
681
+ * @param options - optional text-metric options
682
+ * @returns measured text metrics
683
+ * @example
684
+ * ```ts
685
+ * export default defineScript({
686
+ * init() {
687
+ * const font = go.get<label.Properties>()("#label", "font");
688
+ * const metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog");
689
+ * pprint(metrics);
690
+ * },
691
+ * });
692
+ * ```
693
+ */
694
+ function get_text_metrics(url: Hash | string, text: string, options: resource.TextMetricsOptions): resource.TextMetrics;
695
+ /**
696
+ * Gets texture info from a texture resource path or a texture handle
697
+ *
698
+ * @param path - The path to the resource or a texture handle
699
+ * @returns texture information
700
+ * @example
701
+ * Create a new texture and get the metadata from it
702
+ * ```ts
703
+ * // Create a new texture and get the metadata from it
704
+ * export default defineScript({
705
+ * init() {
706
+ * // the engine registers a texture format only when the driver supports it
707
+ * const format = graphics.TEXTURE_FORMAT_RGBA;
708
+ * if (format === undefined) return;
709
+ * // create an empty texture
710
+ * const tparams = {
711
+ * width: 128,
712
+ * height: 128,
713
+ * type: graphics.TEXTURE_TYPE_2D,
714
+ * format,
715
+ * };
716
+ *
717
+ * const my_texture_path = resource.create_texture("/my_texture.texturec", tparams);
718
+ * const my_texture_info = resource.get_texture_info(my_texture_path);
719
+ *
720
+ * // my_texture_info now contains
721
+ * // {
722
+ * // handle = <the-numeric-handle>,
723
+ * // width = 128,
724
+ * // height = 128,
725
+ * // depth = 1
726
+ * // mipmaps = 1,
727
+ * // page_count = 1,
728
+ * // type = graphics.TEXTURE_TYPE_2D,
729
+ * // flags = graphics.TEXTURE_USAGE_FLAG_SAMPLE
730
+ * // }
731
+ * },
732
+ * });
733
+ * ```
734
+ * @example
735
+ * Get the meta data from an atlas resource
736
+ * ```ts
737
+ * // Get the meta data from an atlas resource
738
+ * export default defineScript({
739
+ * init() {
740
+ * const my_atlas_info = resource.get_atlas("/my_atlas.a.texturesetc");
741
+ * const my_texture_info = resource.get_texture_info(my_atlas_info.texture);
742
+ *
743
+ * // my_texture_info now contains the information about the texture that is backing the atlas
744
+ * },
745
+ * });
746
+ * ```
747
+ */
748
+ function get_texture_info(path: Hash | string | Opaque<"texture"> | number): resource.TextureInfo;
749
+ /**
750
+ * Loads the resource data for a specific resource.
751
+ *
752
+ * @param path - The path to the resource
753
+ * @returns Returns the buffer stored on disc
754
+ * @example
755
+ * ```ts
756
+ * // read custom resource data into buffer
757
+ * const buffer = resource.load("/resources/datafile");
758
+ * ```
759
+ * @example
760
+ * In order for the engine to include custom resources in the build process, you need
761
+ * to specify them in the "game.project" settings file:
762
+ * ```ts
763
+ * // [project]
764
+ * // title = My project
765
+ * // version = 0.1
766
+ * // custom_resources = resources/,assets/level_data.json
767
+ * ```
768
+ */
769
+ function load(path: string): Opaque<"buffer"> & { length: LuaLengthMethod<number> };
770
+ /**
771
+ * Constructor-like function with two purposes:
772
+ *
773
+ * - Load the specified resource as part of loading the script
774
+ * - Create a resource reference that resolves to the hashed path of the run-time resource
775
+ *
776
+ * This function can only be called within go.property function calls.
777
+ *
778
+ * @param path - optional resource path string to the resource
779
+ * @returns a reference to the binary version of the resource
780
+ * @example
781
+ * Load a material and set it to a sprite:
782
+ * ```ts
783
+ * // Load a material and set it to a sprite:
784
+ * export default defineScript({
785
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
786
+ * // registration from this field, and only this field types the property onto `self`.
787
+ * properties: { my_material: resource.material("/material.material") },
788
+ *
789
+ * init(self) {
790
+ * go.set("#sprite", "material", self.my_material);
791
+ * },
792
+ * });
793
+ * ```
794
+ * @example
795
+ * Load a material resource and update a named material with the resource:
796
+ * ```ts
797
+ * // Load a material resource and update a named material with the resource:
798
+ * export default defineScript({
799
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
800
+ * // registration from this field, and only this field types the property onto `self`.
801
+ * properties: { my_material: resource.material("/material.material") },
802
+ *
803
+ * init(self) {
804
+ * go.set("#gui", "materials", self.my_material, { key: "my_material" });
805
+ * },
806
+ * });
807
+ * ```
808
+ */
809
+ function material(path?: string): Hash;
810
+ /**
811
+ * Constructor-like function with two purposes:
812
+ *
813
+ * - Load the specified resource as part of loading the script
814
+ * - Create a resource reference that resolves to the hashed path of the run-time resource
815
+ *
816
+ * This function can only be called within go.property function calls.
817
+ *
818
+ * @param path - optional resource path string to the resource
819
+ * @returns a reference to the binary version of the resource
820
+ * @example
821
+ * ```ts
822
+ * // Set a render target color attachment as a model texture:
823
+ * export default defineScript({
824
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
825
+ * // registration from this field, and only this field types the property onto `self`.
826
+ * properties: { my_render_target: resource.render_target("/rt.render_target") },
827
+ *
828
+ * init(self) {
829
+ * const rt_info = resource.get_render_target_info(self.my_render_target);
830
+ * go.set("#model", "texture0", rt_info.attachments[0]!.texture!);
831
+ * },
832
+ * });
833
+ * ```
834
+ */
835
+ function render_target(path?: string): Hash;
836
+ /**
837
+ * Sets the resource data for a specific resource
838
+ *
839
+ * @param path - The path to the resource
840
+ * @param buffer - The buffer of precreated data, suitable for the intended resource type
841
+ * @example
842
+ * ```ts
843
+ * // Assuming the folder "/res" is added to the project custom resources:
844
+ * // load a texture resource and set it on a sprite
845
+ * const buffer = resource.load("/res/new.texturec");
846
+ * resource.set(go.get<sprite.Properties>()("#sprite", "texture0"), buffer);
847
+ * ```
848
+ */
849
+ function set(path: string | Hash, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }): void;
850
+ /**
851
+ * Sets the data for a specific atlas resource. Setting new atlas data is specified by passing in
852
+ * a texture path for the backing texture of the atlas, a list of geometries and a list of animations
853
+ * that map to the entries in the geometry list. The geometry entries are represented by three lists:
854
+ * vertices, uvs and indices that together represent triangles that are used in other parts of the
855
+ * engine to produce render objects from.
856
+ * Vertex and uv coordinates for the geometries are expected to be
857
+ * in pixel coordinates where 0,0 is the top left corner of the texture.
858
+ * There is no automatic padding or margin support when setting custom data,
859
+ * which could potentially cause filtering artifacts if used with a material sampler that has linear filtering.
860
+ * If that is an issue, you need to calculate padding and margins manually before passing in the geometry data to
861
+ * this function.
862
+ *
863
+ * @param path - The path to the atlas resource
864
+ * @param table - atlas data. **⚠️ `frame_start` is 1-based; passed to Defold unchanged.** **⚠️ `frame_end` is 1-based; passed to Defold unchanged.** **⚠️ `frame_start` is 1-based; passed to Defold unchanged.** **⚠️ `frame_end` is 1-based; passed to Defold unchanged.** **⚠️ `frames` is 1-based; passed to Defold unchanged.** **0️⃣ `indices` is 0-based; passed to Defold unchanged.**
865
+ * @example
866
+ * Add a new animation to an existing atlas
867
+ * ```ts
868
+ * // Add a new animation to an existing atlas
869
+ * export default defineScript({
870
+ * init() {
871
+ * const data = resource.get_atlas("/main/my_atlas.a.texturesetc");
872
+ * const my_animation = {
873
+ * id: "my_new_animation",
874
+ * width: 128,
875
+ * height: 128,
876
+ * frame_start: 1,
877
+ * frame_end: 6,
878
+ * playback: go.PLAYBACK_LOOP_PINGPONG,
879
+ * fps: 8,
880
+ * flip_vertical: false,
881
+ * flip_horizontal: false,
882
+ * };
883
+ * // set_atlas takes each animation's frames as a non-empty list
884
+ * const animations = data.animations.flatMap((animation) => {
885
+ * // an animation described by frame_start/frame_end passes through as-is
886
+ * if (!("frames" in animation)) return [animation];
887
+ * const [first, ...rest] = (animation.frames as number[] | undefined) ?? [];
888
+ * return first === undefined ? [] : [{ ...animation, frames: [first, ...rest] as [number, ...number[]] }];
889
+ * });
890
+ * // set_atlas needs at least one animation and one geometry
891
+ * const [first_geometry, ...geometries] = data.geometries;
892
+ * if (first_geometry !== undefined) {
893
+ * resource.set_atlas("/main/my_atlas.a.texturesetc", {
894
+ * ...data,
895
+ * animations: [my_animation, ...animations],
896
+ * geometries: [first_geometry, ...geometries],
897
+ * });
898
+ * }
899
+ * },
900
+ * });
901
+ * ```
902
+ * @example
903
+ * Sets atlas data for a 256x256 texture with a single animation being rendered as a quad
904
+ * ```ts
905
+ * // Sets atlas data for a 256x256 texture with a single animation being rendered as a quad
906
+ * export default defineScript({
907
+ * init() {
908
+ * const params = {
909
+ * texture: "/main/my_256x256_texture.texturec",
910
+ * animations: [
911
+ * {
912
+ * id: "my_animation",
913
+ * width: 256,
914
+ * height: 256,
915
+ * frames: [1],
916
+ * },
917
+ * ],
918
+ * geometries: [
919
+ * {
920
+ * vertices: [0, 0, 0, 256, 256, 256, 256, 0],
921
+ * uvs: [0, 0, 0, 256, 256, 256, 256, 0],
922
+ * indices: [0, 1, 2, 0, 2, 3],
923
+ * },
924
+ * ],
925
+ * } satisfies Parameters<typeof resource.set_atlas>[1];
926
+ * resource.set_atlas("/main/test.a.texturesetc", params);
927
+ * },
928
+ * });
929
+ * ```
930
+ */
931
+ function set_atlas(path: Hash | string, table: resource.Atlas): void;
932
+ /**
933
+ * Sets the buffer of a resource. By default, setting the resource buffer will either copy the data from the incoming buffer object
934
+ * to the buffer stored in the destination resource, or make a new buffer object if the sizes between the source buffer and the destination buffer
935
+ * stored in the resource differs. In some cases, e.g performance reasons, it might be beneficial to just set the buffer object on the resource without copying or cloning.
936
+ * To achieve this, set the `transfer_ownership` flag to true in the argument table. Transferring ownership from a lua buffer to a resource with this function
937
+ * works exactly the same as resource.create_buffer: the destination resource will take ownership of the buffer held by the lua reference, i.e the buffer will not automatically be removed
938
+ * when the lua reference to the buffer is garbage collected.
939
+ * Note: When setting a buffer with `transfer_ownership = true`, the currently bound buffer in the resource will be destroyed.
940
+ *
941
+ * @param path - The path to the resource
942
+ * @param buffer - The resource buffer
943
+ * @param table - optional buffer-resource update options
944
+ * @example
945
+ * ```ts
946
+ * // How to set the data from a buffer
947
+ * function fill_stream(stream: { [index: number]: number }, verts: number[]) {
948
+ * verts.forEach((value, key) => {
949
+ * stream[key] = value;
950
+ * });
951
+ * }
952
+ *
953
+ * export default defineScript({
954
+ * init() {
955
+ * const res_path = go.get<mesh.Properties>()("#mesh", "vertices");
956
+ *
957
+ * const positions = [
958
+ * 1, -1, 0,
959
+ * 1, 1, 0,
960
+ * -1, -1, 0,
961
+ * ];
962
+ *
963
+ * const num_verts = positions.length / 3;
964
+ *
965
+ * // create a new buffer
966
+ * let buf = buffer.create(num_verts, [{ name: hash("position"), type: buffer.VALUE_TYPE_FLOAT32, count: 3 }]);
967
+ *
968
+ * buf = resource.get_buffer(res_path);
969
+ * const stream_positions = buffer.get_stream(buf, "position");
970
+ *
971
+ * fill_stream(stream_positions, positions);
972
+ *
973
+ * resource.set_buffer(res_path, buf);
974
+ * },
975
+ * });
976
+ * ```
977
+ */
978
+ function set_buffer(path: Hash | string, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, table?: resource.BufferUpdateOptions): void;
979
+ /**
980
+ * Update internal sound resource (wavc/oggc/opusc) with new data
981
+ *
982
+ * @param path - The path to the resource
983
+ * @param buffer - A lua string containing the binary sound data
984
+ */
985
+ function set_sound(path: Hash | string, buffer: string): void;
986
+ /**
987
+ * Sets the pixel data for a specific texture.
988
+ *
989
+ * @param path - The path to the resource
990
+ * @param table - texture update parameters. **0️⃣ `page` is 0-based; passed to Defold unchanged.** **0️⃣ `mipmap` is 0-based; passed to Defold unchanged.**
991
+ * @param buffer - The buffer of precreated pixel data
992
+ * To update a cube map texture you need to pass in six times the amount of data via the buffer, since a cube map has six sides!
993
+ * 3D textures are currently only supported on OpenGL and Vulkan adapters.
994
+ * @example
995
+ * Check whether a texture format is supported by the device:
996
+ * ```ts
997
+ * if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {
998
+ * // It is safe to use this format.
999
+ * }
1000
+ * ```
1001
+ * @example
1002
+ * Check whether the device supports 3D textures before using them:
1003
+ * ```ts
1004
+ * if (graphics.TEXTURE_TYPE_3D !== undefined) {
1005
+ * // The device and graphics adapter support 3D textures.
1006
+ * }
1007
+ * ```
1008
+ * @example
1009
+ * How to set all pixels of an atlas
1010
+ * ```ts
1011
+ * // How to set all pixels of an atlas
1012
+ * export default defineScript({
1013
+ * init() {
1014
+ * const height = 128;
1015
+ * const width = 128;
1016
+ * const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
1017
+ * const stream = buffer.get_stream(buf, hash("rgb"));
1018
+ *
1019
+ * for (let y = 0; y < height; y++) {
1020
+ * for (let x = 0; x < width; x++) {
1021
+ * const index = y * width * 3 + x * 3;
1022
+ * stream[index + 0] = 0xff;
1023
+ * stream[index + 1] = 0x80;
1024
+ * stream[index + 2] = 0x10;
1025
+ * }
1026
+ * }
1027
+ *
1028
+ * // the engine registers a texture format only when the driver supports it
1029
+ * const format = graphics.TEXTURE_FORMAT_RGB;
1030
+ * if (format !== undefined) {
1031
+ * const resource_path = go.get<model.Properties>()("#model", "texture0");
1032
+ * const args = { width, height, type: graphics.TEXTURE_TYPE_2D, format, num_mip_maps: 1 };
1033
+ * resource.set_texture(resource_path, args, buf);
1034
+ * }
1035
+ * return { buffer: buf, stream };
1036
+ * },
1037
+ * });
1038
+ * ```
1039
+ * @example
1040
+ * How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.
1041
+ * ```ts
1042
+ * // How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.
1043
+ * export default defineScript({
1044
+ * init() {
1045
+ * const x = 16;
1046
+ * const y = 16;
1047
+ * const height = 128 - x * 2;
1048
+ * const width = 128 - y * 2;
1049
+ * const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
1050
+ * const stream = buffer.get_stream(buf, hash("rgb"));
1051
+ *
1052
+ * for (let row = 0; row < height; row++) {
1053
+ * for (let col = 0; col < width; col++) {
1054
+ * const index = row * width * 3 + col * 3;
1055
+ * stream[index + 0] = 0xff;
1056
+ * stream[index + 1] = 0x80;
1057
+ * stream[index + 2] = 0x10;
1058
+ * }
1059
+ * }
1060
+ *
1061
+ * // the engine registers a texture format only when the driver supports it
1062
+ * const format = graphics.TEXTURE_FORMAT_RGB;
1063
+ * if (format !== undefined) {
1064
+ * const resource_path = go.get<model.Properties>()("#model", "texture0");
1065
+ * const args = { width, height, x, y, type: graphics.TEXTURE_TYPE_2D, format, num_mip_maps: 1 };
1066
+ * resource.set_texture(resource_path, args, buf);
1067
+ * }
1068
+ * return { buffer: buf, stream };
1069
+ * },
1070
+ * });
1071
+ * ```
1072
+ * @example
1073
+ * Update a texture from a buffer resource
1074
+ * ```ts
1075
+ * // Update a texture from a buffer resource
1076
+ * export default defineScript({
1077
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
1078
+ * // registration from this field, and only this field types the property onto `self`.
1079
+ * properties: { my_buffer: resource.buffer("/my_default_buffer.buffer") },
1080
+ *
1081
+ * init(self) {
1082
+ * // the engine registers a texture format only when the driver supports it
1083
+ * const format = graphics.TEXTURE_FORMAT_RGB;
1084
+ * if (format === undefined) return;
1085
+ * const resource_path = go.get<model.Properties>()("#model", "texture0");
1086
+ * // the "my_buffer" resource is expected to hold 128 * 128 * 3 bytes!
1087
+ * const args = {
1088
+ * width: 128,
1089
+ * height: 128,
1090
+ * type: graphics.TEXTURE_TYPE_2D,
1091
+ * format,
1092
+ * };
1093
+ * // Note that the extra resource.get_buffer call is a requirement here
1094
+ * // since the "self.my_buffer" is just pointing to a buffer resource path
1095
+ * // and not an actual buffer object or buffer resource.
1096
+ * resource.set_texture(resource_path, args, resource.get_buffer(self.my_buffer));
1097
+ * },
1098
+ * });
1099
+ * ```
1100
+ * @example
1101
+ * Update an existing 3D texture from a lua buffer
1102
+ * ```ts
1103
+ * // Update an existing 3D texture from a lua buffer
1104
+ * export default defineScript({
1105
+ * init() {
1106
+ * // the engine registers a texture type or format only when the driver supports it
1107
+ * const type = graphics.TEXTURE_TYPE_IMAGE_3D;
1108
+ * const format = graphics.TEXTURE_FORMAT_RGBA32F;
1109
+ * if (type === undefined || format === undefined) return;
1110
+ * // create a buffer that can hold the data of a 8x8x8 texture
1111
+ * const tbuffer = buffer.create(8 * 8 * 8, [{ name: hash("rgba"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);
1112
+ * const tstream = buffer.get_stream(tbuffer, hash("rgba"));
1113
+ *
1114
+ * // populate the buffer with some data
1115
+ * let index = 0;
1116
+ * for (let z = 1; z <= 8; z++) {
1117
+ * for (let y = 1; y <= 8; y++) {
1118
+ * for (let x = 1; x <= 8; x++) {
1119
+ * tstream[index + 0] = x;
1120
+ * tstream[index + 1] = y;
1121
+ * tstream[index + 2] = z;
1122
+ * tstream[index + 3] = 1.0;
1123
+ * index = index + 4;
1124
+ * }
1125
+ * }
1126
+ * }
1127
+ *
1128
+ * const t_args = {
1129
+ * type,
1130
+ * width: 8,
1131
+ * height: 8,
1132
+ * depth: 8,
1133
+ * format,
1134
+ * };
1135
+ *
1136
+ * // This expects that the texture resource "/my_3d_texture.texturec" already exists
1137
+ * // and is a 3D texture resource. To create a dynamic 3D texture resource
1138
+ * // use the "resource.create_texture" function.
1139
+ * resource.set_texture("/my_3d_texture.texturec", t_args, tbuffer);
1140
+ * },
1141
+ * });
1142
+ * ```
1143
+ * @example
1144
+ * Update texture 2nd array page with loaded texture from png
1145
+ * ```ts
1146
+ * // Update texture 2nd array page with loaded texture from png
1147
+ * const tex_path = "/bundle_resources/page_02.png";
1148
+ * const [data] = sys.load_resource(tex_path);
1149
+ * // the engine registers a texture format only when the driver supports it
1150
+ * const format = graphics.TEXTURE_FORMAT_RGB;
1151
+ * if (data !== undefined && format !== undefined) {
1152
+ * const buf = image.load_buffer(data);
1153
+ * if (buf !== undefined) {
1154
+ * // new_tex is the resource handle of a texture created via resource.create_texture
1155
+ * const new_tex = resource.create_texture("/my_array_texture.texturec", {
1156
+ * type: graphics.TEXTURE_TYPE_2D_ARRAY,
1157
+ * width: buf.width,
1158
+ * height: buf.height,
1159
+ * page_count: 2,
1160
+ * format,
1161
+ * });
1162
+ * resource.set_texture(
1163
+ * new_tex,
1164
+ * {
1165
+ * type: graphics.TEXTURE_TYPE_2D_ARRAY,
1166
+ * width: buf.width,
1167
+ * height: buf.height,
1168
+ * page: 1,
1169
+ * format,
1170
+ * },
1171
+ * buf.buffer,
1172
+ * );
1173
+ * go.set("#mesh", "texture0", new_tex);
1174
+ * }
1175
+ * }
1176
+ * ```
1177
+ */
1178
+ function set_texture(path: Hash | string, table: resource.TextureUpdateParams, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }): void;
1179
+ /**
1180
+ * Constructor-like function with two purposes:
1181
+ *
1182
+ * - Load the specified resource as part of loading the script
1183
+ * - Create a resource reference that resolves to the hashed path of the run-time resource
1184
+ *
1185
+ * This function can only be called within go.property function calls.
1186
+ *
1187
+ * @param path - optional resource path string to the resource
1188
+ * @returns a reference to the binary version of the resource
1189
+ * @example
1190
+ * ```ts
1191
+ * // Load a texture and set it to a model:
1192
+ * export default defineScript({
1193
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
1194
+ * // registration from this field, and only this field types the property onto `self`.
1195
+ * properties: { my_texture: resource.texture("/texture.png") },
1196
+ *
1197
+ * init(self) {
1198
+ * go.set("#model", "texture0", self.my_texture);
1199
+ * },
1200
+ * });
1201
+ * ```
1202
+ */
1203
+ function texture(path?: string): Hash;
1204
+ /**
1205
+ * Constructor-like function with two purposes:
1206
+ *
1207
+ * - Load the specified resource as part of loading the script
1208
+ * - Create a resource reference that resolves to the hashed path of the run-time resource
1209
+ *
1210
+ * This function can only be called within go.property function calls.
1211
+ *
1212
+ * @param path - optional resource path string to the resource
1213
+ * @returns a reference to the binary version of the resource
1214
+ * @example
1215
+ * ```ts
1216
+ * // Load tile source and set it to a tile map:
1217
+ * export default defineScript({
1218
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
1219
+ * // registration from this field, and only this field types the property onto `self`.
1220
+ * properties: { my_tile_source: resource.tile_source("/tilesource.tilesource") },
1221
+ *
1222
+ * init(self) {
1223
+ * go.set("#tilemap", "tile_source", self.my_tile_source);
1224
+ * },
1225
+ * });
1226
+ * ```
1227
+ */
1228
+ function tile_source(path?: string): Hash;
1229
+ }
1230
+ }
1231
+
1232
+ export {};