@defold-typescript/types 0.8.4 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/api-targets.json +18 -0
  3. package/generated/b2d_body.d.ts +348 -0
  4. package/generated/buffer.d.ts +3 -0
  5. package/generated/camera.d.ts +236 -1
  6. package/generated/collectionfactory.d.ts +4 -0
  7. package/generated/factory.d.ts +4 -0
  8. package/generated/font.d.ts +81 -0
  9. package/generated/go.d.ts +53 -0
  10. package/generated/gui.d.ts +264 -49
  11. package/generated/html5.d.ts +17 -13
  12. package/generated/http.d.ts +16 -0
  13. package/generated/image.d.ts +24 -0
  14. package/generated/json.d.ts +2 -0
  15. package/generated/kinds/gui-script.d.ts +2 -0
  16. package/generated/kinds/render-script.d.ts +2 -0
  17. package/generated/kinds/script.d.ts +2 -0
  18. package/generated/model.d.ts +14 -0
  19. package/generated/msg.d.ts +17 -11
  20. package/generated/particlefx.d.ts +6 -0
  21. package/generated/physics.d.ts +32 -0
  22. package/generated/profiler.d.ts +14 -0
  23. package/generated/render.d.ts +109 -0
  24. package/generated/resource.d.ts +223 -0
  25. package/generated/socket.d.ts +4 -0
  26. package/generated/sound.d.ts +6 -0
  27. package/generated/sprite.d.ts +5 -0
  28. package/generated/sys.d.ts +136 -0
  29. package/generated/tilemap.d.ts +2 -0
  30. package/generated/timer.d.ts +3 -0
  31. package/generated/vmath.d.ts +109 -93
  32. package/generated/window.d.ts +23 -0
  33. package/index.d.ts +7 -0
  34. package/package.json +1 -1
  35. package/scripts/fidelity-baseline.json +18 -2
  36. package/scripts/regen.ts +4 -0
  37. package/scripts/signature-store-io.ts +18 -0
  38. package/scripts/sync-api-docs.ts +208 -12
  39. package/src/core-types.ts +4 -2
  40. package/src/doc-comment.ts +42 -5
  41. package/src/engine-globals.d.ts +2 -0
  42. package/src/example-store.ts +11 -7
  43. package/src/index.ts +18 -1
  44. package/src/msg-overloads.d.ts +3 -0
  45. package/src/signature-store.ts +20 -0
package/README.md CHANGED
@@ -13,7 +13,7 @@ Most users get these wired in automatically by the
13
13
  (`bunx @defold-typescript/cli init`), which points `tsconfig.json` at the right surface.
14
14
 
