@defold-typescript/types 0.50.1 → 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 +1128 -1552
- package/api-targets.json +15 -5
- package/examples/translations.json +19 -71
- package/fixtures/messages_doc.json +20 -39
- package/generated/b2d_world.d.ts +10 -10
- package/generated/buffer.d.ts +9 -9
- package/generated/builtin-messages.d.ts +16 -14
- 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/collectionfactory.d.ts +1 -1
- package/generated/collectionproxy.d.ts +2 -2
- package/generated/factory.d.ts +4 -2
- package/generated/go.d.ts +114 -220
- package/generated/graphics.d.ts +5 -0
- package/generated/gui.d.ts +148 -371
- package/generated/http.d.ts +4 -2
- package/generated/image.d.ts +56 -4
- package/generated/kinds/gui-script.d.ts +3 -0
- package/generated/kinds/render-script.d.ts +15 -15
- package/generated/kinds/script.d.ts +1 -0
- package/generated/liveupdate.d.ts +5 -1
- package/generated/material.d.ts +3 -3
- package/generated/model.d.ts +4 -5
- package/generated/particlefx.d.ts +20 -1
- package/generated/physics.d.ts +48 -4
- 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 +175 -21
- package/generated/resource.d.ts +31 -10
- package/generated/sprite.d.ts +49 -1
- package/generated/sys.d.ts +78 -10
- package/generated/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.12.4/factory.d.ts +4 -2
- 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 +4 -2
- package/generated/versions/defold-1.12.4/image.d.ts +83 -3
- package/generated/versions/defold-1.12.4/index.d.ts +2 -0
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.12.4/model.d.ts +4 -5
- package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.12.4/physics.d.ts +47 -3
- package/generated/versions/defold-1.12.4/render.d.ts +119 -15
- 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/tilemap.d.ts +4 -4
- 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/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.13.0/factory.d.ts +4 -2
- 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 +4 -2
- package/generated/versions/defold-1.13.0/image.d.ts +83 -3
- package/generated/versions/defold-1.13.0/index.d.ts +2 -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/model.d.ts +4 -5
- package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.0/physics.d.ts +47 -3
- package/generated/versions/defold-1.13.0/render.d.ts +182 -16
- 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/tilemap.d.ts +4 -4
- 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/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.13.1/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.13.1/factory.d.ts +4 -2
- 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 +4 -2
- package/generated/versions/defold-1.13.1/image.d.ts +83 -3
- package/generated/versions/defold-1.13.1/index.d.ts +3 -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/model.d.ts +4 -5
- package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.1/physics.d.ts +47 -3
- package/generated/versions/defold-1.13.1/render.d.ts +182 -16
- 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/tilemap.d.ts +4 -4
- 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/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.13.2/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.13.2/factory.d.ts +4 -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 +4 -2
- package/generated/versions/defold-1.13.2/image.d.ts +56 -4
- package/generated/versions/defold-1.13.2/index.d.ts +3 -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/model.d.ts +4 -5
- package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
- package/generated/versions/defold-1.13.2/physics.d.ts +48 -4
- package/generated/versions/defold-1.13.2/render.d.ts +164 -20
- 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 +78 -10
- package/generated/versions/defold-1.13.2/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.2/window.d.ts +1 -1
- package/generated/vmath.d.ts +0 -24
- package/generated/window.d.ts +1 -1
- package/identity-vocabulary.json +98 -7
- package/index.d.ts +3 -0
- package/package.json +3 -1
- package/scripts/generate-api-availability.ts +6 -22
- package/scripts/generate-api-signatures.ts +87 -21
- package/scripts/materialize-version.ts +53 -6
- package/scripts/regen.ts +256 -44
- 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 +226 -6
- package/src/core-types.ts +82 -20
- package/src/doc-corrections.ts +53 -5
- package/src/emit-dts.ts +1300 -269
- package/src/emit-messages.ts +289 -0
- package/src/engine-globals.d.ts +8 -2
- package/src/go-overloads.d.ts +80 -15
- 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 +46 -37
- package/src/luals-type-expr.ts +6 -1
- package/src/msg-overloads.d.ts +25 -13
- package/src/physics-event-guard.d.ts +39 -0
- package/src/render-overloads.d.ts +2 -2
- package/src/return-correction-provenance.ts +36 -6
- package/src/signature-store.ts +50 -0
- package/src/timers.d.ts +2 -1
- package/src/vmath-overloads.d.ts +26 -0
- package/src/window-event-guard.d.ts +5 -3
|
@@ -54,7 +54,7 @@ declare global {
|
|
|
54
54
|
/**
|
|
55
55
|
* Script buffer containing the decompressed image data.
|
|
56
56
|
*/
|
|
57
|
-
buffer: Opaque<"buffer"
|
|
57
|
+
buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> };
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Image loading options
|
|
@@ -122,7 +122,7 @@ declare global {
|
|
|
122
122
|
* }
|
|
123
123
|
* ```
|
|
124
124
|
*/
|
|
125
|
-
function get_astc_header(buffer: string): image.astc_header
|
|
125
|
+
function get_astc_header(buffer: string): image.astc_header;
|
|
126
126
|
/**
|
|
127
127
|
* Load image (PNG or JPEG) from buffer.
|
|
128
128
|
*
|
|
@@ -141,7 +141,59 @@ declare global {
|
|
|
141
141
|
* });
|
|
142
142
|
* ```
|
|
143
143
|
*/
|
|
144
|
-
function load(buffer: string
|
|
144
|
+
function load(buffer: string): image.load_result | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Load image (PNG or JPEG) from buffer.
|
|
147
|
+
*
|
|
148
|
+
* @param buffer - image data buffer
|
|
149
|
+
* @param options - Optional loading parameters. A boolean is accepted for backwards compatibility and controls `premultiply_alpha`.
|
|
150
|
+
* @returns loaded image, or `nil` if loading fails
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* // How to load an image from an URL and create a GUI texture from it:
|
|
154
|
+
* const imgurl = "http://www.site.com/image.png";
|
|
155
|
+
* http.request(imgurl, "GET", (self, id, response) => {
|
|
156
|
+
* const img = response.response !== undefined ? image.load(response.response) : undefined;
|
|
157
|
+
* if (img !== undefined) {
|
|
158
|
+
* const tx = gui.new_texture("image_node", img.width, img.height, img.type, img.buffer);
|
|
159
|
+
* }
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
function load(buffer: string, options: boolean | image.load_options): image.load_result | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Load image (PNG or JPEG) from a string buffer.
|
|
166
|
+
*
|
|
167
|
+
* @param buffer - image data buffer
|
|
168
|
+
* @param options - Optional loading parameters. A boolean is accepted for backwards compatibility and controls `premultiply_alpha`.
|
|
169
|
+
* @returns loaded image, or `nil` if loading fails
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* // Load an image from an URL as a buffer and create a texture resource from it:
|
|
173
|
+
* const imgurl = "http://www.site.com/image.png";
|
|
174
|
+
* http.request(imgurl, "GET", (self, id, response) => {
|
|
175
|
+
* const img =
|
|
176
|
+
* response.response !== undefined
|
|
177
|
+
* ? image.load_buffer(response.response, { flip_vertically: true })
|
|
178
|
+
* : undefined;
|
|
179
|
+
* // the engine registers a texture format only when the driver supports it
|
|
180
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
181
|
+
* if (img !== undefined && format !== undefined) {
|
|
182
|
+
* const tparams = {
|
|
183
|
+
* width: img.width,
|
|
184
|
+
* height: img.height,
|
|
185
|
+
* type: graphics.TEXTURE_TYPE_2D,
|
|
186
|
+
* format,
|
|
187
|
+
* };
|
|
188
|
+
*
|
|
189
|
+
* const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams, img.buffer);
|
|
190
|
+
* // Apply the texture to a model
|
|
191
|
+
* go.set("/go1#model", "texture0", my_texture_id);
|
|
192
|
+
* }
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
function load_buffer(buffer: string): image.load_buffer_result | undefined;
|
|
145
197
|
/**
|
|
146
198
|
* Load image (PNG or JPEG) from a string buffer.
|
|
147
199
|
*
|
|
@@ -174,7 +226,7 @@ declare global {
|
|
|
174
226
|
* });
|
|
175
227
|
* ```
|
|
176
228
|
*/
|
|
177
|
-
function load_buffer(buffer: string, options
|
|
229
|
+
function load_buffer(buffer: string, options: boolean | image.load_options): image.load_buffer_result | undefined;
|
|
178
230
|
}
|
|
179
231
|
}
|
|
180
232
|
|
|
@@ -53,10 +53,13 @@ import "../../../src/engine-globals";
|
|
|
53
53
|
import "../../../src/msg-overloads";
|
|
54
54
|
import "../../../src/message-guard";
|
|
55
55
|
import "../../../src/window-event-guard";
|
|
56
|
+
import "../../../src/physics-event-guard";
|
|
56
57
|
import "../../../src/scene-addresses";
|
|
57
58
|
import "../../../src/go-overloads";
|
|
58
59
|
import "../../../src/component-properties";
|
|
59
60
|
import "../../../src/render-overloads";
|
|
61
|
+
import "../../../src/gui-overloads";
|
|
62
|
+
import "../../../src/gui-texture-removal";
|
|
60
63
|
import "../../../src/vmath-overloads";
|
|
61
64
|
import "../../../src/sys-overloads";
|
|
62
65
|
|
|
@@ -6,7 +6,7 @@ declare global {
|
|
|
6
6
|
* Functions and constants to access resources.
|
|
7
7
|
*/
|
|
8
8
|
namespace liveupdate {
|
|
9
|
-
type LIVEUPDATE = typeof liveupdate.LIVEUPDATE_BUNDLED_RESOURCE_MISMATCH | typeof liveupdate.LIVEUPDATE_ENGINE_VERSION_MISMATCH | typeof liveupdate.LIVEUPDATE_FORMAT_ERROR | typeof liveupdate.LIVEUPDATE_INVAL | typeof liveupdate.LIVEUPDATE_INVALID_HEADER | typeof liveupdate.LIVEUPDATE_INVALID_RESOURCE | typeof liveupdate.LIVEUPDATE_IO_ERROR | typeof liveupdate.LIVEUPDATE_MEM_ERROR | typeof liveupdate.LIVEUPDATE_OK | typeof liveupdate.LIVEUPDATE_SCHEME_MISMATCH | typeof liveupdate.LIVEUPDATE_SIGNATURE_MISMATCH | typeof liveupdate.LIVEUPDATE_UNKNOWN | typeof liveupdate.LIVEUPDATE_VERSION_MISMATCH;
|
|
9
|
+
type LIVEUPDATE = typeof liveupdate.LIVEUPDATE_BUNDLED_RESOURCE_MISMATCH | typeof liveupdate.LIVEUPDATE_ENGINE_VERSION_MISMATCH | typeof liveupdate.LIVEUPDATE_FORMAT_ERROR | typeof liveupdate.LIVEUPDATE_INVAL | typeof liveupdate.LIVEUPDATE_INVALID_HEADER | typeof liveupdate.LIVEUPDATE_INVALID_RESOURCE | typeof liveupdate.LIVEUPDATE_IO_ERROR | typeof liveupdate.LIVEUPDATE_MEM_ERROR | typeof liveupdate.LIVEUPDATE_OK | typeof liveupdate.LIVEUPDATE_SCHEME_MISMATCH | typeof liveupdate.LIVEUPDATE_SIGNATURE_MISMATCH | typeof liveupdate.LIVEUPDATE_UNKNOWN | typeof liveupdate.LIVEUPDATE_VERSION_MISMATCH | typeof liveupdate.LIVEUPDATE_NOT_INITIALIZED;
|
|
10
10
|
/**
|
|
11
11
|
* Mismatch between between expected bundled resources and actual bundled resources. The manifest expects a resource to be in the bundle, but it was not found in the bundle. This is typically the case when a non-excluded resource was modified between publishing the bundle and publishing the manifest.
|
|
12
12
|
*/
|
|
@@ -39,6 +39,10 @@ declare global {
|
|
|
39
39
|
* Memory wasn't allocated
|
|
40
40
|
*/
|
|
41
41
|
const LIVEUPDATE_MEM_ERROR: number & { readonly __brand: "liveupdate.LIVEUPDATE_MEM_ERROR" };
|
|
42
|
+
/**
|
|
43
|
+
* Live update is not initialized. `liveupdate.add_mount` and `liveupdate.remove_mount` return it while live update is disabled.
|
|
44
|
+
*/
|
|
45
|
+
const LIVEUPDATE_NOT_INITIALIZED: number & { readonly __brand: "liveupdate.LIVEUPDATE_NOT_INITIALIZED" };
|
|
42
46
|
/**
|
|
43
47
|
* Operation completed successfully.
|
|
44
48
|
*/
|
|
@@ -78,7 +78,7 @@ declare global {
|
|
|
78
78
|
/**
|
|
79
79
|
* Sampler texture type.
|
|
80
80
|
*/
|
|
81
|
-
type: graphics.TEXTURE_TYPE;
|
|
81
|
+
type: graphics.TEXTURE_TYPE | 6 | 7 | 8 | 9 | 10;
|
|
82
82
|
/**
|
|
83
83
|
* Horizontal wrap mode.
|
|
84
84
|
*/
|
|
@@ -348,7 +348,7 @@ declare global {
|
|
|
348
348
|
* Returns a table of all the textures from the material.
|
|
349
349
|
*
|
|
350
350
|
* @param path - The path to the resource
|
|
351
|
-
* @returns material texture information
|
|
351
|
+
* @returns material texture information. Keyed by sampler slot from 1; a slot with no texture has no entry, so iterate with `for (const [slot, info] of textures)`.
|
|
352
352
|
* @example
|
|
353
353
|
* ```ts
|
|
354
354
|
* // Get the textures from a material specified as a resource property
|
|
@@ -363,7 +363,7 @@ declare global {
|
|
|
363
363
|
* });
|
|
364
364
|
* ```
|
|
365
365
|
*/
|
|
366
|
-
function get_textures(path: Hash | string): material.texture_info
|
|
366
|
+
function get_textures(path: Hash | string): LuaMap<number, material.texture_info>;
|
|
367
367
|
/**
|
|
368
368
|
* Returns a table of all the vertex attributes in the material. This function will return all the vertex attributes
|
|
369
369
|
* that are used in the vertex shader of the material.
|
|
@@ -164,10 +164,9 @@ declare global {
|
|
|
164
164
|
* // How to play the "jump" animation followed by the "run" animation:
|
|
165
165
|
* const url = msg.url("#model");
|
|
166
166
|
*
|
|
167
|
-
* function anim_done(self: unknown, message_id:
|
|
167
|
+
* function anim_done(self: unknown, message_id: Hash, message: { animation_id: Hash }) {
|
|
168
168
|
* if (message_id === hash("model_animation_done")) {
|
|
169
|
-
*
|
|
170
|
-
* if (animation_id === hash("jump")) {
|
|
169
|
+
* if (message.animation_id === hash("jump")) {
|
|
171
170
|
* // open animation done, chain with "run"
|
|
172
171
|
* const properties = { blend_duration: 0.2 };
|
|
173
172
|
* model.play_anim(url, "run", go.PLAYBACK_LOOP_FORWARD, properties, anim_done);
|
|
@@ -184,7 +183,7 @@ declare global {
|
|
|
184
183
|
* });
|
|
185
184
|
* ```
|
|
186
185
|
*/
|
|
187
|
-
function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: go.PLAYBACK, play_properties?: model.play_properties, complete_function?: (self: unknown, message_id: Hash, message: BuiltinMessages["model_animation_done"]
|
|
186
|
+
function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: go.PLAYBACK, play_properties?: model.play_properties, complete_function?: (self: unknown, message_id: Hash, message: BuiltinMessages["model_animation_done"]) => void): void;
|
|
188
187
|
/**
|
|
189
188
|
* Resets a shader constant for a model component.
|
|
190
189
|
* The constant must be defined in the material assigned to the model.
|
|
@@ -238,7 +237,7 @@ declare global {
|
|
|
238
237
|
/**
|
|
239
238
|
* The current animation set on the component. The type of the property is hash.
|
|
240
239
|
*/
|
|
241
|
-
animation: Hash;
|
|
240
|
+
readonly animation: Hash;
|
|
242
241
|
/**
|
|
243
242
|
* The normalized animation cursor. The type of the property is number.
|
|
244
243
|
* Please note that model events may not fire as expected when the cursor is manipulated directly.
|
|
@@ -128,7 +128,26 @@ declare global {
|
|
|
128
128
|
* });
|
|
129
129
|
* ```
|
|
130
130
|
*/
|
|
131
|
-
function stop(url: string | Hash | Url
|
|
131
|
+
function stop(url: string | Hash | Url): void;
|
|
132
|
+
/**
|
|
133
|
+
* Stops a particle FX component from playing.
|
|
134
|
+
* Stopping a particle FX does not remove already spawned particles.
|
|
135
|
+
* Which particle FX to stop is identified by the URL.
|
|
136
|
+
*
|
|
137
|
+
* @param url - the particle fx that should stop playing
|
|
138
|
+
* @param options - options used when stopping the particle fx
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* // How to stop a particle fx when a game object is deleted and immediately also
|
|
142
|
+
* // clear any spawned particles:
|
|
143
|
+
* export default defineScript({
|
|
144
|
+
* final(self) {
|
|
145
|
+
* particlefx.stop("#particlefx", { clear: true });
|
|
146
|
+
* },
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
function stop(url: string | Hash | Url, options: particlefx.stop_options): void;
|
|
132
151
|
interface properties {
|
|
133
152
|
/**
|
|
134
153
|
* The animation used during rendering by an emitter in a particle FX component.
|
|
@@ -6,7 +6,7 @@ declare global {
|
|
|
6
6
|
* Collision object physics API documentation
|
|
7
7
|
*/
|
|
8
8
|
namespace physics {
|
|
9
|
-
type event = BuiltinMessages["contact_point_event"] | BuiltinMessages["collision_event"] | BuiltinMessages["trigger_event"] | BuiltinMessages["ray_cast_response"] | BuiltinMessages["ray_cast_missed"];
|
|
9
|
+
type event = BuiltinMessages["contact_point_event"] & { type: Hash<"contact_point_event"> } | BuiltinMessages["collision_event"] & { type: Hash<"collision_event"> } | BuiltinMessages["trigger_event"] & { type: Hash<"trigger_event"> } | BuiltinMessages["ray_cast_response"] & { type: Hash<"ray_cast_response"> } | BuiltinMessages["ray_cast_missed"] & { type: Hash<"ray_cast_missed"> };
|
|
10
10
|
/**
|
|
11
11
|
* The available fields depend on the joint type.
|
|
12
12
|
*/
|
|
@@ -366,7 +366,7 @@ declare global {
|
|
|
366
366
|
* @returns It returns a list. If missed it returns `nil`. See ray_cast_response for details on the returned values.
|
|
367
367
|
* @example
|
|
368
368
|
* ```ts
|
|
369
|
-
* function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash
|
|
369
|
+
* function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash }) {
|
|
370
370
|
* // act on the hit (see 'ray_cast_response')
|
|
371
371
|
* }
|
|
372
372
|
*
|
|
@@ -391,7 +391,7 @@ declare global {
|
|
|
391
391
|
* });
|
|
392
392
|
* ```
|
|
393
393
|
*/
|
|
394
|
-
function raycast(from: Vector3, to: Vector3, groups: Hash[], options?: physics.raycast_options): BuiltinMessages["ray_cast_response"][] | BuiltinMessages["ray_cast_response"] | undefined;
|
|
394
|
+
function raycast(from: Vector3, to: Vector3, groups: Hash[], options?: physics.raycast_options): Omit<BuiltinMessages["ray_cast_response"], "request_id">[] | Omit<BuiltinMessages["ray_cast_response"], "request_id"> | undefined;
|
|
395
395
|
/**
|
|
396
396
|
* Ray casts are used to test for intersections against collision objects in the physics world.
|
|
397
397
|
* Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
|
|
@@ -435,7 +435,51 @@ declare global {
|
|
|
435
435
|
* });
|
|
436
436
|
* ```
|
|
437
437
|
*/
|
|
438
|
-
function raycast_async(from: Vector3, to: Vector3, groups: Hash[]
|
|
438
|
+
function raycast_async(from: Vector3, to: Vector3, groups: Hash[]): void;
|
|
439
|
+
/**
|
|
440
|
+
* Ray casts are used to test for intersections against collision objects in the physics world.
|
|
441
|
+
* Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
|
|
442
|
+
* do not intersect with ray casts.
|
|
443
|
+
* Which collision objects to hit is filtered by their collision groups and can be configured
|
|
444
|
+
* through `groups`.
|
|
445
|
+
* The actual ray cast will be performed during the physics-update.
|
|
446
|
+
*
|
|
447
|
+
* - If an object is hit, the result will be reported via a ray_cast_response message.
|
|
448
|
+
* - If there is no object hit, the result will be reported via a ray_cast_missed message.
|
|
449
|
+
*
|
|
450
|
+
* NOTE: Ray casts will ignore collision objects that contain the starting point of the ray. This is a limitation in Box2D.
|
|
451
|
+
*
|
|
452
|
+
* @param from - the world position of the start of the ray
|
|
453
|
+
* @param to - the world position of the end of the ray
|
|
454
|
+
* @param groups - a lua table containing the hashed groups for which to test collisions against
|
|
455
|
+
* @param request_id - a number in range [0,255]. It will be sent back in the response for identification, 0 by default
|
|
456
|
+
* @example
|
|
457
|
+
* ```ts
|
|
458
|
+
* // How to perform a ray cast asynchronously:
|
|
459
|
+
* export default defineScript({
|
|
460
|
+
* init() {
|
|
461
|
+
* return { my_groups: [hash("my_group1"), hash("my_group2")] };
|
|
462
|
+
* },
|
|
463
|
+
*
|
|
464
|
+
* update(self, dt) {
|
|
465
|
+
* // request ray cast
|
|
466
|
+
* const my_start = go.get_world_position();
|
|
467
|
+
* const my_end = vmath.vector3(my_start.x, my_start.y - 100, my_start.z);
|
|
468
|
+
* physics.raycast_async(my_start, my_end, self.my_groups);
|
|
469
|
+
* },
|
|
470
|
+
*
|
|
471
|
+
* on_message(self, message_id, message, sender) {
|
|
472
|
+
* // check for the response
|
|
473
|
+
* if (message_id === hash("ray_cast_response")) {
|
|
474
|
+
* // act on the hit
|
|
475
|
+
* } else if (message_id === hash("ray_cast_missed")) {
|
|
476
|
+
* // act on the miss
|
|
477
|
+
* }
|
|
478
|
+
* },
|
|
479
|
+
* });
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
function raycast_async(from: Vector3, to: Vector3, groups: Hash[], request_id: number): void;
|
|
439
483
|
/**
|
|
440
484
|
* Only one physics world event listener can be set at a time.
|
|
441
485
|
*
|
|
@@ -15,7 +15,7 @@ declare global {
|
|
|
15
15
|
*/
|
|
16
16
|
use_frustum?: boolean;
|
|
17
17
|
}
|
|
18
|
-
type constant_buffer = Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4
|
|
18
|
+
type constant_buffer = Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> };
|
|
19
19
|
/**
|
|
20
20
|
* Debug-draw options
|
|
21
21
|
*/
|
|
@@ -36,7 +36,7 @@ declare global {
|
|
|
36
36
|
/**
|
|
37
37
|
* Constants used by the compute program. The values are copied when `render.dispatch_compute()` is called.
|
|
38
38
|
*/
|
|
39
|
-
constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4
|
|
39
|
+
constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> };
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Render draw options
|
|
@@ -53,13 +53,13 @@ declare global {
|
|
|
53
53
|
/**
|
|
54
54
|
* Constants used while rendering. The values are copied when `render.draw()` is called.
|
|
55
55
|
*/
|
|
56
|
-
constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4
|
|
56
|
+
constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> };
|
|
57
57
|
/**
|
|
58
58
|
* World-entry sort order. The default is the renderer's preferred back-to-front order.
|
|
59
59
|
*/
|
|
60
60
|
sort_order?: render.SORT;
|
|
61
61
|
}
|
|
62
|
-
type render_predicate =
|
|
62
|
+
type render_predicate = Opaque<"render_predicate">;
|
|
63
63
|
type render_target = Opaque<"render_target">;
|
|
64
64
|
/**
|
|
65
65
|
* Render-target attachment parameters
|
|
@@ -114,6 +114,8 @@ declare global {
|
|
|
114
114
|
}
|
|
115
115
|
type texture = Opaque<"texture">;
|
|
116
116
|
type ClearBufferKey = typeof graphics.BUFFER_TYPE_COLOR0_BIT | typeof graphics.BUFFER_TYPE_DEPTH_BIT | typeof graphics.BUFFER_TYPE_STENCIL_BIT;
|
|
117
|
+
type RenderTargetTextureType = typeof graphics.TEXTURE_TYPE_2D | typeof graphics.TEXTURE_TYPE_CUBE_MAP;
|
|
118
|
+
type RenderTargetParams = render.render_target_params;
|
|
117
119
|
type CONTEXT_EVENT = typeof render.CONTEXT_EVENT_CONTEXT_LOST | typeof render.CONTEXT_EVENT_CONTEXT_RESTORED;
|
|
118
120
|
type FRUSTUM_PLANES = typeof render.FRUSTUM_PLANES_ALL | typeof render.FRUSTUM_PLANES_SIDES;
|
|
119
121
|
type RENDER_TARGET_FLAG = typeof render.TEXTURE_BIT;
|
|
@@ -218,7 +220,7 @@ declare global {
|
|
|
218
220
|
* constants.light_colors[3] = vmath.vector4(1, 1, 1, 1);
|
|
219
221
|
* ```
|
|
220
222
|
*/
|
|
221
|
-
function constant_buffer(): Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4
|
|
223
|
+
function constant_buffer(): Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> };
|
|
222
224
|
/**
|
|
223
225
|
* Deletes a render target created by a render script.
|
|
224
226
|
* You cannot delete a render target resource.
|
|
@@ -231,9 +233,12 @@ declare global {
|
|
|
231
233
|
* return { my_render_target: render.render_target("my_target", {}) };
|
|
232
234
|
* },
|
|
233
235
|
*
|
|
234
|
-
* final
|
|
235
|
-
*
|
|
236
|
-
*
|
|
236
|
+
* // A render script has no final hook, so free the target on a message.
|
|
237
|
+
* on_message(self, message_id) {
|
|
238
|
+
* if (message_id === hash("release_target")) {
|
|
239
|
+
* // How to delete a render target:
|
|
240
|
+
* render.delete_render_target(self.my_render_target);
|
|
241
|
+
* }
|
|
237
242
|
* },
|
|
238
243
|
* });
|
|
239
244
|
* ```
|
|
@@ -287,7 +292,7 @@ declare global {
|
|
|
287
292
|
* });
|
|
288
293
|
* ```
|
|
289
294
|
*/
|
|
290
|
-
function disable_state(state: graphics.
|
|
295
|
+
function disable_state(state: graphics.State): void;
|
|
291
296
|
/**
|
|
292
297
|
* Disables a texture that has previourly been enabled.
|
|
293
298
|
*
|
|
@@ -296,8 +301,11 @@ declare global {
|
|
|
296
301
|
* ```ts
|
|
297
302
|
* export default defineRenderScript({
|
|
298
303
|
* init() {
|
|
304
|
+
* // the engine registers a texture format only when the driver supports it
|
|
305
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
306
|
+
* if (format === undefined) return undefined;
|
|
299
307
|
* const color_params = {
|
|
300
|
-
* format
|
|
308
|
+
* format,
|
|
301
309
|
* width: render.get_window_width(),
|
|
302
310
|
* height: render.get_window_height(),
|
|
303
311
|
* };
|
|
@@ -308,6 +316,7 @@ declare global {
|
|
|
308
316
|
* },
|
|
309
317
|
*
|
|
310
318
|
* update(self, dt) {
|
|
319
|
+
* if (self === undefined) return;
|
|
311
320
|
* render.enable_texture(0, self.my_render_target, graphics.BUFFER_TYPE_COLOR0_BIT);
|
|
312
321
|
* // draw a predicate with the render target available as texture 0 in the predicate
|
|
313
322
|
* // material shader.
|
|
@@ -318,7 +327,7 @@ declare global {
|
|
|
318
327
|
* });
|
|
319
328
|
* ```
|
|
320
329
|
*/
|
|
321
|
-
function disable_texture(binding:
|
|
330
|
+
function disable_texture(binding: string | Hash | number): void;
|
|
322
331
|
/**
|
|
323
332
|
* Dispatches the currently enabled compute program. The dispatch call takes three arguments x,y,z which constitutes
|
|
324
333
|
* the 'global working group' of the compute dispatch. Together with the 'local working group' specified in the compute shader
|
|
@@ -334,8 +343,11 @@ declare global {
|
|
|
334
343
|
* ```ts
|
|
335
344
|
* export default defineRenderScript({
|
|
336
345
|
* init() {
|
|
346
|
+
* // the engine registers a texture format only when the driver supports it
|
|
347
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
348
|
+
* if (format === undefined) return undefined;
|
|
337
349
|
* const color_params = {
|
|
338
|
-
* format
|
|
350
|
+
* format,
|
|
339
351
|
* width: render.get_window_width(),
|
|
340
352
|
* height: render.get_window_height(),
|
|
341
353
|
* };
|
|
@@ -346,6 +358,7 @@ declare global {
|
|
|
346
358
|
* },
|
|
347
359
|
*
|
|
348
360
|
* update(self, dt) {
|
|
361
|
+
* if (self === undefined) return;
|
|
349
362
|
* render.set_compute("bloom");
|
|
350
363
|
* render.enable_texture(0, self.backing_texture);
|
|
351
364
|
* render.enable_texture(1, self.scene_rt);
|
|
@@ -411,7 +424,56 @@ declare global {
|
|
|
411
424
|
* }
|
|
412
425
|
* ```
|
|
413
426
|
*/
|
|
414
|
-
function draw(predicate: Opaque<"render_predicate"
|
|
427
|
+
function draw(predicate: Opaque<"render_predicate">): void;
|
|
428
|
+
/**
|
|
429
|
+
* Draws all objects that match a specified predicate. An optional constant buffer can be
|
|
430
|
+
* provided to override the default constants. If no constants buffer is provided, a default
|
|
431
|
+
* system constants buffer is used containing constants as defined in materials and set through
|
|
432
|
+
* go.set (or particlefx.set_constant) on visual components.
|
|
433
|
+
*
|
|
434
|
+
* @param predicate - predicate to draw for
|
|
435
|
+
* @param options - optional draw options
|
|
436
|
+
* @example
|
|
437
|
+
* ```ts
|
|
438
|
+
* export default defineRenderScript({
|
|
439
|
+
* init() {
|
|
440
|
+
* // define a predicate matching anything with material tag "my_tag"
|
|
441
|
+
* return { my_pred: render.predicate([hash("my_tag")]) };
|
|
442
|
+
* },
|
|
443
|
+
*
|
|
444
|
+
* update(self, dt) {
|
|
445
|
+
* // draw everything in the my_pred predicate
|
|
446
|
+
* render.draw(self.my_pred);
|
|
447
|
+
* },
|
|
448
|
+
* });
|
|
449
|
+
* ```
|
|
450
|
+
* @example
|
|
451
|
+
* Draw predicate with constants:
|
|
452
|
+
* ```ts
|
|
453
|
+
* function draw_tinted(self: { my_pred: Opaque<"render_predicate"> }) {
|
|
454
|
+
* const constants = render.constant_buffer();
|
|
455
|
+
* constants.tint = vmath.vector4(1, 1, 1, 1);
|
|
456
|
+
* render.draw(self.my_pred, { constants });
|
|
457
|
+
* }
|
|
458
|
+
* ```
|
|
459
|
+
* @example
|
|
460
|
+
* Draw with predicate and frustum culling (without near+far planes):
|
|
461
|
+
* ```ts
|
|
462
|
+
* function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
|
|
463
|
+
* const frustum = self.proj.mul(self.view);
|
|
464
|
+
* render.draw(self.my_pred, { frustum });
|
|
465
|
+
* }
|
|
466
|
+
* ```
|
|
467
|
+
* @example
|
|
468
|
+
* Draw with predicate and frustum culling (with near+far planes):
|
|
469
|
+
* ```ts
|
|
470
|
+
* function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
|
|
471
|
+
* const frustum = self.proj.mul(self.view);
|
|
472
|
+
* render.draw(self.my_pred, { frustum, frustum_planes: render.FRUSTUM_PLANES_ALL });
|
|
473
|
+
* }
|
|
474
|
+
* ```
|
|
475
|
+
*/
|
|
476
|
+
function draw(predicate: Opaque<"render_predicate">, options: render.draw_options): void;
|
|
415
477
|
/**
|
|
416
478
|
* Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.
|
|
417
479
|
*
|
|
@@ -478,7 +540,7 @@ declare global {
|
|
|
478
540
|
* });
|
|
479
541
|
* ```
|
|
480
542
|
*/
|
|
481
|
-
function enable_state(state: graphics.
|
|
543
|
+
function enable_state(state: graphics.State): void;
|
|
482
544
|
/**
|
|
483
545
|
* Sets the specified texture handle for a render target attachment or a regular texture
|
|
484
546
|
* that should be used for rendering. The texture can be bound to either a texture unit
|
|
@@ -499,8 +561,11 @@ declare global {
|
|
|
499
561
|
* ```ts
|
|
500
562
|
* export default defineRenderScript({
|
|
501
563
|
* init() {
|
|
564
|
+
* // the engine registers a texture format only when the driver supports it
|
|
565
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
566
|
+
* if (format === undefined) return undefined;
|
|
502
567
|
* const color_params = {
|
|
503
|
-
* format
|
|
568
|
+
* format,
|
|
504
569
|
* width: render.get_window_width(),
|
|
505
570
|
* height: render.get_window_height(),
|
|
506
571
|
* };
|
|
@@ -511,6 +576,7 @@ declare global {
|
|
|
511
576
|
* },
|
|
512
577
|
*
|
|
513
578
|
* update(self, dt) {
|
|
579
|
+
* if (self === undefined) return;
|
|
514
580
|
* // enable target so all drawing is done to it
|
|
515
581
|
* render.set_render_target(self.my_render_target);
|
|
516
582
|
*
|
|
@@ -591,8 +657,11 @@ declare global {
|
|
|
591
657
|
* ```ts
|
|
592
658
|
* export default defineRenderScript({
|
|
593
659
|
* init() {
|
|
660
|
+
* // the engine registers a texture format only when the driver supports it
|
|
661
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
662
|
+
* if (format === undefined) return undefined;
|
|
594
663
|
* const color_params = {
|
|
595
|
-
* format
|
|
664
|
+
* format,
|
|
596
665
|
* width: render.get_window_width(),
|
|
597
666
|
* height: render.get_window_height(),
|
|
598
667
|
* };
|
|
@@ -604,6 +673,7 @@ declare global {
|
|
|
604
673
|
* },
|
|
605
674
|
*
|
|
606
675
|
* update(self, dt) {
|
|
676
|
+
* if (self === undefined) return;
|
|
607
677
|
* // get the height of the render target color buffer
|
|
608
678
|
* const h = render.get_render_target_height(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);
|
|
609
679
|
* // get the height of a render target resource
|
|
@@ -628,8 +698,11 @@ declare global {
|
|
|
628
698
|
* ```ts
|
|
629
699
|
* export default defineRenderScript({
|
|
630
700
|
* init() {
|
|
701
|
+
* // the engine registers a texture format only when the driver supports it
|
|
702
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
703
|
+
* if (format === undefined) return undefined;
|
|
631
704
|
* const color_params = {
|
|
632
|
-
* format
|
|
705
|
+
* format,
|
|
633
706
|
* width: render.get_window_width(),
|
|
634
707
|
* height: render.get_window_height(),
|
|
635
708
|
* };
|
|
@@ -641,6 +714,7 @@ declare global {
|
|
|
641
714
|
* },
|
|
642
715
|
*
|
|
643
716
|
* update(self, dt) {
|
|
717
|
+
* if (self === undefined) return;
|
|
644
718
|
* // get the width of the render target color buffer
|
|
645
719
|
* const w = render.get_render_target_width(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);
|
|
646
720
|
* // get the width of a render target resource
|
|
@@ -763,7 +837,7 @@ declare global {
|
|
|
763
837
|
* 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);
|
|
764
838
|
* ```
|
|
765
839
|
*/
|
|
766
|
-
function set_blend_func_separate(source_factor_color:
|
|
840
|
+
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;
|
|
767
841
|
/**
|
|
768
842
|
* Sets the current render camera to be used for rendering. If a render camera
|
|
769
843
|
* has been set by the render script, the renderer will be using its projection and view matrix
|
|
@@ -959,8 +1033,77 @@ declare global {
|
|
|
959
1033
|
* // 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
|
|
960
1034
|
* export default defineRenderScript({
|
|
961
1035
|
* init() {
|
|
1036
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1037
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
1038
|
+
* if (format === undefined) return undefined;
|
|
1039
|
+
* const color_params = {
|
|
1040
|
+
* format,
|
|
1041
|
+
* width: render.get_window_width(),
|
|
1042
|
+
* height: render.get_window_height(),
|
|
1043
|
+
* };
|
|
1044
|
+
* return {
|
|
1045
|
+
* my_render_target: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
|
|
1046
|
+
* my_pred: render.predicate([hash("my_tag")]),
|
|
1047
|
+
* };
|
|
1048
|
+
* },
|
|
1049
|
+
*
|
|
1050
|
+
* update(self, dt) {
|
|
1051
|
+
* if (self === undefined) return;
|
|
1052
|
+
* // set render target so all drawing is done to it
|
|
1053
|
+
* render.set_render_target(self.my_render_target, {
|
|
1054
|
+
* transient: [graphics.BUFFER_TYPE_DEPTH_BIT, graphics.BUFFER_TYPE_STENCIL_BIT],
|
|
1055
|
+
* });
|
|
1056
|
+
*
|
|
1057
|
+
* // draw a predicate to the render target
|
|
1058
|
+
* render.draw(self.my_pred);
|
|
1059
|
+
*
|
|
1060
|
+
* // set default render target. This also invalidates the depth and stencil buffers of the current target (self.my_render_target)
|
|
1061
|
+
* // which can be an optimisation on some hardware
|
|
1062
|
+
* render.set_render_target(render.RENDER_TARGET_DEFAULT);
|
|
1063
|
+
* },
|
|
1064
|
+
* });
|
|
1065
|
+
* ```
|
|
1066
|
+
* @example
|
|
1067
|
+
* ```ts
|
|
1068
|
+
* export default defineRenderScript({
|
|
1069
|
+
* init() {
|
|
1070
|
+
* return { my_pred: render.predicate([hash("my_tag")]) };
|
|
1071
|
+
* },
|
|
1072
|
+
*
|
|
1073
|
+
* update(self, dt) {
|
|
1074
|
+
* // set render target by a render target resource identifier
|
|
1075
|
+
* render.set_render_target("my_rt_resource");
|
|
1076
|
+
*
|
|
1077
|
+
* // draw a predicate to the render target
|
|
1078
|
+
* render.draw(self.my_pred);
|
|
1079
|
+
*
|
|
1080
|
+
* // reset the render target to the default backbuffer
|
|
1081
|
+
* render.set_render_target(render.RENDER_TARGET_DEFAULT);
|
|
1082
|
+
* },
|
|
1083
|
+
* });
|
|
1084
|
+
* ```
|
|
1085
|
+
*/
|
|
1086
|
+
function set_render_target(render_target?: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT): void;
|
|
1087
|
+
/**
|
|
1088
|
+
* Sets a render target. Subsequent draw operations will be to the
|
|
1089
|
+
* render target until it is replaced by a subsequent call to set_render_target.
|
|
1090
|
+
* This function supports render targets created by a render script, or a render target resource.
|
|
1091
|
+
*
|
|
1092
|
+
* @param render_target - render target to set. Omit it, pass `nil`, or use render.RENDER_TARGET_DEFAULT to set the default render target
|
|
1093
|
+
* @param options - optional render-target activation options
|
|
1094
|
+
* @example
|
|
1095
|
+
* How to set a render target and draw to it and then switch back to the default render target
|
|
1096
|
+
* 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
|
|
1097
|
+
* ```ts
|
|
1098
|
+
* // How to set a render target and draw to it and then switch back to the default render target
|
|
1099
|
+
* // 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
|
|
1100
|
+
* export default defineRenderScript({
|
|
1101
|
+
* init() {
|
|
1102
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1103
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
1104
|
+
* if (format === undefined) return undefined;
|
|
962
1105
|
* const color_params = {
|
|
963
|
-
* format
|
|
1106
|
+
* format,
|
|
964
1107
|
* width: render.get_window_width(),
|
|
965
1108
|
* height: render.get_window_height(),
|
|
966
1109
|
* };
|
|
@@ -971,6 +1114,7 @@ declare global {
|
|
|
971
1114
|
* },
|
|
972
1115
|
*
|
|
973
1116
|
* update(self, dt) {
|
|
1117
|
+
* if (self === undefined) return;
|
|
974
1118
|
* // set render target so all drawing is done to it
|
|
975
1119
|
* render.set_render_target(self.my_render_target, {
|
|
976
1120
|
* transient: [graphics.BUFFER_TYPE_DEPTH_BIT, graphics.BUFFER_TYPE_STENCIL_BIT],
|
|
@@ -1005,7 +1149,7 @@ declare global {
|
|
|
1005
1149
|
* });
|
|
1006
1150
|
* ```
|
|
1007
1151
|
*/
|
|
1008
|
-
function set_render_target(render_target
|
|
1152
|
+
function set_render_target(render_target: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT | undefined, options: render.set_render_target_options): void;
|
|
1009
1153
|
/**
|
|
1010
1154
|
* Sets the render target size for a render target created from
|
|
1011
1155
|
* either a render script, or from a render target resource.
|