@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
@@ -183,7 +183,40 @@ declare global {
183
183
  * }
184
184
  * ```
185
185
  */
186
- function get_config_int(key: string, default_value?: number): number;
186
+ function get_config_int(key: string): number;
187
+ /**
188
+ * Get integer config value from the game.project configuration file with optional default value
189
+ *
190
+ * @param key - key to get value for. The syntax is SECTION.KEY
191
+ * @param default_value - (optional) default value to return if the value does not exist
192
+ * @returns config value as an integer. default_value if the config key does not exist. 0 if no default value was supplied.
193
+ * @example
194
+ * Get user config value
195
+ * ```ts
196
+ * const speed = sys.get_config_int("my_game.speed", 20); // with default value
197
+ * ```
198
+ * @example
199
+ * ```ts
200
+ * const testmode = sys.get_config_int("my_game.testmode"); // without default value
201
+ * if (testmode !== undefined) {
202
+ * // do stuff
203
+ * }
204
+ * ```
205
+ */
206
+ function get_config_int(key: string, default_value: number): number;
207
+ /**
208
+ * Get number config value from the game.project configuration file with optional default value
209
+ *
210
+ * @param key - key to get value for. The syntax is SECTION.KEY
211
+ * @param default_value - (optional) default value to return if the value does not exist
212
+ * @returns config value as an number. default_value if the config key does not exist. 0 if no default value was supplied.
213
+ * @example
214
+ * ```ts
215
+ * // Get user config value
216
+ * const speed = sys.get_config_number("my_game.speed", 20.0);
217
+ * ```
218
+ */
219
+ function get_config_number(key: string): number;
187
220
  /**
188
221
  * Get number config value from the game.project configuration file with optional default value
189
222
  *
@@ -196,7 +229,7 @@ declare global {
196
229
  * const speed = sys.get_config_number("my_game.speed", 20.0);
197
230
  * ```
198
231
  */
199
- function get_config_number(key: string, default_value?: number): number;
232
+ function get_config_number(key: string, default_value: number): number;
200
233
  /**
201
234
  * Returns the current network connectivity status
202
235
  * on mobile platforms.
@@ -355,7 +388,46 @@ declare global {
355
388
  * }
356
389
  * ```
357
390
  */
358
- function get_sys_info(options?: { ignore_secure?: boolean }): { device_model: string; manufacturer: string; system_name: string; system_version: string; api_version: string; language: string; device_language: string; territory: string; gmt_offset: number; device_ident: string; user_agent: string };
391
+ function get_sys_info(): { device_model: string; manufacturer: string; system_name: string; system_version: string; api_version: string; language: string; device_language: string; territory: string; gmt_offset: number; device_ident: string; user_agent: string };
392
+ /**
393
+ * Returns a table with system information.
394
+ *
395
+ * @param options - optional options table
396
+ * - ignore_secure boolean this flag ignores values might be secured by OS e.g. `device_ident`
397
+ * @returns table with system information in the following fields:
398
+ *
399
+ * `device_model`
400
+ * string Only available on iOS and Android.
401
+ * `manufacturer`
402
+ * string Only available on iOS and Android.
403
+ * `system_name`
404
+ * string The system name: "Darwin", "Linux", "Windows", "HTML5", "Android" or "iPhone OS"
405
+ * `system_version`
406
+ * string The system OS version.
407
+ * `api_version`
408
+ * string The API version on the system.
409
+ * `language`
410
+ * string Two character ISO-639 format, i.e. "en".
411
+ * `device_language`
412
+ * string Two character ISO-639 format (i.e. "sr") and, if applicable, followed by a dash (-) and an ISO 15924 script code (i.e. "sr-Cyrl" or "sr-Latn"). Reflects the device preferred language.
413
+ * `territory`
414
+ * string Two character ISO-3166 format, i.e. "US".
415
+ * `gmt_offset`
416
+ * number The current offset from GMT (Greenwich Mean Time), in minutes.
417
+ * `device_ident`
418
+ * string This value secured by OS. "identifierForVendor" on iOS. "android_id" on Android. On Android, you need to add `READ_PHONE_STATE` permission to be able to get this data. We don't use this permission in Defold.
419
+ * `user_agent`
420
+ * string The HTTP user agent, i.e. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8"
421
+ * @example
422
+ * ```ts
423
+ * // How to get system information:
424
+ * const info = sys.get_sys_info();
425
+ * if (info.system_name === "HTML5") {
426
+ * // We are running in a browser.
427
+ * }
428
+ * ```
429
+ */
430
+ function get_sys_info(options: { ignore_secure?: boolean }): { device_model: string; manufacturer: string; system_name: string; system_version: string; api_version: string; language: string; device_language: string; territory: string; gmt_offset: number; device_ident: string; user_agent: string };
359
431
  /**
360
432
  * If the file exists, it must have been created by `sys.save` to be loaded.
361
433
  * This function will raise a Lua error if an error occurs while loading the file.
@@ -401,7 +473,7 @@ declare global {
401
473
  * const asset_2 = sys.load_buffer("/my/absolute/path");
402
474
  * ```
403
475
  */
