@defold-typescript/types 0.51.0 → 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 (130) hide show
  1. package/api-availability.json +4 -58
  2. package/api-signatures.json +878 -1356
  3. package/api-targets.json +15 -5
  4. package/examples/translations.json +4 -56
  5. package/generated/b2d_world.d.ts +10 -10
  6. package/generated/buffer.d.ts +9 -9
  7. package/generated/bullet3d_collision_object.d.ts +1 -1
  8. package/generated/bullet3d_constraint.d.ts +109 -7
  9. package/generated/bullet3d_shape.d.ts +2 -2
  10. package/generated/go.d.ts +114 -220
  11. package/generated/graphics.d.ts +1 -0
  12. package/generated/gui.d.ts +148 -371
  13. package/generated/http.d.ts +2 -2
  14. package/generated/image.d.ts +55 -3
  15. package/generated/kinds/gui-script.d.ts +2 -0
  16. package/generated/kinds/render-script.d.ts +14 -15
  17. package/generated/liveupdate.d.ts +5 -1
  18. package/generated/material.d.ts +3 -3
  19. package/generated/particlefx.d.ts +20 -1
  20. package/generated/physics.d.ts +45 -1
  21. package/generated/render-script-modules/b2d.d.ts +711 -0
  22. package/generated/render-script-modules/bullet3d.d.ts +73 -0
  23. package/generated/render-script-modules/collectionfactory.d.ts +25 -0
  24. package/generated/render-script-modules/collectionproxy.d.ts +39 -0
  25. package/generated/render-script-modules/factory.d.ts +25 -0
  26. package/generated/render-script-modules/go.d.ts +436 -0
  27. package/generated/render-script-modules/label.d.ts +105 -0
  28. package/generated/render-script-modules/model.d.ts +89 -0
  29. package/generated/render-script-modules/particlefx.d.ts +59 -0
  30. package/generated/render-script-modules/physics.d.ts +333 -0
  31. package/generated/render-script-modules/resource.d.ts +1233 -0
  32. package/generated/render-script-modules/sound.d.ts +227 -0
  33. package/generated/render-script-modules/sprite.d.ts +68 -0
  34. package/generated/render-script-modules/tilemap.d.ts +43 -0
  35. package/generated/render.d.ts +134 -8
  36. package/generated/resource.d.ts +31 -10
  37. package/generated/sprite.d.ts +49 -1
  38. package/generated/sys.d.ts +70 -6
  39. package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
  40. package/generated/versions/defold-1.12.4/go.d.ts +115 -343
  41. package/generated/versions/defold-1.12.4/graphics.d.ts +1 -0
  42. package/generated/versions/defold-1.12.4/gui.d.ts +151 -513
  43. package/generated/versions/defold-1.12.4/http.d.ts +2 -2
  44. package/generated/versions/defold-1.12.4/image.d.ts +82 -2
  45. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  46. package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
  47. package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
  48. package/generated/versions/defold-1.12.4/physics.d.ts +45 -1
  49. package/generated/versions/defold-1.12.4/render.d.ts +78 -2
  50. package/generated/versions/defold-1.12.4/resource.d.ts +43 -10
  51. package/generated/versions/defold-1.12.4/sprite.d.ts +58 -1
  52. package/generated/versions/defold-1.12.4/sys.d.ts +101 -6
  53. package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
  54. package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
  55. package/generated/versions/defold-1.13.0/go.d.ts +115 -370
  56. package/generated/versions/defold-1.13.0/graphics.d.ts +1 -0
  57. package/generated/versions/defold-1.13.0/gui.d.ts +151 -513
  58. package/generated/versions/defold-1.13.0/http.d.ts +2 -2
  59. package/generated/versions/defold-1.13.0/image.d.ts +82 -2
  60. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  61. package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
  62. package/generated/versions/defold-1.13.0/material.d.ts +3 -1
  63. package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
  64. package/generated/versions/defold-1.13.0/physics.d.ts +45 -1
  65. package/generated/versions/defold-1.13.0/render.d.ts +142 -4
  66. package/generated/versions/defold-1.13.0/resource.d.ts +43 -10
  67. package/generated/versions/defold-1.13.0/sprite.d.ts +58 -1
  68. package/generated/versions/defold-1.13.0/sys.d.ts +101 -6
  69. package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
  70. package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
  71. package/generated/versions/defold-1.13.1/go.d.ts +115 -370
  72. package/generated/versions/defold-1.13.1/graphics.d.ts +1 -0
  73. package/generated/versions/defold-1.13.1/gui.d.ts +151 -529
  74. package/generated/versions/defold-1.13.1/http.d.ts +2 -2
  75. package/generated/versions/defold-1.13.1/image.d.ts +82 -2
  76. package/generated/versions/defold-1.13.1/index.d.ts +2 -0
  77. package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
  78. package/generated/versions/defold-1.13.1/material.d.ts +3 -1
  79. package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
  80. package/generated/versions/defold-1.13.1/physics.d.ts +45 -1
  81. package/generated/versions/defold-1.13.1/render.d.ts +142 -4
  82. package/generated/versions/defold-1.13.1/resource.d.ts +43 -10
  83. package/generated/versions/defold-1.13.1/sprite.d.ts +58 -1
  84. package/generated/versions/defold-1.13.1/sys.d.ts +101 -6
  85. package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
  86. package/generated/versions/defold-1.13.2/b2d_world.d.ts +10 -10
  87. package/generated/versions/defold-1.13.2/buffer.d.ts +9 -9
  88. package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +1 -1
  89. package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +109 -7
  90. package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +2 -2
  91. package/generated/versions/defold-1.13.2/go.d.ts +114 -220
  92. package/generated/versions/defold-1.13.2/graphics.d.ts +1 -0
  93. package/generated/versions/defold-1.13.2/gui.d.ts +148 -371
  94. package/generated/versions/defold-1.13.2/http.d.ts +2 -2
  95. package/generated/versions/defold-1.13.2/image.d.ts +55 -3
  96. package/generated/versions/defold-1.13.2/index.d.ts +2 -0
  97. package/generated/versions/defold-1.13.2/liveupdate.d.ts +5 -1
  98. package/generated/versions/defold-1.13.2/material.d.ts +3 -3
  99. package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
  100. package/generated/versions/defold-1.13.2/physics.d.ts +45 -1
  101. package/generated/versions/defold-1.13.2/render.d.ts +123 -7
  102. package/generated/versions/defold-1.13.2/resource.d.ts +31 -10
  103. package/generated/versions/defold-1.13.2/sprite.d.ts +49 -1
  104. package/generated/versions/defold-1.13.2/sys.d.ts +70 -6
  105. package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
  106. package/generated/vmath.d.ts +0 -24
  107. package/identity-vocabulary.json +52 -7
  108. package/index.d.ts +2 -0
  109. package/package.json +2 -1
  110. package/scripts/generate-api-availability.ts +1 -21
  111. package/scripts/generate-api-signatures.ts +75 -14
  112. package/scripts/materialize-version.ts +48 -7
  113. package/scripts/regen.ts +214 -19
  114. package/scripts/signature-store-fs.ts +1 -0
  115. package/scripts/target-version.ts +26 -0
  116. package/src/api-doc.ts +26 -0
  117. package/src/component-properties.d.ts +89 -0
  118. package/src/core-types.ts +42 -15
  119. package/src/doc-corrections.ts +53 -5
  120. package/src/emit-dts.ts +758 -198
  121. package/src/engine-globals.d.ts +5 -1
  122. package/src/go-overloads.d.ts +68 -13
  123. package/src/gui-overloads.d.ts +489 -0
  124. package/src/gui-texture-removal.d.ts +41 -0
  125. package/src/index.ts +2 -0
  126. package/src/lifecycle.ts +30 -21
  127. package/src/msg-overloads.d.ts +25 -13
  128. package/src/signature-store.ts +50 -0
  129. package/src/timers.d.ts +2 -1
  130. package/src/vmath-overloads.d.ts +26 -0
