@defold-typescript/types 0.51.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-availability.json +4 -58
- package/api-signatures.json +878 -1356
- package/api-targets.json +15 -5
- package/examples/translations.json +4 -56
- package/generated/b2d_world.d.ts +10 -10
- package/generated/buffer.d.ts +9 -9
- package/generated/bullet3d_collision_object.d.ts +1 -1
- package/generated/bullet3d_constraint.d.ts +109 -7
- package/generated/bullet3d_shape.d.ts +2 -2
- package/generated/go.d.ts +114 -220
- package/generated/graphics.d.ts +1 -0
- package/generated/gui.d.ts +148 -371
- package/generated/http.d.ts +2 -2
- package/generated/image.d.ts +55 -3
- package/generated/kinds/gui-script.d.ts +2 -0
- package/generated/kinds/render-script.d.ts +14 -15
- package/generated/liveupdate.d.ts +5 -1
- package/generated/material.d.ts +3 -3
- package/generated/particlefx.d.ts +20 -1
- package/generated/physics.d.ts +45 -1
- package/generated/render-script-modules/b2d.d.ts +711 -0
- package/generated/render-script-modules/bullet3d.d.ts +73 -0
- package/generated/render-script-modules/collectionfactory.d.ts +25 -0
- package/generated/render-script-modules/collectionproxy.d.ts +39 -0
- package/generated/render-script-modules/factory.d.ts +25 -0
- package/generated/render-script-modules/go.d.ts +436 -0
- package/generated/render-script-modules/label.d.ts +105 -0
- package/generated/render-script-modules/model.d.ts +89 -0
- package/generated/render-script-modules/particlefx.d.ts +59 -0
- package/generated/render-script-modules/physics.d.ts +333 -0
- package/generated/render-script-modules/resource.d.ts +1233 -0
- package/generated/render-script-modules/sound.d.ts +227 -0
- package/generated/render-script-modules/sprite.d.ts +68 -0
- package/generated/render-script-modules/tilemap.d.ts +43 -0
- package/generated/render.d.ts +134 -8
- package/generated/resource.d.ts +31 -10
- package/generated/sprite.d.ts +49 -1
- package/generated/sys.d.ts +70 -6
- package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
- package/generated/versions/defold-1.12.4/go.d.ts +115 -343
- package/generated/versions/defold-1.12.4/graphics.d.ts +1 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +151 -513
- package/generated/versions/defold-1.12.4/http.d.ts +2 -2
- package/generated/versions/defold-1.12.4/image.d.ts +82 -2
- package/generated/versions/defold-1.12.4/index.d.ts +1 -0
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.12.4/physics.d.ts +45 -1
- package/generated/versions/defold-1.12.4/render.d.ts +78 -2
- package/generated/versions/defold-1.12.4/resource.d.ts +43 -10
- package/generated/versions/defold-1.12.4/sprite.d.ts +58 -1
- package/generated/versions/defold-1.12.4/sys.d.ts +101 -6
- package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.0/go.d.ts +115 -370
- package/generated/versions/defold-1.13.0/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +151 -513
- package/generated/versions/defold-1.13.0/http.d.ts +2 -2
- package/generated/versions/defold-1.13.0/image.d.ts +82 -2
- package/generated/versions/defold-1.13.0/index.d.ts +1 -0
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.0/material.d.ts +3 -1
- package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.0/physics.d.ts +45 -1
- package/generated/versions/defold-1.13.0/render.d.ts +142 -4
- package/generated/versions/defold-1.13.0/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.0/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.0/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.1/go.d.ts +115 -370
- package/generated/versions/defold-1.13.1/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.1/gui.d.ts +151 -529
- package/generated/versions/defold-1.13.1/http.d.ts +2 -2
- package/generated/versions/defold-1.13.1/image.d.ts +82 -2
- package/generated/versions/defold-1.13.1/index.d.ts +2 -0
- package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.1/material.d.ts +3 -1
- package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.1/physics.d.ts +45 -1
- package/generated/versions/defold-1.13.1/render.d.ts +142 -4
- package/generated/versions/defold-1.13.1/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.1/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.1/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.2/b2d_world.d.ts +10 -10
- package/generated/versions/defold-1.13.2/buffer.d.ts +9 -9
- package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +1 -1
- package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +109 -7
- package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +2 -2
- package/generated/versions/defold-1.13.2/go.d.ts +114 -220
- package/generated/versions/defold-1.13.2/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.2/gui.d.ts +148 -371
- package/generated/versions/defold-1.13.2/http.d.ts +2 -2
- package/generated/versions/defold-1.13.2/image.d.ts +55 -3
- package/generated/versions/defold-1.13.2/index.d.ts +2 -0
- package/generated/versions/defold-1.13.2/liveupdate.d.ts +5 -1
- package/generated/versions/defold-1.13.2/material.d.ts +3 -3
- package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
- package/generated/versions/defold-1.13.2/physics.d.ts +45 -1
- package/generated/versions/defold-1.13.2/render.d.ts +123 -7
- package/generated/versions/defold-1.13.2/resource.d.ts +31 -10
- package/generated/versions/defold-1.13.2/sprite.d.ts +49 -1
- package/generated/versions/defold-1.13.2/sys.d.ts +70 -6
- package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
- package/generated/vmath.d.ts +0 -24
- package/identity-vocabulary.json +52 -7
- package/index.d.ts +2 -0
- package/package.json +2 -1
- package/scripts/generate-api-availability.ts +1 -21
- package/scripts/generate-api-signatures.ts +75 -14
- package/scripts/materialize-version.ts +48 -7
- package/scripts/regen.ts +214 -19
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/target-version.ts +26 -0
- package/src/api-doc.ts +26 -0
- package/src/component-properties.d.ts +89 -0
- package/src/core-types.ts +42 -15
- package/src/doc-corrections.ts +53 -5
- package/src/emit-dts.ts +758 -198
- package/src/engine-globals.d.ts +5 -1
- package/src/go-overloads.d.ts +68 -13
- package/src/gui-overloads.d.ts +489 -0
- package/src/gui-texture-removal.d.ts +41 -0
- package/src/index.ts +2 -0
- package/src/lifecycle.ts +30 -21
- package/src/msg-overloads.d.ts +25 -13
- package/src/signature-store.ts +50 -0
- package/src/timers.d.ts +2 -1
- package/src/vmath-overloads.d.ts +26 -0
package/api-targets.json
CHANGED
|
@@ -148,7 +148,8 @@
|
|
|
148
148
|
{
|
|
149
149
|
"namespace": "gui",
|
|
150
150
|
"fixture": "gui_doc.json",
|
|
151
|
-
"outFile": "gui.d.ts"
|
|
151
|
+
"outFile": "gui.d.ts",
|
|
152
|
+
"skipFunctions": ["animate", "get", "set"]
|
|
152
153
|
},
|
|
153
154
|
{
|
|
154
155
|
"namespace": "html5",
|
|
@@ -270,6 +271,7 @@
|
|
|
270
271
|
"slerp",
|
|
271
272
|
"mul_per_elem",
|
|
272
273
|
"normalize",
|
|
274
|
+
"dot",
|
|
273
275
|
"vector"
|
|
274
276
|
]
|
|
275
277
|
},
|
|
@@ -539,7 +541,8 @@
|
|
|
539
541
|
{
|
|
540
542
|
"namespace": "gui",
|
|
541
543
|
"fixture": "gui_doc.json",
|
|
542
|
-
"outFile": "gui.d.ts"
|
|
544
|
+
"outFile": "gui.d.ts",
|
|
545
|
+
"skipFunctions": ["animate", "get", "set"]
|
|
543
546
|
},
|
|
544
547
|
{
|
|
545
548
|
"namespace": "html5",
|
|
@@ -661,6 +664,7 @@
|
|
|
661
664
|
"slerp",
|
|
662
665
|
"mul_per_elem",
|
|
663
666
|
"normalize",
|
|
667
|
+
"dot",
|
|
664
668
|
"vector"
|
|
665
669
|
]
|
|
666
670
|
},
|
|
@@ -900,7 +904,8 @@
|
|
|
900
904
|
{
|
|
901
905
|
"namespace": "gui",
|
|
902
906
|
"fixture": "gui_doc.json",
|
|
903
|
-
"outFile": "gui.d.ts"
|
|
907
|
+
"outFile": "gui.d.ts",
|
|
908
|
+
"skipFunctions": ["animate", "get", "set"]
|
|
904
909
|
},
|
|
905
910
|
{
|
|
906
911
|
"namespace": "html5",
|
|
@@ -1021,6 +1026,7 @@
|
|
|
1021
1026
|
"slerp",
|
|
1022
1027
|
"mul_per_elem",
|
|
1023
1028
|
"normalize",
|
|
1029
|
+
"dot",
|
|
1024
1030
|
"vector"
|
|
1025
1031
|
]
|
|
1026
1032
|
},
|
|
@@ -1260,7 +1266,8 @@
|
|
|
1260
1266
|
{
|
|
1261
1267
|
"namespace": "gui",
|
|
1262
1268
|
"fixture": "gui_doc.json",
|
|
1263
|
-
"outFile": "gui.d.ts"
|
|
1269
|
+
"outFile": "gui.d.ts",
|
|
1270
|
+
"skipFunctions": ["animate", "get", "set"]
|
|
1264
1271
|
},
|
|
1265
1272
|
{
|
|
1266
1273
|
"namespace": "html5",
|
|
@@ -1381,6 +1388,7 @@
|
|
|
1381
1388
|
"slerp",
|
|
1382
1389
|
"mul_per_elem",
|
|
1383
1390
|
"normalize",
|
|
1391
|
+
"dot",
|
|
1384
1392
|
"vector"
|
|
1385
1393
|
]
|
|
1386
1394
|
},
|
|
@@ -1563,7 +1571,8 @@
|
|
|
1563
1571
|
{
|
|
1564
1572
|
"namespace": "gui",
|
|
1565
1573
|
"fixture": "gui_doc.json",
|
|
1566
|
-
"outFile": "gui.d.ts"
|
|
1574
|
+
"outFile": "gui.d.ts",
|
|
1575
|
+
"skipFunctions": ["animate", "get", "set"]
|
|
1567
1576
|
},
|
|
1568
1577
|
{
|
|
1569
1578
|
"namespace": "html5",
|
|
@@ -1679,6 +1688,7 @@
|
|
|
1679
1688
|
"slerp",
|
|
1680
1689
|
"mul_per_elem",
|
|
1681
1690
|
"normalize",
|
|
1691
|
+
"dot",
|
|
1682
1692
|
"vector"
|
|
1683
1693
|
]
|
|
1684
1694
|
},
|
|
@@ -363,12 +363,6 @@
|
|
|
363
363
|
"ts": "// How to unload resources of a factory prototype loaded with factory.load:\nfactory.unload(\"#factory\");"
|
|
364
364
|
}
|
|
365
365
|
],
|
|
366
|
-
"final": [
|
|
367
|
-
{
|
|
368
|
-
"sourceHash": "ebc3cae218af001a",
|
|
369
|
-
"ts": "export default defineScript({\n init() {\n return { some_value: 0 };\n },\n\n final(self) {\n // report finalization\n msg.post(\"my_friend_instance\", \"im_dead\", { my_stats: self.some_value });\n },\n});"
|
|
370
|
-
}
|
|
371
|
-
],
|
|
372
366
|
"font.add_font": [
|
|
373
367
|
{
|
|
374
368
|
"sourceHash": "eb23e196a4edbd74",
|
|
@@ -708,7 +702,7 @@
|
|
|
708
702
|
},
|
|
709
703
|
{
|
|
710
704
|
"sourceHash": "7234f15bfdc28abb",
|
|
711
|
-
"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:
|
|
705
|
+
"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: Opaque<\"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 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});"
|
|
712
706
|
},
|
|
713
707
|
{
|
|
714
708
|
"sourceHash": "3d5dcef3260b5964",
|
|
@@ -820,7 +814,7 @@
|
|
|
820
814
|
"gui.set": [
|
|
821
815
|
{
|
|
822
816
|
"sourceHash": "0b505e5f92fd4aff",
|
|
823
|
-
"ts": "const node = gui.get_node(\"my_box_node\");\nconst node_position = gui.get(node, \"position\")
|
|
817
|
+
"ts": "const node = gui.get_node(\"my_box_node\");\nconst node_position = gui.get(node, \"position\");\ngui.set(node, \"position.x\", node_position.x + 128);"
|
|
824
818
|
},
|
|
825
819
|
{
|
|
826
820
|
"sourceHash": "8ed6f5c059ba2496",
|
|
@@ -828,7 +822,7 @@
|
|
|
828
822
|
},
|
|
829
823
|
{
|
|
830
824
|
"sourceHash": "2a8317babd507565",
|
|
831
|
-
"ts": "const node = gui.get_node(\"my_box_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 });"
|
|
825
|
+
"ts": "const node = gui.get_node(\"my_box_node\");\ngui.set(node, hash(\"tint\"), vmath.vector4(1, 0, 0, 1));\n// matrix4 is also supported\ngui.set(node, hash(\"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, hash(\"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, hash(\"light_matrix_array\"), vmath.matrix4(), { index: 4 });\n// update a sub-element in a constant\ngui.set(node, hash(\"tint.x\"), 1);\n// update a sub-element in an array constant at position 4\ngui.set(node, hash(\"tint_array.x\"), 1, { index: 4 });"
|
|
832
826
|
},
|
|
833
827
|
{
|
|
834
828
|
"sourceHash": "b52d73e25b02e93f",
|
|
@@ -903,12 +897,6 @@
|
|
|
903
897
|
"ts": "// Load an image from an URL as a buffer and create a texture resource from it:\nconst imgurl = \"http://www.site.com/image.png\";\nhttp.request(imgurl, \"GET\", (self, id, response) => {\n const img =\n response.response !== undefined\n ? image.load_buffer(response.response, { flip_vertically: true })\n : undefined;\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGBA;\n if (img !== undefined && format !== undefined) {\n const tparams = {\n width: img.width,\n height: img.height,\n type: graphics.TEXTURE_TYPE_2D,\n format,\n };\n\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams, img.buffer);\n // Apply the texture to a model\n go.set(\"/go1#model\", \"texture0\", my_texture_id);\n }\n});"
|
|
904
898
|
}
|
|
905
899
|
],
|
|
906
|
-
"init": [
|
|
907
|
-
{
|
|
908
|
-
"sourceHash": "70267e467e6e247e",
|
|
909
|
-
"ts": "export default defineScript({\n init() {\n // set up useful data\n return { my_value: 1 };\n },\n});"
|
|
910
|
-
}
|
|
911
|
-
],
|
|
912
900
|
"json.decode": [
|
|
913
901
|
{
|
|
914
902
|
"sourceHash": "8dcdd6f81ef65528",
|
|
@@ -1117,36 +1105,6 @@
|
|
|
1117
1105
|
"ts": "const my_url = msg.url(\"#my_component\");\nprint(my_url); // => url: [current_collection:/my_instance#my_component]\n\nconst my_collection_url = msg.url(\"my_collection:/my_sub_collection/my_instance#my_component\");\nprint(my_collection_url); // => url: [my_collection:/my_sub_collection/my_instance#my_component]\n\nconst my_socket_url = msg.url(\"my_socket:\");\nprint(my_socket_url); // => url: [my_collection:]"
|
|
1118
1106
|
}
|
|
1119
1107
|
],
|
|
1120
|
-
"on_input": [
|
|
1121
|
-
{
|
|
1122
|
-
"sourceHash": "86c70cf4ccb7381e",
|
|
1123
|
-
"ts": "// This example demonstrates how a game object instance can be moved as a response to user input.\nexport default defineScript({\n init() {\n // acquire input focus\n msg.post(\".\", \"acquire_input_focus\");\n return {\n // maximum speed the instance can be moved\n max_speed: 2,\n // velocity of the instance, initially zero\n velocity: vmath.vector3(),\n };\n },\n\n update(self, dt) {\n // move the instance\n go.set_position(go.get_position().add(self.velocity.mul(dt)));\n },\n\n on_input(self, action_id, action) {\n // check for movement input\n if (action_id === hash(\"right\")) {\n if (action.released) {\n // reset velocity if input was released\n self.velocity = vmath.vector3();\n } else {\n // update velocity\n self.velocity = vmath.vector3((action.value ?? 0) * self.max_speed, 0, 0);\n }\n }\n },\n});"
|
|
1124
|
-
},
|
|
1125
|
-
{
|
|
1126
|
-
"sourceHash": "cc835ea429adc693",
|
|
1127
|
-
"ts": "export default defineGuiScript({\n init(): { my_value: number | undefined } {\n return { my_value: undefined };\n },\n\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});"
|
|
1128
|
-
}
|
|
1129
|
-
],
|
|
1130
|
-
"on_message": [
|
|
1131
|
-
{
|
|
1132
|
-
"sourceHash": "d5850f2009394171",
|
|
1133
|
-
"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});"
|
|
1134
|
-
},
|
|
1135
|
-
{
|
|
1136
|
-
"sourceHash": "9f37896589565629",
|
|
1137
|
-
"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\"), important_value: 0 };\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 && typeof message.important_value === \"number\") {\n // use the data in some way\n self.important_value = message.important_value;\n }\n },\n});"
|
|
1138
|
-
}
|
|
1139
|
-
],
|
|
1140
|
-
"on_reload": [
|
|
1141
|
-
{
|
|
1142
|
-
"sourceHash": "ba39c0b0d5170ccb",
|
|
1143
|
-
"ts": "// This example demonstrates how to tweak the speed of a game object instance that is moved on user input.\nexport default defineScript({\n init() {\n // acquire input focus\n msg.post(\".\", \"acquire_input_focus\");\n return {\n // maximum speed the instance can be moved, this value is tweaked in the on_reload function below\n max_speed: 2,\n // velocity of the instance, initially zero\n velocity: vmath.vector3(),\n };\n },\n\n update(self, dt) {\n // move the instance\n go.set_position(go.get_position().add(self.velocity.mul(dt)));\n },\n\n on_input(self, action_id, action) {\n // check for movement input\n if (action_id === hash(\"right\")) {\n if (action.released) {\n // reset velocity if input was released\n self.velocity = vmath.vector3();\n } else {\n // update velocity\n self.velocity = vmath.vector3((action.value ?? 0) * self.max_speed, 0, 0);\n }\n }\n },\n\n on_reload(self) {\n // edit this value and reload the script component\n self.max_speed = 100;\n },\n});"
|
|
1144
|
-
},
|
|
1145
|
-
{
|
|
1146
|
-
"sourceHash": "e89fe0d0bd51ed98",
|
|
1147
|
-
"ts": "export default defineGuiScript({\n init() {\n return { my_original_color: gui.get_color(gui.get_node(\"my_node\")) };\n },\n\n on_reload(self) {\n // restore some color (or similar)\n gui.set_color(gui.get_node(\"my_node\"), self.my_original_color);\n },\n});"
|
|
1148
|
-
}
|
|
1149
|
-
],
|
|
1150
1108
|
"particlefx.play": [
|
|
1151
1109
|
{
|
|
1152
1110
|
"sourceHash": "01a21997b47ac4fc",
|
|
@@ -2151,7 +2109,7 @@
|
|
|
2151
2109
|
"sys.load_buffer_async": [
|
|
2152
2110
|
{
|
|
2153
2111
|
"sourceHash": "91d84e7dc569ae20",
|
|
2154
|
-
"ts": "function my_callback(self: unknown, request_id: unknown, result: unknown) {\n const { status, buf } = result as { status: number; buf:
|
|
2112
|
+
"ts": "function my_callback(self: unknown, request_id: unknown, result: unknown) {\n const { status, buf } = result as { status: number; buf: ReturnType<typeof sys.load_buffer> };\n if (status === sys.REQUEST_STATUS_FINISHED) {\n resource.set_texture(\"/my_texture\", { type: graphics.TEXTURE_TYPE_2D, width: 128, height: 128, format: graphics.TEXTURE_FORMAT_RGBA }, buf);\n }\n}\n\nconst my_request = sys.load_buffer_async(\"/assets/my_level_data.bin\", my_callback);"
|
|
2155
2113
|
},
|
|
2156
2114
|
{
|
|
2157
2115
|
"sourceHash": "5545b8901e6ec4c5",
|
|
@@ -2318,16 +2276,6 @@
|
|
|
2318
2276
|
"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 triggered = timer.trigger(self.handle);\n if (!triggered) {\n print(\"the timer is already cancelled or complete\");\n }\n}"
|
|
2319
2277
|
}
|
|
2320
2278
|
],
|
|
2321
|
-
"update": [
|
|
2322
|
-
{
|
|
2323
|
-
"sourceHash": "1019c7620d797753",
|
|
2324
|
-
"ts": "// This example demonstrates how to move a game object instance through the script component:\nexport default defineScript({\n init() {\n // set initial velocity to be 1 along world x-axis\n return { my_velocity: vmath.vector3(1, 0, 0) };\n },\n\n update(self, dt) {\n // move the game object instance\n go.set_position(go.get_position().add(self.my_velocity.mul(dt)));\n },\n});"
|
|
2325
|
-
},
|
|
2326
|
-
{
|
|
2327
|
-
"sourceHash": "f4f87939dbdd5fc3",
|
|
2328
|
-
"ts": "// This example demonstrates how to update a text node that displays game score\n// in a counting fashion. It is assumed that the gui component receives messages\n// from the game when a new score is to be shown.\nexport default defineGuiScript({\n init() {\n return {\n // fetch the score text node for later use (assumes it is called \"score\")\n score_node: gui.get_node(\"score\"),\n // keep track of the current score counted up so far\n current_score: 0,\n // keep track of the target score we should count up to\n target_score: 0,\n // how fast we will update the score, in score/second\n score_update_speed: 1,\n };\n },\n\n update(self, dt) {\n // check if target score is more than current score\n if (self.current_score < self.target_score) {\n // increment current score according to the speed\n self.current_score = self.current_score + dt * self.score_update_speed;\n // check if we went past the target score, clamp current score in that case\n if (self.current_score > self.target_score) {\n self.current_score = self.target_score;\n }\n // update the score text node\n gui.set_text(self.score_node, \"\" + math.floor(self.current_score));\n }\n },\n\n on_message(self, message_id, message) {\n // check the message\n if (message_id === hash(\"set_score\") && typeof message.score === \"number\") {\n self.target_score = message.score;\n }\n },\n});"
|
|
2329
|
-
}
|
|
2330
|
-
],
|
|
2331
2279
|
"vmath.clamp": [
|
|
2332
2280
|
{
|
|
2333
2281
|
"sourceHash": "ce47102e76e3186d",
|
package/generated/b2d_world.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ declare global {
|
|
|
26
26
|
* @param filter - optional query filter
|
|
27
27
|
* @param max_results - optional maximum result count
|
|
28
28
|
*/
|
|
29
|
-
function cast_ray(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_cast_hit[], b2d.tree_stats]>;
|
|
29
|
+
function cast_ray<Backend extends "v2" = "v2">(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_cast_hit[], b2d.tree_stats]>;
|
|
30
30
|
/**
|
|
31
31
|
* The translation is the ray displacement from `origin`. Result order is not
|
|
32
32
|
* guaranteed by Box2D.
|
|
@@ -37,7 +37,7 @@ declare global {
|
|
|
37
37
|
* @param filter - optional query filter
|
|
38
38
|
* @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
|
|
39
39
|
*/
|
|
40
|
-
function cast_ray(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_cast_hit[], b2d.tree_stats]>;
|
|
40
|
+
function cast_ray<Backend extends "v3">(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_cast_hit[], b2d.tree_stats]>;
|
|
41
41
|
/**
|
|
42
42
|
* Cast a ray and return the closest hit.
|
|
43
43
|
*
|
|
@@ -47,7 +47,7 @@ declare global {
|
|
|
47
47
|
* @param filter - optional query filter
|
|
48
48
|
* @returns closest hit, or `nil`
|
|
49
49
|
*/
|
|
50
|
-
function cast_ray_closest(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.fixture_cast_hit | undefined;
|
|
50
|
+
function cast_ray_closest<Backend extends "v2" = "v2">(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.fixture_cast_hit | undefined;
|
|
51
51
|
/**
|
|
52
52
|
* The translation is the ray displacement from `origin`.
|
|
53
53
|
*
|
|
@@ -57,7 +57,7 @@ declare global {
|
|
|
57
57
|
* @param filter - optional query filter
|
|
58
58
|
* @returns closest hit, or `nil`
|
|
59
59
|
*/
|
|
60
|
-
function cast_ray_closest(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.shape_cast_hit | undefined;
|
|
60
|
+
function cast_ray_closest<Backend extends "v3">(world: Opaque<"b2World">, origin: Vector3, translation: Vector3, filter?: b2d.query_filter): b2d.shape_cast_hit | undefined;
|
|
61
61
|
/**
|
|
62
62
|
* Uses Box2D v2 time-of-impact for fixture child shapes that support distance proxies.
|
|
63
63
|
* Grid fixture children are skipped.
|
|
@@ -68,7 +68,7 @@ declare global {
|
|
|
68
68
|
* @param filter - optional query filter
|
|
69
69
|
* @param max_results - optional maximum result count
|
|
70
70
|
*/
|
|
71
|
-
function cast_shape(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_cast_hit[], b2d.tree_stats]>;
|
|
71
|
+
function cast_shape<Backend extends "v2" = "v2">(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_cast_hit[], b2d.tree_stats]>;
|
|
72
72
|
/**
|
|
73
73
|
* The translation is the shape displacement.
|
|
74
74
|
*
|
|
@@ -78,7 +78,7 @@ declare global {
|
|
|
78
78
|
* @param filter - optional query filter
|
|
79
79
|
* @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
|
|
80
80
|
*/
|
|
81
|
-
function cast_shape(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_cast_hit[], b2d.tree_stats]>;
|
|
81
|
+
function cast_shape<Backend extends "v3">(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, translation: Vector3, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_cast_hit[], b2d.tree_stats]>;
|
|
82
82
|
/**
|
|
83
83
|
* Collide a mover capsule against the world.
|
|
84
84
|
*
|
|
@@ -220,7 +220,7 @@ declare global {
|
|
|
220
220
|
* - `fixtures` — overlapping fixtures. **⚠️ `index` is 1-based; passed to Defold unchanged.**
|
|
221
221
|
* - `stats` — broad-phase query statistics
|
|
222
222
|
*/
|
|
223
|
-
function overlap_aabb(world: Opaque<"b2World">, aabb: b2d.aabb, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_info[], b2d.tree_stats]>;
|
|
223
|
+
function overlap_aabb<Backend extends "v2" = "v2">(world: Opaque<"b2World">, aabb: b2d.aabb, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_info[], b2d.tree_stats]>;
|
|
224
224
|
/**
|
|
225
225
|
* Find shapes overlapping an AABB.
|
|
226
226
|
*
|
|
@@ -229,7 +229,7 @@ declare global {
|
|
|
229
229
|
* @param filter - optional query filter
|
|
230
230
|
* @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
|
|
231
231
|
*/
|
|
232
|
-
function overlap_aabb(world: Opaque<"b2World">, aabb: b2d.aabb, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_info[], b2d.tree_stats]>;
|
|
232
|
+
function overlap_aabb<Backend extends "v3">(world: Opaque<"b2World">, aabb: b2d.aabb, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_info[], b2d.tree_stats]>;
|
|
233
233
|
/**
|
|
234
234
|
* Overlap a shape.
|
|
235
235
|
*
|
|
@@ -241,7 +241,7 @@ declare global {
|
|
|
241
241
|
* - `fixtures` — overlapping fixtures. **⚠️ `index` is 1-based; passed to Defold unchanged.**
|
|
242
242
|
* - `stats` — broad-phase query statistics
|
|
243
243
|
*/
|
|
244
|
-
function overlap_shape(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_info[], b2d.tree_stats]>;
|
|
244
|
+
function overlap_shape<Backend extends "v2" = "v2">(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.fixture_info[], b2d.tree_stats]>;
|
|
245
245
|
/**
|
|
246
246
|
* Find shapes overlapping a shape proxy.
|
|
247
247
|
*
|
|
@@ -250,7 +250,7 @@ declare global {
|
|
|
250
250
|
* @param filter - optional query filter
|
|
251
251
|
* @param max_results - optional maximum result count. Omit or pass 0 for unlimited results.
|
|
252
252
|
*/
|
|
253
|
-
function overlap_shape(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_info[], b2d.tree_stats]>;
|
|
253
|
+
function overlap_shape<Backend extends "v3">(world: Opaque<"b2World">, shape: { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; hx: number; hy: number; center?: Vector3; angle?: number } | { type: typeof b2d.shape.SHAPE_TYPE_POLYGON | typeof b2d.shape.SHAPE_TYPE_BOX; vertices: Vector3[] } | { type: typeof b2d.shape.SHAPE_TYPE_CIRCLE; radius: number; center?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CAPSULE; radius: number; center1: Vector3; center2: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_EDGE | typeof b2d.shape.SHAPE_TYPE_SEGMENT; v1: Vector3; v2: Vector3; v0?: Vector3; v3?: Vector3 } | { type: typeof b2d.shape.SHAPE_TYPE_CHAIN; vertices: Vector3[]; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, filter?: b2d.query_filter, max_results?: number): LuaMultiReturn<[b2d.shape_info[], b2d.tree_stats]>;
|
|
254
254
|
/**
|
|
255
255
|
* Rebuild the static broad-phase tree.
|
|
256
256
|
*
|
package/generated/buffer.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare global {
|
|
|
6
6
|
* Functions for manipulating buffers and streams
|
|
7
7
|
*/
|
|
8
8
|
namespace buffer {
|
|
9
|
-
type buffer_data = Opaque<"buffer"
|
|
9
|
+
type buffer_data = Opaque<"buffer"> & { length: LuaLengthMethod<number> };
|
|
10
10
|
type buffer_stream = Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> };
|
|
11
11
|
type ValueType = typeof buffer.VALUE_TYPE_FLOAT32 | typeof buffer.VALUE_TYPE_INT16 | typeof buffer.VALUE_TYPE_INT32 | typeof buffer.VALUE_TYPE_INT64 | typeof buffer.VALUE_TYPE_INT8 | typeof buffer.VALUE_TYPE_UINT16 | typeof buffer.VALUE_TYPE_UINT32 | typeof buffer.VALUE_TYPE_UINT64 | typeof buffer.VALUE_TYPE_UINT8;
|
|
12
12
|
type VALUE_TYPE = typeof buffer.VALUE_TYPE_FLOAT32 | typeof buffer.VALUE_TYPE_INT16 | typeof buffer.VALUE_TYPE_INT32 | typeof buffer.VALUE_TYPE_INT64 | typeof buffer.VALUE_TYPE_INT8 | typeof buffer.VALUE_TYPE_UINT16 | typeof buffer.VALUE_TYPE_UINT32 | typeof buffer.VALUE_TYPE_UINT64 | typeof buffer.VALUE_TYPE_UINT8;
|
|
@@ -71,7 +71,7 @@ declare global {
|
|
|
71
71
|
* buffer.copy_buffer(dstbuffer, 0, srcbuffer, element_count - 10, 10);
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
|
-
function copy_buffer(dst: Opaque<"buffer"
|
|
74
|
+
function copy_buffer(dst: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, dstoffset: number, src: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, srcoffset: number, count: number): void;
|
|
75
75
|
/**
|
|
76
76
|
* Copy a specified amount of data from one stream to another.
|
|
77
77
|
* The value type and size must match between source and destination streams.
|
|
@@ -132,15 +132,15 @@ declare global {
|
|
|
132
132
|
* });
|
|
133
133
|
* ```
|
|
134
134
|
*/
|
|
135
|
-
function create(element_count: number, declaration: ({ name: Hash | string; type: buffer.VALUE_TYPE; count: number })[]): Opaque<"buffer"
|
|
135
|
+
function create(element_count: number, declaration: [({ name: Hash | string; type: buffer.VALUE_TYPE; count: number }), ...({ name: Hash | string; type: buffer.VALUE_TYPE; count: number })[]]): Opaque<"buffer"> & { length: LuaLengthMethod<number> };
|
|
136
136
|
/**
|
|
137
|
-
* Get a copy of all the bytes
|
|
137
|
+
* Get a copy of all the bytes of the buffer, every stream included, as a Lua string.
|
|
138
138
|
*
|
|
139
139
|
* @param buffer - the source buffer
|
|
140
|
-
* @param stream_name - the name of the stream
|
|
140
|
+
* @param stream_name - the name of the stream; the engine ignores it and returns every byte of the buffer
|
|
141
141
|
* @returns the buffer data as a Lua string
|
|
142
142
|
*/
|
|
143
|
-
function get_bytes(buffer: Opaque<"buffer"
|
|
143
|
+
function get_bytes(buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, stream_name?: Hash | string): string;
|
|
144
144
|
/**
|
|
145
145
|
* Get a named metadata entry from a buffer along with its type.
|
|
146
146
|
*
|
|
@@ -156,7 +156,7 @@ declare global {
|
|
|
156
156
|
* if (values) print(`${values.length} values in 'somefloats'`);
|
|
157
157
|
* ```
|
|
158
158
|
*/
|
|
159
|
-
function get_metadata(buf: Opaque<"buffer"
|
|
159
|
+
function get_metadata(buf: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, metadata_name: Hash | string): LuaMultiReturn<[number[] | undefined, buffer.VALUE_TYPE | undefined]>;
|
|
160
160
|
/**
|
|
161
161
|
* Get a specified stream from a buffer.
|
|
162
162
|
*
|
|
@@ -164,7 +164,7 @@ declare global {
|
|
|
164
164
|
* @param stream_name - the stream name
|
|
165
165
|
* @returns the data stream
|
|
166
166
|
*/
|
|
167
|
-
function get_stream(buffer: Opaque<"buffer"
|
|
167
|
+
function get_stream(buffer: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> };
|
|
168
168
|
/**
|
|
169
169
|
* Creates or updates a metadata array entry on a buffer.
|
|
170
170
|
* The value type and count given when updating the entry should match those used when first creating it.
|
|
@@ -185,7 +185,7 @@ declare global {
|
|
|
185
185
|
* buffer.set_metadata(buf, hash("somefloats"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);
|
|
186
186
|
* ```
|
|
187
187
|
*/
|
|
188
|
-
function set_metadata(buf: Opaque<"buffer"
|
|
188
|
+
function set_metadata(buf: Opaque<"buffer"> & { length: LuaLengthMethod<number> }, metadata_name: Hash | string, values: [number, ...number[]], value_type: Exclude<buffer.VALUE_TYPE, typeof buffer.VALUE_TYPE_INT64 | typeof buffer.VALUE_TYPE_UINT64>): void;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
@@ -298,7 +298,7 @@ declare global {
|
|
|
298
298
|
* @param object - collision object
|
|
299
299
|
* @returns rigid body state
|
|
300
300
|
*/
|
|
301
|
-
function is_rigid_body(object: Opaque<"btCollisionObject" | "btRigidBody">):
|
|
301
|
+
function is_rigid_body(object: Opaque<"btCollisionObject" | "btRigidBody">): object is Opaque<"btRigidBody">;
|
|
302
302
|
/**
|
|
303
303
|
* Test whether the object is static
|
|
304
304
|
*
|
|
@@ -246,7 +246,16 @@ declare global {
|
|
|
246
246
|
* @param params - local frames and options
|
|
247
247
|
* @returns cone-twist constraint
|
|
248
248
|
*/
|
|
249
|
-
function create_cone_twist(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.cone_twist_params): bullet3d.constraint.btTypedConstraint;
|
|
249
|
+
function create_cone_twist(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.cone_twist_params & Required<Pick<bullet3d.constraint.cone_twist_params, "frame_b_position" | "frame_b_rotation">>): bullet3d.constraint.btTypedConstraint;
|
|
250
|
+
/**
|
|
251
|
+
* The world is derived from `body_a`.
|
|
252
|
+
*
|
|
253
|
+
* @param body_a - first body
|
|
254
|
+
* @param body_b - second body or world
|
|
255
|
+
* @param params - local frames and options
|
|
256
|
+
* @returns cone-twist constraint
|
|
257
|
+
*/
|
|
258
|
+
function create_cone_twist(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.cone_twist_params): bullet3d.constraint.btTypedConstraint;
|
|
250
259
|
/**
|
|
251
260
|
* The params table requires local frame A and, for a two-body constraint,
|
|
252
261
|
* local frame B. It optionally accepts `collide_connected`. The world is
|
|
@@ -259,7 +268,20 @@ declare global {
|
|
|
259
268
|
* @param params - local frames and options
|
|
260
269
|
* @returns generic 6-DOF constraint
|
|
261
270
|
*/
|
|
262
|
-
function create_generic_6dof(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.generic_6dof_params): bullet3d.constraint.btTypedConstraint;
|
|
271
|
+
function create_generic_6dof(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.generic_6dof_params & Required<Pick<bullet3d.constraint.generic_6dof_params, "frame_b_position" | "frame_b_rotation">>): bullet3d.constraint.btTypedConstraint;
|
|
272
|
+
/**
|
|
273
|
+
* The params table requires local frame A and, for a two-body constraint,
|
|
274
|
+
* local frame B. It optionally accepts `collide_connected`. The world is
|
|
275
|
+
* derived from `body_a`. The active 6-DOF solver ignores its legacy
|
|
276
|
+
* linear-reference-frame selector, so that field is rejected rather than
|
|
277
|
+
* silently accepted.
|
|
278
|
+
*
|
|
279
|
+
* @param body_a - first body
|
|
280
|
+
* @param body_b - second body or world
|
|
281
|
+
* @param params - local frames and options
|
|
282
|
+
* @returns generic 6-DOF constraint
|
|
283
|
+
*/
|
|
284
|
+
function create_generic_6dof(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.generic_6dof_params): bullet3d.constraint.btTypedConstraint;
|
|
263
285
|
/**
|
|
264
286
|
* Both bodies and both local frames are required. The params table optionally
|
|
265
287
|
* accepts `collide_connected`. The world is derived from `body_a`. The active
|
|
@@ -339,7 +361,44 @@ declare global {
|
|
|
339
361
|
* });
|
|
340
362
|
* ```
|
|
341
363
|
*/
|
|
342
|
-
function create_hinge(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.hinge_params): bullet3d.constraint.btTypedConstraint;
|
|
364
|
+
function create_hinge(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.hinge_params & Required<Pick<bullet3d.constraint.hinge_params, "frame_b_position" | "frame_b_rotation">>): bullet3d.constraint.btTypedConstraint;
|
|
365
|
+
/**
|
|
366
|
+
* The world is derived from `body_a`.
|
|
367
|
+
*
|
|
368
|
+
* @param body_a - first body
|
|
369
|
+
* @param body_b - second body or world
|
|
370
|
+
* @param params - local frames and options
|
|
371
|
+
* @returns hinge constraint
|
|
372
|
+
* @example
|
|
373
|
+
* ```ts
|
|
374
|
+
* // Create a motorized hinge with a 90-degree range:
|
|
375
|
+
* export default defineScript({
|
|
376
|
+
* init() {
|
|
377
|
+
* const body_a = bullet3d.get_rigid_body("/door#collisionobject");
|
|
378
|
+
* const body_b = bullet3d.get_rigid_body("/frame#collisionobject");
|
|
379
|
+
* let hinge: bullet3d.constraint.btTypedConstraint | undefined;
|
|
380
|
+
* if (body_a !== undefined) {
|
|
381
|
+
* hinge = bullet3d.constraint.create_hinge(body_a, body_b, {
|
|
382
|
+
* frame_a_position: vmath.vector3(-0.5, 0, 0),
|
|
383
|
+
* frame_a_rotation: vmath.quat(),
|
|
384
|
+
* frame_b_position: vmath.vector3(0.5, 0, 0),
|
|
385
|
+
* frame_b_rotation: vmath.quat(),
|
|
386
|
+
* });
|
|
387
|
+
* bullet3d.constraint.set_hinge_limits(hinge, -math.pi / 4, math.pi / 4);
|
|
388
|
+
* bullet3d.constraint.set_hinge_motor(hinge, true, 1.5, 2.5);
|
|
389
|
+
* }
|
|
390
|
+
* return { hinge };
|
|
391
|
+
* },
|
|
392
|
+
*
|
|
393
|
+
* final(self) {
|
|
394
|
+
* if (self.hinge !== undefined && bullet3d.constraint.is_valid(self.hinge)) {
|
|
395
|
+
* bullet3d.constraint.destroy(self.hinge);
|
|
396
|
+
* }
|
|
397
|
+
* },
|
|
398
|
+
* });
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
function create_hinge(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.hinge_params): bullet3d.constraint.btTypedConstraint;
|
|
343
402
|
/**
|
|
344
403
|
* Both bodies are required. Its initial linear suspension travel is one Defold
|
|
345
404
|
* unit in either direction. The world is derived from `body_a`.
|
|
@@ -383,7 +442,50 @@ declare global {
|
|
|
383
442
|
* });
|
|
384
443
|
* ```
|
|
385
444
|
*/
|
|
386
|
-
function create_point_to_point(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.point_to_point_params): bullet3d.constraint.btTypedConstraint;
|
|
445
|
+
function create_point_to_point(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.point_to_point_params & Required<Pick<bullet3d.constraint.point_to_point_params, "pivot_b">>): bullet3d.constraint.btTypedConstraint;
|
|
446
|
+
/**
|
|
447
|
+
* The world is derived from `body_a`; both bodies must belong to that same world.
|
|
448
|
+
*
|
|
449
|
+
* @param body_a - first body
|
|
450
|
+
* @param body_b - second body or world
|
|
451
|
+
* @param params - pivots and options
|
|
452
|
+
* @returns point-to-point constraint
|
|
453
|
+
* @example
|
|
454
|
+
* ```ts
|
|
455
|
+
* // Join two bodies at matching local pivots and explicitly destroy the
|
|
456
|
+
* // constraint when the script is finalized:
|
|
457
|
+
* export default defineScript({
|
|
458
|
+
* init() {
|
|
459
|
+
* const body_a = bullet3d.get_rigid_body("/body_a#collisionobject");
|
|
460
|
+
* const body_b = bullet3d.get_rigid_body("/body_b#collisionobject");
|
|
461
|
+
* let constraint: bullet3d.constraint.btTypedConstraint | undefined;
|
|
462
|
+
* if (body_a !== undefined) {
|
|
463
|
+
* constraint = bullet3d.constraint.create_point_to_point(body_a, body_b, {
|
|
464
|
+
* pivot_a: vmath.vector3(0.5, 0, 0),
|
|
465
|
+
* pivot_b: vmath.vector3(-0.5, 0, 0),
|
|
466
|
+
* });
|
|
467
|
+
* }
|
|
468
|
+
* return { constraint };
|
|
469
|
+
* },
|
|
470
|
+
*
|
|
471
|
+
* final(self) {
|
|
472
|
+
* if (self.constraint !== undefined && bullet3d.constraint.is_valid(self.constraint)) {
|
|
473
|
+
* bullet3d.constraint.destroy(self.constraint);
|
|
474
|
+
* }
|
|
475
|
+
* },
|
|
476
|
+
* });
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
function create_point_to_point(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.point_to_point_params): bullet3d.constraint.btTypedConstraint;
|
|
480
|
+
/**
|
|
481
|
+
* The world is derived from `body_a`.
|
|
482
|
+
*
|
|
483
|
+
* @param body_a - first body
|
|
484
|
+
* @param body_b - second body or world
|
|
485
|
+
* @param params - local frames and options
|
|
486
|
+
* @returns slider constraint
|
|
487
|
+
*/
|
|
488
|
+
function create_slider(body_a: Opaque<"btRigidBody">, body_b: Opaque<"btRigidBody"> | undefined, params: bullet3d.constraint.slider_params & Required<Pick<bullet3d.constraint.slider_params, "frame_b_position" | "frame_b_rotation">>): bullet3d.constraint.btTypedConstraint;
|
|
387
489
|
/**
|
|
388
490
|
* The world is derived from `body_a`.
|
|
389
491
|
*
|
|
@@ -392,7 +494,7 @@ declare global {
|
|
|
392
494
|
* @param params - local frames and options
|
|
393
495
|
* @returns slider constraint
|
|
394
496
|
*/
|
|
395
|
-
function create_slider(body_a: Opaque<"btRigidBody">, body_b:
|
|
497
|
+
function create_slider(body_a: Opaque<"btRigidBody">, body_b: undefined, params: bullet3d.constraint.slider_params): bullet3d.constraint.btTypedConstraint;
|
|
396
498
|
/**
|
|
397
499
|
* Both bodies are required. The world is derived from `body_a`.
|
|
398
500
|
*
|
|
@@ -567,7 +669,7 @@ declare global {
|
|
|
567
669
|
* @param constraint - slider constraint
|
|
568
670
|
* @param motor - `linear` or `angular`
|
|
569
671
|
*/
|
|
570
|
-
function get_slider_motor(constraint: bullet3d.constraint.btTypedConstraint, motor:
|
|
672
|
+
function get_slider_motor(constraint: bullet3d.constraint.btTypedConstraint, motor: "linear" | "angular"): LuaMultiReturn<[boolean, number, number]>;
|
|
571
673
|
/**
|
|
572
674
|
* Get the current slider position
|
|
573
675
|
*
|
|
@@ -781,7 +883,7 @@ declare global {
|
|
|
781
883
|
* @param target_velocity - linear or angular target velocity
|
|
782
884
|
* @param max_force - non-negative maximum linear force or angular torque
|
|
783
885
|
*/
|
|
784
|
-
function set_slider_motor(constraint: bullet3d.constraint.btTypedConstraint, motor:
|
|
886
|
+
function set_slider_motor(constraint: bullet3d.constraint.btTypedConstraint, motor: "linear" | "angular", enabled: boolean, target_velocity: number, max_force: number): void;
|
|
785
887
|
/**
|
|
786
888
|
* Generic spring 6-DOF constraints use a scale-independent damping factor from
|
|
787
889
|
* 0 to 1, where 1 means no damping. Hinge2 constraints use a damping coefficient
|
|
@@ -11,7 +11,7 @@ declare global {
|
|
|
11
11
|
*/
|
|
12
12
|
namespace bullet3d.shape {
|
|
13
13
|
type btCollisionShape = Opaque<"btCollisionShape">;
|
|
14
|
-
type definition = { type: bullet3d.shape.
|
|
14
|
+
type definition = { type: typeof bullet3d.shape.SHAPE_TYPE_SPHERE; diameter: number; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: typeof bullet3d.shape.SHAPE_TYPE_BOX; dimensions: Vector3; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: typeof bullet3d.shape.SHAPE_TYPE_CAPSULE; diameter: number; height: number; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion } | { type: typeof bullet3d.shape.SHAPE_TYPE_HULL; vertices: Vector3[]; position?: Vector3; rotation?: Quaternion; target_rotation?: Quaternion };
|
|
15
15
|
type SHAPE_TYPE = typeof bullet3d.shape.SHAPE_TYPE_BOX | typeof bullet3d.shape.SHAPE_TYPE_CAPSULE | typeof bullet3d.shape.SHAPE_TYPE_HULL | typeof bullet3d.shape.SHAPE_TYPE_MESH | typeof bullet3d.shape.SHAPE_TYPE_SPHERE;
|
|
16
16
|
/**
|
|
17
17
|
* Box shape type Value `1`. Shape data contains positive vector3 `dimensions` in Defold units.
|
|
@@ -66,7 +66,7 @@ declare global {
|
|
|
66
66
|
* @param shape - shape handle
|
|
67
67
|
* @returns typed shape geometry in Defold units
|
|
68
68
|
*/
|
|
69
|
-
function get_shape(shape: bullet3d.shape.btCollisionShape): bullet3d.shape.definition;
|
|
69
|
+
function get_shape(shape: bullet3d.shape.btCollisionShape): bullet3d.shape.definition | { type: typeof bullet3d.shape.SHAPE_TYPE_MESH };
|
|
70
70
|
/**
|
|
71
71
|
* Get the normalized Defold shape type.
|
|
72
72
|
*
|