@defold-typescript/types 0.39.0 → 0.41.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 (227) hide show
  1. package/api-availability.json +4024 -716
  2. package/api-migrations.json +27 -0
  3. package/api-signatures.json +18118 -10264
  4. package/api-targets.json +448 -11
  5. package/examples/translations.json +619 -148
  6. package/fixtures/messages_doc.json +96 -0
  7. package/generated/b2d.d.ts +680 -4
  8. package/generated/b2d_body.d.ts +29 -103
  9. package/generated/b2d_chain.d.ts +5 -6
  10. package/generated/b2d_fixture.d.ts +34 -38
  11. package/generated/b2d_joint.d.ts +503 -25
  12. package/generated/b2d_shape.d.ts +199 -14
  13. package/generated/b2d_world.d.ts +57 -63
  14. package/generated/buffer.d.ts +33 -29
  15. package/generated/builtin-messages.d.ts +7 -1
  16. package/generated/bullet3d.d.ts +91 -0
  17. package/generated/bullet3d_collision_object.d.ts +433 -0
  18. package/generated/bullet3d_constraint.d.ts +818 -0
  19. package/generated/bullet3d_rigid_body.d.ts +429 -0
  20. package/generated/bullet3d_shape.d.ts +123 -0
  21. package/generated/bullet3d_world.d.ts +492 -0
  22. package/generated/camera.d.ts +31 -34
  23. package/generated/collectionfactory.d.ts +26 -27
  24. package/generated/collectionproxy.d.ts +22 -6
  25. package/generated/compute.d.ts +12 -238
  26. package/generated/crash.d.ts +24 -10
  27. package/generated/editor-vm/http.d.ts +90 -7
  28. package/generated/editor-vm/image.d.ts +7 -7
  29. package/generated/editor-vm/json.d.ts +11 -0
  30. package/generated/editor-vm/localization.d.ts +7 -7
  31. package/generated/editor-vm/tilemap_tiles.d.ts +56 -10
  32. package/generated/editor-vm/zip.d.ts +28 -0
  33. package/generated/editor.d.ts +1496 -430
  34. package/generated/factory.d.ts +21 -25
  35. package/generated/font.d.ts +64 -22
  36. package/generated/go.d.ts +243 -186
  37. package/generated/graphics.d.ts +374 -84
  38. package/generated/gui.d.ts +282 -492
  39. package/generated/html5.d.ts +5 -3
  40. package/generated/http.d.ts +31 -36
  41. package/generated/image.d.ts +127 -85
  42. package/generated/json.d.ts +34 -16
  43. package/generated/kinds/gui-script.d.ts +8 -0
  44. package/generated/kinds/render-script.d.ts +8 -0
  45. package/generated/kinds/script.d.ts +8 -0
  46. package/generated/label.d.ts +77 -7
  47. package/generated/liveupdate.d.ts +13 -10
  48. package/generated/material.d.ts +312 -360
  49. package/generated/model.d.ts +72 -42
  50. package/generated/particlefx.d.ts +19 -28
  51. package/generated/physics.d.ts +378 -144
  52. package/generated/profiler.d.ts +14 -24
  53. package/generated/render.d.ts +294 -297
  54. package/generated/resource.d.ts +753 -641
  55. package/generated/socket.d.ts +131 -134
  56. package/generated/sound.d.ts +65 -34
  57. package/generated/sprite.d.ts +39 -17
  58. package/generated/sys.d.ts +237 -182
  59. package/generated/tilemap.d.ts +21 -16
  60. package/generated/timer.d.ts +34 -21
  61. package/generated/versions/defold-1.12.4/b2d_body.d.ts +0 -7
  62. package/generated/versions/defold-1.12.4/buffer.d.ts +18 -17
  63. package/generated/versions/defold-1.12.4/camera.d.ts +23 -23
  64. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +21 -19
  65. package/generated/versions/defold-1.12.4/collectionproxy.d.ts +2 -2
  66. package/generated/versions/defold-1.12.4/crash.d.ts +2 -2
  67. package/generated/versions/defold-1.12.4/factory.d.ts +15 -16
  68. package/generated/versions/defold-1.12.4/go.d.ts +15 -17
  69. package/generated/versions/defold-1.12.4/gui.d.ts +111 -193
  70. package/generated/versions/defold-1.12.4/html5.d.ts +4 -2
  71. package/generated/versions/defold-1.12.4/http.d.ts +4 -15
  72. package/generated/versions/defold-1.12.4/image.d.ts +38 -46
  73. package/generated/versions/defold-1.12.4/index.d.ts +2 -0
  74. package/generated/versions/defold-1.12.4/json.d.ts +10 -6
  75. package/generated/versions/defold-1.12.4/label.d.ts +2 -3
  76. package/generated/versions/defold-1.12.4/liveupdate.d.ts +5 -3
  77. package/generated/versions/defold-1.12.4/model.d.ts +34 -13
  78. package/generated/versions/defold-1.12.4/particlefx.d.ts +2 -5
  79. package/generated/versions/defold-1.12.4/physics.d.ts +82 -78
  80. package/generated/versions/defold-1.12.4/profiler.d.ts +3 -6
  81. package/generated/versions/defold-1.12.4/render.d.ts +160 -132
  82. package/generated/versions/defold-1.12.4/resource.d.ts +212 -209
  83. package/generated/versions/defold-1.12.4/socket.d.ts +45 -61
  84. package/generated/versions/defold-1.12.4/sound.d.ts +11 -11
  85. package/generated/versions/defold-1.12.4/sprite.d.ts +24 -6
  86. package/generated/versions/defold-1.12.4/sys.d.ts +45 -68
  87. package/generated/versions/defold-1.12.4/tilemap.d.ts +18 -11
  88. package/generated/versions/defold-1.12.4/timer.d.ts +5 -3
  89. package/generated/versions/defold-1.12.4/vmath.d.ts +5 -26
  90. package/generated/versions/defold-1.12.4/window.d.ts +1 -16
  91. package/generated/versions/defold-1.13.0/b2d_body.d.ts +10 -55
  92. package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +25 -25
  93. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +188 -5
  94. package/generated/versions/defold-1.13.0/b2d_world.d.ts +16 -10
  95. package/generated/versions/defold-1.13.0/buffer.d.ts +18 -17
  96. package/generated/versions/defold-1.13.0/camera.d.ts +27 -27
  97. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +21 -19
  98. package/generated/versions/defold-1.13.0/collectionproxy.d.ts +2 -2
  99. package/generated/versions/defold-1.13.0/compute.d.ts +1 -70
  100. package/generated/versions/defold-1.13.0/crash.d.ts +2 -2
  101. package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +3 -3
  102. package/generated/versions/defold-1.13.0/editor.d.ts +34 -24
  103. package/generated/versions/defold-1.13.0/factory.d.ts +15 -16
  104. package/generated/versions/defold-1.13.0/go.d.ts +15 -17
  105. package/generated/versions/defold-1.13.0/graphics.d.ts +121 -37
  106. package/generated/versions/defold-1.13.0/gui.d.ts +111 -193
  107. package/generated/versions/defold-1.13.0/html5.d.ts +4 -2
  108. package/generated/versions/defold-1.13.0/http.d.ts +4 -15
  109. package/generated/versions/defold-1.13.0/image.d.ts +38 -46
  110. package/generated/versions/defold-1.13.0/index.d.ts +2 -0
  111. package/generated/versions/defold-1.13.0/json.d.ts +10 -6
  112. package/generated/versions/defold-1.13.0/label.d.ts +2 -3
  113. package/generated/versions/defold-1.13.0/liveupdate.d.ts +7 -5
  114. package/generated/versions/defold-1.13.0/material.d.ts +69 -107
  115. package/generated/versions/defold-1.13.0/model.d.ts +34 -13
  116. package/generated/versions/defold-1.13.0/particlefx.d.ts +2 -5
  117. package/generated/versions/defold-1.13.0/physics.d.ts +82 -78
  118. package/generated/versions/defold-1.13.0/profiler.d.ts +3 -6
  119. package/generated/versions/defold-1.13.0/render.d.ts +160 -132
  120. package/generated/versions/defold-1.13.0/resource.d.ts +217 -210
  121. package/generated/versions/defold-1.13.0/socket.d.ts +45 -61
  122. package/generated/versions/defold-1.13.0/sound.d.ts +11 -11
  123. package/generated/versions/defold-1.13.0/sprite.d.ts +24 -6
  124. package/generated/versions/defold-1.13.0/sys.d.ts +45 -68
  125. package/generated/versions/defold-1.13.0/tilemap.d.ts +18 -11
  126. package/generated/versions/defold-1.13.0/timer.d.ts +5 -3
  127. package/generated/versions/defold-1.13.0/vmath.d.ts +5 -26
  128. package/generated/versions/defold-1.13.0/window.d.ts +1 -16
  129. package/generated/versions/defold-1.13.1/b2d.d.ts +33 -0
  130. package/generated/versions/defold-1.13.1/b2d_body.d.ts +636 -0
  131. package/generated/versions/defold-1.13.1/b2d_chain.d.ts +106 -0
  132. package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +157 -0
  133. package/generated/versions/defold-1.13.1/b2d_joint.d.ts +823 -0
  134. package/generated/versions/defold-1.13.1/b2d_shape.d.ts +400 -0
  135. package/generated/versions/defold-1.13.1/b2d_world.d.ts +320 -0
  136. package/generated/versions/defold-1.13.1/buffer.d.ts +189 -0
  137. package/generated/versions/defold-1.13.1/camera.d.ts +303 -0
  138. package/generated/versions/defold-1.13.1/collectionfactory.d.ts +151 -0
  139. package/generated/versions/defold-1.13.1/collectionproxy.d.ts +93 -0
  140. package/generated/versions/defold-1.13.1/compute.d.ts +237 -0
  141. package/generated/versions/defold-1.13.1/crash.d.ts +143 -0
  142. package/generated/versions/defold-1.13.1/editor-vm/http.d.ts +56 -0
  143. package/generated/versions/defold-1.13.1/editor-vm/image.d.ts +48 -0
  144. package/generated/versions/defold-1.13.1/editor-vm/json.d.ts +10 -0
  145. package/generated/versions/defold-1.13.1/editor-vm/localization.d.ts +42 -0
  146. package/generated/versions/defold-1.13.1/editor-vm/tilemap_tiles.d.ts +80 -0
  147. package/generated/versions/defold-1.13.1/editor-vm/zip.d.ts +10 -0
  148. package/generated/versions/defold-1.13.1/editor-vm/zlib.d.ts +24 -0
  149. package/generated/versions/defold-1.13.1/editor.d.ts +1121 -0
  150. package/generated/versions/defold-1.13.1/factory.d.ts +124 -0
  151. package/generated/versions/defold-1.13.1/font.d.ts +81 -0
  152. package/generated/versions/defold-1.13.1/go.d.ts +1107 -0
  153. package/generated/versions/defold-1.13.1/graphics.d.ts +411 -0
  154. package/generated/versions/defold-1.13.1/gui.d.ts +2353 -0
  155. package/generated/versions/defold-1.13.1/html5.d.ts +55 -0
  156. package/generated/versions/defold-1.13.1/http.d.ts +77 -0
  157. package/generated/versions/defold-1.13.1/image.d.ts +131 -0
  158. package/generated/versions/defold-1.13.1/index.d.ts +57 -0
  159. package/generated/versions/defold-1.13.1/json.d.ts +80 -0
  160. package/generated/versions/defold-1.13.1/kinds/editor-script.d.ts +14 -0
  161. package/generated/versions/defold-1.13.1/label.d.ts +93 -0
  162. package/generated/versions/defold-1.13.1/liveupdate.d.ts +142 -0
  163. package/generated/versions/defold-1.13.1/material.d.ts +408 -0
  164. package/generated/versions/defold-1.13.1/model.d.ts +272 -0
  165. package/generated/versions/defold-1.13.1/msg.d.ts +10 -0
  166. package/generated/versions/defold-1.13.1/particlefx.d.ts +163 -0
  167. package/generated/versions/defold-1.13.1/physics.d.ts +559 -0
  168. package/generated/versions/defold-1.13.1/profiler.d.ts +235 -0
  169. package/generated/versions/defold-1.13.1/render.d.ts +1190 -0
  170. package/generated/versions/defold-1.13.1/resource.d.ts +1523 -0
  171. package/generated/versions/defold-1.13.1/socket.d.ts +784 -0
  172. package/generated/versions/defold-1.13.1/sound.d.ts +292 -0
  173. package/generated/versions/defold-1.13.1/sprite.d.ts +175 -0
  174. package/generated/versions/defold-1.13.1/sys.d.ts +678 -0
  175. package/generated/versions/defold-1.13.1/tilemap.d.ts +208 -0
  176. package/generated/versions/defold-1.13.1/timer.d.ts +125 -0
  177. package/generated/versions/defold-1.13.1/types.d.ts +61 -0
  178. package/generated/versions/defold-1.13.1/vmath.d.ts +774 -0
  179. package/generated/versions/defold-1.13.1/window.d.ts +183 -0
  180. package/generated/versions/defold-1.13.1/zlib.d.ts +41 -0
  181. package/generated/vmath.d.ts +6 -26
  182. package/generated/window.d.ts +71 -71
  183. package/identity-vocabulary.json +561 -0
  184. package/index.d.ts +8 -0
  185. package/package.json +13 -2
  186. package/scripts/example-store-io.ts +12 -1
  187. package/scripts/extension-goldens.ts +1 -0
  188. package/scripts/fidelity-baseline.json +146 -46
  189. package/scripts/generate-api-availability.ts +90 -12
  190. package/scripts/generate-api-signatures.ts +14 -3
  191. package/scripts/import-defold-release.ts +85 -24
  192. package/scripts/prose-constants.ts +157 -0
  193. package/scripts/regen.ts +396 -78
  194. package/scripts/shared-handle-methods.ts +53 -0
  195. package/scripts/signature-store-fs.ts +1 -0
  196. package/scripts/sync-api-docs.ts +16 -5
  197. package/src/api-availability.ts +0 -0
  198. package/src/api-doc.ts +201 -3
  199. package/src/api-identity.ts +252 -0
  200. package/src/component-properties.d.ts +33 -0
  201. package/src/core-types.ts +28 -3
  202. package/src/correction-pins.ts +49 -0
  203. package/src/custom-messages.d.ts +4 -3
  204. package/src/doc-comment.ts +139 -23
  205. package/src/doc-corrections.ts +108 -0
  206. package/src/editor-vm-globals.d.ts +5 -2
  207. package/src/emit-dts.ts +2474 -281
  208. package/src/emit-messages.ts +52 -0
  209. package/src/engine-globals.d.ts +2 -2
  210. package/src/example-store.ts +125 -14
  211. package/src/field-correction-coverage.ts +204 -0
  212. package/src/fnv1a.ts +16 -0
  213. package/src/go-overloads.d.ts +33 -13
  214. package/src/index-base-table.ts +145 -0
  215. package/src/index-slot-classifications.ts +588 -0
  216. package/src/index.ts +39 -2
  217. package/src/library-index-slot-classifications.ts +332 -0
  218. package/src/lifecycle.ts +61 -199
  219. package/src/luals-type-expr.ts +354 -0
  220. package/src/msg-overloads.d.ts +0 -1
  221. package/src/param-correction-provenance.ts +64 -0
  222. package/src/return-correction-provenance.ts +58 -16
  223. package/src/script-api.ts +3 -1
  224. package/src/sys-overloads.d.ts +48 -0
  225. package/src/vmath-overloads.d.ts +27 -1
  226. package/src/window-event-guard.d.ts +6 -9
  227. package/url-parameters.json +1 -2