15
15
  See the repository [README](https://github.com/defold-typescript/toolchain#readme)
16
- and [`docs/guide/`](https://github.com/defold-typescript/toolchain/tree/main/docs/guide)
16
+ and [`packages/docs/guide/`](https://github.com/defold-typescript/toolchain/tree/main/packages/docs/guide)
17
17
  for the full workflow.
18
18
 
19
19
  ## License
package/api-targets.json CHANGED
@@ -9,6 +9,11 @@
9
9
  "source": null,
10
10
  "modules": [
11
11
  { "namespace": "b2d", "fixture": "b2d_doc.json", "outFile": "b2d.d.ts" },
12
+ {
13
+ "namespace": "b2d.body",
14
+ "fixture": "b2d_body_doc.json",
15
+ "outFile": "b2d_body.d.ts"
16
+ },
12
17
  { "namespace": "buffer", "fixture": "buffer_doc.json", "outFile": "buffer.d.ts" },
13
18
  { "namespace": "camera", "fixture": "camera_doc.json", "outFile": "camera.d.ts" },
14
19
  {
@@ -23,6 +28,7 @@
23
28
  },
24
29
  { "namespace": "crash", "fixture": "crash_doc.json", "outFile": "crash.d.ts" },
25
30
  { "namespace": "factory", "fixture": "factory_doc.json", "outFile": "factory.d.ts" },
31
+ { "namespace": "font", "fixture": "font_doc.json", "outFile": "font.d.ts" },
26
32
  {
27
33
  "namespace": "go",
28
34
  "fixture": "go_doc.json",
@@ -71,6 +77,18 @@
71
77
  { "namespace": "webview", "fixture": "webview_doc.json", "outFile": "webview.d.ts" },
72
78
  { "namespace": "window", "fixture": "window_doc.json", "outFile": "window.d.ts" },
73
79
  { "namespace": "zlib", "fixture": "zlib_doc.json", "outFile": "zlib.d.ts" }
80
+ ],
81
+ "luaStdlib": [
82
+ { "namespace": "base", "fixture": "base_doc.json" },
83
+ { "namespace": "bit", "fixture": "bit_doc.json" },
84
+ { "namespace": "math", "fixture": "math_doc.json" },
85
+ { "namespace": "os", "fixture": "os_doc.json" },
86
+ { "namespace": "string", "fixture": "string_doc.json" },
87
+ { "namespace": "table", "fixture": "table_doc.json" },
88
+ { "namespace": "coroutine", "fixture": "coroutine_doc.json" },
89
+ { "namespace": "debug", "fixture": "debug_doc.json" },
90
+ { "namespace": "io", "fixture": "io_doc.json" },
91
+ { "namespace": "package", "fixture": "package_doc.json" }
74
92
  ]
75
93
  },
76
94
  {
@@ -0,0 +1,348 @@
1
+ /** @noSelfInFile */
2
+ import type { Opaque, Vector3 } from "../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions for interacting with Box2D bodies.
7
+ */
8
+ namespace b2d.body {
9
+ type b2Body = Opaque<"b2Body">;
10
+ type b2World = Opaque<"b2World">;
11
+ /**
12
+ * Dynamic body
13
+ */
14
+ const B2_DYNAMIC_BODY: number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" };
15
+ /**
16
+ * Kinematic body
17
+ */
18
+ const B2_KINEMATIC_BODY: number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" };
19
+ /**
20
+ * Static (immovable) body
21
+ */
22
+ const B2_STATIC_BODY: number & { readonly __brand: "b2d.body.B2_STATIC_BODY" };
23
+ /**
24
+ * Apply an angular impulse.
25
+ *
26
+ * @param body - body
27
+ * @param impulse - impulse the angular impulse in units of kg*m*m/s
28
+ */
29
+ function apply_angular_impulse(body: Opaque<"b2Body">, impulse: number): void;
30
+ /**
31
+ * Apply a force at a world point. If the force is not
32
+ * applied at the center of mass, it will generate a torque and
33
+ * affect the angular velocity. This wakes up the body.
34
+ *
35
+ * @param body - body
36
+ * @param force - the world force vector, usually in Newtons (N).
37
+ * @param point - the world position of the point of application.
38
+ */
39
+ function apply_force(body: Opaque<"b2Body">, force: Vector3, point: Vector3): void;
40
+ /**
41
+ * Apply a force to the center of mass. This wakes up the body.
42
+ *
43
+ * @param body - body
44
+ * @param force - the world force vector, usually in Newtons (N).
45
+ */
46
+ function apply_force_to_center(body: Opaque<"b2Body">, force: Vector3): void;
47
+ /**
48
+ * Apply an impulse at a point. This immediately modifies the velocity.
49
+ * It also modifies the angular velocity if the point of application
50
+ * is not at the center of mass. This wakes up the body.
51
+ *
52
+ * @param body - body
53
+ * @param impulse - the world impulse vector, usually in N-seconds or kg-m/s.
54
+ * @param point - the world position of the point of application.
55
+ */
56
+ function apply_linear_impulse(body: Opaque<"b2Body">, impulse: Vector3, point: Vector3): void;
57
+ /**
58
+ * Apply a torque. This affects the angular velocity
59
+ * without affecting the linear velocity of the center of mass.
60
+ * This wakes up the body.
61
+ *
62
+ * @param body - body
63
+ * @param torque - torque about the z-axis (out of the screen), usually in N-m.
64
+ */
65
+ function apply_torque(body: Opaque<"b2Body">, torque: number): void;
66
+ /**
67
+ * You can disable sleeping on this body. If you disable sleeping, the body will be woken.
68
+ *
69
+ * @param body - body
70
+ * @param enable - if false, the body will never sleep, and consume more CPU
71
+ */
72
+ function enable_sleep(body: Opaque<"b2Body">, enable: boolean): void;
73
+ /**
74
+ * Get the angle in radians.
75
+ *
76
+ * @param body - body
77
+ * @returns the current world rotation angle in radians.
78
+ */
79
+ function get_angle(body: Opaque<"b2Body">): number;
80
+ /**
81
+ * Get the angular damping of the body.
82
+ *
83
+ * @param body - body
84
+ * @returns the damping
85
+ */
86
+ function get_angular_damping(body: Opaque<"b2Body">): number;
87
+ /**
88
+ * Get the angular velocity.
89
+ *
90
+ * @param body - body
91
+ * @returns the angular velocity in radians/second.
92
+ */
93
+ function get_angular_velocity(body: Opaque<"b2Body">): number;
94
+ /**
95
+ * Get the gravity scale of the body.
96
+ *
97
+ * @param body - body
98
+ * @returns the scale
99
+ */
100
+ function get_gravity_scale(body: Opaque<"b2Body">): number;
101
+ /**
102
+ * Get the linear damping of the body.
103
+ *
104
+ * @param body - body
105
+ * @returns the damping
106
+ */
107
+ function get_linear_damping(body: Opaque<"b2Body">): number;
108
+ /**
109
+ * Get the linear velocity of the center of mass.
110
+ *
111
+ * @param body - body
112
+ * @returns the linear velocity of the center of mass.
113
+ */
114
+ function get_linear_velocity(body: Opaque<"b2Body">): Vector3;
115
+ /**
116
+ * Get the world velocity of a local point.
117
+ *
118
+ * @param body - body
119
+ * @param local_point - a point in local coordinates.
120
+ * @returns the world velocity of a point.
121
+ */
122
+ function get_linear_velocity_from_local_point(body: Opaque<"b2Body">, local_point: Vector3): Vector3;
123
+ /**
124
+ * Get the world linear velocity of a world point attached to this body.
125
+ *
126
+ * @param body - body
127
+ * @param world_point - a point in world coordinates.
128
+ * @returns the world velocity of a point.
129
+ */
130
+ function get_linear_velocity_from_world_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
131
+ /**
132
+ * Get the local position of the center of mass.
133
+ *
134
+ * @param body - body
135
+ * @returns Get the local position of the center of mass.
136
+ */
137
+ function get_local_center_of_mass(body: Opaque<"b2Body">): Vector3;
138
+ /**
139
+ * Gets a local point relative to the body's origin given a world point.
140
+ *
141
+ * @param body - body
142
+ * @param world_point - a point in world coordinates.
143
+ * @returns the corresponding local point relative to the body's origin.
144
+ */
145
+ function get_local_point(body: Opaque<"b2Body">, world_point: Vector3): Vector3;
146
+ /**
147
+ * Gets a local vector given a world vector.
148
+ *
149
+ * @param body - body
150
+ * @param world_vector - a vector in world coordinates.
151
+ * @returns the corresponding local vector.
152
+ */
153
+ function get_local_vector(body: Opaque<"b2Body">, world_vector: Vector3): Vector3;
154
+ /**
155
+ * Get the total mass of the body.
156
+ *
157
+ * @param body - body
158
+ * @returns the mass, usually in kilograms (kg).
159
+ */
160
+ function get_mass(body: Opaque<"b2Body">): number;
161
+ /**
162
+ * Get the world body origin position.
163
+ *
164
+ * @param body - body
165
+ * @returns the world position of the body's origin.
166
+ */
167
+ function get_position(body: Opaque<"b2Body">): Vector3;
168
+ /**
169
+ * Get the rotational inertia of the body about the local origin.
170
+ *
171
+ * @param body - body
172
+ * @returns the rotational inertia, usually in kg-m^2.
173
+ */
174
+ function get_rotational_inertia(body: Opaque<"b2Body">): number;
175
+ /**
176
+ * Get the type of this body.
177
+ *
178
+ * @param body - body
179
+ * @returns the body type
180
+ */
181
+ function get_type(body: Opaque<"b2Body">): (number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_STATIC_BODY" });
182
+ /**
183
+ * Get the parent world of this body.
184
+ *
185
+ * @param body - body
186
+ */
187
+ function get_world(body: Opaque<"b2Body">): Opaque<"b2World">;
188
+ /**
189
+ * Get the world position of the center of mass.
190
+ *
191
+ * @param body - body
192
+ * @returns Get the world position of the center of mass.
193
+ */
194
+ function get_world_center_of_mass(body: Opaque<"b2Body">): Vector3;
195
+ /**
196
+ * Get the world coordinates of a point given the local coordinates.
197
+ *
198
+ * @param body - body
199
+ * @param local_vector - localPoint a point on the body measured relative the the body's origin.
200
+ * @returns the same point expressed in world coordinates.
201
+ */
202
+ function get_world_point(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
203
+ /**
204
+ * Get the world coordinates of a vector given the local coordinates.
205
+ *
206
+ * @param body - body
207
+ * @param local_vector - a vector fixed in the body.
208
+ * @returns the same vector expressed in world coordinates.
209
+ */
210
+ function get_world_vector(body: Opaque<"b2Body">, local_vector: Vector3): Vector3;
211
+ /**
212
+ * Get the active state of the body.
213
+ *
214
+ * @param body - body
215
+ * @returns is the body active
216
+ */
217
+ function is_active(body: Opaque<"b2Body">): boolean;
218
+ /**
219
+ * Get the sleeping state of this body.
220
+ *
221
+ * @param body - body
222
+ * @returns true if the body is awake, false if it's sleeping.
223
+ */
224
+ function is_awake(body: Opaque<"b2Body">): boolean;
225
+ /**
226
+ * Is this body in bullet mode
227
+ *
228
+ * @param body - body
229
+ * @returns true if the body is in bullet mode
230
+ */
231
+ function is_bullet(body: Opaque<"b2Body">): boolean;
232
+ /**
233
+ * Does this body have fixed rotation?
234
+ *
235
+ * @param body - body
236
+ * @returns is the rotation fixed
237
+ */
238
+ function is_fixed_rotation(body: Opaque<"b2Body">): boolean;
239
+ /**
240
+ * Is this body allowed to sleep
241
+ *
242
+ * @param body - body
243
+ * @returns true if the body is allowed to sleep
244
+ */
245
+ function is_sleeping_enabled(body: Opaque<"b2Body">): boolean;
246
+ /**
247
+ * This resets the mass properties to the sum of the mass properties of the fixtures.
248
+ * This normally does not need to be called unless you called SetMassData to override
249
+ *
250
+ * @param body - body
251
+ */
252
+ function reset_mass_data(body: Opaque<"b2Body">): void;
253
+ /**
254
+ * Set the active state of the body. An inactive body is not
255
+ * simulated and cannot be collided with or woken up.
256
+ * If you pass a flag of true, all fixtures will be added to the
257
+ * broad-phase.
258
+ * If you pass a flag of false, all fixtures will be removed from
259
+ * the broad-phase and all contacts will be destroyed.
260
+ * Fixtures and joints are otherwise unaffected. You may continue
261
+ * to create/destroy fixtures and joints on inactive bodies.
262
+ * Fixtures on an inactive body are implicitly inactive and will
263
+ * not participate in collisions, ray-casts, or queries.
264
+ * Joints connected to an inactive body are implicitly inactive.
265
+ * An inactive body is still owned by a b2World object and remains
266
+ * in the body list.
267
+ *
268
+ * @param body - body
269
+ * @param enable - true if the body should be active
270
+ */
271
+ function set_active(body: Opaque<"b2Body">, enable: boolean): void;
272
+ /**
273
+ * Set the angular damping of the body.
274
+ *
275
+ * @param body - body
276
+ * @param damping - the damping
277
+ */
278
+ function set_angular_damping(body: Opaque<"b2Body">, damping: number): void;
279
+ /**
280
+ * Set the angular velocity.
281
+ *
282
+ * @param body - body
283
+ * @param omega - the new angular velocity in radians/second.
284
+ */
285
+ function set_angular_velocity(body: Opaque<"b2Body">, omega: number): void;
286
+ /**
287
+ * Set the sleep state of the body. A sleeping body has very low CPU cost.
288
+ *
289
+ * @param body - body
290
+ * @param enable - flag set to false to put body to sleep, true to wake it.
291
+ */
292
+ function set_awake(body: Opaque<"b2Body">, enable: boolean): void;
293
+ /**
294
+ * Should this body be treated like a bullet for continuous collision detection?
295
+ *
296
+ * @param body - body
297
+ * @param enable - if true, the body will be in bullet mode
298
+ */
299
+ function set_bullet(body: Opaque<"b2Body">, enable: boolean): void;
300
+ /**
301
+ * Set this body to have fixed rotation. This causes the mass to be reset.
302
+ *
303
+ * @param body - body
304
+ * @param enable - true if the rotation should be fixed
305
+ */
306
+ function set_fixed_rotation(body: Opaque<"b2Body">, enable: boolean): void;
307
+ /**
308
+ * Set the gravity scale of the body.
309
+ *
310
+ * @param body - body
311
+ * @param scale - the scale
312
+ */
313
+ function set_gravity_scale(body: Opaque<"b2Body">, scale: number): void;
314
+ /**
315
+ * Set the linear damping of the body.
316
+ *
317
+ * @param body - body
318
+ * @param damping - the damping
319
+ */
320
+ function set_linear_damping(body: Opaque<"b2Body">, damping: number): void;
321
+ /**
322
+ * Set the linear velocity of the center of mass.
323
+ *
324
+ * @param body - body
325
+ * @param velocity - the new linear velocity of the center of mass.
326
+ */
327
+ function set_linear_velocity(body: Opaque<"b2Body">, velocity: Vector3): void;
328
+ /**
329
+ * Set the position of the body's origin and rotation.
330
+ * This breaks any contacts and wakes the other bodies.
331
+ * Manipulating a body's transform may cause non-physical behavior.
332
+ *
333
+ * @param body - body
334
+ * @param position - the world position of the body's local origin.
335
+ * @param angle - the world position of the body's local origin.
336
+ */
337
+ function set_transform(body: Opaque<"b2Body">, position: Vector3, angle: number): void;
338
+ /**
339
+ * Set the type of this body. This may alter the mass and velocity.
340
+ *
341
+ * @param body - body
342
+ * @param type - the body type
343
+ */
344
+ function set_type(body: Opaque<"b2Body">, type: (number & { readonly __brand: "b2d.body.B2_DYNAMIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_KINEMATIC_BODY" }) | (number & { readonly __brand: "b2d.body.B2_STATIC_BODY" })): void;
345
+ }
346
+ }
347
+
348
+ export {};
@@ -92,8 +92,11 @@ declare global {
92
92
  *
93
93
  * @param element_count - The number of elements the buffer should hold
94
94
  * @param declaration - A table where each entry (table) describes a stream
95
+ *
95
96
  * - hash | string `name`: The name of the stream
97
+ *
96
98
  * - constant `type`: The data type of the stream
99
+ *
97
100
  * - number `count`: The number of values each element should hold
98
101
  * @returns the new buffer
99
102
  * @example
@@ -1,9 +1,244 @@
1
1
  /** @noSelfInFile */
2
+ import type { Matrix4, Url, Vector3 } from "../src/core-types";
3
+
2
4
  declare global {
3
5
  /**
4
- * Functions for interacting with camera components.
6
+ * Camera functions, messages and constants.
5
7
  */
6
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
+ */
13
+ const ORTHO_MODE_AUTO_COVER: number & { readonly __brand: "camera.ORTHO_MODE_AUTO_COVER" };
14
+ /**
15
+ * Computes zoom so the original display area (game.project width/height) fits inside the window
16
+ * while preserving aspect ratio. Equivalent to using min(window_width/width, window_height/height).
17
+ */
18
+ const ORTHO_MODE_AUTO_FIT: number & { readonly __brand: "camera.ORTHO_MODE_AUTO_FIT" };
19
+ /**
20
+ * Uses the manually set orthographic zoom value (camera.set_orthographic_zoom).
21
+ */
22
+ const ORTHO_MODE_FIXED: number & { readonly __brand: "camera.ORTHO_MODE_FIXED" };
23
+ /**
24
+ * Gets the effective aspect ratio of the camera. If auto aspect ratio is enabled,
25
+ * returns the aspect ratio calculated from the current render target dimensions.
26
+ * Otherwise returns the manually set aspect ratio.
27
+ *
28
+ * @param camera - camera id
29
+ * @returns the effective aspect ratio.
30
+ */
31
+ function get_aspect_ratio(camera?: Url | number): number;
32
+ /**
33
+ * Returns whether auto aspect ratio is enabled. When enabled, the camera automatically
34
+ * calculates aspect ratio from render target dimensions. When disabled, uses the
35
+ * manually set aspect ratio value.
36
+ *
37
+ * @param camera - camera id
38
+ * @returns true if auto aspect ratio is enabled
39
+ */
40
+ function get_auto_aspect_ratio(camera?: Url | number): boolean;
41
+ /**
42
+ * This function returns a table with all the camera URLs that have been
43
+ * registered in the render context.
44
+ *
45
+ * @returns a table with all camera URLs
46
+ * @example
47
+ * ```ts
48
+ * for (const camera_id of camera.get_cameras()) {
49
+ * render.set_camera(camera_id);
50
+ * render.draw(predicate);
51
+ * render.set_camera();
52
+ * }
53
+ * ```
54
+ */
55
+ function get_cameras(): Record<string | number, unknown>;
56
+ /**
57
+ * get enabled
58
+ *
59
+ * @param camera - camera id
60
+ * @returns true if the camera is enabled
61
+ */
62
+ function get_enabled(camera?: Url | number): boolean;
63
+ /**
64
+ * get far z
65
+ *
66
+ * @param camera - camera id
67
+ * @returns the far z.
68
+ */
69
+ function get_far_z(camera?: Url | number): number;
70
+ /**
71
+ * get field of view
72
+ *
73
+ * @param camera - camera id
74
+ * @returns the field of view.
75
+ */
76
+ function get_fov(camera?: Url | number): number;
77
+ /**
78
+ * get near z
79
+ *
80
+ * @param camera - camera id
81
+ * @returns the near z.
82
+ */
83
+ function get_near_z(camera?: Url | number): number;
84
+ /**
85
+ * get orthographic zoom mode
86
+ *
87
+ * @param camera - camera id
88
+ * @returns one of camera.ORTHO_MODE_FIXED, camera.ORTHO_MODE_AUTO_FIT or
89
+ * camera.ORTHO_MODE_AUTO_COVER
90
+ */
91
+ function get_orthographic_mode(camera?: Url | number): number;
92
+ /**
93
+ * get orthographic zoom
94
+ *
95
+ * @param camera - camera id
96
+ * @returns the zoom level when the camera uses orthographic projection.
97
+ */
98
+ function get_orthographic_zoom(camera?: Url | number): number;
99
+ /**
100
+ * get projection matrix
101
+ *
102
+ * @param camera - camera id
103
+ * @returns the projection matrix.
104
+ */
105
+ function get_projection(camera?: Url | number): Matrix4;
106
+ /**
107
+ * get view matrix
108
+ *
109
+ * @param camera - camera id
110
+ * @returns the view matrix.
111
+ */
112
+ function get_view(camera?: Url | number): Matrix4;
113
+ /**
114
+ * Converts a screen-space 2D point with view depth to a 3D world point.
115
+ * z is the view depth in world units measured from the camera plane along the camera forward axis.
116
+ * If a camera isn't specified, the last enabled camera is used.
117
+ *
118
+ * @param pos - Screen-space position (x, y) with z as view depth in world units
119
+ * @param camera - optional camera id
120
+ * @returns the world coordinate
121
+ * @example
122
+ * ```ts
123
+ * // Place objects at the touch point with a random Z position, keeping them
124
+ * // within the visible view zone.
125
+ * export default defineScript({
126
+ * on_input(self, action_id, action) {
127
+ * if (action_id === hash("touch")) {
128
+ * if (action.pressed) {
129
+ * const perspective_camera = msg.url("#perspective_camera");
130
+ * const random_z = math.random(
131
+ * camera.get_near_z(perspective_camera) + 0.01,
132
+ * camera.get_far_z(perspective_camera) - 0.01,
133
+ * );
134
+ * const world_position = camera.screen_to_world(
135
+ * vmath.vector3(action.screen_x, action.screen_y, random_z),
136
+ * perspective_camera,
137
+ * );
138
+ * go.set_position(world_position, "/go1");
139
+ * }
140
+ * }
141
+ * },
142
+ * });
143
+ * ```
144
+ */
145
+ function screen_to_world(pos: Vector3, camera?: Url | number): Vector3;
146
+ /**
147
+ * Converts 2D screen coordinates (x,y) to the 3D world-space point on the camera's near plane for that pixel.
148
+ * If a camera isn't specified, the last enabled camera is used.
149
+ *
150
+ * @param x - X coordinate on screen.
151
+ * @param y - Y coordinate on screen.
152
+ * @param camera - optional camera id
153
+ * @returns the world coordinate on the camera near plane
154
+ * @example
155
+ * ```ts
156
+ * // Place objects at the touch point.
157
+ * export default defineScript({
158
+ * on_input(self, action_id, action) {
159
+ * if (action_id === hash("touch")) {
160
+ * if (action.pressed) {
161
+ * const world_position = camera.screen_xy_to_world(action.screen_x, action.screen_y);
162
+ * go.set_position(world_position, "/go1");
163
+ * }
164
+ * }
165
+ * },
166
+ * });
167
+ * ```
168
+ */
169
+ function screen_xy_to_world(x: number, y: number, camera?: Url | number): Vector3;
170
+ /**
171
+ * Sets the manual aspect ratio for the camera. This value is only used when
172
+ * auto aspect ratio is disabled. To disable auto aspect ratio and use this
173
+ * manual value, call camera.set_auto_aspect_ratio(camera, false).
174
+ *
175
+ * @param camera - camera id
176
+ * @param aspect_ratio - the manual aspect ratio value.
177
+ */
178
+ function set_aspect_ratio(camera: Url | number, aspect_ratio: number): void;
179
+ /**
180
+ * Enables or disables automatic aspect ratio calculation. When enabled (true),
181
+ * the camera automatically calculates aspect ratio from render target dimensions.
182
+ * When disabled (false), uses the manually set aspect ratio value.
183
+ *
184
+ * @param camera - camera id
185
+ * @param auto_aspect_ratio - true to enable auto aspect ratio
186
+ */
187
+ function set_auto_aspect_ratio(camera: Url | number, auto_aspect_ratio: boolean): void;
188
+ /**
189
+ * set far z
190
+ *
191
+ * @param camera - camera id
192
+ * @param far_z - the far z.
193
+ */
194
+ function set_far_z(camera: Url | number, far_z: number): void;
195
+ /**
196
+ * set field of view
197
+ *
198
+ * @param camera - camera id
199
+ * @param fov - the field of view.
200
+ */
201
+ function set_fov(camera: Url | number, fov: number): void;
202
+ /**
203
+ * set near z
204
+ *
205
+ * @param camera - camera id
206
+ * @param near_z - the near z.
207
+ */
208
+ function set_near_z(camera: Url | number, near_z: number): void;
209
+ /**
210
+ * set orthographic zoom mode
211
+ *
212
+ * @param camera - camera id
213
+ * @param mode - camera.ORTHO_MODE_FIXED, camera.ORTHO_MODE_AUTO_FIT or camera.ORTHO_MODE_AUTO_COVER
214
+ */
215
+ function set_orthographic_mode(camera: Url | number, mode: number): void;
216
+ /**
217
+ * set orthographic zoom
218
+ *
219
+ * @param camera - camera id
220
+ * @param orthographic_zoom - the zoom level when the camera uses orthographic projection.
221
+ */
222
+ function set_orthographic_zoom(camera: Url | number, orthographic_zoom: number): void;
223
+ /**
224
+ * Converts a 3D world position to screen-space coordinates with view depth.
225
+ * Returns a vector3 where x and y are in screen pixels and z is the view depth in world units
226
+ * measured from the camera plane along the camera forward axis. The returned z can be used with
227
+ * camera.screen_to_world to reconstruct the world position on the same pixel ray.
228
+ * If a camera isn't specified, the last enabled camera is used.
229
+ *
230
+ * @param world_pos - World-space position
231
+ * @param camera - optional camera id
232
+ * @returns Screen position (x,y in pixels, z is view depth)
233
+ * @example
234
+ * ```ts
235
+ * // Convert a game object position into a screen position.
236
+ * go.update_world_transform("/go1");
237
+ * const world_pos = go.get_world_position("/go1");
238
+ * const screen_pos = camera.world_to_screen(world_pos);
239
+ * ```
240
+ */
241
+ function world_to_screen(world_pos: Vector3, camera?: Url | number): Vector3;
7
242
  }
8
243
  }
9
244
 
@@ -85,8 +85,11 @@ declare global {
85
85
  *
86
86
  * @param url - the collection factory component to get status from
87
87
  * @returns status of the collection factory component
88
+ *
88
89
  * - `collectionfactory.STATUS_UNLOADED`
90
+ *
89
91
  * - `collectionfactory.STATUS_LOADING`
92
+ *
90
93
  * - `collectionfactory.STATUS_LOADED`
91
94
  */
92
95
  function get_status(url?: string | Hash | Url): Opaque<"constant">;
@@ -96,6 +99,7 @@ declare global {
96
99
  *
97
100
  * @param url - the collection factory component to load
98
101
  * @param complete_function - function to call when resources are loaded.
102
+ *
99
103
  * `self`
100
104
  * object The current object.
101
105
  * `url`
@@ -63,8 +63,11 @@ declare global {
63
63
  *
64
64
  * @param url - the factory component to get status from
65
65
  * @returns status of the factory component
66
+ *
66
67
  * - `factory.STATUS_UNLOADED`
68
+ *
67
69
  * - `factory.STATUS_LOADING`
70
+ *
68
71
  * - `factory.STATUS_LOADED`
69
72
  */
70
73
  function get_status(url?: string | Hash | Url): Opaque<"constant">;
@@ -74,6 +77,7 @@ declare global {
74
77
  *
75
78
  * @param url - the factory component to load
76
79
  * @param complete_function - function to call when resources are loaded.
80
+ *
77
81
  * `self`
78
82
  * object The current object.
79
83
  * `url`