@@ -0,0 +1,227 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash } from "../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions and messages for controlling sound components and
7
+ * mixer groups.
8
+ */
9
+ namespace sound {
10
+ /**
11
+ * Data passed to the completion callback of sound.play. The callback's
12
+ * `message_id` indicates whether playback finished or was stopped manually.
13
+ */
14
+ interface play_completion {
15
+ /**
16
+ * The sequential play identifier for the playback.
17
+ */
18
+ play_id: number;
19
+ }
20
+ /**
21
+ * Sound playback properties
22
+ */
23
+ interface play_properties {
24
+ /**
25
+ * Delay in seconds before playback starts. The default is 0.
26
+ */
27
+ delay?: number;
28
+ /**
29
+ * Gain from 0 to 1. The default is 1; this combines with the group and master gains.
30
+ */
31
+ gain?: number;
32
+ /**
33
+ * Pan from -1 to 1. The default is 0; this is added to the component pan.
34
+ */
35
+ pan?: number;
36
+ /**
37
+ * Playback speed from 0 to 50. The default is 1; this is multiplied by the component speed.
38
+ */
39
+ speed?: number;
40
+ /**
41
+ * Playback offset in seconds. Mutually exclusive with `start_frame`.
42
+ */
43
+ start_time?: number;
44
+ /**
45
+ * Playback offset in frames or samples. Takes precedence over `start_time`.
46
+ */
47
+ start_frame?: number;
48
+ }
49
+ /**
50
+ * Sound stop properties
51
+ */
52
+ interface stop_properties {
53
+ /**
54
+ * Sequential playback identifier returned by sound.play.
55
+ */
56
+ play_id?: number;
57
+ }
58
+ /**
59
+ * Get mixer group gain
60
+ *
61
+ * @param group - group name
62
+ * @returns gain in [0 1] range ([-60dB.. 0dB])
63
+ * @example
64
+ * ```ts
65
+ * // Get the mixer group gain for the "soundfx" and convert to dB:
66
+ * const gain = sound.get_group_gain("soundfx");
67
+ * const gain_db = 60 * gain;
68
+ * ```
69
+ */
70
+ function get_group_gain(group: string | Hash): number;
71
+ /**
72
+ * Get a mixer group name as a string.
73
+ * This function is to be used for debugging and
74
+ * development tooling only. The function does a reverse hash lookup, which does not
75
+ * return a proper string value when the game is built in release mode.
76
+ *
77
+ * @param group - group name
78
+ * @returns group name
79
+ * @example
80
+ * ```ts
81
+ * // Get the mixer group string names so we can show them as labels on a dev mixer overlay:
82
+ * const groups = sound.get_groups();
83
+ * for (const group of groups) {
84
+ * const name = sound.get_group_name(group);
85
+ * msg.post("/mixer_overlay#gui", "set_mixer_label", { group: group, label: name });
86
+ * }
87
+ * ```
88
+ */
89
+ function get_group_name(group: Hash): string;
90
+ /**
91
+ * Get a table of all mixer group names (hashes).
92
+ *
93
+ * @returns table of mixer group names
94
+ * @example
95
+ * ```ts
96
+ * // Get the mixer groups, set all gains to 0 except for "master" and "soundfx"
97
+ * // where gain is set to 1:
98
+ * const groups = sound.get_groups();
99
+ * for (const group of groups) {
100
+ * if (group === hash("master") || group === hash("soundfx")) {
101
+ * sound.set_group_gain(group, 1);
102
+ * } else {
103
+ * sound.set_group_gain(group, 0);
104
+ * }
105
+ * }
106
+ * ```
107
+ */
108
+ function get_groups(): Hash[];
109
+ /**
110
+ * Get peak value from mixer group.
111
+ * Note that gain is in linear scale, between 0 and 1.
112
+ * To get the dB value from the gain, use the formula `20 * log(gain)`.
113
+ * Inversely, to find the linear value from a dB value, use the formula
114
+ * `10db/20`.
115
+ * Also note that the returned value might be an approximation and in particular
116
+ * the effective window might be larger than specified.
117
+ *
118
+ * @param group - group name
119
+ * @param window - window length in seconds
120
+ * @example
121
+ * ```ts
122
+ * // Get the peak gain from the "master" group and convert to dB for displaying:
123
+ * const [left_p, right_p] = sound.get_peak("master", 0.1);
124
+ * const left_p_db = 20 * Math.log(left_p);
125
+ * const right_p_db = 20 * Math.log(right_p);
126
+ * ```
127
+ */
128
+ function get_peak(group: string | Hash, window: number): LuaMultiReturn<[number, number]>;
129
+ /**
130
+ * Get RMS (Root Mean Square) value from mixer group. This value is the
131
+ * square root of the mean (average) value of the squared function of
132
+ * the instantaneous values.
133
+ * For instance: for a sinewave signal with a peak gain of -1.94 dB (0.8 linear),
134
+ * the RMS is `0.8 × 1/sqrt(2)` which is about 0.566.
135
+ * Note the returned value might be an approximation and in particular
136
+ * the effective window might be larger than specified.
137
+ *
138
+ * @param group - group name
139
+ * @param window - window length in seconds
140
+ * @example
141
+ * ```ts
142
+ * // Get the RMS from the "master" group where a mono -1.94 dB sinewave is playing:
143
+ * const [rms] = sound.get_rms("master", 0.1); // throw away right channel.
144
+ * print(rms); // => 0.56555819511414
145
+ * ```
146
+ */
147
+ function get_rms(group: string | Hash, window: number): LuaMultiReturn<[number, number]>;
148
+ /**
149
+ * Checks if background music is playing, e.g. from iTunes.
150
+ * On non mobile platforms,
151
+ * this function always return `false`.
152
+ * On Android you can only get a correct reading
153
+ * of this state if your game is not playing any sounds itself. This is a limitation
154
+ * in the Android SDK. If your game is playing any sounds, *even with a gain of zero*, this
155
+ * function will return `false`.
156
+ * The best time to call this function is:
157
+ *
158
+ * - In the `init` function of your main collection script before any sounds are triggered
159
+ * - In a window listener callback when the window.WINDOW_EVENT_FOCUS_GAINED event is received
160
+ *
161
+ * Both those times will give you a correct reading of the state even when your application is
162
+ * swapped out and in while playing sounds and it works equally well on Android and iOS.
163
+ *
164
+ * @returns `true` if music is playing, otherwise `false`.
165
+ * @example
166
+ * ```ts
167
+ * // If music is playing, mute "master":
168
+ * if (sound.is_music_playing()) {
169
+ * // mute "master"
170
+ * sound.set_group_gain("master", 0);
171
+ * }
172
+ * ```
173
+ */
174
+ function is_music_playing(): boolean;
175
+ /**
176
+ * Checks if a phone call is active. If there is an active phone call all
177
+ * other sounds will be muted until the phone call is finished.
178
+ * On non mobile platforms,
179
+ * this function always return `false`.
180
+ *
181
+ * @returns `true` if there is an active phone call, `false` otherwise.
182
+ * @example
183
+ * ```ts
184
+ * // Test if a phone call is on-going:
185
+ * if (sound.is_phone_call_active()) {
186
+ * // do something sensible.
187
+ * }
188
+ * ```
189
+ */
190
+ function is_phone_call_active(): boolean;
191
+ /**
192
+ * Set mixer group gain
193
+ *
194
+ * @param group - group name
195
+ * @param gain - gain in range [0..1] mapped to [0 .. -60dB]
196
+ * @example
197
+ * ```ts
198
+ * // Set mixer group gain on the "soundfx" group to 50% (-30dB):
199
+ * sound.set_group_gain("soundfx", 0.5);
200
+ * ```
201
+ */
202
+ function set_group_gain(group: string | Hash, gain: number): void;
203
+ interface properties {
204
+ /**
205
+ * The gain on the sound-component. Note that gain is in linear scale,
206
+ * between 0 and 1.
207
+ */
208
+ gain: number;
209
+ /**
210
+ * The pan on the sound-component. The valid range is from -1.0 to 1.0,
211
+ * representing -45 degrees left, to +45 degrees right.
212
+ */
213
+ pan: number;
214
+ /**
215
+ * The sound data used when playing the sound. The type of the property is hash.
216
+ */
217
+ sound: Hash;
218
+ /**
219
+ * The speed on the sound-component where 1.0 is normal speed, 0.5 is half
220
+ * speed and 2.0 is double speed. Valid range is 0.0 to 50.0.
221
+ */
222
+ speed: number;
223
+ }
224
+ }
225
+ }
226
+
227
+ export {};
@@ -0,0 +1,68 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Vector3, Vector4 } from "../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Sprite API documentation
7
+ */
8
+ namespace sprite {
9
+ /**
10
+ * Sprite flipbook playback properties
11
+ */
12
+ interface play_properties {
13
+ /**
14
+ * Normalized initial animation cursor.
15
+ */
16
+ offset?: number;
17
+ /**
18
+ * Positive animation playback rate.
19
+ */
20
+ playback_rate?: number;
21
+ }
22
+ interface properties {
23
+ /**
24
+ * READ ONLY The current animation id. An animation that plays currently for the sprite. The type of the property is hash.
25
+ */
26
+ readonly animation: Hash;
27
+ /**
28
+ * The normalized animation cursor. The type of the property is number.
29
+ */
30
+ cursor: number;
31
+ /**
32
+ * READ ONLY The frame count of the currently playing animation.
33
+ */
34
+ readonly frame_count: number;
35
+ /**
36
+ * The image used when rendering the sprite. The type of the property is hash.
37
+ */
38
+ image: Hash;
39
+ /**
40
+ * The material used when rendering the sprite. The type of the property is hash.
41
+ */
42
+ material: Hash;
43
+ /**
44
+ * The animation playback rate. A multiplier to the animation playback rate. The type of the property is number.
45
+ * The playback_rate is a non-negative number, a negative value will be clamped to 0.
46
+ */
47
+ playback_rate: number;
48
+ /**
49
+ * The non-uniform scale of the sprite. The type of the property is vector3.
50
+ */
51
+ scale: Vector3;
52
+ /**
53
+ * The size of the sprite, not allowing for any additional scaling that may be applied.
54
+ * The type of the property is vector3. It is not possible to set the size if the size mode
55
+ * of the sprite is set to auto.
56
+ */
57
+ size: Vector3;
58
+ /**
59
+ * The slice values of the sprite. The type of the property is a vector4 that corresponds to
60
+ * the left, top, right, bottom values of the sprite in the editor.
61
+ * It is not possible to set the slice property if the size mode of the sprite is set to auto.
62
+ */
63
+ slice: Vector4;
64
+ }
65
+ }
66
+ }
67
+
68
+ export {};
@@ -0,0 +1,43 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash } from "../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions and messages used to manipulate tile map components.
7
+ */
8
+ namespace tilemap {
9
+ type TRANSFORM = typeof tilemap.H_FLIP | typeof tilemap.ROTATE_180 | typeof tilemap.ROTATE_270 | typeof tilemap.ROTATE_90 | typeof tilemap.V_FLIP;
10
+ /**
11
+ * flip tile horizontally
12
+ */
13
+ const H_FLIP: number & { readonly __brand: "tilemap.H_FLIP" };
14
+ /**
15
+ * rotate tile 180 degrees clockwise
16
+ */
17
+ const ROTATE_180: number & { readonly __brand: "tilemap.ROTATE_180" };
18
+ /**
19
+ * rotate tile 270 degrees clockwise
20
+ */
21
+ const ROTATE_270: number & { readonly __brand: "tilemap.ROTATE_270" };
22
+ /**
23
+ * rotate tile 90 degrees clockwise
24
+ */
25
+ const ROTATE_90: number & { readonly __brand: "tilemap.ROTATE_90" };
26
+ /**
27
+ * flip tile vertically
28
+ */
29
+ const V_FLIP: number & { readonly __brand: "tilemap.V_FLIP" };
30
+ interface properties {
31
+ /**
32
+ * The material used when rendering the tile map. The type of the property is hash.
33
+ */
34
+ material: Hash;
35
+ /**
36
+ * The tile source used when rendering the tile map. The type of the property is hash.
37
+ */
38
+ tile_source: Hash;
39
+ }
40
+ }
41
+ }
42
+
43
+ export {};
@@ -59,7 +59,7 @@ declare global {
59
59
  */
60
60
  sort_order?: render.SORT;
61
61
  }
