@defold-typescript/types 0.39.0 → 0.40.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 +117 -0
- package/api-signatures.json +262 -237
- package/examples/translations.json +81 -81
- package/generated/b2d_shape.d.ts +23 -1
- package/generated/buffer.d.ts +18 -15
- package/generated/camera.d.ts +2 -2
- package/generated/collectionfactory.d.ts +12 -10
- package/generated/collectionproxy.d.ts +1 -1
- package/generated/compute.d.ts +1 -1
- package/generated/go.d.ts +9 -5
- package/generated/graphics.d.ts +52 -0
- package/generated/gui.d.ts +53 -32
- package/generated/html5.d.ts +3 -1
- package/generated/http.d.ts +4 -2
- package/generated/image.d.ts +24 -15
- package/generated/kinds/gui-script.d.ts +1 -0
- package/generated/kinds/render-script.d.ts +1 -0
- package/generated/kinds/script.d.ts +1 -0
- package/generated/material.d.ts +1 -1
- package/generated/model.d.ts +32 -3
- package/generated/physics.d.ts +13 -11
- package/generated/profiler.d.ts +1 -1
- package/generated/render.d.ts +72 -15
- package/generated/resource.d.ts +100 -69
- package/generated/socket.d.ts +23 -13
- package/generated/sound.d.ts +3 -3
- package/generated/sprite.d.ts +9 -1
- package/generated/sys.d.ts +34 -23
- package/generated/versions/defold-1.12.4/buffer.d.ts +18 -15
- package/generated/versions/defold-1.12.4/camera.d.ts +2 -2
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +12 -10
- package/generated/versions/defold-1.12.4/go.d.ts +9 -5
- package/generated/versions/defold-1.12.4/gui.d.ts +47 -31
- package/generated/versions/defold-1.12.4/html5.d.ts +3 -1
- package/generated/versions/defold-1.12.4/http.d.ts +4 -2
- package/generated/versions/defold-1.12.4/image.d.ts +24 -15
- package/generated/versions/defold-1.12.4/index.d.ts +1 -0
- package/generated/versions/defold-1.12.4/model.d.ts +32 -3
- package/generated/versions/defold-1.12.4/physics.d.ts +13 -11
- package/generated/versions/defold-1.12.4/profiler.d.ts +1 -1
- package/generated/versions/defold-1.12.4/render.d.ts +72 -15
- package/generated/versions/defold-1.12.4/resource.d.ts +100 -69
- package/generated/versions/defold-1.12.4/socket.d.ts +23 -13
- package/generated/versions/defold-1.12.4/sound.d.ts +3 -3
- package/generated/versions/defold-1.12.4/sprite.d.ts +9 -1
- package/generated/versions/defold-1.12.4/sys.d.ts +34 -23
- package/generated/versions/defold-1.12.4/vmath.d.ts +5 -5
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +23 -1
- package/generated/versions/defold-1.13.0/buffer.d.ts +18 -15
- package/generated/versions/defold-1.13.0/camera.d.ts +2 -2
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +12 -10
- package/generated/versions/defold-1.13.0/compute.d.ts +1 -1
- package/generated/versions/defold-1.13.0/go.d.ts +9 -5
- package/generated/versions/defold-1.13.0/graphics.d.ts +48 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +47 -31
- package/generated/versions/defold-1.13.0/html5.d.ts +3 -1
- package/generated/versions/defold-1.13.0/http.d.ts +4 -2
- package/generated/versions/defold-1.13.0/image.d.ts +24 -15
- package/generated/versions/defold-1.13.0/index.d.ts +1 -0
- package/generated/versions/defold-1.13.0/material.d.ts +1 -1
- package/generated/versions/defold-1.13.0/model.d.ts +32 -3
- package/generated/versions/defold-1.13.0/physics.d.ts +13 -11
- package/generated/versions/defold-1.13.0/profiler.d.ts +1 -1
- package/generated/versions/defold-1.13.0/render.d.ts +72 -15
- package/generated/versions/defold-1.13.0/resource.d.ts +100 -69
- package/generated/versions/defold-1.13.0/socket.d.ts +23 -13
- package/generated/versions/defold-1.13.0/sound.d.ts +3 -3
- package/generated/versions/defold-1.13.0/sprite.d.ts +9 -1
- package/generated/versions/defold-1.13.0/sys.d.ts +34 -23
- package/generated/versions/defold-1.13.0/vmath.d.ts +5 -5
- package/generated/vmath.d.ts +5 -5
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/scripts/generate-api-signatures.ts +2 -1
- package/scripts/prose-constants.ts +96 -0
- package/scripts/regen.ts +6 -2
- package/src/component-properties.d.ts +33 -0
- package/src/core-types.ts +4 -2
- package/src/custom-messages.d.ts +4 -3
- package/src/doc-comment.ts +35 -12
- package/src/emit-dts.ts +457 -47
- package/src/engine-globals.d.ts +2 -2
- package/src/go-overloads.d.ts +11 -10
- package/src/index.ts +4 -0
- package/src/param-correction-provenance.ts +67 -0
- package/src/render-overloads.d.ts +15 -0
- package/src/script-api.ts +3 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import type { Hash, Opaque, Quaternion, Url, Vector, Vector3, Vector4 } from "../../../src/core-types";
|
|
2
|
+
import type { Hash, Matrix4, Opaque, Quaternion, Url, Vector, Vector3, Vector4 } from "../../../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
5
|
/**
|
|
@@ -622,15 +622,15 @@ declare global {
|
|
|
622
622
|
* const node = gui.get_node("my_node");
|
|
623
623
|
* // animate to new position
|
|
624
624
|
* const pos = vmath.vector3(100, 100, 0);
|
|
625
|
-
* gui.animate(node, "position", pos,
|
|
625
|
+
* gui.animate(node, "position", pos, gui.EASING_LINEAR, 2);
|
|
626
626
|
* // ...
|
|
627
627
|
* // cancel animation of the x component.
|
|
628
628
|
* gui.cancel_animations(node, "position.x");
|
|
629
629
|
*
|
|
630
630
|
* // Cancels all property animations on a node in a single call:
|
|
631
631
|
* // animate to new position and scale
|
|
632
|
-
* gui.animate(node, "position", vmath.vector3(100, 100, 0),
|
|
633
|
-
* gui.animate(node, "scale", vmath.vector3(0.5),
|
|
632
|
+
* gui.animate(node, "position", vmath.vector3(100, 100, 0), gui.EASING_LINEAR, 5);
|
|
633
|
+
* gui.animate(node, "scale", vmath.vector3(0.5), gui.EASING_LINEAR, 5);
|
|
634
634
|
* // ...
|
|
635
635
|
* // cancel positioning and scaling at once
|
|
636
636
|
* gui.cancel_animations(node);
|
|
@@ -711,6 +711,10 @@ declare global {
|
|
|
711
711
|
* @example
|
|
712
712
|
* ```ts
|
|
713
713
|
* export default defineScript({
|
|
714
|
+
* init() {
|
|
715
|
+
* return { some_value: 0 };
|
|
716
|
+
* },
|
|
717
|
+
*
|
|
714
718
|
* final(self) {
|
|
715
719
|
* // report finalization
|
|
716
720
|
* msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
|
|
@@ -758,7 +762,7 @@ declare global {
|
|
|
758
762
|
* @param node - node to get the property for
|
|
759
763
|
* @param property - the property to retrieve
|
|
760
764
|
* @param options - optional options table (only applicable for material constants)
|
|
761
|
-
* - `index` number index into array property
|
|
765
|
+
* - `index` number zero-based index into array property; the transpiler emits Defold's 1-based index
|
|
762
766
|
* @example
|
|
763
767
|
* ```ts
|
|
764
768
|
* // Get properties on existing nodes:
|
|
@@ -1380,12 +1384,14 @@ declare global {
|
|
|
1380
1384
|
* const size = 4;
|
|
1381
1385
|
* const pos = vmath.vector3(200, 200, 0);
|
|
1382
1386
|
* const path = "/assets/images/logo_4x4.astc";
|
|
1383
|
-
* const
|
|
1384
|
-
*
|
|
1385
|
-
*
|
|
1386
|
-
*
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1387
|
+
* const [data] = sys.load_resource(path);
|
|
1388
|
+
* if (data !== undefined) {
|
|
1389
|
+
* const n = gui.new_box_node(pos, vmath.vector3(size, size, 0));
|
|
1390
|
+
* // size is read from the .astc buffer
|
|
1391
|
+
* // flip is not supported
|
|
1392
|
+
* gui.new_texture(path, 0, 0, "astc", data, false);
|
|
1393
|
+
* gui.set_texture(n, path);
|
|
1394
|
+
* }
|
|
1389
1395
|
* ```
|
|
1390
1396
|
*/
|
|
1391
1397
|
function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip?: boolean): LuaMultiReturn<[boolean, number]>;
|
|
@@ -1530,6 +1536,10 @@ declare global {
|
|
|
1530
1536
|
* @example
|
|
1531
1537
|
* ```ts
|
|
1532
1538
|
* export default defineGuiScript({
|
|
1539
|
+
* init(): { my_value: number | undefined } {
|
|
1540
|
+
* return { my_value: undefined };
|
|
1541
|
+
* },
|
|
1542
|
+
*
|
|
1533
1543
|
* on_input(self, action_id, action) {
|
|
1534
1544
|
* // check for input
|
|
1535
1545
|
* if (action_id === hash("my_action")) {
|
|
@@ -1563,6 +1573,10 @@ declare global {
|
|
|
1563
1573
|
* @example
|
|
1564
1574
|
* ```ts
|
|
1565
1575
|
* export default defineGuiScript({
|
|
1576
|
+
* init() {
|
|
1577
|
+
* return { my_original_color: gui.get_color(gui.get_node("my_node")) };
|
|
1578
|
+
* },
|
|
1579
|
+
*
|
|
1566
1580
|
* on_reload(self) {
|
|
1567
1581
|
* // restore some color (or similar)
|
|
1568
1582
|
* gui.set_color(gui.get_node("my_node"), self.my_original_color);
|
|
@@ -1745,13 +1759,13 @@ declare global {
|
|
|
1745
1759
|
* @param property - the property to set
|
|
1746
1760
|
* @param value - the property to set
|
|
1747
1761
|
* @param options - optional options table (only applicable for material constants)
|
|
1748
|
-
* - `index` number index into array property
|
|
1762
|
+
* - `index` number zero-based index into array property; the transpiler emits Defold's 1-based index
|
|
1749
1763
|
* - `key` hash name of internal property
|
|
1750
1764
|
* @example
|
|
1751
1765
|
* ```ts
|
|
1752
1766
|
* // Updates the position property on an existing node:
|
|
1753
1767
|
* const node = gui.get_node("my_box_node");
|
|
1754
|
-
* const node_position = gui.get(node, "position");
|
|
1768
|
+
* const node_position = gui.get(node, "position") as Vector3;
|
|
1755
1769
|
* gui.set(node, "position.x", node_position.x + 128);
|
|
1756
1770
|
*
|
|
1757
1771
|
* // Updates the rotation property on an existing node:
|
|
@@ -1768,23 +1782,23 @@ declare global {
|
|
|
1768
1782
|
* // matrix4 is also supported
|
|
1769
1783
|
* gui.set(node, "light_matrix", vmath.matrix4());
|
|
1770
1784
|
* // update a constant in an array at position 4. the array is specified in the shader as:
|
|
1771
|
-
* // uniform vec4 tint_array[4]; //
|
|
1772
|
-
* gui.set(node, "tint_array", vmath.vector4(1, 0, 0, 1), { index:
|
|
1785
|
+
* // uniform vec4 tint_array[4]; // TypeScript and the shader are both 0 based
|
|
1786
|
+
* gui.set(node, "tint_array", vmath.vector4(1, 0, 0, 1), { index: 3 });
|
|
1773
1787
|
* // update a matrix constant in an array at position 4. the array is specified in the shader as:
|
|
1774
1788
|
* // uniform mat4 light_matrix_array[4];
|
|
1775
|
-
* gui.set(node, "light_matrix_array", vmath.matrix4(), { index:
|
|
1789
|
+
* gui.set(node, "light_matrix_array", vmath.matrix4(), { index: 3 });
|
|
1776
1790
|
* // update a sub-element in a constant
|
|
1777
1791
|
* gui.set(node, "tint.x", 1);
|
|
1778
1792
|
* // update a sub-element in an array constant at position 4
|
|
1779
|
-
* gui.set(node, "tint_array.x", 1, { index:
|
|
1793
|
+
* gui.set(node, "tint_array.x", 1, { index: 3 });
|
|
1780
1794
|
*
|
|
1781
1795
|
* // Set a named property
|
|
1782
1796
|
* export default defineGuiScript({
|
|
1783
1797
|
* on_message(self, message_id, message) {
|
|
1784
|
-
* if (message_id === hash("set_font")) {
|
|
1798
|
+
* if (message_id === hash("set_font") && types.is_hash(message.font)) {
|
|
1785
1799
|
* gui.set(msg.url(), "fonts", message.font, { key: "my_font_name" });
|
|
1786
1800
|
* gui.set_font(gui.get_node("text"), "my_font_name");
|
|
1787
|
-
* } else if (message_id === hash("set_texture")) {
|
|
1801
|
+
* } else if (message_id === hash("set_texture") && types.is_hash(message.texture)) {
|
|
1788
1802
|
* gui.set(msg.url(), "textures", message.texture, { key: "my_texture" });
|
|
1789
1803
|
* gui.set_texture(gui.get_node("box"), "my_texture");
|
|
1790
1804
|
* gui.play_flipbook(gui.get_node("box"), "logo_256");
|
|
@@ -1793,7 +1807,7 @@ declare global {
|
|
|
1793
1807
|
* });
|
|
1794
1808
|
* ```
|
|
1795
1809
|
*/
|
|
1796
|
-
function set(node: Opaque<"node"> | Url, property: string | Hash | gui.Property, value: number | Vector4 | Vector3 | Quaternion, options?: { index?: number; key?: Hash }): void;
|
|
1810
|
+
function set(node: Opaque<"node"> | Url, property: string | Hash | gui.Property, value: number | Vector4 | Vector3 | Quaternion | Matrix4 | Hash, options?: { index?: number; key?: string | Hash }): void;
|
|
1797
1811
|
/**
|
|
1798
1812
|
* Sets the adjust mode on a node.
|
|
1799
1813
|
* The adjust mode defines how the node will adjust itself to screen
|
|
@@ -2099,7 +2113,7 @@ declare global {
|
|
|
2099
2113
|
* @param node - node to set the rotation for
|
|
2100
2114
|
* @param rotation - new rotation
|
|
2101
2115
|
*/
|
|
2102
|
-
function set_rotation(node: Opaque<"node">, rotation: Quaternion | Vector4): void;
|
|
2116
|
+
function set_rotation(node: Opaque<"node">, rotation: Quaternion | Vector4 | Vector3): void;
|
|
2103
2117
|
/**
|
|
2104
2118
|
* Sets how the safe area is applied to this gui scene.
|
|
2105
2119
|
*
|
|
@@ -2332,15 +2346,17 @@ declare global {
|
|
|
2332
2346
|
* // in a counting fashion. It is assumed that the gui component receives messages
|
|
2333
2347
|
* // from the game when a new score is to be shown.
|
|
2334
2348
|
* export default defineGuiScript({
|
|
2335
|
-
* init(
|
|
2336
|
-
*
|
|
2337
|
-
*
|
|
2338
|
-
*
|
|
2339
|
-
*
|
|
2340
|
-
*
|
|
2341
|
-
*
|
|
2342
|
-
*
|
|
2343
|
-
*
|
|
2349
|
+
* init() {
|
|
2350
|
+
* return {
|
|
2351
|
+
* // fetch the score text node for later use (assumes it is called "score")
|
|
2352
|
+
* score_node: gui.get_node("score"),
|
|
2353
|
+
* // keep track of the current score counted up so far
|
|
2354
|
+
* current_score: 0,
|
|
2355
|
+
* // keep track of the target score we should count up to
|
|
2356
|
+
* target_score: 0,
|
|
2357
|
+
* // how fast we will update the score, in score/second
|
|
2358
|
+
* score_update_speed: 1,
|
|
2359
|
+
* };
|
|
2344
2360
|
* },
|
|
2345
2361
|
*
|
|
2346
2362
|
* update(self, dt) {
|
|
@@ -2359,7 +2375,7 @@ declare global {
|
|
|
2359
2375
|
*
|
|
2360
2376
|
* on_message(self, message_id, message) {
|
|
2361
2377
|
* // check the message
|
|
2362
|
-
* if (message_id === hash("set_score")) {
|
|
2378
|
+
* if (message_id === hash("set_score") && typeof message.score === "number") {
|
|
2363
2379
|
* self.target_score = message.score;
|
|
2364
2380
|
* }
|
|
2365
2381
|
* },
|
|
@@ -18,7 +18,9 @@ declare global {
|
|
|
18
18
|
* const res = html5.run("10 + 20"); // returns the string "30"
|
|
19
19
|
* print(res);
|
|
20
20
|
* const res_num = tonumber(res); // convert to number
|
|
21
|
-
*
|
|
21
|
+
* if (res_num !== undefined) {
|
|
22
|
+
* print(res_num - 20); // prints 10
|
|
23
|
+
* }
|
|
22
24
|
* ```
|
|
23
25
|
*/
|
|
24
26
|
function run(code: string): string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
+
import type { Hash } from "../../../src/core-types";
|
|
3
|
+
|
|
2
4
|
declare global {
|
|
3
5
|
/**
|
|
4
6
|
* Functions for performing HTTP and HTTPS requests.
|
|
@@ -65,7 +67,7 @@ declare global {
|
|
|
65
67
|
* "http://www.google.com",
|
|
66
68
|
* "GET",
|
|
67
69
|
* (self, _id, response) => {
|
|
68
|
-
* if (response.bytes_total !== undefined) {
|
|
70
|
+
* if (response.bytes_received !== undefined && response.bytes_total !== undefined) {
|
|
69
71
|
* update_my_progress_bar(self, response.bytes_received / response.bytes_total);
|
|
70
72
|
* } else {
|
|
71
73
|
* print(response.status);
|
|
@@ -81,7 +83,7 @@ declare global {
|
|
|
81
83
|
* });
|
|
82
84
|
* ```
|
|
83
85
|
*/
|
|
84
|
-
function request(url: string, method: string, callback: (self: unknown, id:
|
|
86
|
+
function request(url: string, method: string, callback: (self: unknown, id: Hash, response: { status: number; response?: string; headers?: LuaMap<string, string>; path?: string; error?: string; bytes_received?: number; bytes_total?: number; range_start?: number; range_end?: number; document_size?: number }) => void, headers?: LuaMap<string, string> | Record<string, string>, post_data?: string, options?: { timeout?: number; path?: string; ignore_cache?: boolean; chunked_transfer?: boolean; report_progress?: boolean }): void;
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -43,8 +43,10 @@ declare global {
|
|
|
43
43
|
* ```ts
|
|
44
44
|
* // How to get the block size and dimensions from a .astc file
|
|
45
45
|
* const [s] = sys.load_resource("/assets/cat.astc");
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* if (s !== undefined) {
|
|
47
|
+
* const header = image.get_astc_header(s);
|
|
48
|
+
* pprint(s);
|
|
49
|
+
* }
|
|
48
50
|
* ```
|
|
49
51
|
*/
|
|
50
52
|
function get_astc_header(buffer: string): { width: number; height: number; depth: number; block_size_x: number; block_size_y: number; block_size_z: number } | undefined;
|
|
@@ -80,8 +82,10 @@ declare global {
|
|
|
80
82
|
* // How to load an image from an URL and create a GUI texture from it:
|
|
81
83
|
* const imgurl = "http://www.site.com/image.png";
|
|
82
84
|
* http.request(imgurl, "GET", (self, id, response) => {
|
|
83
|
-
* const img = image.load(response.response);
|
|
84
|
-
*
|
|
85
|
+
* const img = response.response !== undefined ? image.load(response.response) : undefined;
|
|
86
|
+
* if (img !== undefined) {
|
|
87
|
+
* const tx = gui.new_texture("image_node", img.width, img.height, img.type, img.buffer);
|
|
88
|
+
* }
|
|
85
89
|
* });
|
|
86
90
|
* ```
|
|
87
91
|
*/
|
|
@@ -118,17 +122,22 @@ declare global {
|
|
|
118
122
|
* // Load an image from an URL as a buffer and create a texture resource from it:
|
|
119
123
|
* const imgurl = "http://www.site.com/image.png";
|
|
120
124
|
* http.request(imgurl, "GET", (self, id, response) => {
|
|
121
|
-
* const img =
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
125
|
+
* const img =
|
|
126
|
+
* response.response !== undefined
|
|
127
|
+
* ? image.load_buffer(response.response, { flip_vertically: true })
|
|
128
|
+
* : undefined;
|
|
129
|
+
* if (img !== undefined) {
|
|
130
|
+
* const tparams = {
|
|
131
|
+
* width: img.width,
|
|
132
|
+
* height: img.height,
|
|
133
|
+
* type: graphics.TEXTURE_TYPE_2D,
|
|
134
|
+
* format: graphics.TEXTURE_FORMAT_RGBA,
|
|
135
|
+
* };
|
|
136
|
+
*
|
|
137
|
+
* const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams, img.buffer);
|
|
138
|
+
* // Apply the texture to a model
|
|
139
|
+
* go.set("/go1#model", "texture0", my_texture_id);
|
|
140
|
+
* }
|
|
132
141
|
* });
|
|
133
142
|
* ```
|
|
134
143
|
*/
|
|
@@ -49,6 +49,7 @@ import "../../../src/message-guard";
|
|
|
49
49
|
import "../../../src/window-event-guard";
|
|
50
50
|
import "../../../src/scene-addresses";
|
|
51
51
|
import "../../../src/go-overloads";
|
|
52
|
+
import "../../../src/component-properties";
|
|
52
53
|
import "../../../src/render-overloads";
|
|
53
54
|
import "../../../src/vmath-overloads";
|
|
54
55
|
|
|
@@ -369,7 +369,7 @@ declare global {
|
|
|
369
369
|
* material.set_textures(resource.material("/my_material.materialc"), { my_texture: resource.texture() });
|
|
370
370
|
* ```
|
|
371
371
|
*/
|
|
372
|
-
function set_textures(path: Hash | string, textures: LuaMap<string, Hash>): void;
|
|
372
|
+
function set_textures(path: Hash | string, textures: LuaMap<string, Hash> | Record<string, Hash>): void;
|
|
373
373
|
/**
|
|
374
374
|
* Sets vertex attributes in a material, if the vertex attributes exist.
|
|
375
375
|
*
|
|
@@ -87,11 +87,12 @@ declare global {
|
|
|
87
87
|
* const game = { data: { weapons: { Sword: { damage: 10 } } } };
|
|
88
88
|
*
|
|
89
89
|
* export default defineScript({
|
|
90
|
-
* init(
|
|
90
|
+
* init() {
|
|
91
91
|
* if (model.get_mesh_enabled("#model", "Sword")) {
|
|
92
92
|
* // set properties specific for the sword
|
|
93
|
-
*
|
|
93
|
+
* return { weapon_properties: game.data.weapons["Sword"] };
|
|
94
94
|
* }
|
|
95
|
+
* return { weapon_properties: undefined };
|
|
95
96
|
* },
|
|
96
97
|
* });
|
|
97
98
|
* ```
|
|
@@ -243,7 +244,35 @@ declare global {
|
|
|
243
244
|
/**
|
|
244
245
|
* The texture hash id of the model. Used for getting/setting model texture for unit 0-7
|
|
245
246
|
*/
|
|
246
|
-
|
|
247
|
+
texture0: Hash;
|
|
248
|
+
/**
|
|
249
|
+
* The texture hash id of the model. Used for getting/setting model texture for unit 0-7
|
|
250
|
+
*/
|
|
251
|
+
texture1: Hash;
|
|
252
|
+
/**
|
|
253
|
+
* The texture hash id of the model. Used for getting/setting model texture for unit 0-7
|
|
254
|
+
*/
|
|
255
|
+
texture2: Hash;
|
|
256
|
+
/**
|
|
257
|
+
* The texture hash id of the model. Used for getting/setting model texture for unit 0-7
|
|
258
|
+
*/
|
|
259
|
+
texture3: Hash;
|
|
260
|
+
/**
|
|
261
|
+
* The texture hash id of the model. Used for getting/setting model texture for unit 0-7
|
|
262
|
+
*/
|
|
263
|
+
texture4: Hash;
|
|
264
|
+
/**
|
|
265
|
+
* The texture hash id of the model. Used for getting/setting model texture for unit 0-7
|
|
266
|
+
*/
|
|
267
|
+
texture5: Hash;
|
|
268
|
+
/**
|
|
269
|
+
* The texture hash id of the model. Used for getting/setting model texture for unit 0-7
|
|
270
|
+
*/
|
|
271
|
+
texture6: Hash;
|
|
272
|
+
/**
|
|
273
|
+
* The texture hash id of the model. Used for getting/setting model texture for unit 0-7
|
|
274
|
+
*/
|
|
275
|
+
texture7: Hash;
|
|
247
276
|
}
|
|
248
277
|
}
|
|
249
278
|
}
|
|
@@ -70,7 +70,7 @@ declare global {
|
|
|
70
70
|
* init(self) {
|
|
71
71
|
* let gravity = physics.get_gravity();
|
|
72
72
|
* // Inverse gravity!
|
|
73
|
-
* gravity = -gravity;
|
|
73
|
+
* gravity = vmath.vector3(-gravity.x, -gravity.y, -gravity.z);
|
|
74
74
|
* physics.set_gravity(gravity);
|
|
75
75
|
* },
|
|
76
76
|
* });
|
|
@@ -206,8 +206,8 @@ declare global {
|
|
|
206
206
|
*
|
|
207
207
|
* // How to perform a ray cast synchronously:
|
|
208
208
|
* export default defineScript({
|
|
209
|
-
* init(
|
|
210
|
-
*
|
|
209
|
+
* init() {
|
|
210
|
+
* return { groups: [hash("world"), hash("enemy")] };
|
|
211
211
|
* },
|
|
212
212
|
*
|
|
213
213
|
* update(self, dt) {
|
|
@@ -247,8 +247,8 @@ declare global {
|
|
|
247
247
|
* ```ts
|
|
248
248
|
* // How to perform a ray cast asynchronously:
|
|
249
249
|
* export default defineScript({
|
|
250
|
-
* init(
|
|
251
|
-
*
|
|
250
|
+
* init() {
|
|
251
|
+
* return { my_groups: [hash("my_group1"), hash("my_group2")] };
|
|
252
252
|
* },
|
|
253
253
|
*
|
|
254
254
|
* update(self, dt) {
|
|
@@ -414,9 +414,10 @@ declare global {
|
|
|
414
414
|
* @example
|
|
415
415
|
* ```ts
|
|
416
416
|
* export default defineScript({
|
|
417
|
-
* init(
|
|
418
|
-
*
|
|
419
|
-
* physics.set_hflip("#collisionobject",
|
|
417
|
+
* init() {
|
|
418
|
+
* const fliph = true; // set on some condition
|
|
419
|
+
* physics.set_hflip("#collisionobject", fliph);
|
|
420
|
+
* return { fliph };
|
|
420
421
|
* },
|
|
421
422
|
* });
|
|
422
423
|
* ```
|
|
@@ -488,9 +489,10 @@ declare global {
|
|
|
488
489
|
* @example
|
|
489
490
|
* ```ts
|
|
490
491
|
* export default defineScript({
|
|
491
|
-
* init(
|
|
492
|
-
*
|
|
493
|
-
* physics.set_vflip("#collisionobject",
|
|
492
|
+
* init() {
|
|
493
|
+
* const flipv = true; // set on some condition
|
|
494
|
+
* physics.set_vflip("#collisionobject", flipv);
|
|
495
|
+
* return { flipv };
|
|
494
496
|
* },
|
|
495
497
|
* });
|
|
496
498
|
* ```
|
|
@@ -128,7 +128,7 @@ declare global {
|
|
|
128
128
|
* ```ts
|
|
129
129
|
* // Show the last recorded frame
|
|
130
130
|
* const recorded_frame_count = profiler.recorded_frame_count();
|
|
131
|
-
* profiler.view_recorded_frame(recorded_frame_count);
|
|
131
|
+
* profiler.view_recorded_frame({ frame: recorded_frame_count });
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
134
|
function recorded_frame_count(): number;
|
|
@@ -6,7 +6,7 @@ declare global {
|
|
|
6
6
|
* Rendering API documentation
|
|
7
7
|
*/
|
|
8
8
|
namespace render {
|
|
9
|
-
type constant_buffer = Opaque<"constant_buffer"
|
|
9
|
+
type constant_buffer = Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] };
|
|
10
10
|
type render_target = Opaque<"render_target">;
|
|
11
11
|
type texture = Opaque<"texture">;
|
|
12
12
|
type ClearBufferKey = typeof graphics.BUFFER_TYPE_COLOR0_BIT | typeof graphics.BUFFER_TYPE_DEPTH_BIT | typeof graphics.BUFFER_TYPE_STENCIL_BIT;
|
|
@@ -87,7 +87,7 @@ declare global {
|
|
|
87
87
|
* });
|
|
88
88
|
* ```
|
|
89
89
|
*/
|
|
90
|
-
function constant_buffer(): Opaque<"constant_buffer"
|
|
90
|
+
function constant_buffer(): Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] };
|
|
91
91
|
/**
|
|
92
92
|
* Deletes a render target created by a render script.
|
|
93
93
|
* You cannot delete a render target resource.
|
|
@@ -169,6 +169,18 @@ declare global {
|
|
|
169
169
|
* @example
|
|
170
170
|
* ```ts
|
|
171
171
|
* export default defineRenderScript({
|
|
172
|
+
* init() {
|
|
173
|
+
* const color_params = {
|
|
174
|
+
* format: graphics.TEXTURE_FORMAT_RGBA,
|
|
175
|
+
* width: render.get_window_width(),
|
|
176
|
+
* height: render.get_window_height(),
|
|
177
|
+
* };
|
|
178
|
+
* return {
|
|
179
|
+
* my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
|
|
180
|
+
* my_pred: render.predicate([hash("my_tag")]),
|
|
181
|
+
* };
|
|
182
|
+
* },
|
|
183
|
+
*
|
|
172
184
|
* update(self, dt) {
|
|
173
185
|
* render.enable_texture(0, self.my_render_target, graphics.BUFFER_TYPE_COLOR0_BIT);
|
|
174
186
|
* // draw a predicate with the render target available as texture 0 in the predicate
|
|
@@ -180,7 +192,7 @@ declare global {
|
|
|
180
192
|
* });
|
|
181
193
|
* ```
|
|
182
194
|
*/
|
|
183
|
-
function disable_texture(binding: Opaque<"texture"> | string | Hash): void;
|
|
195
|
+
function disable_texture(binding: Opaque<"texture"> | string | Hash | number): void;
|
|
184
196
|
/**
|
|
185
197
|
* Dispatches the currently enabled compute program. The dispatch call takes three arguments x,y,z which constitutes
|
|
186
198
|
* the 'global working group' of the compute dispatch. Together with the 'local working group' specified in the compute shader
|
|
@@ -205,6 +217,7 @@ declare global {
|
|
|
205
217
|
* height: render.get_window_height(),
|
|
206
218
|
* };
|
|
207
219
|
* return {
|
|
220
|
+
* backing_texture: resource.get_texture_info("/main/backing.texturec").handle,
|
|
208
221
|
* scene_rt: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
|
|
209
222
|
* };
|
|
210
223
|
* },
|
|
@@ -224,7 +237,7 @@ declare global {
|
|
|
224
237
|
* render.dispatch_compute(32, 32, 32, { constants });
|
|
225
238
|
* ```
|
|
226
239
|
*/
|
|
227
|
-
function dispatch_compute(x: number, y: number, z: number, options?: { constants?: Opaque<"constant_buffer"> }): void;
|
|
240
|
+
function dispatch_compute(x: number, y: number, z: number, options?: { constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] } }): void;
|
|
228
241
|
/**
|
|
229
242
|
* Draws all objects that match a specified predicate. An optional constant buffer can be
|
|
230
243
|
* provided to override the default constants. If no constants buffer is provided, a default
|
|
@@ -251,8 +264,12 @@ declare global {
|
|
|
251
264
|
* ```ts
|
|
252
265
|
* export default defineRenderScript({
|
|
253
266
|
* init() {
|
|
254
|
-
*
|
|
255
|
-
*
|
|
267
|
+
* return {
|
|
268
|
+
* // define a predicate matching anything with material tag "my_tag"
|
|
269
|
+
* my_pred: render.predicate([hash("my_tag")]),
|
|
270
|
+
* proj: vmath.matrix4_perspective(math.rad(45), render.get_window_width() / render.get_window_height(), 0.1, 1000),
|
|
271
|
+
* view: vmath.matrix4_look_at(vmath.vector3(0, 0, 10), vmath.vector3(0, 0, 0), vmath.vector3(0, 1, 0)),
|
|
272
|
+
* };
|
|
256
273
|
* },
|
|
257
274
|
*
|
|
258
275
|
* update(self, dt) {
|
|
@@ -275,7 +292,7 @@ declare global {
|
|
|
275
292
|
* });
|
|
276
293
|
* ```
|
|
277
294
|
*/
|
|
278
|
-
function draw(predicate: number, options?: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer"
|
|
295
|
+
function draw(predicate: number, options?: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] }; sort_order?: number }): void;
|
|
279
296
|
/**
|
|
280
297
|
* Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.
|
|
281
298
|
*
|
|
@@ -395,6 +412,18 @@ declare global {
|
|
|
395
412
|
* @example
|
|
396
413
|
* ```ts
|
|
397
414
|
* export default defineRenderScript({
|
|
415
|
+
* init() {
|
|
416
|
+
* const color_params = {
|
|
417
|
+
* format: graphics.TEXTURE_FORMAT_RGBA,
|
|
418
|
+
* width: render.get_window_width(),
|
|
419
|
+
* height: render.get_window_height(),
|
|
420
|
+
* };
|
|
421
|
+
* return {
|
|
422
|
+
* my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
|
|
423
|
+
* my_pred: render.predicate([hash("my_tag")]),
|
|
424
|
+
* };
|
|
425
|
+
* },
|
|
426
|
+
*
|
|
398
427
|
* update(self, dt) {
|
|
399
428
|
* // enable target so all drawing is done to it
|
|
400
429
|
* render.set_render_target(self.my_render_target);
|
|
@@ -416,6 +445,10 @@ declare global {
|
|
|
416
445
|
* ```ts
|
|
417
446
|
* // Or enable a render target by resource id:
|
|
418
447
|
* export default defineRenderScript({
|
|
448
|
+
* init() {
|
|
449
|
+
* return { my_pred: render.predicate([hash("my_tag")]) };
|
|
450
|
+
* },
|
|
451
|
+
*
|
|
419
452
|
* update(self, dt) {
|
|
420
453
|
* render.set_render_target("my_rt_resource");
|
|
421
454
|
* render.draw(self.my_pred);
|
|
@@ -432,6 +465,10 @@ declare global {
|
|
|
432
465
|
* ```ts
|
|
433
466
|
* // Or bind a texture handle directly:
|
|
434
467
|
* export default defineRenderScript({
|
|
468
|
+
* init() {
|
|
469
|
+
* return { my_texture_handle: resource.get_texture_info("/main/my_texture.texturec").handle };
|
|
470
|
+
* },
|
|
471
|
+
*
|
|
435
472
|
* update(self, dt) {
|
|
436
473
|
* // bind a texture to the texture unit 0
|
|
437
474
|
* render.enable_texture(0, self.my_texture_handle);
|
|
@@ -441,7 +478,7 @@ declare global {
|
|
|
441
478
|
* });
|
|
442
479
|
* ```
|
|
443
480
|
*/
|
|
444
|
-
function enable_texture(binding: number | string | Hash, handle_or_name: Opaque<"texture"> | string | Hash, buffer_type?: graphics.BufferType): void;
|
|
481
|
+
function enable_texture(binding: number | string | Hash, handle_or_name: Opaque<"texture"> | string | Hash | Opaque<"render_target"> | number, buffer_type?: graphics.BufferType): void;
|
|
445
482
|
/**
|
|
446
483
|
* Returns the logical window height that is set in the "game.project" settings.
|
|
447
484
|
* Note that the actual window pixel size can change, either by device constraints
|
|
@@ -497,7 +534,7 @@ declare global {
|
|
|
497
534
|
* });
|
|
498
535
|
* ```
|
|
499
536
|
*/
|
|
500
|
-
function get_render_target_height(render_target: Opaque<"render_target"
|
|
537
|
+
function get_render_target_height(render_target: Opaque<"render_target"> | string | Hash, buffer_type: graphics.BufferType): number;
|
|
501
538
|
/**
|
|
502
539
|
* Returns the specified buffer width from a render target.
|
|
503
540
|
*
|
|
@@ -542,7 +579,7 @@ declare global {
|
|
|
542
579
|
* });
|
|
543
580
|
* ```
|
|
544
581
|
*/
|
|
545
|
-
function get_render_target_width(render_target: Opaque<"render_target"
|
|
582
|
+
function get_render_target_width(render_target: Opaque<"render_target"> | string | Hash, buffer_type: graphics.BufferType): number;
|
|
546
583
|
/**
|
|
547
584
|
* Returns the logical window width that is set in the "game.project" settings.
|
|
548
585
|
* Note that the actual window pixel size can change, either by device constraints
|
|
@@ -747,7 +784,7 @@ declare global {
|
|
|
747
784
|
* });
|
|
748
785
|
* ```
|
|
749
786
|
*/
|
|
750
|
-
function set_camera(camera?: Url | number, options?: { use_frustum?: boolean }): void;
|
|
787
|
+
function set_camera(camera?: Url | number | string, options?: { use_frustum?: boolean }): void;
|
|
751
788
|
/**
|
|
752
789
|
* 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.
|
|
753
790
|
* The component masks are all initially `true`.
|
|
@@ -897,7 +934,7 @@ declare global {
|
|
|
897
934
|
* offset for each polygon. The initial value is `0`.
|
|
898
935
|
* `units` is multiplied by an implementation-specific value to create a
|
|
899
936
|
* constant depth offset. The initial value is `0`.
|
|
900
|
-
* The value of the offset is computed as `factor`
|
|
937
|
+
* The value of the offset is computed as `factor` × `DZ` + `r` × `units`
|
|
901
938
|
* `DZ` is a measurement of the depth slope of the polygon which is the change in z (depth)
|
|
902
939
|
* values divided by the change in either x or y coordinates, as you traverse a polygon.
|
|
903
940
|
* The depth values are in window coordinates, clamped to the range [0, 1].
|
|
@@ -952,6 +989,18 @@ declare global {
|
|
|
952
989
|
* // How to set a render target and draw to it and then switch back to the default render target
|
|
953
990
|
* // The render target defines the depth/stencil buffers as transient, when set_render_target is called the next time the buffers may be invalidated and allow for optimisations depending on driver support
|
|
954
991
|
* export default defineRenderScript({
|
|
992
|
+
* init() {
|
|
993
|
+
* const color_params = {
|
|
994
|
+
* format: graphics.TEXTURE_FORMAT_RGBA,
|
|
995
|
+
* width: render.get_window_width(),
|
|
996
|
+
* height: render.get_window_height(),
|
|
997
|
+
* };
|
|
998
|
+
* return {
|
|
999
|
+
* my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
|
|
1000
|
+
* my_pred: render.predicate([hash("my_tag")]),
|
|
1001
|
+
* };
|
|
1002
|
+
* },
|
|
1003
|
+
*
|
|
955
1004
|
* update(self, dt) {
|
|
956
1005
|
* // set render target so all drawing is done to it
|
|
957
1006
|
* render.set_render_target(self.my_render_target, {
|
|
@@ -971,6 +1020,10 @@ declare global {
|
|
|
971
1020
|
* ```ts
|
|
972
1021
|
* // Or set the render target by a render target resource identifier:
|
|
973
1022
|
* export default defineRenderScript({
|
|
1023
|
+
* init() {
|
|
1024
|
+
* return { my_pred: render.predicate([hash("my_tag")]) };
|
|
1025
|
+
* },
|
|
1026
|
+
*
|
|
974
1027
|
* update(self, dt) {
|
|
975
1028
|
* render.set_render_target("my_rt_resource");
|
|
976
1029
|
*
|
|
@@ -983,7 +1036,7 @@ declare global {
|
|
|
983
1036
|
* });
|
|
984
1037
|
* ```
|
|
985
1038
|
*/
|
|
986
|
-
function set_render_target(render_target: Opaque<"render_target"
|
|
1039
|
+
function set_render_target(render_target: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT, options?: { transient?: graphics.BufferType[] }): void;
|
|
987
1040
|
/**
|
|
988
1041
|
* Sets the render target size for a render target created from
|
|
989
1042
|
* either a render script, or from a render target resource.
|
|
@@ -1006,7 +1059,7 @@ declare global {
|
|
|
1006
1059
|
* });
|
|
1007
1060
|
* ```
|
|
1008
1061
|
*/
|
|
1009
|
-
function set_render_target_size(render_target: Opaque<"render_target"
|
|
1062
|
+
function set_render_target_size(render_target: Opaque<"render_target"> | string | Hash, width: number, height: number): void;
|
|
1010
1063
|
/**
|
|
1011
1064
|
* Stenciling is similar to depth-buffering as it enables and disables drawing on a
|
|
1012
1065
|
* per-pixel basis. First, GL drawing primitives are drawn into the stencil planes.
|
|
@@ -1132,7 +1185,11 @@ declare global {
|
|
|
1132
1185
|
* },
|
|
1133
1186
|
*
|
|
1134
1187
|
* on_message(self, message_id, message) {
|
|
1135
|
-
* if (
|
|
1188
|
+
* if (
|
|
1189
|
+
* message_id === hash("set_view_projection") &&
|
|
1190
|
+
* types.is_matrix4(message.view) &&
|
|
1191
|
+
* types.is_matrix4(message.projection)
|
|
1192
|
+
* ) {
|
|
1136
1193
|
* // camera view and projection arrives here.
|
|
1137
1194
|
* self.view = message.view;
|
|
1138
1195
|
* self.projection = message.projection;
|