@defold-typescript/types 0.51.0 → 0.52.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 +4 -58
- package/api-signatures.json +878 -1356
- package/api-targets.json +15 -5
- package/examples/translations.json +4 -56
- package/generated/b2d_world.d.ts +10 -10
- package/generated/buffer.d.ts +9 -9
- package/generated/bullet3d_collision_object.d.ts +1 -1
- package/generated/bullet3d_constraint.d.ts +109 -7
- package/generated/bullet3d_shape.d.ts +2 -2
- package/generated/go.d.ts +114 -220
- package/generated/graphics.d.ts +1 -0
- package/generated/gui.d.ts +148 -371
- package/generated/http.d.ts +2 -2
- package/generated/image.d.ts +55 -3
- package/generated/kinds/gui-script.d.ts +2 -0
- package/generated/kinds/render-script.d.ts +14 -15
- package/generated/liveupdate.d.ts +5 -1
- package/generated/material.d.ts +3 -3
- package/generated/particlefx.d.ts +20 -1
- package/generated/physics.d.ts +45 -1
- package/generated/render-script-modules/b2d.d.ts +711 -0
- package/generated/render-script-modules/bullet3d.d.ts +73 -0
- package/generated/render-script-modules/collectionfactory.d.ts +25 -0
- package/generated/render-script-modules/collectionproxy.d.ts +39 -0
- package/generated/render-script-modules/factory.d.ts +25 -0
- package/generated/render-script-modules/go.d.ts +436 -0
- package/generated/render-script-modules/label.d.ts +105 -0
- package/generated/render-script-modules/model.d.ts +89 -0
- package/generated/render-script-modules/particlefx.d.ts +59 -0
- package/generated/render-script-modules/physics.d.ts +333 -0
- package/generated/render-script-modules/resource.d.ts +1233 -0
- package/generated/render-script-modules/sound.d.ts +227 -0
- package/generated/render-script-modules/sprite.d.ts +68 -0
- package/generated/render-script-modules/tilemap.d.ts +43 -0
- package/generated/render.d.ts +134 -8
- package/generated/resource.d.ts +31 -10
- package/generated/sprite.d.ts +49 -1
- package/generated/sys.d.ts +70 -6
- package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
- package/generated/versions/defold-1.12.4/go.d.ts +115 -343
- package/generated/versions/defold-1.12.4/graphics.d.ts +1 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +151 -513
- package/generated/versions/defold-1.12.4/http.d.ts +2 -2
- package/generated/versions/defold-1.12.4/image.d.ts +82 -2
- package/generated/versions/defold-1.12.4/index.d.ts +1 -0
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.12.4/physics.d.ts +45 -1
- package/generated/versions/defold-1.12.4/render.d.ts +78 -2
- package/generated/versions/defold-1.12.4/resource.d.ts +43 -10
- package/generated/versions/defold-1.12.4/sprite.d.ts +58 -1
- package/generated/versions/defold-1.12.4/sys.d.ts +101 -6
- package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.0/go.d.ts +115 -370
- package/generated/versions/defold-1.13.0/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +151 -513
- package/generated/versions/defold-1.13.0/http.d.ts +2 -2
- package/generated/versions/defold-1.13.0/image.d.ts +82 -2
- package/generated/versions/defold-1.13.0/index.d.ts +1 -0
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.0/material.d.ts +3 -1
- package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.0/physics.d.ts +45 -1
- package/generated/versions/defold-1.13.0/render.d.ts +142 -4
- package/generated/versions/defold-1.13.0/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.0/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.0/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.1/go.d.ts +115 -370
- package/generated/versions/defold-1.13.1/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.1/gui.d.ts +151 -529
- package/generated/versions/defold-1.13.1/http.d.ts +2 -2
- package/generated/versions/defold-1.13.1/image.d.ts +82 -2
- package/generated/versions/defold-1.13.1/index.d.ts +2 -0
- package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.1/material.d.ts +3 -1
- package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.1/physics.d.ts +45 -1
- package/generated/versions/defold-1.13.1/render.d.ts +142 -4
- package/generated/versions/defold-1.13.1/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.1/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.1/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.2/b2d_world.d.ts +10 -10
- package/generated/versions/defold-1.13.2/buffer.d.ts +9 -9
- package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +1 -1
- package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +109 -7
- package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +2 -2
- package/generated/versions/defold-1.13.2/go.d.ts +114 -220
- package/generated/versions/defold-1.13.2/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.2/gui.d.ts +148 -371
- package/generated/versions/defold-1.13.2/http.d.ts +2 -2
- package/generated/versions/defold-1.13.2/image.d.ts +55 -3
- package/generated/versions/defold-1.13.2/index.d.ts +2 -0
- package/generated/versions/defold-1.13.2/liveupdate.d.ts +5 -1
- package/generated/versions/defold-1.13.2/material.d.ts +3 -3
- package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
- package/generated/versions/defold-1.13.2/physics.d.ts +45 -1
- package/generated/versions/defold-1.13.2/render.d.ts +123 -7
- package/generated/versions/defold-1.13.2/resource.d.ts +31 -10
- package/generated/versions/defold-1.13.2/sprite.d.ts +49 -1
- package/generated/versions/defold-1.13.2/sys.d.ts +70 -6
- package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
- package/generated/vmath.d.ts +0 -24
- package/identity-vocabulary.json +52 -7
- package/index.d.ts +2 -0
- package/package.json +2 -1
- package/scripts/generate-api-availability.ts +1 -21
- package/scripts/generate-api-signatures.ts +75 -14
- package/scripts/materialize-version.ts +48 -7
- package/scripts/regen.ts +214 -19
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/target-version.ts +26 -0
- package/src/api-doc.ts +26 -0
- package/src/component-properties.d.ts +89 -0
- package/src/core-types.ts +42 -15
- package/src/doc-corrections.ts +53 -5
- package/src/emit-dts.ts +758 -198
- package/src/engine-globals.d.ts +5 -1
- package/src/go-overloads.d.ts +68 -13
- package/src/gui-overloads.d.ts +489 -0
- package/src/gui-texture-removal.d.ts +41 -0
- package/src/index.ts +2 -0
- package/src/lifecycle.ts +30 -21
- package/src/msg-overloads.d.ts +25 -13
- package/src/signature-store.ts +50 -0
- package/src/timers.d.ts +2 -1
- package/src/vmath-overloads.d.ts +26 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import type { Hash } from "../../../src/core-types";
|
|
2
|
+
import type { Hash, Url } from "../../../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
5
|
/**
|
|
@@ -72,7 +72,7 @@ declare global {
|
|
|
72
72
|
* });
|
|
73
73
|
* ```
|
|
74
74
|
*/
|
|
75
|
-
function request(url: string, method: string, callback: (self: unknown, id: Hash, response: { status: number; url: string; response?: string; headers?: LuaMap<string, string>; path?: string; error?: string; bytes_sent?: number; 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;
|
|
75
|
+
function request(url: string, method: string, callback: (self: unknown, id: Hash, response: { status: number; url: string; response?: string; headers?: LuaMap<string, string>; path?: string; error?: string; bytes_sent?: number; bytes_received?: number; bytes_total?: number; range_start?: number; range_end?: number; document_size?: number }, sender: Url) => 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;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -77,7 +77,87 @@ declare global {
|
|
|
77
77
|
* });
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
function load(buffer: string
|
|
80
|
+
function load(buffer: string): { width: number; height: number; type: Opaque<"constant">; buffer: string } | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Load image (PNG or JPEG) from buffer.
|
|
83
|
+
*
|
|
84
|
+
* @param buffer - image data buffer
|
|
85
|
+
* @param options - An optional table containing parameters for loading the image. Supported entries:
|
|
86
|
+
*
|
|
87
|
+
* `premultiply_alpha`
|
|
88
|
+
* boolean True if alpha should be premultiplied into the color components. Defaults to `false`.
|
|
89
|
+
* `flip_vertically`
|
|
90
|
+
* boolean True if the image contents should be flipped vertically. Defaults to `false`.
|
|
91
|
+
* @returns object or `nil` if loading fails. The object is a table with the following fields:
|
|
92
|
+
*
|
|
93
|
+
* - number `width`: image width
|
|
94
|
+
* - number `height`: image height
|
|
95
|
+
* - constant `type`: image type
|
|
96
|
+
* - `image.TYPE_RGB`
|
|
97
|
+
* - `image.TYPE_RGBA`
|
|
98
|
+
* - `image.TYPE_LUMINANCE`
|
|
99
|
+
* - `image.TYPE_LUMINANCE_ALPHA`
|
|
100
|
+
* - string `buffer`: the raw image data
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* // How to load an image from an URL and create a GUI texture from it:
|
|
104
|
+
* const imgurl = "http://www.site.com/image.png";
|
|
105
|
+
* http.request(imgurl, "GET", (self, id, response) => {
|
|
106
|
+
* const img = response.response !== undefined ? image.load(response.response) : undefined;
|
|
107
|
+
* if (img !== undefined) {
|
|
108
|
+
* const tx = gui.new_texture("image_node", img.width, img.height, img.type, img.buffer);
|
|
109
|
+
* }
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
function load(buffer: string, options: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: string } | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Load image (PNG or JPEG) from a string buffer.
|
|
116
|
+
*
|
|
117
|
+
* @param buffer - image data buffer
|
|
118
|
+
* @param options - An optional table containing parameters for loading the image. Supported entries:
|
|
119
|
+
*
|
|
120
|
+
* `premultiply_alpha`
|
|
121
|
+
* boolean True if alpha should be premultiplied into the color components. Defaults to `false`.
|
|
122
|
+
* `flip_vertically`
|
|
123
|
+
* boolean True if the image contents should be flipped vertically. Defaults to `false`.
|
|
124
|
+
* @returns object or `nil` if loading fails. The object is a table with the following fields:
|
|
125
|
+
*
|
|
126
|
+
* - number `width`: image width
|
|
127
|
+
* - number `height`: image height
|
|
128
|
+
* - constant `type`: image type
|
|
129
|
+
* - `image.TYPE_RGB`
|
|
130
|
+
* - `image.TYPE_RGBA`
|
|
131
|
+
* - `image.TYPE_LUMINANCE`
|
|
132
|
+
* - `image.TYPE_LUMINANCE_ALPHA`
|
|
133
|
+
* - buffer `buffer`: the script buffer that holds the decompressed image data. See buffer.create how to use the buffer.
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* // Load an image from an URL as a buffer and create a texture resource from it:
|
|
137
|
+
* const imgurl = "http://www.site.com/image.png";
|
|
138
|
+
* http.request(imgurl, "GET", (self, id, response) => {
|
|
139
|
+
* const img =
|
|
140
|
+
* response.response !== undefined
|
|
141
|
+
* ? image.load_buffer(response.response, { flip_vertically: true })
|
|
142
|
+
* : undefined;
|
|
143
|
+
* // the engine registers a texture format only when the driver supports it
|
|
144
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
145
|
+
* if (img !== undefined && format !== undefined) {
|
|
146
|
+
* const tparams = {
|
|
147
|
+
* width: img.width,
|
|
148
|
+
* height: img.height,
|
|
149
|
+
* type: graphics.TEXTURE_TYPE_2D,
|
|
150
|
+
* format,
|
|
151
|
+
* };
|
|
152
|
+
*
|
|
153
|
+
* const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams, img.buffer);
|
|
154
|
+
* // Apply the texture to a model
|
|
155
|
+
* go.set("/go1#model", "texture0", my_texture_id);
|
|
156
|
+
* }
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
function load_buffer(buffer: string): { width: number; height: number; type: Opaque<"constant">; buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> } } | undefined;
|
|
81
161
|
/**
|
|
82
162
|
* Load image (PNG or JPEG) from a string buffer.
|
|
83
163
|
*
|
|
@@ -124,7 +204,7 @@ declare global {
|
|
|
124
204
|
* });
|
|
125
205
|
* ```
|
|
126
206
|
*/
|
|
127
|
-
function load_buffer(buffer: string, options
|
|
207
|
+
function load_buffer(buffer: string, options: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> } } | undefined;
|
|
128
208
|
}
|
|
129
209
|
}
|
|
130
210
|
|
|
@@ -52,6 +52,7 @@ import "../../../src/scene-addresses";
|
|
|
52
52
|
import "../../../src/go-overloads";
|
|
53
53
|
import "../../../src/component-properties";
|
|
54
54
|
import "../../../src/render-overloads";
|
|
55
|
+
import "../../../src/gui-overloads";
|
|
55
56
|
import "../../../src/vmath-overloads";
|
|
56
57
|
import "../../../src/sys-overloads";
|
|
57
58
|
|
|
@@ -38,6 +38,10 @@ declare global {
|
|
|
38
38
|
* Memory wasn't allocated
|
|
39
39
|
*/
|
|
40
40
|
const LIVEUPDATE_MEM_ERROR: number & { readonly __brand: "liveupdate.LIVEUPDATE_MEM_ERROR" };
|
|
41
|
+
/**
|
|
42
|
+
* Live update is not initialized. `liveupdate.add_mount` and `liveupdate.remove_mount` return it while live update is disabled.
|
|
43
|
+
*/
|
|
44
|
+
const LIVEUPDATE_NOT_INITIALIZED: number & { readonly __brand: "liveupdate.LIVEUPDATE_NOT_INITIALIZED" };
|
|
41
45
|
/**
|
|
42
46
|
* LIVEUPDATE_OK
|
|
43
47
|
*/
|
|
@@ -217,6 +217,8 @@ declare global {
|
|
|
217
217
|
* - `graphics.TEXTURE_USAGE_FLAG_STORAGE`
|
|
218
218
|
* - `graphics.TEXTURE_USAGE_FLAG_INPUT`
|
|
219
219
|
* - `graphics.TEXTURE_USAGE_FLAG_COLOR`
|
|
220
|
+
*
|
|
221
|
+
* Keyed by sampler slot from 1; a slot with no texture has no entry, so iterate with `for (const [slot, info] of textures)`.
|
|
220
222
|
* @example
|
|
221
223
|
* ```ts
|
|
222
224
|
* // Get the textures from a material specified as a resource property
|
|
@@ -231,7 +233,7 @@ declare global {
|
|
|
231
233
|
* });
|
|
232
234
|
* ```
|
|
233
235
|
*/
|
|
234
|
-
function get_textures(path: Hash | string): { path: Hash; handle: Hash; width: number; height: number; depth: number; mipmaps: number; type: number; flags: number }
|
|
236
|
+
function get_textures(path: Hash | string): LuaMap<number, { path: Hash; handle: Hash; width: number; height: number; depth: number; mipmaps: number; type: number; flags: number }>;
|
|
235
237
|
/**
|
|
236
238
|
* Returns a table of all the vertex attributes in the material. This function will return all the vertex attributes
|
|
237
239
|
* that are used in the vertex shader of the material.
|
|
@@ -134,7 +134,28 @@ declare global {
|
|
|
134
134
|
* });
|
|
135
135
|
* ```
|
|
136
136
|
*/
|
|
137
|
-
function stop(url: string | Hash | Url
|
|
137
|
+
function stop(url: string | Hash | Url): void;
|
|
138
|
+
/**
|
|
139
|
+
* Stops a particle FX component from playing.
|
|
140
|
+
* Stopping a particle FX does not remove already spawned particles.
|
|
141
|
+
* Which particle FX to stop is identified by the URL.
|
|
142
|
+
*
|
|
143
|
+
* @param url - the particle fx that should stop playing
|
|
144
|
+
* @param options - Options when stopping the particle fx. Supported options:
|
|
145
|
+
*
|
|
146
|
+
* - boolean `clear`: instantly clear spawned particles
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* // How to stop a particle fx when a game object is deleted and immediately also
|
|
150
|
+
* // clear any spawned particles:
|
|
151
|
+
* export default defineScript({
|
|
152
|
+
* final(self) {
|
|
153
|
+
* particlefx.stop("#particlefx", { clear: true });
|
|
154
|
+
* },
|
|
155
|
+
* });
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
function stop(url: string | Hash | Url, options: { clear?: boolean }): void;
|
|
138
159
|
interface properties {
|
|
139
160
|
/**
|
|
140
161
|
* The animation used during rendering by an emitter in a particle FX component.
|
|
@@ -269,7 +269,51 @@ declare global {
|
|
|
269
269
|
* });
|
|
270
270
|
* ```
|
|
271
271
|
*/
|
|
272
|
-
function raycast_async(from: Vector3, to: Vector3, groups: Hash[]
|
|
272
|
+
function raycast_async(from: Vector3, to: Vector3, groups: Hash[]): void;
|
|
273
|
+
/**
|
|
274
|
+
* Ray casts are used to test for intersections against collision objects in the physics world.
|
|
275
|
+
* Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
|
|
276
|
+
* do not intersect with ray casts.
|
|
277
|
+
* Which collision objects to hit is filtered by their collision groups and can be configured
|
|
278
|
+
* through `groups`.
|
|
279
|
+
* The actual ray cast will be performed during the physics-update.
|
|
280
|
+
*
|
|
281
|
+
* - If an object is hit, the result will be reported via a ray_cast_response message.
|
|
282
|
+
* - If there is no object hit, the result will be reported via a ray_cast_missed message.
|
|
283
|
+
*
|
|
284
|
+
* NOTE: Ray casts will ignore collision objects that contain the starting point of the ray. This is a limitation in Box2D.
|
|
285
|
+
*
|
|
286
|
+
* @param from - the world position of the start of the ray
|
|
287
|
+
* @param to - the world position of the end of the ray
|
|
288
|
+
* @param groups - a lua table containing the hashed groups for which to test collisions against
|
|
289
|
+
* @param request_id - a number in range [0,255]. It will be sent back in the response for identification, 0 by default
|
|
290
|
+
* @example
|
|
291
|
+
* ```ts
|
|
292
|
+
* // How to perform a ray cast asynchronously:
|
|
293
|
+
* export default defineScript({
|
|
294
|
+
* init() {
|
|
295
|
+
* return { my_groups: [hash("my_group1"), hash("my_group2")] };
|
|
296
|
+
* },
|
|
297
|
+
*
|
|
298
|
+
* update(self, dt) {
|
|
299
|
+
* // request ray cast
|
|
300
|
+
* const my_start = go.get_world_position();
|
|
301
|
+
* const my_end = vmath.vector3(my_start.x, my_start.y - 100, my_start.z);
|
|
302
|
+
* physics.raycast_async(my_start, my_end, self.my_groups);
|
|
303
|
+
* },
|
|
304
|
+
*
|
|
305
|
+
* on_message(self, message_id, message, sender) {
|
|
306
|
+
* // check for the response
|
|
307
|
+
* if (message_id === hash("ray_cast_response")) {
|
|
308
|
+
* // act on the hit
|
|
309
|
+
* } else if (message_id === hash("ray_cast_missed")) {
|
|
310
|
+
* // act on the miss
|
|
311
|
+
* }
|
|
312
|
+
* },
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
function raycast_async(from: Vector3, to: Vector3, groups: Hash[], request_id: number): void;
|
|
273
317
|
/**
|
|
274
318
|
* Only one physics world event listener can be set at a time.
|
|
275
319
|
*
|
|
@@ -10,6 +10,7 @@ declare global {
|
|
|
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;
|
|
13
|
+
type RenderTargetTextureType = typeof graphics.TEXTURE_TYPE_2D | typeof graphics.TEXTURE_TYPE_CUBE_MAP;
|
|
13
14
|
type RenderTargetParams = Record<string | number, unknown>;
|
|
14
15
|
/**
|
|
15
16
|
* The rendering context was lost. Rendering is paused and all graphics resources become invalid. Passed to the `render.set_listener` callback.
|
|
@@ -212,7 +213,7 @@ declare global {
|
|
|
212
213
|
* });
|
|
213
214
|
* ```
|
|
214
215
|
*/
|
|
215
|
-
function disable_texture(binding:
|
|
216
|
+
function disable_texture(binding: string | Hash | number): void;
|
|
216
217
|
/**
|
|
217
218
|
* Dispatches the currently enabled compute program. The dispatch call takes three arguments x,y,z which constitutes
|
|
218
219
|
* the 'global working group' of the compute dispatch. Together with the 'local working group' specified in the compute shader
|
|
@@ -325,7 +326,69 @@ declare global {
|
|
|
325
326
|
* }
|
|
326
327
|
* ```
|
|
327
328
|
*/
|
|
328
|
-
function draw(predicate: Opaque<"render_predicate"
|
|
329
|
+
function draw(predicate: Opaque<"render_predicate">): void;
|
|
330
|
+
/**
|
|
331
|
+
* Draws all objects that match a specified predicate. An optional constant buffer can be
|
|
332
|
+
* provided to override the default constants. If no constants buffer is provided, a default
|
|
333
|
+
* system constants buffer is used containing constants as defined in materials and set through
|
|
334
|
+
* go.set (or particlefx.set_constant) on visual components.
|
|
335
|
+
*
|
|
336
|
+
* @param predicate - predicate to draw for
|
|
337
|
+
* @param options - optional table with properties:
|
|
338
|
+
*
|
|
339
|
+
* `frustum`
|
|
340
|
+
* matrix4 A frustum matrix used to cull renderable items. (E.g. `local frustum = proj * view`). default=nil
|
|
341
|
+
* `frustum_planes`
|
|
342
|
+
* int Determines which sides of the frustum will be used. Default is render.FRUSTUM_PLANES_SIDES.
|
|
343
|
+
*
|
|
344
|
+
* - render.FRUSTUM_PLANES_SIDES : The left, right, top and bottom sides of the frustum.
|
|
345
|
+
* - render.FRUSTUM_PLANES_ALL : All 6 sides of the frustum.
|
|
346
|
+
*
|
|
347
|
+
* `constants`
|
|
348
|
+
* constant_buffer optional constants to use while rendering
|
|
349
|
+
* `sort_order`
|
|
350
|
+
* int How to sort draw order for world-ordered entries. Default uses the renderer's preferred world sorting (back-to-front).
|
|
351
|
+
* @example
|
|
352
|
+
* ```ts
|
|
353
|
+
* export default defineRenderScript({
|
|
354
|
+
* init() {
|
|
355
|
+
* // define a predicate matching anything with material tag "my_tag"
|
|
356
|
+
* return { my_pred: render.predicate([hash("my_tag")]) };
|
|
357
|
+
* },
|
|
358
|
+
*
|
|
359
|
+
* update(self, dt) {
|
|
360
|
+
* // draw everything in the my_pred predicate
|
|
361
|
+
* render.draw(self.my_pred);
|
|
362
|
+
* },
|
|
363
|
+
* });
|
|
364
|
+
* ```
|
|
365
|
+
* @example
|
|
366
|
+
* Draw predicate with constants:
|
|
367
|
+
* ```ts
|
|
368
|
+
* function draw_tinted(self: { my_pred: Opaque<"render_predicate"> }) {
|
|
369
|
+
* const constants = render.constant_buffer();
|
|
370
|
+
* constants.tint = vmath.vector4(1, 1, 1, 1);
|
|
371
|
+
* render.draw(self.my_pred, { constants });
|
|
372
|
+
* }
|
|
373
|
+
* ```
|
|
374
|
+
* @example
|
|
375
|
+
* Draw with predicate and frustum culling (without near+far planes):
|
|
376
|
+
* ```ts
|
|
377
|
+
* function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
|
|
378
|
+
* const frustum = self.proj.mul(self.view);
|
|
379
|
+
* render.draw(self.my_pred, { frustum });
|
|
380
|
+
* }
|
|
381
|
+
* ```
|
|
382
|
+
* @example
|
|
383
|
+
* Draw with predicate and frustum culling (with near+far planes):
|
|
384
|
+
* ```ts
|
|
385
|
+
* function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
|
|
386
|
+
* const frustum = self.proj.mul(self.view);
|
|
387
|
+
* render.draw(self.my_pred, { frustum, frustum_planes: render.FRUSTUM_PLANES_ALL });
|
|
388
|
+
* }
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
function draw(predicate: Opaque<"render_predicate">, options: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> }; sort_order?: number }): void;
|
|
329
392
|
/**
|
|
330
393
|
* Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.
|
|
331
394
|
*
|
|
@@ -762,7 +825,7 @@ declare global {
|
|
|
762
825
|
* 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);
|
|
763
826
|
* ```
|
|
764
827
|
*/
|
|
765
|
-
function set_blend_func_separate(source_factor_color:
|
|
828
|
+
function set_blend_func_separate(source_factor_color: graphics.BlendFactor, destination_factor_color: graphics.BlendFactor, source_factor_alpha: graphics.BlendFactor, destination_factor_alpha: graphics.BlendFactor): void;
|
|
766
829
|
/**
|
|
767
830
|
* Sets the current render camera to be used for rendering. If a render camera
|
|
768
831
|
* has been set by the render script, the renderer will be using its projection and view matrix
|
|
@@ -1043,7 +1106,82 @@ declare global {
|
|
|
1043
1106
|
* });
|
|
1044
1107
|
* ```
|
|
1045
1108
|
*/
|
|
1046
|
-
function set_render_target(render_target?: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT
|
|
1109
|
+
function set_render_target(render_target?: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT): void;
|
|
1110
|
+
/**
|
|
1111
|
+
* Sets a render target. Subsequent draw operations will be to the
|
|
1112
|
+
* render target until it is replaced by a subsequent call to set_render_target.
|
|
1113
|
+
* This function supports render targets created by a render script, or a render target resource.
|
|
1114
|
+
*
|
|
1115
|
+
* @param render_target - render target to set. render.RENDER_TARGET_DEFAULT to set the default render target
|
|
1116
|
+
* @param options - optional table with behaviour parameters
|
|
1117
|
+
*
|
|
1118
|
+
* `transient`
|
|
1119
|
+
* table Transient frame buffer types are only valid while the render target is active, i.e becomes undefined when a new target is set by a subsequent call to set_render_target.
|
|
1120
|
+
* Default is all non-transient. Be aware that some hardware uses a combined depth stencil buffer and when this is the case both are considered non-transient if exclusively selected!
|
|
1121
|
+
* A buffer type defined that doesn't exist in the render target is silently ignored.
|
|
1122
|
+
*
|
|
1123
|
+
* - `graphics.BUFFER_TYPE_COLOR0_BIT`
|
|
1124
|
+
* - `graphics.BUFFER_TYPE_DEPTH_BIT`
|
|
1125
|
+
* - `graphics.BUFFER_TYPE_STENCIL_BIT`
|
|
1126
|
+
* @example
|
|
1127
|
+
* How to set a render target and draw to it and then switch back to the default render target
|
|
1128
|
+
* 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
|
|
1129
|
+
* ```ts
|
|
1130
|
+
* // How to set a render target and draw to it and then switch back to the default render target
|
|
1131
|
+
* // 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
|
|
1132
|
+
* export default defineRenderScript({
|
|
1133
|
+
* init() {
|
|
1134
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1135
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
1136
|
+
* if (format === undefined) return undefined;
|
|
1137
|
+
* const color_params = {
|
|
1138
|
+
* format,
|
|
1139
|
+
* width: render.get_window_width(),
|
|
1140
|
+
* height: render.get_window_height(),
|
|
1141
|
+
* };
|
|
1142
|
+
* return {
|
|
1143
|
+
* my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
|
|
1144
|
+
* my_pred: render.predicate([hash("my_tag")]),
|
|
1145
|
+
* };
|
|
1146
|
+
* },
|
|
1147
|
+
*
|
|
1148
|
+
* update(self, dt) {
|
|
1149
|
+
* if (self === undefined) return;
|
|
1150
|
+
* // set render target so all drawing is done to it
|
|
1151
|
+
* render.set_render_target(self.my_render_target, {
|
|
1152
|
+
* transient: [graphics.BUFFER_TYPE_DEPTH_BIT, graphics.BUFFER_TYPE_STENCIL_BIT],
|
|
1153
|
+
* });
|
|
1154
|
+
*
|
|
1155
|
+
* // draw a predicate to the render target
|
|
1156
|
+
* render.draw(self.my_pred);
|
|
1157
|
+
*
|
|
1158
|
+
* // set default render target. This also invalidates the depth and stencil buffers of the current target (self.my_render_target)
|
|
1159
|
+
* // which can be an optimisation on some hardware
|
|
1160
|
+
* render.set_render_target(render.RENDER_TARGET_DEFAULT);
|
|
1161
|
+
* },
|
|
1162
|
+
* });
|
|
1163
|
+
* ```
|
|
1164
|
+
* @example
|
|
1165
|
+
* ```ts
|
|
1166
|
+
* export default defineRenderScript({
|
|
1167
|
+
* init() {
|
|
1168
|
+
* return { my_pred: render.predicate([hash("my_tag")]) };
|
|
1169
|
+
* },
|
|
1170
|
+
*
|
|
1171
|
+
* update(self, dt) {
|
|
1172
|
+
* // set render target by a render target resource identifier
|
|
1173
|
+
* render.set_render_target("my_rt_resource");
|
|
1174
|
+
*
|
|
1175
|
+
* // draw a predicate to the render target
|
|
1176
|
+
* render.draw(self.my_pred);
|
|
1177
|
+
*
|
|
1178
|
+
* // reset the render target to the default backbuffer
|
|
1179
|
+
* render.set_render_target(render.RENDER_TARGET_DEFAULT);
|
|
1180
|
+
* },
|
|
1181
|
+
* });
|
|
1182
|
+
* ```
|
|
1183
|
+
*/
|
|
1184
|
+
function set_render_target(render_target: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT | undefined, options: { transient?: graphics.BufferType[] }): void;
|
|
1047
1185
|
/**
|
|
1048
1186
|
* Sets the render target size for a render target created from
|
|
1049
1187
|
* either a render script, or from a render target resource.
|
|
@@ -277,7 +277,7 @@ declare global {
|
|
|
277
277
|
* });
|
|
278
278
|
* ```
|
|
279
279
|
*/
|
|
280
|
-
function create_buffer(path: string, table: { buffer: Opaque<"buffer"
|
|
280
|
+
function create_buffer(path: string, table: { buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }; transfer_ownership?: boolean }): Hash;
|
|
281
281
|
/**
|
|
282
282
|
* Creates a sound data resource
|
|
283
283
|
* Supported formats are .oggc, .opusc and .wavc
|
|
@@ -310,7 +310,7 @@ declare global {
|
|
|
310
310
|
* });
|
|
311
311
|
* ```
|
|
312
312
|
*/
|
|
313
|
-
function create_sound_data(path: string, options: { data: string | Opaque<"buffer">; filesize?: number; partial?: boolean }): Hash;
|
|
313
|
+
function create_sound_data(path: string, options: { data: string | Opaque<"buffer">; filesize?: number; partial?: boolean } & ({ partial?: false } | ({ partial: true } & Required<Pick<{ data: string | Opaque<"buffer">; filesize?: number; partial?: boolean }, "filesize">>))): Hash;
|
|
314
314
|
/**
|
|
315
315
|
* Creates a new texture resource that can be used in the same way as any texture created during build time.
|
|
316
316
|
* The path used for creating the texture must be unique, trying to create a resource at a path that is already
|
|
@@ -500,7 +500,7 @@ declare global {
|
|
|
500
500
|
* }
|
|
501
501
|
* ```
|
|
502
502
|
*/
|
|
503
|
-
function create_texture(path: string, table: { type: number; width: number; height: number; depth?: number; format: number; flags?: number; max_mipmaps?: number; compression_type?: number; page_count?: number }, buffer?: Opaque<"buffer">): Hash;
|
|
503
|
+
function create_texture(path: string, table: { type: number; width: number; height: number; depth?: number; format: number; flags?: number; max_mipmaps?: number; compression_type?: number; page_count?: number }, buffer?: Opaque<"buffer"> & { length: LuaLengthMethod<number> }): Hash;
|
|
504
504
|
/**
|
|
505
505
|
* Creates a new texture resource that can be used in the same way as any texture created during build time.
|
|
506
506
|
* The path used for creating the texture must be unique, trying to create a resource at a path that is already
|
|
@@ -670,7 +670,7 @@ declare global {
|
|
|
670
670
|
* });
|
|
671
671
|
* ```
|
|
672
672
|
*/
|
|
673
|
-
function create_texture_async(path: string, table: { type: number; width: number; height: number; depth?: number; format: number; flags?: number; max_mipmaps?: number; compression_type?: number }, buffer: Opaque<"buffer"> | undefined, callback: (...args: unknown[]) => unknown): LuaMultiReturn<[Hash, number]>;
|
|
673
|
+
function create_texture_async(path: string, table: { type: number; width: number; height: number; depth?: number; format: number; flags?: number; max_mipmaps?: number; compression_type?: number }, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> } | undefined, callback: (...args: unknown[]) => unknown): LuaMultiReturn<[Hash, number]>;
|
|
674
674
|
/**
|
|
675
675
|
* Constructor-like function with two purposes:
|
|
676
676
|
*
|
|
@@ -749,7 +749,7 @@ declare global {
|
|
|
749
749
|
* });
|
|
750
750
|
* ```
|
|
751
751
|
*/
|
|
752
|
-
function get_buffer(path: Hash | string): Opaque<"buffer"
|
|
752
|
+
function get_buffer(path: Hash | string): Opaque<"buffer"> & { length: LuaLengthMethod<number> };
|
|
753
753
|
/**
|
|
754
754
|
* Gets render target info from a render target resource path or a render target handle
|
|
755
755
|
*
|
|
@@ -848,7 +848,40 @@ declare global {
|
|
|
848
848
|
* });
|
|
849
849
|
* ```
|
|
850
850
|
*/
|
|
851
|
-
function get_text_metrics(url: Hash | string, text: string
|
|
851
|
+
function get_text_metrics(url: Hash | string, text: string): { width: number; height: number; max_ascent: number; max_descent: number };
|
|
852
|
+
/**
|
|
853
|
+
* Gets the text metrics from a font
|
|
854
|
+
*
|
|
855
|
+
* @param url - the font to get the (unscaled) metrics from
|
|
856
|
+
* @param text - text to measure
|
|
857
|
+
* @param options - A table containing parameters for the text. Supported entries:
|
|
858
|
+
*
|
|
859
|
+
* `width`
|
|
860
|
+
* number The width of the text field. Not used if `line_break` is false.
|
|
861
|
+
* `leading`
|
|
862
|
+
* number The leading (default 1.0)
|
|
863
|
+
* `tracking`
|
|
864
|
+
* number The tracking (default 0.0)
|
|
865
|
+
* `line_break`
|
|
866
|
+
* boolean If the calculation should consider line breaks (default false)
|
|
867
|
+
* @returns a table with the following fields:
|
|
868
|
+
*
|
|
869
|
+
* - width
|
|
870
|
+
* - height
|
|
871
|
+
* - max_ascent
|
|
872
|
+
* - max_descent
|
|
873
|
+
* @example
|
|
874
|
+
* ```ts
|
|
875
|
+
* export default defineScript({
|
|
876
|
+
* init() {
|
|
877
|
+
* const font = go.get<label.properties>()("#label", "font");
|
|
878
|
+
* const metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog");
|
|
879
|
+
* pprint(metrics);
|
|
880
|
+
* },
|
|
881
|
+
* });
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
function get_text_metrics(url: Hash | string, text: string, options: { width?: number; leading?: number; tracking?: number; line_break?: boolean }): { width: number; height: number; max_ascent: number; max_descent: number };
|
|
852
885
|
/**
|
|
853
886
|
* Gets texture info from a texture resource path or a texture handle
|
|
854
887
|
*
|
|
@@ -947,7 +980,7 @@ declare global {
|
|
|
947
980
|
* // custom_resources = resources/,assets/level_data.json
|
|
948
981
|
* ```
|
|
949
982
|
*/
|
|
950
|
-
function load(path: string): Opaque<"buffer"
|
|
983
|
+
function load(path: string): Opaque<"buffer"> & { length: LuaLengthMethod<number> };
|
|
951
984
|
/**
|
|
952
985
|
* Constructor-like function with two purposes:
|
|
953
986
|
*
|
|
@@ -1034,7 +1067,7 @@ declare global {
|
|
|
1034
1067
|
* resource.set(go.get<sprite.properties>()("#sprite", "texture0"), buffer);
|
|
1035
1068
|
* ```
|
|
1036
1069
|
*/
|
|
1037
|
-
function set(path: string | Hash, buffer: Opaque<"buffer">): void;
|
|
1070
|
+
function set(path: string | Hash, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }): void;
|
|
1038
1071
|
/**
|
|
1039
1072
|
* Sets the data for a specific atlas resource. Setting new atlas data is specified by passing in
|
|
1040
1073
|
* a texture path for the backing texture of the atlas, a list of geometries and a list of animations
|
|
@@ -1213,7 +1246,7 @@ declare global {
|
|
|
1213
1246
|
* });
|
|
1214
1247
|
* ```
|
|
1215
1248
|
*/
|
|
1216
|
-
function set_buffer(path: Hash | string, buffer: Opaque<"buffer"
|
|
1249
|
+
function set_buffer(path: Hash | string, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, table?: { transfer_ownership?: boolean }): void;
|
|
1217
1250
|
/**
|
|
1218
1251
|
* Update internal sound resource (wavc/oggc/opusc) with new data
|
|
1219
1252
|
*
|
|
@@ -1466,7 +1499,7 @@ declare global {
|
|
|
1466
1499
|
* }
|
|
1467
1500
|
* ```
|
|
1468
1501
|
*/
|
|
1469
|
-
function set_texture(path: Hash | string, table: { type: number; width: number; height: number; format: number; x?: number; y?: number; z?: number; page?: number; mipmap?: number; compression_type?: number }, buffer: Opaque<"buffer">): void;
|
|
1502
|
+
function set_texture(path: Hash | string, table: { type: number; width: number; height: number; format: number; x?: number; y?: number; z?: number; page?: number; mipmap?: number; compression_type?: number }, buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }): void;
|
|
1470
1503
|
/**
|
|
1471
1504
|
* Constructor-like function with two purposes:
|
|
1472
1505
|
*
|
|
@@ -62,7 +62,64 @@ declare global {
|
|
|
62
62
|
* });
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
function play_flipbook(url: string | Hash | Url, id: string | Hash, complete_function?: (self: unknown, message_id: Hash, message: { current_tile: number; id: Hash }, sender: Url) => void
|
|
65
|
+
function play_flipbook(url: string | Hash | Url, id: string | Hash, complete_function?: (self: unknown, message_id: Hash, message: { current_tile: number; id: Hash }, sender: Url) => void): void;
|
|
66
|
+
/**
|
|
67
|
+
* Play an animation on a sprite component from its tile set
|
|
68
|
+
* An optional completion callback function can be provided that will be called when
|
|
69
|
+
* the animation has completed playing. If no function is provided,
|
|
70
|
+
* a animation_done message is sent to the script that started the animation.
|
|
71
|
+
*
|
|
72
|
+
* @param url - the sprite that should play the animation
|
|
73
|
+
* @param id - hashed id of the animation to play
|
|
74
|
+
* @param complete_function - function to call when the animation has completed.
|
|
75
|
+
*
|
|
76
|
+
* `self`
|
|
77
|
+
* object The current object.
|
|
78
|
+
* `message_id`
|
|
79
|
+
* hash The name of the completion message, `"animation_done"`.
|
|
80
|
+
* `message`
|
|
81
|
+
* table Information about the completion:
|
|
82
|
+
*
|
|
83
|
+
* - number `current_tile` - the current tile of the sprite.
|
|
84
|
+
* - hash `id` - id of the animation that was completed.
|
|
85
|
+
*
|
|
86
|
+
* `sender`
|
|
87
|
+
* url The invoker of the callback: the sprite component.
|
|
88
|
+
* @param play_properties - optional table with properties:
|
|
89
|
+
*
|
|
90
|
+
* `offset`
|
|
91
|
+
* number the normalized initial value of the animation cursor when the animation starts playing.
|
|
92
|
+
* `playback_rate`
|
|
93
|
+
* number the rate with which the animation will be played. Must be positive.
|
|
94
|
+
* @example
|
|
95
|
+
* The following examples assumes that the model has id "sprite".
|
|
96
|
+
* How to play the "jump" animation followed by the "run" animation:
|
|
97
|
+
* ```ts
|
|
98
|
+
* const url = msg.url("#sprite");
|
|
99
|
+
*
|
|
100
|
+
* function anim_done(self: unknown, message_id: Hash, message: { id: Hash }) {
|
|
101
|
+
* if (message_id === hash("animation_done") && message.id === hash("jump")) {
|
|
102
|
+
* // jump animation done, chain with "run"
|
|
103
|
+
* sprite.play_flipbook(url, "run");
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* export default defineScript({
|
|
110
|
+
* init() {
|
|
111
|
+
* const url = msg.url("#sprite");
|
|
112
|
+
* sprite.play_flipbook(url, "jump", (self, message_id, message) => {
|
|
113
|
+
* if (message_id === hash("animation_done") && message.id === hash("jump")) {
|
|
114
|
+
* // jump animation done, chain with "run"
|
|
115
|
+
* sprite.play_flipbook(url, "run");
|
|
116
|
+
* }
|
|
117
|
+
* });
|
|
118
|
+
* },
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
function play_flipbook(url: string | Hash | Url, id: string | Hash, complete_function: ((self: unknown, message_id: Hash, message: { current_tile: number; id: Hash }, sender: Url) => void) | undefined, play_properties: { offset?: number; playback_rate?: number }): void;
|
|
66
123
|
/**
|
|
67
124
|
* Resets a shader constant for a sprite component.
|
|
68
125
|
* The constant must be defined in the material assigned to the sprite.
|