@defold-typescript/types 0.44.1 → 0.46.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.
Files changed (45) hide show
  1. package/examples/translations.json +34 -34
  2. package/generated/b2d_fixture.d.ts +23 -1
  3. package/generated/b2d_shape.d.ts +22 -1
  4. package/generated/compute.d.ts +29 -2
  5. package/generated/go.d.ts +2 -2
  6. package/generated/gui.d.ts +5 -7
  7. package/generated/material.d.ts +98 -8
  8. package/generated/model.d.ts +11 -5
  9. package/generated/particlefx.d.ts +5 -7
  10. package/generated/render.d.ts +12 -18
  11. package/generated/sys.d.ts +8 -10
  12. package/generated/versions/defold-1.12.4/go.d.ts +2 -2
  13. package/generated/versions/defold-1.12.4/gui.d.ts +5 -7
  14. package/generated/versions/defold-1.12.4/particlefx.d.ts +5 -7
  15. package/generated/versions/defold-1.12.4/render.d.ts +12 -18
  16. package/generated/versions/defold-1.12.4/sys.d.ts +8 -10
  17. package/generated/versions/defold-1.12.4/window.d.ts +13 -15
  18. package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +23 -1
  19. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +22 -1
  20. package/generated/versions/defold-1.13.0/compute.d.ts +29 -2
  21. package/generated/versions/defold-1.13.0/go.d.ts +2 -2
  22. package/generated/versions/defold-1.13.0/gui.d.ts +5 -7
  23. package/generated/versions/defold-1.13.0/material.d.ts +98 -8
  24. package/generated/versions/defold-1.13.0/model.d.ts +11 -5
  25. package/generated/versions/defold-1.13.0/particlefx.d.ts +5 -7
  26. package/generated/versions/defold-1.13.0/render.d.ts +12 -18
  27. package/generated/versions/defold-1.13.0/sys.d.ts +8 -10
  28. package/generated/versions/defold-1.13.0/window.d.ts +13 -15
  29. package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +23 -1
  30. package/generated/versions/defold-1.13.1/b2d_shape.d.ts +22 -1
  31. package/generated/versions/defold-1.13.1/compute.d.ts +29 -2
  32. package/generated/versions/defold-1.13.1/go.d.ts +2 -2
  33. package/generated/versions/defold-1.13.1/gui.d.ts +5 -7
  34. package/generated/versions/defold-1.13.1/material.d.ts +98 -8
  35. package/generated/versions/defold-1.13.1/model.d.ts +11 -5
  36. package/generated/versions/defold-1.13.1/particlefx.d.ts +5 -7
  37. package/generated/versions/defold-1.13.1/render.d.ts +12 -18
  38. package/generated/versions/defold-1.13.1/sys.d.ts +8 -10
  39. package/generated/versions/defold-1.13.1/window.d.ts +13 -15
  40. package/generated/window.d.ts +13 -15
  41. package/hsm/async.d.ts +19 -1
  42. package/hsm/debug.d.ts +15 -1
  43. package/hsm/defold.d.ts +21 -1
  44. package/hsm/index.d.ts +222 -94
  45. package/package.json +3 -1
@@ -14,13 +14,13 @@
14
14
  "b2d.fixture.set_shape": [
15
15
  {
16
16
  "sourceHash": "ff836b80569f5d30",
17
- "ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const circle = b2d.fixture.get_shape(body, 1);\n const radius = \"radius\" in circle ? circle.radius : undefined;\n b2d.fixture.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);\n b2d.fixture.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_EDGE, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });\n}"
17
+ "ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n // Move a circle shape relative to the body origin.\n const circle = b2d.fixture.get_shape(body, 1);\n const radius = \"radius\" in circle ? circle.radius : undefined;\n b2d.fixture.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);\n\n // Replace an edge shape's local endpoints.\n b2d.fixture.set_shape(body, 2, {\n type: b2d.shape.SHAPE_TYPE_EDGE,\n v1: vmath.vector3(-32, 0, 0),\n v2: vmath.vector3(32, 0, 0),\n });\n\n // Update a box shape using the polygon box convenience format.\n // The existing polygon must already have four vertices.\n b2d.fixture.set_shape(\n body,\n 3,\n {\n type: b2d.shape.SHAPE_TYPE_BOX,\n hx: 16,\n hy: 8,\n center: vmath.vector3(0, 20, 0),\n angle: math.rad(30),\n },\n true,\n );\n}"
18
18
  }
19
19
  ],
20
20
  "b2d.shape.set_shape": [
21
21
  {
22
22
  "sourceHash": "f31970e9ebb8d446",
23
- "ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const circle = b2d.shape.get_shape(body, 1);\n const radius = \"radius\" in circle ? circle.radius : undefined;\n b2d.shape.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);\n b2d.shape.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_SEGMENT, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });\n}"
23
+ "ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n // Move a circle shape relative to the body origin.\n const circle = b2d.shape.get_shape(body, 1);\n const radius = \"radius\" in circle ? circle.radius : undefined;\n b2d.shape.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);\n\n // Replace a segment shape's local endpoints.\n b2d.shape.set_shape(body, 2, {\n type: b2d.shape.SHAPE_TYPE_SEGMENT,\n v1: vmath.vector3(-32, 0, 0),\n v2: vmath.vector3(32, 0, 0),\n });\n\n // Update a box shape using the polygon box convenience format.\n b2d.shape.set_shape(\n body,\n 3,\n {\n type: b2d.shape.SHAPE_TYPE_BOX,\n hx: 16,\n hy: 8,\n center: vmath.vector3(0, 20, 0),\n angle: math.rad(30),\n },\n true,\n );\n}"
24
24
  }
25
25
  ],
