@defold-typescript/types 0.49.0 → 0.50.1

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 (76) hide show
  1. package/api-availability.json +696 -624
  2. package/api-signatures.json +6799 -160
  3. package/api-targets.json +393 -2
  4. package/examples/translations.json +12 -0
  5. package/generated/b2d.d.ts +15 -0
  6. package/generated/bullet3d.d.ts +16 -0
  7. package/generated/font.d.ts +7 -3
  8. package/generated/graphics.d.ts +7 -0
  9. package/generated/gui.d.ts +5 -4
  10. package/generated/label.d.ts +3 -3
  11. package/generated/render.d.ts +16 -1
  12. package/generated/versions/defold-1.13.2/b2d.d.ts +709 -0
  13. package/generated/versions/defold-1.13.2/b2d_body.d.ts +593 -0
  14. package/generated/versions/defold-1.13.2/b2d_chain.d.ts +105 -0
  15. package/generated/versions/defold-1.13.2/b2d_fixture.d.ts +175 -0
  16. package/generated/versions/defold-1.13.2/b2d_joint.d.ts +1301 -0
  17. package/generated/versions/defold-1.13.2/b2d_shape.d.ts +423 -0
  18. package/generated/versions/defold-1.13.2/b2d_world.d.ts +308 -0
  19. package/generated/versions/defold-1.13.2/buffer.d.ts +192 -0
  20. package/generated/versions/defold-1.13.2/bullet3d.d.ts +91 -0
  21. package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +433 -0
  22. package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +818 -0
  23. package/generated/versions/defold-1.13.2/bullet3d_rigid_body.d.ts +429 -0
  24. package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +123 -0
  25. package/generated/versions/defold-1.13.2/bullet3d_world.d.ts +492 -0
  26. package/generated/versions/defold-1.13.2/camera.d.ts +300 -0
  27. package/generated/versions/defold-1.13.2/collectionfactory.d.ts +148 -0
  28. package/generated/versions/defold-1.13.2/collectionproxy.d.ts +109 -0
  29. package/generated/versions/defold-1.13.2/compute.d.ts +107 -0
  30. package/generated/versions/defold-1.13.2/crash.d.ts +157 -0
  31. package/generated/versions/defold-1.13.2/editor-vm/http.d.ts +139 -0
  32. package/generated/versions/defold-1.13.2/editor-vm/image.d.ts +48 -0
  33. package/generated/versions/defold-1.13.2/editor-vm/json.d.ts +21 -0
  34. package/generated/versions/defold-1.13.2/editor-vm/localization.d.ts +42 -0
  35. package/generated/versions/defold-1.13.2/editor-vm/tilemap_tiles.d.ts +126 -0
  36. package/generated/versions/defold-1.13.2/editor-vm/zip.d.ts +38 -0
  37. package/generated/versions/defold-1.13.2/editor-vm/zlib.d.ts +24 -0
  38. package/generated/versions/defold-1.13.2/editor.d.ts +2177 -0
  39. package/generated/versions/defold-1.13.2/factory.d.ts +121 -0
  40. package/generated/versions/defold-1.13.2/font.d.ts +123 -0
  41. package/generated/versions/defold-1.13.2/go.d.ts +1166 -0
  42. package/generated/versions/defold-1.13.2/graphics.d.ts +613 -0
  43. package/generated/versions/defold-1.13.2/gui.d.ts +2212 -0
  44. package/generated/versions/defold-1.13.2/html5.d.ts +55 -0
  45. package/generated/versions/defold-1.13.2/http.d.ts +83 -0
  46. package/generated/versions/defold-1.13.2/image.d.ts +181 -0
  47. package/generated/versions/defold-1.13.2/index.d.ts +63 -0
  48. package/generated/versions/defold-1.13.2/json.d.ts +94 -0
  49. package/generated/versions/defold-1.13.2/kinds/editor-script.d.ts +14 -0
  50. package/generated/versions/defold-1.13.2/label.d.ts +164 -0
  51. package/generated/versions/defold-1.13.2/liveupdate.d.ts +143 -0
  52. package/generated/versions/defold-1.13.2/material.d.ts +490 -0
  53. package/generated/versions/defold-1.13.2/model.d.ts +287 -0
  54. package/generated/versions/defold-1.13.2/msg.d.ts +10 -0
  55. package/generated/versions/defold-1.13.2/particlefx.d.ts +155 -0
  56. package/generated/versions/defold-1.13.2/physics.d.ts +789 -0
  57. package/generated/versions/defold-1.13.2/profiler.d.ts +228 -0
  58. package/generated/versions/defold-1.13.2/render.d.ts +1153 -0
  59. package/generated/versions/defold-1.13.2/resource.d.ts +1628 -0
  60. package/generated/versions/defold-1.13.2/socket.d.ts +797 -0
  61. package/generated/versions/defold-1.13.2/sound.d.ts +323 -0
  62. package/generated/versions/defold-1.13.2/sprite.d.ts +179 -0
  63. package/generated/versions/defold-1.13.2/sys.d.ts +754 -0
  64. package/generated/versions/defold-1.13.2/tilemap.d.ts +206 -0
  65. package/generated/versions/defold-1.13.2/timer.d.ts +136 -0
  66. package/generated/versions/defold-1.13.2/types.d.ts +61 -0
  67. package/generated/versions/defold-1.13.2/vmath.d.ts +775 -0
  68. package/generated/versions/defold-1.13.2/window.d.ts +196 -0
  69. package/generated/versions/defold-1.13.2/zlib.d.ts +41 -0
  70. package/identity-vocabulary.json +1 -0
  71. package/package.json +2 -2
  72. package/scripts/import-defold-release.ts +3 -31
  73. package/scripts/materialize-version.ts +13 -7
  74. package/scripts/regen.ts +63 -29
  75. package/scripts/sync-api-docs.ts +31 -2
  76. package/src/emit-dts.ts +25 -3
