@defold-typescript/types 0.19.4 → 0.20.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 +2755 -0
- package/api-migrations.json +31 -0
- package/api-signatures.json +2324 -0
- package/api-targets.json +493 -45
- package/generated/b2d.d.ts +6 -0
- package/generated/b2d_body.d.ts +329 -1
- package/generated/b2d_chain.d.ts +106 -0
- package/generated/b2d_fixture.d.ts +155 -0
- package/generated/b2d_joint.d.ts +823 -0
- package/generated/b2d_shape.d.ts +215 -0
- package/generated/b2d_world.d.ts +314 -0
- package/generated/builtin-messages.d.ts +18 -0
- package/generated/camera.d.ts +62 -5
- package/generated/compute.d.ts +306 -0
- package/generated/go.d.ts +29 -4
- package/generated/graphics.d.ts +95 -0
- package/generated/gui.d.ts +1 -3
- package/generated/json.d.ts +2 -2
- package/generated/kinds/gui-script.d.ts +7 -0
- package/generated/kinds/render-script.d.ts +7 -0
- package/generated/kinds/script.d.ts +7 -0
- package/generated/label.d.ts +1 -1
- package/generated/liveupdate.d.ts +22 -4
- package/generated/material.d.ts +444 -0
- package/generated/model.d.ts +46 -5
- package/generated/physics.d.ts +1 -3
- package/generated/profiler.d.ts +2 -3
- package/generated/render.d.ts +25 -9
- package/generated/resource.d.ts +2 -2
- package/generated/sprite.d.ts +15 -1
- package/generated/tilemap.d.ts +14 -0
- package/generated/versions/defold-1.12.4/b2d.d.ts +27 -0
- package/generated/versions/defold-1.12.4/b2d_body.d.ts +348 -0
- package/generated/versions/defold-1.12.4/buffer.d.ts +176 -0
- package/generated/versions/defold-1.12.4/camera.d.ts +245 -0
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +146 -0
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +71 -0
- package/generated/versions/defold-1.12.4/crash.d.ts +143 -0
- package/generated/versions/defold-1.12.4/factory.d.ts +123 -0
- package/generated/versions/defold-1.12.4/font.d.ts +81 -0
- package/generated/versions/defold-1.12.4/go.d.ts +1029 -0
- package/generated/versions/defold-1.12.4/graphics.d.ts +226 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +2372 -0
- package/generated/versions/defold-1.12.4/html5.d.ts +53 -0
- package/generated/versions/defold-1.12.4/http.d.ts +84 -0
- package/generated/versions/defold-1.12.4/iac.d.ts +18 -0
- package/generated/versions/defold-1.12.4/iap.d.ts +60 -0
- package/generated/versions/defold-1.12.4/image.d.ts +139 -0
- package/generated/versions/defold-1.12.4/index.d.ts +41 -0
- package/generated/versions/defold-1.12.4/json.d.ts +76 -0
- package/generated/versions/defold-1.12.4/label.d.ts +94 -0
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +122 -0
- package/generated/versions/defold-1.12.4/model.d.ts +205 -0
- package/generated/versions/defold-1.12.4/msg.d.ts +10 -0
- package/generated/versions/defold-1.12.4/particlefx.d.ts +166 -0
- package/generated/versions/defold-1.12.4/physics.d.ts +547 -0
- package/generated/versions/defold-1.12.4/profiler.d.ts +234 -0
- package/generated/versions/defold-1.12.4/push.d.ts +66 -0
- package/generated/versions/defold-1.12.4/render.d.ts +1149 -0
- package/generated/versions/defold-1.12.4/resource.d.ts +1518 -0
- package/generated/versions/defold-1.12.4/socket.d.ts +795 -0
- package/generated/versions/defold-1.12.4/sound.d.ts +291 -0
- package/generated/versions/defold-1.12.4/sprite.d.ts +143 -0
- package/generated/versions/defold-1.12.4/sys.d.ts +695 -0
- package/generated/versions/defold-1.12.4/tilemap.d.ts +181 -0
- package/generated/versions/defold-1.12.4/timer.d.ts +114 -0
- package/generated/versions/defold-1.12.4/types.d.ts +61 -0
- package/generated/versions/defold-1.12.4/vmath.d.ts +806 -0
- package/generated/versions/defold-1.12.4/webview.d.ts +68 -0
- package/generated/versions/defold-1.12.4/window.d.ts +198 -0
- package/generated/versions/defold-1.12.4/zlib.d.ts +40 -0
- package/index.d.ts +22 -0
- package/package.json +8 -1
- package/scripts/fidelity-audit.ts +69 -12
- package/scripts/fidelity-baseline.json +56 -0
- package/scripts/generate-api-availability.ts +139 -0
- package/scripts/generate-api-signatures.ts +66 -0
- package/scripts/import-defold-release.ts +480 -0
- package/scripts/regen.ts +53 -6
- package/scripts/sync-api-docs.ts +89 -41
- package/src/api-availability.ts +0 -0
- package/src/core-types.ts +9 -0
- package/src/emit-dts.ts +674 -17
- package/src/emit-messages.ts +72 -2
- package/src/index.ts +26 -1
- package/src/lifecycle.ts +43 -2
package/generated/b2d_body.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import type { Opaque, Vector3 } from "../src/core-types";
|
|
2
|
+
import type { Hash, Opaque, Vector3 } from "../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
5
|
/**
|
|
@@ -54,6 +54,13 @@ declare global {
|
|
|
54
54
|
* @param point - the world position of the point of application.
|
|
55
55
|
*/
|
|
56
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;
|
|
57
64
|
/**
|
|
58
65
|
* Apply a torque. This affects the angular velocity
|
|
59
66
|
* without affecting the linear velocity of the center of mass.
|
|
@@ -63,6 +70,137 @@ declare global {
|
|
|
63
70
|
* @param torque - torque about the z-axis (out of the screen), usually in N-m.
|
|
64
71
|
*/
|
|
65
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;
|
|
66
204
|
/**
|
|
67
205
|
* You can disable sleeping on this body. If you disable sleeping, the body will be woken.
|
|
68
206
|
*
|
|
@@ -91,6 +229,33 @@ declare global {
|
|
|
91
229
|
* @returns the angular velocity in radians/second.
|
|
92
230
|
*/
|
|
93
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;
|
|
94
259
|
/**
|
|
95
260
|
* Get the gravity scale of the body.
|
|
96
261
|
*
|
|
@@ -98,6 +263,20 @@ declare global {
|
|
|
98
263
|
* @returns the scale
|
|
99
264
|
*/
|
|
100
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[];
|
|
101
280
|
/**
|
|
102
281
|
* Get the linear damping of the body.
|
|
103
282
|
*
|
|
@@ -128,6 +307,13 @@ declare global {
|
|
|
128
307
|
* @returns the world velocity of a point.
|
|
129
308
|
*/
|
|
130
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;
|
|
131
317
|
/**
|
|
132
318
|
* Get the local position of the center of mass.
|
|
133
319
|
*
|
|
@@ -158,6 +344,34 @@ declare global {
|
|
|
158
344
|
* @returns the mass, usually in kilograms (kg).
|
|
159
345
|
*/
|
|
160
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">;
|
|
161
375
|
/**
|
|
162
376
|
* Get the world body origin position.
|
|
163
377
|
*
|
|
@@ -172,6 +386,34 @@ declare global {
|
|
|
172
386
|
* @returns the rotational inertia, usually in kg-m^2.
|
|
173
387
|
*/
|
|
174
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">;
|
|
175
417
|
/**
|
|
176
418
|
* Get the type of this body.
|
|
177
419
|
*
|
|
@@ -179,12 +421,33 @@ declare global {
|
|
|
179
421
|
* @returns the body type
|
|
180
422
|
*/
|
|
181
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;
|
|
182
431
|
/**
|
|
183
432
|
* Get the parent world of this body.
|
|
184
433
|
*
|
|
185
434
|
* @param body - body
|
|
186
435
|
*/
|
|
187
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;
|
|
188
451
|
/**
|
|
189
452
|
* Get the world position of the center of mass.
|
|
190
453
|
*
|
|
@@ -236,6 +499,13 @@ declare global {
|
|
|
236
499
|
* @returns is the rotation fixed
|
|
237
500
|
*/
|
|
238
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;
|
|
239
509
|
/**
|
|
240
510
|
* Is this body allowed to sleep
|
|
241
511
|
*
|
|
@@ -243,6 +513,13 @@ declare global {
|
|
|
243
513
|
* @returns true if the body is allowed to sleep
|
|
244
514
|
*/
|
|
245
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;
|
|
246
523
|
/**
|
|
247
524
|
* This resets the mass properties to the sum of the mass properties of the fixtures.
|
|
248
525
|
* This normally does not need to be called unless you called SetMassData to override
|
|
@@ -325,6 +602,50 @@ declare global {
|
|
|
325
602
|
* @param velocity - the new linear velocity of the center of mass.
|
|
326
603
|
*/
|
|
327
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;
|
|
328
649
|
/**
|
|
329
650
|
* Set the position of the body's origin and rotation.
|
|
330
651
|
* This breaks any contacts and wakes the other bodies.
|
|
@@ -342,6 +663,13 @@ declare global {
|
|
|
342
663
|
* @param type - the body type
|
|
343
664
|
*/
|
|
344
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;
|
|
345
673
|
}
|
|
346
674
|
}
|
|
347
675
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Opaque } from "../src/core-types";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions for Box2D v3 chains. A chain owns multiple connected segment
|
|
7
|
+
* shapes, so it is represented by a separate `b2Chain` handle.
|
|
8
|
+
*/
|
|
9
|
+
namespace b2d.chain {
|
|
10
|
+
type b2Chain = Opaque<"b2Chain">;
|
|
11
|
+
/**
|
|
12
|
+
* Destroying a chain removes all segment shapes owned by the chain. Destroying
|
|
13
|
+
* any segment shape through `b2d.body.destroy_shape` also destroys its parent chain.
|
|
14
|
+
*
|
|
15
|
+
* @param chain - chain
|
|
16
|
+
*/
|
|
17
|
+
function destroy(chain: Opaque<"b2Chain">): void;
|
|
18
|
+
/**
|
|
19
|
+
* Returns `nil` if the shape is not a chain segment.
|
|
20
|
+
*
|
|
21
|
+
* @param shape_id - shape handle from a shape info table, or pass `body, shape_index`
|
|
22
|
+
* @returns parent chain, or `nil` if the shape is not a chain segment
|
|
23
|
+
*/
|
|
24
|
+
function from_shape(shape_id: Opaque<"b2Shape">): Opaque<"b2Chain"> | unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Get chain friction.
|
|
27
|
+
*
|
|
28
|
+
* @param chain - chain
|
|
29
|
+
* @returns chain friction
|
|
30
|
+
*/
|
|
31
|
+
function get_friction(chain: Opaque<"b2Chain">): number;
|
|
32
|
+
/**
|
|
33
|
+
* Returns a chain geometry table with `loop`, `segment_count`, and `vertices`.
|
|
34
|
+
* Open chains also include `prev_vertex` and `next_vertex` ghost vertices.
|
|
35
|
+
*
|
|
36
|
+
* @param chain - chain
|
|
37
|
+
* @returns chain geometry table
|
|
38
|
+
*/
|
|
39
|
+
function get_geometry(chain: Opaque<"b2Chain">): Record<string | number, unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* Get chain material id.
|
|
42
|
+
*
|
|
43
|
+
* @param chain - chain
|
|
44
|
+
* @returns chain material id
|
|
45
|
+
*/
|
|
46
|
+
function get_material(chain: Opaque<"b2Chain">): number;
|
|
47
|
+
/**
|
|
48
|
+
* Get chain restitution.
|
|
49
|
+
*
|
|
50
|
+
* @param chain - chain
|
|
51
|
+
* @returns chain restitution
|
|
52
|
+
*/
|
|
53
|
+
function get_restitution(chain: Opaque<"b2Chain">): number;
|
|
54
|
+
/**
|
|
55
|
+
* Get the number of segment shapes in a chain.
|
|
56
|
+
*
|
|
57
|
+
* @param chain - chain
|
|
58
|
+
* @returns segment count
|
|
59
|
+
*/
|
|
60
|
+
function get_segment_count(chain: Opaque<"b2Chain">): number;
|
|
61
|
+
/**
|
|
62
|
+
* Get the segment shapes owned by a chain.
|
|
63
|
+
*
|
|
64
|
+
* @param chain - chain
|
|
65
|
+
* @returns array of shape info tables for the chain segments. Each entry includes `shape_id`.
|
|
66
|
+
*/
|
|
67
|
+
function get_segments(chain: Opaque<"b2Chain">): { shape_id: number }[];
|
|
68
|
+
/**
|
|
69
|
+
* Get the world owning a chain.
|
|
70
|
+
*
|
|
71
|
+
* @param chain - chain
|
|
72
|
+
* @returns owning world
|
|
73
|
+
*/
|
|
74
|
+
function get_world(chain: Opaque<"b2Chain">): Opaque<"b2World">;
|
|
75
|
+
/**
|
|
76
|
+
* Validate a chain handle.
|
|
77
|
+
*
|
|
78
|
+
* @param chain - chain
|
|
79
|
+
* @returns true if the chain handle still refers to a live Box2D chain
|
|
80
|
+
*/
|
|
81
|
+
function is_valid(chain: Opaque<"b2Chain">): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Set chain friction.
|
|
84
|
+
*
|
|
85
|
+
* @param chain - chain
|
|
86
|
+
* @param friction - chain friction
|
|
87
|
+
*/
|
|
88
|
+
function set_friction(chain: Opaque<"b2Chain">, friction: number): void;
|
|
89
|
+
/**
|
|
90
|
+
* Set chain material id.
|
|
91
|
+
*
|
|
92
|
+
* @param chain - chain
|
|
93
|
+
* @param material - chain material id
|
|
94
|
+
*/
|
|
95
|
+
function set_material(chain: Opaque<"b2Chain">, material: number): void;
|
|
96
|
+
/**
|
|
97
|
+
* Set chain restitution.
|
|
98
|
+
*
|
|
99
|
+
* @param chain - chain
|
|
100
|
+
* @param restitution - chain restitution
|
|
101
|
+
*/
|
|
102
|
+
function set_restitution(chain: Opaque<"b2Chain">, restitution: number): void;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Opaque, Vector3 } from "../src/core-types";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions for interacting with fixtures attached to Box2D bodies.
|
|
7
|
+
* Fixtures are addressed functionally by `(body, fixture_index)` rather than persistent Lua handles.
|
|
8
|
+
*/
|
|
9
|
+
namespace b2d.fixture {
|
|
10
|
+
/**
|
|
11
|
+
* Get fixture AABB for a child shape.
|
|
12
|
+
*
|
|
13
|
+
* @param body - body
|
|
14
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
15
|
+
* @param child_index - 1-based child shape index
|
|
16
|
+
* @returns table with `lower` and `upper`
|
|
17
|
+
*/
|
|
18
|
+
function get_aabb(body: Opaque<"b2Body">, fixture_index: number, child_index: number): { lower: Vector3; upper: Vector3 };
|
|
19
|
+
/**
|
|
20
|
+
* Get fixture density.
|
|
21
|
+
*
|
|
22
|
+
* @param body - body
|
|
23
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
24
|
+
* @returns density in kg/m^2
|
|
25
|
+
*/
|
|
26
|
+
function get_density(body: Opaque<"b2Body">, fixture_index: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Get fixture filter data for a child shape.
|
|
29
|
+
*
|
|
30
|
+
* @param body - body
|
|
31
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
32
|
+
* @param child_index - 1-based child shape index
|
|
33
|
+
* @returns table with `category_bits`, `mask_bits`, and `group_index`
|
|
34
|
+
*/
|
|
35
|
+
function get_filter_data(body: Opaque<"b2Body">, fixture_index: number, child_index: number): { category_bits: number; mask_bits: number; group_index: number };
|
|
36
|
+
/**
|
|
37
|
+
* Get fixture friction.
|
|
38
|
+
*
|
|
39
|
+
* @param body - body
|
|
40
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
41
|
+
*/
|
|
42
|
+
function get_friction(body: Opaque<"b2Body">, fixture_index: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Get fixture restitution.
|
|
45
|
+
*
|
|
46
|
+
* @param body - body
|
|
47
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
48
|
+
*/
|
|
49
|
+
function get_restitution(body: Opaque<"b2Body">, fixture_index: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Get the fixture shape as a functional shape table.
|
|
52
|
+
*
|
|
53
|
+
* @param body - body
|
|
54
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
55
|
+
* @returns shape table with numeric `type` from `b2d.shape.SHAPE_TYPE_*`,
|
|
56
|
+
* suitable for reuse in `b2d.body.create_fixture`.
|
|
57
|
+
* Circle shapes use `radius` and `center`, edge shapes use `v1`, `v2`, optional `v0`, `v3`,
|
|
58
|
+
* polygon shapes use `vertices`, and chain shapes use `vertices`, `loop`, optional `prev_vertex`, and `next_vertex`.
|
|
59
|
+
* Any angle values are in radians.
|
|
60
|
+
*/
|
|
61
|
+
function get_shape(body: Opaque<"b2Body">, fixture_index: number): { 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 };
|
|
62
|
+
/**
|
|
63
|
+
* Get the fixture type.
|
|
64
|
+
*
|
|
65
|
+
* @param body - body
|
|
66
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
67
|
+
*/
|
|
68
|
+
function get_type(body: Opaque<"b2Body">, fixture_index: number): number;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a fixture is a sensor.
|
|
71
|
+
*
|
|
72
|
+
* @param body - body
|
|
73
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
74
|
+
*/
|
|
75
|
+
function is_sensor(body: Opaque<"b2Body">, fixture_index: number): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Refilter a fixture.
|
|
78
|
+
*
|
|
79
|
+
* @param body - body
|
|
80
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
81
|
+
* @param touch_proxies - if true, touch broad-phase proxies
|
|
82
|
+
*/
|
|
83
|
+
function refilter(body: Opaque<"b2Body">, fixture_index: number, touch_proxies: boolean): void;
|
|
84
|
+
/**
|
|
85
|
+
* Set fixture density.
|
|
86
|
+
*
|
|
87
|
+
* @param body - body
|
|
88
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
89
|
+
* @param density - density in kg/m^2
|
|
90
|
+
* @param update_mass - if true, reset body mass data after the change
|
|
91
|
+
*/
|
|
92
|
+
function set_density(body: Opaque<"b2Body">, fixture_index: number, density: number, update_mass: boolean): void;
|
|
93
|
+
/**
|
|
94
|
+
* Set fixture filter data for a child shape.
|
|
95
|
+
*
|
|
96
|
+
* @param body - body
|
|
97
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
98
|
+
* @param child_index - 1-based child shape index
|
|
99
|
+
* @param filter - table with `category_bits`, `mask_bits`, and `group_index`
|
|
100
|
+
*/
|
|
101
|
+
function set_filter_data(body: Opaque<"b2Body">, fixture_index: number, child_index: number, filter: { category_bits?: number; mask_bits?: number; group_index?: number }): void;
|
|
102
|
+
/**
|
|
103
|
+
* Set fixture friction.
|
|
104
|
+
*
|
|
105
|
+
* @param body - body
|
|
106
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
107
|
+
*/
|
|
108
|
+
function set_friction(body: Opaque<"b2Body">, fixture_index: number, friction: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Set fixture restitution.
|
|
111
|
+
*
|
|
112
|
+
* @param body - body
|
|
113
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
114
|
+
*/
|
|
115
|
+
function set_restitution(body: Opaque<"b2Body">, fixture_index: number, restitution: number): void;
|
|
116
|
+
/**
|
|
117
|
+
* Set sensor mode for a fixture.
|
|
118
|
+
*
|
|
119
|
+
* @param body - body
|
|
120
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
121
|
+
*/
|
|
122
|
+
function set_sensor(body: Opaque<"b2Body">, fixture_index: number, enabled: boolean): void;
|
|
123
|
+
/**
|
|
124
|
+
* This updates the existing Box2D v2 shape using the same table format as
|
|
125
|
+
* `b2d.body.create_fixture` and `b2d.fixture.get_shape`.
|
|
126
|
+
* The shape type must match the current fixture shape type. Polygon updates must
|
|
127
|
+
* keep the same vertex count. Chain shape geometry cannot be updated in-place.
|
|
128
|
+
* The body mass is not updated unless `update_mass` is true.
|
|
129
|
+
*
|
|
130
|
+
* @param body - body
|
|
131
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
132
|
+
* @param shape - shape table with numeric `type` from `b2d.shape.SHAPE_TYPE_*`
|
|
133
|
+
* @param update_mass - if true, reset body mass data after the change
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const body = b2d.get_body("#collisionobject");
|
|
137
|
+
* const circle = b2d.fixture.get_shape(body, 1);
|
|
138
|
+
* circle.center = vmath.vector3(24, 0, 0);
|
|
139
|
+
* b2d.fixture.set_shape(body, 1, circle, true);
|
|
140
|
+
* b2d.fixture.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_EDGE, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
function set_shape(body: Opaque<"b2Body">, fixture_index: number, 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 }, update_mass: boolean): void;
|
|
144
|
+
/**
|
|
145
|
+
* Test a point against a fixture.
|
|
146
|
+
*
|
|
147
|
+
* @param body - body
|
|
148
|
+
* @param fixture_index - 1-based fixture index from `b2d.body.get_fixtures`
|
|
149
|
+
* @param point - point in world coordinates
|
|
150
|
+
*/
|
|
151
|
+
function test_point(body: Opaque<"b2Body">, fixture_index: number, point: Vector3): boolean;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export {};
|