@defold-typescript/types 0.37.0 → 0.39.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 (83) hide show
  1. package/api-signatures.json +348 -267
  2. package/examples/translations.json +323 -147
  3. package/generated/b2d_body.d.ts +7 -4
  4. package/generated/buffer.d.ts +16 -4
  5. package/generated/camera.d.ts +1 -0
  6. package/generated/collectionfactory.d.ts +5 -2
  7. package/generated/collectionproxy.d.ts +1 -1
  8. package/generated/factory.d.ts +2 -1
  9. package/generated/go.d.ts +141 -86
  10. package/generated/graphics.d.ts +2 -0
  11. package/generated/gui.d.ts +65 -40
  12. package/generated/html5.d.ts +1 -1
  13. package/generated/http.d.ts +4 -0
  14. package/generated/model.d.ts +9 -4
  15. package/generated/particlefx.d.ts +1 -1
  16. package/generated/physics.d.ts +16 -9
  17. package/generated/profiler.d.ts +9 -2
  18. package/generated/render.d.ts +224 -99
  19. package/generated/resource.d.ts +143 -157
  20. package/generated/socket.d.ts +13 -8
  21. package/generated/sound.d.ts +3 -2
  22. package/generated/sys.d.ts +16 -10
  23. package/generated/tilemap.d.ts +25 -19
  24. package/generated/timer.d.ts +33 -24
  25. package/generated/versions/defold-1.12.4/buffer.d.ts +16 -4
  26. package/generated/versions/defold-1.12.4/camera.d.ts +1 -0
  27. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +5 -2
  28. package/generated/versions/defold-1.12.4/collectionproxy.d.ts +1 -1
  29. package/generated/versions/defold-1.12.4/factory.d.ts +2 -1
  30. package/generated/versions/defold-1.12.4/go.d.ts +141 -86
  31. package/generated/versions/defold-1.12.4/graphics.d.ts +2 -0
  32. package/generated/versions/defold-1.12.4/gui.d.ts +63 -39
  33. package/generated/versions/defold-1.12.4/html5.d.ts +1 -1
  34. package/generated/versions/defold-1.12.4/http.d.ts +4 -0
  35. package/generated/versions/defold-1.12.4/model.d.ts +9 -4
  36. package/generated/versions/defold-1.12.4/particlefx.d.ts +1 -1
  37. package/generated/versions/defold-1.12.4/physics.d.ts +16 -9
  38. package/generated/versions/defold-1.12.4/profiler.d.ts +9 -2
  39. package/generated/versions/defold-1.12.4/render.d.ts +223 -98
  40. package/generated/versions/defold-1.12.4/resource.d.ts +143 -157
  41. package/generated/versions/defold-1.12.4/socket.d.ts +13 -8
  42. package/generated/versions/defold-1.12.4/sound.d.ts +3 -2
  43. package/generated/versions/defold-1.12.4/sys.d.ts +16 -10
  44. package/generated/versions/defold-1.12.4/tilemap.d.ts +25 -19
  45. package/generated/versions/defold-1.12.4/timer.d.ts +33 -24
  46. package/generated/versions/defold-1.12.4/vmath.d.ts +13 -5
  47. package/generated/versions/defold-1.12.4/window.d.ts +5 -3
  48. package/generated/versions/defold-1.13.0/b2d_body.d.ts +7 -4
  49. package/generated/versions/defold-1.13.0/buffer.d.ts +16 -4
  50. package/generated/versions/defold-1.13.0/camera.d.ts +1 -0
  51. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +5 -2
  52. package/generated/versions/defold-1.13.0/collectionproxy.d.ts +1 -1
  53. package/generated/versions/defold-1.13.0/factory.d.ts +2 -1
  54. package/generated/versions/defold-1.13.0/go.d.ts +141 -86
  55. package/generated/versions/defold-1.13.0/graphics.d.ts +2 -0
  56. package/generated/versions/defold-1.13.0/gui.d.ts +63 -39
  57. package/generated/versions/defold-1.13.0/html5.d.ts +1 -1
  58. package/generated/versions/defold-1.13.0/http.d.ts +4 -0
  59. package/generated/versions/defold-1.13.0/model.d.ts +9 -4
  60. package/generated/versions/defold-1.13.0/particlefx.d.ts +1 -1
  61. package/generated/versions/defold-1.13.0/physics.d.ts +16 -9
  62. package/generated/versions/defold-1.13.0/profiler.d.ts +9 -2
  63. package/generated/versions/defold-1.13.0/render.d.ts +224 -99
  64. package/generated/versions/defold-1.13.0/resource.d.ts +143 -157
  65. package/generated/versions/defold-1.13.0/socket.d.ts +13 -8
  66. package/generated/versions/defold-1.13.0/sound.d.ts +3 -2
  67. package/generated/versions/defold-1.13.0/sys.d.ts +16 -10
  68. package/generated/versions/defold-1.13.0/tilemap.d.ts +25 -19
  69. package/generated/versions/defold-1.13.0/timer.d.ts +33 -24
  70. package/generated/versions/defold-1.13.0/vmath.d.ts +13 -5
  71. package/generated/versions/defold-1.13.0/window.d.ts +5 -3
  72. package/generated/vmath.d.ts +13 -5
  73. package/generated/window.d.ts +5 -3
  74. package/package.json +2 -1
  75. package/src/api-doc.ts +8 -0
  76. package/src/doc-comment.ts +213 -32
  77. package/src/emit-dts.ts +501 -10
  78. package/src/example-store.ts +26 -0
  79. package/src/index.ts +5 -0
  80. package/src/lifecycle.ts +31 -8
  81. package/src/message-dispatch.d.ts +55 -13
  82. package/src/msg-overloads.d.ts +73 -3
  83. package/src/render-overloads.d.ts +0 -17
@@ -2,7 +2,7 @@
2
2
  "b2d.body.create_chain": [
3
3
  {
4
4
  "sourceHash": "a4547c6be36805bc",
5
- "ts": "const [chain, segments] = b2d.body.create_chain(body, {\n vertices: [vmath.vector3(-64, 0, 0), vmath.vector3(0, 16, 0), vmath.vector3(64, 0, 0)],\n prev_vertex: vmath.vector3(-96, 0, 0), next_vertex: vmath.vector3(96, 0, 0), friction: 0.6,\n});"
5
+ "ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const [chain, segments] = b2d.body.create_chain(body, {\n vertices: [vmath.vector3(-64, 0, 0), vmath.vector3(0, 16, 0), vmath.vector3(64, 0, 0)],\n prev_vertex: vmath.vector3(-96, 0, 0), next_vertex: vmath.vector3(96, 0, 0), friction: 0.6,\n });\n}"
6
6
  }
7
7
  ],
