@defold-typescript/types 0.50.0 → 0.51.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-signatures.json +286 -232
- package/examples/translations.json +15 -15
- package/fixtures/messages_doc.json +20 -39
- package/generated/builtin-messages.d.ts +16 -14
- package/generated/collectionfactory.d.ts +1 -1
- package/generated/collectionproxy.d.ts +2 -2
- package/generated/factory.d.ts +4 -2
- package/generated/graphics.d.ts +4 -0
- package/generated/gui.d.ts +2 -2
- package/generated/http.d.ts +3 -1
- package/generated/image.d.ts +1 -1
- 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/model.d.ts +4 -5
- package/generated/physics.d.ts +3 -3
- package/generated/render.d.ts +41 -13
- package/generated/sys.d.ts +8 -4
- package/generated/tilemap.d.ts +4 -4
- 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/gui.d.ts +2 -2
- package/generated/versions/defold-1.12.4/http.d.ts +3 -1
- package/generated/versions/defold-1.12.4/image.d.ts +1 -1
- package/generated/versions/defold-1.12.4/index.d.ts +1 -0
- package/generated/versions/defold-1.12.4/model.d.ts +4 -5
- package/generated/versions/defold-1.12.4/physics.d.ts +2 -2
- package/generated/versions/defold-1.12.4/render.d.ts +41 -13
- package/generated/versions/defold-1.12.4/sys.d.ts +1 -1
- package/generated/versions/defold-1.12.4/tilemap.d.ts +4 -4
- 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/gui.d.ts +2 -2
- package/generated/versions/defold-1.13.0/http.d.ts +3 -1
- package/generated/versions/defold-1.13.0/image.d.ts +1 -1
- package/generated/versions/defold-1.13.0/index.d.ts +1 -0
- package/generated/versions/defold-1.13.0/model.d.ts +4 -5
- package/generated/versions/defold-1.13.0/physics.d.ts +2 -2
- package/generated/versions/defold-1.13.0/render.d.ts +41 -13
- package/generated/versions/defold-1.13.0/sys.d.ts +1 -1
- package/generated/versions/defold-1.13.0/tilemap.d.ts +4 -4
- 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/gui.d.ts +2 -2
- package/generated/versions/defold-1.13.1/http.d.ts +3 -1
- package/generated/versions/defold-1.13.1/image.d.ts +1 -1
- package/generated/versions/defold-1.13.1/index.d.ts +1 -0
- package/generated/versions/defold-1.13.1/model.d.ts +4 -5
- package/generated/versions/defold-1.13.1/physics.d.ts +2 -2
- package/generated/versions/defold-1.13.1/render.d.ts +41 -13
- package/generated/versions/defold-1.13.1/sys.d.ts +1 -1
- package/generated/versions/defold-1.13.1/tilemap.d.ts +4 -4
- 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/gui.d.ts +2 -2
- package/generated/versions/defold-1.13.2/http.d.ts +3 -1
- package/generated/versions/defold-1.13.2/image.d.ts +1 -1
- package/generated/versions/defold-1.13.2/index.d.ts +1 -0
- package/generated/versions/defold-1.13.2/model.d.ts +4 -5
- package/generated/versions/defold-1.13.2/physics.d.ts +3 -3
- package/generated/versions/defold-1.13.2/render.d.ts +41 -13
- package/generated/versions/defold-1.13.2/sys.d.ts +8 -4
- package/generated/versions/defold-1.13.2/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.13.2/window.d.ts +1 -1
- package/generated/window.d.ts +1 -1
- package/identity-vocabulary.json +46 -0
- package/index.d.ts +1 -0
- package/package.json +2 -1
- package/scripts/generate-api-availability.ts +5 -1
- package/scripts/generate-api-signatures.ts +16 -11
- package/scripts/materialize-version.ts +7 -1
- package/scripts/regen.ts +42 -25
- package/src/component-properties.d.ts +137 -6
- package/src/core-types.ts +46 -11
- package/src/emit-dts.ts +555 -84
- package/src/emit-messages.ts +289 -0
- package/src/engine-globals.d.ts +3 -1
- package/src/go-overloads.d.ts +13 -3
- package/src/lifecycle.ts +16 -16
- package/src/luals-type-expr.ts +6 -1
- 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/window-event-guard.d.ts +5 -3
|
@@ -42,7 +42,9 @@ declare global {
|
|
|
42
42
|
* // create a new game object and provide property values
|
|
43
43
|
* const created = factory.create("#factory", undefined, undefined, { my_value: 1 });
|
|
44
44
|
* // communicate with the object
|
|
45
|
-
*
|
|
45
|
+
* if (created !== undefined) {
|
|
46
|
+
* msg.post(created, "hello");
|
|
47
|
+
* }
|
|
46
48
|
* },
|
|
47
49
|
* });
|
|
48
50
|
* ```
|
|
@@ -58,7 +60,7 @@ declare global {
|
|
|
58
60
|
* });
|
|
59
61
|
* ```
|
|
60
62
|
*/
|
|
61
|
-
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): Hash;
|
|
63
|
+
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): Hash | undefined;
|
|
62
64
|
/**
|
|
63
65
|
* This returns status of the factory.
|
|
64
66
|
* Calling this function when the factory is not marked as dynamic loading always returns
|
|
@@ -628,7 +628,7 @@ declare global {
|
|
|
628
628
|
* @param node - root node to clone
|
|
629
629
|
* @returns a table mapping node ids to the corresponding cloned nodes
|
|
630
630
|
*/
|
|
631
|
-
function clone_tree(node: Opaque<"node">):
|
|
631
|
+
function clone_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
|
|
632
632
|
/**
|
|
633
633
|
* Deletes the specified node. Any child nodes of the specified node will be
|
|
634
634
|
* recursively deleted.
|
|
@@ -1144,7 +1144,7 @@ declare global {
|
|
|
1144
1144
|
* @param node - root node to get node tree from
|
|
1145
1145
|
* @returns a table mapping node ids to the corresponding nodes
|
|
1146
1146
|
*/
|
|
1147
|
-
function get_tree(node: Opaque<"node">):
|
|
1147
|
+
function get_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
|
|
1148
1148
|
/**
|
|
1149
1149
|
* gets the node type
|
|
1150
1150
|
*
|
|
@@ -31,6 +31,8 @@ declare global {
|
|
|
31
31
|
* - number `range_start`: the start offset into the requested file
|
|
32
32
|
* - number `range_end`: the end offset into the requested file (inclusive)
|
|
33
33
|
* - number `document_size`: the full size of the requested file
|
|
34
|
+
*
|
|
35
|
+
* With `report_progress` set, the callback also receives progress events carrying `bytes_sent`, `bytes_received`, `bytes_total` and `url` but no `status`; `response.bytes_received !== undefined` marks a progress event, since a final response never carries it.
|
|
34
36
|
* @param headers - optional table with custom headers
|
|
35
37
|
* @param post_data - optional data to send
|
|
36
38
|
* @param options - optional table with request parameters. Supported entries:
|
|
@@ -70,7 +72,7 @@ declare global {
|
|
|
70
72
|
* });
|
|
71
73
|
* ```
|
|
72
74
|
*/
|
|
73
|
-
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;
|
|
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;
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -44,7 +44,7 @@ declare global {
|
|
|
44
44
|
* }
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
function get_astc_header(buffer: string): { width: number; height: number; depth: number; block_size_x: number; block_size_y: number; block_size_z: number }
|
|
47
|
+
function get_astc_header(buffer: string): { width: number; height: number; depth: number; block_size_x: number; block_size_y: number; block_size_z: number };
|
|
48
48
|
/**
|
|
49
49
|
* Load image (PNG or JPEG) from buffer.
|
|
50
50
|
*
|
|
@@ -47,6 +47,7 @@ import "../../../src/engine-globals";
|
|
|
47
47
|
import "../../../src/msg-overloads";
|
|
48
48
|
import "../../../src/message-guard";
|
|
49
49
|
import "../../../src/window-event-guard";
|
|
50
|
+
import "../../../src/physics-event-guard";
|
|
50
51
|
import "../../../src/scene-addresses";
|
|
51
52
|
import "../../../src/go-overloads";
|
|
52
53
|
import "../../../src/component-properties";
|
|
@@ -155,10 +155,9 @@ declare global {
|
|
|
155
155
|
* // How to play the "jump" animation followed by the "run" animation:
|
|
156
156
|
* const url = msg.url("#model");
|
|
157
157
|
*
|
|
158
|
-
* function anim_done(self: unknown, message_id:
|
|
158
|
+
* function anim_done(self: unknown, message_id: Hash, message: { animation_id: Hash }) {
|
|
159
159
|
* if (message_id === hash("model_animation_done")) {
|
|
160
|
-
*
|
|
161
|
-
* if (animation_id === hash("jump")) {
|
|
160
|
+
* if (message.animation_id === hash("jump")) {
|
|
162
161
|
* // open animation done, chain with "run"
|
|
163
162
|
* const properties = { blend_duration: 0.2 };
|
|
164
163
|
* model.play_anim(url, "run", go.PLAYBACK_LOOP_FORWARD, properties, anim_done);
|
|
@@ -175,7 +174,7 @@ declare global {
|
|
|
175
174
|
* });
|
|
176
175
|
* ```
|
|
177
176
|
*/
|
|
178
|
-
function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: go.Playback, play_properties?: { blend_duration?: number; offset?: number; playback_rate?: number }, complete_function?: (self: unknown, message_id:
|
|
177
|
+
function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: go.Playback, play_properties?: { blend_duration?: number; offset?: number; playback_rate?: number }, complete_function?: (self: unknown, message_id: Hash, message: BuiltinMessages["model_animation_done"]) => void): void;
|
|
179
178
|
/**
|
|
180
179
|
* Resets a shader constant for a model component.
|
|
181
180
|
* The constant must be defined in the material assigned to the model.
|
|
@@ -229,7 +228,7 @@ declare global {
|
|
|
229
228
|
/**
|
|
230
229
|
* The current animation set on the component. The type of the property is hash.
|
|
231
230
|
*/
|
|
232
|
-
animation: Hash;
|
|
231
|
+
readonly animation: Hash;
|
|
233
232
|
/**
|
|
234
233
|
* The normalized animation cursor. The type of the property is number.
|
|
235
234
|
* Please note that model events may not fire as expected when the cursor is manipulated directly.
|
|
@@ -200,7 +200,7 @@ declare global {
|
|
|
200
200
|
* @returns It returns a list. If missed it returns `nil`. See ray_cast_response for details on the returned values.
|
|
201
201
|
* @example
|
|
202
202
|
* ```ts
|
|
203
|
-
* function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash
|
|
203
|
+
* function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash }) {
|
|
204
204
|
* // act on the hit (see 'ray_cast_response')
|
|
205
205
|
* }
|
|
206
206
|
*
|
|
@@ -225,7 +225,7 @@ declare global {
|
|
|
225
225
|
* });
|
|
226
226
|
* ```
|
|
227
227
|
*/
|
|
228
|
-
function raycast(from: Vector3, to: Vector3, groups: Hash[], options?: { all?: boolean }):
|
|
228
|
+
function raycast(from: Vector3, to: Vector3, groups: Hash[], options?: { all?: boolean }): Omit<BuiltinMessages["ray_cast_response"], "request_id">[] | Omit<BuiltinMessages["ray_cast_response"], "request_id"> | undefined;
|
|
229
229
|
/**
|
|
230
230
|
* Ray casts are used to test for intersections against collision objects in the physics world.
|
|
231
231
|
* Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
|
|
@@ -6,10 +6,11 @@ declare global {
|
|
|
6
6
|
* Rendering API documentation
|
|
7
7
|
*/
|
|
8
8
|
namespace render {
|
|
9
|
-
type constant_buffer = Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4
|
|
9
|
+
type constant_buffer = Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<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;
|
|
13
|
+
type RenderTargetParams = Record<string | number, unknown>;
|
|
13
14
|
/**
|
|
14
15
|
* The rendering context was lost. Rendering is paused and all graphics resources become invalid. Passed to the `render.set_listener` callback.
|
|
15
16
|
*/
|
|
@@ -104,7 +105,7 @@ declare global {
|
|
|
104
105
|
* constants.light_colors[3] = vmath.vector4(1, 1, 1, 1);
|
|
105
106
|
* ```
|
|
106
107
|
*/
|
|
107
|
-
function constant_buffer(): Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4
|
|
108
|
+
function constant_buffer(): Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> };
|
|
108
109
|
/**
|
|
109
110
|
* Deletes a render target created by a render script.
|
|
110
111
|
* You cannot delete a render target resource.
|
|
@@ -117,9 +118,12 @@ declare global {
|
|
|
117
118
|
* return { my_render_target: render.render_target("my_target", {}) };
|
|
118
119
|
* },
|
|
119
120
|
*
|
|
120
|
-
* final
|
|
121
|
-
*
|
|
122
|
-
*
|
|
121
|
+
* // A render script has no final hook, so free the target on a message.
|
|
122
|
+
* on_message(self, message_id) {
|
|
123
|
+
* if (message_id === hash("release_target")) {
|
|
124
|
+
* // How to delete a render target:
|
|
125
|
+
* render.delete_render_target(self.my_render_target);
|
|
126
|
+
* }
|
|
123
127
|
* },
|
|
124
128
|
* });
|
|
125
129
|
* ```
|
|
@@ -182,8 +186,11 @@ declare global {
|
|
|
182
186
|
* ```ts
|
|
183
187
|
* export default defineRenderScript({
|
|
184
188
|
* init() {
|
|
189
|
+
* // the engine registers a texture format only when the driver supports it
|
|
190
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
191
|
+
* if (format === undefined) return undefined;
|
|
185
192
|
* const color_params = {
|
|
186
|
-
* format
|
|
193
|
+
* format,
|
|
187
194
|
* width: render.get_window_width(),
|
|
188
195
|
* height: render.get_window_height(),
|
|
189
196
|
* };
|
|
@@ -194,6 +201,7 @@ declare global {
|
|
|
194
201
|
* },
|
|
195
202
|
*
|
|
196
203
|
* update(self, dt) {
|
|
204
|
+
* if (self === undefined) return;
|
|
197
205
|
* render.enable_texture(0, self.my_render_target, graphics.BUFFER_TYPE_COLOR0_BIT);
|
|
198
206
|
* // draw a predicate with the render target available as texture 0 in the predicate
|
|
199
207
|
* // material shader.
|
|
@@ -223,8 +231,11 @@ declare global {
|
|
|
223
231
|
* ```ts
|
|
224
232
|
* export default defineRenderScript({
|
|
225
233
|
* init() {
|
|
234
|
+
* // the engine registers a texture format only when the driver supports it
|
|
235
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
236
|
+
* if (format === undefined) return undefined;
|
|
226
237
|
* const color_params = {
|
|
227
|
-
* format
|
|
238
|
+
* format,
|
|
228
239
|
* width: render.get_window_width(),
|
|
229
240
|
* height: render.get_window_height(),
|
|
230
241
|
* };
|
|
@@ -235,6 +246,7 @@ declare global {
|
|
|
235
246
|
* },
|
|
236
247
|
*
|
|
237
248
|
* update(self, dt) {
|
|
249
|
+
* if (self === undefined) return;
|
|
238
250
|
* render.set_compute("bloom");
|
|
239
251
|
* render.enable_texture(0, self.backing_texture);
|
|
240
252
|
* render.enable_texture(1, self.scene_rt);
|
|
@@ -251,7 +263,7 @@ declare global {
|
|
|
251
263
|
* render.dispatch_compute(32, 32, 32, { constants });
|
|
252
264
|
* ```
|
|
253
265
|
*/
|
|
254
|
-
function dispatch_compute(x: number, y: number, z: number, options?: { constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4
|
|
266
|
+
function dispatch_compute(x: number, y: number, z: number, options?: { constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | ConstantArray<Vector4> | ConstantArray<Matrix4> } }): void;
|
|
255
267
|
/**
|
|
256
268
|
* Draws all objects that match a specified predicate. An optional constant buffer can be
|
|
257
269
|
* provided to override the default constants. If no constants buffer is provided, a default
|
|
@@ -313,7 +325,7 @@ declare global {
|
|
|
313
325
|
* }
|
|
314
326
|
* ```
|
|
315
327
|
*/
|
|
316
|
-
function draw(predicate: Opaque<"render_predicate">, options?: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4
|
|
328
|
+
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;
|
|
317
329
|
/**
|
|
318
330
|
* Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.
|
|
319
331
|
*
|
|
@@ -424,8 +436,11 @@ declare global {
|
|
|
424
436
|
* ```ts
|
|
425
437
|
* export default defineRenderScript({
|
|
426
438
|
* init() {
|
|
439
|
+
* // the engine registers a texture format only when the driver supports it
|
|
440
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
441
|
+
* if (format === undefined) return undefined;
|
|
427
442
|
* const color_params = {
|
|
428
|
-
* format
|
|
443
|
+
* format,
|
|
429
444
|
* width: render.get_window_width(),
|
|
430
445
|
* height: render.get_window_height(),
|
|
431
446
|
* };
|
|
@@ -436,6 +451,7 @@ declare global {
|
|
|
436
451
|
* },
|
|
437
452
|
*
|
|
438
453
|
* update(self, dt) {
|
|
454
|
+
* if (self === undefined) return;
|
|
439
455
|
* // enable target so all drawing is done to it
|
|
440
456
|
* render.set_render_target(self.my_render_target);
|
|
441
457
|
*
|
|
@@ -516,8 +532,11 @@ declare global {
|
|
|
516
532
|
* ```ts
|
|
517
533
|
* export default defineRenderScript({
|
|
518
534
|
* init() {
|
|
535
|
+
* // the engine registers a texture format only when the driver supports it
|
|
536
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
537
|
+
* if (format === undefined) return undefined;
|
|
519
538
|
* const color_params = {
|
|
520
|
-
* format
|
|
539
|
+
* format,
|
|
521
540
|
* width: render.get_window_width(),
|
|
522
541
|
* height: render.get_window_height(),
|
|
523
542
|
* };
|
|
@@ -529,6 +548,7 @@ declare global {
|
|
|
529
548
|
* },
|
|
530
549
|
*
|
|
531
550
|
* update(self, dt) {
|
|
551
|
+
* if (self === undefined) return;
|
|
532
552
|
* // get the height of the render target color buffer
|
|
533
553
|
* const h = render.get_render_target_height(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);
|
|
534
554
|
* // get the height of a render target resource
|
|
@@ -553,8 +573,11 @@ declare global {
|
|
|
553
573
|
* ```ts
|
|
554
574
|
* export default defineRenderScript({
|
|
555
575
|
* init() {
|
|
576
|
+
* // the engine registers a texture format only when the driver supports it
|
|
577
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
578
|
+
* if (format === undefined) return undefined;
|
|
556
579
|
* const color_params = {
|
|
557
|
-
* format
|
|
580
|
+
* format,
|
|
558
581
|
* width: render.get_window_width(),
|
|
559
582
|
* height: render.get_window_height(),
|
|
560
583
|
* };
|
|
@@ -566,6 +589,7 @@ declare global {
|
|
|
566
589
|
* },
|
|
567
590
|
*
|
|
568
591
|
* update(self, dt) {
|
|
592
|
+
* if (self === undefined) return;
|
|
569
593
|
* // get the width of the render target color buffer
|
|
570
594
|
* const w = render.get_render_target_width(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);
|
|
571
595
|
* // get the width of a render target resource
|
|
@@ -969,8 +993,11 @@ declare global {
|
|
|
969
993
|
* // 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
|
|
970
994
|
* export default defineRenderScript({
|
|
971
995
|
* init() {
|
|
996
|
+
* // the engine registers a texture format only when the driver supports it
|
|
997
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
998
|
+
* if (format === undefined) return undefined;
|
|
972
999
|
* const color_params = {
|
|
973
|
-
* format
|
|
1000
|
+
* format,
|
|
974
1001
|
* width: render.get_window_width(),
|
|
975
1002
|
* height: render.get_window_height(),
|
|
976
1003
|
* };
|
|
@@ -981,6 +1008,7 @@ declare global {
|
|
|
981
1008
|
* },
|
|
982
1009
|
*
|
|
983
1010
|
* update(self, dt) {
|
|
1011
|
+
* if (self === undefined) return;
|
|
984
1012
|
* // set render target so all drawing is done to it
|
|
985
1013
|
* render.set_render_target(self.my_render_target, {
|
|
986
1014
|
* transient: [graphics.BUFFER_TYPE_DEPTH_BIT, graphics.BUFFER_TYPE_STENCIL_BIT],
|
|
@@ -355,7 +355,7 @@ declare global {
|
|
|
355
355
|
* }
|
|
356
356
|
* ```
|
|
357
357
|
*/
|
|
358
|
-
function get_sys_info(options?: { ignore_secure?: boolean }): { device_model
|
|
358
|
+
function get_sys_info(options?: { ignore_secure?: boolean }): { device_model: string; manufacturer: string; system_name: string; system_version: string; api_version: string; language: string; device_language: string; territory: string; gmt_offset: number; device_ident: string; user_agent: string };
|
|
359
359
|
/**
|
|
360
360
|
* If the file exists, it must have been created by `sys.save` to be loaded.
|
|
361
361
|
* This function will raise a Lua error if an error occurs while loading the file.
|
|
@@ -66,7 +66,7 @@ declare global {
|
|
|
66
66
|
* }
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
function get_tile(url: string | Hash | Url, layer: string | Hash, x: number, y: number): number;
|
|
69
|
+
function get_tile(url: string | Hash | Url, layer: string | Hash, x: number, y: number): number | undefined;
|
|
70
70
|
/**
|
|
71
71
|
* Get the tile information at the specified position in the tilemap.
|
|
72
72
|
* The position is identified by the tile index starting at origin
|
|
@@ -94,7 +94,7 @@ declare global {
|
|
|
94
94
|
* }
|
|
95
95
|
* ```
|
|
96
96
|
*/
|
|
97
|
-
function get_tile_info(url: string | Hash | Url, layer: string | Hash, x: number, y: number): { index: number; h_flip: boolean; v_flip: boolean; rotate_90: boolean };
|
|
97
|
+
function get_tile_info(url: string | Hash | Url, layer: string | Hash, x: number, y: number): { index: number; h_flip: boolean; v_flip: boolean; rotate_90: boolean } | undefined;
|
|
98
98
|
/**
|
|
99
99
|
* Retrieves all the tiles for the specified layer in the tilemap.
|
|
100
100
|
* It returns a table of rows where the keys are the
|
|
@@ -112,13 +112,13 @@ declare global {
|
|
|
112
112
|
* let count = 0;
|
|
113
113
|
* for (let row_index = bottom; row_index <= bottom + rows_count - 1; row_index++) {
|
|
114
114
|
* for (let column_index = left; column_index <= left + columns_count - 1; column_index++) {
|
|
115
|
-
* tile = tiles
|
|
115
|
+
* tile = tiles?.get(row_index)?.get(column_index) ?? 0;
|
|
116
116
|
* count = count + 1;
|
|
117
117
|
* }
|
|
118
118
|
* }
|
|
119
119
|
* ```
|
|
120
120
|
*/
|
|
121
|
-
function get_tiles(url: string | Hash | Url, layer: string | Hash): LuaMap<number, LuaMap<number, number
|
|
121
|
+
function get_tiles(url: string | Hash | Url, layer: string | Hash): LuaMap<number, LuaMap<number, number>> | undefined;
|
|
122
122
|
/**
|
|
123
123
|
* Resets a shader constant for a tile map component.
|
|
124
124
|
* The constant must be defined in the material assigned to the tile map.
|
|
@@ -85,7 +85,7 @@ declare global {
|
|
|
85
85
|
* }
|
|
86
86
|
* ```
|
|
87
87
|
*/
|
|
88
|
-
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: LuaMap<Hash, Record<string | number, unknown>> | Record<string, Record<string | number, unknown>>, scale?: number | Vector3):
|
|
88
|
+
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: LuaMap<Hash, Record<string | number, unknown>> | Record<string, Record<string | number, unknown>>, scale?: number | Vector3): LuaTable<Hash, Hash> & { get: LuaTableGetMethod<string, Hash> };
|
|
89
89
|
/**
|
|
90
90
|
* This returns status of the collection factory.
|
|
91
91
|
* Calling this function when the factory is not marked as dynamic loading always returns COMP_COLLECTION_FACTORY_STATUS_LOADED.
|
|
@@ -86,7 +86,7 @@ declare global {
|
|
|
86
86
|
* msg.post("/go#collectionproxy", "enable");
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
|
-
function set_collection(url: string | Hash | Url, prototype: string | undefined): LuaMultiReturn<[boolean, number]>;
|
|
89
|
+
function set_collection(url: string | Hash | Url, prototype: string | undefined): LuaMultiReturn<[boolean, number | undefined]>;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -42,7 +42,9 @@ declare global {
|
|
|
42
42
|
* // create a new game object and provide property values
|
|
43
43
|
* const created = factory.create("#factory", undefined, undefined, { my_value: 1 });
|
|
44
44
|
* // communicate with the object
|
|
45
|
-
*
|
|
45
|
+
* if (created !== undefined) {
|
|
46
|
+
* msg.post(created, "hello");
|
|
47
|
+
* }
|
|
46
48
|
* },
|
|
47
49
|
* });
|
|
48
50
|
* ```
|
|
@@ -58,7 +60,7 @@ declare global {
|
|
|
58
60
|
* });
|
|
59
61
|
* ```
|
|
60
62
|
*/
|
|
61
|
-
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): Hash;
|
|
63
|
+
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): Hash | undefined;
|
|
62
64
|
/**
|
|
63
65
|
* This returns status of the factory.
|
|
64
66
|
* Calling this function when the factory is not marked as dynamic loading always returns
|
|
@@ -628,7 +628,7 @@ declare global {
|
|
|
628
628
|
* @param node - root node to clone
|
|
629
629
|
* @returns a table mapping node ids to the corresponding cloned nodes
|
|
630
630
|
*/
|
|
631
|
-
function clone_tree(node: Opaque<"node">):
|
|
631
|
+
function clone_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
|
|
632
632
|
/**
|
|
633
633
|
* Deletes the specified node. Any child nodes of the specified node will be
|
|
634
634
|
* recursively deleted.
|
|
@@ -1144,7 +1144,7 @@ declare global {
|
|
|
1144
1144
|
* @param node - root node to get node tree from
|
|
1145
1145
|
* @returns a table mapping node ids to the corresponding nodes
|
|
1146
1146
|
*/
|
|
1147
|
-
function get_tree(node: Opaque<"node">):
|
|
1147
|
+
function get_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
|
|
1148
1148
|
/**
|
|
1149
1149
|
* gets the node type
|
|
1150
1150
|
*
|
|
@@ -31,6 +31,8 @@ declare global {
|
|
|
31
31
|
* - number `range_start`: the start offset into the requested file
|
|
32
32
|
* - number `range_end`: the end offset into the requested file (inclusive)
|
|
33
33
|
* - number `document_size`: the full size of the requested file
|
|
34
|
+
*
|
|
35
|
+
* With `report_progress` set, the callback also receives progress events carrying `bytes_sent`, `bytes_received`, `bytes_total` and `url` but no `status`; `response.bytes_received !== undefined` marks a progress event, since a final response never carries it.
|
|
34
36
|
* @param headers - optional table with custom headers
|
|
35
37
|
* @param post_data - optional data to send
|
|
36
38
|
* @param options - optional table with request parameters. Supported entries:
|
|
@@ -70,7 +72,7 @@ declare global {
|
|
|
70
72
|
* });
|
|
71
73
|
* ```
|
|
72
74
|
*/
|
|
73
|
-
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;
|
|
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;
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -44,7 +44,7 @@ declare global {
|
|
|
44
44
|
* }
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
function get_astc_header(buffer: string): { width: number; height: number; depth: number; block_size_x: number; block_size_y: number; block_size_z: number }
|
|
47
|
+
function get_astc_header(buffer: string): { width: number; height: number; depth: number; block_size_x: number; block_size_y: number; block_size_z: number };
|
|
48
48
|
/**
|
|
49
49
|
* Load image (PNG or JPEG) from buffer.
|
|
50
50
|
*
|
|
@@ -47,6 +47,7 @@ import "../../../src/engine-globals";
|
|
|
47
47
|
import "../../../src/msg-overloads";
|
|
48
48
|
import "../../../src/message-guard";
|
|
49
49
|
import "../../../src/window-event-guard";
|
|
50
|
+
import "../../../src/physics-event-guard";
|
|
50
51
|
import "../../../src/scene-addresses";
|
|
51
52
|
import "../../../src/go-overloads";
|
|
52
53
|
import "../../../src/component-properties";
|
|
@@ -155,10 +155,9 @@ declare global {
|
|
|
155
155
|
* // How to play the "jump" animation followed by the "run" animation:
|
|
156
156
|
* const url = msg.url("#model");
|
|
157
157
|
*
|
|
158
|
-
* function anim_done(self: unknown, message_id:
|
|
158
|
+
* function anim_done(self: unknown, message_id: Hash, message: { animation_id: Hash }) {
|
|
159
159
|
* if (message_id === hash("model_animation_done")) {
|
|
160
|
-
*
|
|
161
|
-
* if (animation_id === hash("jump")) {
|
|
160
|
+
* if (message.animation_id === hash("jump")) {
|
|
162
161
|
* // open animation done, chain with "run"
|
|
163
162
|
* const properties = { blend_duration: 0.2 };
|
|
164
163
|
* model.play_anim(url, "run", go.PLAYBACK_LOOP_FORWARD, properties, anim_done);
|
|
@@ -175,7 +174,7 @@ declare global {
|
|
|
175
174
|
* });
|
|
176
175
|
* ```
|
|
177
176
|
*/
|
|
178
|
-
function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: go.Playback, play_properties?: { blend_duration?: number; offset?: number; playback_rate?: number }, complete_function?: (self: unknown, message_id:
|
|
177
|
+
function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: go.Playback, play_properties?: { blend_duration?: number; offset?: number; playback_rate?: number }, complete_function?: (self: unknown, message_id: Hash, message: BuiltinMessages["model_animation_done"]) => void): void;
|
|
179
178
|
/**
|
|
180
179
|
* Resets a shader constant for a model component.
|
|
181
180
|
* The constant must be defined in the material assigned to the model.
|
|
@@ -229,7 +228,7 @@ declare global {
|
|
|
229
228
|
/**
|
|
230
229
|
* The current animation set on the component. The type of the property is hash.
|
|
231
230
|
*/
|
|
232
|
-
animation: Hash;
|
|
231
|
+
readonly animation: Hash;
|
|
233
232
|
/**
|
|
234
233
|
* The normalized animation cursor. The type of the property is number.
|
|
235
234
|
* Please note that model events may not fire as expected when the cursor is manipulated directly.
|
|
@@ -200,7 +200,7 @@ declare global {
|
|
|
200
200
|
* @returns It returns a list. If missed it returns `nil`. See ray_cast_response for details on the returned values.
|
|
201
201
|
* @example
|
|
202
202
|
* ```ts
|
|
203
|
-
* function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash
|
|
203
|
+
* function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash }) {
|
|
204
204
|
* // act on the hit (see 'ray_cast_response')
|
|
205
205
|
* }
|
|
206
206
|
*
|
|
@@ -225,7 +225,7 @@ declare global {
|
|
|
225
225
|
* });
|
|
226
226
|
* ```
|
|
227
227
|
*/
|
|
228
|
-
function raycast(from: Vector3, to: Vector3, groups: Hash[], options?: { all?: boolean }):
|
|
228
|
+
function raycast(from: Vector3, to: Vector3, groups: Hash[], options?: { all?: boolean }): Omit<BuiltinMessages["ray_cast_response"], "request_id">[] | Omit<BuiltinMessages["ray_cast_response"], "request_id"> | undefined;
|
|
229
229
|
/**
|
|
230
230
|
* Ray casts are used to test for intersections against collision objects in the physics world.
|
|
231
231
|
* Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
|