62
- type render_predicate = number;
62
+ type render_predicate = Opaque<"render_predicate">;
63
63
  type render_target = Opaque<"render_target">;
64
64
  /**
65
65
  * Render-target attachment parameters
@@ -102,7 +102,7 @@ declare global {
102
102
  */
103
103
  flags?: render.RENDER_TARGET_FLAG | number;
104
104
  }
105
- type render_target_params = { type?: graphics.TEXTURE_TYPE; sample_count?: number } & { [key: number]: render.render_target_buffer_params };
105
+ type render_target_params = { type?: render.RenderTargetTextureType; sample_count?: number } & { [key: number]: render.render_target_buffer_params };
106
106
  /**
107
107
  * Render-target activation options
108
108
  */
@@ -118,6 +118,7 @@ declare global {
118
118
  }
119
119
  type texture = Opaque<"texture">;
120
120
  type ClearBufferKey = typeof graphics.BUFFER_TYPE_COLOR0_BIT | typeof graphics.BUFFER_TYPE_DEPTH_BIT | typeof graphics.BUFFER_TYPE_STENCIL_BIT;
121
+ type RenderTargetTextureType = typeof graphics.TEXTURE_TYPE_2D | typeof graphics.TEXTURE_TYPE_CUBE_MAP;
121
122
  type RenderTargetParams = render.render_target_params;
