@defold-typescript/types 0.44.1 → 0.45.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/examples/translations.json +34 -34
- package/generated/b2d_fixture.d.ts +23 -1
- package/generated/b2d_shape.d.ts +22 -1
- package/generated/compute.d.ts +29 -2
- package/generated/go.d.ts +2 -2
- package/generated/gui.d.ts +5 -7
- package/generated/material.d.ts +98 -8
- package/generated/model.d.ts +11 -5
- package/generated/particlefx.d.ts +5 -7
- package/generated/render.d.ts +12 -18
- package/generated/sys.d.ts +8 -10
- package/generated/versions/defold-1.12.4/go.d.ts +2 -2
- package/generated/versions/defold-1.12.4/gui.d.ts +5 -7
- package/generated/versions/defold-1.12.4/particlefx.d.ts +5 -7
- package/generated/versions/defold-1.12.4/render.d.ts +12 -18
- package/generated/versions/defold-1.12.4/sys.d.ts +8 -10
- package/generated/versions/defold-1.12.4/window.d.ts +13 -15
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +23 -1
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +22 -1
- package/generated/versions/defold-1.13.0/compute.d.ts +29 -2
- package/generated/versions/defold-1.13.0/go.d.ts +2 -2
- package/generated/versions/defold-1.13.0/gui.d.ts +5 -7
- package/generated/versions/defold-1.13.0/material.d.ts +98 -8
- package/generated/versions/defold-1.13.0/model.d.ts +11 -5
- package/generated/versions/defold-1.13.0/particlefx.d.ts +5 -7
- package/generated/versions/defold-1.13.0/render.d.ts +12 -18
- package/generated/versions/defold-1.13.0/sys.d.ts +8 -10
- package/generated/versions/defold-1.13.0/window.d.ts +13 -15
- package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +23 -1
- package/generated/versions/defold-1.13.1/b2d_shape.d.ts +22 -1
- package/generated/versions/defold-1.13.1/compute.d.ts +29 -2
- package/generated/versions/defold-1.13.1/go.d.ts +2 -2
- package/generated/versions/defold-1.13.1/gui.d.ts +5 -7
- package/generated/versions/defold-1.13.1/material.d.ts +98 -8
- package/generated/versions/defold-1.13.1/model.d.ts +11 -5
- package/generated/versions/defold-1.13.1/particlefx.d.ts +5 -7
- package/generated/versions/defold-1.13.1/render.d.ts +12 -18
- package/generated/versions/defold-1.13.1/sys.d.ts +8 -10
- package/generated/versions/defold-1.13.1/window.d.ts +13 -15
- package/generated/window.d.ts +13 -15
- package/hsm/index.d.ts +69 -90
- package/package.json +3 -1
|
@@ -108,7 +108,16 @@ declare global {
|
|
|
108
108
|
* vmath.vector4 | vmath.matrix4 the value(s) of the constant. If the constant is an array, the value will be a table of vmath.vector4 or vmath.matrix4 if the type is `material.CONSTANT_TYPE_USER_MATRIX4`.
|
|
109
109
|
* @example
|
|
110
110
|
* ```ts
|
|
111
|
-
*
|
|
111
|
+
* // Get the shader constants from a material specified as a resource property
|
|
112
|
+
* export default defineScript({
|
|
113
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
114
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
115
|
+
* properties: { my_material: resource.material() },
|
|
116
|
+
*
|
|
117
|
+
* init(self) {
|
|
118
|
+
* const constants = material.get_constants(self.my_material);
|
|
119
|
+
* },
|
|
120
|
+
* });
|
|
112
121
|
* ```
|
|
113
122
|
*/
|
|
114
123
|
function get_constants(path: Hash | string): { name: Hash; type: number; value: Vector4 | Matrix4 }[];
|
|
@@ -159,7 +168,16 @@ declare global {
|
|
|
159
168
|
* number the max anisotropy of the texture sampler
|
|
160
169
|
* @example
|
|
161
170
|
* ```ts
|
|
162
|
-
*
|
|
171
|
+
* // Get the texture samplers from a material specified as a resource property
|
|
172
|
+
* export default defineScript({
|
|
173
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
174
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
175
|
+
* properties: { my_material: resource.material() },
|
|
176
|
+
*
|
|
177
|
+
* init(self) {
|
|
178
|
+
* const samplers = material.get_samplers(self.my_material);
|
|
179
|
+
* },
|
|
180
|
+
* });
|
|
163
181
|
* ```
|
|
164
182
|
*/
|
|
165
183
|
function get_samplers(path: Hash | string): { name: Hash; u_wrap: number; v_wrap: number; min_filter: number; mag_filter: number; max_anisotropy: number }[];
|
|
@@ -201,7 +219,16 @@ declare global {
|
|
|
201
219
|
* - `graphics.TEXTURE_USAGE_FLAG_COLOR`
|
|
202
220
|
* @example
|
|
203
221
|
* ```ts
|
|
204
|
-
*
|
|
222
|
+
* // Get the textures from a material specified as a resource property
|
|
223
|
+
* export default defineScript({
|
|
224
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
225
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
226
|
+
* properties: { my_material: resource.material() },
|
|
227
|
+
*
|
|
228
|
+
* init(self) {
|
|
229
|
+
* const textures = material.get_textures(self.my_material);
|
|
230
|
+
* },
|
|
231
|
+
* });
|
|
205
232
|
* ```
|
|
206
233
|
*/
|
|
207
234
|
function get_textures(path: Hash | string): { path: Hash; handle: Hash; width: number; height: number; depth: number; mipmaps: number; type: number; flags: number }[];
|
|
@@ -252,7 +279,16 @@ declare global {
|
|
|
252
279
|
* - `graphics.SEMANTIC_TYPE_TEXTURE_TRANSFORM_2D`
|
|
253
280
|
* @example
|
|
254
281
|
* ```ts
|
|
255
|
-
*
|
|
282
|
+
* // Get the vertex attributes from a material specified as a resource property
|
|
283
|
+
* export default defineScript({
|
|
284
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
285
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
286
|
+
* properties: { my_material: resource.material() },
|
|
287
|
+
*
|
|
288
|
+
* init(self) {
|
|
289
|
+
* const vertex_attributes = material.get_vertex_attributes(self.my_material);
|
|
290
|
+
* },
|
|
291
|
+
* });
|
|
256
292
|
* ```
|
|
257
293
|
*/
|
|
258
294
|
function get_vertex_attributes(path: Hash | string): { name: Hash; value: Vector4 | Vector3 | Matrix4 | number | number[]; normalize: boolean; data_type: number; coordinate_space: number; semantic_type: number }[];
|
|
@@ -287,7 +323,27 @@ declare global {
|
|
|
287
323
|
* vmath.vector4 | vmath.vector3 | vmath.matrix4 | number | table the value(s) of the constant. If the shader constant is an array, the amount of values to update depends on how many values that are passed in the 'value' field.
|
|
288
324
|
* @example
|
|
289
325
|
* ```ts
|
|
290
|
-
*
|
|
326
|
+
* // Set a shader constant in a material specified as a resource property
|
|
327
|
+
* export default defineScript({
|
|
328
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
329
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
330
|
+
* properties: { my_material: resource.material() },
|
|
331
|
+
*
|
|
332
|
+
* init() {
|
|
333
|
+
* return { my_view_proj: vmath.matrix4() };
|
|
334
|
+
* },
|
|
335
|
+
*
|
|
336
|
+
* update(self) {
|
|
337
|
+
* // update the 'tint' constant
|
|
338
|
+
* material.set_constants(self.my_material, {
|
|
339
|
+
* tint: { value: vmath.vector4(1, 0, 0, 1) },
|
|
340
|
+
* });
|
|
341
|
+
* // change the type of the 'view_proj' constant to CONSTANT_TYPE_USER_MATRIX4 so the renderer can set our custom data
|
|
342
|
+
* material.set_constants(self.my_material, {
|
|
343
|
+
* view_proj: { value: self.my_view_proj, type: material.CONSTANT_TYPE_USER_MATRIX4 },
|
|
344
|
+
* });
|
|
345
|
+
* },
|
|
346
|
+
* });
|
|
291
347
|
* ```
|
|
292
348
|
*/
|
|
293
349
|
function set_constants(path: Hash | string, constants: Record<string, { type?: number; value?: Vector4 | Vector3 | Matrix4 | number | (Vector4 | Matrix4)[] }>): void;
|
|
@@ -336,7 +392,18 @@ declare global {
|
|
|
336
392
|
* number the max anisotropy of the texture sampler
|
|
337
393
|
* @example
|
|
338
394
|
* ```ts
|
|
339
|
-
*
|
|
395
|
+
* // Configures a sampler in a material specified as a resource property
|
|
396
|
+
* export default defineScript({
|
|
397
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
398
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
399
|
+
* properties: { my_material: resource.material() },
|
|
400
|
+
*
|
|
401
|
+
* init(self) {
|
|
402
|
+
* material.set_samplers(self.my_material, {
|
|
403
|
+
* texture_sampler: { u_wrap: graphics.TEXTURE_WRAP_REPEAT, v_wrap: graphics.TEXTURE_WRAP_MIRRORED_REPEAT },
|
|
404
|
+
* });
|
|
405
|
+
* },
|
|
406
|
+
* });
|
|
340
407
|
* ```
|
|
341
408
|
*/
|
|
342
409
|
function set_samplers(path: Hash | string, samplers: Record<string, { u_wrap?: number; v_wrap?: number; min_filter?: number; mag_filter?: number; max_anisotropy?: number }>): void;
|
|
@@ -347,7 +414,18 @@ declare global {
|
|
|
347
414
|
* @param textures - A table keyed by sampler name with texture resources as values.
|
|
348
415
|
* @example
|
|
349
416
|
* ```ts
|
|
350
|
-
* material
|
|
417
|
+
* // Set a texture in a material from a resource
|
|
418
|
+
* export default defineScript({
|
|
419
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
420
|
+
* // registrations from this field, and only this field types them onto `self`.
|
|
421
|
+
* properties: { my_material: resource.material(), my_texture: resource.texture() },
|
|
422
|
+
*
|
|
423
|
+
* init(self) {
|
|
424
|
+
* material.set_textures(self.my_material, {
|
|
425
|
+
* my_texture: self.my_texture,
|
|
426
|
+
* });
|
|
427
|
+
* },
|
|
428
|
+
* });
|
|
351
429
|
* ```
|
|
352
430
|
*/
|
|
353
431
|
function set_textures(path: Hash | string, textures: LuaMap<string, Hash> | Record<string, Hash>): void;
|
|
@@ -396,7 +474,19 @@ declare global {
|
|
|
396
474
|
* - `graphics.SEMANTIC_TYPE_TEXTURE_TRANSFORM_2D`
|
|
397
475
|
* @example
|
|
398
476
|
* ```ts
|
|
399
|
-
*
|
|
477
|
+
* // Configures a vertex attribute in a material specified as a resource property
|
|
478
|
+
* export default defineScript({
|
|
479
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
480
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
481
|
+
* properties: { my_material: resource.material() },
|
|
482
|
+
*
|
|
483
|
+
* init(self) {
|
|
484
|
+
* material.set_vertex_attributes(self.my_material, {
|
|
485
|
+
* tint_attribute: { value: vmath.vector4(1, 0, 0, 1), semantic_type: graphics.SEMANTIC_TYPE_COLOR },
|
|
486
|
+
* weights: { value: vmath.vector4(0, 1, 0, 0), semantic_type: graphics.SEMANTIC_TYPE_NONE },
|
|
487
|
+
* });
|
|
488
|
+
* },
|
|
489
|
+
* });
|
|
400
490
|
* ```
|
|
401
491
|
*/
|
|
402
492
|
function set_vertex_attributes(path: Hash | string, attributes: Record<string, { value?: Vector4 | Vector3 | Matrix4 | number | number[]; normalize?: boolean; data_type?: number; coordinate_space?: number; semantic_type?: number }>): void;
|
|
@@ -33,10 +33,14 @@ declare global {
|
|
|
33
33
|
* @returns array of weight values, or empty table if the model has no morph targets
|
|
34
34
|
* @example
|
|
35
35
|
* ```ts
|
|
36
|
-
* const
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
36
|
+
* const w = model.get_blend_weights("#model");
|
|
37
|
+
* w.forEach((weight, i) => {
|
|
38
|
+
* print(i + 1, weight);
|
|
39
|
+
* });
|
|
40
|
+
* // change the data in the table and then set the weights again
|
|
41
|
+
* w[0] = 0.75;
|
|
42
|
+
* w[1] = 0.25;
|
|
43
|
+
* model.set_blend_weights("#model", w);
|
|
40
44
|
* ```
|
|
41
45
|
*/
|
|
42
46
|
function get_blend_weights(url: string | Hash | Url): number[];
|
|
@@ -197,8 +201,10 @@ declare global {
|
|
|
197
201
|
* @param weights - array of weight values (1-based indices). Omit or pass `nil` to clear the override and return morphs to animation only
|
|
198
202
|
* @example
|
|
199
203
|
* ```ts
|
|
204
|
+
* // set the weights for the first 4 morph targets
|
|
200
205
|
* model.set_blend_weights("#model", [0, 1, 0.5, 0]);
|
|
201
|
-
*
|
|
206
|
+
* // clear the override, animation will continue if the weights are driven by an animation
|
|
207
|
+
* model.set_blend_weights("#model"); // clear script override
|
|
202
208
|
* ```
|
|
203
209
|
*/
|
|
204
210
|
function set_blend_weights(url: string | Hash | Url, weights?: number[]): void;
|
|
@@ -50,15 +50,13 @@ declare global {
|
|
|
50
50
|
* // How to play a particle fx when a game object is created.
|
|
51
51
|
* // The callback receives the hash of the path to the particlefx, the hash of the id
|
|
52
52
|
* // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
|
|
53
|
-
* function emitter_state_change(self: unknown, id: unknown, emitter: unknown, state: unknown) {
|
|
54
|
-
* if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
|
|
55
|
-
* // exhaust is done spawning particles...
|
|
56
|
-
* }
|
|
57
|
-
* }
|
|
58
|
-
*
|
|
59
53
|
* export default defineScript({
|
|
60
54
|
* init(self) {
|
|
61
|
-
* particlefx.play("#particlefx",
|
|
55
|
+
* particlefx.play("#particlefx", (self, id, emitter, state) => {
|
|
56
|
+
* if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
|
|
57
|
+
* // exhaust is done spawning particles...
|
|
58
|
+
* }
|
|
59
|
+
* });
|
|
62
60
|
* },
|
|
63
61
|
* });
|
|
64
62
|
* ```
|
|
@@ -70,11 +70,16 @@ declare global {
|
|
|
70
70
|
* @example
|
|
71
71
|
* Then use the constant buffer when drawing a predicate:
|
|
72
72
|
* ```ts
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
73
|
+
* export default defineRenderScript({
|
|
74
|
+
* init() {
|
|
75
|
+
* return { my_pred: render.predicate([hash("my_tag")]) };
|
|
76
|
+
* },
|
|
77
|
+
*
|
|
78
|
+
* update(self, dt) {
|
|
79
|
+
* const constants = render.constant_buffer();
|
|
80
|
+
* render.draw(self.my_pred, { constants });
|
|
81
|
+
* },
|
|
82
|
+
* });
|
|
78
83
|
* ```
|
|
79
84
|
* @example
|
|
80
85
|
* The constant buffer also supports array values by specifying constants in a table:
|
|
@@ -449,13 +454,13 @@ declare global {
|
|
|
449
454
|
* ```
|
|
450
455
|
* @example
|
|
451
456
|
* ```ts
|
|
452
|
-
* // Or enable a render target by resource id:
|
|
453
457
|
* export default defineRenderScript({
|
|
454
458
|
* init() {
|
|
455
459
|
* return { my_pred: render.predicate([hash("my_tag")]) };
|
|
456
460
|
* },
|
|
457
461
|
*
|
|
458
462
|
* update(self, dt) {
|
|
463
|
+
* // enable render target by resource id
|
|
459
464
|
* render.set_render_target("my_rt_resource");
|
|
460
465
|
* render.draw(self.my_pred);
|
|
461
466
|
* render.set_render_target(render.RENDER_TARGET_DEFAULT);
|
|
@@ -469,7 +474,6 @@ declare global {
|
|
|
469
474
|
* ```
|
|
470
475
|
* @example
|
|
471
476
|
* ```ts
|
|
472
|
-
* // Or bind a texture handle directly:
|
|
473
477
|
* export default defineRenderScript({
|
|
474
478
|
* init() {
|
|
475
479
|
* return { my_texture_handle: resource.get_texture_info("/main/my_texture.texturec").handle };
|
|
@@ -512,15 +516,10 @@ declare global {
|
|
|
512
516
|
* ```ts
|
|
513
517
|
* export default defineRenderScript({
|
|
514
518
|
* init() {
|
|
515
|
-
* // render target buffer parameters
|
|
516
519
|
* const color_params = {
|
|
517
520
|
* format: graphics.TEXTURE_FORMAT_RGBA,
|
|
518
521
|
* width: render.get_window_width(),
|
|
519
522
|
* height: render.get_window_height(),
|
|
520
|
-
* min_filter: graphics.TEXTURE_FILTER_LINEAR,
|
|
521
|
-
* mag_filter: graphics.TEXTURE_FILTER_LINEAR,
|
|
522
|
-
* u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
|
|
523
|
-
* v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
|
|
524
523
|
* };
|
|
525
524
|
* return {
|
|
526
525
|
* target_right: render.render_target("right", {
|
|
@@ -554,15 +553,10 @@ declare global {
|
|
|
554
553
|
* ```ts
|
|
555
554
|
* export default defineRenderScript({
|
|
556
555
|
* init() {
|
|
557
|
-
* // render target buffer parameters
|
|
558
556
|
* const color_params = {
|
|
559
557
|
* format: graphics.TEXTURE_FORMAT_RGBA,
|
|
560
558
|
* width: render.get_window_width(),
|
|
561
559
|
* height: render.get_window_height(),
|
|
562
|
-
* min_filter: graphics.TEXTURE_FILTER_LINEAR,
|
|
563
|
-
* mag_filter: graphics.TEXTURE_FILTER_LINEAR,
|
|
564
|
-
* u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
|
|
565
|
-
* v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
|
|
566
560
|
* };
|
|
567
561
|
* return {
|
|
568
562
|
* target_right: render.render_target("right", {
|
|
@@ -1003,13 +997,13 @@ declare global {
|
|
|
1003
997
|
* ```
|
|
1004
998
|
* @example
|
|
1005
999
|
* ```ts
|
|
1006
|
-
* // Or set the render target by a render target resource identifier:
|
|
1007
1000
|
* export default defineRenderScript({
|
|
1008
1001
|
* init() {
|
|
1009
1002
|
* return { my_pred: render.predicate([hash("my_tag")]) };
|
|
1010
1003
|
* },
|
|
1011
1004
|
*
|
|
1012
1005
|
* update(self, dt) {
|
|
1006
|
+
* // set render target by a render target resource identifier
|
|
1013
1007
|
* render.set_render_target("my_rt_resource");
|
|
1014
1008
|
*
|
|
1015
1009
|
* // draw a predicate to the render target
|
|
@@ -605,22 +605,20 @@ declare global {
|
|
|
605
605
|
* string The stack traceback.
|
|
606
606
|
* @example
|
|
607
607
|
* ```ts
|
|
608
|
-
* // Install error handler that just prints the errors
|
|
609
|
-
* function my_error_handler(source: unknown, message: unknown, traceback: unknown) {
|
|
610
|
-
* print(source); //> lua
|
|
611
|
-
* print(message); //> main/my.script:10: attempt to perform arithmetic on a string value
|
|
612
|
-
* print(traceback); //> stack traceback:
|
|
613
|
-
* //> main/test.script:10: in function 'boom'
|
|
614
|
-
* //> main/test.script:15: in function <main/my.script:13>
|
|
615
|
-
* }
|
|
616
|
-
*
|
|
617
608
|
* function boom() {
|
|
618
609
|
* return 10 + "string";
|
|
619
610
|
* }
|
|
620
611
|
*
|
|
621
612
|
* export default defineScript({
|
|
622
613
|
* init() {
|
|
623
|
-
*
|
|
614
|
+
* // Install error handler that just prints the errors
|
|
615
|
+
* sys.set_error_handler((source, message, traceback) => {
|
|
616
|
+
* print(source); //> lua
|
|
617
|
+
* print(message); //> main/my.script:10: attempt to perform arithmetic on a string value
|
|
618
|
+
* print(traceback); //> stack traceback:
|
|
619
|
+
* //> main/test.script:10: in function 'boom'
|
|
620
|
+
* //> main/test.script:15: in function <main/my.script:13>
|
|
621
|
+
* });
|
|
624
622
|
* boom();
|
|
625
623
|
* },
|
|
626
624
|
* });
|
|
@@ -127,23 +127,21 @@ declare global {
|
|
|
127
127
|
* - number `height`: The height of a resize event. nil otherwise.
|
|
128
128
|
* @example
|
|
129
129
|
* ```ts
|
|
130
|
-
* function window_callback(self: unknown, event: unknown, data: Record<string | number, unknown>) {
|
|
131
|
-
* if (event === window.WINDOW_EVENT_FOCUS_LOST) {
|
|
132
|
-
* print("window.WINDOW_EVENT_FOCUS_LOST");
|
|
133
|
-
* } else if (event === window.WINDOW_EVENT_FOCUS_GAINED) {
|
|
134
|
-
* print("window.WINDOW_EVENT_FOCUS_GAINED");
|
|
135
|
-
* } else if (event === window.WINDOW_EVENT_ICONFIED) {
|
|
136
|
-
* print("window.WINDOW_EVENT_ICONFIED");
|
|
137
|
-
* } else if (event === window.WINDOW_EVENT_DEICONIFIED) {
|
|
138
|
-
* print("window.WINDOW_EVENT_DEICONIFIED");
|
|
139
|
-
* } else if (event === window.WINDOW_EVENT_RESIZED) {
|
|
140
|
-
* print("Window resized: ", data.width, data.height);
|
|
141
|
-
* }
|
|
142
|
-
* }
|
|
143
|
-
*
|
|
144
130
|
* export default defineScript({
|
|
145
131
|
* init() {
|
|
146
|
-
* window.set_listener(
|
|
132
|
+
* window.set_listener((self, event, data) => {
|
|
133
|
+
* if (event === window.WINDOW_EVENT_FOCUS_LOST) {
|
|
134
|
+
* print("window.WINDOW_EVENT_FOCUS_LOST");
|
|
135
|
+
* } else if (event === window.WINDOW_EVENT_FOCUS_GAINED) {
|
|
136
|
+
* print("window.WINDOW_EVENT_FOCUS_GAINED");
|
|
137
|
+
* } else if (event === window.WINDOW_EVENT_ICONFIED) {
|
|
138
|
+
* print("window.WINDOW_EVENT_ICONFIED");
|
|
139
|
+
* } else if (event === window.WINDOW_EVENT_DEICONIFIED) {
|
|
140
|
+
* print("window.WINDOW_EVENT_DEICONIFIED");
|
|
141
|
+
* } else if (event === window.WINDOW_EVENT_RESIZED) {
|
|
142
|
+
* print("Window resized: ", data.width, data.height);
|
|
143
|
+
* }
|
|
144
|
+
* });
|
|
147
145
|
* },
|
|
148
146
|
* });
|
|
149
147
|
* ```
|
|
@@ -135,10 +135,32 @@ declare global {
|
|
|
135
135
|
* ```ts
|
|
136
136
|
* const body = b2d.get_body("#collisionobject");
|
|
137
137
|
* if (body !== undefined) {
|
|
138
|
+
* // Move a circle shape relative to the body origin.
|
|
138
139
|
* const circle = b2d.fixture.get_shape(body, 1);
|
|
139
140
|
* const radius = "radius" in circle ? circle.radius : undefined;
|
|
140
141
|
* b2d.fixture.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);
|
|
141
|
-
*
|
|
142
|
+
*
|
|
143
|
+
* // Replace an edge shape's local endpoints.
|
|
144
|
+
* b2d.fixture.set_shape(body, 2, {
|
|
145
|
+
* type: b2d.shape.SHAPE_TYPE_EDGE,
|
|
146
|
+
* v1: vmath.vector3(-32, 0, 0),
|
|
147
|
+
* v2: vmath.vector3(32, 0, 0),
|
|
148
|
+
* });
|
|
149
|
+
*
|
|
150
|
+
* // Update a box shape using the polygon box convenience format.
|
|
151
|
+
* // The existing polygon must already have four vertices.
|
|
152
|
+
* b2d.fixture.set_shape(
|
|
153
|
+
* body,
|
|
154
|
+
* 3,
|
|
155
|
+
* {
|
|
156
|
+
* type: b2d.shape.SHAPE_TYPE_BOX,
|
|
157
|
+
* hx: 16,
|
|
158
|
+
* hy: 8,
|
|
159
|
+
* center: vmath.vector3(0, 20, 0),
|
|
160
|
+
* angle: math.rad(30),
|
|
161
|
+
* },
|
|
162
|
+
* true,
|
|
163
|
+
* );
|
|
142
164
|
* }
|
|
143
165
|
* ```
|
|
144
166
|
*/
|
|
@@ -375,10 +375,31 @@ declare global {
|
|
|
375
375
|
* ```ts
|
|
376
376
|
* const body = b2d.get_body("#collisionobject");
|
|
377
377
|
* if (body !== undefined) {
|
|
378
|
+
* // Move a circle shape relative to the body origin.
|
|
378
379
|
* const circle = b2d.shape.get_shape(body, 1);
|
|
379
380
|
* const radius = "radius" in circle ? circle.radius : undefined;
|
|
380
381
|
* b2d.shape.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);
|
|
381
|
-
*
|
|
382
|
+
*
|
|
383
|
+
* // Replace a segment shape's local endpoints.
|
|
384
|
+
* b2d.shape.set_shape(body, 2, {
|
|
385
|
+
* type: b2d.shape.SHAPE_TYPE_SEGMENT,
|
|
386
|
+
* v1: vmath.vector3(-32, 0, 0),
|
|
387
|
+
* v2: vmath.vector3(32, 0, 0),
|
|
388
|
+
* });
|
|
389
|
+
*
|
|
390
|
+
* // Update a box shape using the polygon box convenience format.
|
|
391
|
+
* b2d.shape.set_shape(
|
|
392
|
+
* body,
|
|
393
|
+
* 3,
|
|
394
|
+
* {
|
|
395
|
+
* type: b2d.shape.SHAPE_TYPE_BOX,
|
|
396
|
+
* hx: 16,
|
|
397
|
+
* hy: 8,
|
|
398
|
+
* center: vmath.vector3(0, 20, 0),
|
|
399
|
+
* angle: math.rad(30),
|
|
400
|
+
* },
|
|
401
|
+
* true,
|
|
402
|
+
* );
|
|
382
403
|
* }
|
|
383
404
|
* ```
|
|
384
405
|
*/
|
|
@@ -167,7 +167,23 @@ declare global {
|
|
|
167
167
|
* vmath.vector4 | vmath.vector3 | vmath.matrix4 | number | table the value(s) of the constant. If the shader constant is an array, the amount of values to update depends on how many values that are passed in the 'value' field.
|
|
168
168
|
* @example
|
|
169
169
|
* ```ts
|
|
170
|
-
*
|
|
170
|
+
* // Set a shader constant in a compute program
|
|
171
|
+
* export default defineScript({
|
|
172
|
+
* init() {
|
|
173
|
+
* return { my_view_proj: vmath.matrix4() };
|
|
174
|
+
* },
|
|
175
|
+
*
|
|
176
|
+
* update(self) {
|
|
177
|
+
* // update the 'tint' constant
|
|
178
|
+
* compute.set_constants("/my_compute.computec", {
|
|
179
|
+
* tint: { value: vmath.vector4(1, 0, 0, 1) },
|
|
180
|
+
* });
|
|
181
|
+
* // change the type of the 'view_proj' constant to CONSTANT_TYPE_USER_MATRIX4 so the renderer can set our custom data
|
|
182
|
+
* compute.set_constants("/my_compute.computec", {
|
|
183
|
+
* view_proj: { value: self.my_view_proj, type: material.CONSTANT_TYPE_USER_MATRIX4 },
|
|
184
|
+
* });
|
|
185
|
+
* },
|
|
186
|
+
* });
|
|
171
187
|
* ```
|
|
172
188
|
*/
|
|
173
189
|
function set_constants(path: Hash | string, constants: Record<string, { type?: number; value?: Vector4 | Vector3 | Matrix4 | number | (Vector4 | Matrix4)[] }>): void;
|
|
@@ -227,7 +243,18 @@ declare global {
|
|
|
227
243
|
* @param textures - A table keyed by sampler name with texture resources as values.
|
|
228
244
|
* @example
|
|
229
245
|
* ```ts
|
|
230
|
-
* compute
|
|
246
|
+
* // Set a texture in a compute program from a resource
|
|
247
|
+
* export default defineScript({
|
|
248
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
249
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
250
|
+
* properties: { my_texture: resource.texture() },
|
|
251
|
+
*
|
|
252
|
+
* init(self) {
|
|
253
|
+
* compute.set_textures("/my_compute.computec", {
|
|
254
|
+
* my_texture: self.my_texture,
|
|
255
|
+
* });
|
|
256
|
+
* },
|
|
257
|
+
* });
|
|
231
258
|
* ```
|
|
232
259
|
*/
|
|
233
260
|
function set_textures(path: Hash | string, textures: LuaMap<string, Hash> | Record<string, Hash>): void;
|
|
@@ -297,7 +297,7 @@ declare global {
|
|
|
297
297
|
* // Delete the script's own game object.
|
|
298
298
|
* go.delete();
|
|
299
299
|
* // Delete a game object with the id "my_game_object".
|
|
300
|
-
* const id = go.get_id("my_game_object");
|
|
300
|
+
* const id = go.get_id("my_game_object"); // retrieve the id of the game object to be deleted
|
|
301
301
|
* go.delete(id);
|
|
302
302
|
* // Delete a list of game objects.
|
|
303
303
|
* const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
|
|
@@ -309,7 +309,7 @@ declare global {
|
|
|
309
309
|
* // Delete the script's own game object and its children.
|
|
310
310
|
* go.delete(true);
|
|
311
311
|
* // Delete a game object with the id "my_game_object" and its children.
|
|
312
|
-
* const id = go.get_id("my_game_object");
|
|
312
|
+
* const id = go.get_id("my_game_object"); // retrieve the id of the game object to be deleted
|
|
313
313
|
* go.delete(id, true);
|
|
314
314
|
* // Delete a list of game objects and their children.
|
|
315
315
|
* const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
|
|
@@ -1597,15 +1597,13 @@ declare global {
|
|
|
1597
1597
|
* // How to play a particle fx when a gui node is created.
|
|
1598
1598
|
* // The callback receives the gui node, the hash of the id
|
|
1599
1599
|
* // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
|
|
1600
|
-
* function emitter_state_change(self: unknown, node: unknown, emitter: unknown, state: unknown) {
|
|
1601
|
-
* if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
|
|
1602
|
-
* // exhaust is done spawning particles...
|
|
1603
|
-
* }
|
|
1604
|
-
* }
|
|
1605
|
-
*
|
|
1606
1600
|
* export default defineGuiScript({
|
|
1607
1601
|
* init(self) {
|
|
1608
|
-
* gui.play_particlefx(gui.get_node("particlefx"),
|
|
1602
|
+
* gui.play_particlefx(gui.get_node("particlefx"), (self, node, emitter, state) => {
|
|
1603
|
+
* if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
|
|
1604
|
+
* // exhaust is done spawning particles...
|
|
1605
|
+
* }
|
|
1606
|
+
* });
|
|
1609
1607
|
* },
|
|
1610
1608
|
* });
|
|
1611
1609
|
* ```
|