@@ -0,0 +1,303 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Matrix4, Url, Vector3 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Messages to control camera components and camera focus.
7
+ */
8
+ namespace camera {
9
+ /**
10
+ * Computes zoom so the original display area covers the entire window while preserving aspect ratio.
11
+ * Equivalent to using max(window_width/width, window_height/height).
12
+ * The result is multiplied by the user-controlled orthographic zoom.
13
+ */
14
+ const ORTHO_MODE_AUTO_COVER: number & { readonly __brand: "camera.ORTHO_MODE_AUTO_COVER" };
15
+ /**
16
+ * Computes zoom so the original display area (game.project width/height) fits inside the window
17
+ * while preserving aspect ratio. Equivalent to using min(window_width/width, window_height/height).
18
+ * The result is multiplied by the user-controlled orthographic zoom.
19
+ */
20
+ const ORTHO_MODE_AUTO_FIT: number & { readonly __brand: "camera.ORTHO_MODE_AUTO_FIT" };
21
+ /**
22
+ * Uses the manually set orthographic zoom value (camera.set_orthographic_zoom).
23
+ */
24
+ const ORTHO_MODE_FIXED: number & { readonly __brand: "camera.ORTHO_MODE_FIXED" };
25
+ /**
26
+ * Gets the effective aspect ratio of the camera. If auto aspect ratio is enabled,
27
+ * returns the aspect ratio calculated from the current render target dimensions.
28
+ * Otherwise returns the manually set aspect ratio.
29
+ *
30
+ * @param camera - camera id
31
+ * @returns the effective aspect ratio.
32
+ */
33
+ function get_aspect_ratio(camera?: Url | number | string | Hash): number;
34
+ /**
35
+ * Returns whether auto aspect ratio is enabled. When enabled, the camera automatically
36
+ * calculates aspect ratio from render target dimensions. When disabled, uses the
37
+ * manually set aspect ratio value.
38
+ *
39
+ * @param camera - camera id
40
+ * @returns true if auto aspect ratio is enabled
41
+ */
42
+ function get_auto_aspect_ratio(camera?: Url | number | string | Hash): boolean;
43
+ /**
44
+ * This function returns a table with all the camera URLs that have been
45
+ * registered in the render context.
46
+ *
47
+ * @returns a table with all camera URLs
48
+ * @example
49
+ * ```ts
50
+ * const predicate = render.predicate([hash("my_tag")]);
51
+ * for (const camera_id of camera.get_cameras()) {
52
+ * render.set_camera(camera_id);
53
+ * render.draw(predicate);
54
+ * render.set_camera();
55
+ * }
56
+ * ```
57
+ */
58
+ function get_cameras(): Url[];
59
+ /**
60
+ * get enabled
61
+ *
62
+ * @param camera - camera id
63
+ * @returns true if the camera is enabled
64
+ */
65
+ function get_enabled(camera?: Url | number | string | Hash): boolean;
66
+ /**
67
+ * get far z
68
+ *
69
+ * @param camera - camera id
70
+ * @returns the far z.
71
+ */
72
+ function get_far_z(camera?: Url | number | string | Hash): number;
73
+ /**
74
+ * get field of view
75
+ *
76
+ * @param camera - camera id
77
+ * @returns the field of view.
78
+ */
79
+ function get_fov(camera?: Url | number | string | Hash): number;
80
+ /**
81
+ * get near z
82
+ *
83
+ * @param camera - camera id
84
+ * @returns the near z.
85
+ */
86
+ function get_near_z(camera?: Url | number | string | Hash): number;
87
+ /**
88
+ * Gets the orthographic zoom calculated from the current window and project dimensions
89
+ * in auto-fit and auto-cover modes. Returns 1.0 in fixed mode.
90
+ *
91
+ * @param camera - camera id
92
+ * @returns the calculated orthographic auto zoom.
93
+ */
94
+ function get_orthographic_auto_zoom(camera?: Url | number | string | Hash): number;
95
+ /**
96
+ * get orthographic zoom mode
97
+ *
98
+ * @param camera - camera id
99
+ * @returns one of camera.ORTHO_MODE_FIXED, camera.ORTHO_MODE_AUTO_FIT or
100
+ * camera.ORTHO_MODE_AUTO_COVER
101
+ */
102
+ function get_orthographic_mode(camera?: Url | number | string | Hash): number;
103
+ /**
104
+ * Gets the positive user-controlled orthographic zoom multiplier. In auto-fit and auto-cover
105
+ * modes, this value is multiplied with camera.get_orthographic_auto_zoom(camera).
106
+ *
107
+ * @param camera - camera id
108
+ * @returns the positive zoom multiplier when the camera uses orthographic projection.
109
+ */
110
+ function get_orthographic_zoom(camera?: Url | number | string | Hash): number;
111
+ /**
112
+ * get projection matrix
113
+ *
114
+ * @param camera - camera id
115
+ * @returns the projection matrix.
116
+ */
117
+ function get_projection(camera?: Url | number | string | Hash): Matrix4;
118
+ /**
119
+ * get view matrix
120
+ *
121
+ * @param camera - camera id
122
+ * @returns the view matrix.
123
+ */
124
+ function get_view(camera?: Url | number | string | Hash): Matrix4;
125
+ /**
126
+ * Converts a screen-space 2D point with view depth to a 3D world point.
127
+ * z is the view depth in world units measured from the camera plane along the camera forward axis.
128
+ * If a camera isn't specified, the last enabled camera is used.
129
+ *
130
+ * @param pos - Screen-space position (x, y) with z as view depth in world units
131
+ * @param camera - optional camera id
132
+ * @returns the world coordinate
133
+ * @example
134
+ * ```ts
135
+ * // Place objects at the touch point with a random Z position, keeping them
136
+ * // within the visible view zone.
137
+ * export default defineScript({
138
+ * on_input(self, action_id, action) {
139
+ * if (action_id === hash("touch")) {
140
+ * if (action.pressed && action.screen_x !== undefined && action.screen_y !== undefined) {
141
+ * const perspective_camera = msg.url("#perspective_camera");
142
+ * const random_z = math.random(
143
+ * camera.get_near_z(perspective_camera) + 0.01,
144
+ * camera.get_far_z(perspective_camera) - 0.01,
145
+ * );
146
+ * const world_position = camera.screen_to_world(
147
+ * vmath.vector3(action.screen_x, action.screen_y, random_z),
148
+ * perspective_camera,
149
+ * );
150
+ * go.set_position(world_position, "/go1");
151
+ * }
152
+ * }
153
+ * },
154
+ * });
155
+ * ```
156
+ */
157
+ function screen_to_world(pos: Vector3, camera?: Url | number | string | Hash): Vector3;
158
+ /**
159
+ * Converts 2D screen coordinates (x,y) to the 3D world-space point on the camera's near plane for that pixel.
160
+ * If a camera isn't specified, the last enabled camera is used.
161
+ *
162
+ * @param x - X coordinate on screen.
163
+ * @param y - Y coordinate on screen.
164
+ * @param camera - optional camera id
165
+ * @returns the world coordinate on the camera near plane
166
+ * @example
167
+ * ```ts
168
+ * // Place objects at the touch point.
169
+ * export default defineScript({
170
+ * on_input(self, action_id, action) {
171
+ * if (action_id === hash("touch")) {
172
+ * if (action.pressed && action.screen_x !== undefined && action.screen_y !== undefined) {
173
+ * const world_position = camera.screen_xy_to_world(action.screen_x, action.screen_y);
174
+ * go.set_position(world_position, "/go1");
175
+ * }
176
+ * }
177
+ * },
178
+ * });
179
+ * ```
180
+ */
181
+ function screen_xy_to_world(x: number, y: number, camera?: Url | number | string | Hash): Vector3;
182
+ /**
183
+ * Sets the manual aspect ratio for the camera. This value is only used when
184
+ * auto aspect ratio is disabled. To disable auto aspect ratio and use this
185
+ * manual value, call camera.set_auto_aspect_ratio(camera, false).
186
+ *
187
+ * @param camera - camera id
188
+ * @param aspect_ratio - the manual aspect ratio value.
189
+ */
190
+ function set_aspect_ratio(camera: Url | number | string | Hash | undefined, aspect_ratio: number): void;
191
+ /**
192
+ * Enables or disables automatic aspect ratio calculation. When enabled (true),
193
+ * the camera automatically calculates aspect ratio from render target dimensions.
194
+ * When disabled (false), uses the manually set aspect ratio value.
195
+ *
196
+ * @param camera - camera id
197
+ * @param auto_aspect_ratio - true to enable auto aspect ratio
198
+ */
199
+ function set_auto_aspect_ratio(camera: Url | number | string | Hash | undefined, auto_aspect_ratio: boolean): void;
200
+ /**
201
+ * set far z
202
+ *
203
+ * @param camera - camera id
204
+ * @param far_z - the far z.
205
+ */
206
+ function set_far_z(camera: Url | number | string | Hash | undefined, far_z: number): void;
207
+ /**
208
+ * set field of view
209
+ *
210
+ * @param camera - camera id
211
+ * @param fov - the field of view.
212
+ */
213
+ function set_fov(camera: Url | number | string | Hash | undefined, fov: number): void;
214
+ /**
215
+ * set near z
216
+ *
217
+ * @param camera - camera id
218
+ * @param near_z - the near z.
219
+ */
220
+ function set_near_z(camera: Url | number | string | Hash | undefined, near_z: number): void;
221
+ /**
222
+ * set orthographic zoom mode
223
+ *
224
+ * @param camera - camera id
225
+ * @param mode - camera.ORTHO_MODE_FIXED, camera.ORTHO_MODE_AUTO_FIT or camera.ORTHO_MODE_AUTO_COVER
226
+ */
227
+ function set_orthographic_mode(camera: Url | number | string | Hash | undefined, mode: number): void;
228
+ /**
229
+ * Sets the positive user-controlled orthographic zoom multiplier. In auto-fit and auto-cover
230
+ * modes, this value is multiplied with camera.get_orthographic_auto_zoom(camera).
231
+ *
232
+ * @param camera - camera id
233
+ * @param orthographic_zoom - the positive zoom multiplier when the camera uses orthographic projection.
234
+ */
235
+ function set_orthographic_zoom(camera: Url | number | string | Hash | undefined, orthographic_zoom: number): void;
236
+ /**
237
+ * Converts a 3D world position to screen-space coordinates with view depth.
238
+ * Returns a vector3 where x and y are in screen pixels and z is the view depth in world units
239
+ * measured from the camera plane along the camera forward axis. The returned z can be used with
240
+ * camera.screen_to_world to reconstruct the world position on the same pixel ray.
241
+ * If a camera isn't specified, the last enabled camera is used.
242
+ *
243
+ * @param world_pos - World-space position
244
+ * @param camera - optional camera id
245
+ * @returns Screen position (x,y in pixels, z is view depth)
246
+ * @example
247
+ * ```ts
248
+ * // Convert a game object position into a screen position.
249
+ * go.update_world_transform("/go1");
250
+ * const world_pos = go.get_world_position("/go1");
251
+ * const screen_pos = camera.world_to_screen(world_pos);
252
+ * ```
253
+ */
254
+ function world_to_screen(world_pos: Vector3, camera?: Url | number | string | Hash): Vector3;
255
+ interface properties {
256
+ /**
257
+ * The ratio between the frustum width and height. Used when calculating the
258
+ * projection of a perspective camera.
259
+ * The type of the property is number.
260
+ */
261
+ aspect_ratio: number;
262
+ /**
263
+ * Camera frustum far plane.
264
+ * The type of the property is float.
265
+ */
266
+ far_z: number;
267
+ /**
268
+ * Vertical field of view of the camera.
269
+ * The type of the property is float.
270
+ */
271
+ fov: number;
272
+ /**
273
+ * Camera frustum near plane.
274
+ * The type of the property is float.
275
+ */
276
+ near_z: number;
277
+ /**
278
+ * READ ONLY The zoom calculated from the current window and project dimensions
279
+ * in auto fit and auto cover modes. The value is 1.0 in fixed mode.
280
+ * The type of the property is float.
281
+ */
282
+ readonly orthographic_auto_zoom: number;
283
+ /**
284
+ * Positive zoom multiplier when using an orthographic projection. In auto fit and auto cover
285
+ * modes, this value is multiplied with the calculated orthographic_auto_zoom value.
286
+ * The type of the property is float.
287
+ */
288
+ orthographic_zoom: number;
289
+ /**
290
+ * READ ONLY The calculated projection matrix of the camera.
291
+ * The type of the property is matrix4.
292
+ */
293
+ readonly projection: Matrix4;
294
+ /**
295
+ * READ ONLY The calculated view matrix of the camera.
296
+ * The type of the property is matrix4.
297
+ */
298
+ readonly view: Matrix4;
299
+ }
300
+ }
301
+ }
302
+
303
+ export {};
@@ -0,0 +1,151 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Quaternion, Url, Vector3 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions for controlling collection factory components which are
7
+ * used to dynamically spawn collections into the runtime.
8
+ */
9
+ namespace collectionfactory {
10
+ type Status = typeof collectionfactory.STATUS_UNLOADED | typeof collectionfactory.STATUS_LOADING | typeof collectionfactory.STATUS_LOADED;
11
+ /**
12
+ * loaded
13
+ */
14
+ const STATUS_LOADED: number & { readonly __brand: "collectionfactory.STATUS_LOADED" };
15
+ /**
16
+ * loading
17
+ */
18
+ const STATUS_LOADING: number & { readonly __brand: "collectionfactory.STATUS_LOADING" };
19
+ /**
20
+ * unloaded
21
+ */
22
+ const STATUS_UNLOADED: number & { readonly __brand: "collectionfactory.STATUS_UNLOADED" };
23
+ /**
24
+ * The URL identifies the collectionfactory component that should do the spawning.
25
+ * Spawning is instant, but spawned game objects get their first update calls the following frame. The supplied parameters for position, rotation and scale
26
+ * will be applied to the whole collection when spawned.
27
+ * Script properties in the created game objects can be overridden through
28
+ * a properties-parameter table. The table should contain game object ids
29
+ * (hash) as keys and property tables as values to be used when initiating each
30
+ * spawned game object.
31
+ * See go.property for more information on script properties.
32
+ * The function returns a table that contains a key for each game object
33
+ * id (hash), as addressed if the collection file was top level, and the
34
+ * corresponding spawned instance id (hash) as value with a unique path
35
+ * prefix added to each instance.
36
+ * Calling collectionfactory.create create on a collection factory that is marked as dynamic without having loaded resources
37
+ * using collectionfactory.load will synchronously load and create resources which may affect application performance.
38
+ *
39
+ * @param url - the collection factory component to be used
40
+ * @param position - position to assign to the newly spawned collection
41
+ * @param rotation - rotation to assign to the newly spawned collection
42
+ * @param properties - table of script properties to propagate to any new game object instances
43
+ * @param scale - uniform scaling to apply to the newly spawned collection (must be greater than 0).
44
+ * @returns a table mapping the id:s from the collection to the new instance id:s
45
+ * @example
46
+ * How to spawn a collection of game objects:
47
+ * ```ts
48
+ * export default defineScript({
49
+ * init() {
50
+ * // Spawn a small group of enemies.
51
+ * const pos = vmath.vector3(100, 12.5, 0);
52
+ * const rot = vmath.quat_rotation_z(Math.PI / 2);
53
+ * const scale = 0.5;
54
+ * const props = new LuaMap<Hash, Record<string, unknown>>();
55
+ * props.set(hash("/enemy_leader"), { health: 1000.0 });
56
+ * props.set(hash("/enemy_1"), { health: 200.0 });
57
+ * props.set(hash("/enemy_2"), { health: 400.0, color: hash("green") });
58
+ *
59
+ * const enemy_ids = collectionfactory.create("#enemyfactory", pos, rot, props, scale);
60
+ * // enemy_ids now map to the spawned instance ids:
61
+ * //
62
+ * // pprint(self.enemy_ids)
63
+ * //
64
+ * // DEBUG:SCRIPT:
65
+ * // {
66
+ * // hash: [/enemy_leader] = hash: [/collection0/enemy_leader],
67
+ * // hash: [/enemy_1] = hash: [/collection0/enemy_1],
68
+ * // hash: [/enemy_2] = hash: [/collection0/enemy_2]
69
+ * // }
70
+ *
71
+ * // Send "attack" message to the leader. First look up its instance id.
72
+ * const leader_id = enemy_ids.get(hash("/enemy_leader"));
73
+ * if (leader_id !== undefined) {
74
+ * msg.post(leader_id, "attack");
75
+ * }
76
+ * return { enemy_ids };
77
+ * },
78
+ * });
79
+ * ```
80
+ * @example
81
+ * How to delete a spawned collection:
82
+ * ```ts
83
+ * function delete_enemies(self: { enemy_ids: Hash[] }) {
84
+ * go.delete(self.enemy_ids);
85
+ * }
86
+ * ```
87
+ */
88
+ function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: LuaMap<Hash, Record<string | number, unknown>> | Record<string, Record<string | number, unknown>>, scale?: number | Vector3): LuaMap<Hash, Hash>;
89
+ /**
90
+ * This returns status of the collection factory.
91
+ * Calling this function when the factory is not marked as dynamic loading always returns COMP_COLLECTION_FACTORY_STATUS_LOADED.
92
+ *
93
+ * @param url - the collection factory component to get status from
94
+ * @returns status of the collection factory component
95
+ *
96
+ * - `collectionfactory.STATUS_UNLOADED`
97
+ * - `collectionfactory.STATUS_LOADING`
98
+ * - `collectionfactory.STATUS_LOADED`
99
+ */
100
+ function get_status(url: string | Hash | Url): collectionfactory.Status;
101
+ /**
102
+ * Resources loaded are referenced by the collection factory component until the existing (parent) collection is destroyed or collectionfactory.unload is called.
103
+ * Calling this function when the factory is not marked as dynamic loading does nothing.
104
+ *
105
+ * @param url - the collection factory component to load
106
+ * @param complete_function - function to call when resources are loaded.
107
+ *
108
+ * `self`
109
+ * object The current object.
110
+ * `url`
111
+ * url url of the collection factory component
112
+ * `result`
113
+ * boolean True if resource were loaded successfully
114
+ * @example
115
+ * ```ts
116
+ * // How to load resources of a collection factory prototype.
117
+ * collectionfactory.load("#factory", (self, url, result) => {});
118
+ * ```
119
+ */
120
+ function load(url: string | Hash | Url, complete_function: (self: unknown, url: unknown, result: unknown) => void): void;
121
+ /**
122
+ * Changes the prototype for the collection factory.
123
+ * Setting the prototype to "nil" will revert back to the original prototype.
124
+ *
125
+ * @param url - the collection factory component
126
+ * @param prototype - the path to the new prototype, or `nil`
127
+ * @example
128
+ * ```ts
129
+ * // How to unload the previous prototype's resources, and then spawn a new collection:
130
+ * collectionfactory.unload("#factory"); // unload the previous resources
131
+ * collectionfactory.set_prototype("#factory", "/main/levels/level1.collectionc");
132
+ * const ids = collectionfactory.create("#factory", go.get_world_position(), vmath.quat());
133
+ * ```
134
+ */
135
+ function set_prototype(url: string | Hash | Url, prototype: string | undefined): void;
136
+ /**
137
+ * This decreases the reference count for each resource loaded with collectionfactory.load. If reference is zero, the resource is destroyed.
138
+ * Calling this function when the factory is not marked as dynamic loading does nothing.
139
+ *
140
+ * @param url - the collection factory component to unload
141
+ * @example
142
+ * ```ts
143
+ * // How to unload resources of a collection factory prototype loaded with collectionfactory.load:
144
+ * collectionfactory.unload("#factory");
145
+ * ```
146
+ */
147
+ function unload(url: string | Hash | Url): void;
148
+ }
149
+ }
150
+
151
+ export {};
@@ -0,0 +1,93 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Url } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Messages for controlling and interacting with collection proxies
7
+ * which are used to dynamically load collections into the runtime.
8
+ */
9
+ namespace collectionproxy {
10
+ /**
11
+ * It's impossible to change the collection if the collection is already loaded.
12
+ */
13
+ const RESULT_ALREADY_LOADED: number & { readonly __brand: "collectionproxy.RESULT_ALREADY_LOADED" };
14
+ /**
15
+ * It's impossible to change the collection while the collection proxy is loading.
16
+ */
17
+ const RESULT_LOADING: number & { readonly __brand: "collectionproxy.RESULT_LOADING" };
18
+ /**
19
+ * It's impossible to change the collection for a proxy that isn't excluded.
20
+ */
21
+ const RESULT_NOT_EXCLUDED: number & { readonly __brand: "collectionproxy.RESULT_NOT_EXCLUDED" };
22
+ /**
23
+ * return an indexed table of resources for a collection proxy where the
24
+ * referenced collection has been excluded using LiveUpdate. Each entry is a
25
+ * hexadecimal string that represents the data of the specific resource.
26
+ * This representation corresponds with the filename for each individual
27
+ * resource that is exported when you bundle an application with LiveUpdate
28
+ * functionality.
29
+ *
30
+ * @param collectionproxy - the collectionproxy to check for resources.
31
+ * @returns the resources, or an empty list if the
32
+ * collection was not excluded.
33
+ * @example
34
+ * ```ts
35
+ * function print_resources(self: unknown, cproxy: Url) {
36
+ * const resources = collectionproxy.get_resources(cproxy);
37
+ * for (const v of resources) {
38
+ * print(`Resource: ${v}`);
39
+ * }
40
+ * }
41
+ * ```
42
+ */
43
+ function get_resources(collectionproxy: Url | string | Hash): string[];
44
+ /**
45
+ * Loads the collection referenced by a collection proxy. The proxy is also
46
+ * initialized and the callback receives `proxy_loading`, `proxy_ready`, or
47
+ * `proxy_error` messages.
48
+ *
49
+ * @param url - the collection proxy component
50
+ * @param options - options table, currently unused
51
+ * @param callback - callback
52
+ * @example
53
+ * ```ts
54
+ * collectionproxy.load("#proxy", undefined, (self, message_id, message, sender) => {
55
+ * if (message_id === hash("proxy_ready")) {
56
+ * print("proxy is ready");
57
+ * } else if (message_id === hash("proxy_loading")) {
58
+ * print("progress", message.progress);
59
+ * } else if (message_id === hash("proxy_error")) {
60
+ * print("error", message.code);
61
+ * }
62
+ * });
63
+ * ```
64
+ */
65
+ function load(url: string | Hash | Url, options: Record<string | number, unknown> | undefined, callback: (self: unknown, message_id: Hash, message: Record<string | number, unknown>, sender: Url) => void): void;
66
+ /**
67
+ * The collection should be loaded by the collection proxy.
68
+ * Setting the collection to "nil" will revert it back to the original collection.
69
+ * The collection proxy shouldn't be loaded and should have the 'Exclude' checkbox checked.
70
+ * This functionality is designed to simplify the management of Live Update resources.
71
+ *
72
+ * @param url - the collection proxy component
73
+ * @param prototype - the path to the new collection, or `nil`
74
+ * @example
75
+ * ```ts
76
+ * // The example assumes the script belongs to an instance with a
77
+ * // collection-proxy-component with id "proxy".
78
+ * const [ok, error] = collectionproxy.set_collection("/go#collectionproxy", "/LU/3.collectionc");
79
+ * if (ok) {
80
+ * print("The collection has been changed to /LU/3.collectionc");
81
+ * } else {
82
+ * print("Error changing collection to /LU/3.collectionc ", error);
83
+ * }
84
+ * msg.post("/go#collectionproxy", "load");
85
+ * msg.post("/go#collectionproxy", "init");
86
+ * msg.post("/go#collectionproxy", "enable");
87
+ * ```
88
+ */
89
+ function set_collection(url: string | Hash | Url, prototype: string | undefined): LuaMultiReturn<[boolean, number]>;
90
+ }
91
+ }
92
+
93
+ export {};