122
123
  type CONTEXT_EVENT = typeof render.CONTEXT_EVENT_CONTEXT_LOST | typeof render.CONTEXT_EVENT_CONTEXT_RESTORED;
123
124
  type FRUSTUM_PLANES = typeof render.FRUSTUM_PLANES_ALL | typeof render.FRUSTUM_PLANES_SIDES;
@@ -295,7 +296,7 @@ declare global {
295
296
  * });
296
297
  * ```
297
298
  */
298
- function disable_state(state: graphics.STATE): void;
299
+ function disable_state(state: graphics.State): void;
299
300
  /**
300
301
  * Disables a texture that has previourly been enabled.
301
302
  *
@@ -330,7 +331,7 @@ declare global {
330
331
  * });
331
332
  * ```
332
333
  */
333
- function disable_texture(binding: Opaque<"texture"> | string | Hash | number): void;
334
+ function disable_texture(binding: string | Hash | number): void;
334
335
  /**
335
336
  * Dispatches the currently enabled compute program. The dispatch call takes three arguments x,y,z which constitutes
336
337
  * the 'global working group' of the compute dispatch. Together with the 'local working group' specified in the compute shader
@@ -427,7 +428,56 @@ declare global {
427
428
  * }
428
429
  * ```
429
430
  */
430
- function draw(predicate: Opaque<"render_predicate">, options?: render.draw_options): void;
431
+ function draw(predicate: Opaque<"render_predicate">): void;
432
+ /**
433
+ * Draws all objects that match a specified predicate. An optional constant buffer can be
434
+ * provided to override the default constants. If no constants buffer is provided, a default
435
+ * system constants buffer is used containing constants as defined in materials and set through
436
+ * go.set (or particlefx.set_constant) on visual components.
437
+ *
438
+ * @param predicate - predicate to draw for
439
+ * @param options - optional draw options
440
+ * @example
441
+ * ```ts
442
+ * export default defineRenderScript({
443
+ * init() {
444
+ * // define a predicate matching anything with material tag "my_tag"
445
+ * return { my_pred: render.predicate([hash("my_tag")]) };
446
+ * },
447
+ *
448
+ * update(self, dt) {
449
+ * // draw everything in the my_pred predicate
450
+ * render.draw(self.my_pred);
451
+ * },
452
+ * });
453
+ * ```
454
+ * @example
455
+ * Draw predicate with constants:
456
+ * ```ts
457
+ * function draw_tinted(self: { my_pred: Opaque<"render_predicate"> }) {
458
+ * const constants = render.constant_buffer();
459
+ * constants.tint = vmath.vector4(1, 1, 1, 1);
460
+ * render.draw(self.my_pred, { constants });
461
+ * }
462
+ * ```
463
+ * @example
464
+ * Draw with predicate and frustum culling (without near+far planes):
465
+ * ```ts
466
+ * function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
467
+ * const frustum = self.proj.mul(self.view);
468
+ * render.draw(self.my_pred, { frustum });
469
+ * }
470
+ * ```
471
+ * @example
472
+ * Draw with predicate and frustum culling (with near+far planes):
473
+ * ```ts
474
+ * function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
475
+ * const frustum = self.proj.mul(self.view);
476
+ * render.draw(self.my_pred, { frustum, frustum_planes: render.FRUSTUM_PLANES_ALL });
477
+ * }
478
+ * ```
479
+ */
480
+ function draw(predicate: Opaque<"render_predicate">, options: render.draw_options): void;
431
481
  /**
432
482
  * Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.
433
483
  *
@@ -494,7 +544,7 @@ declare global {
494
544
  * });
495
545
  * ```
496
546
  */