@@ -0,0 +1,308 @@
1
+ /** @noSelfInFile */
2
+ import type { Opaque, Vector3 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Query and cast functions for the Defold-owned Box2D v2 world.
7
+ */
8
+ namespace b2d.world {
9
+ /**
10
+ * The return value is the fraction of `translation` that can be traveled before collision,
11
+ * or 1 if there is no hit.
12
+ *
13
+ * @param world - world
14
+ * @param capsule - mover capsule
15
+ * @param translation - capsule displacement
16
+ * @param filter - optional query filter
17
+ * @returns travel fraction before collision
18
+ */
19
+ function cast_mover(world: Opaque<"b2World">, capsule: b2d.mover_capsule, translation: Vector3, filter?: b2d.query_filter): number;
20
+ /**
21
+ * Cast a ray.
22
+ *
23
+ * @param world - world from b2d.get_world or b2d.body.get_world
24
+ * @param origin - world ray origin
25
+ * @param translation - world ray translation
26
+ * @param filter - optional query filter
27
+ * @param max_results - optional maximum result count
28
+ */
29
+ function cast_ray(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_cast_hit[], b2d.tree_stats]>;
30
+ /**
31
+ * The translation is the ray displacement from `origin`. Result order is not
32
+ * guaranteed by Box2D.
33
+ *
34
+ * @param world - world
35
+ * @param origin - ray start position
36
+ * @param translation - ray displacement
37
+ * @param filter - optional query filter
38
+ * @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
39
+ */
40
+ function cast_ray(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_cast_hit[], b2d.tree_stats]>;
41
+ /**
42
+ * Cast a ray and return the closest hit.
43
+ *
44
+ * @param world - world from b2d.get_world or b2d.body.get_world
45
+ * @param origin - world ray origin
46
+ * @param translation - world ray translation
47
+ * @param filter - optional query filter
48
+ * @returns closest hit, or `nil`
49
+ */
50
+ function cast_ray_closest(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.fixture_cast_hit | undefined;
51
+ /**
52
+ * The translation is the ray displacement from `origin`.
53
+ *
54
+ * @param world - world
55
+ * @param origin - ray start position
56
+ * @param translation - ray displacement
57
+ * @param filter - optional query filter
58
+ * @returns closest hit, or `nil`
59
+ */
60
+ function cast_ray_closest(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.shape_cast_hit | undefined;
61
+ /**
62
+ * Uses Box2D v2 time-of-impact for fixture child shapes that support distance proxies.
63
+ * Grid fixture children are skipped.
64
+ *
65
+ * @param world - world from b2d.get_world or b2d.body.get_world
66
+ * @param shape - query shape
67
+ * @param translation - world shape translation
68
+ * @param filter - optional query filter
69
+ * @param max_results - optional maximum result count
70
+ */
71
+ function cast_shape(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_cast_hit[], b2d.tree_stats]>;
72
+ /**
73
+ * The translation is the shape displacement.
74
+ *
75
+ * @param world - world
76
+ * @param shape - cast shape
77
+ * @param translation - shape displacement
78
+ * @param filter - optional query filter
79
+ * @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
80
+ */
81
+ function cast_shape(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_cast_hit[], b2d.tree_stats]>;
82
+ /**
83
+ * Collide a mover capsule against the world.
84
+ *
85
+ * @param world - world
86
+ * @param capsule - mover capsule
87
+ * @param filter - optional query filter
88
+ * @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
89
+ * @returns collision planes
90
+ */
91
+ function collide_mover(world: Opaque<"b2World">, capsule: b2d.mover_capsule, filter?: b2d.query_filter, max_results?: number): b2d.mover_plane[];
92
+ /**
93
+ * Enable or disable continuous collision.
94
+ *
95
+ * @param world - world
96
+ * @param enable - true to enable continuous collision
97
+ */
98
+ function enable_continuous(world: Opaque<"b2World">, enable: boolean): void;
99
+ /**
100
+ * Enable or disable world sleeping.
101
+ *
102
+ * @param world - world
103
+ * @param enable - true to allow sleeping
104
+ */
105
+ function enable_sleeping(world: Opaque<"b2World">, enable: boolean): void;
106
+ /**
107
+ * Enable or disable speculative collision.
108
+ *
109
+ * @param world - world
110
+ * @param enable - true to enable speculative collision
111
+ */
112
+ function enable_speculative(world: Opaque<"b2World">, enable: boolean): void;
113
+ /**
114
+ * Enable or disable warm starting.
115
+ *
116
+ * @param world - world
117
+ * @param enable - true to enable warm starting
118
+ */
119
+ function enable_warm_starting(world: Opaque<"b2World">, enable: boolean): void;
120
+ /**
121
+ * Apply an explosion impulse.
122
+ *
123
+ * @param world - world
124
+ * @param definition - explosion definition
125
+ */
126
+ function explode(world: Opaque<"b2World">, definition: b2d.explosion_definition): void;
127
+ /**
128
+ * Get the number of awake bodies.
129
+ *
130
+ * @param world - world
131
+ * @returns awake body count
132
+ */
133
+ function get_awake_body_count(world: Opaque<"b2World">): number;
134
+ /**
135
+ * Get world counters.
136
+ *
137
+ * @param world - world
138
+ * @returns world counters
139
+ */
140
+ function get_counters(world: Opaque<"b2World">): b2d.world_counters;
141
+ /**
142
+ * Get world gravity.
143
+ *
144
+ * @param world - world
145
+ * @returns gravity vector
146
+ */
147
+ function get_gravity(world: Opaque<"b2World">): Vector3;
148
+ /**
149
+ * Get the hit event threshold.
150
+ *
151
+ * @param world - world
152
+ * @returns hit event threshold in project units per second
153
+ */
154
+ function get_hit_event_threshold(world: Opaque<"b2World">): number;
155
+ /**
156
+ * Get the maximum linear speed.
157
+ *
158
+ * @param world - world
159
+ * @returns maximum linear speed in project units per second
160
+ */
161
+ function get_maximum_linear_speed(world: Opaque<"b2World">): number;
162
+ /**
163
+ * Get world profiling data.
164
+ *
165
+ * @param world - world
166
+ * @returns world profiling data
167
+ */
168
+ function get_profile(world: Opaque<"b2World">): b2d.world_profile;
169
+ /**
170
+ * Get the restitution threshold.
171
+ *
172
+ * @param world - world
173
+ * @returns restitution threshold in project units per second
174
+ */
175
+ function get_restitution_threshold(world: Opaque<"b2World">): number;
176
+ /**
177
+ * Get whether continuous collision is enabled.
178
+ *
179
+ * @param world - world
180
+ * @returns true if continuous collision is enabled
181
+ */
182
+ function is_continuous_enabled(world: Opaque<"b2World">): boolean;
183
+ /**
184
+ * The world is locked during callbacks and some simulation phases. Functions
185
+ * marked as locked during callbacks cannot be called while this returns true.
186
+ *
187
+ * @param world - world
188
+ * @returns true if the world is locked
189
+ */
190
+ function is_locked(world: Opaque<"b2World">): boolean;
191
+ /**
192
+ * Get whether world sleeping is enabled.
193
+ *
194
+ * @param world - world
195
+ * @returns true if sleeping is enabled
196
+ */
197
+ function is_sleeping_enabled(world: Opaque<"b2World">): boolean;
198
+ /**
199
+ * Check whether a world handle is valid.
200
+ *
201
+ * @param world - world
202
+ * @returns true if the world handle is valid
203
+ */
204
+ function is_valid(world: Opaque<"b2World">): boolean;
205
+ /**
206
+ * Get whether warm starting is enabled.
207
+ *
208
+ * @param world - world
209
+ * @returns true if warm starting is enabled
210
+ */
211
+ function is_warm_starting_enabled(world: Opaque<"b2World">): boolean;
212
+ /**
213
+ * Overlap an AABB.
214
+ *
215
+ * @param world - world from b2d.get_world or b2d.body.get_world
216
+ * @param aabb - query bounds
217
+ * @param filter - optional query filter
218
+ * @param max_results - optional maximum result count
219
+ * @returns `[fixtures, stats]`:
220
+ * - `fixtures` — overlapping fixtures. **⚠️ `index` is 1-based; passed to Defold unchanged.**
221
+ * - `stats` — broad-phase query statistics
222
+ */
223
+ function overlap_aabb(world: Opaque<"b2World">, aabb: b2d.aabb, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_info[], b2d.tree_stats]>;
224
+ /**
225
+ * Find shapes overlapping an AABB.
226
+ *
227
+ * @param world - world
228
+ * @param aabb - query bounds
229
+ * @param filter - optional query filter
230
+ * @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
231
+ */
232
+ function overlap_aabb(world: Opaque<"b2World">, aabb: b2d.aabb, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_info[], b2d.tree_stats]>;
233
+ /**
234
+ * Overlap a shape.
235
+ *
236
+ * @param world - world from b2d.get_world or b2d.body.get_world
237
+ * @param shape - query shape
238
+ * @param filter - optional query filter
239
+ * @param max_results - optional maximum result count
240
+ * @returns `[fixtures, stats]`:
241
+ * - `fixtures` — overlapping fixtures. **⚠️ `index` is 1-based; passed to Defold unchanged.**
242
+ * - `stats` — broad-phase query statistics
243
+ */
244
+ function overlap_shape(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_info[], b2d.tree_stats]>;
245
+ /**
246
+ * Find shapes overlapping a shape proxy.
247
+ *
248
+ * @param world - world
249
+ * @param shape - query shape
250
+ * @param filter - optional query filter
251
+ * @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
252
+ */
253
+ function overlap_shape(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_info[], b2d.tree_stats]>;
254
+ /**
255
+ * Rebuild the static broad-phase tree.
256
+ *
257
+ * @param world - world
258
+ */
259
+ function rebuild_static_tree(world: Opaque<"b2World">): void;
260
+ /**
261
+ * Set contact solver tuning.
262
+ *
263
+ * @param world - world
264
+ * @param hertz - contact stiffness frequency in hertz
265
+ * @param damping_ratio - contact damping ratio
266
+ * @param pushout - pushout velocity in project units per second
267
+ */
268
+ function set_contact_tuning(world: Opaque<"b2World">, hertz: number, damping_ratio: number, pushout: number): void;
269
+ /**
270
+ * Set world gravity.
271
+ *
272
+ * @param world - world
273
+ * @param gravity - gravity vector
274
+ */
275
+ function set_gravity(world: Opaque<"b2World">, gravity: Vector3): void;
276
+ /**
277
+ * Set the hit event threshold.
278
+ *
279
+ * @param world - world
280
+ * @param threshold - hit event threshold in project units per second
281
+ */
282
+ function set_hit_event_threshold(world: Opaque<"b2World">, threshold: number): void;
283
+ /**
284
+ * Set joint solver tuning.
285
+ *
286
+ * @param world - world
287
+ * @param hertz - joint stiffness frequency in hertz
288
+ * @param damping_ratio - joint damping ratio
289
+ */
290
+ function set_joint_tuning(world: Opaque<"b2World">, hertz: number, damping_ratio: number): void;
291
+ /**
292
+ * Set the maximum linear speed.
293
+ *
294
+ * @param world - world
295
+ * @param speed - maximum linear speed in project units per second
296
+ */
297
+ function set_maximum_linear_speed(world: Opaque<"b2World">, speed: number): void;
298
+ /**
299
+ * Collisions below this relative speed use inelastic collision response.
300
+ *
301
+ * @param world - world
302
+ * @param threshold - restitution threshold in project units per second
303
+ */
304
+ function set_restitution_threshold(world: Opaque<"b2World">, threshold: number): void;
305
+ }
306
+ }
307
+
308
+ export {};
@@ -0,0 +1,192 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Opaque } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions for manipulating buffers and streams
7
+ */
8
+ namespace buffer {
9
+ type buffer_data = Opaque<"buffer">;
10
+ type buffer_stream = Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> };
11
+ type ValueType = typeof buffer.VALUE_TYPE_FLOAT32 | typeof buffer.VALUE_TYPE_INT16 | typeof buffer.VALUE_TYPE_INT32 | typeof buffer.VALUE_TYPE_INT64 | typeof buffer.VALUE_TYPE_INT8 | typeof buffer.VALUE_TYPE_UINT16 | typeof buffer.VALUE_TYPE_UINT32 | typeof buffer.VALUE_TYPE_UINT64 | typeof buffer.VALUE_TYPE_UINT8;
12
+ type VALUE_TYPE = typeof buffer.VALUE_TYPE_FLOAT32 | typeof buffer.VALUE_TYPE_INT16 | typeof buffer.VALUE_TYPE_INT32 | typeof buffer.VALUE_TYPE_INT64 | typeof buffer.VALUE_TYPE_INT8 | typeof buffer.VALUE_TYPE_UINT16 | typeof buffer.VALUE_TYPE_UINT32 | typeof buffer.VALUE_TYPE_UINT64 | typeof buffer.VALUE_TYPE_UINT8;
13
+ /**
14
+ * float32 Float, single precision, 4 bytes
15
+ */
16
+ const VALUE_TYPE_FLOAT32: number & { readonly __brand: "buffer.VALUE_TYPE_FLOAT32" };
17
+ /**
18
+ * int16 Signed integer, 2 bytes
19
+ */
20
+ const VALUE_TYPE_INT16: number & { readonly __brand: "buffer.VALUE_TYPE_INT16" };
21
+ /**
22
+ * int32 Signed integer, 4 bytes
23
+ */
24
+ const VALUE_TYPE_INT32: number & { readonly __brand: "buffer.VALUE_TYPE_INT32" };
25
+ /**
26
+ * int64 Signed integer, 8 bytes
27
+ */
28
+ const VALUE_TYPE_INT64: number & { readonly __brand: "buffer.VALUE_TYPE_INT64" };
29
+ /**
30
+ * int8 Signed integer, 1 byte
31
+ */
32
+ const VALUE_TYPE_INT8: number & { readonly __brand: "buffer.VALUE_TYPE_INT8" };
33
+ /**
34
+ * uint16 Unsigned integer, 2 bytes
35
+ */
36
+ const VALUE_TYPE_UINT16: number & { readonly __brand: "buffer.VALUE_TYPE_UINT16" };
37
+ /**
38
+ * uint32 Unsigned integer, 4 bytes
39
+ */
40
+ const VALUE_TYPE_UINT32: number & { readonly __brand: "buffer.VALUE_TYPE_UINT32" };
41
+ /**
42
+ * uint64 Unsigned integer, 8 bytes
43
+ */
44
+ const VALUE_TYPE_UINT64: number & { readonly __brand: "buffer.VALUE_TYPE_UINT64" };
45
+ /**
46
+ * uint8 Unsigned integer, 1 byte
47
+ */
48
+ const VALUE_TYPE_UINT8: number & { readonly __brand: "buffer.VALUE_TYPE_UINT8" };
49
+ /**
50
+ * Copy all data streams from one buffer to another, element wise.
51
+ * Each of the source streams must have a matching stream in the
52
+ * destination buffer. The streams must match in both type and size.
53
+ * The source and destination buffer can be the same.
54
+ *
55
+ * @param dst - the destination buffer
56
+ * @param dstoffset - the offset to start copying data to
57
+ * @param src - the source data buffer
58
+ * @param srcoffset - the offset to start copying data from
59
+ * @param count - the number of elements to copy
60
+ * @example
61
+ * ```ts
62
+ * // How to copy elements (e.g. vertices) from one buffer to another
63
+ * const element_count = 64;
64
+ * const srcbuffer = resource.get_buffer("/src.bufferc");
65
+ * const dstbuffer = resource.get_buffer("/dst.bufferc");
66
+ *
67
+ * // copy entire buffer
68
+ * buffer.copy_buffer(dstbuffer, 0, srcbuffer, 0, element_count);
69
+ *
70
+ * // copy last 10 elements to the front of another buffer
71
+ * buffer.copy_buffer(dstbuffer, 0, srcbuffer, element_count - 10, 10);
72
+ * ```
73
+ */
74
+ function copy_buffer(dst: Opaque<"buffer">, dstoffset: number, src: Opaque<"buffer">, srcoffset: number, count: number): void;
75
+ /**
76
+ * Copy a specified amount of data from one stream to another.
77
+ * The value type and size must match between source and destination streams.
78
+ * The source and destination streams can be the same.
79
+ *
80
+ * @param dst - the destination stream
81
+ * @param dstoffset - the offset to start copying data to (measured in value type)
82
+ * @param src - the source data stream
83
+ * @param srcoffset - the offset to start copying data from (measured in value type)
84
+ * @param count - the number of values to copy (measured in value type)
85
+ * @example
86
+ * ```ts
87
+ * // How to update a texture of a sprite:
88
+ * const srcbuffer = resource.get_buffer("/src.bufferc");
89
+ * const dstbuffer = resource.get_buffer("/dst.bufferc");
90
+ *
91
+ * // copy entire stream
92
+ * const srcstream = buffer.get_stream(srcbuffer, hash("xyz"));
93
+ * const dststream = buffer.get_stream(dstbuffer, hash("xyz"));
94
+ * buffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length());
95
+ * ```
96
+ */
97
+ function copy_stream(dst: Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> }, dstoffset: number, src: Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> }, srcoffset: number, count: number): void;
98
+ /**
99
+ * Create a new data buffer containing a specified set of streams. A data buffer
100
+ * can contain one or more streams with typed data. This is useful for managing
101
+ * compound data, for instance a vertex buffer could contain separate streams for
102
+ * vertex position, color, normal etc.
103
+ *
104
+ * @param element_count - The number of elements the buffer should hold
105
+ * @param declaration - A table where each entry (table) describes a stream
106
+ *
107
+ * - hash | string `name`: The name of the stream
108
+ * - buffer.VALUE_TYPE `type`: The data type of the stream
109
+ * - number `count`: The number of values each element should hold
110
+ * @returns the new buffer
111
+ * @example
112
+ * ```ts
113
+ * // How to create and initialize a buffer
114
+ * export default defineScript({
115
+ * init() {
116
+ * const size = 128;
117
+ * const [width, height] = [size, size];
118
+ * const [r, g, b] = [0xff, 0x80, 0x10];
119
+ * const image = buffer.create(size * size, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
120
+ * const imagestream = buffer.get_stream(image, hash("rgb"));
121
+ *
122
+ * for (let y = 0; y < height; y++) {
123
+ * for (let x = 0; x < width; x++) {
124
+ * const index = y * width * 3 + x * 3;
125
+ * imagestream[index + 0] = r;
126
+ * imagestream[index + 1] = g;
127
+ * imagestream[index + 2] = b;
128
+ * }
129
+ * }
130
+ * return { image, imagestream };
131
+ * },
132
+ * });
133
+ * ```
134
+ */
135
+ function create(element_count: number, declaration: ({ name: Hash | string; type: buffer.VALUE_TYPE; count: number })[]): Opaque<"buffer">;
136
+ /**
137
+ * Get a copy of all the bytes from a specified stream as a Lua string.
138
+ *
139
+ * @param buffer - the source buffer
140
+ * @param stream_name - the name of the stream
141
+ * @returns the buffer data as a Lua string
142
+ */
143
+ function get_bytes(buffer: Opaque<"buffer">, stream_name: Hash | string): string;
144
+ /**
145
+ * Get a named metadata entry from a buffer along with its type.
146
+ *
147
+ * @param buf - the buffer to get the metadata from
148
+ * @param metadata_name - name of the metadata entry
149
+ * @example
150
+ * ```ts
151
+ * // How to get a metadata entry from a buffer
152
+ * const buf = resource.get_buffer("/my.bufferc");
153
+ *
154
+ * // retrieve a metadata entry named "somefloats" and its numeric type
155
+ * const [values, type] = buffer.get_metadata(buf, hash("somefloats"));
156
+ * if (values) print(`${values.length} values in 'somefloats'`);
157
+ * ```
158
+ */
159
+ function get_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string): LuaMultiReturn<[number[] | undefined, buffer.VALUE_TYPE | undefined]>;
160
+ /**
161
+ * Get a specified stream from a buffer.
162
+ *
163
+ * @param buffer - the buffer to get the stream from
164
+ * @param stream_name - the stream name
165
+ * @returns the data stream
166
+ */
167
+ function get_stream(buffer: Opaque<"buffer">, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> };
168
+ /**
169
+ * Creates or updates a metadata array entry on a buffer.
170
+ * The value type and count given when updating the entry should match those used when first creating it.
171
+ *
172
+ * @param buf - the buffer to set the metadata on
173
+ * @param metadata_name - name of the metadata entry
174
+ * @param values - actual metadata, an array of numeric values
175
+ * @param value_type - type of values when stored
176
+ * @example
177
+ * ```ts
178
+ * // How to set a metadata entry on a buffer
179
+ * const buf = resource.get_buffer("/my.bufferc");
180
+ *
181
+ * // create a new metadata entry with three floats
182
+ * buffer.set_metadata(buf, hash("somefloats"), [1.5, 3.2, 7.9], buffer.VALUE_TYPE_FLOAT32);
183
+ * // ...
184
+ * // update to a new set of values
185
+ * buffer.set_metadata(buf, hash("somefloats"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);
186
+ * ```
187
+ */
188
+ function set_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string, values: number[], value_type: buffer.VALUE_TYPE): void;
189
+ }
190
+ }
191
+
192
+ export {};
@@ -0,0 +1,91 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Opaque, Url } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Native-style access to the Bullet 3D world and collision objects owned by
7
+ * Defold. World creation, destruction and stepping remain controlled by Defold.
8
+ * The backend name refers to three-dimensional physics.
9
+ *
10
+ * World, collision-object and rigid-body userdata are borrowed handles to
11
+ * Defold-owned objects. Shape userdata are borrowed logical child-slot handles
12
+ * attached to a collision object. Constraint userdata identify auxiliary native
13
+ * objects owned by this Lua API; destroy them explicitly when no longer needed.
14
+ * They are also destroyed automatically when a required body or world is
15
+ * destroyed.
16
+ *
17
+ * A collision-object, rigid-body or shape handle becomes invalid when its
18
+ * collision object is deleted or reloaded. A world handle remains valid across
19
+ * collision-object reloads, but becomes invalid when its collection and physics
20
+ * world are destroyed. The corresponding `is_valid()` function is safe for
21
+ * checking a retained handle; every other operation rejects an invalid handle.
22
+ */
23
+ namespace bullet3d {
24
+ type btCollisionObject = Opaque<"btCollisionObject" | "btRigidBody">;
25
+ type btDiscreteDynamicsWorld = Opaque<"btDiscreteDynamicsWorld">;
26
+ type btRigidBody = Opaque<"btRigidBody">;
27
+ /**
28
+ * Bullet version information
29
+ */
30
+ interface version_info {
31
+ /**
32
+ * full Bullet version string
33
+ */
34
+ version: string;
35
+ /**
36
+ * compact numeric Bullet version
37
+ */
38
+ number: number;
39
+ /**
40
+ * major version number
41
+ */
42
+ major: number;
43
+ /**
44
+ * minor version number
45
+ */
46
+ minor: number;
47
+ }
48
+ /**
49
+ * This returns both rigid bodies and ghost trigger objects.
50
+ * This function raises an error unless the collection uses 3D physics.
51
+ *
52
+ * @param url - collision object component URL
53
+ * @returns the collision object, or `nil`
54
+ */
55
+ function get_collision_object(url: string | Hash | Url): Opaque<"btCollisionObject" | "btRigidBody"> | undefined;
56
+ /**
57
+ * Trigger components are ghost objects, so this function returns `nil` for them.
58
+ * This function raises an error unless the collection uses 3D physics.
59
+ *
60
+ * @param url - collision object component URL
61
+ * @returns the rigid body handle, or `nil`
62
+ * @example
63
+ * ```ts
64
+ * const world = bullet3d.get_world();
65
+ * const body = bullet3d.get_rigid_body("#collisionobject");
66
+ * if (world !== undefined && body !== undefined && bullet3d.rigid_body.is_valid(body)) {
67
+ * bullet3d.rigid_body.apply_central_impulse(body, vmath.vector3(0, 10, 0));
68
+ * }
69
+ *
70
+ * // A trigger is a collision object, not a rigid body.
71
+ * const trigger = bullet3d.get_collision_object("#trigger");
72
+ * assert(trigger !== undefined && bullet3d.get_rigid_body("#trigger") === undefined);
73
+ * ```
74
+ */
75
+ function get_rigid_body(url: string | Hash | Url): Opaque<"btRigidBody"> | undefined;
76
+ /**
77
+ * Get the Bullet version
78
+ *
79
+ * @returns version information
80
+ */
81
+ function get_version(): bullet3d.version_info;
82
+ /**
83
+ * This function raises an error unless the collection uses 3D physics.
84
+ *
85
+ * @returns the world, or `nil` if the collection has no physics world
86
+ */
87
+ function get_world(): bullet3d.btDiscreteDynamicsWorld | undefined;
88
+ }
89
+ }
90
+
91
+ export {};