@defold-typescript/types 0.26.0 → 0.28.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.
- package/api-availability.json +307 -307
- package/api-signatures.json +1311 -0
- package/api-targets.json +342 -0
- package/examples/translations.json +1984 -0
- package/fixtures/messages_doc.json +880 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +43 -43
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +22 -22
- package/generated/versions/defold-1.12.4/physics.d.ts +78 -75
- package/generated/versions/defold-1.12.4/render.d.ts +75 -55
- package/generated/versions/defold-1.12.4/resource.d.ts +187 -175
- package/generated/versions/defold-1.13.0/b2d.d.ts +33 -0
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +676 -0
- package/generated/versions/defold-1.13.0/b2d_chain.d.ts +106 -0
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +155 -0
- package/generated/versions/defold-1.13.0/b2d_joint.d.ts +823 -0
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +215 -0
- package/generated/versions/defold-1.13.0/b2d_world.d.ts +314 -0
- package/generated/versions/defold-1.13.0/buffer.d.ts +176 -0
- package/generated/versions/defold-1.13.0/camera.d.ts +302 -0
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +146 -0
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +71 -0
- package/generated/versions/defold-1.13.0/compute.d.ts +306 -0
- package/generated/versions/defold-1.13.0/crash.d.ts +143 -0
- package/generated/versions/defold-1.13.0/editor-vm/http.d.ts +56 -0
- package/generated/versions/defold-1.13.0/editor-vm/json.d.ts +10 -0
- package/generated/versions/defold-1.13.0/editor-vm/localization.d.ts +42 -0
- package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +80 -0
- package/generated/versions/defold-1.13.0/editor-vm/zip.d.ts +10 -0
- package/generated/versions/defold-1.13.0/editor-vm/zlib.d.ts +24 -0
- package/generated/versions/defold-1.13.0/editor.d.ts +1092 -0
- package/generated/versions/defold-1.13.0/factory.d.ts +123 -0
- package/generated/versions/defold-1.13.0/font.d.ts +81 -0
- package/generated/versions/defold-1.13.0/go.d.ts +1054 -0
- package/generated/versions/defold-1.13.0/graphics.d.ts +321 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +2370 -0
- package/generated/versions/defold-1.13.0/html5.d.ts +53 -0
- package/generated/versions/defold-1.13.0/http.d.ts +84 -0
- package/generated/versions/defold-1.13.0/iac.d.ts +18 -0
- package/generated/versions/defold-1.13.0/iap.d.ts +60 -0
- package/generated/versions/defold-1.13.0/image.d.ts +139 -0
- package/generated/versions/defold-1.13.0/index.d.ts +48 -0
- package/generated/versions/defold-1.13.0/json.d.ts +76 -0
- package/generated/versions/defold-1.13.0/kinds/editor-script.d.ts +13 -0
- package/generated/versions/defold-1.13.0/label.d.ts +94 -0
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +140 -0
- package/generated/versions/defold-1.13.0/material.d.ts +444 -0
- package/generated/versions/defold-1.13.0/model.d.ts +246 -0
- package/generated/versions/defold-1.13.0/msg.d.ts +10 -0
- package/generated/versions/defold-1.13.0/particlefx.d.ts +166 -0
- package/generated/versions/defold-1.13.0/physics.d.ts +548 -0
- package/generated/versions/defold-1.13.0/profiler.d.ts +233 -0
- package/generated/versions/defold-1.13.0/push.d.ts +66 -0
- package/generated/versions/defold-1.13.0/render.d.ts +1185 -0
- package/generated/versions/defold-1.13.0/resource.d.ts +1530 -0
- package/generated/versions/defold-1.13.0/socket.d.ts +795 -0
- package/generated/versions/defold-1.13.0/sound.d.ts +291 -0
- package/generated/versions/defold-1.13.0/sprite.d.ts +157 -0
- package/generated/versions/defold-1.13.0/sys.d.ts +695 -0
- package/generated/versions/defold-1.13.0/tilemap.d.ts +195 -0
- package/generated/versions/defold-1.13.0/timer.d.ts +114 -0
- package/generated/versions/defold-1.13.0/types.d.ts +61 -0
- package/generated/versions/defold-1.13.0/vmath.d.ts +806 -0
- package/generated/versions/defold-1.13.0/webview.d.ts +68 -0
- package/generated/versions/defold-1.13.0/window.d.ts +198 -0
- package/generated/versions/defold-1.13.0/zlib.d.ts +40 -0
- package/index.d.ts +4 -84
- package/package.json +11 -3
- package/scripts/import-defold-release.ts +18 -1
- package/src/example-store.ts +5 -0
- package/scripts/lua-types-signature-index.ts +0 -151
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Hash, 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 [chain, segments] = b2d.body.create_chain(body, {
|
|
109
|
+
* vertices: [vmath.vector3(-64, 0, 0), vmath.vector3(0, 16, 0), vmath.vector3(64, 0, 0)],
|
|
110
|
+
* prev_vertex: vmath.vector3(-96, 0, 0), next_vertex: vmath.vector3(96, 0, 0), friction: 0.6,
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
function create_chain(body: Opaque<"b2Body">, definition: Record<string | number, unknown>): LuaMultiReturn<[Opaque<"b2Chain">, { shape_id: number }[]]>;
|
|
115
|
+
/**
|
|
116
|
+
* Creates a fixture and attach it to this body. Use this function if you need
|
|
117
|
+
* to set some fixture parameters, like friction. Otherwise you can create the
|
|
118
|
+
* fixture directly from a shape.
|
|
119
|
+
* If the density is non-zero, this function automatically updates the mass of the body.
|
|
120
|
+
* Contacts are not created until the next time step.
|
|
121
|
+
*
|
|
122
|
+
* @param body - body
|
|
123
|
+
* @param definition - fixture definition table with:
|
|
124
|
+
* `shape` = shape table, `friction` = number, `restitution` = number,
|
|
125
|
+
* `density` = number, `sensor` = boolean, and optional `filter` table.
|
|
126
|
+
* Supported shape tables are:
|
|
127
|
+
* `circle` = `{ type = b2d.shape.SHAPE_TYPE_CIRCLE, radius = number, center = vector3_or_nil }`
|
|
128
|
+
* `edge` = `{ type = b2d.shape.SHAPE_TYPE_EDGE, v1 = vector3, v2 = vector3, v0 = vector3_or_nil, v3 = vector3_or_nil }`
|
|
129
|
+
* `polygon` = `{ type = b2d.shape.SHAPE_TYPE_POLYGON, vertices = { vector3, ... } }`
|
|
130
|
+
* `box` = `{ type = b2d.shape.SHAPE_TYPE_BOX, hx = number, hy = number, center = vector3_or_nil, angle = radians_or_nil }`
|
|
131
|
+
* `chain` = `{ type = b2d.shape.SHAPE_TYPE_CHAIN, vertices = { vector3, ... }, loop = boolean_or_nil, prev_vertex = vector3_or_nil, next_vertex = vector3_or_nil }`
|
|
132
|
+
* @returns fixture info table with `index`, `type`, `sensor`, `density`, `friction`, `restitution`, and `child_count`
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const body = b2d.get_body("#collisionobject");
|
|
136
|
+
* const triangle = b2d.body.create_fixture(body, {
|
|
137
|
+
* density: 1.0, friction: 0.3,
|
|
138
|
+
* shape: { type: b2d.shape.SHAPE_TYPE_POLYGON, vertices: [vmath.vector3(-16, -16, 0), vmath.vector3(16, -16, 0), vmath.vector3(0, 16, 0)] },
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
function create_fixture(body: Opaque<"b2Body">, definition: { shape?: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }; friction?: number; restitution?: number; density?: number; 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 };
|
|
143
|
+
/**
|
|
144
|
+
* Creates a fixture from a shape and attach it to this body.
|
|
145
|
+
* This is a convenience function. Use b2FixtureDef if you need to set parameters
|
|
146
|
+
* like friction, restitution, user data, or filtering.
|
|
147
|
+
* If the density is non-zero, this function automatically updates the mass of the body.
|
|
148
|
+
*
|
|
149
|
+
* @param body - body
|
|
150
|
+
* @param shape - the shape to be cloned.
|
|
151
|
+
* @param density - the shape density (set to zero for static bodies).
|
|
152
|
+
*/
|
|
153
|
+
function create_fixture(body: Opaque<"b2Body">, shape: Opaque<"b2Shape">, density: number): void;
|
|
154
|
+
/**
|
|
155
|
+
* Creates a shape and attaches it to this body.
|
|
156
|
+
* If the density is non-zero, this function automatically updates the mass of the body.
|
|
157
|
+
* Contacts are not created until the next time step.
|
|
158
|
+
* The definition may include `density`, `friction`, `restitution`, `material`,
|
|
159
|
+
* `sensor` or `is_sensor`, `filter`, and the shape table itself. The shape table
|
|
160
|
+
* can be in `definition.shape` or directly in `definition`.
|
|
161
|
+
*
|
|
162
|
+
* @param body - body
|
|
163
|
+
* @param definition - the shape definition.
|
|
164
|
+
*/
|
|
165
|
+
function create_shape(body: Opaque<"b2Body">, definition: Record<string | number, unknown>): void;
|
|
166
|
+
/**
|
|
167
|
+
* Destroy a fixture from a body.
|
|
168
|
+
*
|
|
169
|
+
* @param body - body
|
|
170
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
171
|
+
*/
|
|
172
|
+
function destroy_fixture(body: Opaque<"b2Body">, fixture_index: number): void;
|
|
173
|
+
/**
|
|
174
|
+
* Destroy a shape. This removes the shape from the broad-phase and
|
|
175
|
+
* destroys all contacts associated with this shape. This will
|
|
176
|
+
* automatically adjust the mass of the body if the body is dynamic and the
|
|
177
|
+
* shape has positive density.
|
|
178
|
+
* All shapes attached to a body are implicitly destroyed when the body is destroyed.
|
|
179
|
+
*
|
|
180
|
+
* @param body - body
|
|
181
|
+
* @param shape_index - 1-based shape index from `b2d.body.get_shapes`
|
|
182
|
+
*/
|
|
183
|
+
function destroy_shape(body: Opaque<"b2Body">, shape_index: number): void;
|
|
184
|
+
/**
|
|
185
|
+
* Print the body representation to the log output
|
|
186
|
+
*
|
|
187
|
+
* @param body - body
|
|
188
|
+
*/
|
|
189
|
+
function dump(body: Opaque<"b2Body">): void;
|
|
190
|
+
/**
|
|
191
|
+
* Enable or disable contact events on all body shapes.
|
|
192
|
+
*
|
|
193
|
+
* @param body - body
|
|
194
|
+
* @param enable - true to enable contact events
|
|
195
|
+
*/
|
|
196
|
+
function enable_contact_events(body: Opaque<"b2Body">, enable: boolean): void;
|
|
197
|
+
/**
|
|
198
|
+
* Enable or disable hit events on all body shapes.
|
|
199
|
+
*
|
|
200
|
+
* @param body - body
|
|
201
|
+
* @param enable - true to enable hit events
|
|
202
|
+
*/
|
|
203
|
+
function enable_hit_events(body: Opaque<"b2Body">, enable: boolean): void;
|
|
204
|
+
/**
|
|
205
|
+
* You can disable sleeping on this body. If you disable sleeping, the body will be woken.
|
|
206
|
+
*
|
|
207
|
+
* @param body - body
|
|
208
|
+
* @param enable - if false, the body will never sleep, and consume more CPU
|
|
209
|
+
*/
|
|
210
|
+
function enable_sleep(body: Opaque<"b2Body">, enable: boolean): void;
|
|
211
|
+
/**
|
|
212
|
+
* Get the angle in radians.
|
|
213
|
+
*
|
|
214
|
+
* @param body - body
|
|
215
|
+
* @returns the current world rotation angle in radians.
|
|
216
|
+
*/
|
|
217
|
+
function get_angle(body: Opaque<"b2Body">): number;
|
|
218
|
+
/**
|
|
219
|
+
* Get the angular damping of the body.
|
|
220
|
+
*
|
|
221
|
+
* @param body - body
|
|
222
|
+
* @returns the damping
|
|
223
|
+
*/
|
|
224
|
+
function get_angular_damping(body: Opaque<"b2Body">): number;
|
|
225
|
+
/**
|
|
226
|
+
* Get the angular velocity.
|
|
227
|
+
*
|
|
228
|
+
* @param body - body
|
|
229
|
+
* @returns the angular velocity in radians/second.
|
|
230
|
+
*/
|
|
231
|
+
function get_angular_velocity(body: Opaque<"b2Body">): number;
|
|
232
|
+
/**
|
|
233
|
+
* Get touching contact data for a body.
|
|
234
|
+
*
|
|
235
|
+
* @param body - body
|
|
236
|
+
* @returns array of contact tables
|
|
237
|
+
*/
|
|
238
|
+
function get_contact_data(body: Opaque<"b2Body">): Record<string | number, unknown>;
|
|
239
|
+
/**
|
|
240
|
+
* Get the list of all contacts attached to this body.
|
|
241
|
+
*
|
|
242
|
+
* @param body - body
|
|
243
|
+
* @returns the first edge
|
|
244
|
+
*/
|
|
245
|
+
function get_contact_list(body: Opaque<"b2Body">): Opaque<"b2ContactEdge">;
|
|
246
|
+
/**
|
|
247
|
+
* Get the fixtures attached to this body.
|
|
248
|
+
*
|
|
249
|
+
* @param body - body
|
|
250
|
+
* @returns array of fixture info tables with `index`, `type`, `sensor`, `density`, `friction`, `restitution`, and `child_count`
|
|
251
|
+
*/
|
|
252
|
+
function get_fixtures(body: Opaque<"b2Body">): { index: number; type: number; sensor: boolean; density: number; friction: number; restitution: number; child_count: number }[];
|
|
253
|
+
/**
|
|
254
|
+
* Get the total force currently applied on this object
|
|
255
|
+
*
|
|
256
|
+
* @param body - body
|
|
257
|
+
*/
|
|
258
|
+
function get_force(body: Opaque<"b2Body">): Vector3;
|
|
259
|
+
/**
|
|
260
|
+
* Get the gravity scale of the body.
|
|
261
|
+
*
|
|
262
|
+
* @param body - body
|
|
263
|
+
* @returns the scale
|
|
264
|
+
*/
|
|
265
|
+
function get_gravity_scale(body: Opaque<"b2Body">): number;
|
|
266
|
+
/**
|
|
267
|
+
* Get the rotational inertia of the body about the local origin.
|
|
268
|
+
*
|
|
269
|
+
* @param body - body
|
|
270
|
+
* @returns the rotational inertia, usually in kg-m^2.
|
|
271
|
+
*/
|
|
272
|
+
function get_inertia(body: Opaque<"b2Body">): number;
|
|
273
|
+
/**
|
|
274
|
+
* Get the joints attached to this body.
|
|
275
|
+
*
|
|
276
|
+
* @param body - body
|
|
277
|
+
* @returns array of `b2Joint` handles created by `b2d.joint`
|
|
278
|
+
*/
|
|
279
|
+
function get_joints(body: Opaque<"b2Body">): number[];
|
|
280
|
+
/**
|
|
281
|
+
* Get the linear damping of the body.
|
|
282
|
+
*
|
|
283
|
+
* @param body - body
|
|
284
|
+
* @returns the damping
|
|
285
|
+
*/
|
|
286
|
+
function get_linear_damping(body: Opaque<"b2Body">): number;
|
|
287
|
+
/**
|
|
288
|
+
* Get the linear velocity of the center of mass.
|
|
289
|
+
*
|
|
290
|
+
* @param body - body
|
|
291
|
+
* @returns the linear velocity of the center of mass.
|
|
292
|
+
*/
|
|
293
|
+
function get_linear_velocity(body: Opaque<"b2Body">): Vector3;
|
|
294
|
+
/**
|
|
295
|
+
* Get the world velocity of a local point.
|
|
296
|
+
*
|
|
297
|
+
* @param body - body
|
|
298
|
+
* @param local_point - a point in local coordinates.
|
|
299
|
+
* @returns the world velocity of a point.
|
|
300
|
+
*/
|
|
301
|
+
function get_linear_velocity_from_local_point(body: Opaque<"b2Body">, local_point: Vector3): Vector3;
|
|
302
|
+
/**
|
|
303
|
+
* Get the world linear velocity of a world point attached to this body.
|
|
304
|
+
*
|
|
305
|
+
* @param body - body
|
|
306
|
+
* @param world_point - a point in world coordinates.
|
|
307
|
+
* @returns the world velocity of a point.
|
|
308
|
+
*/
|
|
309
|
+
function get_linear_velocity_from_world_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
|
|
310
|
+
/**
|
|
311
|
+
* Get the local position of the center of mass.
|
|
312
|
+
*
|
|
313
|
+
* @param body - body
|
|
314
|
+
* @returns Get the local position of the center of mass.
|
|
315
|
+
*/
|
|
316
|
+
function get_local_center(body: Opaque<"b2Body">): Vector3;
|
|
317
|
+
/**
|
|
318
|
+
* Get the local position of the center of mass.
|
|
319
|
+
*
|
|
320
|
+
* @param body - body
|
|
321
|
+
* @returns Get the local position of the center of mass.
|
|
322
|
+
*/
|
|
323
|
+
function get_local_center_of_mass(body: Opaque<"b2Body">): Vector3;
|
|
324
|
+
/**
|
|
325
|
+
* Gets a local point relative to the body's origin given a world point.
|
|
326
|
+
*
|
|
327
|
+
* @param body - body
|
|
328
|
+
* @param world_point - a point in world coordinates.
|
|
329
|
+
* @returns the corresponding local point relative to the body's origin.
|
|
330
|
+
*/
|
|
331
|
+
function get_local_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
|
|
332
|
+
/**
|
|
333
|
+
* Gets a local vector given a world vector.
|
|
334
|
+
*
|
|
335
|
+
* @param body - body
|
|
336
|
+
* @param world_vector - a vector in world coordinates.
|
|
337
|
+
* @returns the corresponding local vector.
|
|
338
|
+
*/
|
|
339
|
+
function get_local_vector(body: Opaque<"b2Body">, world_vector: Vector3): Vector3;
|
|
340
|
+
/**
|
|
341
|
+
* Get the total mass of the body.
|
|
342
|
+
*
|
|
343
|
+
* @param body - body
|
|
344
|
+
* @returns the mass, usually in kilograms (kg).
|
|
345
|
+
*/
|
|
346
|
+
function get_mass(body: Opaque<"b2Body">): number;
|
|
347
|
+
/**
|
|
348
|
+
* Get the mass data of the body.
|
|
349
|
+
*
|
|
350
|
+
* @param body - body
|
|
351
|
+
* @returns table with `mass`, `center` in local coordinates, and `inertia`.
|
|
352
|
+
*/
|
|
353
|
+
function get_mass_data(body: Opaque<"b2Body">): { mass: number; center: Vector3; inertia: number };
|
|
354
|
+
/**
|
|
355
|
+
* Get the mass data of the body.
|
|
356
|
+
*
|
|
357
|
+
* @param body - body
|
|
358
|
+
* @returns a struct containing the mass, inertia and center of the body.
|
|
359
|
+
*/
|
|
360
|
+
function get_mass_data(body: Opaque<"b2Body">): Opaque<"b2MassData">;
|
|
361
|
+
/**
|
|
362
|
+
* Get the body name.
|
|
363
|
+
*
|
|
364
|
+
* @param body - body
|
|
365
|
+
* @returns body name, or nil if no name is set
|
|
366
|
+
*/
|
|
367
|
+
function get_name(body: Opaque<"b2Body">): string;
|
|
368
|
+
/**
|
|
369
|
+
* Get the next body in the world's body list.
|
|
370
|
+
*
|
|
371
|
+
* @param body - body
|
|
372
|
+
* @returns the next body
|
|
373
|
+
*/
|
|
374
|
+
function get_next(body: Opaque<"b2Body">): Opaque<"b2Body">;
|
|
375
|
+
/**
|
|
376
|
+
* Get the world body origin position.
|
|
377
|
+
*
|
|
378
|
+
* @param body - body
|
|
379
|
+
* @returns the world position of the body's origin.
|
|
380
|
+
*/
|
|
381
|
+
function get_position(body: Opaque<"b2Body">): Vector3;
|
|
382
|
+
/**
|
|
383
|
+
* Get the rotational inertia of the body about the local origin.
|
|
384
|
+
*
|
|
385
|
+
* @param body - body
|
|
386
|
+
* @returns the rotational inertia, usually in kg-m^2.
|
|
387
|
+
*/
|
|
388
|
+
function get_rotational_inertia(body: Opaque<"b2Body">): number;
|
|
389
|
+
/**
|
|
390
|
+
* Get the list of all shapes attached to this body.
|
|
391
|
+
*
|
|
392
|
+
* @param body - body
|
|
393
|
+
* @returns a table of shape info entries. Each entry includes `shape_id` for use with `b2d.shape` functions.
|
|
394
|
+
*/
|
|
395
|
+
function get_shapes(body: Opaque<"b2Body">): { shape_id: number }[];
|
|
396
|
+
/**
|
|
397
|
+
* Get the sleep velocity threshold.
|
|
398
|
+
*
|
|
399
|
+
* @param body - body
|
|
400
|
+
* @returns velocity threshold in Defold units per second
|
|
401
|
+
*/
|
|
402
|
+
function get_sleep_threshold(body: Opaque<"b2Body">): number;
|
|
403
|
+
/**
|
|
404
|
+
* Get the body transform for the body's origin.
|
|
405
|
+
*
|
|
406
|
+
* @param body - body
|
|
407
|
+
* @returns table with `position` and `angle` in radians.
|
|
408
|
+
*/
|
|
409
|
+
function get_transform(body: Opaque<"b2Body">): { position: Vector3; angle: number };
|
|
410
|
+
/**
|
|
411
|
+
* Get the body transform for the body's origin.
|
|
412
|
+
*
|
|
413
|
+
* @param body - body
|
|
414
|
+
* @returns the world position of the body's origin.
|
|
415
|
+
*/
|
|
416
|
+
function get_transform(body: Opaque<"b2Body">): Opaque<"b2Transform">;
|
|
417
|
+
/**
|
|
418
|
+
* Get the type of this body.
|
|
419
|
+
*
|
|
420
|
+
* @param body - body
|
|
421
|
+
* @returns the body type
|
|
422
|
+
*/
|
|
423
|
+
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" });
|
|
424
|
+
/**
|
|
425
|
+
* Get the user data pointer that was provided in the body definition.
|
|
426
|
+
*
|
|
427
|
+
* @param body - body
|
|
428
|
+
* @returns the game object id this body is connected to
|
|
429
|
+
*/
|
|
430
|
+
function get_user_data(body: Opaque<"b2Body">): Hash;
|
|
431
|
+
/**
|
|
432
|
+
* Get the parent world of this body.
|
|
433
|
+
*
|
|
434
|
+
* @param body - body
|
|
435
|
+
*/
|
|
436
|
+
function get_world(body: Opaque<"b2Body">): Opaque<"b2World">;
|
|
437
|
+
/**
|
|
438
|
+
* Get the angle in radians.
|
|
439
|
+
*
|
|
440
|
+
* @param body - body
|
|
441
|
+
* @returns the current world rotation angle in radians.
|
|
442
|
+
*/
|
|
443
|
+
function get_world_center(body: Opaque<"b2Body">): number;
|
|
444
|
+
/**
|
|
445
|
+
* Get the world position of the center of mass.
|
|
446
|
+
*
|
|
447
|
+
* @param body - body
|
|
448
|
+
* @returns Get the world position of the center of mass.
|
|
449
|
+
*/
|
|
450
|
+
function get_world_center(body: Opaque<"b2Body">): Vector3;
|
|
451
|
+
/**
|
|
452
|
+
* Get the world position of the center of mass.
|
|
453
|
+
*
|
|
454
|
+
* @param body - body
|
|
455
|
+
* @returns Get the world position of the center of mass.
|
|
456
|
+
*/
|
|
457
|
+
function get_world_center_of_mass(body: Opaque<"b2Body">): Vector3;
|
|
458
|
+
/**
|
|
459
|
+
* Get the world coordinates of a point given the local coordinates.
|
|
460
|
+
*
|
|
461
|
+
* @param body - body
|
|
462
|
+
* @param local_vector - localPoint a point on the body measured relative the the body's origin.
|
|
463
|
+
* @returns the same point expressed in world coordinates.
|
|
464
|
+
*/
|
|
465
|
+
function get_world_point(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
|
|
466
|
+
/**
|
|
467
|
+
* Get the world coordinates of a vector given the local coordinates.
|
|
468
|
+
*
|
|
469
|
+
* @param body - body
|
|
470
|
+
* @param local_vector - a vector fixed in the body.
|
|
471
|
+
* @returns the same vector expressed in world coordinates.
|
|
472
|
+
*/
|
|
473
|
+
function get_world_vector(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
|
|
474
|
+
/**
|
|
475
|
+
* Get the active state of the body.
|
|
476
|
+
*
|
|
477
|
+
* @param body - body
|
|
478
|
+
* @returns is the body active
|
|
479
|
+
*/
|
|
480
|
+
function is_active(body: Opaque<"b2Body">): boolean;
|
|
481
|
+
/**
|
|
482
|
+
* Get the sleeping state of this body.
|
|
483
|
+
*
|
|
484
|
+
* @param body - body
|
|
485
|
+
* @returns true if the body is awake, false if it's sleeping.
|
|
486
|
+
*/
|
|
487
|
+
function is_awake(body: Opaque<"b2Body">): boolean;
|
|
488
|
+
/**
|
|
489
|
+
* Is this body in bullet mode
|
|
490
|
+
*
|
|
491
|
+
* @param body - body
|
|
492
|
+
* @returns true if the body is in bullet mode
|
|
493
|
+
*/
|
|
494
|
+
function is_bullet(body: Opaque<"b2Body">): boolean;
|
|
495
|
+
/**
|
|
496
|
+
* Does this body have fixed rotation?
|
|
497
|
+
*
|
|
498
|
+
* @param body - body
|
|
499
|
+
* @returns is the rotation fixed
|
|
500
|
+
*/
|
|
501
|
+
function is_fixed_rotation(body: Opaque<"b2Body">): boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Is this body allowed to sleep
|
|
504
|
+
*
|
|
505
|
+
* @param body - body
|
|
506
|
+
* @returns true if the body is allowed to sleep
|
|
507
|
+
*/
|
|
508
|
+
function is_sleeping_allowed(body: Opaque<"b2Body">): boolean;
|
|
509
|
+
/**
|
|
510
|
+
* Is this body allowed to sleep
|
|
511
|
+
*
|
|
512
|
+
* @param body - body
|
|
513
|
+
* @returns true if the body is allowed to sleep
|
|
514
|
+
*/
|
|
515
|
+
function is_sleeping_enabled(body: Opaque<"b2Body">): boolean;
|
|
516
|
+
/**
|
|
517
|
+
* Validate a body handle.
|
|
518
|
+
*
|
|
519
|
+
* @param body - body
|
|
520
|
+
* @returns true if the body handle still refers to a live Box2D body
|
|
521
|
+
*/
|
|
522
|
+
function is_valid(body: Opaque<"b2Body">): boolean;
|
|
523
|
+
/**
|
|
524
|
+
* This resets the mass properties to the sum of the mass properties of the fixtures.
|
|
525
|
+
* This normally does not need to be called unless you called SetMassData to override
|
|
526
|
+
*
|
|
527
|
+
* @param body - body
|
|
528
|
+
*/
|
|
529
|
+
function reset_mass_data(body: Opaque<"b2Body">): void;
|
|
530
|
+
/**
|
|
531
|
+
* Set the active state of the body. An inactive body is not
|
|
532
|
+
* simulated and cannot be collided with or woken up.
|
|
533
|
+
* If you pass a flag of true, all fixtures will be added to the
|
|
534
|
+
* broad-phase.
|
|
535
|
+
* If you pass a flag of false, all fixtures will be removed from
|
|
536
|
+
* the broad-phase and all contacts will be destroyed.
|
|
537
|
+
* Fixtures and joints are otherwise unaffected. You may continue
|
|
538
|
+
* to create/destroy fixtures and joints on inactive bodies.
|
|
539
|
+
* Fixtures on an inactive body are implicitly inactive and will
|
|
540
|
+
* not participate in collisions, ray-casts, or queries.
|
|
541
|
+
* Joints connected to an inactive body are implicitly inactive.
|
|
542
|
+
* An inactive body is still owned by a b2World object and remains
|
|
543
|
+
* in the body list.
|
|
544
|
+
*
|
|
545
|
+
* @param body - body
|
|
546
|
+
* @param enable - true if the body should be active
|
|
547
|
+
*/
|
|
548
|
+
function set_active(body: Opaque<"b2Body">, enable: boolean): void;
|
|
549
|
+
/**
|
|
550
|
+
* Set the angular damping of the body.
|
|
551
|
+
*
|
|
552
|
+
* @param body - body
|
|
553
|
+
* @param damping - the damping
|
|
554
|
+
*/
|
|
555
|
+
function set_angular_damping(body: Opaque<"b2Body">, damping: number): void;
|
|
556
|
+
/**
|
|
557
|
+
* Set the angular velocity.
|
|
558
|
+
*
|
|
559
|
+
* @param body - body
|
|
560
|
+
* @param omega - the new angular velocity in radians/second.
|
|
561
|
+
*/
|
|
562
|
+
function set_angular_velocity(body: Opaque<"b2Body">, omega: number): void;
|
|
563
|
+
/**
|
|
564
|
+
* Set the sleep state of the body. A sleeping body has very low CPU cost.
|
|
565
|
+
*
|
|
566
|
+
* @param body - body
|
|
567
|
+
* @param enable - flag set to false to put body to sleep, true to wake it.
|
|
568
|
+
*/
|
|
569
|
+
function set_awake(body: Opaque<"b2Body">, enable: boolean): void;
|
|
570
|
+
/**
|
|
571
|
+
* Should this body be treated like a bullet for continuous collision detection?
|
|
572
|
+
*
|
|
573
|
+
* @param body - body
|
|
574
|
+
* @param enable - if true, the body will be in bullet mode
|
|
575
|
+
*/
|
|
576
|
+
function set_bullet(body: Opaque<"b2Body">, enable: boolean): void;
|
|
577
|
+
/**
|
|
578
|
+
* Set this body to have fixed rotation. This causes the mass to be reset.
|
|
579
|
+
*
|
|
580
|
+
* @param body - body
|
|
581
|
+
* @param enable - true if the rotation should be fixed
|
|
582
|
+
*/
|
|
583
|
+
function set_fixed_rotation(body: Opaque<"b2Body">, enable: boolean): void;
|
|
584
|
+
/**
|
|
585
|
+
* Set the gravity scale of the body.
|
|
586
|
+
*
|
|
587
|
+
* @param body - body
|
|
588
|
+
* @param scale - the scale
|
|
589
|
+
*/
|
|
590
|
+
function set_gravity_scale(body: Opaque<"b2Body">, scale: number): void;
|
|
591
|
+
/**
|
|
592
|
+
* Set the linear damping of the body.
|
|
593
|
+
*
|
|
594
|
+
* @param body - body
|
|
595
|
+
* @param damping - the damping
|
|
596
|
+
*/
|
|
597
|
+
function set_linear_damping(body: Opaque<"b2Body">, damping: number): void;
|
|
598
|
+
/**
|
|
599
|
+
* Set the linear velocity of the center of mass.
|
|
600
|
+
*
|
|
601
|
+
* @param body - body
|
|
602
|
+
* @param velocity - the new linear velocity of the center of mass.
|
|
603
|
+
*/
|
|
604
|
+
function set_linear_velocity(body: Opaque<"b2Body">, velocity: Vector3): void;
|
|
605
|
+
/**
|
|
606
|
+
* Set the mass properties to override the mass properties of the fixtures.
|
|
607
|
+
*
|
|
608
|
+
* @param body - body
|
|
609
|
+
* @param data - table with `mass`, `center` in local coordinates, and `inertia`.
|
|
610
|
+
*/
|
|
611
|
+
function set_mass_data(body: Opaque<"b2Body">, data: { mass?: number; center?: Vector3; inertia?: number }): void;
|
|
612
|
+
/**
|
|
613
|
+
* Set the mass properties to override the mass properties of the shapes.
|
|
614
|
+
*
|
|
615
|
+
* @param body - body
|
|
616
|
+
* @param data - the mass properties.
|
|
617
|
+
*/
|
|
618
|
+
function set_mass_data(body: Opaque<"b2Body">, data: Opaque<"b2MassData">): void;
|
|
619
|
+
/**
|
|
620
|
+
* Set the body name.
|
|
621
|
+
*
|
|
622
|
+
* @param body - body
|
|
623
|
+
* @param name - body name
|
|
624
|
+
*/
|
|
625
|
+
function set_name(body: Opaque<"b2Body">, name: string): void;
|
|
626
|
+
/**
|
|
627
|
+
* Set the sleep velocity threshold.
|
|
628
|
+
*
|
|
629
|
+
* @param body - body
|
|
630
|
+
* @param threshold - velocity threshold in Defold units per second
|
|
631
|
+
*/
|
|
632
|
+
function set_sleep_threshold(body: Opaque<"b2Body">, threshold: number): void;
|
|
633
|
+
/**
|
|
634
|
+
* You can disable sleeping on this body. If you disable sleeping, the body will be woken.
|
|
635
|
+
*
|
|
636
|
+
* @param body - body
|
|
637
|
+
* @param enable - if false, the body will never sleep, and consume more CPU
|
|
638
|
+
*/
|
|
639
|
+
function set_sleeping_allowed(body: Opaque<"b2Body">, enable: boolean): void;
|
|
640
|
+
/**
|
|
641
|
+
* Set velocity to reach a target transform.
|
|
642
|
+
*
|
|
643
|
+
* @param body - body
|
|
644
|
+
* @param position - target world position
|
|
645
|
+
* @param angle - target world angle in radians
|
|
646
|
+
* @param time_step - time step used to compute velocity
|
|
647
|
+
*/
|
|
648
|
+
function set_target_transform(body: Opaque<"b2Body">, position: Vector3, angle: number, time_step: number): void;
|
|
649
|
+
/**
|
|
650
|
+
* Set the position of the body's origin and rotation.
|
|
651
|
+
* This breaks any contacts and wakes the other bodies.
|
|
652
|
+
* Manipulating a body's transform may cause non-physical behavior.
|
|
653
|
+
*
|
|
654
|
+
* @param body - body
|
|
655
|
+
* @param position - the world position of the body's local origin.
|
|
656
|
+
* @param angle - the world position of the body's local origin.
|
|
657
|
+
*/
|
|
658
|
+
function set_transform(body: Opaque<"b2Body">, position: Vector3, angle: number): void;
|
|
659
|
+
/**
|
|
660
|
+
* Set the type of this body. This may alter the mass and velocity.
|
|
661
|
+
*
|
|
662
|
+
* @param body - body
|
|
663
|
+
* @param type - the body type
|
|
664
|
+
*/
|
|
665
|
+
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;
|
|
666
|
+
/**
|
|
667
|
+
* Set the user data. Use this to store your application specific data.
|
|
668
|
+
*
|
|
669
|
+
* @param body - body
|
|
670
|
+
* @param id - the game object id
|
|
671
|
+
*/
|
|
672
|
+
function set_user_data(body: Opaque<"b2Body">, id: Hash): void;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
export {};
|