404
- function load_buffer(path: string): Opaque<"buffer">;
476
+ function load_buffer(path: string): Opaque<"buffer"> & { length: LuaLengthMethod<number> };
405
477
  /**
406
478
  * The sys.load_buffer function will first try to load the resource
407
479
  * from any of the mounted resource locations and return the data if
@@ -434,7 +506,7 @@ declare global {
434
506
  * Load binary data from a custom project resource and update a texture resource:
435
507
  * ```ts
436
508
  * function my_callback(self: unknown, request_id: unknown, result: unknown) {
437
- * const { status, buf } = result as { status: number; buf: Opaque<"buffer"> };
509
+ * const { status, buf } = result as { status: number; buf: ReturnType<typeof sys.load_buffer> };
438
510
  * if (status === sys.REQUEST_STATUS_FINISHED) {
439
511
  * resource.set_texture("/my_texture", { type: graphics.TEXTURE_TYPE_2D, width: 128, height: 128, format: graphics.TEXTURE_FORMAT_RGBA }, buf);
440
512
  * }
@@ -519,7 +591,30 @@ declare global {
519
591
  * }
520
592
  * ```
521
593
  */
522
- function open_url(url: string, attributes?: { target?: string }): boolean;
594
+ function open_url(url: string): boolean;
595
+ /**
596
+ * Open URL in default application, typically a browser
597
+ *
598
+ * @param url - url to open
599
+ * @param attributes - table with attributes
600
+ * `target`
601
+ * - string : Optional. Specifies the target attribute or the name of the window. The following values are supported:
602
+ * - `_self` - (default value) URL replaces the current page.
603
+ * - `_blank` - URL is loaded into a new window, or tab.
604
+ * - `_parent` - URL is loaded into the parent frame.
605
+ * - `_top` - URL replaces any framesets that may be loaded.
606
+ * - `name` - The name of the window (Note: the name does not specify the title of the new window).
607
+ * @returns a boolean indicating if the url could be opened or not
608
+ * @example
609
+ * ```ts
610
+ * // Open an URL:
611
+ * const success = sys.open_url("http://www.defold.com", { target: "_blank" });
612
+ * if (!success) {
613
+ * // could not open the url...
614
+ * }
615
+ * ```
616
+ */
617
+ function open_url(url: string, attributes: { target?: string }): boolean;
523
618
  /**
524
619
  * Reboots the game engine with a specified set of arguments.
525
620
  * Arguments will be translated into command line arguments. Calling reboot
@@ -68,30 +68,6 @@ declare global {
68
68
  * ```
69
69
  */
70
70
  function cross(v1: Vector3, v2: Vector3): Vector3;