26
26
  "buffer.copy_buffer": [
@@ -240,7 +240,7 @@
240
240
  "compute.set_constants": [
241
241
  {
242
242
  "sourceHash": "e14e2048f75cadc6",
243
- "ts": "compute.set_constants(\"/my_compute.computec\", { tint: { value: vmath.vector4(1, 0, 0, 1) } });"
243
+ "ts": "// Set a shader constant in a compute program\nexport default defineScript({\n init() {\n return { my_view_proj: vmath.matrix4() };\n },\n\n update(self) {\n // update the 'tint' constant\n compute.set_constants(\"/my_compute.computec\", {\n tint: { value: vmath.vector4(1, 0, 0, 1) },\n });\n // change the type of the 'view_proj' constant to CONSTANT_TYPE_USER_MATRIX4 so the renderer can set our custom data\n compute.set_constants(\"/my_compute.computec\", {\n view_proj: { value: self.my_view_proj, type: material.CONSTANT_TYPE_USER_MATRIX4 },\n });\n },\n});"
244
244
  }
245
245
  ],
246
246
  "compute.set_samplers": [
@@ -252,7 +252,7 @@
252
252
  "compute.set_textures": [
253
253
  {
254
254
  "sourceHash": "87edc357f8852364",
255
- "ts": "compute.set_textures(\"/my_compute.computec\", { my_texture: resource.texture() });"
255
+ "ts": "// Set a texture in a compute program from a resource\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_texture: resource.texture() },\n\n init(self) {\n compute.set_textures(\"/my_compute.computec\", {\n my_texture: self.my_texture,\n });\n },\n});"
256
256
  }
257
257
  ],
258
258
  "editor.bob": [
@@ -408,11 +408,11 @@
408
408
  "go.delete": [
409
409
  {
410
410
  "sourceHash": "eb1a20098678b7b1",
411
- "ts": "// Delete the script's own game object.\ngo.delete();\n// Delete a game object with the id \"my_game_object\".\nconst id = go.get_id(\"my_game_object\");\ngo.delete(id);\n// Delete a list of game objects.\nconst ids = [hash(\"/my_object_1\"), hash(\"/my_object_2\"), hash(\"/my_object_3\")];\ngo.delete(ids);"
411
+ "ts": "// Delete the script's own game object.\ngo.delete();\n// Delete a game object with the id \"my_game_object\".\nconst id = go.get_id(\"my_game_object\"); // retrieve the id of the game object to be deleted\ngo.delete(id);\n// Delete a list of game objects.\nconst ids = [hash(\"/my_object_1\"), hash(\"/my_object_2\"), hash(\"/my_object_3\")];\ngo.delete(ids);"
412
412
  },
413
413
  {
414
414
  "sourceHash": "15be7513485334cf",
415
- "ts": "// Delete the script's own game object and its children.\ngo.delete(true);\n// Delete a game object with the id \"my_game_object\" and its children.\nconst id = go.get_id(\"my_game_object\");\ngo.delete(id, true);\n// Delete a list of game objects and their children.\nconst ids = [hash(\"/my_object_1\"), hash(\"/my_object_2\"), hash(\"/my_object_3\")];\ngo.delete(ids, true);"
415
+ "ts": "// Delete the script's own game object and its children.\ngo.delete(true);\n// Delete a game object with the id \"my_game_object\" and its children.\nconst id = go.get_id(\"my_game_object\"); // retrieve the id of the game object to be deleted\ngo.delete(id, true);\n// Delete a list of game objects and their children.\nconst ids = [hash(\"/my_object_1\"), hash(\"/my_object_2\"), hash(\"/my_object_3\")];\ngo.delete(ids, true);"
416
416
  }
417
417
  ],
418
418
  "go.exists": [
@@ -436,11 +436,11 @@
436
436
  },
437
437
  {
438
438
  "sourceHash": "decf402c4b246359",
439
- "ts": "// the glsl indices are 0-based\nconst url = msg.url(\"#mesh\");\ngo.get(url, \"example\", { index: 1 }); // the first vector4 in the array: example[0]\ngo.get(url, \"example\", { index: 16 }); // the last vector4 in the array: example[15]\ngo.get(url, \"example.x\", { index: 1 }); // an element of a vector4: example[0].x"
439
+ "ts": "const url = msg.url(\"#mesh\");\n// get the first vector4 in the array: example[0] (the glsl indices are 0-based)\ngo.get(url, \"example\", { index: 1 });\n\n// get the last vector4 in the array: example[15] (the glsl indices are 0-based)\ngo.get(url, \"example\", { index: 16 });\n\n// get an element of a vector4 in the array: example[0].x (the glsl indices are 0-based)\ngo.get(url, \"example.x\", { index: 1 });"
440
440
  },
441
441
  {
442
442
  "sourceHash": "cd59aaeb4278cdfc",
443
- "ts": "const url = msg.url(\"#mesh\");\ngo.get(url, \"example\"); // => [vector4, vector4, ...]\ngo.get(url, \"example.x\"); // => [number1, number2, ...]"
443
+ "ts": "const url = msg.url(\"#mesh\");\n// get all vector4's in the constant array\ngo.get(url, \"example\");\n// result: [vector4, vector4, ...]\n// get all elements of the vector4's from an array\ngo.get(url, \"example.x\");\n// result: [number1, number2, ...]"
444
444
  },
445
445
  {
446
446
  "sourceHash": "4b5cae0c647b3381",
@@ -456,7 +456,7 @@
456
456
  },
457
457
  {
458
458
  "sourceHash": "3ba93bc03f7948cc",
459
- "ts": "const url = msg.url(\"#mesh\");\n// get all vector4's in the constant array\ngo.get(url, \"example\"); // => [vector4, vector4, ...]\n// get all elements of the vector4's from an array\ngo.get(url, \"example.x\"); // => [number1, number2, ...]"
459
+ "ts": "const url = msg.url(\"#mesh\");\n// get all vector4's in the constant array\ngo.get(url, \"example\");\n// result: [vector4, vector4, ...]\n\n// get all elements of the vector4's from an array\ngo.get(url, \"example.x\");\n// result: [number1, number2, ...]"
460
460
  }
461
461
  ],
462
462
  "go.get_id": [
@@ -590,11 +590,11 @@
590
590
  },
591
591
  {
592
592
  "sourceHash": "150af4281adacf42",
593
- "ts": "// the glsl indices are 0-based\nconst url = msg.url(\"#mesh\");\ngo.set(url, \"example\", vmath.vector4(1, 1, 1, 1), { index: 1 }); // example[0] = v\ngo.set(url, \"example\", vmath.vector4(2, 2, 2, 2), { index: 16 }); // example[15] = v\ngo.set(url, \"example.x\", 7, { index: 1 }); // example[0].x = 7"
593
+ "ts": "const url = msg.url(\"#mesh\");\n// set the first vector4 in the array: example[0] = v (the glsl indices are 0-based)\ngo.set(url, \"example\", vmath.vector4(1, 1, 1, 1), { index: 1 });\n\n// set the last vector4 in the array: example[15] = v (the glsl indices are 0-based)\ngo.set(url, \"example\", vmath.vector4(2, 2, 2, 2), { index: 16 });\n\n// set an element of a vector4 in the array: example[0].x = 7 (the glsl indices are 0-based)\ngo.set(url, \"example.x\", 7, { index: 1 });"
594
594
  },
595
595
  {
596
596
  "sourceHash": "fb7b5aefbb9fad4b",
597
- "ts": "// set the first two vector4's in the array\n// if the array has more than two elements in the array they will not be set\nconst url = msg.url(\"#mesh\");\ngo.set(url, \"example\", [vmath.vector4(1, 1, 1, 1), vmath.vector4(2, 2, 2, 2)]);"
597
+ "ts": "const url = msg.url(\"#mesh\");\n// set the first two vector4's in the array\n// if the array has more than two elements in the array they will not be set\ngo.set(url, \"example\", [vmath.vector4(1, 1, 1, 1), vmath.vector4(2, 2, 2, 2)]);"
598
598
  },
599
599
  {
600
600
  "sourceHash": "ea5b1b6430458d24",
@@ -602,7 +602,7 @@
602
602
  },
603
603
  {
604
604
  "sourceHash": "bb73335ad4c5f1fe",
605
- "ts": "go.property(\"my_material\", resource.material());\n\nfunction set_sub_component_material(self: { my_material: Hash }) {\n go.set(\"#particlefx\", \"material\", self.my_material, { keys: [\"cone_emitter\"] });\n}"
605
+ "ts": "export default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_material: resource.material() },\n\n init(self) {\n go.set(\"#particlefx\", \"material\", self.my_material, { keys: [\"cone_emitter\"] });\n },\n});"
606
606
  },
607
607
  {
608
608
  "sourceHash": "2a68fe57bedcd5c1",
@@ -790,7 +790,7 @@
790
790
  "gui.play_particlefx": [
791
791
  {
792
792
  "sourceHash": "19a26b6e14ad0997",
793
- "ts": "// How to play a particle fx when a gui node is created.\n// The callback receives the gui node, the hash of the id\n// of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.\nfunction emitter_state_change(self: unknown, node: unknown, emitter: unknown, state: unknown) {\n if (emitter === hash(\"exhaust\") && state === particlefx.EMITTER_STATE_POSTSPAWN) {\n // exhaust is done spawning particles...\n }\n}\n\nexport default defineGuiScript({\n init(self) {\n gui.play_particlefx(gui.get_node(\"particlefx\"), emitter_state_change);\n },\n});"
793
+ "ts": "// How to play a particle fx when a gui node is created.\n// The callback receives the gui node, the hash of the id\n// of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.\nexport default defineGuiScript({\n init(self) {\n gui.play_particlefx(gui.get_node(\"particlefx\"), (self, node, emitter, state) => {\n if (emitter === hash(\"exhaust\") && state === particlefx.EMITTER_STATE_POSTSPAWN) {\n // exhaust is done spawning particles...\n }\n });\n },\n});"
794
794
  }
795
795
  ],
796
796
  "gui.reset_material": [
@@ -982,49 +982,49 @@
982
982
  "material.get_constants": [
983
983
  {
984
984
  "sourceHash": "6409de8793053165",
985
- "ts": "const constants = material.get_constants(resource.material(\"/my_material.materialc\"));"
985
+ "ts": "// Get the shader constants from a material specified as a resource property\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_material: resource.material() },\n\n init(self) {\n const constants = material.get_constants(self.my_material);\n },\n});"
986
986
  }
987
987
  ],
988
988
  "material.get_samplers": [
989
989
  {
990
990
  "sourceHash": "e346ac9f6ec55d31",
991
- "ts": "const samplers = material.get_samplers(resource.material(\"/my_material.materialc\"));"
991
+ "ts": "// Get the texture samplers from a material specified as a resource property\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_material: resource.material() },\n\n init(self) {\n const samplers = material.get_samplers(self.my_material);\n },\n});"
992
992
  }
993
993
  ],
994
994
  "material.get_textures": [
995
995
  {
996
996
  "sourceHash": "350415f3b2ba725d",
997
- "ts": "const textures = material.get_textures(resource.material(\"/my_material.materialc\"));"
997
+ "ts": "// Get the textures from a material specified as a resource property\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_material: resource.material() },\n\n init(self) {\n const textures = material.get_textures(self.my_material);\n },\n});"
998
998
  }
999
999
  ],
1000
1000
  "material.get_vertex_attributes": [
1001
1001
  {
1002
1002
  "sourceHash": "e835376dd87b4332",
1003
- "ts": "const vertex_attributes = material.get_vertex_attributes(resource.material(\"/my_material.materialc\"));"
1003
+ "ts": "// Get the vertex attributes from a material specified as a resource property\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_material: resource.material() },\n\n init(self) {\n const vertex_attributes = material.get_vertex_attributes(self.my_material);\n },\n});"
1004
1004
  }
1005
1005
  ],
1006
1006
  "material.set_constants": [
1007
1007
  {
1008
1008
  "sourceHash": "4f7ec4631253a3dc",
1009
- "ts": "material.set_constants(resource.material(\"/my_material.materialc\"), { tint: { value: vmath.vector4(1, 0, 0, 1) } });"
1009
+ "ts": "// Set a shader constant in a material specified as a resource property\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_material: resource.material() },\n\n init() {\n return { my_view_proj: vmath.matrix4() };\n },\n\n update(self) {\n // update the 'tint' constant\n material.set_constants(self.my_material, {\n tint: { value: vmath.vector4(1, 0, 0, 1) },\n });\n // change the type of the 'view_proj' constant to CONSTANT_TYPE_USER_MATRIX4 so the renderer can set our custom data\n material.set_constants(self.my_material, {\n view_proj: { value: self.my_view_proj, type: material.CONSTANT_TYPE_USER_MATRIX4 },\n });\n },\n});"
1010
1010
  }
1011
1011
  ],
1012
1012
  "material.set_samplers": [
1013
1013
  {
1014
1014
  "sourceHash": "3d29dbd58cf503ad",
1015
- "ts": "material.set_samplers(resource.material(\"/my_material.materialc\"), { texture_sampler: { u_wrap: graphics.TEXTURE_WRAP_REPEAT, v_wrap: graphics.TEXTURE_WRAP_MIRRORED_REPEAT } });"
1015
+ "ts": "// Configures a sampler in a material specified as a resource property\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_material: resource.material() },\n\n init(self) {\n material.set_samplers(self.my_material, {\n texture_sampler: { u_wrap: graphics.TEXTURE_WRAP_REPEAT, v_wrap: graphics.TEXTURE_WRAP_MIRRORED_REPEAT },\n });\n },\n});"
1016
1016
  }
1017
1017
  ],
1018
1018
  "material.set_textures": [
1019
1019
  {
1020
1020
  "sourceHash": "8b7930f275efc915",
1021
- "ts": "material.set_textures(resource.material(\"/my_material.materialc\"), { my_texture: resource.texture() });"
1021
+ "ts": "// Set a texture in a material from a resource\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registrations from this field, and only this field types them onto `self`.\n properties: { my_material: resource.material(), my_texture: resource.texture() },\n\n init(self) {\n material.set_textures(self.my_material, {\n my_texture: self.my_texture,\n });\n },\n});"
1022
1022
  }
1023
1023
  ],
1024
1024
  "material.set_vertex_attributes": [
1025
1025
  {
1026
1026
  "sourceHash": "a78800caef15ee12",
1027
- "ts": "material.set_vertex_attributes(resource.material(\"/my_material.materialc\"), { tint_attribute: { value: vmath.vector4(1, 0, 0, 1), semantic_type: graphics.SEMANTIC_TYPE_COLOR } });"
1027
+ "ts": "// Configures a vertex attribute in a material specified as a resource property\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_material: resource.material() },\n\n init(self) {\n material.set_vertex_attributes(self.my_material, {\n tint_attribute: { value: vmath.vector4(1, 0, 0, 1), semantic_type: graphics.SEMANTIC_TYPE_COLOR },\n weights: { value: vmath.vector4(0, 1, 0, 0), semantic_type: graphics.SEMANTIC_TYPE_NONE },\n });\n },\n});"
1028
1028
  }
1029
1029
  ],
1030
1030
  "model.get_aabb": [
@@ -1036,7 +1036,7 @@
1036
1036
  "model.get_blend_weights": [
1037
1037
  {
1038
1038
  "sourceHash": "a4945bd4efb90dd9",
1039
- "ts": "const weights = model.get_blend_weights(\"#model\");\nweights[1] = 0.75;\nweights[2] = 0.25;\nmodel.set_blend_weights(\"#model\", weights);"
1039
+ "ts": "const w = model.get_blend_weights(\"#model\");\nw.forEach((weight, i) => {\n print(i + 1, weight);\n});\n// change the data in the table and then set the weights again\nw[0] = 0.75;\nw[1] = 0.25;\nmodel.set_blend_weights(\"#model\", w);"
1040
1040
  }
1041
1041
  ],
1042
1042
  "model.get_go": [
@@ -1072,7 +1072,7 @@
1072
1072
  "model.set_blend_weights": [
1073
1073
  {
1074
1074
  "sourceHash": "74fd31c0afc44481",
1075
- "ts": "model.set_blend_weights(\"#model\", [0, 1, 0.5, 0]);\nmodel.set_blend_weights(\"#model\");"
1075
+ "ts": "// set the weights for the first 4 morph targets\nmodel.set_blend_weights(\"#model\", [0, 1, 0.5, 0]);\n// clear the override, animation will continue if the weights are driven by an animation\nmodel.set_blend_weights(\"#model\"); // clear script override"
1076
1076
  }
1077
1077
  ],
1078
1078
  "model.set_mesh_enabled": [
@@ -1138,7 +1138,7 @@
1138
1138
  "particlefx.play": [
1139
1139
  {
1140
1140
  "sourceHash": "01a21997b47ac4fc",
1141
- "ts": "// How to play a particle fx when a game object is created.\n// The callback receives the hash of the path to the particlefx, the hash of the id\n// of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.\nfunction emitter_state_change(self: unknown, id: unknown, emitter: unknown, state: unknown) {\n if (emitter === hash(\"exhaust\") && state === particlefx.EMITTER_STATE_POSTSPAWN) {\n // exhaust is done spawning particles...\n }\n}\n\nexport default defineScript({\n init(self) {\n particlefx.play(\"#particlefx\", emitter_state_change);\n },\n});"
1141
+ "ts": "// How to play a particle fx when a game object is created.\n// The callback receives the hash of the path to the particlefx, the hash of the id\n// of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.\nexport default defineScript({\n init(self) {\n particlefx.play(\"#particlefx\", (self, id, emitter, state) => {\n if (emitter === hash(\"exhaust\") && state === particlefx.EMITTER_STATE_POSTSPAWN) {\n // exhaust is done spawning particles...\n }\n });\n },\n});"
1142
1142
  }
1143
1143
  ],
1144
1144
  "particlefx.reset_constant": [
@@ -1332,7 +1332,7 @@
1332
1332
  },
1333
1333
  {
1334
1334
  "sourceHash": "d89056c8f1a576bb",
1335
- "ts": "function draw_tinted(self: { my_pred: Opaque<\"render_predicate\"> }) {\n const constants = render.constant_buffer();\n constants.tint = vmath.vector4(1, 1, 1, 1);\n render.draw(self.my_pred, { constants });\n}"
1335
+ "ts": "export default defineRenderScript({\n init() {\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n const constants = render.constant_buffer();\n render.draw(self.my_pred, { constants });\n },\n});"
1336
1336
  },
1337
1337
  {
1338
1338
  "sourceHash": "2c9cd28e1eb6e610",
@@ -1420,11 +1420,11 @@
1420
1420
  },
1421
1421
  {
1422
1422
  "sourceHash": "dc0ea083dbea5fe1",
1423
- "ts": "// Or enable a render target by resource id:\nexport default defineRenderScript({\n init() {\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n render.set_render_target(\"my_rt_resource\");\n render.draw(self.my_pred);\n render.set_render_target(render.RENDER_TARGET_DEFAULT);\n\n render.enable_texture(0, \"my_rt_resource\", graphics.BUFFER_TYPE_COLOR0_BIT);\n // draw a predicate with the render target available as texture 0 in the predicate\n // material shader.\n render.draw(self.my_pred);\n },\n});"
1423
+ "ts": "export default defineRenderScript({\n init() {\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n // enable render target by resource id\n render.set_render_target(\"my_rt_resource\");\n render.draw(self.my_pred);\n render.set_render_target(render.RENDER_TARGET_DEFAULT);\n\n render.enable_texture(0, \"my_rt_resource\", graphics.BUFFER_TYPE_COLOR0_BIT);\n // draw a predicate with the render target available as texture 0 in the predicate\n // material shader.\n render.draw(self.my_pred);\n },\n});"
1424
1424
  },
1425
1425
  {
1426
1426
  "sourceHash": "49503c29f0de95f3",
1427
- "ts": "// Or bind a texture handle directly:\nexport default defineRenderScript({\n init() {\n return { my_texture_handle: resource.get_texture_info(\"/main/my_texture.texturec\").handle };\n },\n\n update(self, dt) {\n // bind a texture to the texture unit 0\n render.enable_texture(0, self.my_texture_handle);\n // bind the same texture to a named sampler\n render.enable_texture(\"my_texture_sampler\", self.my_texture_handle);\n },\n});"
1427
+ "ts": "export default defineRenderScript({\n init() {\n return { my_texture_handle: resource.get_texture_info(\"/main/my_texture.texturec\").handle };\n },\n\n update(self, dt) {\n // bind a texture to the texture unit 0\n render.enable_texture(0, self.my_texture_handle);\n // bind the same texture to a named sampler\n render.enable_texture(\"my_texture_sampler\", self.my_texture_handle);\n },\n});"
1428
1428
  }
1429
1429
  ],
1430
1430
  "render.get_height": [
@@ -1436,13 +1436,13 @@
1436
1436
  "render.get_render_target_height": [
1437
1437
  {
1438
1438
  "sourceHash": "f509a9b954573583",
1439
- "ts": "export default defineRenderScript({\n init() {\n // render target buffer parameters\n const color_params = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n return {\n target_right: render.render_target(\"right\", {\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,\n }),\n };\n },\n\n update(self, dt) {\n // get the height of the render target color buffer\n const h = render.get_render_target_height(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);\n // get the height of a render target resource\n const w = render.get_render_target_height(\"my_rt_resource\", graphics.BUFFER_TYPE_COLOR0_BIT);\n },\n});"
1439
+ "ts": "export default defineRenderScript({\n init() {\n const color_params = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n };\n return {\n target_right: render.render_target(\"right\", {\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,\n }),\n };\n },\n\n update(self, dt) {\n // get the height of the render target color buffer\n const h = render.get_render_target_height(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);\n // get the height of a render target resource\n const w = render.get_render_target_height(\"my_rt_resource\", graphics.BUFFER_TYPE_COLOR0_BIT);\n },\n});"
1440
1440
  }
1441
1441
  ],
1442
1442
  "render.get_render_target_width": [
1443
1443
  {
1444
1444
  "sourceHash": "25c6d828a4ae3706",
1445
- "ts": "export default defineRenderScript({\n init() {\n // render target buffer parameters\n const color_params = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n return {\n target_right: render.render_target(\"right\", {\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,\n }),\n };\n },\n\n update(self, dt) {\n // get the width of the render target color buffer\n const w = render.get_render_target_width(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);\n // get the width of a render target resource\n const w2 = render.get_render_target_width(\"my_rt_resource\", graphics.BUFFER_TYPE_COLOR0_BIT);\n },\n});"
1445
+ "ts": "export default defineRenderScript({\n init() {\n const color_params = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n };\n return {\n target_right: render.render_target(\"right\", {\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,\n }),\n };\n },\n\n update(self, dt) {\n // get the width of the render target color buffer\n const w = render.get_render_target_width(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);\n // get the width of a render target resource\n const w2 = render.get_render_target_width(\"my_rt_resource\", graphics.BUFFER_TYPE_COLOR0_BIT);\n },\n});"
1446
1446
  }
1447
1447
  ],
1448
1448
  "render.get_width": [
@@ -1476,7 +1476,7 @@
1476
1476
  },
1477
1477
  {
1478
1478
  "sourceHash": "271ca31f05e103b5",
1479
- "ts": "// How to create a render target with multiple outputs:\nexport default defineRenderScript({\n init() {\n // render target buffer parameters\n const color_params_rgba = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n const color_params_float = {\n format: graphics.TEXTURE_FORMAT_RG32F,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n\n // the engine registers the extra color attachments only when the driver supports them\n const color1 = graphics.BUFFER_TYPE_COLOR1_BIT;\n const color2 = graphics.BUFFER_TYPE_COLOR2_BIT;\n if (color1 === undefined || color2 === undefined) return undefined;\n\n // Create a render target with three color attachments\n // Note: No depth buffer is attached here\n return {\n my_render_target: render.render_target({\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params_rgba,\n [color1]: color_params_rgba,\n [color2]: color_params_float,\n }),\n my_pred: render.predicate([hash(\"my_tag\")]),\n };\n },\n\n update(self, dt) {\n if (self === undefined) return;\n // enable target so all drawing is done to it\n render.set_render_target(self.my_render_target);\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n },\n});"
1479
+ "ts": "// How to create a render target with multiple outputs:\nexport default defineRenderScript({\n init() {\n // render target buffer parameters\n const color_params_rgba = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n const color_params_float = {\n format: graphics.TEXTURE_FORMAT_RG32F,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n\n // the engine registers the extra color attachments only when the driver supports them\n const color1 = graphics.BUFFER_TYPE_COLOR1_BIT;\n const color2 = graphics.BUFFER_TYPE_COLOR2_BIT;\n if (color1 === undefined || color2 === undefined) return undefined;\n\n // Create a render target with three color attachments\n // Note: No depth buffer is attached here\n return {\n my_render_target: render.render_target({\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params_rgba,\n [color1]: color_params_rgba,\n [color2]: color_params_float,\n }),\n my_pred: render.predicate([hash(\"my_tag\")]),\n };\n },\n\n update(self, dt) {\n if (self === undefined) return;\n // set target so all drawing is done to it\n render.set_render_target(self.my_render_target);\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n },\n});"
1480
1480
  },
1481
1481
  {
1482
1482
  "sourceHash": "e39f13af5d65d01d",
@@ -1574,7 +1574,7 @@
1574
1574
  },
1575
1575
  {
1576
1576
  "sourceHash": "bb08db5e232c5b5e",
1577
- "ts": "// Or set the render target by a render target resource identifier:\nexport default defineRenderScript({\n init() {\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n render.set_render_target(\"my_rt_resource\");\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n\n // reset the render target to the default backbuffer\n render.set_render_target(render.RENDER_TARGET_DEFAULT);\n },\n});"
1577
+ "ts": "export default defineRenderScript({\n init() {\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n // set render target by a render target resource identifier\n render.set_render_target(\"my_rt_resource\");\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n\n // reset the render target to the default backbuffer\n render.set_render_target(render.RENDER_TARGET_DEFAULT);\n },\n});"
1578
1578
  }
1579
1579
  ],
1580
1580
  "render.set_render_target_size": [
@@ -2203,7 +2203,7 @@
2203
2203
  "sys.set_error_handler": [
2204
2204
  {
2205
2205
  "sourceHash": "7346508f30f50bc9",
2206
- "ts": "// Install error handler that just prints the errors\nfunction my_error_handler(source: unknown, message: unknown, traceback: unknown) {\n print(source); //> lua\n print(message); //> main/my.script:10: attempt to perform arithmetic on a string value\n print(traceback); //> stack traceback:\n //> main/test.script:10: in function 'boom'\n //> main/test.script:15: in function <main/my.script:13>\n}\n\nfunction boom() {\n return 10 + \"string\";\n}\n\nexport default defineScript({\n init() {\n sys.set_error_handler(my_error_handler);\n boom();\n },\n});"
2206
+ "ts": "function boom() {\n return 10 + \"string\";\n}\n\nexport default defineScript({\n init() {\n // Install error handler that just prints the errors\n sys.set_error_handler((source, message, traceback) => {\n print(source); //> lua\n print(message); //> main/my.script:10: attempt to perform arithmetic on a string value\n print(traceback); //> stack traceback:\n //> main/test.script:10: in function 'boom'\n //> main/test.script:15: in function <main/my.script:13>\n });\n boom();\n },\n});"
2207
2207
  }
2208
2208
  ],
2209
2209
  "sys.set_render_enabled": [
@@ -2609,11 +2609,11 @@
2609
2609
  "window.set_listener": [
2610
2610
  {
2611
2611
  "sourceHash": "5075cb14faa9510b",
2612
- "ts": "function window_callback(self: unknown, event: unknown, data: Record<string | number, unknown>) {\n if (event === window.WINDOW_EVENT_FOCUS_LOST) {\n print(\"window.WINDOW_EVENT_FOCUS_LOST\");\n } else if (event === window.WINDOW_EVENT_FOCUS_GAINED) {\n print(\"window.WINDOW_EVENT_FOCUS_GAINED\");\n } else if (event === window.WINDOW_EVENT_ICONFIED) {\n print(\"window.WINDOW_EVENT_ICONFIED\");\n } else if (event === window.WINDOW_EVENT_DEICONIFIED) {\n print(\"window.WINDOW_EVENT_DEICONIFIED\");\n } else if (event === window.WINDOW_EVENT_RESIZED) {\n print(\"Window resized: \", data.width, data.height);\n }\n}\n\nexport default defineScript({\n init() {\n window.set_listener(window_callback);\n },\n});"
2612
+ "ts": "export default defineScript({\n init() {\n window.set_listener((self, event, data) => {\n if (event === window.WINDOW_EVENT_FOCUS_LOST) {\n print(\"window.WINDOW_EVENT_FOCUS_LOST\");\n } else if (event === window.WINDOW_EVENT_FOCUS_GAINED) {\n print(\"window.WINDOW_EVENT_FOCUS_GAINED\");\n } else if (event === window.WINDOW_EVENT_ICONFIED) {\n print(\"window.WINDOW_EVENT_ICONFIED\");\n } else if (event === window.WINDOW_EVENT_DEICONIFIED) {\n print(\"window.WINDOW_EVENT_DEICONIFIED\");\n } else if (event === window.WINDOW_EVENT_RESIZED) {\n print(\"Window resized: \", data.width, data.height);\n }\n });\n },\n});"
2613
2613
  },
2614
2614
  {
2615
2615
  "sourceHash": "c4168599cd777bb9",
2616
- "ts": "function window_callback(self: unknown, event: unknown, data: Record<string | number, unknown>) {\n if (event === window.WINDOW_EVENT_FOCUS_LOST) {\n print(\"window.WINDOW_EVENT_FOCUS_LOST\");\n } else if (event === window.WINDOW_EVENT_FOCUS_GAINED) {\n print(\"window.WINDOW_EVENT_FOCUS_GAINED\");\n } else if (event === window.WINDOW_EVENT_ICONIFIED) {\n print(\"window.WINDOW_EVENT_ICONIFIED\");\n } else if (event === window.WINDOW_EVENT_DEICONIFIED) {\n print(\"window.WINDOW_EVENT_DEICONIFIED\");\n } else if (event === window.WINDOW_EVENT_RESIZED) {\n print(\"Window resized: \", data.width, data.height);\n }\n}\n\nexport default defineScript({\n init() {\n window.set_listener(window_callback);\n },\n});"
2616
+ "ts": "export default defineScript({\n init() {\n window.set_listener((self, event, data) => {\n if (event === window.WINDOW_EVENT_FOCUS_LOST) {\n print(\"window.WINDOW_EVENT_FOCUS_LOST\");\n } else if (event === window.WINDOW_EVENT_FOCUS_GAINED) {\n print(\"window.WINDOW_EVENT_FOCUS_GAINED\");\n } else if (event === window.WINDOW_EVENT_ICONIFIED) {\n print(\"window.WINDOW_EVENT_ICONIFIED\");\n } else if (event === window.WINDOW_EVENT_DEICONIFIED) {\n print(\"window.WINDOW_EVENT_DEICONIFIED\");\n } else if (event === window.WINDOW_EVENT_RESIZED) {\n print(\"Window resized: \", data.width, data.height);\n }\n });\n },\n});"
2617
2617
  }
2618
2618
  ],
2619
2619
  "zlib.deflate": [
@@ -131,10 +131,32 @@ declare global {
131
131
  * ```ts
132
132
  * const body = b2d.get_body("#collisionobject");
133
133
  * if (body !== undefined) {
134
+ * // Move a circle shape relative to the body origin.
134
135
  * const circle = b2d.fixture.get_shape(body, 1);
135
136
  * const radius = "radius" in circle ? circle.radius : undefined;
136
137
  * b2d.fixture.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);
137
- * b2d.fixture.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_EDGE, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });
138
+ *
139
+ * // Replace an edge shape's local endpoints.
140
+ * b2d.fixture.set_shape(body, 2, {
141
+ * type: b2d.shape.SHAPE_TYPE_EDGE,
142
+ * v1: vmath.vector3(-32, 0, 0),
143
+ * v2: vmath.vector3(32, 0, 0),
144
+ * });
145
+ *
146
+ * // Update a box shape using the polygon box convenience format.
147
+ * // The existing polygon must already have four vertices.
148
+ * b2d.fixture.set_shape(
149
+ * body,
150
+ * 3,
151
+ * {
152
+ * type: b2d.shape.SHAPE_TYPE_BOX,
153
+ * hx: 16,
154
+ * hy: 8,
155
+ * center: vmath.vector3(0, 20, 0),
156
+ * angle: math.rad(30),
157
+ * },
158
+ * true,
159
+ * );
138
160
  * }
139
161
  * ```
140
162
  */
@@ -377,10 +377,31 @@ declare global {
377
377
  * ```ts
378
378
  * const body = b2d.get_body("#collisionobject");
379
379
  * if (body !== undefined) {
380
+ * // Move a circle shape relative to the body origin.
380
381
  * const circle = b2d.shape.get_shape(body, 1);
381
382
  * const radius = "radius" in circle ? circle.radius : undefined;
382
383
  * b2d.shape.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);
383
- * b2d.shape.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_SEGMENT, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });
384
+ *
385
+ * // Replace a segment shape's local endpoints.
386
+ * b2d.shape.set_shape(body, 2, {
387
+ * type: b2d.shape.SHAPE_TYPE_SEGMENT,
388
+ * v1: vmath.vector3(-32, 0, 0),
389
+ * v2: vmath.vector3(32, 0, 0),
390
+ * });
391
+ *
392
+ * // Update a box shape using the polygon box convenience format.
393
+ * b2d.shape.set_shape(
394
+ * body,
395
+ * 3,
396
+ * {
397
+ * type: b2d.shape.SHAPE_TYPE_BOX,
398
+ * hx: 16,
399
+ * hy: 8,
400
+ * center: vmath.vector3(0, 20, 0),
401
+ * angle: math.rad(30),
402
+ * },
403
+ * true,
404
+ * );
384
405
  * }
385
406
  * ```
386
407
  */
@@ -47,7 +47,23 @@ declare global {
47
47
  * @param constants - Constant options keyed by constant name. Partial updates are supported.
48
48
  * @example
49
49
  * ```ts
50
- * compute.set_constants("/my_compute.computec", { tint: { value: vmath.vector4(1, 0, 0, 1) } });
50
+ * // Set a shader constant in a compute program
51
+ * export default defineScript({
52
+ * init() {
53
+ * return { my_view_proj: vmath.matrix4() };
54
+ * },
55
+ *
56
+ * update(self) {
57
+ * // update the 'tint' constant
58
+ * compute.set_constants("/my_compute.computec", {
59
+ * tint: { value: vmath.vector4(1, 0, 0, 1) },
60
+ * });
61
+ * // change the type of the 'view_proj' constant to CONSTANT_TYPE_USER_MATRIX4 so the renderer can set our custom data
62
+ * compute.set_constants("/my_compute.computec", {
63
+ * view_proj: { value: self.my_view_proj, type: material.CONSTANT_TYPE_USER_MATRIX4 },
64
+ * });
65
+ * },
66
+ * });
51
67
  * ```
52
68
  */
53
69
  function set_constants(path: Hash | string, constants: LuaMap<string | Hash, material.constant_options> | Record<string, material.constant_options>): void;
@@ -70,7 +86,18 @@ declare global {
70
86
  * @param textures - A table keyed by sampler name with texture resources as values.
71
87
  * @example
72
88
  * ```ts
73
- * compute.set_textures("/my_compute.computec", { my_texture: resource.texture() });
89
+ * // Set a texture in a compute program from a resource
90
+ * export default defineScript({
91
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
92
+ * // registration from this field, and only this field types the property onto `self`.
93
+ * properties: { my_texture: resource.texture() },
94
+ *
95
+ * init(self) {
96
+ * compute.set_textures("/my_compute.computec", {
97
+ * my_texture: self.my_texture,
98
+ * });
99
+ * },
100
+ * });
74
101
  * ```
75
102
  */
76
103
  function set_textures(path: Hash | string, textures: LuaMap<string | Hash, string | Hash> | Record<string, string | Hash>): void;
package/generated/go.d.ts CHANGED
@@ -316,7 +316,7 @@ declare global {
316
316
  * // Delete the script's own game object.
317
317
  * go.delete();
318
318
  * // Delete a game object with the id "my_game_object".
319
- * const id = go.get_id("my_game_object");
319
+ * const id = go.get_id("my_game_object"); // retrieve the id of the game object to be deleted
320
320
  * go.delete(id);
321
321
  * // Delete a list of game objects.
322
322
  * const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
@@ -328,7 +328,7 @@ declare global {
328
328
  * // Delete the script's own game object and its children.
329
329
  * go.delete(true);
330
330
  * // Delete a game object with the id "my_game_object" and its children.
331
- * const id = go.get_id("my_game_object");
331
+ * const id = go.get_id("my_game_object"); // retrieve the id of the game object to be deleted
332
332
  * go.delete(id, true);
333
333
  * // Delete a list of game objects and their children.
334
334
  * const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
@@ -1490,15 +1490,13 @@ declare global {
1490
1490
  * // How to play a particle fx when a gui node is created.
1491
1491
  * // The callback receives the gui node, the hash of the id
1492
1492
  * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
1493
- * function emitter_state_change(self: unknown, node: unknown, emitter: unknown, state: unknown) {
1494
- * if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
1495
- * // exhaust is done spawning particles...
1496
- * }
1497
- * }
1498
- *
1499
1493
  * export default defineGuiScript({
1500
1494
  * init(self) {
1501
- * gui.play_particlefx(gui.get_node("particlefx"), emitter_state_change);
1495
+ * gui.play_particlefx(gui.get_node("particlefx"), (self, node, emitter, state) => {
1496
+ * if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
1497
+ * // exhaust is done spawning particles...
1498
+ * }
1499
+ * });
1502
1500
  * },
1503
1501
  * });
1504
1502
  * ```
@@ -310,7 +310,16 @@ declare global {
310
310
  * @returns Shader constant information.
311
311
  * @example
312
312
  * ```ts
313
- * const constants = material.get_constants(resource.material("/my_material.materialc"));
313
+ * // Get the shader constants from a material specified as a resource property
314
+ * export default defineScript({
315
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
316
+ * // registration from this field, and only this field types the property onto `self`.
317
+ * properties: { my_material: resource.material() },
318
+ *
319
+ * init(self) {
320
+ * const constants = material.get_constants(self.my_material);
321
+ * },
322
+ * });
314
323
  * ```
315
324
  */
316
325
  function get_constants(path: Hash | string): material.constant_info[];
@@ -322,7 +331,16 @@ declare global {
322
331
  * @returns texture sampler information
323
332
  * @example
324
333
  * ```ts
325
- * const samplers = material.get_samplers(resource.material("/my_material.materialc"));
334
+ * // Get the texture samplers from a material specified as a resource property
335
+ * export default defineScript({
336
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
337
+ * // registration from this field, and only this field types the property onto `self`.
338
+ * properties: { my_material: resource.material() },
339
+ *
340
+ * init(self) {
341
+ * const samplers = material.get_samplers(self.my_material);
342
+ * },
343
+ * });
326
344
  * ```
327
345
  */
328
346
  function get_samplers(path: Hash | string): material.sampler_info[];
@@ -333,7 +351,16 @@ declare global {
333
351
  * @returns material texture information
334
352
  * @example
335
353
  * ```ts
336
- * const textures = material.get_textures(resource.material("/my_material.materialc"));
354
+ * // Get the textures from a material specified as a resource property
355
+ * export default defineScript({
356
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
357
+ * // registration from this field, and only this field types the property onto `self`.
358
+ * properties: { my_material: resource.material() },
359
+ *
360
+ * init(self) {
361
+ * const textures = material.get_textures(self.my_material);
362
+ * },
363
+ * });
337
364
  * ```
338
365
  */
339
366
  function get_textures(path: Hash | string): material.texture_info[];
@@ -345,7 +372,16 @@ declare global {
345
372
  * @returns vertex attribute information
346
373
  * @example
347
374
  * ```ts
348
- * const vertex_attributes = material.get_vertex_attributes(resource.material("/my_material.materialc"));
375
+ * // Get the vertex attributes from a material specified as a resource property
376
+ * export default defineScript({
377
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
378
+ * // registration from this field, and only this field types the property onto `self`.
379
+ * properties: { my_material: resource.material() },
380
+ *
381
+ * init(self) {
382
+ * const vertex_attributes = material.get_vertex_attributes(self.my_material);
383
+ * },
384
+ * });
349
385
  * ```
350
386
  */
351
387
  function get_vertex_attributes(path: Hash | string): material.vertex_attribute_info[];
@@ -356,7 +392,27 @@ declare global {
356
392
  * @param constants - Shader constant updates keyed by constant name. Partial updates are supported.
357
393
  * @example
358
394
  * ```ts
359
- * material.set_constants(resource.material("/my_material.materialc"), { tint: { value: vmath.vector4(1, 0, 0, 1) } });
395
+ * // Set a shader constant 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() {
402
+ * return { my_view_proj: vmath.matrix4() };
403
+ * },
404
+ *
405
+ * update(self) {
406
+ * // update the 'tint' constant
407
+ * material.set_constants(self.my_material, {
408
+ * tint: { value: vmath.vector4(1, 0, 0, 1) },
409
+ * });
410
+ * // change the type of the 'view_proj' constant to CONSTANT_TYPE_USER_MATRIX4 so the renderer can set our custom data
411
+ * material.set_constants(self.my_material, {
412
+ * view_proj: { value: self.my_view_proj, type: material.CONSTANT_TYPE_USER_MATRIX4 },
413
+ * });
414
+ * },
415
+ * });
360
416
  * ```
361
417
  */
362
418
  function set_constants(path: Hash | string, constants: LuaMap<string | Hash, material.constant_options> | Record<string, material.constant_options>): void;
@@ -368,7 +424,18 @@ declare global {
368
424
  * @param samplers - Sampler updates keyed by sampler name. Partial updates are supported.
369
425
  * @example
370
426
  * ```ts
371
- * material.set_samplers(resource.material("/my_material.materialc"), { texture_sampler: { u_wrap: graphics.TEXTURE_WRAP_REPEAT, v_wrap: graphics.TEXTURE_WRAP_MIRRORED_REPEAT } });
427
+ * // Configures a sampler in a material specified as a resource property
428
+ * export default defineScript({
429
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
430
+ * // registration from this field, and only this field types the property onto `self`.
431
+ * properties: { my_material: resource.material() },
432
+ *
433
+ * init(self) {
434
+ * material.set_samplers(self.my_material, {
435
+ * texture_sampler: { u_wrap: graphics.TEXTURE_WRAP_REPEAT, v_wrap: graphics.TEXTURE_WRAP_MIRRORED_REPEAT },
436
+ * });
437
+ * },
438
+ * });
372
439
  * ```
373
440
  */
374
441
  function set_samplers(path: Hash | string, samplers: LuaMap<string | Hash, material.sampler_options> | Record<string, material.sampler_options>): void;
@@ -379,7 +446,18 @@ declare global {
379
446
  * @param textures - A table keyed by sampler name with texture resources as values.
380
447
  * @example
381
448
  * ```ts
382
- * material.set_textures(resource.material("/my_material.materialc"), { my_texture: resource.texture() });
449
+ * // Set a texture in a material from a resource
450
+ * export default defineScript({
451
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
452
+ * // registrations from this field, and only this field types them onto `self`.
453
+ * properties: { my_material: resource.material(), my_texture: resource.texture() },
454
+ *
455
+ * init(self) {
456
+ * material.set_textures(self.my_material, {
457
+ * my_texture: self.my_texture,
458
+ * });
459
+ * },
460
+ * });
383
461
  * ```
384
462
  */
385
463
  function set_textures(path: Hash | string, textures: LuaMap<string | Hash, string | Hash> | Record<string, string | Hash>): void;
@@ -390,7 +468,19 @@ declare global {
390
468
  * @param attributes - Vertex attributes keyed by name, or an array with explicit `name` fields. Partial updates are supported.
391
469
  * @example
392
470
  * ```ts
393
- * material.set_vertex_attributes(resource.material("/my_material.materialc"), { tint_attribute: { value: vmath.vector4(1, 0, 0, 1), semantic_type: graphics.SEMANTIC_TYPE_COLOR } });
471
+ * // Configures a vertex attribute in a material specified as a resource property
472
+ * export default defineScript({
473
+ * // Never call `go.property` yourself: the transpiler emits the chunk-scope
474
+ * // registration from this field, and only this field types the property onto `self`.
475
+ * properties: { my_material: resource.material() },
476
+ *
477
+ * init(self) {
478
+ * material.set_vertex_attributes(self.my_material, {
479
+ * tint_attribute: { value: vmath.vector4(1, 0, 0, 1), semantic_type: graphics.SEMANTIC_TYPE_COLOR },
480
+ * weights: { value: vmath.vector4(0, 1, 0, 0), semantic_type: graphics.SEMANTIC_TYPE_NONE },
481
+ * });
482
+ * },
483
+ * });
394
484
  * ```
395
485
  */
396
486
  function set_vertex_attributes(path: Hash | string, attributes: LuaMap<string | Hash, material.vertex_attribute_options> | Record<string, material.vertex_attribute_options> | material.named_vertex_attribute_options[]): void;