@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/render.d.ts
CHANGED
|
@@ -3,15 +3,7 @@ import type { Hash, Matrix4, Opaque, Url, Vector4 } from "../src/core-types";
|
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
5
|
/**
|
|
6
|
-
* Rendering
|
|
7
|
-
* accessible only from render scripts.
|
|
8
|
-
*
|
|
9
|
-
* The rendering API was originally built on top of OpenGL ES 2.0, and it uses a subset of the
|
|
10
|
-
* OpenGL computer graphics rendering API for rendering 2D and 3D computer
|
|
11
|
-
* graphics. Our current target is OpenGLES 3.0 with fallbacks to 2.0 on some platforms.
|
|
12
|
-
*
|
|
13
|
-
* [icon:attention] It is possible to create materials and write shaders that
|
|
14
|
-
* require features not in OpenGL ES 2.0, but those will not work cross platform.
|
|
6
|
+
* Rendering API documentation
|
|
15
7
|
*/
|
|
16
8
|
namespace render {
|
|
17
9
|
type constant_buffer = Opaque<"constant_buffer">;
|
|
@@ -658,6 +650,17 @@ declare global {
|
|
|
658
650
|
* ```
|
|
659
651
|
*/
|
|
660
652
|
function render_target(name: string, parameters: Record<string | number, unknown>): Opaque<"render_target">;
|
|
653
|
+
/**
|
|
654
|
+
* Sets the blend equation with separate equations for the color and alpha channels.
|
|
655
|
+
*
|
|
656
|
+
* @param equation_color - color blend equation
|
|
657
|
+
* @param equation_alpha - alpha blend equation
|
|
658
|
+
* @example
|
|
659
|
+
* ```ts
|
|
660
|
+
* render.set_blend_equation_separate(graphics.BLEND_EQUATION_ADD, graphics.BLEND_EQUATION_REVERSE_SUBTRACT);
|
|
661
|
+
* ```
|
|
662
|
+
*/
|
|
663
|
+
function set_blend_equation_separate(equation_color: number, equation_alpha: number): void;
|
|
661
664
|
/**
|
|
662
665
|
* Specifies the arithmetic used when computing pixel values that are written to the frame
|
|
663
666
|
* buffer. In RGBA mode, pixels can be drawn using a function that blends the source RGBA
|
|
@@ -745,6 +748,19 @@ declare global {
|
|
|
745
748
|
* ```
|
|
746
749
|
*/
|
|
747
750
|
function set_blend_func(source_factor: number, destination_factor: number): void;
|
|
751
|
+
/**
|
|
752
|
+
* Sets the blend function with separate blend factors for the color and alpha channels.
|
|
753
|
+
*
|
|
754
|
+
* @param source_factor_color - source color blend factor
|
|
755
|
+
* @param destination_factor_color - destination color blend factor
|
|
756
|
+
* @param source_factor_alpha - source alpha blend factor
|
|
757
|
+
* @param destination_factor_alpha - destination alpha blend factor
|
|
758
|
+
* @example
|
|
759
|
+
* ```ts
|
|
760
|
+
* render.set_blend_func_separate(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, graphics.BLEND_FACTOR_ONE, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
function set_blend_func_separate(source_factor_color: number, destination_factor_color: number, source_factor_alpha: number, destination_factor_alpha: number): void;
|
|
748
764
|
/**
|
|
749
765
|
* Sets the current render camera to be used for rendering. If a render camera
|
|
750
766
|
* has been set by the render script, the renderer will be using its projection and view matrix
|
package/generated/resource.d.ts
CHANGED
|
@@ -255,7 +255,7 @@ declare global {
|
|
|
255
255
|
* -
|
|
256
256
|
*
|
|
257
257
|
* `transfer_ownership`
|
|
258
|
-
* boolean optional flag to determine
|
|
258
|
+
* boolean optional flag to determine whether or not the resource should take over ownership of the buffer object (default true)
|
|
259
259
|
* @returns Returns the buffer resource path
|
|
260
260
|
* @example
|
|
261
261
|
* ```ts
|
|
@@ -1224,7 +1224,7 @@ declare global {
|
|
|
1224
1224
|
* -
|
|
1225
1225
|
*
|
|
1226
1226
|
* `transfer_ownership`
|
|
1227
|
-
* boolean optional flag to determine
|
|
1227
|
+
* boolean optional flag to determine whether or not the resource should take over ownership of the buffer object (default false)
|
|
1228
1228
|
* @example
|
|
1229
1229
|
* ```ts
|
|
1230
1230
|
* // How to set the data from a buffer
|
package/generated/sprite.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Hash, Url, Vector3, Vector4 } from "../src/core-types";
|
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Sprite API documentation
|
|
7
7
|
*/
|
|
8
8
|
namespace sprite {
|
|
9
9
|
/**
|
|
@@ -53,6 +53,20 @@ declare global {
|
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
function play_flipbook(url: string | Hash | Url, id: string | Hash, complete_function?: (self: unknown, message_id: unknown, message: unknown, sender: unknown) => void, play_properties?: { offset?: number; playback_rate?: number }): void;
|
|
56
|
+
/**
|
|
57
|
+
* Resets a shader constant for a sprite component.
|
|
58
|
+
* The constant must be defined in the material assigned to the sprite.
|
|
59
|
+
* Resetting a constant through this function implies that the value defined in the material will be used.
|
|
60
|
+
* Which sprite to reset a constant for is identified by the URL.
|
|
61
|
+
*
|
|
62
|
+
* @param url - the sprite that should have a constant reset
|
|
63
|
+
* @param constant - name of the constant
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* sprite.reset_constant("#sprite", "tint");
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
function reset_constant(url: string | Hash | Url, constant: string | Hash): void;
|
|
56
70
|
/**
|
|
57
71
|
* Sets horizontal flipping of the provided sprite's animations.
|
|
58
72
|
* The sprite is identified by its URL.
|
package/generated/tilemap.d.ts
CHANGED
|
@@ -110,6 +110,20 @@ declare global {
|
|
|
110
110
|
* ```
|
|
111
111
|
*/
|
|
112
112
|
function get_tiles(url: string | Hash | Url, layer: string | Hash): LuaMap<number, LuaMap<number, number>>;
|
|
113
|
+
/**
|
|
114
|
+
* Resets a shader constant for a tile map component.
|
|
115
|
+
* The constant must be defined in the material assigned to the tile map.
|
|
116
|
+
* Resetting a constant through this function implies that the value defined in the material will be used.
|
|
117
|
+
* Which tile map to reset a constant for is identified by the URL.
|
|
118
|
+
*
|
|
119
|
+
* @param url - the tile map that should have a constant reset
|
|
120
|
+
* @param constant - name of the constant
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* tilemap.reset_constant("#tilemap", "tint");
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
function reset_constant(url: string | Hash | Url, constant: string | Hash): void;
|
|
113
127
|
/**
|
|
114
128
|
* Replace a tile in a tile map with a new tile.
|
|
115
129
|
* The coordinates of the tiles are indexed so that the "first" tile just
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Hash, Opaque, Url } from "../../../src/core-types";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions for interacting with Box2D.
|
|
7
|
+
*/
|
|
8
|
+
namespace b2d {
|
|
9
|
+
type b2Body = Opaque<"b2Body">;
|
|
10
|
+
type b2World = Opaque<"b2World">;
|
|
11
|
+
/**
|
|
12
|
+
* Get the Box2D body from a collision object
|
|
13
|
+
*
|
|
14
|
+
* @param url - the url to the game object collision component
|
|
15
|
+
* @returns the body if successful. Otherwise `nil`.
|
|
16
|
+
*/
|
|
17
|
+
function get_body(url: string | Hash | Url): Opaque<"b2Body">;
|
|
18
|
+
/**
|
|
19
|
+
* Get the Box2D world from the current collection
|
|
20
|
+
*
|
|
21
|
+
* @returns the world if successful. Otherwise `nil`.
|
|
22
|
+
*/
|
|
23
|
+
function get_world(): Opaque<"b2World">;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Opaque, Vector3 } from "../../../src/core-types";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions for interacting with Box2D bodies.
|
|
7
|
+
*/
|
|
8
|
+
namespace b2d.body {
|
|
9
|
+
type b2Body = Opaque<"b2Body">;
|
|
10
|
+
type b2World = Opaque<"b2World">;
|
|
11
|
+
/**
|
|
12
|
+
* Dynamic body
|
|
13
|
+
*/
|
|
14
|
+
const B2_DYNAMIC_BODY: number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" };
|
|
15
|
+
/**
|
|
16
|
+
* Kinematic body
|
|
17
|
+
*/
|
|
18
|
+
const B2_KINEMATIC_BODY: number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" };
|
|
19
|
+
/**
|
|
20
|
+
* Static (immovable) body
|
|
21
|
+
*/
|
|
22
|
+
const B2_STATIC_BODY: number & { readonly __brand: "b2d.body.B2_STATIC_BODY" };
|
|
23
|
+
/**
|
|
24
|
+
* Apply an angular impulse.
|
|
25
|
+
*
|
|
26
|
+
* @param body - body
|
|
27
|
+
* @param impulse - impulse the angular impulse in units of kg*m*m/s
|
|
28
|
+
*/
|
|
29
|
+
function apply_angular_impulse(body: Opaque<"b2Body">, impulse: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Apply a force at a world point. If the force is not
|
|
32
|
+
* applied at the center of mass, it will generate a torque and
|
|
33
|
+
* affect the angular velocity. This wakes up the body.
|
|
34
|
+
*
|
|
35
|
+
* @param body - body
|
|
36
|
+
* @param force - the world force vector, usually in Newtons (N).
|
|
37
|
+
* @param point - the world position of the point of application.
|
|
38
|
+
*/
|
|
39
|
+
function apply_force(body: Opaque<"b2Body">, force: Vector3, point: Vector3): void;
|
|
40
|
+
/**
|
|
41
|
+
* Apply a force to the center of mass. This wakes up the body.
|
|
42
|
+
*
|
|
43
|
+
* @param body - body
|
|
44
|
+
* @param force - the world force vector, usually in Newtons (N).
|
|
45
|
+
*/
|
|
46
|
+
function apply_force_to_center(body: Opaque<"b2Body">, force: Vector3): void;
|
|
47
|
+
/**
|
|
48
|
+
* Apply an impulse at a point. This immediately modifies the velocity.
|
|
49
|
+
* It also modifies the angular velocity if the point of application
|
|
50
|
+
* is not at the center of mass. This wakes up the body.
|
|
51
|
+
*
|
|
52
|
+
* @param body - body
|
|
53
|
+
* @param impulse - the world impulse vector, usually in N-seconds or kg-m/s.
|
|
54
|
+
* @param point - the world position of the point of application.
|
|
55
|
+
*/
|
|
56
|
+
function apply_linear_impulse(body: Opaque<"b2Body">, impulse: Vector3, point: Vector3): void;
|
|
57
|
+
/**
|
|
58
|
+
* Apply a torque. This affects the angular velocity
|
|
59
|
+
* without affecting the linear velocity of the center of mass.
|
|
60
|
+
* This wakes up the body.
|
|
61
|
+
*
|
|
62
|
+
* @param body - body
|
|
63
|
+
* @param torque - torque about the z-axis (out of the screen), usually in N-m.
|
|
64
|
+
*/
|
|
65
|
+
function apply_torque(body: Opaque<"b2Body">, torque: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* You can disable sleeping on this body. If you disable sleeping, the body will be woken.
|
|
68
|
+
*
|
|
69
|
+
* @param body - body
|
|
70
|
+
* @param enable - if false, the body will never sleep, and consume more CPU
|
|
71
|
+
*/
|
|
72
|
+
function enable_sleep(body: Opaque<"b2Body">, enable: boolean): void;
|
|
73
|
+
/**
|
|
74
|
+
* Get the angle in radians.
|
|
75
|
+
*
|
|
76
|
+
* @param body - body
|
|
77
|
+
* @returns the current world rotation angle in radians.
|
|
78
|
+
*/
|
|
79
|
+
function get_angle(body: Opaque<"b2Body">): number;
|
|
80
|
+
/**
|
|
81
|
+
* Get the angular damping of the body.
|
|
82
|
+
*
|
|
83
|
+
* @param body - body
|
|
84
|
+
* @returns the damping
|
|
85
|
+
*/
|
|
86
|
+
function get_angular_damping(body: Opaque<"b2Body">): number;
|
|
87
|
+
/**
|
|
88
|
+
* Get the angular velocity.
|
|
89
|
+
*
|
|
90
|
+
* @param body - body
|
|
91
|
+
* @returns the angular velocity in radians/second.
|
|
92
|
+
*/
|
|
93
|
+
function get_angular_velocity(body: Opaque<"b2Body">): number;
|
|
94
|
+
/**
|
|
95
|
+
* Get the gravity scale of the body.
|
|
96
|
+
*
|
|
97
|
+
* @param body - body
|
|
98
|
+
* @returns the scale
|
|
99
|
+
*/
|
|
100
|
+
function get_gravity_scale(body: Opaque<"b2Body">): number;
|
|
101
|
+
/**
|
|
102
|
+
* Get the linear damping of the body.
|
|
103
|
+
*
|
|
104
|
+
* @param body - body
|
|
105
|
+
* @returns the damping
|
|
106
|
+
*/
|
|
107
|
+
function get_linear_damping(body: Opaque<"b2Body">): number;
|
|
108
|
+
/**
|
|
109
|
+
* Get the linear velocity of the center of mass.
|
|
110
|
+
*
|
|
111
|
+
* @param body - body
|
|
112
|
+
* @returns the linear velocity of the center of mass.
|
|
113
|
+
*/
|
|
114
|
+
function get_linear_velocity(body: Opaque<"b2Body">): Vector3;
|
|
115
|
+
/**
|
|
116
|
+
* Get the world velocity of a local point.
|
|
117
|
+
*
|
|
118
|
+
* @param body - body
|
|
119
|
+
* @param local_point - a point in local coordinates.
|
|
120
|
+
* @returns the world velocity of a point.
|
|
121
|
+
*/
|
|
122
|
+
function get_linear_velocity_from_local_point(body: Opaque<"b2Body">, local_point: Vector3): Vector3;
|
|
123
|
+
/**
|
|
124
|
+
* Get the world linear velocity of a world point attached to this body.
|
|
125
|
+
*
|
|
126
|
+
* @param body - body
|
|
127
|
+
* @param world_point - a point in world coordinates.
|
|
128
|
+
* @returns the world velocity of a point.
|
|
129
|
+
*/
|
|
130
|
+
function get_linear_velocity_from_world_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
|
|
131
|
+
/**
|
|
132
|
+
* Get the local position of the center of mass.
|
|
133
|
+
*
|
|
134
|
+
* @param body - body
|
|
135
|
+
* @returns Get the local position of the center of mass.
|
|
136
|
+
*/
|
|
137
|
+
function get_local_center_of_mass(body: Opaque<"b2Body">): Vector3;
|
|
138
|
+
/**
|
|
139
|
+
* Gets a local point relative to the body's origin given a world point.
|
|
140
|
+
*
|
|
141
|
+
* @param body - body
|
|
142
|
+
* @param world_point - a point in world coordinates.
|
|
143
|
+
* @returns the corresponding local point relative to the body's origin.
|
|
144
|
+
*/
|
|
145
|
+
function get_local_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
|
|
146
|
+
/**
|
|
147
|
+
* Gets a local vector given a world vector.
|
|
148
|
+
*
|
|
149
|
+
* @param body - body
|
|
150
|
+
* @param world_vector - a vector in world coordinates.
|
|
151
|
+
* @returns the corresponding local vector.
|
|
152
|
+
*/
|
|
153
|
+
function get_local_vector(body: Opaque<"b2Body">, world_vector: Vector3): Vector3;
|
|
154
|
+
/**
|
|
155
|
+
* Get the total mass of the body.
|
|
156
|
+
*
|
|
157
|
+
* @param body - body
|
|
158
|
+
* @returns the mass, usually in kilograms (kg).
|
|
159
|
+
*/
|
|
160
|
+
function get_mass(body: Opaque<"b2Body">): number;
|
|
161
|
+
/**
|
|
162
|
+
* Get the world body origin position.
|
|
163
|
+
*
|
|
164
|
+
* @param body - body
|
|
165
|
+
* @returns the world position of the body's origin.
|
|
166
|
+
*/
|
|
167
|
+
function get_position(body: Opaque<"b2Body">): Vector3;
|
|
168
|
+
/**
|
|
169
|
+
* Get the rotational inertia of the body about the local origin.
|
|
170
|
+
*
|
|
171
|
+
* @param body - body
|
|
172
|
+
* @returns the rotational inertia, usually in kg-m^2.
|
|
173
|
+
*/
|
|
174
|
+
function get_rotational_inertia(body: Opaque<"b2Body">): number;
|
|
175
|
+
/**
|
|
176
|
+
* Get the type of this body.
|
|
177
|
+
*
|
|
178
|
+
* @param body - body
|
|
179
|
+
* @returns the body type
|
|
180
|
+
*/
|
|
181
|
+
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" });
|
|
182
|
+
/**
|
|
183
|
+
* Get the parent world of this body.
|
|
184
|
+
*
|
|
185
|
+
* @param body - body
|
|
186
|
+
*/
|
|
187
|
+
function get_world(body: Opaque<"b2Body">): Opaque<"b2World">;
|
|
188
|
+
/**
|
|
189
|
+
* Get the world position of the center of mass.
|
|
190
|
+
*
|
|
191
|
+
* @param body - body
|
|
192
|
+
* @returns Get the world position of the center of mass.
|
|
193
|
+
*/
|
|
194
|
+
function get_world_center_of_mass(body: Opaque<"b2Body">): Vector3;
|
|
195
|
+
/**
|
|
196
|
+
* Get the world coordinates of a point given the local coordinates.
|
|
197
|
+
*
|
|
198
|
+
* @param body - body
|
|
199
|
+
* @param local_vector - localPoint a point on the body measured relative the the body's origin.
|
|
200
|
+
* @returns the same point expressed in world coordinates.
|
|
201
|
+
*/
|
|
202
|
+
function get_world_point(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
|
|
203
|
+
/**
|
|
204
|
+
* Get the world coordinates of a vector given the local coordinates.
|
|
205
|
+
*
|
|
206
|
+
* @param body - body
|
|
207
|
+
* @param local_vector - a vector fixed in the body.
|
|
208
|
+
* @returns the same vector expressed in world coordinates.
|
|
209
|
+
*/
|
|
210
|
+
function get_world_vector(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
|
|
211
|
+
/**
|
|
212
|
+
* Get the active state of the body.
|
|
213
|
+
*
|
|
214
|
+
* @param body - body
|
|
215
|
+
* @returns is the body active
|
|
216
|
+
*/
|
|
217
|
+
function is_active(body: Opaque<"b2Body">): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Get the sleeping state of this body.
|
|
220
|
+
*
|
|
221
|
+
* @param body - body
|
|
222
|
+
* @returns true if the body is awake, false if it's sleeping.
|
|
223
|
+
*/
|
|
224
|
+
function is_awake(body: Opaque<"b2Body">): boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Is this body in bullet mode
|
|
227
|
+
*
|
|
228
|
+
* @param body - body
|
|
229
|
+
* @returns true if the body is in bullet mode
|
|
230
|
+
*/
|
|
231
|
+
function is_bullet(body: Opaque<"b2Body">): boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Does this body have fixed rotation?
|
|
234
|
+
*
|
|
235
|
+
* @param body - body
|
|
236
|
+
* @returns is the rotation fixed
|
|
237
|
+
*/
|
|
238
|
+
function is_fixed_rotation(body: Opaque<"b2Body">): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Is this body allowed to sleep
|
|
241
|
+
*
|
|
242
|
+
* @param body - body
|
|
243
|
+
* @returns true if the body is allowed to sleep
|
|
244
|
+
*/
|
|
245
|
+
function is_sleeping_enabled(body: Opaque<"b2Body">): boolean;
|
|
246
|
+
/**
|
|
247
|
+
* This resets the mass properties to the sum of the mass properties of the fixtures.
|
|
248
|
+
* This normally does not need to be called unless you called SetMassData to override
|
|
249
|
+
*
|
|
250
|
+
* @param body - body
|
|
251
|
+
*/
|
|
252
|
+
function reset_mass_data(body: Opaque<"b2Body">): void;
|
|
253
|
+
/**
|
|
254
|
+
* Set the active state of the body. An inactive body is not
|
|
255
|
+
* simulated and cannot be collided with or woken up.
|
|
256
|
+
* If you pass a flag of true, all fixtures will be added to the
|
|
257
|
+
* broad-phase.
|
|
258
|
+
* If you pass a flag of false, all fixtures will be removed from
|
|
259
|
+
* the broad-phase and all contacts will be destroyed.
|
|
260
|
+
* Fixtures and joints are otherwise unaffected. You may continue
|
|
261
|
+
* to create/destroy fixtures and joints on inactive bodies.
|
|
262
|
+
* Fixtures on an inactive body are implicitly inactive and will
|
|
263
|
+
* not participate in collisions, ray-casts, or queries.
|
|
264
|
+
* Joints connected to an inactive body are implicitly inactive.
|
|
265
|
+
* An inactive body is still owned by a b2World object and remains
|
|
266
|
+
* in the body list.
|
|
267
|
+
*
|
|
268
|
+
* @param body - body
|
|
269
|
+
* @param enable - true if the body should be active
|
|
270
|
+
*/
|
|
271
|
+
function set_active(body: Opaque<"b2Body">, enable: boolean): void;
|
|
272
|
+
/**
|
|
273
|
+
* Set the angular damping of the body.
|
|
274
|
+
*
|
|
275
|
+
* @param body - body
|
|
276
|
+
* @param damping - the damping
|
|
277
|
+
*/
|
|
278
|
+
function set_angular_damping(body: Opaque<"b2Body">, damping: number): void;
|
|
279
|
+
/**
|
|
280
|
+
* Set the angular velocity.
|
|
281
|
+
*
|
|
282
|
+
* @param body - body
|
|
283
|
+
* @param omega - the new angular velocity in radians/second.
|
|
284
|
+
*/
|
|
285
|
+
function set_angular_velocity(body: Opaque<"b2Body">, omega: number): void;
|
|
286
|
+
/**
|
|
287
|
+
* Set the sleep state of the body. A sleeping body has very low CPU cost.
|
|
288
|
+
*
|
|
289
|
+
* @param body - body
|
|
290
|
+
* @param enable - flag set to false to put body to sleep, true to wake it.
|
|
291
|
+
*/
|
|
292
|
+
function set_awake(body: Opaque<"b2Body">, enable: boolean): void;
|
|
293
|
+
/**
|
|
294
|
+
* Should this body be treated like a bullet for continuous collision detection?
|
|
295
|
+
*
|
|
296
|
+
* @param body - body
|
|
297
|
+
* @param enable - if true, the body will be in bullet mode
|
|
298
|
+
*/
|
|
299
|
+
function set_bullet(body: Opaque<"b2Body">, enable: boolean): void;
|
|
300
|
+
/**
|
|
301
|
+
* Set this body to have fixed rotation. This causes the mass to be reset.
|
|
302
|
+
*
|
|
303
|
+
* @param body - body
|
|
304
|
+
* @param enable - true if the rotation should be fixed
|
|
305
|
+
*/
|
|
306
|
+
function set_fixed_rotation(body: Opaque<"b2Body">, enable: boolean): void;
|
|
307
|
+
/**
|
|
308
|
+
* Set the gravity scale of the body.
|
|
309
|
+
*
|
|
310
|
+
* @param body - body
|
|
311
|
+
* @param scale - the scale
|
|
312
|
+
*/
|
|
313
|
+
function set_gravity_scale(body: Opaque<"b2Body">, scale: number): void;
|
|
314
|
+
/**
|
|
315
|
+
* Set the linear damping of the body.
|
|
316
|
+
*
|
|
317
|
+
* @param body - body
|
|
318
|
+
* @param damping - the damping
|
|
319
|
+
*/
|
|
320
|
+
function set_linear_damping(body: Opaque<"b2Body">, damping: number): void;
|
|
321
|
+
/**
|
|
322
|
+
* Set the linear velocity of the center of mass.
|
|
323
|
+
*
|
|
324
|
+
* @param body - body
|
|
325
|
+
* @param velocity - the new linear velocity of the center of mass.
|
|
326
|
+
*/
|
|
327
|
+
function set_linear_velocity(body: Opaque<"b2Body">, velocity: Vector3): void;
|
|
328
|
+
/**
|
|
329
|
+
* Set the position of the body's origin and rotation.
|
|
330
|
+
* This breaks any contacts and wakes the other bodies.
|
|
331
|
+
* Manipulating a body's transform may cause non-physical behavior.
|
|
332
|
+
*
|
|
333
|
+
* @param body - body
|
|
334
|
+
* @param position - the world position of the body's local origin.
|
|
335
|
+
* @param angle - the world position of the body's local origin.
|
|
336
|
+
*/
|
|
337
|
+
function set_transform(body: Opaque<"b2Body">, position: Vector3, angle: number): void;
|
|
338
|
+
/**
|
|
339
|
+
* Set the type of this body. This may alter the mass and velocity.
|
|
340
|
+
*
|
|
341
|
+
* @param body - body
|
|
342
|
+
* @param type - the body type
|
|
343
|
+
*/
|
|
344
|
+
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;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export {};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import type { Hash, Opaque } from "../../../src/core-types";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions for manipulating buffers and streams
|
|
7
|
+
*/
|
|
8
|
+
namespace buffer {
|
|
9
|
+
/**
|
|
10
|
+
* Float, single precision, 4 bytes
|
|
11
|
+
*/
|
|
12
|
+
const VALUE_TYPE_FLOAT32: number & { readonly __brand: "buffer.VALUE_TYPE_FLOAT32" };
|
|
13
|
+
/**
|
|
14
|
+
* Signed integer, 2 bytes
|
|
15
|
+
*/
|
|
16
|
+
const VALUE_TYPE_INT16: number & { readonly __brand: "buffer.VALUE_TYPE_INT16" };
|
|
17
|
+
/**
|
|
18
|
+
* Signed integer, 4 bytes
|
|
19
|
+
*/
|
|
20
|
+
const VALUE_TYPE_INT32: number & { readonly __brand: "buffer.VALUE_TYPE_INT32" };
|
|
21
|
+
/**
|
|
22
|
+
* Signed integer, 8 bytes
|
|
23
|
+
*/
|
|
24
|
+
const VALUE_TYPE_INT64: number & { readonly __brand: "buffer.VALUE_TYPE_INT64" };
|
|
25
|
+
/**
|
|
26
|
+
* Signed integer, 1 byte
|
|
27
|
+
*/
|
|
28
|
+
const VALUE_TYPE_INT8: number & { readonly __brand: "buffer.VALUE_TYPE_INT8" };
|
|
29
|
+
/**
|
|
30
|
+
* Unsigned integer, 2 bytes
|
|
31
|
+
*/
|
|
32
|
+
const VALUE_TYPE_UINT16: number & { readonly __brand: "buffer.VALUE_TYPE_UINT16" };
|
|
33
|
+
/**
|
|
34
|
+
* Unsigned integer, 4 bytes
|
|
35
|
+
*/
|
|
36
|
+
const VALUE_TYPE_UINT32: number & { readonly __brand: "buffer.VALUE_TYPE_UINT32" };
|
|
37
|
+
/**
|
|
38
|
+
* Unsigned integer, 8 bytes
|
|
39
|
+
*/
|
|
40
|
+
const VALUE_TYPE_UINT64: number & { readonly __brand: "buffer.VALUE_TYPE_UINT64" };
|
|
41
|
+
/**
|
|
42
|
+
* Unsigned integer, 1 byte
|
|
43
|
+
*/
|
|
44
|
+
const VALUE_TYPE_UINT8: number & { readonly __brand: "buffer.VALUE_TYPE_UINT8" };
|
|
45
|
+
/**
|
|
46
|
+
* Copy all data streams from one buffer to another, element wise.
|
|
47
|
+
* Each of the source streams must have a matching stream in the
|
|
48
|
+
* destination buffer. The streams must match in both type and size.
|
|
49
|
+
* The source and destination buffer can be the same.
|
|
50
|
+
*
|
|
51
|
+
* @param dst - the destination buffer
|
|
52
|
+
* @param dstoffset - the offset to start copying data to
|
|
53
|
+
* @param src - the source data buffer
|
|
54
|
+
* @param srcoffset - the offset to start copying data from
|
|
55
|
+
* @param count - the number of elements to copy
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* // How to copy elements (e.g. vertices) from one buffer to another
|
|
59
|
+
* // copy entire buffer
|
|
60
|
+
* buffer.copy_buffer(dstbuffer, 0, srcbuffer, 0, srcbuffer.length);
|
|
61
|
+
*
|
|
62
|
+
* // copy last 10 elements to the front of another buffer
|
|
63
|
+
* buffer.copy_buffer(dstbuffer, 0, srcbuffer, srcbuffer.length - 10, 10);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
function copy_buffer(dst: Opaque<"buffer">, dstoffset: number, src: Opaque<"buffer">, srcoffset: number, count: number): void;
|
|
67
|
+
/**
|
|
68
|
+
* Copy a specified amount of data from one stream to another.
|
|
69
|
+
* The value type and size must match between source and destination streams.
|
|
70
|
+
* The source and destination streams can be the same.
|
|
71
|
+
*
|
|
72
|
+
* @param dst - the destination stream
|
|
73
|
+
* @param dstoffset - the offset to start copying data to (measured in value type)
|
|
74
|
+
* @param src - the source data stream
|
|
75
|
+
* @param srcoffset - the offset to start copying data from (measured in value type)
|
|
76
|
+
* @param count - the number of values to copy (measured in value type)
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* // How to update a texture of a sprite:
|
|
80
|
+
* // copy entire stream
|
|
81
|
+
* const srcstream = buffer.get_stream(srcbuffer, hash("xyz"));
|
|
82
|
+
* const dststream = buffer.get_stream(dstbuffer, hash("xyz"));
|
|
83
|
+
* buffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
function copy_stream(dst: Opaque<"bufferstream"> & { [index: number]: number }, dstoffset: number, src: Opaque<"bufferstream"> & { [index: number]: number }, srcoffset: number, count: number): void;
|
|
87
|
+
/**
|
|
88
|
+
* Create a new data buffer containing a specified set of streams. A data buffer
|
|
89
|
+
* can contain one or more streams with typed data. This is useful for managing
|
|
90
|
+
* compound data, for instance a vertex buffer could contain separate streams for
|
|
91
|
+
* vertex position, color, normal etc.
|
|
92
|
+
*
|
|
93
|
+
* @param element_count - The number of elements the buffer should hold
|
|
94
|
+
* @param declaration - A table where each entry (table) describes a stream
|
|
95
|
+
*
|
|
96
|
+
* - hash | string `name`: The name of the stream
|
|
97
|
+
*
|
|
98
|
+
* - constant `type`: The data type of the stream
|
|
99
|
+
*
|
|
100
|
+
* - number `count`: The number of values each element should hold
|
|
101
|
+
* @returns the new buffer
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* // How to create and initialize a buffer
|
|
105
|
+
* export default defineScript({
|
|
106
|
+
* init(self) {
|
|
107
|
+
* const size = 128;
|
|
108
|
+
* self.image = buffer.create(size * size, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
|
|
109
|
+
* self.imagestream = buffer.get_stream(self.image, hash("rgb"));
|
|
110
|
+
*
|
|
111
|
+
* for (let y = 0; y < self.height; y++) {
|
|
112
|
+
* for (let x = 0; x < self.width; x++) {
|
|
113
|
+
* const index = y * self.width * 3 + x * 3;
|
|
114
|
+
* self.imagestream[index + 0] = self.r;
|
|
115
|
+
* self.imagestream[index + 1] = self.g;
|
|
116
|
+
* self.imagestream[index + 2] = self.b;
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
* },
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
function create(element_count: number, declaration: { name?: Hash | string; type?: Opaque<"constant">; count?: number }): Opaque<"buffer">;
|
|
124
|
+
/**
|
|
125
|
+
* Get a copy of all the bytes from a specified stream as a Lua string.
|
|
126
|
+
*
|
|
127
|
+
* @param buffer - the source buffer
|
|
128
|
+
* @param stream_name - the name of the stream
|
|
129
|
+
* @returns the buffer data as a Lua string
|
|
130
|
+
*/
|
|
131
|
+
function get_bytes(buffer: Opaque<"buffer">, stream_name: Hash): string;
|
|
132
|
+
/**
|
|
133
|
+
* Get a named metadata entry from a buffer along with its type.
|
|
134
|
+
*
|
|
135
|
+
* @param buf - the buffer to get the metadata from
|
|
136
|
+
* @param metadata_name - name of the metadata entry
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* // How to get a metadata entry from a buffer
|
|
140
|
+
* // retrieve a metadata entry named "somefloats" and its numeric type
|
|
141
|
+
* const [values, type] = buffer.get_metadata(buf, hash("somefloats"));
|
|
142
|
+
* if (values) print(`${values.length} values in 'somefloats'`);
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
function get_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string): LuaMultiReturn<[number[] | unknown, Opaque<"constant"> | unknown]>;
|
|
146
|
+
/**
|
|
147
|
+
* Get a specified stream from a buffer.
|
|
148
|
+
*
|
|
149
|
+
* @param buffer - the buffer to get the stream from
|
|
150
|
+
* @param stream_name - the stream name
|
|
151
|
+
* @returns the data stream
|
|
152
|
+
*/
|
|
153
|
+
function get_stream(buffer: Opaque<"buffer">, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number };
|
|
154
|
+
/**
|
|
155
|
+
* Creates or updates a metadata array entry on a buffer.
|
|
156
|
+
* The value type and count given when updating the entry should match those used when first creating it.
|
|
157
|
+
*
|
|
158
|
+
* @param buf - the buffer to set the metadata on
|
|
159
|
+
* @param metadata_name - name of the metadata entry
|
|
160
|
+
* @param values - actual metadata, an array of numeric values
|
|
161
|
+
* @param value_type - type of values when stored
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* // How to set a metadata entry on a buffer
|
|
165
|
+
* // create a new metadata entry with three floats
|
|
166
|
+
* buffer.set_metadata(buf, hash("somefloats"), [1.5, 3.2, 7.9], buffer.VALUE_TYPE_FLOAT32);
|
|
167
|
+
* // ...
|
|
168
|
+
* // update to a new set of values
|
|
169
|
+
* buffer.set_metadata(buf, hash("somefloats"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
function set_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string, values: number[], value_type: Opaque<"constant">): void;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export {};
|