@defold-typescript/types 0.40.0 → 0.41.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 (224) hide show
  1. package/api-availability.json +3963 -772
  2. package/api-migrations.json +27 -0
  3. package/api-signatures.json +18069 -10240
  4. package/api-targets.json +448 -11
  5. package/examples/translations.json +560 -89
  6. package/fixtures/messages_doc.json +96 -0
  7. package/generated/b2d.d.ts +680 -4
  8. package/generated/b2d_body.d.ts +29 -103
  9. package/generated/b2d_chain.d.ts +5 -6
  10. package/generated/b2d_fixture.d.ts +34 -38
  11. package/generated/b2d_joint.d.ts +503 -25
  12. package/generated/b2d_shape.d.ts +183 -20
  13. package/generated/b2d_world.d.ts +57 -63
  14. package/generated/buffer.d.ts +16 -15
  15. package/generated/builtin-messages.d.ts +7 -1
  16. package/generated/bullet3d.d.ts +91 -0
  17. package/generated/bullet3d_collision_object.d.ts +433 -0
  18. package/generated/bullet3d_constraint.d.ts +818 -0
  19. package/generated/bullet3d_rigid_body.d.ts +429 -0
  20. package/generated/bullet3d_shape.d.ts +123 -0
  21. package/generated/bullet3d_world.d.ts +492 -0
  22. package/generated/camera.d.ts +29 -32
  23. package/generated/collectionfactory.d.ts +15 -18
  24. package/generated/collectionproxy.d.ts +22 -6
  25. package/generated/compute.d.ts +12 -238
  26. package/generated/crash.d.ts +24 -10
  27. package/generated/editor-vm/http.d.ts +90 -7
  28. package/generated/editor-vm/image.d.ts +7 -7
  29. package/generated/editor-vm/json.d.ts +11 -0
  30. package/generated/editor-vm/localization.d.ts +7 -7
  31. package/generated/editor-vm/tilemap_tiles.d.ts +56 -10
  32. package/generated/editor-vm/zip.d.ts +28 -0
  33. package/generated/editor.d.ts +1496 -430
  34. package/generated/factory.d.ts +21 -25
  35. package/generated/font.d.ts +64 -22
  36. package/generated/go.d.ts +235 -182
  37. package/generated/graphics.d.ts +335 -97
  38. package/generated/gui.d.ts +240 -471
  39. package/generated/html5.d.ts +2 -2
  40. package/generated/http.d.ts +28 -35
  41. package/generated/image.d.ts +105 -72
  42. package/generated/json.d.ts +34 -16
  43. package/generated/kinds/gui-script.d.ts +7 -0
  44. package/generated/kinds/render-script.d.ts +7 -0
  45. package/generated/kinds/script.d.ts +7 -0
  46. package/generated/label.d.ts +77 -7
  47. package/generated/liveupdate.d.ts +13 -10
  48. package/generated/material.d.ts +312 -360
  49. package/generated/model.d.ts +40 -39
  50. package/generated/particlefx.d.ts +19 -28
  51. package/generated/physics.d.ts +365 -133
  52. package/generated/profiler.d.ts +13 -23
  53. package/generated/render.d.ts +237 -297
  54. package/generated/resource.d.ts +664 -583
  55. package/generated/socket.d.ts +120 -133
  56. package/generated/sound.d.ts +62 -31
  57. package/generated/sprite.d.ts +31 -17
  58. package/generated/sys.d.ts +234 -190
  59. package/generated/tilemap.d.ts +21 -16
  60. package/generated/timer.d.ts +34 -21
  61. package/generated/versions/defold-1.12.4/b2d_body.d.ts +0 -7
  62. package/generated/versions/defold-1.12.4/buffer.d.ts +1 -3
  63. package/generated/versions/defold-1.12.4/camera.d.ts +21 -21
  64. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +9 -9
  65. package/generated/versions/defold-1.12.4/collectionproxy.d.ts +2 -2
  66. package/generated/versions/defold-1.12.4/crash.d.ts +2 -2
  67. package/generated/versions/defold-1.12.4/factory.d.ts +15 -16
  68. package/generated/versions/defold-1.12.4/go.d.ts +6 -12
  69. package/generated/versions/defold-1.12.4/gui.d.ts +77 -175
  70. package/generated/versions/defold-1.12.4/html5.d.ts +1 -1
  71. package/generated/versions/defold-1.12.4/http.d.ts +0 -13
  72. package/generated/versions/defold-1.12.4/image.d.ts +16 -33
  73. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  74. package/generated/versions/defold-1.12.4/json.d.ts +10 -6
  75. package/generated/versions/defold-1.12.4/label.d.ts +2 -3
  76. package/generated/versions/defold-1.12.4/liveupdate.d.ts +5 -3
  77. package/generated/versions/defold-1.12.4/model.d.ts +2 -10
  78. package/generated/versions/defold-1.12.4/particlefx.d.ts +2 -5
  79. package/generated/versions/defold-1.12.4/physics.d.ts +69 -67
  80. package/generated/versions/defold-1.12.4/profiler.d.ts +2 -5
  81. package/generated/versions/defold-1.12.4/render.d.ts +99 -128
  82. package/generated/versions/defold-1.12.4/resource.d.ts +120 -148
  83. package/generated/versions/defold-1.12.4/socket.d.ts +34 -60
  84. package/generated/versions/defold-1.12.4/sound.d.ts +8 -8
  85. package/generated/versions/defold-1.12.4/sprite.d.ts +15 -5
  86. package/generated/versions/defold-1.12.4/sys.d.ts +37 -71
  87. package/generated/versions/defold-1.12.4/tilemap.d.ts +18 -11
  88. package/generated/versions/defold-1.12.4/timer.d.ts +5 -3
  89. package/generated/versions/defold-1.12.4/vmath.d.ts +0 -21
  90. package/generated/versions/defold-1.12.4/window.d.ts +1 -16
  91. package/generated/versions/defold-1.13.0/b2d_body.d.ts +10 -55
  92. package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +25 -25
  93. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +169 -8
  94. package/generated/versions/defold-1.13.0/b2d_world.d.ts +16 -10
  95. package/generated/versions/defold-1.13.0/buffer.d.ts +1 -3
  96. package/generated/versions/defold-1.13.0/camera.d.ts +25 -25
  97. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +9 -9
  98. package/generated/versions/defold-1.13.0/collectionproxy.d.ts +2 -2
  99. package/generated/versions/defold-1.13.0/compute.d.ts +0 -69
  100. package/generated/versions/defold-1.13.0/crash.d.ts +2 -2
  101. package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +3 -3
  102. package/generated/versions/defold-1.13.0/editor.d.ts +34 -24
  103. package/generated/versions/defold-1.13.0/factory.d.ts +15 -16
  104. package/generated/versions/defold-1.13.0/go.d.ts +6 -12
  105. package/generated/versions/defold-1.13.0/graphics.d.ts +73 -37
  106. package/generated/versions/defold-1.13.0/gui.d.ts +77 -175
  107. package/generated/versions/defold-1.13.0/html5.d.ts +1 -1
  108. package/generated/versions/defold-1.13.0/http.d.ts +0 -13
  109. package/generated/versions/defold-1.13.0/image.d.ts +16 -33
  110. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  111. package/generated/versions/defold-1.13.0/json.d.ts +10 -6
  112. package/generated/versions/defold-1.13.0/label.d.ts +2 -3
  113. package/generated/versions/defold-1.13.0/liveupdate.d.ts +7 -5
  114. package/generated/versions/defold-1.13.0/material.d.ts +68 -106
  115. package/generated/versions/defold-1.13.0/model.d.ts +2 -10
  116. package/generated/versions/defold-1.13.0/particlefx.d.ts +2 -5
  117. package/generated/versions/defold-1.13.0/physics.d.ts +69 -67
  118. package/generated/versions/defold-1.13.0/profiler.d.ts +2 -5
  119. package/generated/versions/defold-1.13.0/render.d.ts +99 -128
  120. package/generated/versions/defold-1.13.0/resource.d.ts +126 -150
  121. package/generated/versions/defold-1.13.0/socket.d.ts +34 -60
  122. package/generated/versions/defold-1.13.0/sound.d.ts +8 -8
  123. package/generated/versions/defold-1.13.0/sprite.d.ts +15 -5
  124. package/generated/versions/defold-1.13.0/sys.d.ts +37 -71
  125. package/generated/versions/defold-1.13.0/tilemap.d.ts +18 -11
  126. package/generated/versions/defold-1.13.0/timer.d.ts +5 -3
  127. package/generated/versions/defold-1.13.0/vmath.d.ts +0 -21
  128. package/generated/versions/defold-1.13.0/window.d.ts +1 -16
  129. package/generated/versions/defold-1.13.1/b2d.d.ts +33 -0
  130. package/generated/versions/defold-1.13.1/b2d_body.d.ts +636 -0
  131. package/generated/versions/defold-1.13.1/b2d_chain.d.ts +106 -0
  132. package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +157 -0
  133. package/generated/versions/defold-1.13.1/b2d_joint.d.ts +823 -0
  134. package/generated/versions/defold-1.13.1/b2d_shape.d.ts +400 -0
  135. package/generated/versions/defold-1.13.1/b2d_world.d.ts +320 -0
  136. package/generated/versions/defold-1.13.1/buffer.d.ts +189 -0
  137. package/generated/versions/defold-1.13.1/camera.d.ts +303 -0
  138. package/generated/versions/defold-1.13.1/collectionfactory.d.ts +151 -0
  139. package/generated/versions/defold-1.13.1/collectionproxy.d.ts +93 -0
  140. package/generated/versions/defold-1.13.1/compute.d.ts +237 -0
  141. package/generated/versions/defold-1.13.1/crash.d.ts +143 -0
  142. package/generated/versions/defold-1.13.1/editor-vm/http.d.ts +56 -0
  143. package/generated/versions/defold-1.13.1/editor-vm/image.d.ts +48 -0
  144. package/generated/versions/defold-1.13.1/editor-vm/json.d.ts +10 -0
  145. package/generated/versions/defold-1.13.1/editor-vm/localization.d.ts +42 -0
  146. package/generated/versions/defold-1.13.1/editor-vm/tilemap_tiles.d.ts +80 -0
  147. package/generated/versions/defold-1.13.1/editor-vm/zip.d.ts +10 -0
  148. package/generated/versions/defold-1.13.1/editor-vm/zlib.d.ts +24 -0
  149. package/generated/versions/defold-1.13.1/editor.d.ts +1121 -0
  150. package/generated/versions/defold-1.13.1/factory.d.ts +124 -0
  151. package/generated/versions/defold-1.13.1/font.d.ts +81 -0
  152. package/generated/versions/defold-1.13.1/go.d.ts +1107 -0
  153. package/generated/versions/defold-1.13.1/graphics.d.ts +411 -0
  154. package/generated/versions/defold-1.13.1/gui.d.ts +2353 -0
  155. package/generated/versions/defold-1.13.1/html5.d.ts +55 -0
  156. package/generated/versions/defold-1.13.1/http.d.ts +77 -0
  157. package/generated/versions/defold-1.13.1/image.d.ts +131 -0
  158. package/generated/versions/defold-1.13.1/index.d.ts +57 -0
  159. package/generated/versions/defold-1.13.1/json.d.ts +80 -0
  160. package/generated/versions/defold-1.13.1/kinds/editor-script.d.ts +14 -0
  161. package/generated/versions/defold-1.13.1/label.d.ts +93 -0
  162. package/generated/versions/defold-1.13.1/liveupdate.d.ts +142 -0
  163. package/generated/versions/defold-1.13.1/material.d.ts +408 -0
  164. package/generated/versions/defold-1.13.1/model.d.ts +272 -0
  165. package/generated/versions/defold-1.13.1/msg.d.ts +10 -0
  166. package/generated/versions/defold-1.13.1/particlefx.d.ts +163 -0
  167. package/generated/versions/defold-1.13.1/physics.d.ts +559 -0
  168. package/generated/versions/defold-1.13.1/profiler.d.ts +235 -0
  169. package/generated/versions/defold-1.13.1/render.d.ts +1190 -0
  170. package/generated/versions/defold-1.13.1/resource.d.ts +1523 -0
  171. package/generated/versions/defold-1.13.1/socket.d.ts +784 -0
  172. package/generated/versions/defold-1.13.1/sound.d.ts +292 -0
  173. package/generated/versions/defold-1.13.1/sprite.d.ts +175 -0
  174. package/generated/versions/defold-1.13.1/sys.d.ts +678 -0
  175. package/generated/versions/defold-1.13.1/tilemap.d.ts +208 -0
  176. package/generated/versions/defold-1.13.1/timer.d.ts +125 -0
  177. package/generated/versions/defold-1.13.1/types.d.ts +61 -0
  178. package/generated/versions/defold-1.13.1/vmath.d.ts +774 -0
  179. package/generated/versions/defold-1.13.1/window.d.ts +183 -0
  180. package/generated/versions/defold-1.13.1/zlib.d.ts +41 -0
  181. package/generated/vmath.d.ts +1 -21
  182. package/generated/window.d.ts +71 -71
  183. package/identity-vocabulary.json +561 -0
  184. package/index.d.ts +7 -0
  185. package/package.json +13 -2
  186. package/scripts/example-store-io.ts +12 -1
  187. package/scripts/extension-goldens.ts +1 -0
  188. package/scripts/fidelity-baseline.json +146 -46
  189. package/scripts/generate-api-availability.ts +90 -12
  190. package/scripts/generate-api-signatures.ts +12 -2
  191. package/scripts/import-defold-release.ts +85 -24
  192. package/scripts/prose-constants.ts +77 -16
  193. package/scripts/regen.ts +391 -77
  194. package/scripts/shared-handle-methods.ts +53 -0
  195. package/scripts/signature-store-fs.ts +1 -0
  196. package/scripts/sync-api-docs.ts +16 -5
  197. package/src/api-availability.ts +0 -0
  198. package/src/api-doc.ts +201 -3
  199. package/src/api-identity.ts +252 -0
  200. package/src/core-types.ts +26 -3
  201. package/src/correction-pins.ts +49 -0
  202. package/src/doc-comment.ts +104 -11
  203. package/src/doc-corrections.ts +108 -0
  204. package/src/editor-vm-globals.d.ts +5 -2
  205. package/src/emit-dts.ts +2064 -281
  206. package/src/emit-messages.ts +52 -0
  207. package/src/example-store.ts +125 -14
  208. package/src/field-correction-coverage.ts +204 -0
  209. package/src/fnv1a.ts +16 -0
  210. package/src/go-overloads.d.ts +25 -6
  211. package/src/index-base-table.ts +145 -0
  212. package/src/index-slot-classifications.ts +588 -0
  213. package/src/index.ts +38 -5
  214. package/src/library-index-slot-classifications.ts +332 -0
  215. package/src/lifecycle.ts +61 -199
  216. package/src/luals-type-expr.ts +354 -0
  217. package/src/msg-overloads.d.ts +0 -1
  218. package/src/param-correction-provenance.ts +8 -11
  219. package/src/render-overloads.d.ts +0 -15
  220. package/src/return-correction-provenance.ts +58 -16
  221. package/src/sys-overloads.d.ts +48 -0
  222. package/src/vmath-overloads.d.ts +27 -1
  223. package/src/window-event-guard.d.ts +6 -9
  224. package/url-parameters.json +1 -2
