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