8
8
  "b2d.body.create_fixture": [
@@ -26,13 +26,13 @@
26
26
  "buffer.copy_buffer": [
27
27
  {
28
28
  "sourceHash": "314e1246a630d761",
29
- "ts": "// How to copy elements (e.g. vertices) from one buffer to another\n// copy entire buffer\nbuffer.copy_buffer(dstbuffer, 0, srcbuffer, 0, srcbuffer.length);\n\n// copy last 10 elements to the front of another buffer\nbuffer.copy_buffer(dstbuffer, 0, srcbuffer, srcbuffer.length - 10, 10);"
29
+ "ts": "// How to copy elements (e.g. vertices) from one buffer to another\nconst element_count = 64;\nconst srcbuffer = resource.get_buffer(\"/src.bufferc\");\nconst dstbuffer = resource.get_buffer(\"/dst.bufferc\");\n\n// copy entire buffer\nbuffer.copy_buffer(dstbuffer, 0, srcbuffer, 0, element_count);\n\n// copy last 10 elements to the front of another buffer\nbuffer.copy_buffer(dstbuffer, 0, srcbuffer, element_count - 10, 10);"
30
30
  }
31
31
  ],
32
32
  "buffer.copy_stream": [
33
33
  {
34
34
  "sourceHash": "359ea94639622db5",
35
- "ts": "// How to update a texture of a sprite:\n// copy entire stream\nconst srcstream = buffer.get_stream(srcbuffer, hash(\"xyz\"));\nconst dststream = buffer.get_stream(dstbuffer, hash(\"xyz\"));\nbuffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length);"
35
+ "ts": "// How to update a texture of a sprite:\nconst srcbuffer = resource.get_buffer(\"/src.bufferc\");\nconst dstbuffer = resource.get_buffer(\"/dst.bufferc\");\n\n// copy entire stream\nconst srcstream = buffer.get_stream(srcbuffer, hash(\"xyz\"));\nconst dststream = buffer.get_stream(dstbuffer, hash(\"xyz\"));\nbuffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length);"
36
36
  }
37
37
  ],
38
38
  "buffer.create": [
@@ -44,19 +44,19 @@
44
44
  "buffer.get_metadata": [
45
45
  {
46
46
  "sourceHash": "fab020678d7483db",
47
- "ts": "// How to get a metadata entry from a buffer\n// retrieve a metadata entry named \"somefloats\" and its numeric type\nconst [values, type] = buffer.get_metadata(buf, hash(\"somefloats\"));\nif (values) print(`${values.length} values in 'somefloats'`);"
47
+ "ts": "// How to get a metadata entry from a buffer\nconst buf = resource.get_buffer(\"/my.bufferc\");\n\n// retrieve a metadata entry named \"somefloats\" and its numeric type\nconst [values, type] = buffer.get_metadata(buf, hash(\"somefloats\"));\nif (values) print(`${values.length} values in 'somefloats'`);"
48
48
  }
49
49
  ],
50
50
  "buffer.set_metadata": [
51
51
  {
52
52
  "sourceHash": "d2835d9dc456523a",
53
- "ts": "// How to set a metadata entry on a buffer\n// create a new metadata entry with three floats\nbuffer.set_metadata(buf, hash(\"somefloats\"), [1.5, 3.2, 7.9], buffer.VALUE_TYPE_FLOAT32);\n// ...\n// update to a new set of values\nbuffer.set_metadata(buf, hash(\"somefloats\"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);"
53
+ "ts": "// How to set a metadata entry on a buffer\nconst buf = resource.get_buffer(\"/my.bufferc\");\n\n// create a new metadata entry with three floats\nbuffer.set_metadata(buf, hash(\"somefloats\"), [1.5, 3.2, 7.9], buffer.VALUE_TYPE_FLOAT32);\n// ...\n// update to a new set of values\nbuffer.set_metadata(buf, hash(\"somefloats\"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);"
54
54
  }
55
55
  ],
56
56
  "camera.get_cameras": [
57
57
  {
58
58
  "sourceHash": "d332d9320898b958",
59
- "ts": "for (const camera_id of camera.get_cameras()) {\n render.set_camera(camera_id);\n render.draw(predicate);\n render.set_camera();\n}"
59
+ "ts": "const predicate = render.predicate([hash(\"my_tag\")]);\nfor (const camera_id of camera.get_cameras()) {\n render.set_camera(camera_id);\n render.draw(predicate);\n render.set_camera();\n}"
60
60
  }
61
61
  ],
62
62
  "camera.screen_to_world": [
@@ -80,7 +80,7 @@
80
80
  "collectionfactory.create": [
81
81
  {
82
82
  "sourceHash": "5a49721288808772",
83
- "ts": "// How to spawn a collection of game objects:\nexport default defineScript({\n init(self) {\n // Spawn a small group of enemies.\n const pos = vmath.vector3(100, 12.5, 0);\n const rot = vmath.quat_rotation_z(Math.PI / 2);\n const scale = 0.5;\n const props = {\n [hash(\"/enemy_leader\")]: { health: 1000.0 },\n [hash(\"/enemy_1\")]: { health: 200.0 },\n [hash(\"/enemy_2\")]: { health: 400.0, color: hash(\"green\") },\n };\n\n self.enemy_ids = collectionfactory.create(\"#enemyfactory\", pos, rot, props, scale);\n // enemy_ids now map to the spawned instance ids:\n //\n // pprint(self.enemy_ids)\n //\n // DEBUG:SCRIPT:\n // {\n // hash: [/enemy_leader] = hash: [/collection0/enemy_leader],\n // hash: [/enemy_1] = hash: [/collection0/enemy_1],\n // hash: [/enemy_2] = hash: [/collection0/enemy_2]\n // }\n\n // Send \"attack\" message to the leader. First look up its instance id.\n const leader_id = self.enemy_ids[hash(\"/enemy_leader\")];\n msg.post(leader_id, \"attack\");\n },\n});\n\n// How to delete a spawned collection:\ngo.delete(self.enemy_ids);"
83
+ "ts": "// How to spawn a collection of game objects:\nexport default defineScript({\n init(self) {\n // Spawn a small group of enemies.\n const pos = vmath.vector3(100, 12.5, 0);\n const rot = vmath.quat_rotation_z(Math.PI / 2);\n const scale = 0.5;\n const props = {\n [hash(\"/enemy_leader\")]: { health: 1000.0 },\n [hash(\"/enemy_1\")]: { health: 200.0 },\n [hash(\"/enemy_2\")]: { health: 400.0, color: hash(\"green\") },\n };\n\n self.enemy_ids = collectionfactory.create(\"#enemyfactory\", pos, rot, props, scale);\n // enemy_ids now map to the spawned instance ids:\n //\n // pprint(self.enemy_ids)\n //\n // DEBUG:SCRIPT:\n // {\n // hash: [/enemy_leader] = hash: [/collection0/enemy_leader],\n // hash: [/enemy_1] = hash: [/collection0/enemy_1],\n // hash: [/enemy_2] = hash: [/collection0/enemy_2]\n // }\n\n // Send \"attack\" message to the leader. First look up its instance id.\n const leader_id = self.enemy_ids[hash(\"/enemy_leader\")];\n msg.post(leader_id, \"attack\");\n },\n});\n\n// How to delete a spawned collection:\nfunction delete_enemies(self: { enemy_ids: Hash[] }) {\n go.delete(self.enemy_ids);\n}"
84
84
  }
85
85
  ],
86
86
  "collectionfactory.load": [
@@ -104,7 +104,7 @@
104
104
  "collectionproxy.get_resources": [
105
105
  {
106
106
  "sourceHash": "5bba0e0917a2a842",
107
- "ts": "function print_resources(self, cproxy) {\n const resources = collectionproxy.get_resources(cproxy);\n for (const v of resources) {\n print(`Resource: ${v}`);\n }\n}"
107
+ "ts": "function print_resources(self: unknown, cproxy: Url) {\n const resources = collectionproxy.get_resources(cproxy);\n for (const v of resources) {\n print(`Resource: ${v}`);\n }\n}"
108
108
  }
109
109
  ],
110
110
  "collectionproxy.load": [
@@ -253,32 +253,52 @@
253
253
  ],
254
254
  "go.animate": [
255
255
  {
256
- "sourceHash": "ec6a31d150125e06",
257
- "ts": "// Animate the position of a game object to x = 10 during 1 second, then\n// y = 20 during 1 second:\ngo.animate(go.get_id(), \"position.x\", go.PLAYBACK_ONCE_FORWARD, 10, go.EASING_LINEAR, 1, 0, () => {\n go.animate(go.get_id(), \"position.y\", go.PLAYBACK_ONCE_FORWARD, 20, go.EASING_LINEAR, 1);\n});\n\n// Animate the y position of a game object using a crazy custom easing curve:\nconst values = [\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n];\nconst vec = vmath.vector(values);\ngo.animate(\"go\", \"position.y\", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0);"
256
+ "sourceHash": "c4fc72e0b8812778",
257
+ "ts": "go.animate(go.get_id(), \"position.x\", go.PLAYBACK_ONCE_FORWARD, 10, go.EASING_LINEAR, 1, 0, () => {\n go.animate(go.get_id(), \"position.y\", go.PLAYBACK_ONCE_FORWARD, 20, go.EASING_LINEAR, 1);\n});"
258
+ },
259
+ {
260
+ "sourceHash": "97218eef909de34f",
261
+ "ts": "const values = [\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n];\nconst vec = vmath.vector(values);\ngo.animate(\"go\", \"position.y\", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0);"
258
262
  }
259
263
  ],
260
264
  "go.cancel_animations": [
261
265
  {
262
- "sourceHash": "4f012d6eb3d73ce9",
263
- "ts": "// Cancel the animation of the position of a game object:\ngo.cancel_animations(go.get_id(), \"position\");\n\n// Cancel all property animations of the current game object:\ngo.cancel_animations(\".\");\n\n// Cancel all property animations of the sprite component of the current game object:\ngo.cancel_animations(\"#sprite\");"
266
+ "sourceHash": "86ed1a1a22f1883a",
267
+ "ts": "go.cancel_animations(go.get_id(), \"position\");"
268
+ },
269
+ {
270
+ "sourceHash": "a56dbdf46c4ad3b2",
271
+ "ts": "go.cancel_animations(\".\");"
272
+ },
273
+ {
274
+ "sourceHash": "997c90a6a68b8f88",
275
+ "ts": "go.cancel_animations(\"#sprite\");"
264
276
  }
265
277
  ],
266
278
  "go.delete": [
267
279
  {
268
- "sourceHash": "63517a8a15d5d030",
269
- "ts": "// This example demonstrates how to delete game objects:\n// 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);\n\n// This example demonstrates how to delete game objects and their children\n// (child-to-parent order):\n// 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 id2 = go.get_id(\"my_game_object\");\ngo.delete(id2, true);\n// Delete a list of game objects and their children.\nconst ids2 = [hash(\"/my_object_1\"), hash(\"/my_object_2\"), hash(\"/my_object_3\")];\ngo.delete(ids2, true);"
280
+ "sourceHash": "eb1a20098678b7b1",
281
+ "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);"
282
+ },
283
+ {
284
+ "sourceHash": "15be7513485334cf",
285
+ "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);"
270
286
  }
271
287
  ],
272
288
  "go.exists": [
273
289
  {
274
- "sourceHash": "377b4eb5d71df398",
275
- "ts": "// Check if game object \"my_game_object\" exists in the current collection:\ngo.exists(\"/my_game_object\");\n\n// Check if game object exists in another collection:\ngo.exists(\"other_collection:/my_game_object\");"
290
+ "sourceHash": "610b20b7cdbe9792",
291
+ "ts": "go.exists(\"/my_game_object\");"
292
+ },
293
+ {
294
+ "sourceHash": "902851e29bcce669",
295
+ "ts": "go.exists(\"other_collection:/my_game_object\");"
276
296
  }
277
297
  ],
278
298
  "go.get": [
279
299
  {
280
300
  "sourceHash": "7cac2203eda50a5e",
281
- "ts": "// Get a property \"speed\" from a script \"player\"; the property must be declared\n// in the player script:\ngo.property(\"speed\", 50);\n\n// Then in the calling script (assumed to belong to the same game object, but it\n// does not have to):\nconst speed = go.get(\"#player\", \"speed\");\n\n// Get a value in a material property array (the glsl indices are 0-based):\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\n\n// Get all values in a material property array as a table:\ngo.get(url, \"example\"); // => [vector4, vector4, ...]\ngo.get(url, \"example.x\"); // => [number1, number2, ...]\n\n// Get a named property (the resource of a certain gui font):\nconst font_hash = go.get(\"#gui\", \"fonts\", { key: \"system_font_BIG\" });\n\n// Get a property from a sub-component, using the \"keys\" options table\n// (addressing the first level of a component):\ngo.get(\"#particlefx\", \"material\", { keys: [\"cone_emitter\"] });\n\n// Get a property in a deeper sub-hierarchy (if the component supports it).\n// Note: no built-in component supports this yet, but a custom one could.\ngo.get(\"#my_component\", \"some_property\", { keys: [\"root\", \"child_node\"] });"
301
+ "ts": "// Get a property \"speed\" from a script \"player\"; the property must be declared\n// in the player script:\ngo.property(\"speed\", 50);\n\n// Then in the calling script (assumed to belong to the same game object, but it\n// does not have to):\nconst speed = go.get(\"#player\", \"speed\");\n\n// Get a value in a material property array (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\n\n// Get all values in a material property array as a table:\ngo.get(url, \"example\"); // => [vector4, vector4, ...]\ngo.get(url, \"example.x\"); // => [number1, number2, ...]\n\n// Get a named property (the resource of a certain gui font):\nconst font_hash = go.get(\"#gui\", \"fonts\", { key: \"system_font_BIG\" });\n\n// Get a property from a sub-component, using the \"keys\" options table\n// (addressing the first level of a component):\ngo.get(\"#particlefx\", \"material\", { keys: [\"cone_emitter\"] });\n\n// Get a property in a deeper sub-hierarchy (if the component supports it).\n// Note: no built-in component supports this yet, but a custom one could.\ngo.get(\"#my_component\", \"some_property\", { keys: [\"root\", \"child_node\"] });"
282
302
  }
283
303
  ],
284
304
  "go.get_id": [
@@ -289,62 +309,102 @@
289
309
  ],
290
310
  "go.get_parent": [
291
311
  {
292
- "sourceHash": "6e98305fd4cd8f14",
293
- "ts": "// Get parent of the instance containing the calling script:\nconst parent_id = go.get_parent();\n\n// Get parent of the instance with id \"x\":\nconst parent_id2 = go.get_parent(\"x\");"
312
+ "sourceHash": "434d482e8248704d",
313
+ "ts": "const parent_id = go.get_parent();"
314
+ },
315
+ {
316
+ "sourceHash": "668765191be47af9",
317
+ "ts": "const parent_id = go.get_parent(\"x\");"
294
318
  }
295
319
  ],
296
320
  "go.get_position": [
297
321
  {
298
- "sourceHash": "958a14823ca50504",
299
- "ts": "// Get the position of the game object the script is attached to:\nconst p = go.get_position();\n\n// Get the position of another game object \"my_gameobject\":\nconst pos = go.get_position(\"my_gameobject\");"
322
+ "sourceHash": "37ab8f7b8b14f4ea",
323
+ "ts": "const p = go.get_position();"
324
+ },
325
+ {
326
+ "sourceHash": "75d15265b5277990",
327
+ "ts": "const pos = go.get_position(\"my_gameobject\");"
300
328
  }
301
329
  ],
302
330
  "go.get_rotation": [
303
331
  {
304
- "sourceHash": "46e4f7ff790322c3",
305
- "ts": "// Get the rotation of the game object the script is attached to:\nconst r = go.get_rotation();\n\n// Get the rotation of another game object with id \"x\":\nconst r2 = go.get_rotation(\"x\");"
332
+ "sourceHash": "9789a55fd1d86205",
333
+ "ts": "const r = go.get_rotation();"
334
+ },
335
+ {
336
+ "sourceHash": "871aa52a5ec2b871",
337
+ "ts": "const r = go.get_rotation(\"x\");"
306
338
  }
307
339
  ],
308
340
  "go.get_scale": [
309
341
  {
310
- "sourceHash": "b6a9bd9d19741cdd",
311
- "ts": "// Get the scale of the game object the script is attached to:\nconst s = go.get_scale();\n\n// Get the scale of another game object with id \"x\":\nconst s2 = go.get_scale(\"x\");"
342
+ "sourceHash": "e213e818ecd4cb1c",
343
+ "ts": "const s = go.get_scale();"
344
+ },
345
+ {
346
+ "sourceHash": "d91ff62c48d3223a",
347
+ "ts": "const s = go.get_scale(\"x\");"
312
348
  }
313
349
  ],
314
350
  "go.get_scale_uniform": [
315
351
  {
316
- "sourceHash": "0add83a46d3434c3",
317
- "ts": "// Get the uniform scale of the game object the script is attached to:\nconst s = go.get_scale_uniform();\n\n// Get the uniform scale of another game object with id \"x\":\nconst s2 = go.get_scale_uniform(\"x\");"
352
+ "sourceHash": "d63cb41c211275d3",
353
+ "ts": "const s = go.get_scale_uniform();"
354
+ },
355
+ {
356
+ "sourceHash": "99ee7b666f1b339b",
357
+ "ts": "const s = go.get_scale_uniform(\"x\");"
318
358
  }
319
359
  ],
320
360
  "go.get_world_position": [
321
361
  {
322
- "sourceHash": "ab804a5cdcfd4f7d",
323
- "ts": "// Get the world position of the game object the script is attached to:\nconst p = go.get_world_position();\n\n// Reach a sibling game object by its id — relative addressing, no socket prefix:\nconst p2 = go.get_world_position(\"x\");"
362
+ "sourceHash": "6e33af505543920b",
363
+ "ts": "const p = go.get_world_position();"
364
+ },
365
+ {
366
+ "sourceHash": "147cd749a9dc03d3",
367
+ "ts": "// Relative addressing by id — no socket prefix:\nconst p = go.get_world_position(\"x\");"
324
368
  }
325
369
  ],
326
370
  "go.get_world_rotation": [
327
371
  {
328
- "sourceHash": "05c7e59676f614f9",
329
- "ts": "// Get the world rotation of the game object the script is attached to:\nconst r = go.get_world_rotation();\n\n// Get the world rotation of another game object with id \"x\":\nconst r2 = go.get_world_rotation(\"x\");"
372
+ "sourceHash": "034bc38d83c5bbec",
373
+ "ts": "const r = go.get_world_rotation();"
374
+ },
375
+ {
376
+ "sourceHash": "ca4f41fe8d61dd4a",
377
+ "ts": "const r = go.get_world_rotation(\"x\");"
330
378
  }
331
379
  ],
332
380
  "go.get_world_scale": [
333
381
  {
334
- "sourceHash": "bbbe0d3b0c6a9153",
335
- "ts": "// Get the world 3D scale of the game object the script is attached to:\nconst s = go.get_world_scale();\n\n// Get the world scale of another game object \"x\":\nconst s2 = go.get_world_scale(\"x\");"
382
+ "sourceHash": "5966d75fdfac664f",
383
+ "ts": "const s = go.get_world_scale();"
384
+ },
385
+ {
386
+ "sourceHash": "7f93e96d6c6d567f",
387
+ "ts": "const s = go.get_world_scale(\"x\");"
336
388
  }
337
389
  ],
338
390
  "go.get_world_scale_uniform": [
339
391
  {
340
- "sourceHash": "14162dd238db34dd",
341
- "ts": "// Get the world uniform scale of the game object the script is attached to:\nconst s = go.get_world_scale_uniform();\n\n// Get the world uniform scale of another game object with id \"x\":\nconst s2 = go.get_world_scale_uniform(\"x\");"
392
+ "sourceHash": "22473e9aa97e88ec",
393
+ "ts": "const s = go.get_world_scale_uniform();"
394
+ },
395
+ {
396
+ "sourceHash": "5d546c291638cc4a",
397
+ "ts": "const s = go.get_world_scale_uniform(\"x\");"
342
398
  }
343
399
  ],
344
400
  "go.get_world_transform": [
345
401
  {
346
- "sourceHash": "832de2e98a73e953",
347
- "ts": "// Get the world transform of the game object the script is attached to:\nconst m = go.get_world_transform();\n\n// Get the world transform of another game object with id \"x\":\nconst m2 = go.get_world_transform(\"x\");"
402
+ "sourceHash": "2839422dc878a66f",
403
+ "ts": "const m = go.get_world_transform();"
404
+ },
405
+ {
406
+ "sourceHash": "50412f3fb6a3e39f",
407
+ "ts": "const m = go.get_world_transform(\"x\");"
348
408
  }
349
409
  ],
350
410
  "go.property": [
@@ -356,43 +416,71 @@
356
416
  "go.set": [
357
417
  {
358
418
  "sourceHash": "2ca1763ad71c1232",
359
- "ts": "// Set a property \"speed\" of a script \"player\"; the property must be declared in\n// the player script:\ngo.property(\"speed\", 50);\n\n// Then in the calling script (assumed to belong to the same game object, but it\n// does not have to):\ngo.set(\"#player\", \"speed\", 100);\n\n// Set a vector4 in a material property array (the glsl indices are 0-based):\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\n\n// Set a material property array by a table of vector4 (only the first two are\n// set; extra array elements are ignored):\ngo.set(url, \"example\", [vmath.vector4(1, 1, 1, 1), vmath.vector4(2, 2, 2, 2)]);\n\n// Set a named property (inside init(self)):\ngo.property(\"big_font\", resource.font());\ngo.set(\"#gui\", \"fonts\", self.big_font, { key: \"system_font_BIG\" });\n\n// Set a property on a sub-component, using the \"keys\" options table (inside\n// init(self)):\ngo.property(\"my_material\", resource.material);\ngo.set(\"#particlefx\", \"material\", self.my_material, { keys: [\"cone_emitter\"] });\n\n// Set a property in a deeper sub-hierarchy (if the component supports it).\n// Note: no built-in component supports this yet, but a custom one could.\ngo.set(\"#my_component\", \"some_property\", some_value, { keys: [\"root\", \"child_node\"] });"
419
+ "ts": "// Set a property \"speed\" of a script \"player\"; the property must be declared in\n// the player script:\ngo.property(\"speed\", 50);\n\n// Then in the calling script (assumed to belong to the same game object, but it\n// does not have to):\ngo.set(\"#player\", \"speed\", 100);\n\n// Set a vector4 in a material property array (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\n\n// Set a material property array by a table of vector4 (only the first two are\n// set; extra array elements are ignored):\ngo.set(url, \"example\", [vmath.vector4(1, 1, 1, 1), vmath.vector4(2, 2, 2, 2)]);\n\n// Set a named property (inside init(self)):\ngo.property(\"big_font\", resource.font());\n\nfunction set_named_font(self: { big_font: Hash }) {\n go.set(\"#gui\", \"fonts\", self.big_font, { key: \"system_font_BIG\" });\n}\n\n// Set a property on a sub-component, using the \"keys\" options table (inside\n// init(self)):\ngo.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}\n\n// Set a property in a deeper sub-hierarchy (if the component supports it).\n// Note: no built-in component supports this yet, but a custom one could.\nconst some_value = 1;\ngo.set(\"#my_component\", \"some_property\", some_value, { keys: [\"root\", \"child_node\"] });"
360
420
  }
361
421
  ],
362
422
  "go.set_parent": [
363
423
  {
364
- "sourceHash": "2822e1839ed2a321",
365
- "ts": "// Attach myself to another instance \"my_parent\":\ngo.set_parent(go.get_id(), go.get_id(\"my_parent\"));\n\n// Attach an instance \"my_instance\" to another instance \"my_parent\":\ngo.set_parent(go.get_id(\"my_instance\"), go.get_id(\"my_parent\"));\n\n// Detach an instance \"my_instance\" from its parent (if any):\ngo.set_parent(go.get_id(\"my_instance\"));"
424
+ "sourceHash": "6b1747286d3ffe0e",
425
+ "ts": "go.set_parent(go.get_id(), go.get_id(\"my_parent\"));"
426
+ },
427
+ {
428
+ "sourceHash": "bd49a2fdce4a6b26",
429
+ "ts": "go.set_parent(go.get_id(\"my_instance\"), go.get_id(\"my_parent\"));"
430
+ },
431
+ {
432
+ "sourceHash": "d16a1b6edf422448",
433
+ "ts": "go.set_parent(go.get_id(\"my_instance\"));"
366
434
  }
367
435
  ],
368
436
  "go.set_position": [
369
437
  {
370
- "sourceHash": "ad83d0274d776e8f",
371
- "ts": "// `p` is the desired position (a Vector3).\nconst p = vmath.vector3();\n\n// Set the position of the game object the script is attached to:\ngo.set_position(p);\n\n// Reach a sibling game object by its id — relative addressing, no socket prefix:\ngo.set_position(p, \"x\");"
438
+ "sourceHash": "ecc2445f2b8dc35c",
439
+ "ts": "// `p` is the desired position (a Vector3).\nconst p = vmath.vector3();\ngo.set_position(p);"
440
+ },
441
+ {
442
+ "sourceHash": "53b1e5cd24447416",
443
+ "ts": "// `p` is the desired position (a Vector3).\nconst p = vmath.vector3();\n\n// Relative addressing by id — no socket prefix:\ngo.set_position(p, \"x\");"
372
444
  }
373
445
  ],
374
446
  "go.set_rotation": [
375
447
  {
376
- "sourceHash": "782b2092fc7f641f",
377
- "ts": "// `r` is the desired rotation (a Quaternion).\nconst r = vmath.quat();\n\n// Set the rotation of the game object the script is attached to:\ngo.set_rotation(r);\n\n// Set the rotation of another game object with id \"x\":\ngo.set_rotation(r, \"x\");"
448
+ "sourceHash": "82ce8a803b606397",
449
+ "ts": "// `r` is the desired rotation (a Quaternion).\nconst r = vmath.quat();\ngo.set_rotation(r);"
450
+ },
451
+ {
452
+ "sourceHash": "e83143a6f2e2aafb",
453
+ "ts": "// `r` is the desired rotation (a Quaternion).\nconst r = vmath.quat();\ngo.set_rotation(r, \"x\");"
378
454
  }
379
455
  ],
380
456
  "go.set_scale": [
381
457
  {
382
- "sourceHash": "456df524622a534f",
383
- "ts": "// Set the scale of the game object the script is attached to:\nconst s = vmath.vector3(2.0, 1.0, 1.0);\ngo.set_scale(s);\n\n// Set the scale of another game object with id \"obj_id\":\nconst s2 = 1.2;\ngo.set_scale(s2, \"obj_id\");"
458
+ "sourceHash": "60c5ef571b15ad1c",
459
+ "ts": "const s = vmath.vector3(2.0, 1.0, 1.0);\ngo.set_scale(s);"
460
+ },
461
+ {
462
+ "sourceHash": "fe995a14ec731da3",
463
+ "ts": "const s = 1.2;\ngo.set_scale(s, \"obj_id\");"
384
464
  }
385
465
  ],
386
466
  "go.set_scale_xy": [
387
467
  {
388
- "sourceHash": "6d23b1a65292cf1f",
389
- "ts": "// Set the scale of the game object the script is attached to:\nconst s = vmath.vector3(2.0, 1.0, 5.0);\ngo.set_scale_xy(s); // z will not be set here, only x and y\n\n// Set the scale of another game object with id \"obj_id\":\nconst s2 = 1.2;\ngo.set_scale_xy(s2, \"obj_id\"); // z will not be set here, only x and y"
468
+ "sourceHash": "1b80e34a394c163a",
469
+ "ts": "const s = vmath.vector3(2.0, 1.0, 5.0);\ngo.set_scale_xy(s); // z will not be set here, only x and y"
470
+ },
471
+ {
472
+ "sourceHash": "6afb14c6bf68e351",
473
+ "ts": "const s = 1.2;\ngo.set_scale_xy(s, \"obj_id\"); // z will not be set here, only x and y"
390
474
  }
391
475
  ],
392
476
  "go.update_world_transform": [
393
477
  {
394
- "sourceHash": "0c189fdea4a6d715",
395
- "ts": "// Update this game object's world transform:\ngo.update_world_transform();\n\n// Update another game object's world transform:\ngo.update_world_transform(\"/other\");"
478
+ "sourceHash": "ce32b76e7d8c835d",
479
+ "ts": "go.update_world_transform();"
480
+ },
481
+ {
482
+ "sourceHash": "190e7045e4302208",
483
+ "ts": "go.update_world_transform(\"/other\");"
396
484
  }
397
485
  ],
398
486
  "go.world_to_local_position": [
@@ -409,8 +497,16 @@
409
497
  ],
410
498
  "gui.animate": [
411
499
  {
412
- "sourceHash": "afd63fafe7e65e70",
413
- "ts": "// How to start a simple color animation, where the node fades in to white during 0.5 seconds:\ngui.set_color(node, vmath.vector4(0, 0, 0, 0)); // node is fully transparent\ngui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5); // start animation\n\n// How to start a sequenced animation where the node fades in to white during 0.5\n// seconds, stays visible for 2 seconds and then fades out:\nfunction on_animation_done(self, node) {\n // fade out node, but wait 2 seconds before the animation starts\n gui.animate(node, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);\n}\n\nexport default defineScript({\n init(self) {\n // fetch the node we want to animate\n const my_node = gui.get_node(\"my_node\");\n // node is initially set to fully transparent\n gui.set_color(my_node, vmath.vector4(0, 0, 0, 0));\n // animate the node immediately and call on_animation_done when the animation has completed\n gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done);\n },\n});\n\n// How to animate a node's y position using a crazy custom easing curve:\nexport default defineScript({\n init(self) {\n const values = [\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n ];\n const vec = vmath.vector(values);\n const node = gui.get_node(\"box\");\n gui.animate(node, \"position.y\", 100, vec, 4.0, 0, undefined, gui.PLAYBACK_LOOP_PINGPONG);\n },\n});"
500
+ "sourceHash": "2469bb86819278c2",
501
+ "ts": "// How to start a simple color animation, where the node fades in to white during 0.5 seconds:\nconst node = gui.get_node(\"my_node\");\ngui.set_color(node, vmath.vector4(0, 0, 0, 0)); // node is fully transparent\ngui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5); // start animation"
502
+ },
503
+ {
504
+ "sourceHash": "7234f15bfdc28abb",
505
+ "ts": "// How to start a sequenced animation where the node fades in to white during 0.5\n// seconds, stays visible for 2 seconds and then fades out:\nfunction on_animation_done(self: unknown, node: unknown) {\n // fade out node, but wait 2 seconds before the animation starts\n gui.animate(node as Opaque<\"node\">, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);\n}\n\nexport default defineGuiScript({\n init(self) {\n // fetch the node we want to animate\n const my_node = gui.get_node(\"my_node\");\n // node is initially set to fully transparent\n gui.set_color(my_node, vmath.vector4(0, 0, 0, 0));\n // animate the node immediately and call on_animation_done when the animation has completed\n gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done);\n },\n});"
506
+ },
507
+ {
508
+ "sourceHash": "3d5dcef3260b5964",
509
+ "ts": "// How to animate a node's y position using a crazy custom easing curve:\nexport default defineGuiScript({\n init(self) {\n const values = [\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n ];\n const vec = vmath.vector(values);\n const node = gui.get_node(\"box\");\n gui.animate(node, \"position.y\", 100, vec, 4.0, 0, undefined, gui.PLAYBACK_LOOP_PINGPONG);\n },\n});"
414
510
  }
415
511
  ],
416
512
  "gui.cancel_animations": [
@@ -434,7 +530,7 @@
434
530
  "gui.delete_texture": [
435
531
  {
436
532
  "sourceHash": "360a3c74413c6a02",
437
- "ts": "export default defineScript({\n init(self) {\n // Create a texture.\n if (gui.new_texture(\"temp_tx\", 10, 10, \"rgb\", \"\\0\".repeat(10 * 10 * 3))) {\n // Do something with the texture.\n // ...\n\n // Delete the texture\n gui.delete_texture(\"temp_tx\");\n }\n },\n});"
533
+ "ts": "export default defineGuiScript({\n init(self) {\n // Create a texture.\n if (gui.new_texture(\"temp_tx\", 10, 10, \"rgb\", \"\\0\".repeat(10 * 10 * 3))) {\n // Do something with the texture.\n // ...\n\n // Delete the texture\n gui.delete_texture(\"temp_tx\");\n }\n },\n});"
438
534
  }
439
535
  ],
440
536
  "gui.get": [
@@ -446,7 +542,7 @@
446
542
  "gui.get_font_resource": [
447
543
  {
448
544
  "sourceHash": "8eda6241dbbefbbb",
449
- "ts": "// Get the text metrics for a text\nexport default defineScript({\n init(self) {\n const node = gui.get_node(\"name\");\n const font_name = gui.get_font(node);\n const font = gui.get_font_resource(font_name);\n const metrics = resource.get_text_metrics(font, \"The quick brown fox\\n jumps over the lazy dog\");\n },\n});"
545
+ "ts": "// Get the text metrics for a text\nexport default defineGuiScript({\n init(self) {\n const node = gui.get_node(\"name\");\n const font_name = gui.get_font(node);\n const font = gui.get_font_resource(font_name);\n const metrics = resource.get_text_metrics(font, \"The quick brown fox\\n jumps over the lazy dog\");\n },\n});"
450
546
  }
451
547
  ],
452
548
  "gui.get_id": [
@@ -476,19 +572,19 @@
476
572
  "gui.new_texture": [
477
573
  {
478
574
  "sourceHash": "192ba6f4b864704a",
479
- "ts": "// How to create a texture and apply it to a new box node:\nexport default defineScript({\n init(self) {\n const w = 200;\n const h = 300;\n\n // A nice orange. String with the RGB values.\n const orange = String.fromCharCode(0xff, 0x80, 0x10);\n\n // Create the texture. Repeat the color string for each pixel.\n const [ok, reason] = gui.new_texture(\"orange_tx\", w, h, \"rgb\", orange.repeat(w * h));\n if (ok) {\n // Create a box node and apply the texture to it.\n const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));\n gui.set_texture(n, \"orange_tx\");\n } else {\n // Could not create texture for some reason...\n if (reason === gui.RESULT_TEXTURE_ALREADY_EXISTS) {\n // ...\n } else {\n // ...\n }\n }\n },\n});\n\n// How to create a texture using .astc format\nconst path = \"/assets/images/logo_4x4.astc\";\nconst buffer = sys.load_resource(path);\nconst n = gui.new_box_node(pos, vmath.vector3(size, size, 0));\n// size is read from the .astc buffer\n// flip is not supported\ngui.new_texture(path, 0, 0, \"astc\", buffer, false);\ngui.set_texture(n, path);"
575
+ "ts": "// How to create a texture and apply it to a new box node:\nexport default defineGuiScript({\n init(self) {\n const w = 200;\n const h = 300;\n\n // A nice orange. String with the RGB values.\n const orange = String.fromCharCode(0xff, 0x80, 0x10);\n\n // Create the texture. Repeat the color string for each pixel.\n const [ok, reason] = gui.new_texture(\"orange_tx\", w, h, \"rgb\", orange.repeat(w * h));\n if (ok) {\n // Create a box node and apply the texture to it.\n const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));\n gui.set_texture(n, \"orange_tx\");\n } else {\n // Could not create texture for some reason...\n if (reason === gui.RESULT_TEXTURE_ALREADY_EXISTS) {\n // ...\n } else {\n // ...\n }\n }\n },\n});\n\n// How to create a texture using .astc format\nconst size = 4;\nconst pos = vmath.vector3(200, 200, 0);\nconst path = \"/assets/images/logo_4x4.astc\";\nconst buffer = sys.load_resource(path);\nconst n = gui.new_box_node(pos, vmath.vector3(size, size, 0));\n// size is read from the .astc buffer\n// flip is not supported\ngui.new_texture(path, 0, 0, \"astc\", buffer, false);\ngui.set_texture(n, path);"
480
576
  }
481
577
  ],
482
578
  "gui.play_flipbook": [
483
579
  {
484
580
  "sourceHash": "341233e631c23020",
485
- "ts": "// Set the texture of a node to a flipbook animation from an atlas:\nfunction anim_callback(self, node) {\n // Take action after animation has played.\n}\n\nexport default defineScript({\n init(self) {\n // Create a new node and set the texture to a flipbook animation\n const node = gui.get_node(\"button_node\");\n gui.set_texture(node, \"gui_sprites\");\n gui.play_flipbook(node, \"animated_button\");\n },\n});\n\n// Set the texture of a node to an image from an atlas:\n// Create a new node and set the texture to a \"button.png\" from atlas\nconst node = gui.get_node(\"button_node\");\ngui.set_texture(node, \"gui_sprites\");\ngui.play_flipbook(node, \"button\");"
581
+ "ts": "// Set the texture of a node to a flipbook animation from an atlas:\nfunction anim_callback(self: unknown, node: unknown) {\n // Take action after animation has played.\n}\n\nexport default defineGuiScript({\n init(self) {\n // Create a new node and set the texture to a flipbook animation\n const node = gui.get_node(\"button_node\");\n gui.set_texture(node, \"gui_sprites\");\n gui.play_flipbook(node, \"animated_button\");\n },\n});\n\n// Set the texture of a node to an image from an atlas:\n// Create a new node and set the texture to a \"button.png\" from atlas\nconst node = gui.get_node(\"button_node\");\ngui.set_texture(node, \"gui_sprites\");\ngui.play_flipbook(node, \"button\");"
486
582
  }
487
583
  ],
488
584
  "gui.play_particlefx": [
489
585
  {
490
586
  "sourceHash": "19a26b6e14ad0997",
491
- "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, node, emitter, state) {\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 gui.play_particlefx(gui.get_node(\"particlefx\"), emitter_state_change);\n },\n});"
587
+ "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});"
492
588
  }
493
589
  ],
494
590
  "gui.reset_material": [
@@ -500,17 +596,17 @@
500
596
  "gui.screen_to_local": [
501
597
  {
502
598
  "sourceHash": "3e442324e48a7f04",
503
- "ts": "// Animate a node to the pressed pointer position:\nexport default defineScript({\n init() {\n msg.post(\".\", \"acquire_input_focus\");\n return { marker: gui.get_node(\"marker\") };\n },\n\n on_input(self, action_id, action) {\n if (action_id === hash(\"touch\") && action.pressed) {\n const screen_position = vmath.vector3(action.screen_x, action.screen_y, 0);\n const target_position = gui.screen_to_local(self.marker, screen_position);\n gui.animate(self.marker, gui.PROP_POSITION, target_position, gui.EASING_OUTQUAD, 0.2);\n return true;\n }\n },\n});"
599
+ "ts": "// Animate a node to the pressed pointer position:\nexport default defineGuiScript({\n init() {\n msg.post(\".\", \"acquire_input_focus\");\n return { marker: gui.get_node(\"marker\") };\n },\n\n on_input(self, action_id, action) {\n if (action_id === hash(\"touch\") && action.pressed) {\n const screen_position = vmath.vector3(action.screen_x, action.screen_y, 0);\n const target_position = gui.screen_to_local(self.marker, screen_position);\n gui.animate(self.marker, gui.PROP_POSITION, target_position, gui.EASING_OUTQUAD, 0.2);\n return true;\n }\n },\n});"
504
600
  }
505
601
  ],
506
602
  "gui.set": [
507
603
  {
508
604
  "sourceHash": "a609fdbcee772fac",
509
- "ts": "// Updates the position property on an existing node:\nconst node = gui.get_node(\"my_box_node\");\nconst node_position = gui.get(node, \"position\");\ngui.set(node, \"position.x\", node_position.x + 128);\n\n// Updates the rotation property on an existing node:\ngui.set(node, \"rotation\", vmath.quat_rotation_z(math.rad(45)));\n// this is equivalent to:\ngui.set(node, \"euler.z\", 45);\n// or using the entire vector:\ngui.set(node, \"euler\", vmath.vector3(0, 0, 45));\n// or using the set_rotation\ngui.set_rotation(node, vmath.vector3(0, 0, 45));\n\n// Sets various material constants for a node:\ngui.set(node, \"tint\", vmath.vector4(1, 0, 0, 1));\n// matrix4 is also supported\ngui.set(node, \"light_matrix\", vmath.matrix4());\n// update a constant in an array at position 4. the array is specified in the shader as:\n// uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based\ngui.set(node, \"tint_array\", vmath.vector4(1, 0, 0, 1), { index: 4 });\n// update a matrix constant in an array at position 4. the array is specified in the shader as:\n// uniform mat4 light_matrix_array[4];\ngui.set(node, \"light_matrix_array\", vmath.matrix4(), { index: 4 });\n// update a sub-element in a constant\ngui.set(node, \"tint.x\", 1);\n// update a sub-element in an array constant at position 4\ngui.set(node, \"tint_array.x\", 1, { index: 4 });\n\n// Set a named property\nexport default defineScript({\n on_message(self, message_id, message) {\n if (message_id === hash(\"set_font\")) {\n gui.set(msg.url(), \"fonts\", message.font, { key: \"my_font_name\" });\n gui.set_font(gui.get_node(\"text\"), \"my_font_name\");\n } else if (message_id === hash(\"set_texture\")) {\n gui.set(msg.url(), \"textures\", message.texture, { key: \"my_texture\" });\n gui.set_texture(gui.get_node(\"box\"), \"my_texture\");\n gui.play_flipbook(gui.get_node(\"box\"), \"logo_256\");\n }\n },\n});\n\n// Remove a named runtime texture resource mapping:\nconst atlas_id = resource.create_atlas(\"/runtime.texturesetc\", atlas_params);\ngui.set(msg.url(), \"textures\", atlas_id, { key: \"runtime_texture\" });\ngui.set_texture(gui.get_node(\"box\"), \"runtime_texture\");\n\n// Later, remove the GUI mapping before releasing the atlas resource.\ngui.set(msg.url(), \"textures\", undefined, { key: \"runtime_texture\" });\nresource.release(atlas_id);"
605
+ "ts": "// Updates the position property on an existing node:\nconst node = gui.get_node(\"my_box_node\");\nconst node_position = gui.get(node, \"position\");\ngui.set(node, \"position.x\", node_position.x + 128);\n\n// Updates the rotation property on an existing node:\ngui.set(node, \"rotation\", vmath.quat_rotation_z(math.rad(45)));\n// this is equivalent to:\ngui.set(node, \"euler.z\", 45);\n// or using the entire vector:\ngui.set(node, \"euler\", vmath.vector3(0, 0, 45));\n// or using the set_rotation\ngui.set_rotation(node, vmath.vector3(0, 0, 45));\n\n// Sets various material constants for a node:\ngui.set(node, \"tint\", vmath.vector4(1, 0, 0, 1));\n// matrix4 is also supported\ngui.set(node, \"light_matrix\", vmath.matrix4());\n// update a constant in an array at position 4. the array is specified in the shader as:\n// uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based\ngui.set(node, \"tint_array\", vmath.vector4(1, 0, 0, 1), { index: 4 });\n// update a matrix constant in an array at position 4. the array is specified in the shader as:\n// uniform mat4 light_matrix_array[4];\ngui.set(node, \"light_matrix_array\", vmath.matrix4(), { index: 4 });\n// update a sub-element in a constant\ngui.set(node, \"tint.x\", 1);\n// update a sub-element in an array constant at position 4\ngui.set(node, \"tint_array.x\", 1, { index: 4 });\n\n// Set a named property\nexport default defineGuiScript({\n on_message(self, message_id, message) {\n if (message_id === hash(\"set_font\")) {\n gui.set(msg.url(), \"fonts\", message.font, { key: \"my_font_name\" });\n gui.set_font(gui.get_node(\"text\"), \"my_font_name\");\n } else if (message_id === hash(\"set_texture\")) {\n gui.set(msg.url(), \"textures\", message.texture, { key: \"my_texture\" });\n gui.set_texture(gui.get_node(\"box\"), \"my_texture\");\n gui.play_flipbook(gui.get_node(\"box\"), \"logo_256\");\n }\n },\n});\n\n// Remove a named runtime texture resource mapping:\nconst atlas_params = { texture: \"/runtime.texturec\", animations: [], geometries: [] };\nconst atlas_id = resource.create_atlas(\"/runtime.texturesetc\", atlas_params);\ngui.set(msg.url(), \"textures\", atlas_id, { key: \"runtime_texture\" });\ngui.set_texture(gui.get_node(\"box\"), \"runtime_texture\");\n\n// Later, remove the GUI mapping before releasing the atlas resource.\ngui.set(msg.url(), \"textures\", undefined, { key: \"runtime_texture\" });\nresource.release(atlas_id);"
510
606
  },
511
607
  {
512
608
  "sourceHash": "d195edde0a9fd170",
513
- "ts": "// Updates the position property on an existing node:\nconst node = gui.get_node(\"my_box_node\");\nconst node_position = gui.get(node, \"position\");\ngui.set(node, \"position.x\", node_position.x + 128);\n\n// Updates the rotation property on an existing node:\ngui.set(node, \"rotation\", vmath.quat_rotation_z(math.rad(45)));\n// this is equivalent to:\ngui.set(node, \"euler.z\", 45);\n// or using the entire vector:\ngui.set(node, \"euler\", vmath.vector3(0, 0, 45));\n// or using the set_rotation\ngui.set_rotation(node, vmath.vector3(0, 0, 45));\n\n// Sets various material constants for a node:\ngui.set(node, \"tint\", vmath.vector4(1, 0, 0, 1));\n// matrix4 is also supported\ngui.set(node, \"light_matrix\", vmath.matrix4());\n// update a constant in an array at position 4. the array is specified in the shader as:\n// uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based\ngui.set(node, \"tint_array\", vmath.vector4(1, 0, 0, 1), { index: 4 });\n// update a matrix constant in an array at position 4. the array is specified in the shader as:\n// uniform mat4 light_matrix_array[4];\ngui.set(node, \"light_matrix_array\", vmath.matrix4(), { index: 4 });\n// update a sub-element in a constant\ngui.set(node, \"tint.x\", 1);\n// update a sub-element in an array constant at position 4\ngui.set(node, \"tint_array.x\", 1, { index: 4 });\n\n// Set a named property\nexport default defineScript({\n on_message(self, message_id, message) {\n if (message_id === hash(\"set_font\")) {\n gui.set(msg.url(), \"fonts\", message.font, { key: \"my_font_name\" });\n gui.set_font(gui.get_node(\"text\"), \"my_font_name\");\n } else if (message_id === hash(\"set_texture\")) {\n gui.set(msg.url(), \"textures\", message.texture, { key: \"my_texture\" });\n gui.set_texture(gui.get_node(\"box\"), \"my_texture\");\n gui.play_flipbook(gui.get_node(\"box\"), \"logo_256\");\n }\n },\n});"
609
+ "ts": "// Updates the position property on an existing node:\nconst node = gui.get_node(\"my_box_node\");\nconst node_position = gui.get(node, \"position\");\ngui.set(node, \"position.x\", node_position.x + 128);\n\n// Updates the rotation property on an existing node:\ngui.set(node, \"rotation\", vmath.quat_rotation_z(math.rad(45)));\n// this is equivalent to:\ngui.set(node, \"euler.z\", 45);\n// or using the entire vector:\ngui.set(node, \"euler\", vmath.vector3(0, 0, 45));\n// or using the set_rotation\ngui.set_rotation(node, vmath.vector3(0, 0, 45));\n\n// Sets various material constants for a node:\ngui.set(node, \"tint\", vmath.vector4(1, 0, 0, 1));\n// matrix4 is also supported\ngui.set(node, \"light_matrix\", vmath.matrix4());\n// update a constant in an array at position 4. the array is specified in the shader as:\n// uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based\ngui.set(node, \"tint_array\", vmath.vector4(1, 0, 0, 1), { index: 4 });\n// update a matrix constant in an array at position 4. the array is specified in the shader as:\n// uniform mat4 light_matrix_array[4];\ngui.set(node, \"light_matrix_array\", vmath.matrix4(), { index: 4 });\n// update a sub-element in a constant\ngui.set(node, \"tint.x\", 1);\n// update a sub-element in an array constant at position 4\ngui.set(node, \"tint_array.x\", 1, { index: 4 });\n\n// Set a named property\nexport default defineGuiScript({\n on_message(self, message_id, message) {\n if (message_id === hash(\"set_font\")) {\n gui.set(msg.url(), \"fonts\", message.font, { key: \"my_font_name\" });\n gui.set_font(gui.get_node(\"text\"), \"my_font_name\");\n } else if (message_id === hash(\"set_texture\")) {\n gui.set(msg.url(), \"textures\", message.texture, { key: \"my_texture\" });\n gui.set_texture(gui.get_node(\"box\"), \"my_texture\");\n gui.play_flipbook(gui.get_node(\"box\"), \"logo_256\");\n }\n },\n});"
514
610
  }
515
611
  ],
516
612
  "gui.set_id": [
@@ -534,7 +630,7 @@
534
630
  "gui.set_texture_data": [
535
631
  {
536
632
  "sourceHash": "86e3fd4362242ba1",
537
- "ts": "export default defineScript({\n init(self) {\n const w = 200;\n const h = 300;\n\n // Create a dynamic texture, all white.\n if (gui.new_texture(\"dynamic_tx\", w, h, \"rgb\", String.fromCharCode(0xff).repeat(w * h * 3))) {\n // Create a box node and apply the texture to it.\n const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));\n gui.set_texture(n, \"dynamic_tx\");\n\n // ...\n\n // Change the data in the texture to a nice orange.\n const orange = String.fromCharCode(0xff, 0x80, 0x10);\n if (gui.set_texture_data(\"dynamic_tx\", w, h, \"rgb\", orange.repeat(w * h))) {\n // Go on and to more stuff\n // ...\n }\n } else {\n // Something went wrong\n // ...\n }\n },\n});"
633
+ "ts": "export default defineGuiScript({\n init(self) {\n const w = 200;\n const h = 300;\n\n // Create a dynamic texture, all white.\n if (gui.new_texture(\"dynamic_tx\", w, h, \"rgb\", String.fromCharCode(0xff).repeat(w * h * 3))) {\n // Create a box node and apply the texture to it.\n const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));\n gui.set_texture(n, \"dynamic_tx\");\n\n // ...\n\n // Change the data in the texture to a nice orange.\n const orange = String.fromCharCode(0xff, 0x80, 0x10);\n if (gui.set_texture_data(\"dynamic_tx\", w, h, \"rgb\", orange.repeat(w * h))) {\n // Go on and to more stuff\n // ...\n }\n } else {\n // Something went wrong\n // ...\n }\n },\n});"
538
634
  }
539
635
  ],
540
636
  "html5.run": [
@@ -546,13 +642,13 @@
546
642
  "html5.set_interaction_listener": [
547
643
  {
548
644
  "sourceHash": "edc07489a3fc761c",
549
- "ts": "function on_interaction(self) {\n print(\"on_interaction called\");\n html5.set_interaction_listener(undefined);\n}\n\nexport default defineScript({\n init() {\n html5.set_interaction_listener(on_interaction);\n },\n});"
645
+ "ts": "function on_interaction(self: unknown) {\n print(\"on_interaction called\");\n html5.set_interaction_listener(undefined);\n}\n\nexport default defineScript({\n init() {\n html5.set_interaction_listener(on_interaction);\n },\n});"
550
646
  }
551
647
  ],
552
648
  "http.request": [
553
649
  {
554
650
  "sourceHash": "170c94c250c1ce49",
555
- "ts": "// Basic HTTP-GET request. The callback receives a table with the response\n// in the fields status, the response (the data) and headers (a table).\nexport default defineScript({\n init() {\n http.request(\n \"http://www.google.com\",\n \"GET\",\n (self, _id, response) => {\n if (response.bytes_total !== undefined) {\n update_my_progress_bar(self, response.bytes_received / response.bytes_total);\n } else {\n print(response.status);\n print(response.response);\n pprint(response.headers);\n }\n },\n undefined,\n undefined,\n { report_progress: true },\n );\n },\n});"
651
+ "ts": "function update_my_progress_bar(self: unknown, fraction: number) {\n // draw the progress bar at the given fraction\n}\n\n// Basic HTTP-GET request. The callback receives a table with the response\n// in the fields status, the response (the data) and headers (a table).\nexport default defineScript({\n init() {\n http.request(\n \"http://www.google.com\",\n \"GET\",\n (self, _id, response) => {\n if (response.bytes_total !== undefined) {\n update_my_progress_bar(self, response.bytes_received / response.bytes_total);\n } else {\n print(response.status);\n print(response.response);\n pprint(response.headers);\n }\n },\n undefined,\n undefined,\n { report_progress: true },\n );\n },\n});"
556
652
  }
557
653
  ],
558
654
  "image.get_astc_header": [
@@ -710,13 +806,13 @@
710
806
  "model.get_mesh_enabled": [
711
807
  {
712
808
  "sourceHash": "b2f9e47a91bc3f12",
713
- "ts": "export default defineScript({\n init(self) {\n if (model.get_mesh_enabled(\"#model\", \"Sword\")) {\n // set properties specific for the sword\n self.weapon_properties = game.data.weapons[\"Sword\"];\n }\n },\n});"
809
+ "ts": "// shared weapon data, e.g. required from your own module\nconst game = { data: { weapons: { Sword: { damage: 10 } } } };\n\nexport default defineScript({\n init(self) {\n if (model.get_mesh_enabled(\"#model\", \"Sword\")) {\n // set properties specific for the sword\n self.weapon_properties = game.data.weapons[\"Sword\"];\n }\n },\n});"
714
810
  }
715
811
  ],
716
812
  "model.play_anim": [
717
813
  {
718
814
  "sourceHash": "64d6b46054d23a1b",
719
- "ts": "// The following examples assume that the model has id \"model\".\n// How to play the \"jump\" animation followed by the \"run\" animation:\nfunction anim_done(self, message_id, message, sender) {\n if (message_id === hash(\"model_animation_done\")) {\n if (message.animation_id === hash(\"jump\")) {\n // open animation done, chain with \"run\"\n const properties = { blend_duration: 0.2 };\n model.play_anim(url, \"run\", go.PLAYBACK_LOOP_FORWARD, properties, anim_done);\n }\n }\n}\n\nexport default defineScript({\n init(self) {\n const url = msg.url(\"#model\");\n const play_properties = { blend_duration: 0.1 };\n // first blend during 0.1 sec into the jump, then during 0.2 s into the run animation\n model.play_anim(url, \"jump\", go.PLAYBACK_ONCE_FORWARD, play_properties, anim_done);\n },\n});"
815
+ "ts": "// The following examples assume that the model has id \"model\".\n// How to play the \"jump\" animation followed by the \"run\" animation:\nconst url = msg.url(\"#model\");\n\nfunction anim_done(self: unknown, message_id: unknown, message: unknown, sender: unknown) {\n if (message_id === hash(\"model_animation_done\")) {\n const { animation_id } = message as { animation_id: Hash };\n if (animation_id === hash(\"jump\")) {\n // open animation done, chain with \"run\"\n const properties = { blend_duration: 0.2 };\n model.play_anim(url, \"run\", go.PLAYBACK_LOOP_FORWARD, properties, anim_done);\n }\n }\n}\n\nexport default defineScript({\n init(self) {\n const play_properties = { blend_duration: 0.1 };\n // first blend during 0.1 sec into the jump, then during 0.2 s into the run animation\n model.play_anim(url, \"jump\", go.PLAYBACK_ONCE_FORWARD, play_properties, anim_done);\n },\n});"
720
816
  }
721
817
  ],
722
818
  "model.reset_constant": [
@@ -740,7 +836,7 @@
740
836
  "msg.post": [
741
837
  {
742
838
  "sourceHash": "8eb90635d0b538fe",
743
- "ts": "// Send \"enable\" to the sprite \"my_sprite\" in \"my_gameobject\":\nmsg.post(\"my_gameobject#my_sprite\", \"enable\");\n\n// Send a \"my_message\" to a url with some additional data:\nconst params = { my_parameter: \"my_value\" };\nmsg.post(my_url, \"my_message\", params);"
839
+ "ts": "// Send \"enable\" to the sprite \"my_sprite\" in \"my_gameobject\":\nmsg.post(\"my_gameobject#my_sprite\", \"enable\");\n\n// Send a \"my_message\" to a url with some additional data:\nconst my_url = msg.url(\"my_gameobject#my_script\");\nconst params = { my_parameter: \"my_value\" };\nmsg.post(my_url, \"my_message\", params);"
744
840
  }
745
841
  ],
746
842
  "msg.url": [
@@ -764,13 +860,17 @@
764
860
  },
765
861
  {
766
862
  "sourceHash": "cc835ea429adc693",
767
- "ts": "export default defineScript({\n on_input(self, action_id, action) {\n // check for input\n if (action_id === hash(\"my_action\")) {\n // take appropriate action\n self.my_value = action.value;\n }\n // consume input\n return true;\n },\n});"
863
+ "ts": "export default defineGuiScript({\n on_input(self, action_id, action) {\n // check for input\n if (action_id === hash(\"my_action\")) {\n // take appropriate action\n self.my_value = action.value;\n }\n // consume input\n return true;\n },\n});"
768
864
  }
769
865
  ],
770
866
  "on_message": [
771
867
  {
772
- "sourceHash": "bfed6bd72e3242e2",
773
- "ts": "// This example demonstrates how a game object instance, called \"a\", can communicate with another instance, called \"b\". It\n// is assumed that both script components of the instances has id \"script\".\n\n// a.script — Script of instance \"a\":\nexport default defineScript({\n init() {\n // let b know about some important data\n msg.post(\"b#script\", \"my_data\", { important_value: 1 });\n },\n});\n\n// b.script — Script of instance \"b\":\nexport default defineScript({\n init() {\n // store the url of instance \"a\" for later use, by specifying undefined as socket we\n // automatically use our own socket\n return { a_url: msg.url(undefined, go.get_id(\"a\"), \"script\") };\n },\n\n on_message(self, message_id, message, sender) {\n // check message and sender\n if (message_id === hash(\"my_data\") && sender === self.a_url) {\n // use the data in some way\n self.important_value = message.important_value;\n }\n },\n});"
868
+ "sourceHash": "d5850f2009394171",
869
+ "ts": "// This example demonstrates how a game object instance, called \"a\", can communicate with another instance, called \"b\". It\n// is assumed that both script components of the instances has id \"script\".\n\n// a.script — Script of instance \"a\":\nexport default defineScript({\n init() {\n // let b know about some important data\n msg.post(\"b#script\", \"my_data\", { important_value: 1 });\n },\n});"
870
+ },
871
+ {
872
+ "sourceHash": "9f37896589565629",
873
+ "ts": "// b.script — Script of instance \"b\":\nexport default defineScript({\n init() {\n // store the url of instance \"a\" for later use, by specifying undefined as socket we\n // automatically use our own socket\n return { a_url: msg.url(undefined, go.get_id(\"a\"), \"script\") };\n },\n\n on_message(self, message_id, message, sender) {\n // check message and sender\n if (message_id === hash(\"my_data\") && sender === self.a_url) {\n // use the data in some way\n self.important_value = message.important_value;\n }\n },\n});"
774
874
  }
775
875
  ],
776
876
  "on_reload": [
@@ -786,7 +886,7 @@
786
886
  "particlefx.play": [
787
887
  {
788
888
  "sourceHash": "01a21997b47ac4fc",
789
- "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, id, emitter, state) {\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});"
889
+ "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});"
790
890
  }
791
891
  ],
792
892
  "particlefx.reset_constant": [
@@ -816,23 +916,23 @@
816
916
  "physics.raycast": [
817
917
  {
818
918
  "sourceHash": "3e0c534d741f0120",
819
- "ts": "// How to perform a ray cast synchronously:\nexport default defineScript({\n init(self) {\n self.groups = [hash(\"world\"), hash(\"enemy\")];\n },\n\n update(self, dt) {\n // request ray cast\n const result = physics.raycast(from, to, self.groups, { all: true });\n if (result !== undefined) {\n // act on the hit (see 'ray_cast_response')\n for (const result of results) {\n handle_result(result);\n }\n }\n },\n});"
919
+ "ts": "function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash; request_id: number }) {\n // act on the hit (see 'ray_cast_response')\n}\n\n// How to perform a ray cast synchronously:\nexport default defineScript({\n init(self) {\n self.groups = [hash(\"world\"), hash(\"enemy\")];\n },\n\n update(self, dt) {\n // request ray cast\n const from = go.get_world_position();\n const to = vmath.vector3(from.x, from.y - 100, from.z);\n const results = physics.raycast(from, to, self.groups, { all: true });\n if (results !== undefined) {\n for (const result of results) {\n handle_result(result);\n }\n }\n },\n});"
820
920
  }
821
921
  ],
822
922
  "physics.raycast_async": [
823
923
  {
824
924
  "sourceHash": "746b7900ebaa1f10",
825
- "ts": "// How to perform a ray cast asynchronously:\nexport default defineScript({\n init(self) {\n self.my_groups = [hash(\"my_group1\"), hash(\"my_group2\")];\n },\n\n update(self, dt) {\n // request ray cast\n physics.raycast_async(my_start, my_end, self.my_groups);\n },\n\n on_message(self, message_id, message, sender) {\n // check for the response\n if (message_id === hash(\"ray_cast_response\")) {\n // act on the hit\n } else if (message_id === hash(\"ray_cast_missed\")) {\n // act on the miss\n }\n },\n});"
925
+ "ts": "// How to perform a ray cast asynchronously:\nexport default defineScript({\n init(self) {\n self.my_groups = [hash(\"my_group1\"), hash(\"my_group2\")];\n },\n\n update(self, dt) {\n // request ray cast\n const my_start = go.get_world_position();\n const my_end = vmath.vector3(my_start.x, my_start.y - 100, my_start.z);\n physics.raycast_async(my_start, my_end, self.my_groups);\n },\n\n on_message(self, message_id, message, sender) {\n // check for the response\n if (message_id === hash(\"ray_cast_response\")) {\n // act on the hit\n } else if (message_id === hash(\"ray_cast_missed\")) {\n // act on the miss\n }\n },\n});"
826
926
  }
827
927
  ],
828
928
  "physics.set_event_listener": [
829
929
  {
830
930
  "sourceHash": "5d31d05d52e50c3f",
831
- "ts": "function physics_world_listener(self, events) {\n for (const event of events) {\n const event_type = event[\"type\"];\n if (event_type === hash(\"contact_point_event\")) {\n pprint(event);\n // {\n // distance = 2.1490633487701,\n // applied_impulse = 0\n // a = { --[[0x113f7c6c0]]\n // group = hash: [box],\n // id = hash: [/box]\n // mass = 0,\n // normal = vmath.vector3(0.379, 0.925, -0),\n // position = vmath.vector3(517.337, 235.068, 0),\n // instance_position = vmath.vector3(480, 144, 0),\n // relative_velocity = vmath.vector3(-0, -0, -0),\n // },\n // b = { --[[0x113f7c840]]\n // group = hash: [circle],\n // id = hash: [/circle]\n // mass = 0,\n // normal = vmath.vector3(-0.379, -0.925, 0),\n // position = vmath.vector3(517.337, 235.068, 0),\n // instance_position = vmath.vector3(-0.0021, 0, -0.0022),\n // relative_velocity = vmath.vector3(0, 0, 0),\n // },\n // }\n } else if (event === hash(\"collision_event\")) {\n pprint(event);\n // {\n // a = {\n // group = hash: [default],\n // position = vmath.vector3(183, 666, 0),\n // id = hash: [/go1]\n // },\n // b = {\n // group = hash: [default],\n // position = vmath.vector3(185, 704.05865478516, 0),\n // id = hash: [/go2]\n // }\n // }\n } else if (event === hash(\"trigger_event\")) {\n pprint(event);\n // {\n // enter = true,\n // b = {\n // group = hash: [default],\n // id = hash: [/go2]\n // },\n // a = {\n // group = hash: [default],\n // id = hash: [/go1]\n // }\n // },\n } else if (event === hash(\"ray_cast_response\")) {\n pprint(event);\n // {\n // group = hash: [default],\n // request_id = 0,\n // position = vmath.vector3(249.92222595215, 249.92222595215, 0),\n // fraction = 0.68759721517563,\n // normal = vmath.vector3(0, 1, 0),\n // id = hash: [/go]\n // }\n } else if (event === hash(\"ray_cast_missed\")) {\n pprint(event);\n // {\n // request_id = 0\n // },\n }\n }\n}\n\nexport default defineScript({\n init(self) {\n physics.set_event_listener(physics_world_listener);\n },\n});"
931
+ "ts": "function physics_world_listener(self: unknown, events: unknown) {\n for (const event of events as Record<string, unknown>[]) {\n const event_type = event[\"type\"];\n if (event_type === hash(\"contact_point_event\")) {\n pprint(event);\n // {\n // distance = 2.1490633487701,\n // applied_impulse = 0\n // a = { --[[0x113f7c6c0]]\n // group = hash: [box],\n // id = hash: [/box]\n // mass = 0,\n // normal = vmath.vector3(0.379, 0.925, -0),\n // position = vmath.vector3(517.337, 235.068, 0),\n // instance_position = vmath.vector3(480, 144, 0),\n // relative_velocity = vmath.vector3(-0, -0, -0),\n // },\n // b = { --[[0x113f7c840]]\n // group = hash: [circle],\n // id = hash: [/circle]\n // mass = 0,\n // normal = vmath.vector3(-0.379, -0.925, 0),\n // position = vmath.vector3(517.337, 235.068, 0),\n // instance_position = vmath.vector3(-0.0021, 0, -0.0022),\n // relative_velocity = vmath.vector3(0, 0, 0),\n // },\n // }\n } else if (event_type === hash(\"collision_event\")) {\n pprint(event);\n // {\n // a = {\n // group = hash: [default],\n // position = vmath.vector3(183, 666, 0),\n // id = hash: [/go1]\n // },\n // b = {\n // group = hash: [default],\n // position = vmath.vector3(185, 704.05865478516, 0),\n // id = hash: [/go2]\n // }\n // }\n } else if (event_type === hash(\"trigger_event\")) {\n pprint(event);\n // {\n // enter = true,\n // b = {\n // group = hash: [default],\n // id = hash: [/go2]\n // },\n // a = {\n // group = hash: [default],\n // id = hash: [/go1]\n // }\n // },\n } else if (event_type === hash(\"ray_cast_response\")) {\n pprint(event);\n // {\n // group = hash: [default],\n // request_id = 0,\n // position = vmath.vector3(249.92222595215, 249.92222595215, 0),\n // fraction = 0.68759721517563,\n // normal = vmath.vector3(0, 1, 0),\n // id = hash: [/go]\n // }\n } else if (event_type === hash(\"ray_cast_missed\")) {\n pprint(event);\n // {\n // request_id = 0\n // },\n }\n }\n}\n\nexport default defineScript({\n init(self) {\n physics.set_event_listener(physics_world_listener);\n },\n});"
832
932
  },
833
933
  {
834
934
  "sourceHash": "ac24712f2e988ba4",
835
- "ts": "function physics_world_listener(self, events) {\n for (const event of events) {\n const event_type = event[\"type\"];\n if (event_type === hash(\"contact_point_event\")) {\n pprint(event);\n // {\n // distance = 2.1490633487701,\n // applied_impulse = 0\n // a = { --[[0x113f7c6c0]]\n // group = hash: [box],\n // id = hash: [/box]\n // mass = 0,\n // normal = vmath.vector3(0.379, 0.925, -0),\n // position = vmath.vector3(517.337, 235.068, 0),\n // instance_position = vmath.vector3(480, 144, 0),\n // relative_velocity = vmath.vector3(-0, -0, -0),\n // },\n // b = { --[[0x113f7c840]]\n // group = hash: [circle],\n // id = hash: [/circle]\n // mass = 0,\n // normal = vmath.vector3(-0.379, -0.925, 0),\n // position = vmath.vector3(517.337, 235.068, 0),\n // instance_position = vmath.vector3(-0.0021, 0, -0.0022),\n // relative_velocity = vmath.vector3(0, 0, 0),\n // },\n // }\n } else if (event === hash(\"collision_event\")) {\n pprint(event);\n // {\n // a = {\n // group = hash: [default],\n // position = vmath.vector3(183, 666, 0),\n // id = hash: [/go1]\n // },\n // b = {\n // group = hash: [default],\n // position = vmath.vector3(185, 704.05865478516, 0),\n // id = hash: [/go2]\n // }\n // }\n } else if (event === hash(\"trigger_event\")) {\n pprint(event);\n // {\n // enter = true,\n // b = {\n // group = hash: [default],\n // id = hash: [/go2]\n // },\n // a = {\n // group = hash: [default],\n // id = hash: [/go1]\n // }\n // },\n } else if (event === hash(\"ray_cast_response\")) {\n pprint(event);\n // {\n // group = hash: [default],\n // request_id = 0,\n // position = vmath.vector3(249.92222595215, 249.92222595215, 0),\n // fraction = 0.68759721517563,\n // normal = vmath.vector3(0, 1, 0),\n // id = hash: [/go]\n // }\n } else if (event === hash(\"ray_cast_missed\")) {\n pprint(event);\n // {\n // request_id = 0\n // },\n }\n }\n}\n\nexport default defineScript({\n init(self) {\n physics.set_event_listener(physics_world_listener);\n },\n});"
935
+ "ts": "function physics_world_listener(self: unknown, events: unknown) {\n for (const event of events as Record<string, unknown>[]) {\n const event_type = event[\"type\"];\n if (event_type === hash(\"contact_point_event\")) {\n pprint(event);\n // {\n // distance = 2.1490633487701,\n // applied_impulse = 0\n // a = { --[[0x113f7c6c0]]\n // group = hash: [box],\n // id = hash: [/box]\n // mass = 0,\n // normal = vmath.vector3(0.379, 0.925, -0),\n // position = vmath.vector3(517.337, 235.068, 0),\n // instance_position = vmath.vector3(480, 144, 0),\n // relative_velocity = vmath.vector3(-0, -0, -0),\n // },\n // b = { --[[0x113f7c840]]\n // group = hash: [circle],\n // id = hash: [/circle]\n // mass = 0,\n // normal = vmath.vector3(-0.379, -0.925, 0),\n // position = vmath.vector3(517.337, 235.068, 0),\n // instance_position = vmath.vector3(-0.0021, 0, -0.0022),\n // relative_velocity = vmath.vector3(0, 0, 0),\n // },\n // }\n } else if (event_type === hash(\"collision_event\")) {\n pprint(event);\n // {\n // a = {\n // group = hash: [default],\n // position = vmath.vector3(183, 666, 0),\n // id = hash: [/go1]\n // },\n // b = {\n // group = hash: [default],\n // position = vmath.vector3(185, 704.05865478516, 0),\n // id = hash: [/go2]\n // }\n // }\n } else if (event_type === hash(\"trigger_event\")) {\n pprint(event);\n // {\n // enter = true,\n // b = {\n // group = hash: [default],\n // id = hash: [/go2]\n // },\n // a = {\n // group = hash: [default],\n // id = hash: [/go1]\n // }\n // },\n } else if (event_type === hash(\"ray_cast_response\")) {\n pprint(event);\n // {\n // group = hash: [default],\n // request_id = 0,\n // position = vmath.vector3(249.92222595215, 249.92222595215, 0),\n // fraction = 0.68759721517563,\n // normal = vmath.vector3(0, 1, 0),\n // id = hash: [/go]\n // }\n } else if (event_type === hash(\"ray_cast_missed\")) {\n pprint(event);\n // {\n // request_id = 0\n // },\n }\n }\n}\n\nexport default defineScript({\n init(self) {\n physics.set_event_listener(physics_world_listener);\n },\n});"
836
936
  }
837
937
  ],
838
938
  "physics.set_gravity": [
@@ -886,7 +986,7 @@
886
986
  "profiler.log_text": [
887
987
  {
888
988
  "sourceHash": "86c7e0a666f0147e",
889
- "ts": "profiler.log_text(`Event: ${name}`);"
989
+ "ts": "const name = \"my_event\";\nprofiler.log_text(`Event: ${name}`);"
890
990
  }
891
991
  ],
892
992
  "profiler.recorded_frame_count": [
@@ -898,7 +998,7 @@
898
998
  "profiler.scope_begin": [
899
999
  {
900
1000
  "sourceHash": "fa297bd541df8930",
901
- "ts": "// Go back one frame\nprofiler.scope_begin(\"test_function\");\ntest_function();\nprofiler.scope_end();"
1001
+ "ts": "function test_function() {\n // the work being measured\n}\n\n// Go back one frame\nprofiler.scope_begin(\"test_function\");\ntest_function();\nprofiler.scope_end();"
902
1002
  }
903
1003
  ],
904
1004
  "profiler.set_ui_mode": [
@@ -934,67 +1034,75 @@
934
1034
  "render.constant_buffer": [
935
1035
  {
936
1036
  "sourceHash": "851cc71b74ec904a",
937
- "ts": "// Set a \"tint\" constant in a constant buffer in the render script:\nconst constants = render.constant_buffer();\nconstants.tint = vmath.vector4(1, 1, 1, 1);\n\n// Then use the constant buffer when drawing a predicate:\nrender.draw(self.my_pred, { constants });\n\n// The constant buffer also supports array values by specifying constants in an array:\nconst constants2 = render.constant_buffer();\nconstants2.light_colors = [];\nconstants2.light_colors[0] = vmath.vector4(1, 0, 0, 1);\nconstants2.light_colors[1] = vmath.vector4(0, 1, 0, 1);\nconstants2.light_colors[2] = vmath.vector4(0, 0, 1, 1);\n\n// You can also create the array by passing the vectors directly:\nconst constants3 = render.constant_buffer();\nconstants3.light_colors = [\n vmath.vector4(1, 0, 0, 1),\n vmath.vector4(0, 1, 0, 1),\n vmath.vector4(0, 0, 1, 1),\n];\n\n// Add more constants to the array\nconstants3.light_colors[3] = vmath.vector4(1, 1, 1, 1);"
1037
+ "ts": "export default defineRenderScript({\n init() {\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n // Set a \"tint\" constant in a constant buffer in the render script:\n const constants = render.constant_buffer();\n constants.tint = vmath.vector4(1, 1, 1, 1);\n\n // Then use the constant buffer when drawing a predicate:\n render.draw(self.my_pred, { constants });\n\n // The constant buffer also supports array values by specifying constants in an array:\n const constants2 = render.constant_buffer();\n constants2.light_colors = [];\n constants2.light_colors[0] = vmath.vector4(1, 0, 0, 1);\n constants2.light_colors[1] = vmath.vector4(0, 1, 0, 1);\n constants2.light_colors[2] = vmath.vector4(0, 0, 1, 1);\n\n // You can also create the array by passing the vectors directly:\n const constants3 = render.constant_buffer();\n constants3.light_colors = [\n vmath.vector4(1, 0, 0, 1),\n vmath.vector4(0, 1, 0, 1),\n vmath.vector4(0, 0, 1, 1),\n ];\n\n // Add more constants to the array\n constants3.light_colors[3] = vmath.vector4(1, 1, 1, 1);\n },\n});"
938
1038
  }
939
1039
  ],
940
1040
  "render.delete_render_target": [
941
1041
  {
942
1042
  "sourceHash": "e535502af5d49877",
943
- "ts": "// How to delete a render target:\nrender.delete_render_target(self.my_render_target);"
1043
+ "ts": "export default defineRenderScript({\n init() {\n return { my_render_target: render.render_target(\"my_target\", {}) };\n },\n\n final(self) {\n // How to delete a render target:\n render.delete_render_target(self.my_render_target);\n },\n});"
944
1044
  }
945
1045
  ],
946
1046
  "render.disable_material": [
947
1047
  {
948
1048
  "sourceHash": "256ae7b73905f4b2",
949
- "ts": "// Enable material named \"glow\", then draw my_pred with it.\nrender.enable_material(\"glow\");\nrender.draw(self.my_pred);\nrender.disable_material();"
1049
+ "ts": "export default defineRenderScript({\n init() {\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n // Enable material named \"glow\", then draw my_pred with it.\n render.enable_material(\"glow\");\n render.draw(self.my_pred);\n render.disable_material();\n },\n});"
950
1050
  }
951
1051
  ],
952
1052
  "render.disable_state": [
953
1053
  {
954
1054
  "sourceHash": "9ec916d3d474ace5",
955
- "ts": "// Disable face culling when drawing the tile predicate:\nrender.disable_state(graphics.STATE_CULL_FACE);\nrender.draw(self.tile_pred);"
1055
+ "ts": "export default defineRenderScript({\n init() {\n return { tile_pred: render.predicate([hash(\"tile\")]) };\n },\n\n update(self, dt) {\n // Disable face culling when drawing the tile predicate:\n render.disable_state(graphics.STATE_CULL_FACE);\n render.draw(self.tile_pred);\n },\n});"
956
1056
  }
957
1057
  ],
958
1058
  "render.disable_texture": [
959
1059
  {
960
1060
  "sourceHash": "77eefc5b608dd2e6",
961
- "ts": "export default defineScript({\n update(self, dt) {\n render.enable_texture(0, self.my_render_target, 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 // done, disable the texture\n render.disable_texture(0);\n },\n});"
1061
+ "ts": "export default defineRenderScript({\n update(self, dt) {\n render.enable_texture(0, self.my_render_target, 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 // done, disable the texture\n render.disable_texture(0);\n },\n});"
962
1062
  }
963
1063
  ],
964
1064
  "render.dispatch_compute": [
965
1065
  {
966
1066
  "sourceHash": "af76607a05354da7",
967
- "ts": "export default defineScript({\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 scene_rt: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),\n };\n },\n\n update(self, dt) {\n render.set_compute(\"bloom\");\n render.enable_texture(0, self.backing_texture);\n render.enable_texture(1, self.scene_rt);\n render.dispatch_compute(128, 128, 1);\n render.set_compute();\n },\n});\n\n// Dispatch a compute program with a constant buffer:\nconst constants = render.constant_buffer();\nconstants.tint = vmath.vector4(1, 1, 1, 1);\nrender.dispatch_compute(32, 32, 32, { constants });"
1067
+ "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 scene_rt: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),\n };\n },\n\n update(self, dt) {\n render.set_compute(\"bloom\");\n render.enable_texture(0, self.backing_texture);\n render.enable_texture(1, self.scene_rt);\n render.dispatch_compute(128, 128, 1);\n render.set_compute();\n },\n});\n\n// Dispatch a compute program with a constant buffer:\nconst constants = render.constant_buffer();\nconstants.tint = vmath.vector4(1, 1, 1, 1);\nrender.dispatch_compute(32, 32, 32, { constants });"
968
1068
  }
969
1069
  ],
970
1070
  "render.draw": [
971
1071
  {
972
1072
  "sourceHash": "47232b75e7b74189",
973
- "ts": "export default defineScript({\n init() {\n // define a predicate matching anything with material tag \"my_tag\"\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n // draw everything in the my_pred predicate\n render.draw(self.my_pred);\n },\n});\n\n// Draw predicate with constants:\nconst constants = render.constant_buffer();\nconstants.tint = vmath.vector4(1, 1, 1, 1);\nrender.draw(self.my_pred, { constants });\n\n// Draw with predicate and frustum culling (without near+far planes):\nconst frustum = self.proj.mul(self.view);\nrender.draw(self.my_pred, { frustum });\n\n// Draw with predicate and frustum culling (with near+far planes):\nconst frustum2 = self.proj.mul(self.view);\nrender.draw(self.my_pred, { frustum: frustum2, frustum_planes: render.FRUSTUM_PLANES_ALL });"
1073
+ "ts": "export default defineRenderScript({\n init() {\n // define a predicate matching anything with material tag \"my_tag\"\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n // draw everything in the my_pred predicate\n render.draw(self.my_pred);\n\n // Draw predicate with constants:\n const constants = render.constant_buffer();\n constants.tint = vmath.vector4(1, 1, 1, 1);\n render.draw(self.my_pred, { constants });\n\n // Draw with predicate and frustum culling (without near+far planes):\n const frustum = self.proj.mul(self.view);\n render.draw(self.my_pred, { frustum });\n\n // Draw with predicate and frustum culling (with near+far planes):\n const frustum2 = self.proj.mul(self.view);\n render.draw(self.my_pred, { frustum: frustum2, frustum_planes: render.FRUSTUM_PLANES_ALL });\n },\n});"
974
1074
  }
975
1075
  ],
976
1076
  "render.draw_debug3d": [
977
1077
  {
978
1078
  "sourceHash": "b200f780e2bf16f3",
979
- "ts": "export default defineScript({\n update(self, dt) {\n // draw debug visualization\n render.draw_debug3d();\n },\n});"
1079
+ "ts": "export default defineRenderScript({\n update(self, dt) {\n // draw debug visualization\n render.draw_debug3d();\n },\n});"
980
1080
  }
981
1081
  ],
982
1082
  "render.enable_material": [
983
1083
  {
984
1084
  "sourceHash": "256ae7b73905f4b2",
985
- "ts": "// Enable material named \"glow\", then draw my_pred with it.\nrender.enable_material(\"glow\");\nrender.draw(self.my_pred);\nrender.disable_material();"
1085
+ "ts": "export default defineRenderScript({\n init() {\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n // Enable material named \"glow\", then draw my_pred with it.\n render.enable_material(\"glow\");\n render.draw(self.my_pred);\n render.disable_material();\n },\n});"
986
1086
  }
987
1087
  ],
988
1088
  "render.enable_state": [
989
1089
  {
990
1090
  "sourceHash": "d08dd567d90c4036",
991
- "ts": "// Enable stencil test when drawing the gui predicate, then disable it:\nrender.enable_state(graphics.STATE_STENCIL_TEST);\nrender.draw(self.gui_pred);\nrender.disable_state(graphics.STATE_STENCIL_TEST);"
1091
+ "ts": "export default defineRenderScript({\n init() {\n return { gui_pred: render.predicate([hash(\"gui\")]) };\n },\n\n update(self, dt) {\n // Enable stencil test when drawing the gui predicate, then disable it:\n render.enable_state(graphics.STATE_STENCIL_TEST);\n render.draw(self.gui_pred);\n render.disable_state(graphics.STATE_STENCIL_TEST);\n },\n});"
992
1092
  }
993
1093
  ],
994
1094
  "render.enable_texture": [
995
1095
  {
996
- "sourceHash": "4dd1d2618c062e70",
997
- "ts": "export default defineScript({\n update(self, dt) {\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 // disable target\n render.set_render_target(render.RENDER_TARGET_DEFAULT);\n\n render.enable_texture(0, self.my_render_target, 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});\n\n// Or enable a render target by resource id:\nexport default defineScript({\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});\n\n// Or bind a texture handle directly:\nexport default defineScript({\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});"
1096
+ "sourceHash": "410c8dd98e44842a",
1097
+ "ts": "export default defineRenderScript({\n update(self, dt) {\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 // disable target\n render.set_render_target(render.RENDER_TARGET_DEFAULT);\n\n render.enable_texture(0, self.my_render_target, 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});"
1098
+ },
1099
+ {
1100
+ "sourceHash": "dc0ea083dbea5fe1",
1101
+ "ts": "// Or enable a render target by resource id:\nexport default defineRenderScript({\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});"
1102
+ },
1103
+ {
1104
+ "sourceHash": "49503c29f0de95f3",
1105
+ "ts": "// Or bind a texture handle directly:\nexport default defineRenderScript({\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});"
998
1106
  }
999
1107
  ],
1000
1108
  "render.get_height": [
@@ -1006,13 +1114,13 @@
1006
1114
  "render.get_render_target_height": [
1007
1115
  {
1008
1116
  "sourceHash": "f509a9b954573583",
1009
- "ts": "// get the height of the render target color buffer\nconst h = render.get_render_target_height(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);\n// get the height of a render target resource\nconst w = render.get_render_target_height(\"my_rt_resource\", graphics.BUFFER_TYPE_COLOR0_BIT);"
1117
+ "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});"
1010
1118
  }
1011
1119
  ],
1012
1120
  "render.get_render_target_width": [
1013
1121
  {
1014
1122
  "sourceHash": "25c6d828a4ae3706",
1015
- "ts": "// get the width of the render target color buffer\nconst w = render.get_render_target_width(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);\n// get the width of a render target resource\nconst w2 = render.get_render_target_width(\"my_rt_resource\", graphics.BUFFER_TYPE_COLOR0_BIT);"
1123
+ "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});"
1016
1124
  }
1017
1125
  ],
1018
1126
  "render.get_width": [
@@ -1041,12 +1149,16 @@
1041
1149
  ],
1042
1150
  "render.render_target": [
1043
1151
  {
1044
- "sourceHash": "608b59338c18571b",
1045
- "ts": "// How to create a new render target and draw to it:\nexport default defineScript({\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 const depth_params = {\n format: graphics.TEXTURE_FORMAT_DEPTH,\n width: render.get_window_width(),\n height: render.get_window_height(),\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n return {\n my_render_target: render.render_target({\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,\n [graphics.BUFFER_TYPE_DEPTH_BIT]: depth_params,\n }),\n };\n },\n\n update(self, dt) {\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});\n\n// How to create a render target with multiple outputs:\nexport default defineScript({\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 // 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 [graphics.BUFFER_TYPE_COLOR1_BIT]: color_params_rgba,\n [graphics.BUFFER_TYPE_COLOR2_BIT]: color_params_float,\n }),\n };\n },\n\n update(self, dt) {\n // enable target so all drawing is done to it\n render.enable_render_target(self.my_render_target);\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n },\n});"
1152
+ "sourceHash": "0c72f5142a3a57da",
1153
+ "ts": "// How to create a new render target and draw to it:\nexport 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 const depth_params = {\n format: graphics.TEXTURE_FORMAT_DEPTH,\n width: render.get_window_width(),\n height: render.get_window_height(),\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n return {\n my_render_target: render.render_target({\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,\n [graphics.BUFFER_TYPE_DEPTH_BIT]: depth_params,\n }),\n };\n },\n\n update(self, dt) {\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});"
1154
+ },
1155
+ {
1156
+ "sourceHash": "271ca31f05e103b5",
1157
+ "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 // 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 [graphics.BUFFER_TYPE_COLOR1_BIT]: color_params_rgba,\n [graphics.BUFFER_TYPE_COLOR2_BIT]: color_params_float,\n }),\n };\n },\n\n update(self, dt) {\n // enable target so all drawing is done to it\n render.enable_render_target(self.my_render_target);\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n },\n});"
1046
1158
  },
1047
1159
  {
1048
- "sourceHash": "766fbfcc7bc21b4b",
1049
- "ts": "// How to create a new render target and draw to it:\nexport default defineScript({\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 const depth_params = {\n format: graphics.TEXTURE_FORMAT_DEPTH,\n width: render.get_window_width(),\n height: render.get_window_height(),\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n return {\n my_render_target: render.render_target({\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,\n [graphics.BUFFER_TYPE_DEPTH_BIT]: depth_params,\n }),\n };\n },\n\n update(self, dt) {\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});\n\n// How to create a render target with multiple outputs:\nexport default defineScript({\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 // 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 [graphics.BUFFER_TYPE_COLOR1_BIT]: color_params_rgba,\n [graphics.BUFFER_TYPE_COLOR2_BIT]: color_params_float,\n }),\n };\n },\n\n update(self, dt) {\n // enable target so all drawing is done to it\n render.enable_render_target(self.my_render_target);\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n },\n});"
1160
+ "sourceHash": "e39f13af5d65d01d",
1161
+ "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 // 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 [graphics.BUFFER_TYPE_COLOR1_BIT]: color_params_rgba,\n [graphics.BUFFER_TYPE_COLOR2_BIT]: color_params_float,\n }),\n };\n },\n\n update(self, dt) {\n // enable target so all drawing is done to it\n render.enable_render_target(self.my_render_target);\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n },\n});"
1050
1162
  }
1051
1163
  ],
1052
1164
  "render.set_blend_equation_separate": [
@@ -1070,7 +1182,7 @@
1070
1182
  "render.set_camera": [
1071
1183
  {
1072
1184
  "sourceHash": "6ee012d07a0487a6",
1073
- "ts": "// Set the current camera to be used for rendering\nrender.set_camera(\"main:/my_go#camera\");\nrender.draw(self.my_pred);\nrender.set_camera(undefined);\n\n// Use the camera frustum for frustum culling together with a specific frustum plane option for the draw command\n// The camera frustum will take precedence over the frustum plane option in render.draw\nrender.set_camera(\"main:/my_go#camera\", { use_frustum: true });\n// However, we can still customize the frustum planes regardless of the camera option!\nrender.draw(self.my_pred, { frustum_planes: render.FRUSTUM_PLANES_ALL });\nrender.set_camera();"
1185
+ "ts": "export default defineRenderScript({\n init() {\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n // Set the current camera to be used for rendering\n render.set_camera(\"main:/my_go#camera\");\n render.draw(self.my_pred);\n render.set_camera(undefined);\n\n // Use the camera frustum for frustum culling together with a specific frustum plane option for the draw command\n // The camera frustum will take precedence over the frustum plane option in render.draw\n render.set_camera(\"main:/my_go#camera\", { use_frustum: true });\n // However, we can still customize the frustum planes regardless of the camera option!\n render.draw(self.my_pred, { frustum_planes: render.FRUSTUM_PLANES_ALL });\n render.set_camera();\n },\n});"
1074
1186
  }
1075
1187
  ],
1076
1188
  "render.set_color_mask": [
@@ -1082,7 +1194,7 @@
1082
1194
  "render.set_compute": [
1083
1195
  {
1084
1196
  "sourceHash": "5e76b88c05d9f3f7",
1085
- "ts": "// Enable compute program named \"fractals\", then dispatch it.\nrender.set_compute(\"fractals\");\nrender.enable_texture(0, self.backing_texture);\nrender.dispatch_compute(128, 128, 1);\nrender.set_compute();"
1197
+ "ts": "export default defineRenderScript({\n init() {\n return { backing_texture: \"my_texture_resource\" };\n },\n\n update(self, dt) {\n // Enable compute program named \"fractals\", then dispatch it.\n render.set_compute(\"fractals\");\n render.enable_texture(0, self.backing_texture);\n render.dispatch_compute(128, 128, 1);\n render.set_compute();\n },\n});"
1086
1198
  }
1087
1199
  ],
1088
1200
  "render.set_cull_face": [
@@ -1106,7 +1218,7 @@
1106
1218
  "render.set_listener": [
1107
1219
  {
1108
1220
  "sourceHash": "6fc340897eeb1ab9",
1109
- "ts": "// Set listener and handle render context events.\n// custom.render_script\nexport default defineScript({\n init() {\n render.set_listener((self, event_type) => {\n if (event_type === render.CONTEXT_EVENT_CONTEXT_LOST) {\n // Some stuff when rendering context is lost\n } else if (event_type === render.CONTEXT_EVENT_CONTEXT_RESTORED) {\n // Start reload resources, reload game, etc.\n }\n });\n },\n});"
1221
+ "ts": "// Set listener and handle render context events.\n// custom.render_script\nexport default defineRenderScript({\n init() {\n render.set_listener((self, event_type) => {\n if (event_type === render.CONTEXT_EVENT_CONTEXT_LOST) {\n // Some stuff when rendering context is lost\n } else if (event_type === render.CONTEXT_EVENT_CONTEXT_RESTORED) {\n // Start reload resources, reload game, etc.\n }\n });\n },\n});"
1110
1222
  }
1111
1223
  ],
1112
1224
  "render.set_polygon_offset": [
@@ -1123,14 +1235,18 @@
1123
1235
  ],
1124
1236
  "render.set_render_target": [
1125
1237
  {
1126
- "sourceHash": "b30691f486beb1fa",
1127
- "ts": "// How to set a render target and draw to it and then switch back to the default render target\n// 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\nexport default defineScript({\n update(self, dt) {\n // set render target so all drawing is done to it\n render.set_render_target(self.my_render_target, {\n transient: [graphics.BUFFER_TYPE_DEPTH_BIT, graphics.BUFFER_TYPE_STENCIL_BIT],\n });\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n\n // set default render target. This also invalidates the depth and stencil buffers of the current target (self.my_render_target)\n // which can be an optimisation on some hardware\n render.set_render_target(render.RENDER_TARGET_DEFAULT);\n },\n});\n\n// Or set the render target by a render target resource identifier:\nexport default defineScript({\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});"
1238
+ "sourceHash": "c6e25f5038d19bee",
1239
+ "ts": "// How to set a render target and draw to it and then switch back to the default render target\n// 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\nexport default defineRenderScript({\n update(self, dt) {\n // set render target so all drawing is done to it\n render.set_render_target(self.my_render_target, {\n transient: [graphics.BUFFER_TYPE_DEPTH_BIT, graphics.BUFFER_TYPE_STENCIL_BIT],\n });\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n\n // set default render target. This also invalidates the depth and stencil buffers of the current target (self.my_render_target)\n // which can be an optimisation on some hardware\n render.set_render_target(render.RENDER_TARGET_DEFAULT);\n },\n});"
1240
+ },
1241
+ {
1242
+ "sourceHash": "bb08db5e232c5b5e",
1243
+ "ts": "// Or set the render target by a render target resource identifier:\nexport default defineRenderScript({\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});"
1128
1244
  }
1129
1245
  ],
1130
1246
  "render.set_render_target_size": [
1131
1247
  {
1132
1248
  "sourceHash": "00274352e6327274",
1133
- "ts": "// Resize render targets to the current window size:\nrender.set_render_target_size(self.my_render_target, render.get_window_width(), render.get_window_height());\nrender.set_render_target_size(\"my_rt_resource\", render.get_window_width(), render.get_window_height());"
1249
+ "ts": "export default defineRenderScript({\n init() {\n return { my_render_target: render.render_target(\"my_target\", {}) };\n },\n\n update(self, dt) {\n // Resize render targets to the current window size:\n render.set_render_target_size(self.my_render_target, render.get_window_width(), render.get_window_height());\n render.set_render_target_size(\"my_rt_resource\", render.get_window_width(), render.get_window_height());\n },\n});"
1134
1250
  }
1135
1251
  ],
1136
1252
  "render.set_stencil_func": [
@@ -1154,7 +1270,7 @@
1154
1270
  "render.set_view": [
1155
1271
  {
1156
1272
  "sourceHash": "7a30b4955abb3844",
1157
- "ts": "// How to set the view and projection matrices according to\n// the values supplied by a camera.\nexport default defineScript({\n init() {\n return {\n view: vmath.matrix4(),\n projection: vmath.matrix4(),\n };\n },\n\n update(self, dt) {\n // set the view to the stored view value\n render.set_view(self.view);\n // now we can draw with this view\n },\n\n on_message(self, message_id, message) {\n if (message_id === hash(\"set_view_projection\")) {\n // camera view and projection arrives here.\n self.view = message.view;\n self.projection = message.projection;\n }\n },\n});"
1273
+ "ts": "// How to set the view and projection matrices according to\n// the values supplied by a camera.\nexport default defineRenderScript({\n init() {\n return {\n view: vmath.matrix4(),\n projection: vmath.matrix4(),\n };\n },\n\n update(self, dt) {\n // set the view to the stored view value\n render.set_view(self.view);\n // now we can draw with this view\n },\n\n on_message(self, message_id, message) {\n if (message_id === hash(\"set_view_projection\")) {\n // camera view and projection arrives here.\n self.view = message.view;\n self.projection = message.projection;\n }\n },\n});"
1158
1274
  }
1159
1275
  ],
1160
1276
  "render.set_viewport": [
@@ -1165,8 +1281,12 @@
1165
1281
  ],
1166
1282
  "resource.atlas": [
1167
1283
  {
1168
- "sourceHash": "ee6a5c4c09121554",
1169
- "ts": "// Load an atlas and set it to a sprite:\ngo.property(\"my_atlas\", resource.atlas(\"/atlas.atlas\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#sprite\", \"image\", self.my_atlas);\n },\n});\n\n// Load an atlas and set it to a gui:\ngo.property(\"my_atlas\", resource.atlas(\"/atlas.atlas\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#gui\", \"textures\", self.my_atlas, { key: \"my_atlas\" });\n },\n});"
1284
+ "sourceHash": "10e8e4948751ccc8",
1285
+ "ts": "// Load an atlas and set it to a sprite:\ngo.property(\"my_atlas\", resource.atlas(\"/atlas.atlas\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#sprite\", \"image\", self.my_atlas);\n },\n});"
1286
+ },
1287
+ {
1288
+ "sourceHash": "46638db8e246e1ed",
1289
+ "ts": "// Load an atlas and set it to a gui:\ngo.property(\"my_atlas\", resource.atlas(\"/atlas.atlas\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#gui\", \"textures\", self.my_atlas, { key: \"my_atlas\" });\n },\n});"
1170
1290
  }
1171
1291
  ],
1172
1292
  "resource.buffer": [
@@ -1183,8 +1303,12 @@
1183
1303
  ],
1184
1304
  "resource.create_buffer": [
1185
1305
  {
1186
- "sourceHash": "436c1c10688cba69",
1187
- "ts": "// Create a buffer object and bind it to a buffer resource\nexport default defineScript({\n init() {\n const size = 1;\n const positions = [\n // triangle 1\n size, size, 0,\n -size, -size, 0,\n size, -size, 0,\n // triangle 2\n size, size, 0,\n -size, size, 0,\n -size, -size, 0,\n ];\n\n const buffer_handle = buffer.create(positions.length, [\n {\n name: hash(\"position\"),\n type: buffer.VALUE_TYPE_FLOAT32,\n count: 3,\n },\n ]);\n\n const stream = buffer.get_stream(buffer_handle, hash(\"position\"));\n\n // transfer vertex data to buffer\n for (let k = 0; k < positions.length; k++) {\n stream[k] = positions[k];\n }\n\n const my_buffer = resource.create_buffer(\"/my_buffer.bufferc\", { buffer: buffer_handle });\n go.set(\"/go#mesh\", \"vertices\", my_buffer);\n },\n});\n\n// Create a buffer resource from existing resource\nexport default defineScript({\n init() {\n const res = resource.get_buffer(\"/my_buffer_path.bufferc\");\n // create a cloned buffer resource from another resource buffer\n const buf = resource.create_buffer(\"/my_cloned_buffer.bufferc\", { buffer: res });\n // assign cloned buffer to a mesh component\n go.set(\"/go#mesh\", \"vertices\", buf);\n },\n});"
1306
+ "sourceHash": "a4804ebe744d930a",
1307
+ "ts": "// Create a buffer object and bind it to a buffer resource\nexport default defineScript({\n init() {\n const size = 1;\n const positions = [\n // triangle 1\n size, size, 0,\n -size, -size, 0,\n size, -size, 0,\n // triangle 2\n size, size, 0,\n -size, size, 0,\n -size, -size, 0,\n ];\n\n const buffer_handle = buffer.create(positions.length, [\n {\n name: hash(\"position\"),\n type: buffer.VALUE_TYPE_FLOAT32,\n count: 3,\n },\n ]);\n\n const stream = buffer.get_stream(buffer_handle, hash(\"position\"));\n\n // transfer vertex data to buffer\n for (let k = 0; k < positions.length; k++) {\n stream[k] = positions[k];\n }\n\n const my_buffer = resource.create_buffer(\"/my_buffer.bufferc\", { buffer: buffer_handle });\n go.set(\"/go#mesh\", \"vertices\", my_buffer);\n },\n});"
1308
+ },
1309
+ {
1310
+ "sourceHash": "eef45bf7aae2047d",
1311
+ "ts": "// Create a buffer resource from existing resource\nexport default defineScript({\n init() {\n const res = resource.get_buffer(\"/my_buffer_path.bufferc\");\n // create a cloned buffer resource from another resource buffer\n const buf = resource.create_buffer(\"/my_cloned_buffer.bufferc\", { buffer: res });\n // assign cloned buffer to a mesh component\n go.set(\"/go#mesh\", \"vertices\", buf);\n },\n});"
1188
1312
  }
1189
1313
  ],
1190
1314
  "resource.create_sound_data": [
@@ -1195,24 +1319,44 @@
1195
1319
  ],
1196
1320
  "resource.create_texture": [
1197
1321
  {
1198
- "sourceHash": "f510168083ffdd30",
1199
- "ts": "// How to create an 128x128 RGBA texture resource and assign it to a model\nexport default defineScript({\n init() {\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA,\n };\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams);\n go.set(\"#model\", \"texture0\", my_texture_id);\n },\n});\n\n// How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object\nexport default defineScript({\n init() {\n // Create a new buffer with 4 components and FLOAT32 type\n const tbuffer = buffer.create(128 * 128, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < 128; y++) {\n for (let x = 0; x < 128; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 999.0;\n tstream[index + 1] = -1.0;\n tstream[index + 2] = 0.5;\n tstream[index + 3] = 1.0;\n }\n }\n\n // Create a 2D Texture with a RGBA23F format\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA32F,\n };\n\n // Note that we pass the buffer as the last argument here!\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams, tbuffer);\n\n // assign the texture to a model\n go.set(\"#model\", \"texture0\", my_texture_id);\n },\n});\n\n// How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader\nexport default defineScript({\n init() {\n const t_volume = resource.create_texture(\"/my_backing_texture.texturec\", {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 32,\n height: 32,\n depth: 32,\n format: resource.TEXTURE_FORMAT_RGBA32F,\n flags: resource.TEXTURE_USAGE_FLAG_STORAGE + resource.TEXTURE_USAGE_FLAG_SAMPLE,\n });\n\n // pass the backing texture to the render script\n msg.post(\"@render:\", \"add_textures\", [t_volume]);\n },\n});\n\n// How to create 512x512 texture array with 5 pages.\nconst new_tex = resource.create_texture(\"/runtime/example_array.texturec\", {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: 512,\n height: 512,\n page_count: 5,\n format: graphics.TEXTURE_FORMAT_RGB,\n});"
1322
+ "sourceHash": "717b1b10958e5fa2",
1323
+ "ts": "// How to create an 128x128 RGBA texture resource and assign it to a model\nexport default defineScript({\n init() {\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA,\n };\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams);\n go.set(\"#model\", \"texture0\", my_texture_id);\n },\n});"
1324
+ },
1325
+ {
1326
+ "sourceHash": "71bd6ae180eb83d6",
1327
+ "ts": "// How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object\nexport default defineScript({\n init() {\n // Create a new buffer with 4 components and FLOAT32 type\n const tbuffer = buffer.create(128 * 128, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < 128; y++) {\n for (let x = 0; x < 128; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 999.0;\n tstream[index + 1] = -1.0;\n tstream[index + 2] = 0.5;\n tstream[index + 3] = 1.0;\n }\n }\n\n // Create a 2D Texture with a RGBA23F format\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA32F,\n };\n\n // Note that we pass the buffer as the last argument here!\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams, tbuffer);\n\n // assign the texture to a model\n go.set(\"#model\", \"texture0\", my_texture_id);\n },\n});"
1328
+ },
1329
+ {
1330
+ "sourceHash": "be4f6e903c862a52",
1331
+ "ts": "// How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader\nexport default defineScript({\n init() {\n const t_volume = resource.create_texture(\"/my_backing_texture.texturec\", {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 32,\n height: 32,\n depth: 32,\n format: resource.TEXTURE_FORMAT_RGBA32F,\n flags: resource.TEXTURE_USAGE_FLAG_STORAGE + resource.TEXTURE_USAGE_FLAG_SAMPLE,\n });\n\n // pass the backing texture to the render script\n msg.post(\"@render:\", \"add_textures\", [t_volume]);\n },\n});"
1200
1332
  },
1201
1333
  {
1202
- "sourceHash": "41e0481ae55c393d",
1203
- "ts": "// How to create an 128x128 RGBA texture resource and assign it to a model\nexport default defineScript({\n init() {\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA,\n };\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams);\n go.set(\"#model\", \"texture0\", my_texture_id);\n },\n});\n\n// How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object\nexport default defineScript({\n init() {\n // Create a new buffer with 4 components and FLOAT32 type\n const tbuffer = buffer.create(128 * 128, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < 128; y++) {\n for (let x = 0; x < 128; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 999.0;\n tstream[index + 1] = -1.0;\n tstream[index + 2] = 0.5;\n tstream[index + 3] = 1.0;\n }\n }\n\n // Create a 2D Texture with a RGBA23F format\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA32F,\n };\n\n // Note that we pass the buffer as the last argument here!\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams, tbuffer);\n\n // assign the texture to a model\n go.set(\"#model\", \"texture0\", my_texture_id);\n },\n});\n\n// How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader\nexport default defineScript({\n init() {\n const t_volume = resource.create_texture(\"/my_backing_texture.texturec\", {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 32,\n height: 32,\n depth: 32,\n format: resource.TEXTURE_FORMAT_RGBA32F,\n flags: resource.TEXTURE_USAGE_FLAG_STORAGE + resource.TEXTURE_USAGE_FLAG_SAMPLE,\n });\n\n // pass the backing texture to the render script\n msg.post(\"@render:\", \"add_textures\", [t_volume]);\n },\n});\n\n// How to create 512x512 texture array with 5 pages.\nconst new_tex = resource.create_texture(\"/runtime/example_array.texturec\", {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: 512,\n height: 512,\n page_count: 5,\n format: graphics.TEXTURE_FORMAT_RGB,\n});"
1334
+ "sourceHash": "b1535ccf9e09d259",
1335
+ "ts": "// How to create 512x512 texture array with 5 pages.\nconst new_tex = resource.create_texture(\"/runtime/example_array.texturec\", {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: 512,\n height: 512,\n page_count: 5,\n format: graphics.TEXTURE_FORMAT_RGB,\n});"
1336
+ },
1337
+ {
1338
+ "sourceHash": "54a85cf9f38f2521",
1339
+ "ts": "// How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader\nexport default defineScript({\n init() {\n const t_volume = resource.create_texture(\"/my_backing_texture.texturec\", {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 32,\n height: 32,\n depth: 32,\n format: resource.TEXTURE_FORMAT_RGBA32F,\n flags: resource.TEXTURE_USAGE_FLAG_STORAGE + resource.TEXTURE_USAGE_FLAG_SAMPLE,\n });\n\n // pass the backing texture to the render script\n msg.post(\"@render:\", \"add_textures\", [t_volume]);\n },\n});"
1204
1340
  }
1205
1341
  ],
1206
1342
  "resource.create_texture_async": [
1207
1343
  {
1208
- "sourceHash": "b90223f19d598eaa",
1209
- "ts": "// Create a texture resource asyncronously with a buffer and a callback\nfunction callback(self, request_id, resource) {\n // The resource has been updated with a new texture,\n // so we can update other systems with the new handle,\n // or update components to use the resource if we want\n const tinfo = resource.get_texture_info(resource);\n msg.post(\"@render:\", \"set_backing_texture\", tinfo.handle);\n}\n\nexport default defineScript({\n init() {\n // Create a texture resource async\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA,\n };\n\n // Create a new buffer with 4 components\n const tbuffer = buffer.create(tparams.width * tparams.height, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_UINT8, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < tparams.width; y++) {\n for (let x = 0; x < tparams.height; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 255;\n tstream[index + 1] = 0;\n tstream[index + 2] = 255;\n tstream[index + 3] = 255;\n }\n }\n // create the texture\n const [tpath, request_id] = resource.create_texture_async(\"/my_texture.texturec\", tparams, tbuffer, callback);\n // at this point you can use the resource as-is, but note that the texture will be a blank 1x1 texture\n // that will be removed once the new texture has been updated\n go.set(\"#model\", \"texture0\", tpath);\n },\n});\n\n// Create a texture resource asyncronously without a callback\nexport default defineScript({\n init() {\n // Create a texture resource async\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA,\n };\n\n // Create a new buffer with 4 components\n const tbuffer = buffer.create(tparams.width * tparams.height, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_UINT8, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < tparams.width; y++) {\n for (let x = 0; x < tparams.height; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 255;\n tstream[index + 1] = 0;\n tstream[index + 2] = 255;\n tstream[index + 3] = 255;\n }\n }\n // create the texture\n const [tpath, request_id] = resource.create_texture_async(\"/my_texture.texturec\", tparams, tbuffer);\n // at this point you can use the resource as-is, but note that the texture will be a blank 1x1 texture\n // that will be removed once the new texture has been updated\n go.set(\"#model\", \"texture0\", tpath);\n },\n});"
1344
+ "sourceHash": "f1188598b3ca5eb1",
1345
+ "ts": "// Create a texture resource asyncronously with a buffer and a callback\nfunction callback(self: unknown, request_id: unknown, texture_path: unknown) {\n // The resource has been updated with a new texture,\n // so we can update other systems with the new handle,\n // or update components to use the resource if we want\n const tinfo = resource.get_texture_info(texture_path as Hash);\n msg.post(\"@render:\", \"set_backing_texture\", { handle: tinfo.handle });\n}\n\nexport default defineScript({\n init() {\n // Create a texture resource async\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA,\n };\n\n // Create a new buffer with 4 components\n const tbuffer = buffer.create(tparams.width * tparams.height, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_UINT8, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < tparams.width; y++) {\n for (let x = 0; x < tparams.height; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 255;\n tstream[index + 1] = 0;\n tstream[index + 2] = 255;\n tstream[index + 3] = 255;\n }\n }\n // create the texture\n const [tpath, request_id] = resource.create_texture_async(\"/my_texture.texturec\", tparams, tbuffer, callback);\n // at this point you can use the resource as-is, but note that the texture will be a blank 1x1 texture\n // that will be removed once the new texture has been updated\n go.set(\"#model\", \"texture0\", tpath);\n },\n});"
1346
+ },
1347
+ {
1348
+ "sourceHash": "921632059c7abb58",
1349
+ "ts": "// Create a texture resource asyncronously without a callback\nexport default defineScript({\n init() {\n // Create a texture resource async\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA,\n };\n\n // Create a new buffer with 4 components\n const tbuffer = buffer.create(tparams.width * tparams.height, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_UINT8, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < tparams.width; y++) {\n for (let x = 0; x < tparams.height; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 255;\n tstream[index + 1] = 0;\n tstream[index + 2] = 255;\n tstream[index + 3] = 255;\n }\n }\n // create the texture\n const [tpath, request_id] = resource.create_texture_async(\"/my_texture.texturec\", tparams, tbuffer);\n // at this point you can use the resource as-is, but note that the texture will be a blank 1x1 texture\n // that will be removed once the new texture has been updated\n go.set(\"#model\", \"texture0\", tpath);\n },\n});"
1210
1350
  }
1211
1351
  ],
1212
1352
  "resource.font": [
1213
1353
  {
1214
- "sourceHash": "f6d4ca24e4f87bfe",
1215
- "ts": "// Load a font and set it to a label:\ngo.property(\"my_font\", resource.font(\"/font.font\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#label\", \"font\", self.my_font);\n },\n});\n\n// Load a font and set it to a gui:\ngo.property(\"my_font\", resource.font(\"/font.font\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#gui\", \"fonts\", self.my_font, { key: \"my_font\" });\n },\n});"
1354
+ "sourceHash": "3e41babc3620a985",
1355
+ "ts": "// Load a font and set it to a label:\ngo.property(\"my_font\", resource.font(\"/font.font\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#label\", \"font\", self.my_font);\n },\n});"
1356
+ },
1357
+ {
1358
+ "sourceHash": "8eb5018038b320d3",
1359
+ "ts": "// Load a font and set it to a gui:\ngo.property(\"my_font\", resource.font(\"/font.font\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#gui\", \"fonts\", self.my_font, { key: \"my_font\" });\n },\n});"
1216
1360
  }
1217
1361
  ],
1218
1362
  "resource.get_buffer": [
@@ -1223,8 +1367,12 @@
1223
1367
  ],
1224
1368
  "resource.get_render_target_info": [
1225
1369
  {
1226
- "sourceHash": "5e526c539ed8ae25",
1227
- "ts": "// Get the metadata from a render target resource\nexport default defineScript({\n init() {\n const info = resource.get_render_target_info(\"/my_render_target.render_targetc\");\n // the info table contains meta data about all the render target attachments\n // so it's not necessary to use resource.get_texture here, but we do it here\n // just to show that it's possible:\n const info_attachment_1 = resource.get_texture_info(info.attachments[0]!.handle);\n },\n});\n\n// Get a texture attachment from a render target and set it on a model component\nexport default defineScript({\n init() {\n const info = resource.get_render_target_info(\"/my_render_target.render_targetc\");\n const attachment = info.attachments[0]!.texture!;\n // you can also get texture info from the 'texture' field, since it's a resource hash\n const texture_info = resource.get_texture_info(attachment);\n go.set(\"#model\", \"texture0\", attachment);\n },\n});"
1370
+ "sourceHash": "8ae55f299be441f4",
1371
+ "ts": "// Get the metadata from a render target resource\nexport default defineScript({\n init() {\n const info = resource.get_render_target_info(\"/my_render_target.render_targetc\");\n // the info table contains meta data about all the render target attachments\n // so it's not necessary to use resource.get_texture here, but we do it here\n // just to show that it's possible:\n const info_attachment_1 = resource.get_texture_info(info.attachments[0]!.handle);\n },\n});"
1372
+ },
1373
+ {
1374
+ "sourceHash": "9356cfca159697a1",
1375
+ "ts": "// Get a texture attachment from a render target and set it on a model component\nexport default defineScript({\n init() {\n const info = resource.get_render_target_info(\"/my_render_target.render_targetc\");\n const attachment = info.attachments[0]!.texture!;\n // you can also get texture info from the 'texture' field, since it's a resource hash\n const texture_info = resource.get_texture_info(attachment);\n go.set(\"#model\", \"texture0\", attachment);\n },\n});"
1228
1376
  }
1229
1377
  ],
1230
1378
  "resource.get_text_metrics": [
@@ -1235,8 +1383,12 @@
1235
1383
  ],
1236
1384
  "resource.get_texture_info": [
1237
1385
  {
1238
- "sourceHash": "4164f100ea5a8c15",
1239
- "ts": "// Create a new texture and get the metadata from it\nexport default defineScript({\n init() {\n // create an empty texture\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA,\n };\n\n const my_texture_path = resource.create_texture(\"/my_texture.texturec\", tparams);\n const my_texture_info = resource.get_texture_info(my_texture_path);\n\n // my_texture_info now contains\n // {\n // handle = <the-numeric-handle>,\n // width = 128,\n // height = 128,\n // depth = 1\n // mipmaps = 1,\n // page_count = 1,\n // type = graphics.TEXTURE_TYPE_2D,\n // flags = graphics.TEXTURE_USAGE_FLAG_SAMPLE\n // }\n },\n});\n\n// Get the meta data from an atlas resource\nexport default defineScript({\n init() {\n const my_atlas_info = resource.get_atlas(\"/my_atlas.a.texturesetc\");\n const my_texture_info = resource.get_texture_info(my_atlas_info.texture);\n\n // my_texture_info now contains the information about the texture that is backing the atlas\n },\n});"
1386
+ "sourceHash": "2d4a0b27a192425a",
1387
+ "ts": "// Create a new texture and get the metadata from it\nexport default defineScript({\n init() {\n // create an empty texture\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGBA,\n };\n\n const my_texture_path = resource.create_texture(\"/my_texture.texturec\", tparams);\n const my_texture_info = resource.get_texture_info(my_texture_path);\n\n // my_texture_info now contains\n // {\n // handle = <the-numeric-handle>,\n // width = 128,\n // height = 128,\n // depth = 1\n // mipmaps = 1,\n // page_count = 1,\n // type = graphics.TEXTURE_TYPE_2D,\n // flags = graphics.TEXTURE_USAGE_FLAG_SAMPLE\n // }\n },\n});"
1388
+ },
1389
+ {
1390
+ "sourceHash": "4fed93d6cd7f9380",
1391
+ "ts": "// Get the meta data from an atlas resource\nexport default defineScript({\n init() {\n const my_atlas_info = resource.get_atlas(\"/my_atlas.a.texturesetc\");\n const my_texture_info = resource.get_texture_info(my_atlas_info.texture);\n\n // my_texture_info now contains the information about the texture that is backing the atlas\n },\n});"
1240
1392
  }
1241
1393
  ],
1242
1394
  "resource.load": [
@@ -1247,8 +1399,12 @@
1247
1399
  ],
1248
1400
  "resource.material": [
1249
1401
  {
1250
- "sourceHash": "5bc0271405b04027",
1251
- "ts": "// Load a material and set it to a sprite:\ngo.property(\"my_material\", resource.material(\"/material.material\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#sprite\", \"material\", self.my_material);\n },\n});\n\n// Load a material resource and update a named material with the resource:\ngo.property(\"my_material\", resource.material(\"/material.material\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#gui\", \"materials\", self.my_material, { key: \"my_material\" });\n },\n});"
1402
+ "sourceHash": "444ac3e37fe7401e",
1403
+ "ts": "// Load a material and set it to a sprite:\ngo.property(\"my_material\", resource.material(\"/material.material\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#sprite\", \"material\", self.my_material);\n },\n});"
1404
+ },
1405
+ {
1406
+ "sourceHash": "7de09b2a13f4e657",
1407
+ "ts": "// Load a material resource and update a named material with the resource:\ngo.property(\"my_material\", resource.material(\"/material.material\"));\n\nexport default defineScript({\n init(self) {\n go.set(\"#gui\", \"materials\", self.my_material, { key: \"my_material\" });\n },\n});"
1252
1408
  }
1253
1409
  ],
1254
1410
  "resource.render_target": [
@@ -1265,24 +1421,44 @@
1265
1421
  ],
1266
1422
  "resource.set_atlas": [
1267
1423
  {
1268
- "sourceHash": "349576ce8a915179",
1269
- "ts": "// Add a new animation to an existing atlas\nexport default defineScript({\n init() {\n const data = resource.get_atlas(\"/main/my_atlas.a.texturesetc\");\n const my_animation = {\n id: \"my_new_animation\",\n width: 128,\n height: 128,\n frame_start: 1,\n frame_end: 6,\n playback: go.PLAYBACK_LOOP_PINGPONG,\n fps: 8,\n };\n data.animations.push(my_animation);\n resource.set_atlas(\"/main/my_atlas.a.texturesetc\", data);\n },\n});\n\n// Sets atlas data for a 256x256 texture with a single animation being rendered as a quad\nexport default defineScript({\n init() {\n const params = {\n texture: \"/main/my_256x256_texture.texturec\",\n animations: [\n {\n id: \"my_animation\",\n width: 256,\n height: 256,\n frames: [1],\n },\n ],\n geometries: [\n {\n vertices: [0, 0, 0, 256, 256, 256, 256, 0],\n uvs: [0, 0, 0, 256, 256, 256, 256, 0],\n indices: [0, 1, 2, 0, 2, 3],\n },\n ],\n };\n resource.set_atlas(\"/main/test.a.texturesetc\", params);\n },\n});"
1424
+ "sourceHash": "58ec7c40c31875a4",
1425
+ "ts": "// Add a new animation to an existing atlas\nexport default defineScript({\n init() {\n const data = resource.get_atlas(\"/main/my_atlas.a.texturesetc\");\n const my_animation = {\n id: \"my_new_animation\",\n width: 128,\n height: 128,\n frame_start: 1,\n frame_end: 6,\n playback: go.PLAYBACK_LOOP_PINGPONG,\n fps: 8,\n };\n data.animations.push(my_animation);\n resource.set_atlas(\"/main/my_atlas.a.texturesetc\", data);\n },\n});"
1426
+ },
1427
+ {
1428
+ "sourceHash": "c672fd8c9d921f68",
1429
+ "ts": "// Sets atlas data for a 256x256 texture with a single animation being rendered as a quad\nexport default defineScript({\n init() {\n const params = {\n texture: \"/main/my_256x256_texture.texturec\",\n animations: [\n {\n id: \"my_animation\",\n width: 256,\n height: 256,\n frames: [1],\n },\n ],\n geometries: [\n {\n vertices: [0, 0, 0, 256, 256, 256, 256, 0],\n uvs: [0, 0, 0, 256, 256, 256, 256, 0],\n indices: [0, 1, 2, 0, 2, 3],\n },\n ],\n };\n resource.set_atlas(\"/main/test.a.texturesetc\", params);\n },\n});"
1270
1430
  }
1271
1431
  ],
1272
1432
  "resource.set_buffer": [
1273
1433
  {
1274
1434
  "sourceHash": "a52fd8ac7453f601",
1275
- "ts": "// How to set the data from a buffer\nfunction fill_stream(stream, verts) {\n verts.forEach((value, key) => {\n stream[key] = verts[key];\n });\n}\n\nexport default defineScript({\n init() {\n const res_path = go.get(\"#mesh\", \"vertices\");\n\n const positions = [\n 1, -1, 0,\n 1, 1, 0,\n -1, -1, 0,\n ];\n\n const num_verts = positions.length / 3;\n\n // create a new buffer\n let buf = buffer.create(num_verts, [{ name: hash(\"position\"), type: buffer.VALUE_TYPE_FLOAT32, count: 3 }]);\n\n buf = resource.get_buffer(res_path);\n const stream_positions = buffer.get_stream(buf, \"position\");\n\n fill_stream(stream_positions, positions);\n\n resource.set_buffer(res_path, buf);\n },\n});"
1435
+ "ts": "// How to set the data from a buffer\nfunction fill_stream(stream: { [index: number]: number }, verts: number[]) {\n verts.forEach((value, key) => {\n stream[key] = value;\n });\n}\n\nexport default defineScript({\n init() {\n const res_path = go.get(\"#mesh\", \"vertices\");\n\n const positions = [\n 1, -1, 0,\n 1, 1, 0,\n -1, -1, 0,\n ];\n\n const num_verts = positions.length / 3;\n\n // create a new buffer\n let buf = buffer.create(num_verts, [{ name: hash(\"position\"), type: buffer.VALUE_TYPE_FLOAT32, count: 3 }]);\n\n buf = resource.get_buffer(res_path);\n const stream_positions = buffer.get_stream(buf, \"position\");\n\n fill_stream(stream_positions, positions);\n\n resource.set_buffer(res_path, buf);\n },\n});"
1276
1436
  }
1277
1437
  ],
1278
1438
  "resource.set_texture": [
1279
1439
  {
1280
- "sourceHash": "1f7a5108992a12f0",
1281
- "ts": "// How to set all pixels of an atlas\nexport default defineScript({\n init(self) {\n self.height = 128;\n self.width = 128;\n self.buffer = buffer.create(self.width * self.height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n self.stream = buffer.get_stream(self.buffer, hash(\"rgb\"));\n\n for (let y = 0; y < self.height; y++) {\n for (let x = 0; x < self.width; x++) {\n const index = y * self.width * 3 + x * 3;\n self.stream[index + 0] = 0xff;\n self.stream[index + 1] = 0x80;\n self.stream[index + 2] = 0x10;\n }\n }\n\n const resource_path = go.get(\"#model\", \"texture0\");\n const args = { width: self.width, height: self.height, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };\n resource.set_texture(resource_path, args, self.buffer);\n },\n});\n\n// How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.\nexport default defineScript({\n init(self) {\n self.x = 16;\n self.y = 16;\n self.height = 128 - self.x * 2;\n self.width = 128 - self.y * 2;\n self.buffer = buffer.create(self.width * self.height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n self.stream = buffer.get_stream(self.buffer, hash(\"rgb\"));\n\n for (let y = 0; y < self.height; y++) {\n for (let x = 0; x < self.width; x++) {\n const index = y * self.width * 3 + x * 3;\n self.stream[index + 0] = 0xff;\n self.stream[index + 1] = 0x80;\n self.stream[index + 2] = 0x10;\n }\n }\n\n const resource_path = go.get(\"#model\", \"texture0\");\n const args = { width: self.width, height: self.height, x: self.x, y: self.y, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };\n resource.set_texture(resource_path, args, self.buffer);\n },\n});\n\n// Update a texture from a buffer resource\ngo.property(\"my_buffer\", resource.buffer(\"/my_default_buffer.buffer\"));\n\nexport default defineScript({\n init(self) {\n const resource_path = go.get(\"#model\", \"texture0\");\n // the \"my_buffer\" resource is expected to hold 128 * 128 * 3 bytes!\n const args = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGB,\n };\n // Note that the extra resource.get_buffer call is a requirement here\n // since the \"self.my_buffer\" is just pointing to a buffer resource path\n // and not an actual buffer object or buffer resource.\n resource.set_texture(resource_path, args, resource.get_buffer(self.my_buffer));\n },\n});\n\n// Update an existing 3D texture from a buffer\nexport default defineScript({\n init() {\n // create a buffer that can hold the data of a 8x8x8 texture\n const tbuffer = buffer.create(8 * 8 * 8, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // populate the buffer with some data\n let index = 0;\n for (let z = 0; z < 8; z++) {\n for (let y = 0; y < 8; y++) {\n for (let x = 0; x < 8; x++) {\n tstream[index + 0] = x;\n tstream[index + 1] = y;\n tstream[index + 2] = z;\n tstream[index + 3] = 1.0;\n index = index + 4;\n }\n }\n }\n\n const t_args = {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 8,\n height: 8,\n depth: 8,\n format: resource.TEXTURE_FORMAT_RGBA32F,\n };\n\n // This expects that the texture resource \"/my_3d_texture.texturec\" already exists\n // and is a 3D texture resource. To create a dynamic 3D texture resource\n // use the \"resource.create_texture\" function.\n resource.set_texture(\"/my_3d_texture.texturec\", t_args, tbuffer);\n },\n});\n\n// Update texture 2nd array page with loaded texture from png\n// new_tex is resource handle of texture which was created via resource.create_resource\nconst tex_path = \"/bundle_resources/page_02.png\";\nconst [data] = sys.load_resource(tex_path);\nconst buf = image.load_buffer(data);\nresource.set_texture(\n new_tex,\n {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: buf.width,\n height: buf.height,\n page: 1,\n format: graphics.TEXTURE_FORMAT_RGB,\n },\n buf.buffer,\n);\ngo.set(\"#mesh\", \"texture0\", new_tex);"
1440
+ "sourceHash": "fe312c35ef2ab0f4",
1441
+ "ts": "// How to set all pixels of an atlas\nexport default defineScript({\n init(self) {\n self.height = 128;\n self.width = 128;\n self.buffer = buffer.create(self.width * self.height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n self.stream = buffer.get_stream(self.buffer, hash(\"rgb\"));\n\n for (let y = 0; y < self.height; y++) {\n for (let x = 0; x < self.width; x++) {\n const index = y * self.width * 3 + x * 3;\n self.stream[index + 0] = 0xff;\n self.stream[index + 1] = 0x80;\n self.stream[index + 2] = 0x10;\n }\n }\n\n const resource_path = go.get(\"#model\", \"texture0\");\n const args = { width: self.width, height: self.height, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };\n resource.set_texture(resource_path, args, self.buffer);\n },\n});"
1442
+ },
1443
+ {
1444
+ "sourceHash": "b4098f0f37b9c1d0",
1445
+ "ts": "// How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.\nexport default defineScript({\n init(self) {\n self.x = 16;\n self.y = 16;\n self.height = 128 - self.x * 2;\n self.width = 128 - self.y * 2;\n self.buffer = buffer.create(self.width * self.height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n self.stream = buffer.get_stream(self.buffer, hash(\"rgb\"));\n\n for (let y = 0; y < self.height; y++) {\n for (let x = 0; x < self.width; x++) {\n const index = y * self.width * 3 + x * 3;\n self.stream[index + 0] = 0xff;\n self.stream[index + 1] = 0x80;\n self.stream[index + 2] = 0x10;\n }\n }\n\n const resource_path = go.get(\"#model\", \"texture0\");\n const args = { width: self.width, height: self.height, x: self.x, y: self.y, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };\n resource.set_texture(resource_path, args, self.buffer);\n },\n});"
1446
+ },
1447
+ {
1448
+ "sourceHash": "02d7f2ec29971bf1",
1449
+ "ts": "// Update a texture from a buffer resource\ngo.property(\"my_buffer\", resource.buffer(\"/my_default_buffer.buffer\"));\n\nexport default defineScript({\n init(self) {\n const resource_path = go.get(\"#model\", \"texture0\");\n // the \"my_buffer\" resource is expected to hold 128 * 128 * 3 bytes!\n const args = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGB,\n };\n // Note that the extra resource.get_buffer call is a requirement here\n // since the \"self.my_buffer\" is just pointing to a buffer resource path\n // and not an actual buffer object or buffer resource.\n resource.set_texture(resource_path, args, resource.get_buffer(self.my_buffer));\n },\n});"
1450
+ },
1451
+ {
1452
+ "sourceHash": "15829bfe1b186bc3",
1453
+ "ts": "// Update an existing 3D texture from a buffer\nexport default defineScript({\n init() {\n // create a buffer that can hold the data of a 8x8x8 texture\n const tbuffer = buffer.create(8 * 8 * 8, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // populate the buffer with some data\n let index = 0;\n for (let z = 0; z < 8; z++) {\n for (let y = 0; y < 8; y++) {\n for (let x = 0; x < 8; x++) {\n tstream[index + 0] = x;\n tstream[index + 1] = y;\n tstream[index + 2] = z;\n tstream[index + 3] = 1.0;\n index = index + 4;\n }\n }\n }\n\n const t_args = {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 8,\n height: 8,\n depth: 8,\n format: resource.TEXTURE_FORMAT_RGBA32F,\n };\n\n // This expects that the texture resource \"/my_3d_texture.texturec\" already exists\n // and is a 3D texture resource. To create a dynamic 3D texture resource\n // use the \"resource.create_texture\" function.\n resource.set_texture(\"/my_3d_texture.texturec\", t_args, tbuffer);\n },\n});"
1454
+ },
1455
+ {
1456
+ "sourceHash": "f9b616092f8c1b6a",
1457
+ "ts": "// Update texture 2nd array page with loaded texture from png\nconst tex_path = \"/bundle_resources/page_02.png\";\nconst [data] = sys.load_resource(tex_path);\nif (data !== undefined) {\n const buf = image.load_buffer(data);\n if (buf !== undefined) {\n // new_tex is the resource handle of a texture created via resource.create_texture\n const new_tex = resource.create_texture(\"/my_array_texture.texturec\", {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: buf.width,\n height: buf.height,\n page_count: 2,\n format: graphics.TEXTURE_FORMAT_RGB,\n });\n resource.set_texture(\n new_tex,\n {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: buf.width,\n height: buf.height,\n page: 1,\n format: graphics.TEXTURE_FORMAT_RGB,\n },\n buf.buffer,\n );\n go.set(\"#mesh\", \"texture0\", new_tex);\n }\n}"
1282
1458
  },
1283
1459
  {
1284
- "sourceHash": "48a7f4c2c8433aed",
1285
- "ts": "// How to set all pixels of an atlas\nexport default defineScript({\n init(self) {\n self.height = 128;\n self.width = 128;\n self.buffer = buffer.create(self.width * self.height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n self.stream = buffer.get_stream(self.buffer, hash(\"rgb\"));\n\n for (let y = 0; y < self.height; y++) {\n for (let x = 0; x < self.width; x++) {\n const index = y * self.width * 3 + x * 3;\n self.stream[index + 0] = 0xff;\n self.stream[index + 1] = 0x80;\n self.stream[index + 2] = 0x10;\n }\n }\n\n const resource_path = go.get(\"#model\", \"texture0\");\n const args = { width: self.width, height: self.height, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };\n resource.set_texture(resource_path, args, self.buffer);\n },\n});\n\n// How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.\nexport default defineScript({\n init(self) {\n self.x = 16;\n self.y = 16;\n self.height = 128 - self.x * 2;\n self.width = 128 - self.y * 2;\n self.buffer = buffer.create(self.width * self.height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n self.stream = buffer.get_stream(self.buffer, hash(\"rgb\"));\n\n for (let y = 0; y < self.height; y++) {\n for (let x = 0; x < self.width; x++) {\n const index = y * self.width * 3 + x * 3;\n self.stream[index + 0] = 0xff;\n self.stream[index + 1] = 0x80;\n self.stream[index + 2] = 0x10;\n }\n }\n\n const resource_path = go.get(\"#model\", \"texture0\");\n const args = { width: self.width, height: self.height, x: self.x, y: self.y, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };\n resource.set_texture(resource_path, args, self.buffer);\n },\n});\n\n// Update a texture from a buffer resource\ngo.property(\"my_buffer\", resource.buffer(\"/my_default_buffer.buffer\"));\n\nexport default defineScript({\n init(self) {\n const resource_path = go.get(\"#model\", \"texture0\");\n // the \"my_buffer\" resource is expected to hold 128 * 128 * 3 bytes!\n const args = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format: graphics.TEXTURE_FORMAT_RGB,\n };\n // Note that the extra resource.get_buffer call is a requirement here\n // since the \"self.my_buffer\" is just pointing to a buffer resource path\n // and not an actual buffer object or buffer resource.\n resource.set_texture(resource_path, args, resource.get_buffer(self.my_buffer));\n },\n});\n\n// Update an existing 3D texture from a buffer\nexport default defineScript({\n init() {\n // create a buffer that can hold the data of a 8x8x8 texture\n const tbuffer = buffer.create(8 * 8 * 8, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // populate the buffer with some data\n let index = 0;\n for (let z = 0; z < 8; z++) {\n for (let y = 0; y < 8; y++) {\n for (let x = 0; x < 8; x++) {\n tstream[index + 0] = x;\n tstream[index + 1] = y;\n tstream[index + 2] = z;\n tstream[index + 3] = 1.0;\n index = index + 4;\n }\n }\n }\n\n const t_args = {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 8,\n height: 8,\n depth: 8,\n format: resource.TEXTURE_FORMAT_RGBA32F,\n };\n\n // This expects that the texture resource \"/my_3d_texture.texturec\" already exists\n // and is a 3D texture resource. To create a dynamic 3D texture resource\n // use the \"resource.create_texture\" function.\n resource.set_texture(\"/my_3d_texture.texturec\", t_args, tbuffer);\n },\n});\n\n// Update texture 2nd array page with loaded texture from png\n// new_tex is resource handle of texture which was created via resource.create_resource\nconst tex_path = \"/bundle_resources/page_02.png\";\nconst [data] = sys.load_resource(tex_path);\nconst buf = image.load_buffer(data);\nresource.set_texture(\n new_tex,\n {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: buf.width,\n height: buf.height,\n page: 1,\n format: graphics.TEXTURE_FORMAT_RGB,\n },\n buf.buffer,\n);\ngo.set(\"#mesh\", \"texture0\", new_tex);"
1460
+ "sourceHash": "34dce6f8362c0e92",
1461
+ "ts": "// Update an existing 3D texture from a buffer\nexport default defineScript({\n init() {\n // create a buffer that can hold the data of a 8x8x8 texture\n const tbuffer = buffer.create(8 * 8 * 8, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // populate the buffer with some data\n let index = 0;\n for (let z = 0; z < 8; z++) {\n for (let y = 0; y < 8; y++) {\n for (let x = 0; x < 8; x++) {\n tstream[index + 0] = x;\n tstream[index + 1] = y;\n tstream[index + 2] = z;\n tstream[index + 3] = 1.0;\n index = index + 4;\n }\n }\n }\n\n const t_args = {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 8,\n height: 8,\n depth: 8,\n format: resource.TEXTURE_FORMAT_RGBA32F,\n };\n\n // This expects that the texture resource \"/my_3d_texture.texturec\" already exists\n // and is a 3D texture resource. To create a dynamic 3D texture resource\n // use the \"resource.create_texture\" function.\n resource.set_texture(\"/my_3d_texture.texturec\", t_args, tbuffer);\n },\n});"
1286
1462
  }
1287
1463
  ],
1288
1464
  "resource.texture": [
@@ -1306,7 +1482,7 @@
1306
1482
  "socket.newtry": [
1307
1483
  {
1308
1484
  "sourceHash": "38a669dbf612b327",
1309
- "ts": "// Perform operations on an open socket c:\n// create a try function that closes 'c' on error\nconst try_ = socket.newtry(() => c.close());\n// do everything reassured c will be closed\ntry_(c.send(\"hello there?\\r\\n\"));\nconst answer = try_(c.receive());\n// ...\ntry_(c.send(\"good bye\\r\\n\"));\nc.close();"
1485
+ "ts": "// Perform operations on an open socket c:\nconst [c] = socket.connect(\"localhost\", 80);\nif (c !== undefined) {\n // create a try function that closes 'c' on error\n const try_ = socket.newtry(() => c.close());\n // do everything reassured c will be closed\n try_(c.send(\"hello there?\\r\\n\"));\n const answer = try_(c.receive());\n // ...\n try_(c.send(\"good bye\\r\\n\"));\n c.close();\n}"
1310
1486
  }
1311
1487
  ],
1312
1488
  "socket.protect": [
@@ -1318,7 +1494,7 @@
1318
1494
  "socket.skip": [
1319
1495
  {
1320
1496
  "sourceHash": "3a75c35a80c48e9e",
1321
- "ts": "// Instead of doing the following with dummy variables:\n// get the status code and separator from SMTP server reply\nconst [dummy1, dummy2, code, sep] = string.find(line, \"^(%d%d%d)(.?)\");\n\n// You can skip a number of variables:\n// get the status code and separator from SMTP server reply\nconst [code, sep] = socket.skip(2, string.find(line, \"^(%d%d%d)(.?)\"));"
1497
+ "ts": "const line = \"250 OK\";\n\n// Instead of doing the following with dummy variables:\n// get the status code and separator from SMTP server reply\nconst [dummy1, dummy2, code, sep] = string.find(line, \"^(%d%d%d)(.?)\");\n\n// You can skip a number of variables:\n// get the status code and separator from SMTP server reply\nconst [code, sep] = socket.skip(2, string.find(line, \"^(%d%d%d)(.?)\"));"
1322
1498
  }
1323
1499
  ],
1324
1500
  "sound.get_group_gain": [
@@ -1372,7 +1548,7 @@
1372
1548
  "sound.play": [
1373
1549
  {
1374
1550
  "sourceHash": "fcfbfd341c41ec59",
1375
- "ts": "// Assuming the script belongs to an instance with a sound-component with id\n// \"sound\", this will make the component play its sound after 1 second:\nsound.play(\"#sound\", { delay: 1, gain: 0.9, pan: -1.0 });\n\n// Using the callback argument, you can chain several sounds together:\nfunction sound_done(self, message_id, message, sender) {\n // play 'boom' sound fx when the countdown has completed\n if (message_id === hash(\"sound_done\") && message.play_id === self.countdown_id) {\n sound.play(\"#boom\", undefined, sound_done);\n }\n}\n\nexport default defineScript({\n init(self) {\n self.countdown_id = sound.play(\"#countdown\", undefined, sound_done);\n },\n});"
1551
+ "ts": "// Assuming the script belongs to an instance with a sound-component with id\n// \"sound\", this will make the component play its sound after 1 second:\nsound.play(\"#sound\", { delay: 1, gain: 0.9, pan: -1.0 });\n\n// Using the callback argument, you can chain several sounds together:\nfunction sound_done(self: unknown, message_id: unknown, message: unknown, sender: unknown) {\n // play 'boom' sound fx when the countdown has completed\n const { play_id } = message as { play_id: number };\n if (message_id === hash(\"sound_done\") && play_id === (self as { countdown_id: number }).countdown_id) {\n sound.play(\"#boom\", undefined, sound_done);\n }\n}\n\nexport default defineScript({\n init(self) {\n self.countdown_id = sound.play(\"#countdown\", undefined, sound_done);\n },\n});"
1376
1552
  }
1377
1553
  ],
1378
1554
  "sound.set_gain": [
@@ -1426,13 +1602,13 @@
1426
1602
  "sys.deserialize": [
1427
1603
  {
1428
1604
  "sourceHash": "3129688709daf585",
1429
- "ts": "// Deserialize a table that was previously serialized:\nconst buffer = sys.serialize(my_table);\nconst table = sys.deserialize(buffer);"
1605
+ "ts": "// Deserialize a table that was previously serialized:\nconst my_table = { score: 100, level: 3 };\nconst buffer = sys.serialize(my_table);\nconst table = sys.deserialize(buffer);"
1430
1606
  }
1431
1607
  ],
1432
1608
  "sys.exists": [
1433
1609
  {
1434
1610
  "sourceHash": "7e98945102ff1ab7",
1435
- "ts": "// Load data but return nil if path didn't exist\nif (!sys.exists(path)) {\n return undefined;\n}\nreturn sys.load(path); // returns {} if it failed"
1611
+ "ts": "// Load data but return nil if path didn't exist\nconst path = \"/save/game.dat\";\nif (!sys.exists(path)) {\n return undefined;\n}\nreturn sys.load(path); // returns {} if it failed"
1436
1612
  }
1437
1613
  ],
1438
1614
  "sys.exit": [
@@ -1492,7 +1668,7 @@
1492
1668
  "sys.get_host_path": [
1493
1669
  {
1494
1670
  "sourceHash": "a059ecb3d55d5c22",
1495
- "ts": "// Save data on the host\nconst host_path = sys.get_host_path(\"logs/test.txt\");\nsys.save(host_path, mytable);\n\n// Load data from the host\nconst host_path = sys.get_host_path(\"logs/test.txt\");\nconst table = sys.load(host_path);"
1671
+ "ts": "// Save data on the host\nconst mytable = { score: 100, level: 3 };\nconst host_path = sys.get_host_path(\"logs/test.txt\");\nsys.save(host_path, mytable);\n\n// Load data from the host\nconst host_path = sys.get_host_path(\"logs/test.txt\");\nconst table = sys.load(host_path);"
1496
1672
  }
1497
1673
  ],
1498
1674
  "sys.get_ifaddrs": [
@@ -1528,7 +1704,7 @@
1528
1704
  "sys.load_buffer_async": [
1529
1705
  {
1530
1706
  "sourceHash": "6a383bca91cf11eb",
1531
- "ts": "// Load binary data from a custom project resource and update a texture resource:\nfunction my_callback(self, request_id, result) {\n if (result.status === resource.REQUEST_STATUS_FINISHED) {\n resource.set_texture(\"/my_texture\", {}, result.buf); // texture args\n }\n}\n\nconst my_request = sys.load_buffer_async(\"/assets/my_level_data.bin\", my_callback);\n\n// Load binary data from non-custom resource files on disk:\nfunction my_callback(self, request_id, result) {\n if (result.status !== sys.REQUEST_STATUS_FINISHED) {\n // uh oh! File could not be found, do something graceful\n } else if (request_id === self.first_asset) {\n // result.buffer contains data from my_level_asset.bin\n } else if (request_id === self.second_asset) {\n // result.buffer contains data from 'my_level.bin'\n }\n}\n\nexport default defineScript({\n init(self) {\n self.first_asset = hash(\"folder_next_to_binary/my_level_asset.bin\");\n self.second_asset = hash(\"/some_absolute_path/my_level.bin\");\n self.first_request = sys.load_buffer_async(self.first_asset, my_callback);\n self.second_request = sys.load_buffer_async(self.second_asset, my_callback);\n },\n});"
1707
+ "ts": "// Load binary data from a custom project resource and update a texture resource:\nfunction my_callback(self: unknown, request_id: unknown, result: unknown) {\n const { status, buf } = result as { status: number; buf: Opaque<\"buffer\"> };\n if (status === resource.REQUEST_STATUS_FINISHED) {\n resource.set_texture(\"/my_texture\", {}, buf); // texture args\n }\n}\n\nconst my_request = sys.load_buffer_async(\"/assets/my_level_data.bin\", my_callback);\n\n// Load binary data from non-custom resource files on disk:\nfunction my_callback(self: unknown, request_id: unknown, result: unknown) {\n const { first_asset, second_asset } = self as { first_asset: Hash; second_asset: Hash };\n if ((result as { status: number }).status !== sys.REQUEST_STATUS_FINISHED) {\n // uh oh! File could not be found, do something graceful\n } else if (request_id === first_asset) {\n // result.buffer contains data from my_level_asset.bin\n } else if (request_id === second_asset) {\n // result.buffer contains data from 'my_level.bin'\n }\n}\n\nexport default defineScript({\n init(self) {\n self.first_asset = hash(\"folder_next_to_binary/my_level_asset.bin\");\n self.second_asset = hash(\"/some_absolute_path/my_level.bin\");\n self.first_request = sys.load_buffer_async(self.first_asset, my_callback);\n self.second_request = sys.load_buffer_async(self.second_asset, my_callback);\n },\n});"
1532
1708
  }
1533
1709
  ],
1534
1710
  "sys.load_resource": [
@@ -1576,7 +1752,7 @@
1576
1752
  "sys.set_error_handler": [
1577
1753
  {
1578
1754
  "sourceHash": "7346508f30f50bc9",
1579
- "ts": "// Install error handler that just prints the errors\nfunction my_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\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});"
1755
+ "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});"
1580
1756
  }
1581
1757
  ],
1582
1758
  "sys.set_render_enable": [
@@ -1606,19 +1782,19 @@
1606
1782
  "tilemap.get_tile": [
1607
1783
  {
1608
1784
  "sourceHash": "a4284f541bd0cf03",
1609
- "ts": "// get the tile under the player.\nconst tileno = tilemap.get_tile(\"/level#tilemap\", \"foreground\", self.player_x, self.player_y);"
1785
+ "ts": "function tile_under_player(self: { player_x: number; player_y: number }) {\n // get the tile under the player.\n const tileno = tilemap.get_tile(\"/level#tilemap\", \"foreground\", self.player_x, self.player_y);\n}"
1610
1786
  }
1611
1787
  ],
1612
1788
  "tilemap.get_tile_info": [
1613
1789
  {
1614
1790
  "sourceHash": "a05cf9c118a0d36c",
1615
- "ts": "// get the tile under the player.\nconst tile_info = tilemap.get_tile_info(\"/level#tilemap\", \"foreground\", self.player_x, self.player_y);\npprint(tile_info);\n// {\n// index = 0,\n// h_flip = false,\n// v_flip = true,\n// rotate_90 = false\n// }"
1791
+ "ts": "function tile_info_under_player(self: { player_x: number; player_y: number }) {\n // get the tile under the player.\n const tile_info = tilemap.get_tile_info(\"/level#tilemap\", \"foreground\", self.player_x, self.player_y);\n pprint(tile_info);\n // {\n // index = 0,\n // h_flip = false,\n // v_flip = true,\n // rotate_90 = false\n // }\n}"
1616
1792
  }
1617
1793
  ],
1618
1794
  "tilemap.get_tiles": [
1619
1795
  {
1620
1796
  "sourceHash": "61b14de4991f966b",
1621
- "ts": "const [left, bottom, columns_count, rows_count] = tilemap.get_bounds(\"#tilemap\");\nconst tiles = tilemap.get_tiles(\"#tilemap\", \"layer\");\nlet tile = 0;\nlet count = 0;\nfor (let row_index = bottom; row_index <= bottom + rows_count - 1; row_index++) {\n for (let column_index = left; column_index <= left + columns_count - 1; column_index++) {\n tile = tiles[row_index][column_index];\n count = count + 1;\n }\n}"
1797
+ "ts": "const [left, bottom, columns_count, rows_count] = tilemap.get_bounds(\"#tilemap\");\nconst tiles = tilemap.get_tiles(\"#tilemap\", \"layer\");\nlet tile = 0;\nlet count = 0;\nfor (let row_index = bottom; row_index <= bottom + rows_count - 1; row_index++) {\n for (let column_index = left; column_index <= left + columns_count - 1; column_index++) {\n tile = tiles.get(row_index)?.get(column_index) ?? 0;\n count = count + 1;\n }\n}"
1622
1798
  }
1623
1799
  ],
1624
1800
  "tilemap.reset_constant": [
@@ -1630,7 +1806,7 @@
1630
1806
  "tilemap.set_tile": [
1631
1807
  {
1632
1808
  "sourceHash": "bc75d2a572ada34d",
1633
- "ts": "// Clear the tile under the player.\ntilemap.set_tile(\"/level#tilemap\", \"foreground\", self.player_x, self.player_y, 0);\n\n// Set tile with different combination of flip and rotation\ntilemap.set_tile(\"#tilemap\", \"layer1\", x, y, 0, tilemap.H_FLIP + tilemap.V_FLIP + tilemap.ROTATE_90);\ntilemap.set_tile(\"#tilemap\", \"layer1\", x, y, 0, tilemap.H_FLIP + tilemap.ROTATE_270);\ntilemap.set_tile(\"#tilemap\", \"layer1\", x, y, 0, tilemap.V_FLIP + tilemap.H_FLIP);\ntilemap.set_tile(\"#tilemap\", \"layer1\", x, y, 0, tilemap.ROTATE_180);"
1809
+ "ts": "function set_tiles(self: { player_x: number; player_y: number }, x: number, y: number) {\n // Clear the tile under the player.\n tilemap.set_tile(\"/level#tilemap\", \"foreground\", self.player_x, self.player_y, 0);\n\n // Set tile with different combination of flip and rotation\n tilemap.set_tile(\"#tilemap\", \"layer1\", x, y, 0, tilemap.H_FLIP + tilemap.V_FLIP + tilemap.ROTATE_90);\n tilemap.set_tile(\"#tilemap\", \"layer1\", x, y, 0, tilemap.H_FLIP + tilemap.ROTATE_270);\n tilemap.set_tile(\"#tilemap\", \"layer1\", x, y, 0, tilemap.V_FLIP + tilemap.H_FLIP);\n tilemap.set_tile(\"#tilemap\", \"layer1\", x, y, 0, tilemap.ROTATE_180);\n}"
1634
1810
  }
1635
1811
  ],
1636
1812
  "tilemap.set_visible": [
@@ -1642,25 +1818,25 @@
1642
1818
  "timer.cancel": [
1643
1819
  {
1644
1820
  "sourceHash": "00f46bbbb35028b3",
1645
- "ts": "self.handle = timer.delay(1, true, () => print(\"print every second\"));\n// ...\nconst result = timer.cancel(self.handle);\nif (!result) {\n print(\"the timer is already cancelled\");\n}"
1821
+ "ts": "function cancel_ticking(self: { handle: number }) {\n self.handle = timer.delay(1, true, () => print(\"print every second\"));\n // ...\n const result = timer.cancel(self.handle);\n if (!result) {\n print(\"the timer is already cancelled\");\n }\n}"
1646
1822
  }
1647
1823
  ],
1648
1824
  "timer.delay": [
1649
1825
  {
1650
1826
  "sourceHash": "d50acfc0a9d925a8",
1651
- "ts": "// A simple one-shot timer\ntimer.delay(1, false, () => print(\"print in one second\"));\n\n// Repetitive timer which canceled after 10 calls\nfunction call_every_second(self, handle, time_elapsed) {\n self.counter = self.counter + 1;\n print(\"Call #\", self.counter);\n if (self.counter === 10) {\n timer.cancel(handle); // cancel timer after 10 calls\n }\n}\n\nself.counter = 0;\ntimer.delay(1, true, call_every_second);"
1827
+ "ts": "// A simple one-shot timer\ntimer.delay(1, false, () => print(\"print in one second\"));\n\n// Repetitive timer which canceled after 10 calls\nfunction call_every_second(self: unknown, handle: unknown, time_elapsed: unknown) {\n const state = self as { counter: number };\n state.counter = state.counter + 1;\n print(\"Call #\", state.counter);\n if (state.counter === 10) {\n timer.cancel(handle as number); // cancel timer after 10 calls\n }\n}\n\nfunction start_counting(self: { counter: number }) {\n self.counter = 0;\n timer.delay(1, true, call_every_second);\n}"
1652
1828
  }
1653
1829
  ],
1654
1830
  "timer.get_info": [
1655
1831
  {
1656
1832
  "sourceHash": "f2fcacbd1849146e",
1657
- "ts": "self.handle = timer.delay(1, true, () => print(\"print every second\"));\n// ...\nconst result = timer.get_info(self.handle);\nif (!result) {\n print(\"the timer is already cancelled or complete\");\n} else {\n pprint(result); // delay, time_remaining, repeating\n}"
1833
+ "ts": "function report_ticking(self: { handle: number }) {\n self.handle = timer.delay(1, true, () => print(\"print every second\"));\n // ...\n const result = timer.get_info(self.handle);\n if (!result) {\n print(\"the timer is already cancelled or complete\");\n } else {\n pprint(result); // delay, time_remaining, repeating\n }\n}"
1658
1834
  }
1659
1835
  ],
1660
1836
  "timer.trigger": [
1661
1837
  {
1662
1838
  "sourceHash": "3d4814c0a3380acf",
1663
- "ts": "self.handle = timer.delay(1, true, () => print(\"print every second or manually by timer.trigger\"));\n// ...\nconst result = timer.trigger(self.handle);\nif (!result) {\n print(\"the timer is already cancelled or complete\");\n}"
1839
+ "ts": "function trigger_ticking(self: { handle: number }) {\n self.handle = timer.delay(1, true, () => print(\"print every second or manually by timer.trigger\"));\n // ...\n const result = timer.trigger(self.handle);\n if (!result) {\n print(\"the timer is already cancelled or complete\");\n }\n}"
1664
1840
  }
1665
1841
  ],
1666
1842
  "update": [
@@ -1694,7 +1870,7 @@
1694
1870
  "vmath.dot": [
1695
1871
  {
1696
1872
  "sourceHash": "4f4a1c2d340af81b",
1697
- "ts": "if (vmath.dot(vector1, vector2) === 0) {\n // The two vectors are perpendicular (at right-angles to each other)\n // ...\n}"
1873
+ "ts": "const vector1 = vmath.vector3(1, 0, 0);\nconst vector2 = vmath.vector3(0, 1, 0);\n\nif (vmath.dot(vector1, vector2) === 0) {\n // The two vectors are perpendicular (at right-angles to each other)\n // ...\n}"
1698
1874
  }
1699
1875
  ],
1700
1876
  "vmath.euler_to_quat": [
@@ -1712,13 +1888,13 @@
1712
1888
  "vmath.length": [
1713
1889
  {
1714
1890
  "sourceHash": "740d91676dd23d10",
1715
- "ts": "if (vmath.length(self.velocity) < max_velocity) {\n // The speed (velocity vector) is below max.\n\n // TODO: max_velocity can be expressed as squared\n // so we can compare with length_sqr() instead.\n // ...\n}"
1891
+ "ts": "function below_max_speed(self: { velocity: Vector3 }, max_velocity: number) {\n if (vmath.length(self.velocity) < max_velocity) {\n // The speed (velocity vector) is below max.\n\n // TODO: max_velocity can be expressed as squared\n // so we can compare with length_sqr() instead.\n // ...\n }\n}"
1716
1892
  }
1717
1893
  ],
1718
1894
  "vmath.length_sqr": [
1719
1895
  {
1720
1896
  "sourceHash": "221e411fbcc2c4f8",
1721
- "ts": "if (vmath.length_sqr(vector1) < vmath.length_sqr(vector2)) {\n // Vector 1 has less magnitude than vector 2\n // ...\n}"
1897
+ "ts": "const vector1 = vmath.vector3(1, 0, 0);\nconst vector2 = vmath.vector3(0, 2, 0);\n\nif (vmath.length_sqr(vector1) < vmath.length_sqr(vector2)) {\n // Vector 1 has less magnitude than vector 2\n // ...\n}"
1722
1898
  }
1723
1899
  ],
1724
1900
  "vmath.lerp": [
@@ -1828,7 +2004,7 @@
1828
2004
  "vmath.mul_per_elem": [
1829
2005
  {
1830
2006
  "sourceHash": "49995280c8b8dc5a",
1831
- "ts": "const blend_color = vmath.mul_per_elem(color1, color2);"
2007
+ "ts": "const color1 = vmath.vector4(1, 0.5, 0.5, 1);\nconst color2 = vmath.vector4(0.5, 1, 0.5, 1);\nconst blend_color = vmath.mul_per_elem(color1, color2);"
1832
2008
  }
1833
2009
  ],
1834
2010
  "vmath.normalize": [
@@ -1966,7 +2142,7 @@
1966
2142
  "window.set_listener": [
1967
2143
  {
1968
2144
  "sourceHash": "5075cb14faa9510b",
1969
- "ts": "function window_callback(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\nexport default defineScript({\n init() {\n window.set_listener(window_callback);\n },\n});"
2145
+ "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});"
1970
2146
  }
1971
2147
  ],
1972
2148
  "zlib.deflate": [