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