@defold-typescript/types 0.48.0 → 0.50.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 (78) 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/hsm/debug.d.ts +6 -3
  71. package/hsm/index.d.ts +309 -77
  72. package/identity-vocabulary.json +1 -0
  73. package/package.json +2 -2
  74. package/scripts/import-defold-release.ts +3 -31
  75. package/scripts/materialize-version.ts +13 -7
  76. package/scripts/regen.ts +63 -29
  77. package/scripts/sync-api-docs.ts +31 -2
  78. package/src/emit-dts.ts +25 -3
@@ -0,0 +1,789 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Url, Vector3 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Collision object physics API documentation
7
+ */
8
+ namespace physics {
9
+ type event = BuiltinMessages["contact_point_event"] | BuiltinMessages["collision_event"] | BuiltinMessages["trigger_event"] | BuiltinMessages["ray_cast_response"] | BuiltinMessages["ray_cast_missed"];
10
+ /**
11
+ * The available fields depend on the joint type.
12
+ */
13
+ interface joint_properties {
14
+ /**
15
+ * whether the connected objects should collide
16
+ */
17
+ collide_connected?: boolean;
18
+ /**
19
+ * Natural spring length between the anchor points.
20
+ */
21
+ length?: number;
22
+ /**
23
+ * Mass-spring-damper frequency in Hertz; zero disables softness.
24
+ */
25
+ frequency?: number;
26
+ /**
27
+ * Damping ratio, where zero is no damping and one is critical damping.
28
+ */
29
+ damping?: number;
30
+ /**
31
+ * Maximum fixed-joint rope length.
32
+ */
33
+ max_length?: number;
34
+ /**
35
+ * Local translation unit axis in the first body.
36
+ */
37
+ local_axis_a?: Vector3;
38
+ /**
39
+ * Angle of the second body relative to the first body, in radians.
40
+ */
41
+ reference_angle?: number;
42
+ /**
43
+ * Lower angular limit in radians.
44
+ */
45
+ lower_angle?: number;
46
+ /**
47
+ * Upper angular limit in radians.
48
+ */
49
+ upper_angle?: number;
50
+ /**
51
+ * Lower translation limit, usually in meters.
52
+ */
53
+ lower_translation?: number;
54
+ /**
55
+ * Upper translation limit, usually in meters.
56
+ */
57
+ upper_translation?: number;
58
+ /**
59
+ * Maximum motor torque used to reach the desired speed, usually in N-m.
60
+ */
61
+ max_motor_torque?: number;
62
+ /**
63
+ * Maximum motor force used to reach the desired speed.
64
+ */
65
+ max_motor_force?: number;
66
+ /**
67
+ * Desired motor speed.
68
+ */
69
+ motor_speed?: number;
70
+ /**
71
+ * Whether joint limits are enabled.
72
+ */
73
+ enable_limit?: boolean;
74
+ /**
75
+ * Whether the joint motor is enabled.
76
+ */
77
+ enable_motor?: boolean;
78
+ }
79
+ /**
80
+ * The available optional fields depend on the joint type.
81
+ */
82
+ interface joint_properties_info {
83
+ /**
84
+ * whether the connected objects collide
85
+ */
86
+ collide_connected: boolean;
87
+ /**
88
+ * spring length
89
+ */
90
+ length?: number;
91
+ /**
92
+ * spring frequency
93
+ */
94
+ frequency?: number;
95
+ /**
96
+ * damping ratio
97
+ */
98
+ damping?: number;
99
+ /**
100
+ * fixed-joint maximum length
101
+ */
102
+ max_length?: number;
103
+ /**
104
+ * local joint axis
105
+ */
106
+ local_axis_a?: Vector3;
107
+ /**
108
+ * reference angle
109
+ */
110
+ reference_angle?: number;
111
+ /**
112
+ * lower angular limit
113
+ */
114
+ lower_angle?: number;
115
+ /**
116
+ * upper angular limit
117
+ */
118
+ upper_angle?: number;
119
+ /**
120
+ * lower translation limit
121
+ */
122
+ lower_translation?: number;
123
+ /**
124
+ * upper translation limit
125
+ */
126
+ upper_translation?: number;
127
+ /**
128
+ * maximum motor torque
129
+ */
130
+ max_motor_torque?: number;
131
+ /**
132
+ * maximum motor force
133
+ */
134
+ max_motor_force?: number;
135
+ /**
136
+ * motor speed
137
+ */
138
+ motor_speed?: number;
139
+ /**
140
+ * whether limits are enabled
141
+ */
142
+ enable_limit?: boolean;
143
+ /**
144
+ * whether the motor is enabled
145
+ */
146
+ enable_motor?: boolean;
147
+ /**
148
+ * Read-only current hinge angle in radians.
149
+ */
150
+ joint_angle?: number;
151
+ /**
152
+ * Read-only current hinge angular speed or slider/wheel translation speed.
153
+ */
154
+ joint_speed?: number;
155
+ /**
156
+ * Read-only current slider or wheel translation, usually in meters.
157
+ */
158
+ joint_translation?: number;
159
+ }
160
+ /**
161
+ * Ray-cast options
162
+ */
163
+ interface raycast_options {
164
+ /**
165
+ * Return every hit instead of only the closest hit.
166
+ */
167
+ all?: boolean;
168
+ }
169
+ /**
170
+ * The available geometry fields depend on `type`.
171
+ */
172
+ interface shape_data {
173
+ /**
174
+ * shape type
175
+ */
176
+ type: physics.SHAPE_TYPE;
177
+ /**
178
+ * sphere diameter or capsule pole diameter
179
+ */
180
+ diameter?: number;
181
+ /**
182
+ * box dimensions
183
+ */
184
+ dimensions?: Vector3;
185
+ /**
186
+ * capsule height
187
+ */
188
+ height?: number;
189
+ }
190
+ type JOINT_TYPE = typeof physics.JOINT_TYPE_FIXED | typeof physics.JOINT_TYPE_HINGE | typeof physics.JOINT_TYPE_SLIDER | typeof physics.JOINT_TYPE_SPRING | typeof physics.JOINT_TYPE_WELD | typeof physics.JOINT_TYPE_WHEEL;
191
+ type SHAPE_TYPE = typeof physics.SHAPE_TYPE_BOX | typeof physics.SHAPE_TYPE_CAPSULE | typeof physics.SHAPE_TYPE_HULL | typeof physics.SHAPE_TYPE_MESH | typeof physics.SHAPE_TYPE_SPHERE;
192
+ /**
193
+ * Fixed joint; uses `max_length` from physics.joint_properties.
194
+ */
195
+ const JOINT_TYPE_FIXED: number & { readonly __brand: "physics.JOINT_TYPE_FIXED" };
196
+ /**
197
+ * Hinge joint; uses the angular-limit and motor fields from physics.joint_properties.
198
+ */
199
+ const JOINT_TYPE_HINGE: number & { readonly __brand: "physics.JOINT_TYPE_HINGE" };
200
+ /**
201
+ * Slider joint; uses the translation-limit and motor fields from physics.joint_properties.
202
+ */
203
+ const JOINT_TYPE_SLIDER: number & { readonly __brand: "physics.JOINT_TYPE_SLIDER" };
204
+ /**
205
+ * Spring joint; uses `length`, `frequency`, and `damping` from physics.joint_properties.
206
+ */
207
+ const JOINT_TYPE_SPRING: number & { readonly __brand: "physics.JOINT_TYPE_SPRING" };
208
+ /**
209
+ * Weld joint; uses `reference_angle`, `frequency`, and `damping` from physics.joint_properties.
210
+ */
211
+ const JOINT_TYPE_WELD: number & { readonly __brand: "physics.JOINT_TYPE_WELD" };
212
+ /**
213
+ * Wheel joint; uses the axis, motor, frequency, and damping fields from physics.joint_properties.
214
+ */
215
+ const JOINT_TYPE_WHEEL: number & { readonly __brand: "physics.JOINT_TYPE_WHEEL" };
216
+ /**
217
+ * Box shape.
218
+ */
219
+ const SHAPE_TYPE_BOX: number & { readonly __brand: "physics.SHAPE_TYPE_BOX" };
220
+ /**
221
+ * Capsule shape; supported only by 3D physics.
222
+ */
223
+ const SHAPE_TYPE_CAPSULE: number & { readonly __brand: "physics.SHAPE_TYPE_CAPSULE" };
224
+ /**
225
+ * Convex hull shape.
226
+ */
227
+ const SHAPE_TYPE_HULL: number & { readonly __brand: "physics.SHAPE_TYPE_HULL" };
228
+ /**
229
+ * Triangle mesh shape; supported only by the Bullet 3D backend.
230
+ */
231
+ const SHAPE_TYPE_MESH: number & { readonly __brand: "physics.SHAPE_TYPE_MESH" };
232
+ /**
233
+ * Sphere shape.
234
+ */
235
+ const SHAPE_TYPE_SPHERE: number & { readonly __brand: "physics.SHAPE_TYPE_SPHERE" };
236
+ /**
237
+ * Create a physics joint between two collision object components.
238
+ * Note: Currently only supported in 2D physics.
239
+ *
240
+ * @param joint_type - the joint type
241
+ * @param collisionobject_a - first collision object
242
+ * @param joint_id - id of the joint
243
+ * @param position_a - local position where to attach the joint on the first collision object
244
+ * @param collisionobject_b - second collision object
245
+ * @param position_b - local position where to attach the joint on the second collision object
246
+ * @param properties - optional joint-specific properties
247
+ */
248
+ function create_joint(joint_type: physics.JOINT_TYPE, collisionobject_a: string | Hash | Url, joint_id: string | Hash, position_a: Vector3, collisionobject_b: string | Hash | Url, position_b: Vector3, properties?: physics.joint_properties): void;
249
+ /**
250
+ * Destroy an already physics joint. The joint has to be created before a
251
+ * destroy can be issued.
252
+ * Note: Currently only supported in 2D physics.
253
+ *
254
+ * @param collisionobject - collision object where the joint exist
255
+ * @param joint_id - id of the joint
256
+ */
257
+ function destroy_joint(collisionobject: string | Hash | Url, joint_id: string | Hash): void;
258
+ /**
259
+ * Get the gravity in runtime. The gravity returned is not global, it will return
260
+ * the gravity for the collection that the function is called from.
261
+ * Note: For 2D physics the z component will always be zero.
262
+ *
263
+ * @returns gravity vector of collection
264
+ * @example
265
+ * ```ts
266
+ * export default defineScript({
267
+ * init(self) {
268
+ * let gravity = physics.get_gravity();
269
+ * // Inverse gravity!
270
+ * gravity = vmath.vector3(-gravity.x, -gravity.y, -gravity.z);
271
+ * physics.set_gravity(gravity);
272
+ * },
273
+ * });
274
+ * ```
275
+ */
276
+ function get_gravity(): Vector3;
277
+ /**
278
+ * Returns the group name of a collision object as a hash.
279
+ *
280
+ * @param url - the collision object to return the group of.
281
+ * @returns hash value of the group.
282
+ * @example
283
+ * ```ts
284
+ * function check_is_enemy(): boolean {
285
+ * const group = physics.get_group("#collisionobject");
286
+ * return group === hash("enemy");
287
+ * }
288
+ * ```
289
+ */
290
+ function get_group(url: string | Hash | Url): Hash;
291
+ /**
292
+ * Get a table for properties for a connected joint. The joint has to be created before
293
+ * properties can be retrieved.
294
+ * Note: Currently only supported in 2D physics.
295
+ *
296
+ * @param collisionobject - collision object where the joint exist
297
+ * @param joint_id - id of the joint
298
+ * @returns joint properties
299
+ */
300
+ function get_joint_properties(collisionobject: string | Hash | Url, joint_id: string | Hash): physics.joint_properties_info;
301
+ /**
302
+ * Get the reaction force for a joint. The joint has to be created before
303
+ * the reaction force can be calculated.
304
+ * Note: Currently only supported in 2D physics.
305
+ *
306
+ * @param collisionobject - collision object where the joint exist
307
+ * @param joint_id - id of the joint
308
+ * @returns reaction force for the joint
309
+ */
310
+ function get_joint_reaction_force(collisionobject: string | Hash | Url, joint_id: string | Hash): Vector3;
311
+ /**
312
+ * Get the reaction torque for a joint. The joint has to be created before
313
+ * the reaction torque can be calculated.
314
+ * Note: Currently only supported in 2D physics.
315
+ *
316
+ * @param collisionobject - collision object where the joint exist
317
+ * @param joint_id - id of the joint
318
+ * @returns the reaction torque on bodyB in N*m.
319
+ */
320
+ function get_joint_reaction_torque(collisionobject: string | Hash | Url, joint_id: string | Hash): number;
321
+ /**
322
+ * Returns true if the specified group is set in the mask of a collision
323
+ * object, false otherwise.
324
+ *
325
+ * @param url - the collision object to check the mask of.
326
+ * @param group - the name of the group to check for.
327
+ * @returns boolean value of the maskbit. 'true' if present, 'false' otherwise.
328
+ * @example
329
+ * ```ts
330
+ * function is_invincible(): boolean {
331
+ * // check if the collisionobject would collide with the "bullet" group
332
+ * const invincible = physics.get_maskbit("#collisionobject", "bullet");
333
+ * return invincible;
334
+ * }
335
+ * ```
336
+ */
337
+ function get_maskbit(url: string | Hash | Url, group: string | Hash): boolean;
338
+ /**
339
+ * Gets collision shape data from a collision object
340
+ *
341
+ * @param url - the collision object.
342
+ * @param shape - the name of the shape to get data for.
343
+ * @returns collision shape data
344
+ * @example
345
+ * ```ts
346
+ * function get_shape_meta() {
347
+ * const sphere = physics.get_shape("#collisionobject", "my_sphere_shape");
348
+ * // returns a table with sphere.diameter
349
+ * return sphere;
350
+ * }
351
+ * ```
352
+ */
353
+ function get_shape(url: string | Hash | Url, shape: string | Hash): physics.shape_data;
354
+ /**
355
+ * Ray casts are used to test for intersections against collision objects in the physics world.
356
+ * Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
357
+ * do not intersect with ray casts.
358
+ * Which collision objects to hit is filtered by their collision groups and can be configured
359
+ * through `groups`.
360
+ * NOTE: Ray casts will ignore collision objects that contain the starting point of the ray. This is a limitation in Box2D.
361
+ *
362
+ * @param from - the world position of the start of the ray
363
+ * @param to - the world position of the end of the ray
364
+ * @param groups - a lua table containing the hashed groups for which to test collisions against
365
+ * @param options - optional ray-cast options
366
+ * @returns It returns a list. If missed it returns `nil`. See ray_cast_response for details on the returned values.
367
+ * @example
368
+ * ```ts
369
+ * function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash; request_id: number }) {
370
+ * // act on the hit (see 'ray_cast_response')
371
+ * }
372
+ *
373
+ * // How to perform a ray cast synchronously:
374
+ * export default defineScript({
375
+ * init() {
376
+ * return { groups: [hash("world"), hash("enemy")] };
377
+ * },
378
+ *
379
+ * update(self, dt) {
380
+ * // request ray cast
381
+ * const from = go.get_world_position();
382
+ * const to = vmath.vector3(from.x, from.y - 100, from.z);
383
+ * const results = physics.raycast(from, to, self.groups, { all: true });
384
+ * if (results !== undefined) {
385
+ * // with `all` set, the ray cast returns every hit as a list
386
+ * for (const result of Array.isArray(results) ? results : [results]) {
387
+ * handle_result(result);
388
+ * }
389
+ * }
390
+ * },
391
+ * });
392
+ * ```
393
+ */
394
+ function raycast(from: Vector3, to: Vector3, groups: Hash[], options?: physics.raycast_options): BuiltinMessages["ray_cast_response"][] | BuiltinMessages["ray_cast_response"] | undefined;
395
+ /**
396
+ * Ray casts are used to test for intersections against collision objects in the physics world.
397
+ * Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
398
+ * do not intersect with ray casts.
399
+ * Which collision objects to hit is filtered by their collision groups and can be configured
400
+ * through `groups`.
401
+ * The actual ray cast will be performed during the physics-update.
402
+ *
403
+ * - If an object is hit, the result will be reported via a ray_cast_response message.
404
+ * - If there is no object hit, the result will be reported via a ray_cast_missed message.
405
+ *
406
+ * NOTE: Ray casts will ignore collision objects that contain the starting point of the ray. This is a limitation in Box2D.
407
+ *
408
+ * @param from - the world position of the start of the ray
409
+ * @param to - the world position of the end of the ray
410
+ * @param groups - a lua table containing the hashed groups for which to test collisions against
411
+ * @param request_id - a number in range [0,255]. It will be sent back in the response for identification, 0 by default
412
+ * @example
413
+ * ```ts
414
+ * // How to perform a ray cast asynchronously:
415
+ * export default defineScript({
416
+ * init() {
417
+ * return { my_groups: [hash("my_group1"), hash("my_group2")] };
418
+ * },
419
+ *
420
+ * update(self, dt) {
421
+ * // request ray cast
422
+ * const my_start = go.get_world_position();
423
+ * const my_end = vmath.vector3(my_start.x, my_start.y - 100, my_start.z);
424
+ * physics.raycast_async(my_start, my_end, self.my_groups);
425
+ * },
426
+ *
427
+ * on_message(self, message_id, message, sender) {
428
+ * // check for the response
429
+ * if (message_id === hash("ray_cast_response")) {
430
+ * // act on the hit
431
+ * } else if (message_id === hash("ray_cast_missed")) {
432
+ * // act on the miss
433
+ * }
434
+ * },
435
+ * });
436
+ * ```
437
+ */
438
+ function raycast_async(from: Vector3, to: Vector3, groups: Hash[], request_id?: number): void;
439
+ /**
440
+ * Only one physics world event listener can be set at a time.
441
+ *
442
+ * @param callback - A callback that receives information about all physics interactions in this physics world. Pass `nil` to remove the listener.
443
+ *
444
+ * `self`
445
+ * script_instance The calling script instance
446
+ * `events`
447
+ * physics.event[] An array of event tables. Each event table contains a `type` field with the hashed name of one of these messages, together with fields specific to that event type:
448
+ *
449
+ * - contact_point_event
450
+ * - collision_event
451
+ * - trigger_event
452
+ * - ray_cast_response
453
+ * - ray_cast_missed
454
+ * @example
455
+ * ```ts
456
+ * function physics_world_listener(self: unknown, events: unknown) {
457
+ * for (const event of events as Record<string, unknown>[]) {
458
+ * const event_type = event["type"];
459
+ * if (event_type === hash("contact_point_event")) {
460
+ * pprint(event);
461
+ * // {
462
+ * // distance = 2.1490633487701,
463
+ * // applied_impulse = 0
464
+ * // a = { --[[0x113f7c6c0]]
465
+ * // group = hash: [box],
466
+ * // id = hash: [/box]
467
+ * // mass = 0,
468
+ * // normal = vmath.vector3(0.379, 0.925, -0),
469
+ * // position = vmath.vector3(517.337, 235.068, 0),
470
+ * // instance_position = vmath.vector3(480, 144, 0),
471
+ * // relative_velocity = vmath.vector3(-0, -0, -0),
472
+ * // },
473
+ * // b = { --[[0x113f7c840]]
474
+ * // group = hash: [circle],
475
+ * // id = hash: [/circle]
476
+ * // mass = 0,
477
+ * // normal = vmath.vector3(-0.379, -0.925, 0),
478
+ * // position = vmath.vector3(517.337, 235.068, 0),
479
+ * // instance_position = vmath.vector3(-0.0021, 0, -0.0022),
480
+ * // relative_velocity = vmath.vector3(0, 0, 0),
481
+ * // },
482
+ * // }
483
+ * } else if (event_type === hash("collision_event")) {
484
+ * pprint(event);
485
+ * // {
486
+ * // a = {
487
+ * // group = hash: [default],
488
+ * // position = vmath.vector3(183, 666, 0),
489
+ * // id = hash: [/go1]
490
+ * // },
491
+ * // b = {
492
+ * // group = hash: [default],
493
+ * // position = vmath.vector3(185, 704.05865478516, 0),
494
+ * // id = hash: [/go2]
495
+ * // }
496
+ * // }
497
+ * } else if (event_type === hash("trigger_event")) {
498
+ * pprint(event);
499
+ * // {
500
+ * // enter = true,
501
+ * // b = {
502
+ * // group = hash: [default],
503
+ * // id = hash: [/go2]
504
+ * // },
505
+ * // a = {
506
+ * // group = hash: [default],
507
+ * // id = hash: [/go1]
508
+ * // }
509
+ * // },
510
+ * } else if (event_type === hash("ray_cast_response")) {
511
+ * pprint(event);
512
+ * // {
513
+ * // group = hash: [default],
514
+ * // request_id = 0,
515
+ * // position = vmath.vector3(249.92222595215, 249.92222595215, 0),
516
+ * // fraction = 0.68759721517563,
517
+ * // normal = vmath.vector3(0, 1, 0),
518
+ * // id = hash: [/go]
519
+ * // }
520
+ * } else if (event_type === hash("ray_cast_missed")) {
521
+ * pprint(event);
522
+ * // {
523
+ * // request_id = 0
524
+ * // },
525
+ * }
526
+ * }
527
+ * }
528
+ *
529
+ * export default defineScript({
530
+ * init(self) {
531
+ * physics.set_event_listener(physics_world_listener);
532
+ * },
533
+ * });
534
+ * ```
535
+ */
536
+ function set_event_listener(callback?: (self: unknown, events: physics.event[]) => void): void;
537
+ /**
538
+ * Set the gravity in runtime. The gravity change is not global, it will only affect
539
+ * the collection that the function is called from.
540
+ * Note: For 2D physics the z component of the gravity vector will be ignored.
541
+ *
542
+ * @param gravity - the new gravity vector
543
+ * @example
544
+ * ```ts
545
+ * export default defineScript({
546
+ * init(self) {
547
+ * // Set "upside down" gravity for this collection.
548
+ * physics.set_gravity(vmath.vector3(0, 10.0, 0));
549
+ * },
550
+ * });
551
+ * ```
552
+ */
553
+ function set_gravity(gravity: Vector3): void;
554
+ /**
555
+ * Updates the group property of a collision object to the specified
556
+ * string value. The group name should exist i.e. have been used in
557
+ * a collision object in the editor.
558
+ *
559
+ * @param url - the collision object affected.
560
+ * @param group - the new group name to be assigned.
561
+ * @example
562
+ * ```ts
563
+ * function change_collision_group() {
564
+ * physics.set_group("#collisionobject", "enemy");
565
+ * }
566
+ * ```
567
+ */
568
+ function set_group(url: string | Hash | Url, group: string | Hash): void;
569
+ /**
570
+ * Flips the collision shapes horizontally for a collision object
571
+ *
572
+ * @param url - the collision object that should flip its shapes
573
+ * @param flip - `true` if the collision object should flip its shapes, `false` if not
574
+ * @example
575
+ * ```ts
576
+ * export default defineScript({
577
+ * init() {
578
+ * const fliph = true; // set on some condition
579
+ * physics.set_hflip("#collisionobject", fliph);
580
+ * return { fliph };
581
+ * },
582
+ * });
583
+ * ```
584
+ */
585
+ function set_hflip(url: string | Hash | Url, flip: boolean): void;
586
+ /**
587
+ * Updates the properties for an already connected joint. The joint has to be created before
588
+ * properties can be changed.
589
+ * Note: Currently only supported in 2D physics.
590
+ *
591
+ * @param collisionobject - collision object where the joint exist
592
+ * @param joint_id - id of the joint
593
+ * @param properties - joint specific properties table
594
+ * Note: The `collide_connected` field cannot be updated/changed after a connection has been made.
595
+ */
596
+ function set_joint_properties(collisionobject: string | Hash | Url, joint_id: string | Hash, properties: physics.joint_properties): void;
597
+ /**
598
+ * Sets or clears the masking of a group (maskbit) in a collision object.
599
+ *
600
+ * @param url - the collision object to change the mask of.
601
+ * @param group - the name of the group (maskbit) to modify in the mask.
602
+ * @param maskbit - boolean value of the new maskbit. 'true' to enable, 'false' to disable.
603
+ * @example
604
+ * ```ts
605
+ * function make_invincible() {
606
+ * // no longer collide with the "bullet" group
607
+ * physics.set_maskbit("#collisionobject", "bullet", false);
608
+ * }
609
+ * ```
610
+ */
611
+ function set_maskbit(url: string | Hash | Url, group: string | Hash, maskbit: boolean): void;
612
+ /**
613
+ * Sets collision shape data for a collision object. Please note that updating data in 3D
614
+ * can be quite costly for box and capsules. Because of the physics engine, the cost
615
+ * comes from having to recreate the shape objects when certain shapes needs to be updated.
616
+ *
617
+ * @param url - the collision object.
618
+ * @param shape - the name of the shape to get data for.
619
+ * @param table - updated collision shape data
620
+ * Hull and mesh geometry cannot be changed with this function.
621
+ * @example
622
+ * ```ts
623
+ * function set_shape_data() {
624
+ * // set capsule shape data
625
+ * physics.set_shape("#collisionobject", "my_capsule_shape", {
626
+ * type: physics.SHAPE_TYPE_CAPSULE,
627
+ * diameter: 10,
628
+ * height: 20,
629
+ * });
630
+ *
631
+ * // set sphere shape data
632
+ * physics.set_shape("#collisionobject", "my_sphere_shape", {
633
+ * type: physics.SHAPE_TYPE_SPHERE,
634
+ * diameter: 10,
635
+ * });
636
+ *
637
+ * // set box shape data
638
+ * physics.set_shape("#collisionobject", "my_box_shape", {
639
+ * type: physics.SHAPE_TYPE_BOX,
640
+ * dimensions: vmath.vector3(10, 10, 5),
641
+ * });
642
+ * }
643
+ * ```
644
+ */
645
+ function set_shape(url: string | Hash | Url, shape: string | Hash, table: physics.shape_data): void;
646
+ /**
647
+ * Flips the collision shapes vertically for a collision object
648
+ *
649
+ * @param url - the collision object that should flip its shapes
650
+ * @param flip - `true` if the collision object should flip its shapes, `false` if not
651
+ * @example
652
+ * ```ts
653
+ * export default defineScript({
654
+ * init() {
655
+ * const flipv = true; // set on some condition
656
+ * physics.set_vflip("#collisionobject", flipv);
657
+ * return { flipv };
658
+ * },
659
+ * });
660
+ * ```
661
+ */
662
+ function set_vflip(url: string | Hash | Url, flip: boolean): void;
663
+ /**
664
+ * The function recalculates the density of each shape based on the total area of all shapes and the specified mass, then updates the mass of the body accordingly.
665
+ * Note: Currently only supported in 2D physics.
666
+ *
667
+ * @param collisionobject - the collision object whose mass needs to be updated.
668
+ * @param mass - the new mass value to set for the collision object.
669
+ * @example
670
+ * ```ts
671
+ * physics.update_mass("#collisionobject", 14);
672
+ * ```
673
+ */
674
+ function update_mass(collisionobject: string | Hash | Url, mass: number): void;
675
+ /**
676
+ * Collision objects tend to fall asleep when inactive for a small period of time for
677
+ * efficiency reasons. This function wakes them up.
678
+ *
679
+ * @param url - the collision object to wake.
680
+ * @example
681
+ * ```ts
682
+ * export default defineScript({
683
+ * on_input(self, action_id, action) {
684
+ * if (action_id === hash("test") && action.pressed) {
685
+ * physics.wakeup("#collisionobject");
686
+ * }
687
+ * },
688
+ * });
689
+ * ```
690
+ */
691
+ function wakeup(url: string | Hash | Url): void;
692
+ namespace message {
693
+ namespace physics {
694
+ /**
695
+ * collision object information
696
+ */
697
+ interface collision_info {
698
+ /**
699
+ * object position in world space
700
+ */
701
+ position: Vector3;
702
+ /**
703
+ * object identifier
704
+ */
705
+ id: Hash;
706
+ /**
707
+ * object collision group
708
+ */
709
+ group: Hash;
710
+ }
711
+ /**
712
+ * contact-point object information
713
+ */
714
+ interface contact_point_info {
715
+ /**
716
+ * contact point position in world space
717
+ */
718
+ position: Vector3;
719
+ /**
720
+ * object position in world space
721
+ */
722
+ instance_position: Vector3;
723
+ /**
724
+ * contact normal pointing from the other object toward this object
725
+ */
726
+ normal: Vector3;
727
+ /**
728
+ * object velocity relative to the other object
729
+ */
730
+ relative_velocity: Vector3;
731
+ /**
732
+ * object mass in kilograms
733
+ */
734
+ mass: number;
735
+ /**
736
+ * object identifier
737
+ */
738
+ id: Hash;
739
+ /**
740
+ * object collision group
741
+ */
742
+ group: Hash;
743
+ }
744
+ /**
745
+ * trigger interaction object information
746
+ */
747
+ interface trigger_info {
748
+ /**
749
+ * object identifier
750
+ */
751
+ id: Hash;
752
+ /**
753
+ * object collision group
754
+ */
755
+ group: Hash;
756
+ }
757
+ }
758
+ }
759
+ interface properties {
760
+ /**
761
+ * The angular damping value for the collision object. Setting this value alters the damping of
762
+ * angular motion of the object (rotation). Valid values are between 0 (no damping) and 1 (full damping).
763
+ */
764
+ angular_damping: number;
765
+ /**
766
+ * The current angular velocity of the collision object component as a vector3.
767
+ * The velocity is measured as a rotation around the vector with a speed equivalent to the vector length
768
+ * in radians/s.
769
+ */
770
+ angular_velocity: Vector3;
771
+ /**
772
+ * The linear damping value for the collision object. Setting this value alters the damping of
773
+ * linear motion of the object. Valid values are between 0 (no damping) and 1 (full damping).
774
+ */
775
+ linear_damping: number;
776
+ /**
777
+ * The current linear velocity of the collision object component as a vector3.
778
+ * The velocity is measured in units/s (pixels/s).
779
+ */
780
+ linear_velocity: Vector3;
781
+ /**
782
+ * READ ONLY Returns the defined physical mass of the collision object component as a number.
783
+ */
784
+ readonly mass: number;
785
+ }
786
+ }
787
+ }
788
+
789
+ export {};