@@ -0,0 +1,636 @@
1
+ /** @noSelfInFile */
2
+ import type { Opaque, Vector3 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions for interacting with Box2D bodies.
7
+ */
8
+ namespace b2d.body {
9
+ type b2Body = Opaque<"b2Body">;
10
+ type b2World = Opaque<"b2World">;
11
+ /**
12
+ * Dynamic body
13
+ */
14
+ const B2_DYNAMIC_BODY: number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" };
15
+ /**
16
+ * Kinematic body
17
+ */
18
+ const B2_KINEMATIC_BODY: number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" };
19
+ /**
20
+ * Static (immovable) body
21
+ */
22
+ const B2_STATIC_BODY: number & { readonly __brand: "b2d.body.B2_STATIC_BODY" };
23
+ /**
24
+ * Apply an angular impulse.
25
+ *
26
+ * @param body - body
27
+ * @param impulse - impulse the angular impulse in units of kg*m*m/s
28
+ */
29
+ function apply_angular_impulse(body: Opaque<"b2Body">, impulse: number): void;
30
+ /**
31
+ * Apply a force at a world point. If the force is not
32
+ * applied at the center of mass, it will generate a torque and
33
+ * affect the angular velocity. This wakes up the body.
34
+ *
35
+ * @param body - body
36
+ * @param force - the world force vector, usually in Newtons (N).
37
+ * @param point - the world position of the point of application.
38
+ */
39
+ function apply_force(body: Opaque<"b2Body">, force: Vector3, point: Vector3): void;
40
+ /**
41
+ * Apply a force to the center of mass. This wakes up the body.
42
+ *
43
+ * @param body - body
44
+ * @param force - the world force vector, usually in Newtons (N).
45
+ */
46
+ function apply_force_to_center(body: Opaque<"b2Body">, force: Vector3): void;
47
+ /**
48
+ * Apply an impulse at a point. This immediately modifies the velocity.
49
+ * It also modifies the angular velocity if the point of application
50
+ * is not at the center of mass. This wakes up the body.
51
+ *
52
+ * @param body - body
53
+ * @param impulse - the world impulse vector, usually in N-seconds or kg-m/s.
54
+ * @param point - the world position of the point of application.
55
+ */
56
+ function apply_linear_impulse(body: Opaque<"b2Body">, impulse: Vector3, point: Vector3): void;
57
+ /**
58
+ * Apply a linear impulse to the center of mass.
59
+ *
60
+ * @param body - body
61
+ * @param impulse - world impulse vector
62
+ */
63
+ function apply_linear_impulse_to_center(body: Opaque<"b2Body">, impulse: Vector3): void;
64
+ /**
65
+ * Apply a torque. This affects the angular velocity
66
+ * without affecting the linear velocity of the center of mass.
67
+ * This wakes up the body.
68
+ *
69
+ * @param body - body
70
+ * @param torque - torque about the z-axis (out of the screen), usually in N-m.
71
+ */
72
+ function apply_torque(body: Opaque<"b2Body">, torque: number): void;
73
+ /**
74
+ * Compute the world AABB of all body shapes.
75
+ *
76
+ * @param body - body
77
+ * @returns table with `lower` and `upper` vector3 fields
78
+ */
79
+ function compute_aabb(body: Opaque<"b2Body">): { lower: Vector3; upper: Vector3 };
80
+ /**
81
+ * Chains are one-sided connected segments with optional ghost vertices at
82
+ * the ends of open chains. Ghost vertices are creation-time chain data only and
83
+ * cannot be added to arbitrary shapes, bodies, or joints after creation.
84
+ *
85
+ * `definition.vertices`
86
+ * table array of local `vector3` vertices. Open chains require at least 2 vertices. Loop chains require at least 4 vertices.
87
+ * `definition.loop`
88
+ * boolean true to create a closed loop chain.
89
+ * `definition.prev_vertex`
90
+ * vector3 optional ghost vertex before the first vertex for open chains.
91
+ * `definition.next_vertex`
92
+ * vector3 optional ghost vertex after the last vertex for open chains.
93
+ * `definition.friction`
94
+ * number optional friction.
95
+ * `definition.restitution`
96
+ * number optional restitution.
97
+ * `definition.material`
98
+ * number optional material id.
99
+ * `definition.filter`
100
+ * table optional filter with `category_bits`, `mask_bits`, and `group_index`.
101
+ * `definition.enable_sensor_events`
102
+ * boolean true to enable sensor events for chain segments.
103
+ *
104
+ * @param body - body
105
+ * @param definition - the chain definition
106
+ * @example
107
+ * ```ts
108
+ * const body = b2d.get_body("#collisionobject");
109
+ * if (body !== undefined) {
110
+ * const [chain, segments] = b2d.body.create_chain(body, {
111
+ * vertices: [vmath.vector3(-64, 0, 0), vmath.vector3(0, 16, 0), vmath.vector3(64, 0, 0)],
112
+ * prev_vertex: vmath.vector3(-96, 0, 0), next_vertex: vmath.vector3(96, 0, 0), friction: 0.6,
113
+ * });
114
+ * }
115
+ * ```
116
+ */
117
+ function create_chain(body: Opaque<"b2Body">, definition: { vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3; friction?: number; restitution?: number; material?: number; filter?: { category_bits?: number; mask_bits?: number; group_index?: number }; enable_sensor_events?: boolean }): LuaMultiReturn<[Opaque<"b2Chain">, { shape_id: number }[]]>;
118
+ /**
119
+ * Creates a fixture and attach it to this body. Use this function if you need
120
+ * to set some fixture parameters, like friction. Otherwise you can create the
121
+ * fixture directly from a shape.
122
+ * If the density is non-zero, this function automatically updates the mass of the body.
123
+ * Contacts are not created until the next time step.
124
+ *
125
+ * @param body - body
126
+ * @param definition - fixture definition table with:
127
+ * `shape` = shape table, `friction` = number, `restitution` = number,
128
+ * `density` = number, `sensor` = boolean, and optional `filter` table.
129
+ * Supported shape tables are:
130
+ * `circle` = `{ type = b2d.shape.SHAPE_TYPE_CIRCLE, radius = number, center = vector3_or_nil }`
131
+ * `edge` = `{ type = b2d.shape.SHAPE_TYPE_EDGE, v1 = vector3, v2 = vector3, v0 = vector3_or_nil, v3 = vector3_or_nil }`
132
+ * `polygon` = `{ type = b2d.shape.SHAPE_TYPE_POLYGON, vertices = { vector3, ... } }`
133
+ * `box` = `{ type = b2d.shape.SHAPE_TYPE_BOX, hx = number, hy = number, center = vector3_or_nil, angle = radians_or_nil }`
134
+ * `chain` = `{ type = b2d.shape.SHAPE_TYPE_CHAIN, vertices = { vector3, ... }, loop = boolean_or_nil, prev_vertex = vector3_or_nil, next_vertex = vector3_or_nil }`
135
+ * @returns fixture info table with `index`, `type`, `sensor`, `density`, `friction`, `restitution`, and `child_count`. **⚠️ `index` is 1-based; passed to Defold unchanged.**
136
+ * @example
137
+ * ```ts
138
+ * const body = b2d.get_body("#collisionobject");
139
+ * if (body !== undefined) {
140
+ * const triangle = b2d.body.create_fixture(body, {
141
+ * density: 1.0, friction: 0.3,
142
+ * shape: { type: b2d.shape.SHAPE_TYPE_POLYGON, vertices: [vmath.vector3(-16, -16, 0), vmath.vector3(16, -16, 0), vmath.vector3(0, 16, 0)] },
143
+ * });
144
+ * }
145
+ * ```
146
+ */
147
+ function create_fixture(body: Opaque<"b2Body">, definition: { 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_EDGE; 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 }; friction?: number; restitution?: number; density?: number; sensor?: boolean; is_sensor?: boolean; filter?: { category_bits: number; mask_bits: number; group_index: number } }): { index: number; type: number; sensor: boolean; density: number; friction: number; restitution: number; child_count: number };
148
+ /**
149
+ * Creates a shape and attaches it to this body.
150
+ * If the density is non-zero, this function automatically updates the mass of the body.
151
+ * Contacts are not created until the next time step.
152
+ * The definition may include `density`, `friction`, `restitution`, `material`,
153
+ * `sensor` or `is_sensor`, `filter`, and the shape table itself. The shape table
154
+ * can be in `definition.shape` or directly in `definition`.
155
+ *
156
+ * @param body - body
157
+ * @param definition - the shape definition.
158
+ * @returns **⚠️ `index` is 1-based; passed to Defold unchanged.**
159
+ */
160
+ function create_shape(body: Opaque<"b2Body">, definition: ({ 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 } } | { 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 }) & { density?: number; friction?: number; restitution?: number; material?: number; sensor?: boolean; is_sensor?: boolean; filter?: { category_bits: number; mask_bits: number; group_index: number } }): { index: number; shape_id: Opaque<"b2Shape">; type: number; sensor: boolean; density: number; friction: number; restitution: number; material: number; child_count: number; is_chain_segment: boolean };
161
+ /**
162
+ * Destroy a fixture from a body.
163
+ *
164
+ * @param body - body
165
+ * @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`. **⚠️ 1-based; passed to Defold unchanged.**
166
+ */
167
+ function destroy_fixture(body: Opaque<"b2Body">, fixture_index: number): void;
168
+ /**
169
+ * Destroy a shape. This removes the shape from the broad-phase and
170
+ * destroys all contacts associated with this shape. This will
171
+ * automatically adjust the mass of the body if the body is dynamic and the
172
+ * shape has positive density.
173
+ * All shapes attached to a body are implicitly destroyed when the body is destroyed.
174
+ *
175
+ * @param body - body
176
+ * @param shape_index - 1-based shape index from `b2d.body.get_shapes`. **⚠️ 1-based; passed to Defold unchanged.**
177
+ */
178
+ function destroy_shape(body: Opaque<"b2Body">, shape_index: number): void;
179
+ /**
180
+ * Print the body representation to the log output
181
+ *
182
+ * @param body - body
183
+ */
184
+ function dump(body: Opaque<"b2Body">): void;
185
+ /**
186
+ * Enable or disable contact events on all body shapes.
187
+ *
188
+ * @param body - body
189
+ * @param enable - true to enable contact events
190
+ */
191
+ function enable_contact_events(body: Opaque<"b2Body">, enable: boolean): void;
192
+ /**
193
+ * Enable or disable hit events on all body shapes.
194
+ *
195
+ * @param body - body
196
+ * @param enable - true to enable hit events
197
+ */
198
+ function enable_hit_events(body: Opaque<"b2Body">, enable: boolean): void;
199
+ /**
200
+ * You can disable sleeping on this body. If you disable sleeping, the body will be woken.
201
+ *
202
+ * @param body - body
203
+ * @param enable - if false, the body will never sleep, and consume more CPU
204
+ */
205
+ function enable_sleep(body: Opaque<"b2Body">, enable: boolean): void;
206
+ /**
207
+ * Get the angle in radians.
208
+ *
209
+ * @param body - body
210
+ * @returns the current world rotation angle in radians.
211
+ */
212
+ function get_angle(body: Opaque<"b2Body">): number;
213
+ /**
214
+ * Get the angular damping of the body.
215
+ *
216
+ * @param body - body
217
+ * @returns the damping
218
+ */
219
+ function get_angular_damping(body: Opaque<"b2Body">): number;
220
+ /**
221
+ * Get the angular velocity.
222
+ *
223
+ * @param body - body
224
+ * @returns the angular velocity in radians/second.
225
+ */
226
+ function get_angular_velocity(body: Opaque<"b2Body">): number;
227
+ /**
228
+ * Get touching contact data for a body.
229
+ *
230
+ * @param body - body
231
+ * @returns array of contact tables
232
+ */
233
+ function get_contact_data(body: Opaque<"b2Body">): Record<string | number, unknown>;
234
+ /**
235
+ * Get the fixtures attached to this body.
236
+ *
237
+ * @param body - body
238
+ * @returns array of fixture info tables with `index`, `type`, `sensor`, `density`, `friction`, `restitution`, and `child_count`. **⚠️ `index` is 1-based; passed to Defold unchanged.**
239
+ */
240
+ function get_fixtures(body: Opaque<"b2Body">): { index: number; type: number; sensor: boolean; density: number; friction: number; restitution: number; child_count: number }[];
241
+ /**
242
+ * Get the total force currently applied on this object
243
+ *
244
+ * @param body - body
245
+ */
246
+ function get_force(body: Opaque<"b2Body">): Vector3;
247
+ /**
248
+ * Get the gravity scale of the body.
249
+ *
250
+ * @param body - body
251
+ * @returns the scale
252
+ */
253
+ function get_gravity_scale(body: Opaque<"b2Body">): number;
254
+ /**
255
+ * Get the rotational inertia of the body about the local origin.
256
+ *
257
+ * @param body - body
258
+ * @returns the rotational inertia, usually in kg-m^2.
259
+ */
260
+ function get_inertia(body: Opaque<"b2Body">): number;
261
+ /**
262
+ * Get the joints attached to this body.
263
+ *
264
+ * @param body - body
265
+ * @returns array of `b2Joint` handles created by `b2d.joint`
266
+ */
267
+ function get_joints(body: Opaque<"b2Body">): number[];
268
+ /**
269
+ * Get the linear damping of the body.
270
+ *
271
+ * @param body - body
272
+ * @returns the damping
273
+ */
274
+ function get_linear_damping(body: Opaque<"b2Body">): number;
275
+ /**
276
+ * Get the linear velocity of the center of mass.
277
+ *
278
+ * @param body - body
279
+ * @returns the linear velocity of the center of mass.
280
+ */
281
+ function get_linear_velocity(body: Opaque<"b2Body">): Vector3;
282
+ /**
283
+ * Get the world velocity of a local point.
284
+ *
285
+ * @param body - body
286
+ * @param local_point - a point in local coordinates.
287
+ * @returns the world velocity of a point.
288
+ */
289
+ function get_linear_velocity_from_local_point(body: Opaque<"b2Body">, local_point: Vector3): Vector3;
290
+ /**
291
+ * Get the world linear velocity of a world point attached to this body.
292
+ *
293
+ * @param body - body
294
+ * @param world_point - a point in world coordinates.
295
+ * @returns the world velocity of a point.
296
+ */
297
+ function get_linear_velocity_from_world_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
298
+ /**
299
+ * Get the local position of the center of mass.
300
+ *
301
+ * @param body - body
302
+ * @returns Get the local position of the center of mass.
303
+ */
304
+ function get_local_center(body: Opaque<"b2Body">): Vector3;
305
+ /**
306
+ * Get the local position of the center of mass.
307
+ *
308
+ * @param body - body
309
+ * @returns Get the local position of the center of mass.
310
+ */
311
+ function get_local_center_of_mass(body: Opaque<"b2Body">): Vector3;
312
+ /**
313
+ * Gets a local point relative to the body's origin given a world point.
314
+ *
315
+ * @param body - body
316
+ * @param world_point - a point in world coordinates.
317
+ * @returns the corresponding local point relative to the body's origin.
318
+ */
319
+ function get_local_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
320
+ /**
321
+ * Gets a local vector given a world vector.
322
+ *
323
+ * @param body - body
324
+ * @param world_vector - a vector in world coordinates.
325
+ * @returns the corresponding local vector.
326
+ */
327
+ function get_local_vector(body: Opaque<"b2Body">, world_vector: Vector3): Vector3;
328
+ /**
329
+ * Get the total mass of the body.
330
+ *
331
+ * @param body - body
332
+ * @returns the mass, usually in kilograms (kg).
333
+ */
334
+ function get_mass(body: Opaque<"b2Body">): number;
335
+ /**
336
+ * Get the mass data of the body.
337
+ *
338
+ * @param body - body
339
+ * @returns table with `mass`, `center` in local coordinates, and `inertia`.
340
+ */
341
+ function get_mass_data(body: Opaque<"b2Body">): { mass: number; center: Vector3; inertia: number };
342
+ /**
343
+ * Get the mass data of the body.
344
+ *
345
+ * @param body - body
346
+ * @returns a struct containing the mass, inertia and center of the body.
347
+ */
348
+ function get_mass_data(body: Opaque<"b2Body">): Opaque<"b2MassData">;
349
+ /**
350
+ * Get the body name.
351
+ *
352
+ * @param body - body
353
+ * @returns body name, or nil if no name is set
354
+ */
355
+ function get_name(body: Opaque<"b2Body">): string;
356
+ /**
357
+ * Get the next body in the world's body list.
358
+ *
359
+ * @param body - body
360
+ * @returns the next body
361
+ */
362
+ function get_next(body: Opaque<"b2Body">): Opaque<"b2Body">;
363
+ /**
364
+ * Get the world body origin position.
365
+ *
366
+ * @param body - body
367
+ * @returns the world position of the body's origin.
368
+ */
369
+ function get_position(body: Opaque<"b2Body">): Vector3;
370
+ /**
371
+ * Get the rotational inertia of the body about the local origin.
372
+ *
373
+ * @param body - body
374
+ * @returns the rotational inertia, usually in kg-m^2.
375
+ */
376
+ function get_rotational_inertia(body: Opaque<"b2Body">): number;
377
+ /**
378
+ * Get the list of all shapes attached to this body.
379
+ *
380
+ * @param body - body
381
+ * @returns a table of shape info entries. Each entry includes `shape_id` for use with `b2d.shape` functions.
382
+ */
383
+ function get_shapes(body: Opaque<"b2Body">): { shape_id: number }[];
384
+ /**
385
+ * Get the sleep velocity threshold.
386
+ *
387
+ * @param body - body
388
+ * @returns velocity threshold in Defold units per second
389
+ */
390
+ function get_sleep_threshold(body: Opaque<"b2Body">): number;
391
+ /**
392
+ * Get the body transform for the body's origin.
393
+ *
394
+ * @param body - body
395
+ * @returns table with `position` and `angle` in radians.
396
+ */
397
+ function get_transform(body: Opaque<"b2Body">): { position: Vector3; angle: number };
398
+ /**
399
+ * Get the body transform for the body's origin.
400
+ *
401
+ * @param body - body
402
+ * @returns the world position of the body's origin.
403
+ */
404
+ function get_transform(body: Opaque<"b2Body">): Opaque<"b2Transform">;
405
+ /**
406
+ * Get the type of this body.
407
+ *
408
+ * @param body - body
409
+ * @returns the body type
410
+ */
411
+ function get_type(body: Opaque<"b2Body">): (number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_STATIC_BODY" });
412
+ /**
413
+ * Get the parent world of this body.
414
+ *
415
+ * @param body - body
416
+ */
417
+ function get_world(body: Opaque<"b2Body">): Opaque<"b2World">;
418
+ /**
419
+ * Get the world position of the center of mass.
420
+ *
421
+ * @param body - body
422
+ * @returns Get the world position of the center of mass.
423
+ */
424
+ function get_world_center(body: Opaque<"b2Body">): Vector3;
425
+ /**
426
+ * Get the world position of the center of mass.
427
+ *
428
+ * @param body - body
429
+ * @returns Get the world position of the center of mass.
430
+ */
431
+ function get_world_center_of_mass(body: Opaque<"b2Body">): Vector3;
432
+ /**
433
+ * Get the world coordinates of a point given the local coordinates.
434
+ *
435
+ * @param body - body
436
+ * @param local_vector - localPoint a point on the body measured relative the the body's origin.
437
+ * @returns the same point expressed in world coordinates.
438
+ */
439
+ function get_world_point(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
440
+ /**
441
+ * Get the world coordinates of a vector given the local coordinates.
442
+ *
443
+ * @param body - body
444
+ * @param local_vector - a vector fixed in the body.
445
+ * @returns the same vector expressed in world coordinates.
446
+ */
447
+ function get_world_vector(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
448
+ /**
449
+ * Get the active state of the body.
450
+ *
451
+ * @param body - body
452
+ * @returns is the body active
453
+ */
454
+ function is_active(body: Opaque<"b2Body">): boolean;
455
+ /**
456
+ * Get the sleeping state of this body.
457
+ *
458
+ * @param body - body
459
+ * @returns true if the body is awake, false if it's sleeping.
460
+ */
461
+ function is_awake(body: Opaque<"b2Body">): boolean;
462
+ /**
463
+ * Is this body in bullet mode
464
+ *
465
+ * @param body - body
466
+ * @returns true if the body is in bullet mode
467
+ */
468
+ function is_bullet(body: Opaque<"b2Body">): boolean;
469
+ /**
470
+ * Does this body have fixed rotation?
471
+ *
472
+ * @param body - body
473
+ * @returns is the rotation fixed
474
+ */
475
+ function is_fixed_rotation(body: Opaque<"b2Body">): boolean;
476
+ /**
477
+ * Is this body allowed to sleep
478
+ *
479
+ * @param body - body
480
+ * @returns true if the body is allowed to sleep
481
+ */
482
+ function is_sleeping_allowed(body: Opaque<"b2Body">): boolean;
483
+ /**
484
+ * Is this body allowed to sleep
485
+ *
486
+ * @param body - body
487
+ * @returns true if the body is allowed to sleep
488
+ */
489
+ function is_sleeping_enabled(body: Opaque<"b2Body">): boolean;
490
+ /**
491
+ * Validate a body handle.
492
+ *
493
+ * @param body - body
494
+ * @returns true if the body handle still refers to a live Box2D body
495
+ */
496
+ function is_valid(body: Opaque<"b2Body">): boolean;
497
+ /**
498
+ * This resets the mass properties to the sum of the mass properties of the fixtures.
499
+ * This normally does not need to be called unless you called SetMassData to override
500
+ *
501
+ * @param body - body
502
+ */
503
+ function reset_mass_data(body: Opaque<"b2Body">): void;
504
+ /**
505
+ * Set the active state of the body. An inactive body is not
506
+ * simulated and cannot be collided with or woken up.
507
+ * If you pass a flag of true, all fixtures will be added to the
508
+ * broad-phase.
509
+ * If you pass a flag of false, all fixtures will be removed from
510
+ * the broad-phase and all contacts will be destroyed.
511
+ * Fixtures and joints are otherwise unaffected. You may continue
512
+ * to create/destroy fixtures and joints on inactive bodies.
513
+ * Fixtures on an inactive body are implicitly inactive and will
514
+ * not participate in collisions, ray-casts, or queries.
515
+ * Joints connected to an inactive body are implicitly inactive.
516
+ * An inactive body is still owned by a b2World object and remains
517
+ * in the body list.
518
+ *
519
+ * @param body - body
520
+ * @param enable - true if the body should be active
521
+ */
522
+ function set_active(body: Opaque<"b2Body">, enable: boolean): void;
523
+ /**
524
+ * Set the angular damping of the body.
525
+ *
526
+ * @param body - body
527
+ * @param damping - the damping
528
+ */
529
+ function set_angular_damping(body: Opaque<"b2Body">, damping: number): void;
530
+ /**
531
+ * Set the angular velocity.
532
+ *
533
+ * @param body - body
534
+ * @param omega - the new angular velocity in radians/second.
535
+ */
536
+ function set_angular_velocity(body: Opaque<"b2Body">, omega: number): void;
537
+ /**
538
+ * Set the sleep state of the body. A sleeping body has very low CPU cost.
539
+ *
540
+ * @param body - body
541
+ * @param enable - flag set to false to put body to sleep, true to wake it.
542
+ */
543
+ function set_awake(body: Opaque<"b2Body">, enable: boolean): void;
544
+ /**
545
+ * Should this body be treated like a bullet for continuous collision detection?
546
+ *
547
+ * @param body - body
548
+ * @param enable - if true, the body will be in bullet mode
549
+ */
550
+ function set_bullet(body: Opaque<"b2Body">, enable: boolean): void;
551
+ /**
552
+ * Set this body to have fixed rotation. This causes the mass to be reset.
553
+ *
554
+ * @param body - body
555
+ * @param enable - true if the rotation should be fixed
556
+ */
557
+ function set_fixed_rotation(body: Opaque<"b2Body">, enable: boolean): void;
558
+ /**
559
+ * Set the gravity scale of the body.
560
+ *
561
+ * @param body - body
562
+ * @param scale - the scale
563
+ */
564
+ function set_gravity_scale(body: Opaque<"b2Body">, scale: number): void;
565
+ /**
566
+ * Set the linear damping of the body.
567
+ *
568
+ * @param body - body
569
+ * @param damping - the damping
570
+ */
571
+ function set_linear_damping(body: Opaque<"b2Body">, damping: number): void;
572
+ /**
573
+ * Set the linear velocity of the center of mass.
574
+ *
575
+ * @param body - body
576
+ * @param velocity - the new linear velocity of the center of mass.
577
+ */
578
+ function set_linear_velocity(body: Opaque<"b2Body">, velocity: Vector3): void;
579
+ /**
580
+ * Set the mass properties to override the mass properties of the fixtures.
581
+ *
582
+ * @param body - body
583
+ * @param data - table with `mass`, `center` in local coordinates, and `inertia`.
584
+ */
585
+ function set_mass_data(body: Opaque<"b2Body">, data: { mass: number; center: Vector3; inertia: number }): void;
586
+ /**
587
+ * Set the body name.
588
+ *
589
+ * @param body - body
590
+ * @param name - body name
591
+ */
592
+ function set_name(body: Opaque<"b2Body">, name: string): void;
593
+ /**
594
+ * Set the sleep velocity threshold.
595
+ *
596
+ * @param body - body
597
+ * @param threshold - velocity threshold in Defold units per second
598
+ */
599
+ function set_sleep_threshold(body: Opaque<"b2Body">, threshold: number): void;
600
+ /**
601
+ * You can disable sleeping on this body. If you disable sleeping, the body will be woken.
602
+ *
603
+ * @param body - body
604
+ * @param enable - if false, the body will never sleep, and consume more CPU
605
+ */
606
+ function set_sleeping_allowed(body: Opaque<"b2Body">, enable: boolean): void;
607
+ /**
608
+ * Set velocity to reach a target transform.
609
+ *
610
+ * @param body - body
611
+ * @param position - target world position
612
+ * @param angle - target world angle in radians
613
+ * @param time_step - time step used to compute velocity
614
+ */
615
+ function set_target_transform(body: Opaque<"b2Body">, position: Vector3, angle: number, time_step: number): void;
616
+ /**
617
+ * Set the position of the body's origin and rotation.
618
+ * This breaks any contacts and wakes the other bodies.
619
+ * Manipulating a body's transform may cause non-physical behavior.
620
+ *
621
+ * @param body - body
622
+ * @param position - the world position of the body's local origin.
623
+ * @param angle - the world position of the body's local origin.
624
+ */
625
+ function set_transform(body: Opaque<"b2Body">, position: Vector3, angle: number): void;
626
+ /**
627
+ * Set the type of this body. This may alter the mass and velocity.
628
+ *
629
+ * @param body - body
630
+ * @param type - the body type
631
+ */
632
+ function set_type(body: Opaque<"b2Body">, type: (number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_STATIC_BODY" })): void;
633
+ }
634
+ }
635
+
636
+ export {};