497
- function enable_state(state: graphics.STATE): void;
547
+ function enable_state(state: graphics.State): void;
498
548
  /**
499
549
  * Sets the specified texture handle for a render target attachment or a regular texture
500
550
  * that should be used for rendering. The texture can be bound to either a texture unit
@@ -791,7 +841,7 @@ declare global {
791
841
  * render.set_blend_func_separate(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, graphics.BLEND_FACTOR_ONE, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
792
842
  * ```
793
843
  */
794
- function set_blend_func_separate(source_factor_color: number, destination_factor_color: number, source_factor_alpha: number, destination_factor_alpha: number): void;
844
+ function set_blend_func_separate(source_factor_color: graphics.BlendFactor, destination_factor_color: graphics.BlendFactor, source_factor_alpha: graphics.BlendFactor, destination_factor_alpha: graphics.BlendFactor): void;
795
845
  /**
796
846
  * Sets the current render camera to be used for rendering. If a render camera
797
847
  * has been set by the render script, the renderer will be using its projection and view matrix
@@ -1047,7 +1097,83 @@ declare global {
1047
1097
  * });
1048
1098
  * ```
1049
1099
  */
1050
- function set_render_target(render_target?: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT, options?: render.set_render_target_options): void;
1100
+ function set_render_target(render_target?: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT): void;
1101
+ /**
1102
+ * Sets a render target. Subsequent draw operations will be to the
1103
+ * render target until it is replaced by a subsequent call to set_render_target.
1104
+ * This function supports render targets created by a render script, or a render target resource.
1105
+ *
1106
+ * @param render_target - render target to set. Omit it, pass `nil`, or use render.RENDER_TARGET_DEFAULT to set the default render target
1107
+ * @param options - optional render-target activation options
1108
+ *
1109
+ * `face`
1110
+ * number Cubemap face selected for rendering. This option is valid only for cubemap render targets and defaults to `graphics.CUBEMAP_FACE_POSITIVE_X`.
1111
+ *
1112
+ * - `graphics.CUBEMAP_FACE_POSITIVE_X`
1113
+ * - `graphics.CUBEMAP_FACE_NEGATIVE_X`
1114
+ * - `graphics.CUBEMAP_FACE_POSITIVE_Y`
1115
+ * - `graphics.CUBEMAP_FACE_NEGATIVE_Y`
1116
+ * - `graphics.CUBEMAP_FACE_POSITIVE_Z`
1117
+ * - `graphics.CUBEMAP_FACE_NEGATIVE_Z`
1118
+ * @example
1119
+ * How to set a render target and draw to it and then switch back to the default render target
1120
+ * The render target defines the depth/stencil buffers as transient, when set_render_target is called the next time the buffers may be invalidated and allow for optimisations depending on driver support
1121
+ * ```ts
1122
+ * // How to set a render target and draw to it and then switch back to the default render target
1123
+ * // The render target defines the depth/stencil buffers as transient, when set_render_target is called the next time the buffers may be invalidated and allow for optimisations depending on driver support
1124
+ * export default defineRenderScript({
1125
+ * init() {
1126
+ * // the engine registers a texture format only when the driver supports it
1127
+ * const format = graphics.TEXTURE_FORMAT_RGBA;
1128
+ * if (format === undefined) return undefined;
1129
+ * const color_params = {
1130
+ * format,
1131
+ * width: render.get_window_width(),
1132
+ * height: render.get_window_height(),
1133
+ * };
1134
+ * return {
1135
+ * my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
1136
+ * my_pred: render.predicate([hash("my_tag")]),
1137
+ * };
1138
+ * },
1139
+ *
1140
+ * update(self, dt) {
1141
+ * if (self === undefined) return;
1142
+ * // set render target so all drawing is done to it
1143
+ * render.set_render_target(self.my_render_target, {
1144
+ * transient: [graphics.BUFFER_TYPE_DEPTH_BIT, graphics.BUFFER_TYPE_STENCIL_BIT],
1145
+ * });
1146
+ *
1147
+ * // draw a predicate to the render target
1148
+ * render.draw(self.my_pred);
1149
+ *
1150
+ * // set default render target. This also invalidates the depth and stencil buffers of the current target (self.my_render_target)
1151
+ * // which can be an optimisation on some hardware
1152
+ * render.set_render_target(render.RENDER_TARGET_DEFAULT);
1153
+ * },
1154
+ * });
1155
+ * ```
1156
+ * @example
1157
+ * ```ts
1158
+ * export default defineRenderScript({
1159
+ * init() {
1160
+ * return { my_pred: render.predicate([hash("my_tag")]) };
1161
+ * },
1162
+ *
1163
+ * update(self, dt) {
1164
+ * // set render target by a render target resource identifier
1165
+ * render.set_render_target("my_rt_resource");
1166
+ *
1167
+ * // draw a predicate to the render target
1168
+ * render.draw(self.my_pred);
1169
+ *
1170
+ * // reset the render target to the default backbuffer
1171
+ * render.set_render_target(render.RENDER_TARGET_DEFAULT);
1172
+ * },
1173
+ * });
1174
+ * ```
1175
+ */
1176
+ function set_render_target(render_target: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT | undefined, options: render.set_render_target_options): void;
1051
1177
  /**
1052
1178
  * Sets the render target size for a render target created from
1053
1179
  * either a render script, or from a render target resource.
@@ -130,7 +130,7 @@ declare global {
130
130
  /**
131
131
  * Buffer to bind to the resource.
132
132
  */
