@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
package/generated/http.d.ts
CHANGED
|
@@ -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
|
|
package/generated/image.d.ts
CHANGED
|
@@ -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
|
*/
|
package/generated/material.d.ts
CHANGED
|
@@ -371,7 +371,7 @@ declare global {
|
|
|
371
371
|
* material.set_textures(resource.material("/my_material.materialc"), { my_texture: resource.texture() });
|
|
372
372
|
* ```
|
|
373
373
|
*/
|
|
374
|
-
function set_textures(path: Hash | string, textures: LuaMap<string, Hash>): void;
|
|
374
|
+
function set_textures(path: Hash | string, textures: LuaMap<string, Hash> | Record<string, Hash>): void;
|
|
375
375
|
/**
|
|
376
376
|
* Sets vertex attributes in a material, if the vertex attributes exist.
|
|
377
377
|
*
|
package/generated/model.d.ts
CHANGED
|
@@ -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
|
}
|
package/generated/physics.d.ts
CHANGED
|
@@ -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
|
* ```
|
package/generated/profiler.d.ts
CHANGED
|
@@ -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;
|
package/generated/render.d.ts
CHANGED
|
@@ -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;
|