diff --git a/index.d.ts b/index.d.ts
index b11cc79..db685dc 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -2,7 +2,7 @@
///
///
-// DEFOLD. stable version 1.8.0 (ef07c036b8f7d34f4b1d7fcc355ce46a92d2dcc8)
+// DEFOLD. stable version 1.8.1 (fd1ad4c17bfdcd890ea7176f2672c35102384419)
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
/**
@@ -331,7 +331,9 @@ declare namespace b2d {
* @param url the url to the game object collision component
* @return body the body if successful. Otherwise `undefined`.
*/
- export function get_body(url: url): typeof b2d.body;
+ export function get_body(
+ url: hash | url | string,
+ ): typeof b2d.body | undefined;
/**
* Get the Box2D world from the current collection
@@ -361,33 +363,48 @@ declare namespace b2d.body {
/**
* Apply an angular impulse.
+ * @param body body
* @param impulse impulse the angular impulse in units of kg*m*m/s
*/
- export function apply_angular_impulse(impulse: number): void;
+ export function apply_angular_impulse(
+ body: typeof b2d.body,
+ impulse: number,
+ ): void;
/**
* Apply a force at a world point. If the force is not
* applied at the center of mass, it will generate a torque and
* affect the angular velocity. This wakes up the body.
+ * @param body body
* @param force the world force vector, usually in Newtons (N).
* @param point the world position of the point of application.
*/
- export function apply_force(force: vmath.vector3, point: vmath.vector3): void;
+ export function apply_force(
+ body: typeof b2d.body,
+ force: vmath.vector3,
+ point: vmath.vector3,
+ ): void;
/**
* Apply a force to the center of mass. This wakes up the body.
+ * @param body body
* @param force the world force vector, usually in Newtons (N).
*/
- export function apply_force_to_center(force: vmath.vector3): void;
+ export function apply_force_to_center(
+ body: typeof b2d.body,
+ force: vmath.vector3,
+ ): void;
/**
* Apply an impulse at a point. This immediately modifies the velocity.
* It also modifies the angular velocity if the point of application
* is not at the center of mass. This wakes up the body.
+ * @param body body
* @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
* @param point the world position of the point of application.
*/
export function apply_linear_impulse(
+ body: typeof b2d.body,
impulse: vmath.vector3,
point: vmath.vector3,
): void;
@@ -396,186 +413,236 @@ declare namespace b2d.body {
* Apply a torque. This affects the angular velocity
* without affecting the linear velocity of the center of mass.
* This wakes up the body.
+ * @param body body
* @param torque torque about the z-axis (out of the screen), usually in N-m.
*/
- export function apply_torque(torque: number): void;
+ export function apply_torque(body: typeof b2d.body, torque: number): void;
/**
* Print the body representation to the log output
+ * @param body body
*/
- export function dump(): void;
+ export function dump(body: typeof b2d.body): void;
/**
* Get the angular damping of the body.
+ * @param body body
* @return damping the damping
*/
- export function get_angular_damping(): number;
+ export function get_angular_damping(body: typeof b2d.body): number;
/**
* Set the angular velocity.
+ * @param body body
* @param omega the new angular velocity in radians/second.
*/
- export function get_angular_velocity(omega: number): void;
+ export function get_angular_velocity(
+ body: typeof b2d.body,
+ omega: number,
+ ): void;
/**
* Get the angular velocity.
+ * @param body body
* @return velocity the angular velocity in radians/second.
*/
- export function get_angular_velocity(): number;
+ export function get_angular_velocity(body: typeof b2d.body): number;
/**
* Get the gravity scale of the body.
+ * @param body body
* @return scale the scale
*/
- export function get_gravity_scale(): number;
+ export function get_gravity_scale(body: typeof b2d.body): number;
/**
* Get the rotational inertia of the body about the local origin.
+ * @param body body
* @return inertia the rotational inertia, usually in kg-m^2.
*/
- export function get_inertia(): number;
+ export function get_inertia(body: typeof b2d.body): number;
/**
* Get the linear damping of the body.
+ * @param body body
* @return damping the damping
*/
- export function get_linear_damping(): number;
+ export function get_linear_damping(body: typeof b2d.body): number;
/**
* Get the linear velocity of the center of mass.
+ * @param body body
* @return velocity the linear velocity of the center of mass.
*/
- export function get_linear_velocity(): vmath.vector3;
+ export function get_linear_velocity(body: typeof b2d.body): vmath.vector3;
/**
- * Get the world linear velocity of a world point attached to this body.
- * @param world_point a point in world coordinates.
+ * Get the world velocity of a local point.
+ * @param body body
+ * @param local_point a point in local coordinates.
* @return velocity the world velocity of a point.
*/
- export function get_linear_velocity_from_world_point(
- world_point: vmath.vector3,
+ export function get_linear_velocity_from_local_point(
+ body: typeof b2d.body,
+ local_point: vmath.vector3,
): vmath.vector3;
/**
- * Get the world velocity of a local point.
- * @param world_point a point in local coordinates.
+ * Get the world linear velocity of a world point attached to this body.
+ * @param body body
+ * @param world_point a point in world coordinates.
* @return velocity the world velocity of a point.
*/
export function get_linear_velocity_from_world_point(
+ body: typeof b2d.body,
world_point: vmath.vector3,
): vmath.vector3;
/**
* Get the local position of the center of mass.
+ * @param body body
* @return center Get the local position of the center of mass.
*/
- export function get_local_center(): vmath.vector3;
+ export function get_local_center(body: typeof b2d.body): vmath.vector3;
/**
* Gets a local point relative to the body's origin given a world point.
+ * @param body body
* @param world_point a point in world coordinates.
* @return vector the corresponding local point relative to the body's origin.
*/
- export function get_local_point(world_point: vmath.vector3): vmath.vector3;
+ export function get_local_point(
+ body: typeof b2d.body,
+ world_point: vmath.vector3,
+ ): vmath.vector3;
/**
* Gets a local vector given a world vector.
+ * @param body body
* @param world_vector a vector in world coordinates.
* @return vector the corresponding local vector.
*/
- export function get_local_vector(world_vector: vmath.vector3): vmath.vector3;
+ export function get_local_vector(
+ body: typeof b2d.body,
+ world_vector: vmath.vector3,
+ ): vmath.vector3;
/**
* Get the total mass of the body.
+ * @param body body
* @return mass the mass, usually in kilograms (kg).
*/
- export function get_mass(): number;
+ export function get_mass(body: typeof b2d.body): number;
/**
* Get the next body in the world's body list.
+ * @param body body
* @return body the next body
*/
- export function get_next(): AnyNotNil | undefined;
+ export function get_next(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Get the world body origin position.
+ * @param body body
* @return position the world position of the body's origin.
*/
- export function get_position(): vmath.vector3;
+ export function get_position(body: typeof b2d.body): vmath.vector3;
/**
* Get the type of this body.
+ * @param body body
* @return type the body type
*/
- export function get_type(): AnyNotNil | undefined;
+ export function get_type(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Get the parent world of this body.
+ * @param body body
* @return world
*/
- export function get_world(): AnyNotNil | undefined;
+ export function get_world(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Get the angle in radians.
+ * @param body body
* @return angle the current world rotation angle in radians.
*/
- export function get_world_center(): number;
+ export function get_world_center(body: typeof b2d.body): number;
/**
* Get the world position of the center of mass.
+ * @param body body
* @return center Get the world position of the center of mass.
*/
- export function get_world_center(): vmath.vector3;
+ export function get_world_center(body: typeof b2d.body): vmath.vector3;
/**
* Get the world coordinates of a point given the local coordinates.
+ * @param body body
* @param local_vector localPoint a point on the body measured relative the the body's origin.
* @return vector the same point expressed in world coordinates.
*/
- export function get_world_point(local_vector: vmath.vector3): vmath.vector3;
+ export function get_world_point(
+ body: typeof b2d.body,
+ local_vector: vmath.vector3,
+ ): vmath.vector3;
/**
* Get the world coordinates of a vector given the local coordinates.
+ * @param body body
* @param local_vector a vector fixed in the body.
* @return vector the same vector expressed in world coordinates.
*/
- export function get_world_vector(local_vector: vmath.vector3): vmath.vector3;
+ export function get_world_vector(
+ body: typeof b2d.body,
+ local_vector: vmath.vector3,
+ ): vmath.vector3;
/**
* Get the active state of the body.
+ * @param body body
* @return enabled is the body active
*/
- export function is_active(): AnyNotNil | undefined;
+ export function is_active(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Get the sleeping state of this body.
+ * @param body body
* @return enabled true if the body is awake, false if it's sleeping.
*/
- export function is_awake(): AnyNotNil | undefined;
+ export function is_awake(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Is this body in bullet mode
+ * @param body body
* @return enabled true if the body is in bullet mode
*/
- export function is_bullet(): AnyNotNil | undefined;
+ export function is_bullet(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Does this body have fixed rotation?
+ * @param body body
* @return enabled is the rotation fixed
*/
- export function is_fixed_rotation(): AnyNotNil | undefined;
+ export function is_fixed_rotation(
+ body: typeof b2d.body,
+ ): AnyNotNil | undefined;
/**
* Is this body allowed to sleep
+ * @param body body
* @return enabled true if the body is allowed to sleep
*/
- export function is_sleeping_allowed(): AnyNotNil | undefined;
+ export function is_sleeping_allowed(
+ body: typeof b2d.body,
+ ): AnyNotNil | undefined;
/**
* This resets the mass properties to the sum of the mass properties of the fixtures.
* This normally does not need to be called unless you called SetMassData to override
+ * @param body body
*/
- export function reset_mass_data(): void;
+ export function reset_mass_data(body: typeof b2d.body): void;
/**
* Set the active state of the body. An inactive body is not
@@ -591,72 +658,108 @@ declare namespace b2d.body {
* Joints connected to an inactive body are implicitly inactive.
* An inactive body is still owned by a b2World object and remains
* in the body list.
+ * @param body body
* @param enable true if the body should be active
*/
- export function set_active(enable: any): void;
+ export function set_active(body: typeof b2d.body, enable: boolean): void;
/**
* Set the angular damping of the body.
+ * @param body body
* @param damping the damping
*/
- export function set_angular_damping(damping: number): void;
+ export function set_angular_damping(
+ body: typeof b2d.body,
+ damping: number,
+ ): void;
/**
* Set the sleep state of the body. A sleeping body has very low CPU cost.
+ * @param body body
* @param enable flag set to false to put body to sleep, true to wake it.
*/
- export function set_awake(enable: any): void;
+ export function set_awake(body: typeof b2d.body, enable: boolean): void;
/**
* Should this body be treated like a bullet for continuous collision detection?
+ * @param body body
* @param enable if true, the body will be in bullet mode
*/
- export function set_bullet(enable: any): void;
+ export function set_bullet(body: typeof b2d.body, enable: boolean): void;
/**
* Set this body to have fixed rotation. This causes the mass to be reset.
+ * @param body body
* @param enable true if the rotation should be fixed
*/
- export function set_fixed_rotation(enable: any): void;
+ export function set_fixed_rotation(
+ body: typeof b2d.body,
+ enable: boolean,
+ ): void;
/**
* Set the gravity scale of the body.
+ * @param body body
* @param scale the scale
*/
- export function set_gravity_scale(scale: number): void;
+ export function set_gravity_scale(body: typeof b2d.body, scale: number): void;
/**
* Set the linear damping of the body.
+ * @param body body
* @param damping the damping
*/
- export function set_linear_damping(damping: number): void;
+ export function set_linear_damping(
+ body: typeof b2d.body,
+ damping: number,
+ ): void;
/**
* Set the linear velocity of the center of mass.
+ * @param body body
* @param velocity the new linear velocity of the center of mass.
*/
- export function set_linear_velocity(velocity: vmath.vector3): void;
+ export function set_linear_velocity(
+ body: typeof b2d.body,
+ velocity: vmath.vector3,
+ ): void;
/**
* You can disable sleeping on this body. If you disable sleeping, the body will be woken.
+ * @param body body
* @param enable if false, the body will never sleep, and consume more CPU
*/
- export function set_sleeping_allowed(enable: any): void;
+ export function set_sleeping_allowed(
+ body: typeof b2d.body,
+ enable: boolean,
+ ): void;
/**
* Set the position of the body's origin and rotation.
* This breaks any contacts and wakes the other bodies.
* Manipulating a body's transform may cause non-physical behavior.
+ * @param body body
* @param position the world position of the body's local origin.
* @param angle the world position of the body's local origin.
*/
- export function set_transform(position: vmath.vector3, angle: number): void;
+ export function set_transform(
+ body: typeof b2d.body,
+ position: vmath.vector3,
+ angle: number,
+ ): void;
/**
* Set the type of this body. This may alter the mass and velocity.
+ * @param body body
* @param type the body type
*/
- export function set_type(type: any): void;
+ export function set_type(
+ body: typeof b2d.body,
+ type:
+ | typeof b2d.body.B2_DYNAMIC_BODY
+ | typeof b2d.body.B2_KINEMATIC_BODY
+ | typeof b2d.body.B2_STATIC_BODY,
+ ): void;
}
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
@@ -2728,7 +2831,7 @@ with a custom curve. See the animation guide for more information.
* @param recursive check hierarchy recursively
* @return enabled whether the node is enabled or not
*/
- export function is_enabled(node: node, recursive: boolean): boolean;
+ export function is_enabled(node: node, recursive?: boolean): boolean;
/**
* Alters the ordering of the two supplied nodes by moving the first node
@@ -3210,12 +3313,12 @@ the new state of the emitter:
/**
* Sets the parent node of the specified node.
* @param node node for which to set its parent
- * @param parent parent node to set
+ * @param parent parent node to set, pass `undefined` to remove parent
* @param keep_scene_transform optional flag to make the scene position being perserved
*/
export function set_parent(
node: node,
- parent: node,
+ parent?: node,
keep_scene_transform?: boolean,
): void;
@@ -3359,7 +3462,7 @@ the new state of the emitter:
* @param node node to set text for
* @param text text to set
*/
- export function set_text(node: node, text: string): void;
+ export function set_text(node: node, text: number | string): void;
/**
* Set the texture on a box or pie node. The texture must be mapped to
@@ -3650,6 +3753,34 @@ declare namespace physics {
readonly _JOINT_TYPE_: unique symbol;
};
+ /**
+ *
+ */
+ export const SHAPE_TYPE_BOX: number & {
+ readonly _SHAPE_TYPE_: unique symbol;
+ };
+
+ /**
+ *
+ */
+ export const SHAPE_TYPE_CAPSULE: number & {
+ readonly _SHAPE_TYPE_: unique symbol;
+ };
+
+ /**
+ *
+ */
+ export const SHAPE_TYPE_HULL: number & {
+ readonly _SHAPE_TYPE_: unique symbol;
+ };
+
+ /**
+ *
+ */
+ export const SHAPE_TYPE_SPHERE: number & {
+ readonly _SHAPE_TYPE_: unique symbol;
+ };
+
/**
* Create a physics joint between two collision object components.
* Note: Currently only supported in 2D physics.
@@ -3968,17 +4099,20 @@ See physics.get_shape for a detailed description of each field in the data table
`local function set_shape_data()
-- set capsule shape data
local data = {}
+ data.type = physics.SHAPE_TYPE_CAPSULE
data.diameter = 10
data.height = 20
physics.set_shape("#collisionobject", "my_capsule_shape", data)
-- set sphere shape data
data = {}
+ data.type = physics.SHAPE_TYPE_SPHERE
data.diameter = 10
physics.set_shape("#collisionobject", "my_sphere_shape", data)
-- set box shape data
data = {}
+ data.type = physics.SHAPE_TYPE_BOX
data.dimensions = vmath.vector3(10, 10, 5)
physics.set_shape("#collisionobject", "my_box_shape", data)
end
@@ -5151,6 +5285,26 @@ to enable those textures as well. Currently 4 color attachments are supported:
typeof render.BLEND_CONSTANT_ALPHA | typeof render.BLEND_CONSTANT_COLOR | typeof render.BLEND_DST_ALPHA | typeof render.BLEND_DST_COLOR | typeof render.BLEND_ONE | typeof render.BLEND_ONE_MINUS_CONSTANT_ALPHA | typeof render.BLEND_ONE_MINUS_CONSTANT_COLOR | typeof render.BLEND_ONE_MINUS_DST_ALPHA | typeof render.BLEND_ONE_MINUS_DST_COLOR | typeof render.BLEND_ONE_MINUS_SRC_ALPHA | typeof render.BLEND_ONE_MINUS_SRC_COLOR | typeof render.BLEND_SRC_ALPHA | typeof render.BLEND_SRC_ALPHA_SATURATE | typeof render.BLEND_SRC_COLOR | typeof render.BLEND_ZERO,
): void;
+ /**
+ * Sets the current render camera to be used for rendering. If a render camera
+ * has been set by the render script, the renderer will be using its projection and view matrix
+ * during rendering. If a projection and/or view matrix has been set by the render script,
+ * they will not be used until the current render camera has been reset by calling `render.set_camera()`.
+ * If the 'use_frustum' flag in the options table has been set to true, the renderer will automatically use the
+ * camera frustum for frustum culling regardless of what frustum is being passed into the render.draw() function.
+ * Note that the frustum plane option in render.draw can still be used together with the camera.
+ * @param camera camera id to use, or undefined to reset
+ * @param options optional table with properties:
+
+`use_frustum`
+If true, the renderer will use the cameras view-projection matrix for frustum culling (default: false)
+
+ */
+ export function set_camera(
+ camera: any,
+ options?: { use_frustum: boolean },
+ ): void;
+
/**
* Specifies whether the individual color components in the frame buffer is enabled for writing (`true`) or disabled (`false`). For example, if `blue` is `false`, nothing is written to the blue component of any pixel in any of the color buffers, regardless of the drawing operation attempted. Note that writing are either enabled or disabled for entire color components, not the individual bits of a component.
* The component masks are all initially `true`.
@@ -5959,13 +6113,14 @@ Creating an empty texture with no buffer data is not supported as a core feature
- `COMPRESSION_TYPE_BASIS_UASTC`
* @param buffer optional buffer of precreated pixel data
- * @return path_ The path to the resource and the request id for the async request.
+ * @return path The path to the resource.
+ * @return request_id The request id for the async request.
*/
export function create_texture_async(
path: string,
table: AnyNotNil,
buffer?: buffer,
- ): AnyNotNil | undefined;
+ ): LuaMultiReturn<[hash, any]>;
/**
* Constructor-like function with two purposes:
@@ -7373,7 +7528,7 @@ The response data. Contains the fields:
* @param options optional table with request parameters. Supported entries:
`timeout`: timeout in seconds
-Not available in HTML5 build
+Path should be absolute
Not available in HTML5 build
Not available in HTML5 build
@@ -8242,14 +8397,6 @@ declare namespace zlib {
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
declare namespace camera {
- /**
- * Post this message to a camera-component to activate it.
- * Several cameras can be active at the same time, but only the camera that was last activated will be used for rendering.
- * When the camera is deactivated (see `release_camera_focus`), the previously activated camera will again be used for rendering automatically.
- * The reason it is called "camera focus" is the similarity to how acquiring input focus works (see `acquire_input_focus`).
- */
- export type acquire_camera_focus = 'acquire_camera_focus';
-
/**
* The ratio between the frustum width and height. Used when calculating the
* projection of a perspective camera.
@@ -8257,18 +8404,6 @@ declare namespace camera {
*/
export let aspect_ratio: number;
- /**
- * makes camera active
- * @param url url of camera component
- */
- export function acquire_focus(url: hash | url | string): void;
-
- /**
- * deactivate camera
- * @param url url of camera component
- */
- export function release_focus(url: hash | url | string): void;
-
/**
* Camera frustum far plane.
* The type of the property is float.
@@ -8299,14 +8434,6 @@ declare namespace camera {
*/
export const projection: Readonly;
- /**
- *
- * Post this message to a camera-component to deactivate it. The camera is then removed from the active cameras.
- * See `acquire_camera_focus` for more information how the active cameras are used in rendering.
- *
- */
- export type release_camera_focus = 'release_camera_focus';
-
/**
*
* Post this message to a camera-component to set its properties at run-time.