133
- buffer: Opaque<"buffer">;
133
+ buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> };
134
134
  /**
135
135
  * Whether the resource takes ownership of the buffer. The default is true.
136
136
  */
@@ -708,7 +708,7 @@ declare global {
708
708
  * });
709
709
  * ```
710
710
  */
711
- function create_sound_data(path: string, options: resource.sound_data_options): Hash;
711
+ function create_sound_data(path: string, options: resource.sound_data_options & ({ partial?: false } | ({ partial: true } & Required<Pick<resource.sound_data_options, "filesize">>))): Hash;
712
712
  /**
713
713
  * Creates a new texture resource that can be used in the same way as any texture created during build time.
714
714
  * The path used for creating the texture must be unique, trying to create a resource at a path that is already
@@ -836,7 +836,7 @@ declare global {
836
836
  * }
837
837
  * ```
838
838
  */
839
- function create_texture(path: string, table: resource.texture_creation_params, buffer?: Opaque<"buffer">): Hash;
839
+ function create_texture(path: string, table: resource.texture_creation_params, buffer?: Opaque<"buffer"> & { length: LuaLengthMethod<number> }): Hash;
840
840
  /**
841
841
  * Creates a new texture resource that can be used in the same way as any texture created during build time.
842
842
  * The path used for creating the texture must be unique, trying to create a resource at a path that is already
@@ -955,7 +955,7 @@ declare global {
955
955
  * });
956
956
  * ```
957
957
  */
