@ts-defold/types 1.2.73 → 1.2.75

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.
Files changed (2) hide show
  1. package/index.d.ts +148 -40
  2. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -3,8 +3,35 @@
3
3
  /// <reference types="lua-types/5.1" />
4
4
  /// <reference types="lua-types/special/jit-only" />
5
5
 
6
- // DEFOLD. stable version 1.11.0 (7c81792859a6da7f7401c0ac37a4cc83bb500ff6)
6
+ // DEFOLD. stable version 1.11.2 (a6d86c0083f00ee6c3709478ff3b33deff5e6d19)
7
7
 
8
+ /**
9
+ * All ids in the engine are represented as hashes, so a string needs to be hashed
10
+ before it can be compared with an id.
11
+ * @param s string to hash
12
+ * @returns a hashed string
13
+ * @example To compare a message_id in an on-message callback function:
14
+ ```lua
15
+ function on_message(self, message_id, message, sender)
16
+ if message_id == hash("my_message") then
17
+ -- Act on the message here
18
+ end
19
+ end
20
+ ```
21
+ */
22
+ declare function hash(s: string): hash;
23
+ /**
24
+ * Returns a hexadecimal representation of a hash value.
25
+ The returned string is always padded with leading zeros.
26
+ * @param h hash value to get hex string for
27
+ * @returns hex representation of the hash
28
+ * @example ```lua
29
+ local h = hash("my_hash")
30
+ local hexstr = hash_to_hex(h)
31
+ print(hexstr) --> a2bc06d97f580aab
32
+ ```
33
+ */
34
+ declare function hash_to_hex(h: hash): string;
8
35
  /**
9
36
  * Pretty printing of Lua values. This function prints Lua values
10
37
  in a manner similar to +print()+, but will also recurse into tables
@@ -34,33 +61,6 @@ Lua tables is undefined):
34
61
  ```
35
62
  */
36
63
  declare function pprint(...v: any[]): void;
37
- /**
38
- * All ids in the engine are represented as hashes, so a string needs to be hashed
39
- before it can be compared with an id.
40
- * @param s string to hash
41
- * @returns a hashed string
42
- * @example To compare a message_id in an on-message callback function:
43
- ```lua
44
- function on_message(self, message_id, message, sender)
45
- if message_id == hash("my_message") then
46
- -- Act on the message here
47
- end
48
- end
49
- ```
50
- */
51
- declare function hash(s: string): hash;
52
- /**
53
- * Returns a hexadecimal representation of a hash value.
54
- The returned string is always padded with leading zeros.
55
- * @param h hash value to get hex string for
56
- * @returns hex representation of the hash
57
- * @example ```lua
58
- local h = hash("my_hash")
59
- local hexstr = hash_to_hex(h)
60
- print(hexstr) --> a2bc06d97f580aab
61
- ```
62
- */
63
- declare function hash_to_hex(h: hash): string;
64
64
  /**
65
65
  * A unique identifier used to reference resources, messages, properties, and other entities within the game.
66
66
  */
@@ -546,6 +546,20 @@ export function set_metadata(buf: buffer, metadata_name: hash | string, values:
546
546
  }
547
547
 