71
- /**
72
- * The returned value is a scalar defined as:
73
- * `P ⋅ Q = |P| |Q| cos θ`
74
- * where θ is the angle between the vectors P and Q.
75
- *
76
- * - If the dot product is positive then the angle between the vectors is below 90 degrees.
77
- * - If the dot product is zero the vectors are perpendicular (at right-angles to each other).
78
- * - If the dot product is negative then the angle between the vectors is more than 90 degrees.
79
- *
80
- * @param v1 - first vector
81
- * @param v2 - second vector
82
- * @returns dot product
83
- * @example
84
- * ```ts
85
- * const vector1 = vmath.vector3(1, 0, 0);
86
- * const vector2 = vmath.vector3(0, 1, 0);
87
- *
88
- * if (vmath.dot(vector1, vector2) === 0) {
89
- * // The two vectors are perpendicular (at right-angles to each other)
90
- * // ...
91
- * }
92
- * ```
93
- */
94
- function dot(v1: Vector3 | Vector4, v2: Vector3 | Vector4): number;
95
71
  /**
96
72
  * The resulting matrix is the inverse of the supplied matrix.
97
73
  * For ortho-normal matrices, e.g. regular object transformation,
@@ -26,7 +26,7 @@ declare global {
26
26
  * @param filter - optional query filter
27
27
  * @param max_results - optional maximum result count
28
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]>;
29
+ function cast_ray<Backend extends "v2" = "v2">(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_cast_hit[], b2d.tree_stats]>;
30
30
  /**
31
31
  * The translation is the ray displacement from `origin`. Result order is not
32
32
  * guaranteed by Box2D.
@@ -37,7 +37,7 @@ declare global {
37
37
  * @param filter - optional query filter
38
38
  * @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
39
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]>;
40
+ function cast_ray<Backend extends "v3">(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_cast_hit[], b2d.tree_stats]>;
41
41
  /**
42
42
  * Cast a ray and return the closest hit.
43
43
  *
@@ -47,7 +47,7 @@ declare global {
47
47
  * @param filter - optional query filter
48
48
  * @returns closest hit, or `nil`
49
49
  */