958
- function create_texture_async(path: string, table: resource.texture_creation_params, buffer: Opaque<"buffer"> | undefined, callback: (self: unknown, request_id: number, result: resource.texture_creation_result) => void): LuaMultiReturn<[Hash, number]>;
958
+ function create_texture_async(path: string, table: resource.texture_creation_params, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> } | undefined, callback: (self: unknown, request_id: number, result: resource.texture_creation_result) => void): LuaMultiReturn<[Hash, number]>;
959
959
  /**
960
960
  * Constructor-like function with two purposes:
961
961
  *
@@ -1024,7 +1024,7 @@ declare global {
1024
1024
  * });
1025
1025
  * ```
1026
1026
  */
1027
- function get_buffer(path: Hash | string): Opaque<"buffer">;
1027
+ function get_buffer(path: Hash | string): Opaque<"buffer"> & { length: LuaLengthMethod<number> };
1028
1028
  /**
1029
1029
  * Gets render target info from a render target resource path or a render target handle
1030
1030
  *
@@ -1080,7 +1080,28 @@ declare global {
1080
1080
  * });
1081
1081
  * ```
1082
1082
  */
1083
- function get_text_metrics(url: Hash | string, text: string, options?: resource.text_metrics_options): resource.text_metrics;
1083
+ function get_text_metrics(url: Hash | string, text: string): resource.text_metrics;
1084
+ /**
1085
+ * Gets the text metrics from a font. Rich text markup is measured using its
1086
+ * visible text and font sizes. If markup cannot be parsed, the text is measured literally.
1087
+ * Inline sprites reserve their specified dimensions, or one em by default.
1088
+ *
1089
+ * @param url - the font to get the (unscaled) metrics from
1090
+ * @param text - text to measure
1091
+ * @param options - optional text-metric options
1092
+ * @returns measured text metrics
1093
+ * @example
1094
+ * ```ts
1095
+ * export default defineScript({
1096
+ * init() {
1097
+ * const font = go.get<label.properties>()("#label", "font");
1098
+ * const metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog");
1099
+ * pprint(metrics);
1100
+ * },
1101
+ * });
1102
+ * ```
1103
+ */
1104
+ function get_text_metrics(url: Hash | string, text: string, options: resource.text_metrics_options): resource.text_metrics;
1084
1105
  /**
1085
1106
  * Gets texture info from a texture resource path or a texture handle
1086
1107
  *
@@ -1155,7 +1176,7 @@ declare global {
1155
1176
  * // custom_resources = resources/,assets/level_data.json
1156
1177
  * ```
1157
1178
  */