548
548
  declare namespace camera {
549
+ /**
550
+ * Computes zoom so the original display area covers the entire window while preserving aspect ratio.
551
+ Equivalent to using max(window_width/width, window_height/height).
552
+ */
553
+ export const ORTHO_MODE_AUTO_COVER: number;
554
+ /**
555
+ * Computes zoom so the original display area (game.project width/height) fits inside the window
556
+ while preserving aspect ratio. Equivalent to using min(window_width/width, window_height/height).
557
+ */
558
+ export const ORTHO_MODE_AUTO_FIT: number;
559
+ /**
560
+ * Uses the manually set orthographic zoom value (camera.set_orthographic_zoom).
561
+ */
562
+ export const ORTHO_MODE_FIXED: number;
549
563
  /**
550
564
  * Gets the effective aspect ratio of the camera. If auto aspect ratio is enabled,
551
565
  returns the aspect ratio calculated from the current render target dimensions.
@@ -598,6 +612,13 @@ export function get_fov(camera: url | number | undefined): number;
598
612
  * @returns the near z.
599
613
  */
600
614
  export function get_near_z(camera: url | number | undefined): number;
615
+ /**
616
+ * get orthographic zoom mode
617
+ * @param camera camera id
618
+ * @returns one of camera.ORTHO_MODE_FIXED, camera.ORTHO_MODE_AUTO_FIT or
619
+ camera.ORTHO_MODE_AUTO_COVER
620
+ */
621
+ export function get_orthographic_mode(camera: url | number | undefined): number;
601
622
  /**
602
623
  * get orthographic zoom
603
624
  * @param camera camera id
@@ -650,6 +671,12 @@ export function set_fov(camera: url | number | undefined, fov: number): void;
650
671
  * @param near_z the near z.
651
672
  */
652
673
  export function set_near_z(camera: url | number | undefined, near_z: number): void;
674
+ /**
675
+ * set orthographic zoom mode
676
+ * @param camera camera id
677
+ * @param mode camera.ORTHO_MODE_FIXED, camera.ORTHO_MODE_AUTO_FIT or camera.ORTHO_MODE_AUTO_COVER
678
+ */
679
+ export function set_orthographic_mode(camera: url | number | undefined, mode: number): void;
653
680
  /**
654
681
  * set orthographic zoom
655
682
  * @param camera camera id
@@ -1643,6 +1670,7 @@ local s = go.get_scale_uniform("x")
1643
1670
  export function get_scale_uniform(id?: string | hash | url): number;
1644
1671
  /**
1645
1672
  * The function will return the world position calculated at the end of the previous frame.
1673
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1646
1674
  Use go.get_position to retrieve the position relative to the parent.
1647
1675
  * @param id optional id of the game object instance to get the world position for, by default the instance of the calling script
1648
1676
  * @returns instance world position
@@ -1659,6 +1687,7 @@ local p = go.get_world_position("x")
1659
1687
  export function get_world_position(id?: string | hash | url): vmath.vector3;
1660
1688
  /**
1661
1689
  * The function will return the world rotation calculated at the end of the previous frame.
1690
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1662
1691
  Use go.get_rotation to retrieve the rotation relative to the parent.
1663
1692
  * @param id optional id of the game object instance to get the world rotation for, by default the instance of the calling script
1664
1693
  * @returns instance world rotation
@@ -1675,6 +1704,7 @@ local r = go.get_world_rotation("x")
1675
1704
  export function get_world_rotation(id?: string | hash | url): vmath.quaternion;
1676
1705
  /**
1677
1706
  * The function will return the world 3D scale factor calculated at the end of the previous frame.
1707
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1678
1708
  Use go.get_scale to retrieve the 3D scale factor relative to the parent.
1679
1709
  This vector is derived by decomposing the transformation matrix and should be used with care.
1680
1710
  For most cases it should be fine to use go.get_world_scale_uniform instead.
@@ -1693,6 +1723,7 @@ local s = go.get_world_scale("x")
1693
1723
  export function get_world_scale(id?: string | hash | url): vmath.vector3;
1694
1724
  /**
1695
1725
  * The function will return the world scale factor calculated at the end of the previous frame.
1726
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1696
1727
  Use go.get_scale_uniform to retrieve the scale factor relative to the parent.
1697
1728
  * @param id optional id of the game object instance to get the world scale for, by default the instance of the calling script
1698
1729
  * @returns instance world scale factor
@@ -1709,6 +1740,7 @@ local s = go.get_world_scale_uniform("x")
1709
1740
  export function get_world_scale_uniform(id?: string | hash | url): number;
1710
1741
  /**
1711
1742
  * The function will return the world transform matrix calculated at the end of the previous frame.
1743
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1712
1744
  * @param id optional id of the game object instance to get the world transform for, by default the instance of the calling script
1713
1745
  * @returns instance world transform
1714
1746
  * @example Get the world transform of the game object instance the script is attached to:
@@ -2213,6 +2245,26 @@ end
2213
2245
  ```
2214
2246
  */
2215
2247
  export function update(this: LuaUserdata, dt: number): void;
2248
+ /**
2249
+ * Recalculates and updates the cached world transform immediately for the target instance
2250
+ and its ancestors (parent chain up to the collection root). Descendants (children) are
2251
+ not updated by this function.
2252
+ If no id is provided, the instance of the calling script is used.
2253
+ ⚠ Use this after changing local transform mid-frame when you need the
2254
+ new world transform right away (e.g. before end-of-frame updates). Note that child
2255
+ instances will still have last-frame world transforms until the regular update.
2256
+ * @param id optional id of the game object instance to update
2257
+ * @example Update this game object's world transform:
2258
+ ```lua
2259
+ go.update_world_transform()
2260
+ ```
2261
+
2262
+ Update another game object's world transform:
2263
+ ```lua
2264
+ go.update_world_transform("/other")
2265
+ ```
2266
+ */
2267
+ export function update_world_transform(id?: string | hash | url): void;
2216
2268
  /**
2217
2269
  * ⚠ The function uses world transformation calculated at the end of previous frame.
2218
2270
  * @param position position which need to be converted
@@ -2415,7 +2467,7 @@ export const TEXTURE_FORMAT_RGBA_16BPP: number;
2415
2467
  /**
2416
2468
  * May be nil if the graphics driver doesn't support it
2417
2469
  */
2418
- export let TEXTURE_FORMAT_RGBA_ASTC_4x4: number;
2470
+ export const TEXTURE_FORMAT_RGBA_ASTC_4X4: number;
2419
2471
  /**
2420
2472
  * May be nil if the graphics driver doesn't support it
2421
2473
  */
@@ -3010,9 +3062,9 @@ end
3010
3062
  */
3011
3063
  export function animate(node: node, property: string | number, to: number | vmath.vector3 | vmath.vector4 | vmath.quaternion, easing: number | vmath.vector3 | vmath.vector4 | vmath.quaternion | ReturnType<typeof vmath.vector>, duration: number, delay?: number, complete_function?: (this: any, node: node,) => void, playback?: number): void;
3012
3064
  /**
3013
- * If an animation of the specified node is currently running (started by `gui.animate`), it will immediately be canceled.
3065
+ * If one or more animations of the specified node is currently running (started by `gui.animate`), they will immediately be canceled.
3014
3066
  * @param node node that should have its animation canceled
3015
- * @param property property for which the animation should be canceled
3067
+ * @param property optional property for which the animation should be canceled
3016
3068
 
3017
3069
  `"position"`
3018
3070
  `"rotation"`
@@ -3037,10 +3089,21 @@ local pos = vmath.vector3(100, 100, 0)
3037
3089
  gui.animate(node, "position", pos, go.EASING_LINEAR, 2)
3038
3090
  ...
3039
3091
  -- cancel animation of the x component.
3040
- gui.cancel_animation(node, "position.x")
3092
+ gui.cancel_animations(node, "position.x")
3093
+ ```
3094
+
3095
+ Cancels all property animations on a node in a single call:
3096
+ ```lua
3097
+ local node = gui.get_node("my_node")
3098
+ -- animate to new position and scale
3099
+ gui.animate(node, "position", vmath.vector3(100, 100, 0), go.EASING_LINEAR, 5)
3100
+ gui.animate(node, "scale", vmath.vector3(0.5), go.EASING_LINEAR, 5)
3101
+ ...
3102
+ -- cancel positioning and scaling at once
3103
+ gui.cancel_animations(node)
3041
3104
  ```
3042
3105
  */
3043
- export function cancel_animation(node: node, property: string | number): void;
3106
+ export function cancel_animations(node: node, property?: undefined | string | number): void;
3044
3107
  /**
3045
3108
  * Cancels any running flipbook animation on the specified node.
3046
3109
  * @param node node cancel flipbook animation for
@@ -3344,6 +3407,12 @@ export function get_layer(node: node): hash;
3344
3407
  * @returns layout id
3345
3408
  */
3346
3409
  export function get_layout(): hash;
3410
+ /**
3411
+ * Returns a table mapping each layout id hash to a vector3(width, height, 0). For the default layout,
3412
+ the current scene resolution is returned. If a layout name is not present in the Display Profiles (or when
3413
+ no display profiles are assigned), the width/height pair is 0.
3414
+ */
3415
+ export function get_layouts(): LuaMap<hash, vmath.vector3>;
3347
3416
  /**
3348
3417
  * Returns the leading value for a text node.
3349
3418
  * @param node node from where to get the leading
@@ -4279,6 +4348,14 @@ export function set_inner_radius(node: node, radius: number): void;
4279
4348
  * @param layer layer id
4280
4349
  */
4281
4350
  export function set_layer(node: node, layer: string | hash): void;
4351
+ /**
4352
+ * Applies a named layout on the GUI scene. This re-applies per-layout node descriptors
4353
+ and, if a matching Display Profile exists, updates the scene resolution. Emits
4354
+ the "layout_changed" message to the scene script when the layout actually changes.
4355
+ * @param layout the layout id to apply
4356
+ * @returns true if the layout exists in the scene and was applied, false otherwise
4357
+ */
4358
+ export function set_layout(layout: string | hash): boolean;
4282
4359
  /**
4283
4360
  * Sets the leading value for a text node. This value is used to
4284
4361
  scale the line spacing of text.
@@ -6237,6 +6314,18 @@ declare namespace render {
6237
6314
  export const FRUSTUM_PLANES_ALL: number;
6238
6315
  export const FRUSTUM_PLANES_SIDES: number;
6239
6316
  export const RENDER_TARGET_DEFAULT: number;
6317
+ /**
6318
+ * Depth sort far-to-near (default; good for transparent passes).
6319
+ */
6320
+ export const SORT_BACK_TO_FRONT: number;
6321
+ /**
6322
+ * Depth sort near-to-far (good for opaque passes to reduce overdraw).
6323
+ */
6324
+ export const SORT_FRONT_TO_BACK: number;
6325
+ /**
6326
+ * No per-call sorting; draw entries in insertion order.
6327
+ */
6328
+ export const SORT_NONE: number;
6240
6329
  /**
6241
6330
  * Clear buffers in the currently enabled render target with specified value. If the render target has been created with multiple
6242
6331
  color attachments, all buffers will be cleared with the same value.
@@ -6405,6 +6494,8 @@ render.FRUSTUM_PLANES_ALL : All 6 sides of the frustum.
6405
6494
 
6406
6495
  `constants`
6407
6496
  constant_buffer optional constants to use while rendering
6497
+ `sort_order`
6498
+ int How to sort draw order for world-ordered entries. Default uses the renderer's preferred world sorting (back-to-front).
6408
6499
 
6409
6500
  * @example ```lua
6410
6501
  function init(self)
@@ -7527,6 +7618,7 @@ export function create_atlas(path: string, table: { texture: string | hash; anim
7527
7618
  height: number;
7528
7619
  pivot_x: number;
7529
7620
  pivot_y: number;
7621
+ rotated: boolean;
7530
7622
  vertices: number[] | LuaSet<number>;
7531
7623
  uvs: number[] | LuaSet<number>;
7532
7624
  indices: number[] | LuaSet<number>;
@@ -7671,7 +7763,7 @@ These constants might not be available on the device:
7671
7763
  `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
7672
7764
  `graphics.TEXTURE_FORMAT_RGB_ETC1`
7673
7765
  `graphics.TEXTURE_FORMAT_RGBA_ETC2`
7674
- `graphics.TEXTURE_FORMAT_RGBA_ASTC_4x4`
7766
+ `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
7675
7767
  `graphics.TEXTURE_FORMAT_RGB_BC1`
7676
7768
  `graphics.TEXTURE_FORMAT_RGBA_BC3`
7677
7769
  `graphics.TEXTURE_FORMAT_R_BC4`
@@ -7841,7 +7933,7 @@ These constants might not be available on the device:
7841
7933
  `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
7842
7934
  `graphics.TEXTURE_FORMAT_RGB_ETC1`
7843
7935
  `graphics.TEXTURE_FORMAT_RGBA_ETC2`
7844
- `graphics.TEXTURE_FORMAT_RGBA_ASTC_4x4`
7936
+ `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
7845
7937
  `graphics.TEXTURE_FORMAT_RGB_BC1`
7846
7938
  `graphics.TEXTURE_FORMAT_RGBA_BC3`
7847
7939
  `graphics.TEXTURE_FORMAT_R_BC4`
@@ -7883,6 +7975,7 @@ Creating an empty texture with no buffer data is not supported as a core feature
7883
7975
  `COMPRESSION_TYPE_BASIS_UASTC`
7884
7976
 
7885
7977
  * @param buffer optional buffer of precreated pixel data
7978
+ * @param callback callback function when texture is created (self, request_id, resource)
7886
7979
  * @example Create a texture resource asyncronously with a buffer and a callback
7887
7980
  ```lua
7888
7981
  function callback(self, request_id, resource)
@@ -7955,7 +8048,7 @@ function init(self)
7955
8048
  end
7956
8049
  ```
7957
8050
  */
7958
- export function create_texture_async(path: string | hash, table: { type: number; width: number; height: number; depth: number; format: number; flags: number; max_mipmaps?: number; compression_type?: number }, buffer?: buffer): LuaMultiReturn<[hash, number]>;
8051
+ export function create_texture_async(path: string | hash, table: { type: number; width: number; height: number; depth: number; format: number; flags: number; max_mipmaps?: number; compression_type?: number }, buffer: buffer, callback?: (this: any, request_id: number, resource: hash) => void): LuaMultiReturn<[hash, number]>;
7959
8052
  /**
7960
8053
  * Constructor-like function with two purposes:
7961
8054
 
@@ -8516,7 +8609,7 @@ These constants might not be available on the device:
8516
8609
  - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
8517
8610
  - `graphics.TEXTURE_FORMAT_RGB_ETC1`
8518
8611
  - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
8519
- - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4x4`
8612
+ - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
8520
8613
  - `graphics.TEXTURE_FORMAT_RGB_BC1`
8521
8614
  - `graphics.TEXTURE_FORMAT_RGBA_BC3`
8522
8615
  - `graphics.TEXTURE_FORMAT_R_BC4`
@@ -9610,6 +9703,10 @@ number sound gain between 0 and 1, default is 1. The final gain of the sound wil
9610
9703
  number sound pan between -1 and 1, default is 0. The final pan of the sound will be an addition of this pan and the sound pan.
9611
9704
  `speed`
9612
9705
  number sound speed where 1.0 is normal speed, 0.5 is half speed and 2.0 is double speed. The final speed of the sound will be a multiplication of this speed and the sound speed.
9706
+ `start_time`
9707
+ number start playback offset (seconds). Optional, mutually exclusive with `start_frame`.
9708
+ `start_frame`
9709
+ number start playback offset (frames/samples). Optional, mutually exclusive with `start_time`. If both are provided, `start_frame` is used.
9613
9710
 
9614
9711
  * @param complete_function function to call when the sound has finished playing or stopped manually via sound.stop.
9615
9712
 
@@ -9647,7 +9744,7 @@ function init(self)
9647
9744
  end
9648
9745
  ```
9649
9746
  */
9650
- export function play(url: string | hash | url, play_properties?: { delay?: number; gain?: number; pan?: number; speed?: number }, complete_function?: (this: any, message_id: hash, message: { play_id: number }, sender: url,) => void): number;
9747
+ export function play(url: string | hash | url, play_properties?: { delay?: number; gain?: number; pan?: number; speed?: number; start_time?: number; start_frame?: number }, complete_function?: (this: any, message_id: hash, message: { play_id: number }, sender: url,) => void): number;
9651
9748
  /**
9652
9749
  * Set gain on all active playing voices of a sound.
9653
9750
  * @param url the sound to set the gain of
@@ -10040,8 +10137,8 @@ print(my_file_path) --> /home/foobar/.local/share/my_game/my_file
10040
10137
  -- Android package name: com.foobar.packagename
10041
10138
  print(my_file_path) --> /data/data/0/com.foobar.packagename/files/my_file
10042
10139
 
10043
- -- iOS: /var/mobile/Containers/Data/Application/123456AB-78CD-90DE-12345678ABCD/my_game/my_file
10044
- print(my_file_path) --> /var/containers/Bundle/Applications/123456AB-78CD-90DE-12345678ABCD/my_game.app
10140
+ -- iOS: my_game.app
10141
+ print(my_file_path) --> /var/mobile/Containers/Data/Application/123456AB-78CD-90DE-12345678ABCD/my_game/my_file
10045
10142
 
10046
10143
  -- HTML5 path inside the IndexedDB: /data/.my_game/my_file or /.my_game/my_file
10047
10144
  print(my_file_path) --> /data/.my_game/my_file
@@ -11489,6 +11586,9 @@ print(vec - vmath.vector4(2.0)) --> vmath.vector4(-1, 0, 1, 2)
11489
11586
  */
11490
11587
  export function vector4(x: number, y: number, z: number, w: number): vmath.vector4;
11491
11588
  }declare namespace vmath {
11589
+ export function clamp(value: number, min: number | vmath.vector3 | vmath.vector4, max: number | vmath.vector3 | vmath.vector4): number;
11590
+ export function clamp(value: vmath.vector3, min: number | vmath.vector3 | vmath.vector4, max: number | vmath.vector3 | vmath.vector4): vmath.vector3;
11591
+ export function clamp(value: vmath.vector4, min: number | vmath.vector3 | vmath.vector4, max: number | vmath.vector3 | vmath.vector4): vmath.vector4;
11492
11592
  export type matrix4 = number & {
11493
11593
  /**
11494
11594
  * Multiplication Operator for Matrix4
@@ -11517,6 +11617,12 @@ export type matrix4 = number & {
11517
11617
  m33: number;
11518
11618
  m34: number;
11519
11619
  };
11620
+ export function mul_per_elem(v1: vmath.vector3, v2: vmath.vector3): vmath.vector3;
11621
+ export function mul_per_elem(v1: vmath.vector4, v2: vmath.vector4): vmath.vector4;
11622
+ export function normalize(v1: vmath.vector3): vmath.vector3;
11623
+ export function normalize(v1: vmath.vector4): vmath.vector4;
11624
+ export function normalize(v1: vmath.quaternion): vmath.quaternion;
11625
+ export function normalize(v1: vmath.vector): vmath.vector;
11520
11626
  export type quaternion = number & {
11521
11627
  /**
11522
11628
  * Multiplication Operator for Matrix4
@@ -11528,6 +11634,8 @@ export type quaternion = number & {
11528
11634
  z: number;
11529
11635
  w: number;
11530
11636
  };
11637
+ export function slerp(t: number, v1: vmath.vector3, v2: vmath.vector3): vmath.vector3;
11638
+ export function slerp(t: number, v1: vmath.vector4, v2: vmath.vector4): vmath.vector4;
11531
11639
  export type vector = number & { [key: number]: number };
11532
11640
  export type vector3 = number & {
11533
11641
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-defold/types",
3
- "version": "1.2.73",
3
+ "version": "1.2.75",
4
4
  "description": "TypeScript definitions for Defold",
5
5
  "repository": "github:ts-defold/types",
6
6
  "keywords": [
@@ -29,7 +29,7 @@
29
29
  "devDependencies": {
30
30
  "tsd-ext-type-gen": "^2.0.0",
31
31
  "typescript": "5.8.2",
32
- "typescript-to-lua": "~1.31.0"
32
+ "typescript-to-lua": "~1.32.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "typescript-to-lua": "^1.10.0"