@defold-typescript/types 0.49.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-availability.json +696 -624
- package/api-signatures.json +6799 -160
- package/api-targets.json +393 -2
- package/examples/translations.json +12 -0
- package/generated/b2d.d.ts +15 -0
- package/generated/bullet3d.d.ts +16 -0
- package/generated/font.d.ts +7 -3
- package/generated/graphics.d.ts +7 -0
- package/generated/gui.d.ts +5 -4
- package/generated/label.d.ts +3 -3
- package/generated/render.d.ts +16 -1
- package/generated/versions/defold-1.13.2/b2d.d.ts +709 -0
- package/generated/versions/defold-1.13.2/b2d_body.d.ts +593 -0
- package/generated/versions/defold-1.13.2/b2d_chain.d.ts +105 -0
- package/generated/versions/defold-1.13.2/b2d_fixture.d.ts +175 -0
- package/generated/versions/defold-1.13.2/b2d_joint.d.ts +1301 -0
- package/generated/versions/defold-1.13.2/b2d_shape.d.ts +423 -0
- package/generated/versions/defold-1.13.2/b2d_world.d.ts +308 -0
- package/generated/versions/defold-1.13.2/buffer.d.ts +192 -0
- package/generated/versions/defold-1.13.2/bullet3d.d.ts +91 -0
- package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +433 -0
- package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +818 -0
- package/generated/versions/defold-1.13.2/bullet3d_rigid_body.d.ts +429 -0
- package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +123 -0
- package/generated/versions/defold-1.13.2/bullet3d_world.d.ts +492 -0
- package/generated/versions/defold-1.13.2/camera.d.ts +300 -0
- package/generated/versions/defold-1.13.2/collectionfactory.d.ts +148 -0
- package/generated/versions/defold-1.13.2/collectionproxy.d.ts +109 -0
- package/generated/versions/defold-1.13.2/compute.d.ts +107 -0
- package/generated/versions/defold-1.13.2/crash.d.ts +157 -0
- package/generated/versions/defold-1.13.2/editor-vm/http.d.ts +139 -0
- package/generated/versions/defold-1.13.2/editor-vm/image.d.ts +48 -0
- package/generated/versions/defold-1.13.2/editor-vm/json.d.ts +21 -0
- package/generated/versions/defold-1.13.2/editor-vm/localization.d.ts +42 -0
- package/generated/versions/defold-1.13.2/editor-vm/tilemap_tiles.d.ts +126 -0
- package/generated/versions/defold-1.13.2/editor-vm/zip.d.ts +38 -0
- package/generated/versions/defold-1.13.2/editor-vm/zlib.d.ts +24 -0
- package/generated/versions/defold-1.13.2/editor.d.ts +2177 -0
- package/generated/versions/defold-1.13.2/factory.d.ts +121 -0
- package/generated/versions/defold-1.13.2/font.d.ts +123 -0
- package/generated/versions/defold-1.13.2/go.d.ts +1166 -0
- package/generated/versions/defold-1.13.2/graphics.d.ts +613 -0
- package/generated/versions/defold-1.13.2/gui.d.ts +2212 -0
- package/generated/versions/defold-1.13.2/html5.d.ts +55 -0
- package/generated/versions/defold-1.13.2/http.d.ts +83 -0
- package/generated/versions/defold-1.13.2/image.d.ts +181 -0
- package/generated/versions/defold-1.13.2/index.d.ts +63 -0
- package/generated/versions/defold-1.13.2/json.d.ts +94 -0
- package/generated/versions/defold-1.13.2/kinds/editor-script.d.ts +14 -0
- package/generated/versions/defold-1.13.2/label.d.ts +164 -0
- package/generated/versions/defold-1.13.2/liveupdate.d.ts +143 -0
- package/generated/versions/defold-1.13.2/material.d.ts +490 -0
- package/generated/versions/defold-1.13.2/model.d.ts +287 -0
- package/generated/versions/defold-1.13.2/msg.d.ts +10 -0
- package/generated/versions/defold-1.13.2/particlefx.d.ts +155 -0
- package/generated/versions/defold-1.13.2/physics.d.ts +789 -0
- package/generated/versions/defold-1.13.2/profiler.d.ts +228 -0
- package/generated/versions/defold-1.13.2/render.d.ts +1153 -0
- package/generated/versions/defold-1.13.2/resource.d.ts +1628 -0
- package/generated/versions/defold-1.13.2/socket.d.ts +797 -0
- package/generated/versions/defold-1.13.2/sound.d.ts +323 -0
- package/generated/versions/defold-1.13.2/sprite.d.ts +179 -0
- package/generated/versions/defold-1.13.2/sys.d.ts +754 -0
- package/generated/versions/defold-1.13.2/tilemap.d.ts +206 -0
- package/generated/versions/defold-1.13.2/timer.d.ts +136 -0
- package/generated/versions/defold-1.13.2/types.d.ts +61 -0
- package/generated/versions/defold-1.13.2/vmath.d.ts +775 -0
- package/generated/versions/defold-1.13.2/window.d.ts +196 -0
- package/generated/versions/defold-1.13.2/zlib.d.ts +41 -0
- package/identity-vocabulary.json +1 -0
- package/package.json +2 -2
- package/scripts/import-defold-release.ts +3 -31
- package/scripts/materialize-version.ts +13 -7
- package/scripts/regen.ts +63 -29
- package/scripts/sync-api-docs.ts +31 -2
- package/src/emit-dts.ts +25 -3
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Opaque, Vector3 } from "../../../src/core-types";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Rigid body functions accept the collision object userdata returned by
|
|
7
|
+
* `bullet3d.get_rigid_body()`. Passing a trigger ghost object raises an error.
|
|
8
|
+
* Defold retains ownership of the collision shape, motion state, world
|
|
9
|
+
* membership, and native user pointer. The shape's logical children can be
|
|
10
|
+
* mutated through `bullet3d.shape`; shared resource shapes become per-instance
|
|
11
|
+
* copies on first mutation. Mass and local inertia can be changed for dynamic
|
|
12
|
+
* bodies without changing their Defold collision-object type.
|
|
13
|
+
*
|
|
14
|
+
* Linear quantities use Defold units. Angular velocity, damping, and factors
|
|
15
|
+
* are unscaled. Torque and angular impulse use squared physics scale because
|
|
16
|
+
* inertia scales with length squared. Floating-point and vector inputs must be
|
|
17
|
+
* finite. Damping must be in `[0, 1]`, and sleeping thresholds must be
|
|
18
|
+
* non-negative.
|
|
19
|
+
*/
|
|
20
|
+
namespace bullet3d.rigid_body {
|
|
21
|
+
type FLAG = typeof bullet3d.rigid_body.BT_DISABLE_WORLD_GRAVITY | typeof bullet3d.rigid_body.BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT | typeof bullet3d.rigid_body.BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_WORLD | typeof bullet3d.rigid_body.BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY;
|
|
22
|
+
/**
|
|
23
|
+
* Disable automatic world gravity. Set this bit before assigning custom body gravity that must survive later world-gravity changes or re-adding the body to a world.
|
|
24
|
+
*/
|
|
25
|
+
const BT_DISABLE_WORLD_GRAVITY: number & { readonly __brand: "bullet3d.rigid_body.BT_DISABLE_WORLD_GRAVITY" };
|
|
26
|
+
/**
|
|
27
|
+
* Enable explicit gyroscopic force integration.
|
|
28
|
+
*/
|
|
29
|
+
const BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT: number & { readonly __brand: "bullet3d.rigid_body.BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT" };
|
|
30
|
+
/**
|
|
31
|
+
* Enable implicit body-space gyroscopic force integration. This flag is enabled by default for newly constructed rigid bodies.
|
|
32
|
+
*/
|
|
33
|
+
const BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY: number & { readonly __brand: "bullet3d.rigid_body.BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY" };
|
|
34
|
+
/**
|
|
35
|
+
* Enable implicit world-space gyroscopic force integration.
|
|
36
|
+
*/
|
|
37
|
+
const BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_WORLD: number & { readonly __brand: "bullet3d.rigid_body.BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_WORLD" };
|
|
38
|
+
/**
|
|
39
|
+
* Apply a force at the center of mass
|
|
40
|
+
*
|
|
41
|
+
* @param body - rigid body
|
|
42
|
+
* @param force - force in Defold units
|
|
43
|
+
*/
|
|
44
|
+
function apply_central_force(body: Opaque<"btRigidBody">, force: Vector3): void;
|
|
45
|
+
/**
|
|
46
|
+
* Apply an impulse at the center of mass
|
|
47
|
+
*
|
|
48
|
+
* @param body - rigid body
|
|
49
|
+
* @param impulse - impulse in Defold units
|
|
50
|
+
*/
|
|
51
|
+
function apply_central_impulse(body: Opaque<"btRigidBody">, impulse: Vector3): void;
|
|
52
|
+
/**
|
|
53
|
+
* This has the same point semantics as `b2d.body.apply_force`: `world_position`
|
|
54
|
+
* is the point where the force is applied. The binding converts it to the
|
|
55
|
+
* center-of-mass-relative offset expected by Bullet's `applyForce` method.
|
|
56
|
+
*
|
|
57
|
+
* @param body - rigid body
|
|
58
|
+
* @param force - force in Defold units
|
|
59
|
+
* @param world_position - application point in world space and Defold units
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* // Apply an upward force at the game object's current world position:
|
|
63
|
+
* export default defineScript({
|
|
64
|
+
* init() {
|
|
65
|
+
* const body = bullet3d.get_rigid_body("#collisionobject");
|
|
66
|
+
* if (body === undefined) return;
|
|
67
|
+
* const force = vmath.vector3(0, 100, 0);
|
|
68
|
+
* bullet3d.rigid_body.apply_force(body, force, go.get_world_position());
|
|
69
|
+
* },
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function apply_force(body: Opaque<"btRigidBody">, force: Vector3, world_position: Vector3): void;
|
|
74
|
+
/**
|
|
75
|
+
* This exposes Bullet's `btRigidBody::applyForce` point convention directly.
|
|
76
|
+
* `relative_position` is an offset from the body's center of mass expressed in
|
|
77
|
+
* world axes, not a world position or body-local coordinate.
|
|
78
|
+
*
|
|
79
|
+
* @param body - rigid body
|
|
80
|
+
* @param force - force in Defold units
|
|
81
|
+
* @param relative_position - center-of-mass-relative offset in world axes and Defold units
|
|
82
|
+
*/
|
|
83
|
+
function apply_force_at_relative_position(body: Opaque<"btRigidBody">, force: Vector3, relative_position: Vector3): void;
|
|
84
|
+
/**
|
|
85
|
+
* This exposes Bullet's `btRigidBody::applyImpulse` point convention directly.
|
|
86
|
+
* `relative_position` is an offset from the body's center of mass expressed in
|
|
87
|
+
* world axes, not a world position or body-local coordinate.
|
|
88
|
+
*
|
|
89
|
+
* @param body - rigid body
|
|
90
|
+
* @param impulse - impulse in Defold units
|
|
91
|
+
* @param relative_position - center-of-mass-relative offset in world axes and Defold units
|
|
92
|
+
*/
|
|
93
|
+
function apply_impulse(body: Opaque<"btRigidBody">, impulse: Vector3, relative_position: Vector3): void;
|
|
94
|
+
/**
|
|
95
|
+
* This has the same point semantics as `b2d.body.apply_linear_impulse`.
|
|
96
|
+
* `world_position` is converted to the center-of-mass-relative offset expected
|
|
97
|
+
* by Bullet's `applyImpulse` method.
|
|
98
|
+
*
|
|
99
|
+
* @param body - rigid body
|
|
100
|
+
* @param impulse - impulse in Defold units
|
|
101
|
+
* @param world_position - application point in world space and Defold units
|
|
102
|
+
*/
|
|
103
|
+
function apply_linear_impulse(body: Opaque<"btRigidBody">, impulse: Vector3, world_position: Vector3): void;
|
|
104
|
+
/**
|
|
105
|
+
* Apply torque
|
|
106
|
+
*
|
|
107
|
+
* @param body - rigid body
|
|
108
|
+
* @param torque - torque in Defold squared units
|
|
109
|
+
*/
|
|
110
|
+
function apply_torque(body: Opaque<"btRigidBody">, torque: Vector3): void;
|
|
111
|
+
/**
|
|
112
|
+
* Apply a torque impulse
|
|
113
|
+
*
|
|
114
|
+
* @param body - rigid body
|
|
115
|
+
* @param impulse - angular impulse in Defold squared units
|
|
116
|
+
*/
|
|
117
|
+
function apply_torque_impulse(body: Opaque<"btRigidBody">, impulse: Vector3): void;
|
|
118
|
+
/**
|
|
119
|
+
* Clear accumulated force and torque
|
|
120
|
+
*
|
|
121
|
+
* @param body - rigid body
|
|
122
|
+
*/
|
|
123
|
+
function clear_forces(body: Opaque<"btRigidBody">): void;
|
|
124
|
+
/**
|
|
125
|
+
* Calls Bullet's native `btRigidBody::getAabb`, which immediately calculates
|
|
126
|
+
* the bounds from the body's current collision shape and world transform. This
|
|
127
|
+
* does not read the broadphase proxy's cached AABB.
|
|
128
|
+
*
|
|
129
|
+
* @param body - rigid body
|
|
130
|
+
* @returns world-space bounds in Defold units
|
|
131
|
+
*/
|
|
132
|
+
function compute_aabb(body: Opaque<"btRigidBody">): bullet3d.world.aabb;
|
|
133
|
+
/**
|
|
134
|
+
* Get angular damping
|
|
135
|
+
*
|
|
136
|
+
* @param body - rigid body
|
|
137
|
+
* @returns angular damping
|
|
138
|
+
*/
|
|
139
|
+
function get_angular_damping(body: Opaque<"btRigidBody">): number;
|
|
140
|
+
/**
|
|
141
|
+
* Get the angular factor
|
|
142
|
+
*
|
|
143
|
+
* @param body - rigid body
|
|
144
|
+
* @returns per-axis angular factor
|
|
145
|
+
*/
|
|
146
|
+
function get_angular_factor(body: Opaque<"btRigidBody">): Vector3;
|
|
147
|
+
/**
|
|
148
|
+
* Get the angular sleeping threshold
|
|
149
|
+
*
|
|
150
|
+
* @param body - rigid body
|
|
151
|
+
* @returns threshold in radians per second
|
|
152
|
+
*/
|
|
153
|
+
function get_angular_sleeping_threshold(body: Opaque<"btRigidBody">): number;
|
|
154
|
+
/**
|
|
155
|
+
* Get angular velocity
|
|
156
|
+
*
|
|
157
|
+
* @param body - rigid body
|
|
158
|
+
* @returns angular velocity in radians per second
|
|
159
|
+
*/
|
|
160
|
+
function get_angular_velocity(body: Opaque<"btRigidBody">): Vector3;
|
|
161
|
+
/**
|
|
162
|
+
* Get the center-of-mass world position
|
|
163
|
+
*
|
|
164
|
+
* @param body - rigid body
|
|
165
|
+
* @returns center-of-mass position in Defold units
|
|
166
|
+
*/
|
|
167
|
+
function get_center_of_mass_position(body: Opaque<"btRigidBody">): Vector3;
|
|
168
|
+
/**
|
|
169
|
+
* Get linear and angular damping
|
|
170
|
+
*
|
|
171
|
+
* @param body - rigid body
|
|
172
|
+
*/
|
|
173
|
+
function get_damping(body: Opaque<"btRigidBody">): LuaMultiReturn<[number, number]>;
|
|
174
|
+
/**
|
|
175
|
+
* Get rigid body flags
|
|
176
|
+
*
|
|
177
|
+
* @param body - rigid body
|
|
178
|
+
* @returns rigid body flags
|
|
179
|
+
*/
|
|
180
|
+
function get_flags(body: Opaque<"btRigidBody">): number;
|
|
181
|
+
/**
|
|
182
|
+
* Get body gravity
|
|
183
|
+
*
|
|
184
|
+
* @param body - rigid body
|
|
185
|
+
* @returns gravity in Defold units per second squared
|
|
186
|
+
*/
|
|
187
|
+
function get_gravity(body: Opaque<"btRigidBody">): Vector3;
|
|
188
|
+
/**
|
|
189
|
+
* Get inverse mass
|
|
190
|
+
*
|
|
191
|
+
* @param body - rigid body
|
|
192
|
+
* @returns inverse mass
|
|
193
|
+
*/
|
|
194
|
+
function get_inverse_mass(body: Opaque<"btRigidBody">): number;
|
|
195
|
+
/**
|
|
196
|
+
* Get linear damping
|
|
197
|
+
*
|
|
198
|
+
* @param body - rigid body
|
|
199
|
+
* @returns linear damping
|
|
200
|
+
*/
|
|
201
|
+
function get_linear_damping(body: Opaque<"btRigidBody">): number;
|
|
202
|
+
/**
|
|
203
|
+
* Get the linear factor
|
|
204
|
+
*
|
|
205
|
+
* @param body - rigid body
|
|
206
|
+
* @returns per-axis linear factor
|
|
207
|
+
*/
|
|
208
|
+
function get_linear_factor(body: Opaque<"btRigidBody">): Vector3;
|
|
209
|
+
/**
|
|
210
|
+
* Get the linear sleeping threshold
|
|
211
|
+
*
|
|
212
|
+
* @param body - rigid body
|
|
213
|
+
* @returns threshold in Defold units per second
|
|
214
|
+
*/
|
|
215
|
+
function get_linear_sleeping_threshold(body: Opaque<"btRigidBody">): number;
|
|
216
|
+
/**
|
|
217
|
+
* Get linear velocity
|
|
218
|
+
*
|
|
219
|
+
* @param body - rigid body
|
|
220
|
+
* @returns velocity in Defold units per second
|
|
221
|
+
*/
|
|
222
|
+
function get_linear_velocity(body: Opaque<"btRigidBody">): Vector3;
|
|
223
|
+
/**
|
|
224
|
+
* This has the same point semantics as
|
|
225
|
+
* `b2d.body.get_linear_velocity_from_local_point`. The local origin is the
|
|
226
|
+
* body's center of mass.
|
|
227
|
+
*
|
|
228
|
+
* @param body - rigid body
|
|
229
|
+
* @param local_point - point in body-local space and Defold units
|
|
230
|
+
* @returns point velocity in Defold units per second
|
|
231
|
+
*/
|
|
232
|
+
function get_linear_velocity_from_local_point(body: Opaque<"btRigidBody">, local_point: Vector3): Vector3;
|
|
233
|
+
/**
|
|
234
|
+
* This has the same point semantics as
|
|
235
|
+
* `b2d.body.get_linear_velocity_from_world_point`.
|
|
236
|
+
*
|
|
237
|
+
* @param body - rigid body
|
|
238
|
+
* @param world_point - point in world space and Defold units
|
|
239
|
+
* @returns point velocity in Defold units per second
|
|
240
|
+
*/
|
|
241
|
+
function get_linear_velocity_from_world_point(body: Opaque<"btRigidBody">, world_point: Vector3): Vector3;
|
|
242
|
+
/**
|
|
243
|
+
* Returns the diagonal local inertia in Defold mass-times-distance-squared
|
|
244
|
+
* units. A zero component denotes an axis with zero inverse inertia.
|
|
245
|
+
*
|
|
246
|
+
* @param body - rigid body
|
|
247
|
+
* @returns diagonal local inertia
|
|
248
|
+
*/
|
|
249
|
+
function get_local_inertia(body: Opaque<"btRigidBody">): Vector3;
|
|
250
|
+
/**
|
|
251
|
+
* Get mass
|
|
252
|
+
*
|
|
253
|
+
* @param body - rigid body
|
|
254
|
+
* @returns mass, or zero for an infinite-mass body
|
|
255
|
+
*/
|
|
256
|
+
function get_mass(body: Opaque<"btRigidBody">): number;
|
|
257
|
+
/**
|
|
258
|
+
* Get total accumulated force
|
|
259
|
+
*
|
|
260
|
+
* @param body - rigid body
|
|
261
|
+
* @returns accumulated force in Defold units
|
|
262
|
+
*/
|
|
263
|
+
function get_total_force(body: Opaque<"btRigidBody">): Vector3;
|
|
264
|
+
/**
|
|
265
|
+
* Get total accumulated torque
|
|
266
|
+
*
|
|
267
|
+
* @param body - rigid body
|
|
268
|
+
* @returns accumulated torque in Defold squared units
|
|
269
|
+
*/
|
|
270
|
+
function get_total_torque(body: Opaque<"btRigidBody">): Vector3;
|
|
271
|
+
/**
|
|
272
|
+
* The relative position is expressed in world axes. Despite Bullet's function
|
|
273
|
+
* name, it is not a body-local coordinate.
|
|
274
|
+
*
|
|
275
|
+
* @param body - rigid body
|
|
276
|
+
* @param relative_position - center-of-mass-relative offset in world axes and Defold units
|
|
277
|
+
* @returns point velocity in Defold units per second
|
|
278
|
+
*/
|
|
279
|
+
function get_velocity_in_local_point(body: Opaque<"btRigidBody">, relative_position: Vector3): Vector3;
|
|
280
|
+
/**
|
|
281
|
+
* Get the body's world
|
|
282
|
+
*
|
|
283
|
+
* @param body - rigid body
|
|
284
|
+
* @returns owning world
|
|
285
|
+
*/
|
|
286
|
+
function get_world(body: Opaque<"btRigidBody">): bullet3d.btDiscreteDynamicsWorld;
|
|
287
|
+
/**
|
|
288
|
+
* Test a rigid body flag
|
|
289
|
+
*
|
|
290
|
+
* @param body - rigid body
|
|
291
|
+
* @param flag - flag or mask
|
|
292
|
+
* @returns `true` when all requested flag bits are set
|
|
293
|
+
*/
|
|
294
|
+
function has_flag(body: Opaque<"btRigidBody">, flag: number): boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Test whether a handle refers to a valid rigid body
|
|
297
|
+
*
|
|
298
|
+
* @param body - rigid body
|
|
299
|
+
* @returns rigid body validity
|
|
300
|
+
*/
|
|
301
|
+
function is_valid(body: Opaque<"btRigidBody">): boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Set angular damping
|
|
304
|
+
*
|
|
305
|
+
* @param body - rigid body
|
|
306
|
+
* @param damping - finite angular damping in `[0, 1]`
|
|
307
|
+
*/
|
|
308
|
+
function set_angular_damping(body: Opaque<"btRigidBody">, damping: number): void;
|
|
309
|
+
/**
|
|
310
|
+
* Set the angular factor
|
|
311
|
+
*
|
|
312
|
+
* @param body - rigid body
|
|
313
|
+
* @param factor - per-axis angular factor
|
|
314
|
+
*/
|
|
315
|
+
function set_angular_factor(body: Opaque<"btRigidBody">, factor: Vector3): void;
|
|
316
|
+
/**
|
|
317
|
+
* Set angular velocity
|
|
318
|
+
*
|
|
319
|
+
* @param body - rigid body
|
|
320
|
+
* @param velocity - finite angular velocity in radians per second
|
|
321
|
+
*/
|
|
322
|
+
function set_angular_velocity(body: Opaque<"btRigidBody">, velocity: Vector3): void;
|
|
323
|
+
/**
|
|
324
|
+
* Set linear and angular damping
|
|
325
|
+
*
|
|
326
|
+
* @param body - rigid body
|
|
327
|
+
* @param linear - finite linear damping in `[0, 1]`
|
|
328
|
+
* @param angular - finite angular damping in `[0, 1]`
|
|
329
|
+
*/
|
|
330
|
+
function set_damping(body: Opaque<"btRigidBody">, linear: number, angular: number): void;
|
|
331
|
+
/**
|
|
332
|
+
* This replaces the complete flag mask. Every enabled gyroscopic mode is
|
|
333
|
+
* evaluated independently, so clear existing gyroscopic mode bits before
|
|
334
|
+
* selecting a different mode.
|
|
335
|
+
*
|
|
336
|
+
* @param body - rigid body
|
|
337
|
+
* @param flags - rigid body flags
|
|
338
|
+
*/
|
|
339
|
+
function set_flags(body: Opaque<"btRigidBody">, flags: number): void;
|
|
340
|
+
/**
|
|
341
|
+
* A later `bullet3d.world.set_gravity()` call, or removing and re-adding the
|
|
342
|
+
* body to a world, can overwrite custom body gravity unless the body's
|
|
343
|
+
* `BT_DISABLE_WORLD_GRAVITY` flag is set.
|
|
344
|
+
*
|
|
345
|
+
* @param body - rigid body
|
|
346
|
+
* @param gravity - gravity in Defold units per second squared
|
|
347
|
+
* @example
|
|
348
|
+
* ```ts
|
|
349
|
+
* // Give one body persistent custom gravity without discarding its other flags:
|
|
350
|
+
* export default defineScript({
|
|
351
|
+
* init() {
|
|
352
|
+
* const body = bullet3d.get_rigid_body("#collisionobject");
|
|
353
|
+
* if (body === undefined) return;
|
|
354
|
+
* let flags = bullet3d.rigid_body.get_flags(body);
|
|
355
|
+
* flags = bit.bor(flags, bullet3d.rigid_body.BT_DISABLE_WORLD_GRAVITY);
|
|
356
|
+
* bullet3d.rigid_body.set_flags(body, flags);
|
|
357
|
+
* bullet3d.rigid_body.set_gravity(body, vmath.vector3(0, 4, 0));
|
|
358
|
+
* },
|
|
359
|
+
* });
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
function set_gravity(body: Opaque<"btRigidBody">, gravity: Vector3): void;
|
|
363
|
+
/**
|
|
364
|
+
* Set linear damping
|
|
365
|
+
*
|
|
366
|
+
* @param body - rigid body
|
|
367
|
+
* @param damping - finite linear damping in `[0, 1]`
|
|
368
|
+
*/
|
|
369
|
+
function set_linear_damping(body: Opaque<"btRigidBody">, damping: number): void;
|
|
370
|
+
/**
|
|
371
|
+
* Set the linear factor
|
|
372
|
+
*
|
|
373
|
+
* @param body - rigid body
|
|
374
|
+
* @param factor - per-axis linear factor
|
|
375
|
+
*/
|
|
376
|
+
function set_linear_factor(body: Opaque<"btRigidBody">, factor: Vector3): void;
|
|
377
|
+
/**
|
|
378
|
+
* Set linear velocity
|
|
379
|
+
*
|
|
380
|
+
* @param body - rigid body
|
|
381
|
+
* @param velocity - finite velocity in Defold units per second
|
|
382
|
+
*/
|
|
383
|
+
function set_linear_velocity(body: Opaque<"btRigidBody">, velocity: Vector3): void;
|
|
384
|
+
/**
|
|
385
|
+
* Recalculates local inertia from the body's current collision shape. Only a
|
|
386
|
+
* dynamic body can be changed; zero mass cannot be used to convert it into a
|
|
387
|
+
* static body. Values too small to have a finite native inverse are rejected.
|
|
388
|
+
* The body is activated after the update.
|
|
389
|
+
*
|
|
390
|
+
* @param body - dynamic rigid body
|
|
391
|
+
* @param mass - finite mass greater than zero
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* // Change the mass of a dynamic collision object and inspect its recalculated inertia:
|
|
395
|
+
* export default defineScript({
|
|
396
|
+
* init() {
|
|
397
|
+
* const body = bullet3d.get_rigid_body("#collisionobject");
|
|
398
|
+
* if (body === undefined) return;
|
|
399
|
+
* bullet3d.rigid_body.set_mass(body, 5);
|
|
400
|
+
* print("local inertia", bullet3d.rigid_body.get_local_inertia(body));
|
|
401
|
+
* },
|
|
402
|
+
* });
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
function set_mass(body: Opaque<"btRigidBody">, mass: number): void;
|
|
406
|
+
/**
|
|
407
|
+
* Sets mass and diagonal local inertia together, updates the world-space
|
|
408
|
+
* inertia tensor, and activates the body. Only dynamic bodies are accepted.
|
|
409
|
+
* A zero inertia component is allowed and disables angular response on that
|
|
410
|
+
* local axis; negative, non-finite, or nonzero values too small to have a
|
|
411
|
+
* finite native inverse are rejected.
|
|
412
|
+
*
|
|
413
|
+
* @param body - dynamic rigid body
|
|
414
|
+
* @param mass - finite mass greater than zero
|
|
415
|
+
* @param local_inertia - finite non-negative diagonal local inertia in Defold mass-times-distance-squared units
|
|
416
|
+
*/
|
|
417
|
+
function set_mass_properties(body: Opaque<"btRigidBody">, mass: number, local_inertia: Vector3): void;
|
|
418
|
+
/**
|
|
419
|
+
* Set the sleeping thresholds
|
|
420
|
+
*
|
|
421
|
+
* @param body - rigid body
|
|
422
|
+
* @param linear - finite non-negative linear threshold in Defold units per second
|
|
423
|
+
* @param angular - finite non-negative angular threshold in radians per second
|
|
424
|
+
*/
|
|
425
|
+
function set_sleeping_thresholds(body: Opaque<"btRigidBody">, linear: number, angular: number): void;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Opaque, Quaternion, Vector3 } from "../../../src/core-types";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Borrowed shape handles identify a one-based child slot on a Defold-owned
|
|
7
|
+
* collision object. They remain attached to that logical slot when its native
|
|
8
|
+
* shape is replaced and become invalid with their owning collision object.
|
|
9
|
+
* Shape mutation is copy-on-write, so instances sharing a collision resource
|
|
10
|
+
* are not modified together. Lengths use Defold world units.
|
|
11
|
+
*/
|
|
12
|
+
namespace bullet3d.shape {
|
|
13
|
+
type btCollisionShape = Opaque<"btCollisionShape">;
|
|
14
|
+
type definition = { type: bullet3d.shape.SHAPE_TYPE; diameter: number; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: bullet3d.shape.SHAPE_TYPE; dimensions: Vector3; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: bullet3d.shape.SHAPE_TYPE; diameter: number; height: number; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: bullet3d.shape.SHAPE_TYPE; vertices: Vector3[]; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion };
|
|
15
|
+
type SHAPE_TYPE = typeof bullet3d.shape.SHAPE_TYPE_BOX | typeof bullet3d.shape.SHAPE_TYPE_CAPSULE | typeof bullet3d.shape.SHAPE_TYPE_HULL | typeof bullet3d.shape.SHAPE_TYPE_MESH | typeof bullet3d.shape.SHAPE_TYPE_SPHERE;
|
|
16
|
+
/**
|
|
17
|
+
* Box shape type Value `1`. Shape data contains positive vector3 `dimensions` in Defold units.
|
|
18
|
+
*/
|
|
19
|
+
const SHAPE_TYPE_BOX: number & { readonly __brand: "bullet3d.shape.SHAPE_TYPE_BOX" };
|
|
20
|
+
/**
|
|
21
|
+
* Capsule shape type Value `2`. Shape data contains a positive numeric `diameter` and positive numeric cylindrical-section `height` in Defold units.
|
|
22
|
+
*/
|
|
23
|
+
const SHAPE_TYPE_CAPSULE: number & { readonly __brand: "bullet3d.shape.SHAPE_TYPE_CAPSULE" };
|
|
24
|
+
/**
|
|
25
|
+
* Convex hull shape type Value `3`. Shape data contains a `vertices` array with at least four finite vector3 values in Defold units.
|
|
26
|
+
*/
|
|
27
|
+
const SHAPE_TYPE_HULL: number & { readonly __brand: "bullet3d.shape.SHAPE_TYPE_HULL" };
|
|
28
|
+
/**
|
|
29
|
+
* Triangle mesh shape type Value `4`. Shape data contains only the `type`; triangle geometry is read-only.
|
|
30
|
+
*/
|
|
31
|
+
const SHAPE_TYPE_MESH: number & { readonly __brand: "bullet3d.shape.SHAPE_TYPE_MESH" };
|
|
32
|
+
/**
|
|
33
|
+
* Sphere shape type Value `0`. Shape data contains a positive numeric `diameter` in Defold units.
|
|
34
|
+
*/
|
|
35
|
+
const SHAPE_TYPE_SPHERE: number & { readonly __brand: "bullet3d.shape.SHAPE_TYPE_SPHERE" };
|
|
36
|
+
/**
|
|
37
|
+
* Get the owning collision object.
|
|
38
|
+
*
|
|
39
|
+
* @param shape - shape handle
|
|
40
|
+
* @returns owning collision object
|
|
41
|
+
*/
|
|
42
|
+
function get_collision_object(shape: bullet3d.shape.btCollisionShape): Opaque<"btCollisionObject" | "btRigidBody">;
|
|
43
|
+
/**
|
|
44
|
+
* Get the one-based child index.
|
|
45
|
+
*
|
|
46
|
+
* @param shape - shape handle
|
|
47
|
+
* @returns one-based shape index. **⚠️ 1-based; passed to Defold unchanged.**
|
|
48
|
+
*/
|
|
49
|
+
function get_index(shape: bullet3d.shape.btCollisionShape): number;
|
|
50
|
+
/**
|
|
51
|
+
* A non-compound collision object's only shape has no child transform, so this
|
|
52
|
+
* function returns the identity transform for it.
|
|
53
|
+
*
|
|
54
|
+
* @param shape - shape handle
|
|
55
|
+
*/
|
|
56
|
+
function get_local_transform(shape: bullet3d.shape.btCollisionShape): LuaMultiReturn<[Vector3, Quaternion]>;
|
|
57
|
+
/**
|
|
58
|
+
* The returned table always contains `type`, one of `bullet3d.shape.SHAPE_TYPE_*`.
|
|
59
|
+
* A sphere also contains numeric `diameter`; a box contains vector3
|
|
60
|
+
* `dimensions`; a capsule contains numeric `diameter` and cylindrical-section
|
|
61
|
+
* `height`; a hull contains a `vertices` array of vector3 values; and a triangle
|
|
62
|
+
* mesh contains only `type`. Primitive and hull tables use Defold units and can
|
|
63
|
+
* be passed to a `bullet3d.world` shape query after adding the desired `position`
|
|
64
|
+
* and optional `rotation` fields.
|
|
65
|
+
*
|
|
66
|
+
* @param shape - shape handle
|
|
67
|
+
* @returns typed shape geometry in Defold units
|
|
68
|
+
*/
|
|
69
|
+
function get_shape(shape: bullet3d.shape.btCollisionShape): bullet3d.shape.definition;
|
|
70
|
+
/**
|
|
71
|
+
* Get the normalized Defold shape type.
|
|
72
|
+
*
|
|
73
|
+
* @param shape - shape handle
|
|
74
|
+
* @returns collision shape type
|
|
75
|
+
*/
|
|
76
|
+
function get_type(shape: bullet3d.shape.btCollisionShape): bullet3d.shape.SHAPE_TYPE;
|
|
77
|
+
/**
|
|
78
|
+
* Test whether a shape handle and its owner still exist.
|
|
79
|
+
*
|
|
80
|
+
* @param shape - shape handle
|
|
81
|
+
* @returns validity
|
|
82
|
+
*/
|
|
83
|
+
function is_valid(shape: bullet3d.shape.btCollisionShape): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* A non-compound collision object's only shape has no child transform and is
|
|
86
|
+
* rejected. The binding normalizes the supplied rotation.
|
|
87
|
+
*
|
|
88
|
+
* @param shape - shape handle
|
|
89
|
+
* @param position - finite local position
|
|
90
|
+
* @param rotation - finite non-zero local rotation
|
|
91
|
+
*/
|
|
92
|
+
function set_local_transform(shape: bullet3d.shape.btCollisionShape, position: Vector3, rotation: Quaternion): void;
|
|
93
|
+
/**
|
|
94
|
+
* The table uses the same format as `get_shape`. Its `type` must match the
|
|
95
|
+
* existing shape because changing native shape type is not supported. Primitive
|
|
96
|
+
* dimensions must be finite and greater than zero. Hulls require at least four
|
|
97
|
+
* finite vertices. Triangle mesh geometry cannot be changed with this function.
|
|
98
|
+
*
|
|
99
|
+
* @param shape - shape handle
|
|
100
|
+
* @param data - typed shape geometry in Defold units
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* // Increase the dimensions of the first box shape by 50 percent for this instance:
|
|
104
|
+
* export default defineScript({
|
|
105
|
+
* init() {
|
|
106
|
+
* const object = bullet3d.get_collision_object("#collisionobject");
|
|
107
|
+
* if (object === undefined) return;
|
|
108
|
+
* const shape = bullet3d.collision_object.get_shape(object, 1);
|
|
109
|
+
* const data = bullet3d.shape.get_shape(shape);
|
|
110
|
+
*
|
|
111
|
+
* if (data.type === bullet3d.shape.SHAPE_TYPE_BOX && "dimensions" in data) {
|
|
112
|
+
* data.dimensions = data.dimensions.mul(1.5);
|
|
113
|
+
* bullet3d.shape.set_shape(shape, data);
|
|
114
|
+
* }
|
|
115
|
+
* },
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
function set_shape(shape: bullet3d.shape.btCollisionShape, data: bullet3d.shape.definition): void;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export {};
|