1158
- function load(path: string): Opaque<"buffer">;
1179
+ function load(path: string): Opaque<"buffer"> & { length: LuaLengthMethod<number> };
1159
1180
  /**
1160
1181
  * Constructor-like function with two purposes:
1161
1182
  *
@@ -1242,7 +1263,7 @@ declare global {
1242
1263
  * resource.set(go.get<sprite.properties>()("#sprite", "texture0"), buffer);
1243
1264
  * ```
1244
1265
  */
1245
- function set(path: string | Hash, buffer: Opaque<"buffer">): void;
1266
+ function set(path: string | Hash, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }): void;
1246
1267
  /**
1247
1268
  * Sets the data for a specific atlas resource. Setting new atlas data is specified by passing in
1248
1269
  * a texture path for the backing texture of the atlas, a list of geometries and a list of animations
@@ -1371,7 +1392,7 @@ declare global {
1371
1392
  * });
1372
1393
  * ```
1373
1394
  */
1374
- function set_buffer(path: Hash | string, buffer: Opaque<"buffer">, table?: resource.buffer_update_options): void;
1395
+ function set_buffer(path: Hash | string, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, table?: resource.buffer_update_options): void;
1375
1396
  /**
1376
1397
  * Update internal sound resource (wavc/oggc/opusc) with new data
1377
1398
  *
@@ -1571,7 +1592,7 @@ declare global {
1571
1592
  * }
1572
1593
  * ```
1573
1594
  */
1574
- function set_texture(path: Hash | string, table: resource.texture_update_params, buffer: Opaque<"buffer">): void;
1595
+ function set_texture(path: Hash | string, table: resource.texture_update_params, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }): void;
1575
1596
  /**
1576
1597
  * Constructor-like function with two purposes:
1577
1598
  *