50
- function cast_ray_closest(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.fixture_cast_hit | undefined;
50
+ function cast_ray_closest<Backend extends "v2" = "v2">(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.fixture_cast_hit | undefined;
51
51
  /**
52
52
  * The translation is the ray displacement from `origin`.
53
53
  *
@@ -57,7 +57,7 @@ declare global {
57
57
  * @param filter - optional query filter
58
58
  * @returns closest hit, or `nil`
59
59
  */
60
- function cast_ray_closest(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.shape_cast_hit | undefined;
60
+ function cast_ray_closest<Backend extends "v3">(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.shape_cast_hit | undefined;
61
61
  /**
62
62
  * Uses Box2D v2 time-of-impact for fixture child shapes that support distance proxies.
63
63
  * Grid fixture children are skipped.
@@ -68,7 +68,7 @@ declare global {
68
68
  * @param filter - optional query filter
69
69
  * @param max_results - optional maximum result count
70
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]>;
71
+ function cast_shape<Backend extends "v2" = "v2">(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
72
  /**
73
73
  * The translation is the shape displacement.
74
74
  *
@@ -78,7 +78,7 @@ declare global {
78
78
  * @param filter - optional query filter
79
79
  * @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
80
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]>;
81
+ function cast_shape<Backend extends "v3">(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
82
  /**
83
83
  * Collide a mover capsule against the world.
84
84
  *
@@ -220,7 +220,7 @@ declare global {
220
220
  * - `fixtures` — overlapping fixtures. **⚠️ `index` is 1-based; passed to Defold unchanged.**
221
221
  * - `stats` — broad-phase query statistics
222
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]>;
223
+ function overlap_aabb<Backend extends "v2" = "v2">(world: Opaque<"b2World">, aabb: b2d.aabb, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_info[], b2d.tree_stats]>;
224
224
  /**
225
225
  * Find shapes overlapping an AABB.
226
226
  *
@@ -229,7 +229,7 @@ declare global {
229
229
  * @param filter - optional query filter
230
230
  * @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
231
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]>;
232
+ function overlap_aabb<Backend extends "v3">(world: Opaque<"b2World">, aabb: b2d.aabb, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_info[], b2d.tree_stats]>;
233
233
  /**
234
234
  * Overlap a shape.
235
235
  *
@@ -241,7 +241,7 @@ declare global {
241
241
  * - `fixtures` — overlapping fixtures. **⚠️ `index` is 1-based; passed to Defold unchanged.**
242
242
  * - `stats` — broad-phase query statistics
243
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]>;
244
+ function overlap_shape<Backend extends "v2" = "v2">(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
245
  /**
246
246
  * Find shapes overlapping a shape proxy.
247
247
  *
@@ -250,7 +250,7 @@ declare global {
250
250
  * @param filter - optional query filter
251
251
  * @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
252
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]>;
253
+ function overlap_shape<Backend extends "v3">(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
254
  /**
255
255
  * Rebuild the static broad-phase tree.
256
256
  *
@@ -6,7 +6,7 @@ declare global {
6
6
  * Functions for manipulating buffers and streams
7
7
  */
8
8
  namespace buffer {
9
- type buffer_data = Opaque<"buffer">;
9
+ type buffer_data = Opaque<"buffer"> & { length: LuaLengthMethod<number> };
10
10
  type buffer_stream = Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> };
11
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
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;
@@ -71,7 +71,7 @@ declare global {
71
71
  * buffer.copy_buffer(dstbuffer, 0, srcbuffer, element_count - 10, 10);
72
72
  * ```
73
73
  */
74
- function copy_buffer(dst: Opaque<"buffer">, dstoffset: number, src: Opaque<"buffer">, srcoffset: number, count: number): void;
74
+ function copy_buffer(dst: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, dstoffset: number, src: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, srcoffset: number, count: number): void;
75
75
  /**
76
76
  * Copy a specified amount of data from one stream to another.
77
77
  * The value type and size must match between source and destination streams.
@@ -132,15 +132,15 @@ declare global {
132
132
  * });
133
133
  * ```
134
134
  */
135
- function create(element_count: number, declaration: ({ name: Hash | string; type: buffer.VALUE_TYPE; count: number })[]): Opaque<"buffer">;
135
+ function create(element_count: number, declaration: [({ name: Hash | string; type: buffer.VALUE_TYPE; count: number }), ...({ name: Hash | string; type: buffer.VALUE_TYPE; count: number })[]]): Opaque<"buffer"> & { length: LuaLengthMethod<number> };
136
136
  /**
137
- * Get a copy of all the bytes from a specified stream as a Lua string.
137
+ * Get a copy of all the bytes of the buffer, every stream included, as a Lua string.
138
138
  *
139
139
  * @param buffer - the source buffer
140
- * @param stream_name - the name of the stream
140
+ * @param stream_name - the name of the stream; the engine ignores it and returns every byte of the buffer
141
141
  * @returns the buffer data as a Lua string
142
142
  */
143
- function get_bytes(buffer: Opaque<"buffer">, stream_name: Hash | string): string;
143
+ function get_bytes(buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, stream_name?: Hash | string): string;
144
144
  /**
145
145
  * Get a named metadata entry from a buffer along with its type.
146
146
  *
@@ -156,7 +156,7 @@ declare global {
156
156
  * if (values) print(`${values.length} values in 'somefloats'`);
157
157
  * ```
158
158
  */
159
- function get_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string): LuaMultiReturn<[number[] | undefined, buffer.VALUE_TYPE | undefined]>;
159
+ function get_metadata(buf: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, metadata_name: Hash | string): LuaMultiReturn<[number[] | undefined, buffer.VALUE_TYPE | undefined]>;
160
160
  /**
161
161
  * Get a specified stream from a buffer.
162
162
  *
@@ -164,7 +164,7 @@ declare global {
164
164
  * @param stream_name - the stream name
165
165
  * @returns the data stream
166
166
  */
167
- function get_stream(buffer: Opaque<"buffer">, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> };
167
+ function get_stream(buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> };
168
168
  /**
169
169
  * Creates or updates a metadata array entry on a buffer.
170
170
  * The value type and count given when updating the entry should match those used when first creating it.
@@ -185,7 +185,7 @@ declare global {
185
185
  * buffer.set_metadata(buf, hash("somefloats"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);
186
186
  * ```
187
187
  */
188
- function set_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string, values: number[], value_type: buffer.VALUE_TYPE): void;
188
+ function set_metadata(buf: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, metadata_name: Hash | string, values: [number, ...number[]], value_type: Exclude<buffer.VALUE_TYPE, typeof buffer.VALUE_TYPE_INT64 | typeof buffer.VALUE_TYPE_UINT64>): void;
189
189
  }
190
190
  }
191
191
 
@@ -298,7 +298,7 @@ declare global {
298
298
  * @param object - collision object
299
299
  * @returns rigid body state
300
300
  */
301
- function is_rigid_body(object: Opaque<"btCollisionObject" | "btRigidBody">): boolean;
301
+ function is_rigid_body(object: Opaque<"btCollisionObject" | "btRigidBody">): object is Opaque<"btRigidBody">;
302
302
  /**
303
303
  * Test whether the object is static
304
304
  *
@@ -246,7 +246,16 @@ declare global {
246
246
  * @param params - local frames and options
247
247
  * @returns cone-twist constraint
248
248
  */
249
- function create_cone_twist(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.cone_twist_params): bullet3d.constraint.btTypedConstraint;
249
+ function create_cone_twist(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.cone_twist_params & Required<Pick<bullet3d.constraint.cone_twist_params, "frame_b_position" | "frame_b_rotation">>): bullet3d.constraint.btTypedConstraint;
250
+ /**
251
+ * The world is derived from `body_a`.
252
+ *
253
+ * @param body_a - first body
254
+ * @param body_b - second body or world
255
+ * @param params - local frames and options
256
+ * @returns cone-twist constraint
257
+ */
258
+ function create_cone_twist(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.cone_twist_params): bullet3d.constraint.btTypedConstraint;
250
259
  /**
251
260
  * The params table requires local frame A and, for a two-body constraint,
252
261
  * local frame B. It optionally accepts `collide_connected`. The world is
@@ -259,7 +268,20 @@ declare global {
259
268
  * @param params - local frames and options
260
269
  * @returns generic 6-DOF constraint
261
270
  */
262
- function create_generic_6dof(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.generic_6dof_params): bullet3d.constraint.btTypedConstraint;
271
+ function create_generic_6dof(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.generic_6dof_params & Required<Pick<bullet3d.constraint.generic_6dof_params, "frame_b_position" | "frame_b_rotation">>): bullet3d.constraint.btTypedConstraint;
272
+ /**
273
+ * The params table requires local frame A and, for a two-body constraint,
274
+ * local frame B. It optionally accepts `collide_connected`. The world is
275
+ * derived from `body_a`. The active 6-DOF solver ignores its legacy
276
+ * linear-reference-frame selector, so that field is rejected rather than
277
+ * silently accepted.
278
+ *
279
+ * @param body_a - first body
280
+ * @param body_b - second body or world
281
+ * @param params - local frames and options
282
+ * @returns generic 6-DOF constraint
283
+ */
284
+ function create_generic_6dof(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.generic_6dof_params): bullet3d.constraint.btTypedConstraint;
263
285
  /**
264
286
  * Both bodies and both local frames are required. The params table optionally
265
287
  * accepts `collide_connected`. The world is derived from `body_a`. The active
@@ -339,7 +361,44 @@ declare global {
339
361
  * });
340
362
  * ```
341
363
  */
342
- function create_hinge(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.hinge_params): bullet3d.constraint.btTypedConstraint;
364
+ function create_hinge(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.hinge_params & Required<Pick<bullet3d.constraint.hinge_params, "frame_b_position" | "frame_b_rotation">>): bullet3d.constraint.btTypedConstraint;
365
+ /**
366
+ * The world is derived from `body_a`.
367
+ *
368
+ * @param body_a - first body
369
+ * @param body_b - second body or world
370
+ * @param params - local frames and options
371
+ * @returns hinge constraint
372
+ * @example
373
+ * ```ts
374
+ * // Create a motorized hinge with a 90-degree range:
375
+ * export default defineScript({
376
+ * init() {
377
+ * const body_a = bullet3d.get_rigid_body("/door#collisionobject");
378
+ * const body_b = bullet3d.get_rigid_body("/frame#collisionobject");
379
+ * let hinge: bullet3d.constraint.btTypedConstraint | undefined;
380
+ * if (body_a !== undefined) {
381
+ * hinge = bullet3d.constraint.create_hinge(body_a, body_b, {
382
+ * frame_a_position: vmath.vector3(-0.5, 0, 0),
383
+ * frame_a_rotation: vmath.quat(),
384
+ * frame_b_position: vmath.vector3(0.5, 0, 0),
385
+ * frame_b_rotation: vmath.quat(),
386
+ * });
387
+ * bullet3d.constraint.set_hinge_limits(hinge, -math.pi / 4, math.pi / 4);
388
+ * bullet3d.constraint.set_hinge_motor(hinge, true, 1.5, 2.5);
389
+ * }
390
+ * return { hinge };
391
+ * },
392
+ *
393
+ * final(self) {
394
+ * if (self.hinge !== undefined && bullet3d.constraint.is_valid(self.hinge)) {
395
+ * bullet3d.constraint.destroy(self.hinge);
396
+ * }
397
+ * },
398
+ * });
399
+ * ```
400
+ */
401
+ function create_hinge(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.hinge_params): bullet3d.constraint.btTypedConstraint;
343
402
  /**
344
403
  * Both bodies are required. Its initial linear suspension travel is one Defold
345
404
  * unit in either direction. The world is derived from `body_a`.
@@ -383,7 +442,50 @@ declare global {
383
442
  * });
384
443
  * ```
385
444
  */
386
- function create_point_to_point(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.point_to_point_params): bullet3d.constraint.btTypedConstraint;
445
+ function create_point_to_point(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.point_to_point_params & Required<Pick<bullet3d.constraint.point_to_point_params, "pivot_b">>): bullet3d.constraint.btTypedConstraint;
446
+ /**
447
+ * The world is derived from `body_a`; both bodies must belong to that same world.
448
+ *
449
+ * @param body_a - first body
450
+ * @param body_b - second body or world
451
+ * @param params - pivots and options
452
+ * @returns point-to-point constraint
453
+ * @example
454
+ * ```ts
455
+ * // Join two bodies at matching local pivots and explicitly destroy the
456
+ * // constraint when the script is finalized:
457
+ * export default defineScript({
458
+ * init() {
459
+ * const body_a = bullet3d.get_rigid_body("/body_a#collisionobject");
460
+ * const body_b = bullet3d.get_rigid_body("/body_b#collisionobject");
461
+ * let constraint: bullet3d.constraint.btTypedConstraint | undefined;
462
+ * if (body_a !== undefined) {
463
+ * constraint = bullet3d.constraint.create_point_to_point(body_a, body_b, {
464
+ * pivot_a: vmath.vector3(0.5, 0, 0),
465
+ * pivot_b: vmath.vector3(-0.5, 0, 0),
466
+ * });
467
+ * }
468
+ * return { constraint };
469
+ * },
470
+ *
471
+ * final(self) {
472
+ * if (self.constraint !== undefined && bullet3d.constraint.is_valid(self.constraint)) {
473
+ * bullet3d.constraint.destroy(self.constraint);
474
+ * }
475
+ * },
476
+ * });
477
+ * ```
478
+ */
479
+ function create_point_to_point(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.point_to_point_params): bullet3d.constraint.btTypedConstraint;
480
+ /**
481
+ * The world is derived from `body_a`.
482
+ *
483
+ * @param body_a - first body
484
+ * @param body_b - second body or world
485
+ * @param params - local frames and options
486
+ * @returns slider constraint
487
+ */
488
+ function create_slider(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.slider_params & Required<Pick<bullet3d.constraint.slider_params, "frame_b_position" | "frame_b_rotation">>): bullet3d.constraint.btTypedConstraint;
387
489
  /**
388
490
  * The world is derived from `body_a`.
389
491
  *
@@ -392,7 +494,7 @@ declare global {
392
494
  * @param params - local frames and options
393
495
  * @returns slider constraint
394
496
  */
395
- function create_slider(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.slider_params): bullet3d.constraint.btTypedConstraint;
497
+ function create_slider(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.slider_params): bullet3d.constraint.btTypedConstraint;
396
498
  /**
397
499
  * Both bodies are required. The world is derived from `body_a`.
398
500
  *
@@ -567,7 +669,7 @@ declare global {
567
669
  * @param constraint - slider constraint
568
670
  * @param motor - `linear` or `angular`
569
671
  */
570
- function get_slider_motor(constraint: bullet3d.constraint.btTypedConstraint, motor: string): LuaMultiReturn<[boolean, number, number]>;
672
+ function get_slider_motor(constraint: bullet3d.constraint.btTypedConstraint, motor: "linear" | "angular"): LuaMultiReturn<[boolean, number, number]>;
571
673
  /**
572
674
  * Get the current slider position
573
675
  *
@@ -781,7 +883,7 @@ declare global {
781
883
  * @param target_velocity - linear or angular target velocity
782
884
  * @param max_force - non-negative maximum linear force or angular torque
783
885
  */
784
- function set_slider_motor(constraint: bullet3d.constraint.btTypedConstraint, motor: string, enabled: boolean, target_velocity: number, max_force: number): void;
886
+ function set_slider_motor(constraint: bullet3d.constraint.btTypedConstraint, motor: "linear" | "angular", enabled: boolean, target_velocity: number, max_force: number): void;
785
887
  /**
786
888
  * Generic spring 6-DOF constraints use a scale-independent damping factor from
787
889
  * 0 to 1, where 1 means no damping. Hinge2 constraints use a damping coefficient
@@ -11,7 +11,7 @@ declare global {
11
11
  */
12
12
  namespace bullet3d.shape {
13
13
  type btCollisionShape = Opaque<"btCollisionShape">;
14
- type definition = { type: bullet3d.shape.SHAPE_TYPE; diameter: number; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: bullet3d.shape.SHAPE_TYPE; dimensions: Vector3; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: bullet3d.shape.SHAPE_TYPE; diameter: number; height: number; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: bullet3d.shape.SHAPE_TYPE; vertices: Vector3[]; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion };
14
+ type definition = { type: typeof bullet3d.shape.SHAPE_TYPE_SPHERE; diameter: number; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: typeof bullet3d.shape.SHAPE_TYPE_BOX; dimensions: Vector3; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: typeof bullet3d.shape.SHAPE_TYPE_CAPSULE; diameter: number; height: number; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: typeof bullet3d.shape.SHAPE_TYPE_HULL; vertices: Vector3[]; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion };
15
15
  type SHAPE_TYPE = typeof bullet3d.shape.SHAPE_TYPE_BOX | typeof bullet3d.shape.SHAPE_TYPE_CAPSULE | typeof bullet3d.shape.SHAPE_TYPE_HULL | typeof bullet3d.shape.SHAPE_TYPE_MESH | typeof bullet3d.shape.SHAPE_TYPE_SPHERE;
16
16
  /**
17
17
  * Box shape type Value `1`. Shape data contains positive vector3 `dimensions` in Defold units.
@@ -66,7 +66,7 @@ declare global {
66
66
  * @param shape - shape handle
67
67
  * @returns typed shape geometry in Defold units
68
68
  */
69
- function get_shape(shape: bullet3d.shape.btCollisionShape): bullet3d.shape.definition;
69
+ function get_shape(shape: bullet3d.shape.btCollisionShape): bullet3d.shape.definition | { type: typeof bullet3d.shape.SHAPE_TYPE_MESH };
70
70
  /**
71
71
  * Get the normalized Defold shape type.
72
72
  *