@defold-typescript/types 0.5.3 → 0.5.5
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/generated/go.d.ts +180 -179
- package/generated/msg.d.ts +9 -9
- package/generated/sprite.d.ts +33 -32
- package/generated/vmath.d.ts +232 -229
- package/package.json +1 -1
- package/scripts/example-store-io.ts +18 -0
- package/scripts/regen.ts +5 -1
- package/src/doc-comment.ts +2 -1
- package/src/emit-dts.ts +19 -5
- package/src/example-store.ts +44 -0
- package/src/go-overloads.d.ts +30 -0
- package/src/message-dispatch.d.ts +21 -0
- package/src/message-guard.d.ts +19 -0
- package/src/msg-overloads.d.ts +20 -0
package/generated/go.d.ts
CHANGED
|
@@ -226,27 +226,22 @@ declare global {
|
|
|
226
226
|
* `property`
|
|
227
227
|
* hash The id of the animated property.
|
|
228
228
|
* @example
|
|
229
|
-
* ```
|
|
230
|
-
* Animate the position of a game object to x = 10 during 1 second, then
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* 1, 1, 1, 1, 1, 1, 1, 1,
|
|
246
|
-
* 0, 0, 0, 0, 0, 0, 0, 0,
|
|
247
|
-
* 1, 1, 1, 1, 1, 1, 1, 1 }
|
|
248
|
-
* local vec = vmath.vector(values)
|
|
249
|
-
* go.animate("go", "position.y", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0)
|
|
229
|
+
* ```ts
|
|
230
|
+
* // Animate the position of a game object to x = 10 during 1 second, then
|
|
231
|
+
* // y = 20 during 1 second:
|
|
232
|
+
* go.animate(go.get_id(), "position.x", go.PLAYBACK_ONCE_FORWARD, 10, go.EASING_LINEAR, 1, 0, () => {
|
|
233
|
+
* go.animate(go.get_id(), "position.y", go.PLAYBACK_ONCE_FORWARD, 20, go.EASING_LINEAR, 1);
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* // Animate the y position of a game object using a crazy custom easing curve:
|
|
237
|
+
* const values = [
|
|
238
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
239
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
240
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
241
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
242
|
+
* ];
|
|
243
|
+
* const vec = vmath.vector(values);
|
|
244
|
+
* go.animate("go", "position.y", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0);
|
|
250
245
|
* ```
|
|
251
246
|
*/
|
|
252
247
|
export function animate(url: string | Hash | Url, property: string | Hash, playback: number & { readonly __brand: "go.PLAYBACK_ONCE_FORWARD" } | number & { readonly __brand: "go.PLAYBACK_ONCE_BACKWARD" } | number & { readonly __brand: "go.PLAYBACK_ONCE_PINGPONG" } | number & { readonly __brand: "go.PLAYBACK_LOOP_FORWARD" } | number & { readonly __brand: "go.PLAYBACK_LOOP_BACKWARD" } | number & { readonly __brand: "go.PLAYBACK_LOOP_PINGPONG" }, to: number | Vector3 | Vector4 | Quaternion, easing: Vector | number & { readonly __brand: "go.EASING_INBACK" } | number & { readonly __brand: "go.EASING_INBOUNCE" } | number & { readonly __brand: "go.EASING_INCIRC" } | number & { readonly __brand: "go.EASING_INCUBIC" } | number & { readonly __brand: "go.EASING_INELASTIC" } | number & { readonly __brand: "go.EASING_INEXPO" } | number & { readonly __brand: "go.EASING_INOUTBACK" } | number & { readonly __brand: "go.EASING_INOUTBOUNCE" } | number & { readonly __brand: "go.EASING_INOUTCIRC" } | number & { readonly __brand: "go.EASING_INOUTCUBIC" } | number & { readonly __brand: "go.EASING_INOUTELASTIC" } | number & { readonly __brand: "go.EASING_INOUTEXPO" } | number & { readonly __brand: "go.EASING_INOUTQUAD" } | number & { readonly __brand: "go.EASING_INOUTQUART" } | number & { readonly __brand: "go.EASING_INOUTQUINT" } | number & { readonly __brand: "go.EASING_INOUTSINE" } | number & { readonly __brand: "go.EASING_INQUAD" } | number & { readonly __brand: "go.EASING_INQUART" } | number & { readonly __brand: "go.EASING_INQUINT" } | number & { readonly __brand: "go.EASING_INSINE" } | number & { readonly __brand: "go.EASING_LINEAR" } | number & { readonly __brand: "go.EASING_OUTBACK" } | number & { readonly __brand: "go.EASING_OUTBOUNCE" } | number & { readonly __brand: "go.EASING_OUTCIRC" } | number & { readonly __brand: "go.EASING_OUTCUBIC" } | number & { readonly __brand: "go.EASING_OUTELASTIC" } | number & { readonly __brand: "go.EASING_OUTEXPO" } | number & { readonly __brand: "go.EASING_OUTINBACK" } | number & { readonly __brand: "go.EASING_OUTINBOUNCE" } | number & { readonly __brand: "go.EASING_OUTINCIRC" } | number & { readonly __brand: "go.EASING_OUTINCUBIC" } | number & { readonly __brand: "go.EASING_OUTINELASTIC" } | number & { readonly __brand: "go.EASING_OUTINEXPO" } | number & { readonly __brand: "go.EASING_OUTINQUAD" } | number & { readonly __brand: "go.EASING_OUTINQUART" } | number & { readonly __brand: "go.EASING_OUTINQUINT" } | number & { readonly __brand: "go.EASING_OUTINSINE" } | number & { readonly __brand: "go.EASING_OUTQUAD" } | number & { readonly __brand: "go.EASING_OUTQUART" } | number & { readonly __brand: "go.EASING_OUTQUINT" } | number & { readonly __brand: "go.EASING_OUTSINE" }, duration: number, delay?: number, complete_function?: (self: unknown, url: unknown, property: unknown) => void): void;
|
|
@@ -257,15 +252,15 @@ declare global {
|
|
|
257
252
|
* @param url - url of the game object or component
|
|
258
253
|
* @param property - optional id of the property to cancel
|
|
259
254
|
* @example
|
|
260
|
-
* ```
|
|
261
|
-
* Cancel the animation of the position of a game object:
|
|
262
|
-
* go.cancel_animations(go.get_id(), "position")
|
|
255
|
+
* ```ts
|
|
256
|
+
* // Cancel the animation of the position of a game object:
|
|
257
|
+
* go.cancel_animations(go.get_id(), "position");
|
|
263
258
|
*
|
|
264
|
-
* Cancel all property animations of the current game object:
|
|
265
|
-
* go.cancel_animations(".")
|
|
259
|
+
* // Cancel all property animations of the current game object:
|
|
260
|
+
* go.cancel_animations(".");
|
|
266
261
|
*
|
|
267
|
-
* Cancel all property animations of the sprite component of the current game object:
|
|
268
|
-
* go.cancel_animations("#sprite")
|
|
262
|
+
* // Cancel all property animations of the sprite component of the current game object:
|
|
263
|
+
* go.cancel_animations("#sprite");
|
|
269
264
|
* ```
|
|
270
265
|
*/
|
|
271
266
|
export function cancel_animations(url: string | Hash | Url, property?: string | Hash): void;
|
|
@@ -280,26 +275,27 @@ declare global {
|
|
|
280
275
|
* @param id - optional id or table of id's of the instance(s) to delete, the instance of the calling script is deleted by default
|
|
281
276
|
* @param recursive - optional boolean, set to true to recursively delete child hiearchy in child to parent order
|
|
282
277
|
* @example
|
|
283
|
-
* ```
|
|
284
|
-
* This example demonstrates how to delete game objects
|
|
285
|
-
*
|
|
286
|
-
* go.delete()
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
* go.delete(id)
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* go.delete(ids)
|
|
293
|
-
*
|
|
294
|
-
* This example demonstrates how to delete
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* go.
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
278
|
+
* ```ts
|
|
279
|
+
* // This example demonstrates how to delete game objects:
|
|
280
|
+
* // Delete the script's own game object.
|
|
281
|
+
* go.delete();
|
|
282
|
+
* // Delete a game object with the id "my_game_object".
|
|
283
|
+
* const id = go.get_id("my_game_object");
|
|
284
|
+
* go.delete(id);
|
|
285
|
+
* // Delete a list of game objects.
|
|
286
|
+
* const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
|
|
287
|
+
* go.delete(ids);
|
|
288
|
+
*
|
|
289
|
+
* // This example demonstrates how to delete game objects and their children
|
|
290
|
+
* // (child-to-parent order):
|
|
291
|
+
* // Delete the script's own game object and its children.
|
|
292
|
+
* go.delete(true);
|
|
293
|
+
* // Delete a game object with the id "my_game_object" and its children.
|
|
294
|
+
* const id2 = go.get_id("my_game_object");
|
|
295
|
+
* go.delete(id2, true);
|
|
296
|
+
* // Delete a list of game objects and their children.
|
|
297
|
+
* const ids2 = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
|
|
298
|
+
* go.delete(ids2, true);
|
|
303
299
|
* ```
|
|
304
300
|
*/
|
|
305
301
|
function _delete(id?: string | Hash | Url | (string | Hash | Url)[], recursive?: boolean): void;
|
|
@@ -310,12 +306,12 @@ declare global {
|
|
|
310
306
|
* @param url - url of the game object to check
|
|
311
307
|
* @returns true if the game object exists
|
|
312
308
|
* @example
|
|
313
|
-
* ```
|
|
314
|
-
* Check if game object "my_game_object" exists in the current collection
|
|
315
|
-
* go.exists("/my_game_object")
|
|
309
|
+
* ```ts
|
|
310
|
+
* // Check if game object "my_game_object" exists in the current collection:
|
|
311
|
+
* go.exists("/my_game_object");
|
|
316
312
|
*
|
|
317
|
-
* Check if game object exists in another collection
|
|
318
|
-
* go.exists("other_collection:/my_game_object")
|
|
313
|
+
* // Check if game object exists in another collection:
|
|
314
|
+
* go.exists("other_collection:/my_game_object");
|
|
319
315
|
* ```
|
|
320
316
|
*/
|
|
321
317
|
export function exists(url: string | Hash | Url): boolean;
|
|
@@ -353,16 +349,17 @@ declare global {
|
|
|
353
349
|
* @param path - path of the instance for which to return the id
|
|
354
350
|
* @returns instance id
|
|
355
351
|
* @example
|
|
356
|
-
* ```
|
|
357
|
-
* For the instance with path /my_sub_collection/my_instance, the following calls
|
|
358
|
-
*
|
|
359
|
-
*
|
|
352
|
+
* ```ts
|
|
353
|
+
* // For the instance with path /my_sub_collection/my_instance, the following calls
|
|
354
|
+
* // are equivalent:
|
|
355
|
+
* const id = go.get_id(); // no path, defaults to the instance containing the calling script
|
|
356
|
+
* print(id); // => hash: [/my_sub_collection/my_instance]
|
|
360
357
|
*
|
|
361
|
-
*
|
|
362
|
-
* print(
|
|
358
|
+
* const id2 = go.get_id("/my_sub_collection/my_instance"); // absolute path
|
|
359
|
+
* print(id2); // => hash: [/my_sub_collection/my_instance]
|
|
363
360
|
*
|
|
364
|
-
*
|
|
365
|
-
* print(
|
|
361
|
+
* const id3 = go.get_id("my_instance"); // relative path
|
|
362
|
+
* print(id3); // => hash: [/my_sub_collection/my_instance]
|
|
366
363
|
* ```
|
|
367
364
|
*/
|
|
368
365
|
export function get_id(path?: string): Hash;
|
|
@@ -372,12 +369,12 @@ declare global {
|
|
|
372
369
|
* @param id - optional id of the game object instance to get parent for, defaults to the instance containing the calling script
|
|
373
370
|
* @returns parent instance or `nil`
|
|
374
371
|
* @example
|
|
375
|
-
* ```
|
|
376
|
-
* Get parent of the instance containing the calling script:
|
|
377
|
-
*
|
|
372
|
+
* ```ts
|
|
373
|
+
* // Get parent of the instance containing the calling script:
|
|
374
|
+
* const parent_id = go.get_parent();
|
|
378
375
|
*
|
|
379
|
-
* Get parent of the instance with id "x":
|
|
380
|
-
*
|
|
376
|
+
* // Get parent of the instance with id "x":
|
|
377
|
+
* const parent_id2 = go.get_parent("x");
|
|
381
378
|
* ```
|
|
382
379
|
*/
|
|
383
380
|
export function get_parent(id?: string | Hash | Url): Hash | unknown;
|
|
@@ -387,12 +384,12 @@ declare global {
|
|
|
387
384
|
* @param id - optional id of the game object instance to get the position for, by default the instance of the calling script
|
|
388
385
|
* @returns instance position
|
|
389
386
|
* @example
|
|
390
|
-
* ```
|
|
391
|
-
* Get the position of the game object
|
|
392
|
-
*
|
|
387
|
+
* ```ts
|
|
388
|
+
* // Get the position of the game object the script is attached to:
|
|
389
|
+
* const p = go.get_position();
|
|
393
390
|
*
|
|
394
|
-
* Get the position of another game object
|
|
395
|
-
*
|
|
391
|
+
* // Get the position of another game object "my_gameobject":
|
|
392
|
+
* const pos = go.get_position("my_gameobject");
|
|
396
393
|
* ```
|
|
397
394
|
*/
|
|
398
395
|
export function get_position(id?: string | Hash | Url): Vector3;
|
|
@@ -402,12 +399,12 @@ declare global {
|
|
|
402
399
|
* @param id - optional id of the game object instance to get the rotation for, by default the instance of the calling script
|
|
403
400
|
* @returns instance rotation
|
|
404
401
|
* @example
|
|
405
|
-
* ```
|
|
406
|
-
* Get the rotation of the game object
|
|
407
|
-
*
|
|
402
|
+
* ```ts
|
|
403
|
+
* // Get the rotation of the game object the script is attached to:
|
|
404
|
+
* const r = go.get_rotation();
|
|
408
405
|
*
|
|
409
|
-
* Get the rotation of another game object
|
|
410
|
-
*
|
|
406
|
+
* // Get the rotation of another game object with id "x":
|
|
407
|
+
* const r2 = go.get_rotation("x");
|
|
411
408
|
* ```
|
|
412
409
|
*/
|
|
413
410
|
export function get_rotation(id?: string | Hash | Url): Quaternion;
|
|
@@ -417,12 +414,12 @@ declare global {
|
|
|
417
414
|
* @param id - optional id of the game object instance to get the scale for, by default the instance of the calling script
|
|
418
415
|
* @returns instance scale factor
|
|
419
416
|
* @example
|
|
420
|
-
* ```
|
|
421
|
-
* Get the scale of the game object
|
|
422
|
-
*
|
|
417
|
+
* ```ts
|
|
418
|
+
* // Get the scale of the game object the script is attached to:
|
|
419
|
+
* const s = go.get_scale();
|
|
423
420
|
*
|
|
424
|
-
* Get the scale of another game object
|
|
425
|
-
*
|
|
421
|
+
* // Get the scale of another game object with id "x":
|
|
422
|
+
* const s2 = go.get_scale("x");
|
|
426
423
|
* ```
|
|
427
424
|
*/
|
|
428
425
|
export function get_scale(id?: string | Hash | Url): Vector3;
|
|
@@ -432,12 +429,12 @@ declare global {
|
|
|
432
429
|
* @param id - optional id of the game object instance to get the uniform scale for, by default the instance of the calling script
|
|
433
430
|
* @returns uniform instance scale factor
|
|
434
431
|
* @example
|
|
435
|
-
* ```
|
|
436
|
-
* Get the scale of the game object
|
|
437
|
-
*
|
|
432
|
+
* ```ts
|
|
433
|
+
* // Get the uniform scale of the game object the script is attached to:
|
|
434
|
+
* const s = go.get_scale_uniform();
|
|
438
435
|
*
|
|
439
|
-
* Get the uniform scale of another game object
|
|
440
|
-
*
|
|
436
|
+
* // Get the uniform scale of another game object with id "x":
|
|
437
|
+
* const s2 = go.get_scale_uniform("x");
|
|
441
438
|
* ```
|
|
442
439
|
*/
|
|
443
440
|
export function get_scale_uniform(id?: string | Hash | Url): number;
|
|
@@ -449,12 +446,12 @@ declare global {
|
|
|
449
446
|
* @param id - optional id of the game object instance to get the world position for, by default the instance of the calling script
|
|
450
447
|
* @returns instance world position
|
|
451
448
|
* @example
|
|
452
|
-
* ```
|
|
453
|
-
* Get the world position of the game object
|
|
454
|
-
*
|
|
449
|
+
* ```ts
|
|
450
|
+
* // Get the world position of the game object the script is attached to:
|
|
451
|
+
* const p = go.get_world_position();
|
|
455
452
|
*
|
|
456
|
-
* Get the world position of another game object
|
|
457
|
-
*
|
|
453
|
+
* // Get the world position of another game object with id "x":
|
|
454
|
+
* const p2 = go.get_world_position("x");
|
|
458
455
|
* ```
|
|
459
456
|
*/
|
|
460
457
|
export function get_world_position(id?: string | Hash | Url): Vector3;
|
|
@@ -466,12 +463,12 @@ declare global {
|
|
|
466
463
|
* @param id - optional id of the game object instance to get the world rotation for, by default the instance of the calling script
|
|
467
464
|
* @returns instance world rotation
|
|
468
465
|
* @example
|
|
469
|
-
* ```
|
|
470
|
-
* Get the world rotation of the game object
|
|
471
|
-
*
|
|
466
|
+
* ```ts
|
|
467
|
+
* // Get the world rotation of the game object the script is attached to:
|
|
468
|
+
* const r = go.get_world_rotation();
|
|
472
469
|
*
|
|
473
|
-
* Get the world rotation of another game object
|
|
474
|
-
*
|
|
470
|
+
* // Get the world rotation of another game object with id "x":
|
|
471
|
+
* const r2 = go.get_world_rotation("x");
|
|
475
472
|
* ```
|
|
476
473
|
*/
|
|
477
474
|
export function get_world_rotation(id?: string | Hash | Url): Quaternion;
|
|
@@ -485,12 +482,12 @@ declare global {
|
|
|
485
482
|
* @param id - optional id of the game object instance to get the world scale for, by default the instance of the calling script
|
|
486
483
|
* @returns instance world 3D scale factor
|
|
487
484
|
* @example
|
|
488
|
-
* ```
|
|
489
|
-
* Get the world 3D scale of the game object
|
|
490
|
-
*
|
|
485
|
+
* ```ts
|
|
486
|
+
* // Get the world 3D scale of the game object the script is attached to:
|
|
487
|
+
* const s = go.get_world_scale();
|
|
491
488
|
*
|
|
492
|
-
* Get the world scale of another game object
|
|
493
|
-
*
|
|
489
|
+
* // Get the world scale of another game object "x":
|
|
490
|
+
* const s2 = go.get_world_scale("x");
|
|
494
491
|
* ```
|
|
495
492
|
*/
|
|
496
493
|
export function get_world_scale(id?: string | Hash | Url): Vector3;
|
|
@@ -502,12 +499,12 @@ declare global {
|
|
|
502
499
|
* @param id - optional id of the game object instance to get the world scale for, by default the instance of the calling script
|
|
503
500
|
* @returns instance world scale factor
|
|
504
501
|
* @example
|
|
505
|
-
* ```
|
|
506
|
-
* Get the world scale of the game object
|
|
507
|
-
*
|
|
502
|
+
* ```ts
|
|
503
|
+
* // Get the world uniform scale of the game object the script is attached to:
|
|
504
|
+
* const s = go.get_world_scale_uniform();
|
|
508
505
|
*
|
|
509
|
-
* Get the world scale of another game object
|
|
510
|
-
*
|
|
506
|
+
* // Get the world uniform scale of another game object with id "x":
|
|
507
|
+
* const s2 = go.get_world_scale_uniform("x");
|
|
511
508
|
* ```
|
|
512
509
|
*/
|
|
513
510
|
export function get_world_scale_uniform(id?: string | Hash | Url): number;
|
|
@@ -518,12 +515,12 @@ declare global {
|
|
|
518
515
|
* @param id - optional id of the game object instance to get the world transform for, by default the instance of the calling script
|
|
519
516
|
* @returns instance world transform
|
|
520
517
|
* @example
|
|
521
|
-
* ```
|
|
522
|
-
* Get the world transform of the game object
|
|
523
|
-
*
|
|
518
|
+
* ```ts
|
|
519
|
+
* // Get the world transform of the game object the script is attached to:
|
|
520
|
+
* const m = go.get_world_transform();
|
|
524
521
|
*
|
|
525
|
-
* Get the world transform of another game object
|
|
526
|
-
*
|
|
522
|
+
* // Get the world transform of another game object with id "x":
|
|
523
|
+
* const m2 = go.get_world_transform("x");
|
|
527
524
|
* ```
|
|
528
525
|
*/
|
|
529
526
|
export function get_world_transform(id?: string | Hash | Url): Matrix4;
|
|
@@ -763,22 +760,24 @@ declare global {
|
|
|
763
760
|
* @param name - the id of the property
|
|
764
761
|
* @param value - default value of the property. In the case of a url, only the empty constructor msg.url() is allowed. In the case of a resource one of the resource constructors (eg resource.atlas(), resource.font() etc) is expected.
|
|
765
762
|
* @example
|
|
766
|
-
* ```
|
|
767
|
-
* This example
|
|
768
|
-
*
|
|
769
|
-
* go.property("health", 100)
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
763
|
+
* ```ts
|
|
764
|
+
* // This example defines a property "health" in a script. The health is decreased
|
|
765
|
+
* // whenever someone sends a "take_damage" message to the script.
|
|
766
|
+
* go.property("health", 100);
|
|
767
|
+
*
|
|
768
|
+
* export default defineScript({
|
|
769
|
+
* init(self) {
|
|
770
|
+
* // prints 100 to the output
|
|
771
|
+
* print(self.health);
|
|
772
|
+
* },
|
|
773
|
+
*
|
|
774
|
+
* on_message(self, message_id, message) {
|
|
775
|
+
* if (message_id === hash("take_damage")) {
|
|
776
|
+
* self.health = self.health - message.damage;
|
|
777
|
+
* print(`Ouch! My health is now: ${self.health}`);
|
|
778
|
+
* }
|
|
779
|
+
* },
|
|
780
|
+
* });
|
|
782
781
|
* ```
|
|
783
782
|
*/
|
|
784
783
|
export function property(name: string, value: number | Hash | Url | Vector3 | Vector4 | Quaternion | Opaque<"resource"> | boolean): void;
|
|
@@ -794,15 +793,15 @@ declare global {
|
|
|
794
793
|
* @param parent_id - optional id of the new parent game object, defaults to detaching game object from its parent
|
|
795
794
|
* @param keep_world_transform - optional boolean, set to true to maintain the world transform when changing spaces. Defaults to false.
|
|
796
795
|
* @example
|
|
797
|
-
* ```
|
|
798
|
-
* Attach myself to another instance "my_parent":
|
|
799
|
-
* go.set_parent(go.get_id(),go.get_id("my_parent"))
|
|
796
|
+
* ```ts
|
|
797
|
+
* // Attach myself to another instance "my_parent":
|
|
798
|
+
* go.set_parent(go.get_id(), go.get_id("my_parent"));
|
|
800
799
|
*
|
|
801
|
-
* Attach an instance "my_instance" to another instance "my_parent":
|
|
802
|
-
* go.set_parent(go.get_id("my_instance"),go.get_id("my_parent"))
|
|
800
|
+
* // Attach an instance "my_instance" to another instance "my_parent":
|
|
801
|
+
* go.set_parent(go.get_id("my_instance"), go.get_id("my_parent"));
|
|
803
802
|
*
|
|
804
|
-
* Detach an instance "my_instance" from its parent (if any):
|
|
805
|
-
* go.set_parent(go.get_id("my_instance"))
|
|
803
|
+
* // Detach an instance "my_instance" from its parent (if any):
|
|
804
|
+
* go.set_parent(go.get_id("my_instance"));
|
|
806
805
|
* ```
|
|
807
806
|
*/
|
|
808
807
|
export function set_parent(id?: string | Hash | Url, parent_id?: string | Hash | Url, keep_world_transform?: boolean): void;
|
|
@@ -812,14 +811,15 @@ declare global {
|
|
|
812
811
|
* @param position - position to set
|
|
813
812
|
* @param id - optional id of the game object instance to set the position for, by default the instance of the calling script
|
|
814
813
|
* @example
|
|
815
|
-
* ```
|
|
816
|
-
*
|
|
817
|
-
*
|
|
818
|
-
* go.set_position(p)
|
|
814
|
+
* ```ts
|
|
815
|
+
* // `p` is the desired position (a Vector3).
|
|
816
|
+
* const p = vmath.vector3();
|
|
819
817
|
*
|
|
820
|
-
* Set the position of
|
|
821
|
-
*
|
|
822
|
-
*
|
|
818
|
+
* // Set the position of the game object the script is attached to:
|
|
819
|
+
* go.set_position(p);
|
|
820
|
+
*
|
|
821
|
+
* // Set the position of another game object with id "x":
|
|
822
|
+
* go.set_position(p, "x");
|
|
823
823
|
* ```
|
|
824
824
|
*/
|
|
825
825
|
export function set_position(position: Vector3, id?: string | Hash | Url): void;
|
|
@@ -829,14 +829,15 @@ declare global {
|
|
|
829
829
|
* @param rotation - rotation to set
|
|
830
830
|
* @param id - optional id of the game object instance to get the rotation for, by default the instance of the calling script
|
|
831
831
|
* @example
|
|
832
|
-
* ```
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
832
|
+
* ```ts
|
|
833
|
+
* // `r` is the desired rotation (a Quaternion).
|
|
834
|
+
* const r = vmath.quat();
|
|
835
|
+
*
|
|
836
|
+
* // Set the rotation of the game object the script is attached to:
|
|
837
|
+
* go.set_rotation(r);
|
|
836
838
|
*
|
|
837
|
-
* Set the rotation of another game object
|
|
838
|
-
*
|
|
839
|
-
* go.set_rotation(r, "x")
|
|
839
|
+
* // Set the rotation of another game object with id "x":
|
|
840
|
+
* go.set_rotation(r, "x");
|
|
840
841
|
* ```
|
|
841
842
|
*/
|
|
842
843
|
export function set_rotation(rotation: Quaternion, id?: string | Hash | Url): void;
|
|
@@ -847,14 +848,14 @@ declare global {
|
|
|
847
848
|
* @param scale - vector or uniform scale factor, must be greater than 0
|
|
848
849
|
* @param id - optional id of the game object instance to get the scale for, by default the instance of the calling script
|
|
849
850
|
* @example
|
|
850
|
-
* ```
|
|
851
|
-
* Set the scale of the game object
|
|
852
|
-
*
|
|
853
|
-
* go.set_scale(s)
|
|
854
|
-
*
|
|
855
|
-
* Set the scale of another game object
|
|
856
|
-
*
|
|
857
|
-
* go.set_scale(
|
|
851
|
+
* ```ts
|
|
852
|
+
* // Set the scale of the game object the script is attached to:
|
|
853
|
+
* const s = vmath.vector3(2.0, 1.0, 1.0);
|
|
854
|
+
* go.set_scale(s);
|
|
855
|
+
*
|
|
856
|
+
* // Set the scale of another game object with id "obj_id":
|
|
857
|
+
* const s2 = 1.2;
|
|
858
|
+
* go.set_scale(s2, "obj_id");
|
|
858
859
|
* ```
|
|
859
860
|
*/
|
|
860
861
|
export function set_scale(scale: number | Vector3, id?: string | Hash | Url): void;
|
|
@@ -865,14 +866,14 @@ declare global {
|
|
|
865
866
|
* @param scale - vector or uniform scale factor, must be greater than 0
|
|
866
867
|
* @param id - optional id of the game object instance to get the scale for, by default the instance of the calling script
|
|
867
868
|
* @example
|
|
868
|
-
* ```
|
|
869
|
-
* Set the scale of the game object
|
|
870
|
-
*
|
|
871
|
-
* go.set_scale_xy(s)
|
|
872
|
-
*
|
|
873
|
-
* Set the scale of another game object
|
|
874
|
-
*
|
|
875
|
-
* go.set_scale_xy(
|
|
869
|
+
* ```ts
|
|
870
|
+
* // Set the scale of the game object the script is attached to:
|
|
871
|
+
* const s = vmath.vector3(2.0, 1.0, 5.0);
|
|
872
|
+
* go.set_scale_xy(s); // z will not be set here, only x and y
|
|
873
|
+
*
|
|
874
|
+
* // Set the scale of another game object with id "obj_id":
|
|
875
|
+
* const s2 = 1.2;
|
|
876
|
+
* go.set_scale_xy(s2, "obj_id"); // z will not be set here, only x and y
|
|
876
877
|
* ```
|
|
877
878
|
*/
|
|
878
879
|
export function set_scale_xy(scale: number | Vector3, id?: string | Hash | Url): void;
|
|
@@ -908,12 +909,12 @@ declare global {
|
|
|
908
909
|
*
|
|
909
910
|
* @param id - optional id of the game object instance to update
|
|
910
911
|
* @example
|
|
911
|
-
* ```
|
|
912
|
-
* Update this game object's world transform:
|
|
913
|
-
* go.update_world_transform()
|
|
912
|
+
* ```ts
|
|
913
|
+
* // Update this game object's world transform:
|
|
914
|
+
* go.update_world_transform();
|
|
914
915
|
*
|
|
915
|
-
* Update another game object's world transform:
|
|
916
|
-
* go.update_world_transform("/other")
|
|
916
|
+
* // Update another game object's world transform:
|
|
917
|
+
* go.update_world_transform("/other");
|
|
917
918
|
* ```
|
|
918
919
|
*/
|
|
919
920
|
export function update_world_transform(id?: string | Hash | Url): void;
|
|
@@ -924,11 +925,11 @@ declare global {
|
|
|
924
925
|
* @param url - url of the game object which coordinate system convert to
|
|
925
926
|
* @returns converted position
|
|
926
927
|
* @example
|
|
927
|
-
* ```
|
|
928
|
-
* Convert position of "test" game object into coordinate space of "child" object.
|
|
929
|
-
*
|
|
930
|
-
*
|
|
931
|
-
*
|
|
928
|
+
* ```ts
|
|
929
|
+
* // Convert position of "test" game object into coordinate space of "child" object.
|
|
930
|
+
* const test_pos = go.get_world_position("/test");
|
|
931
|
+
* const child_pos = go.get_world_position("/child");
|
|
932
|
+
* const new_position = go.world_to_local_position(test_pos, "/child");
|
|
932
933
|
* ```
|
|
933
934
|
*/
|
|
934
935
|
export function world_to_local_position(position: Vector3, url: string | Hash | Url): Vector3;
|
|
@@ -939,11 +940,11 @@ declare global {
|
|
|
939
940
|
* @param url - url of the game object which coordinate system convert to
|
|
940
941
|
* @returns converted transformation
|
|
941
942
|
* @example
|
|
942
|
-
* ```
|
|
943
|
-
* Convert
|
|
944
|
-
*
|
|
945
|
-
*
|
|
946
|
-
*
|
|
943
|
+
* ```ts
|
|
944
|
+
* // Convert transform of "test" game object into coordinate space of "child" object.
|
|
945
|
+
* const test_transform = go.get_world_transform("/test");
|
|
946
|
+
* const child_transform = go.get_world_transform("/child");
|
|
947
|
+
* const result_transform = go.world_to_local_transform(test_transform, "/child");
|
|
947
948
|
* ```
|
|
948
949
|
*/
|
|
949
950
|
export function world_to_local_transform(transformation: Matrix4, url: string | Hash | Url): Matrix4;
|
package/generated/msg.d.ts
CHANGED
|
@@ -49,16 +49,16 @@ declare global {
|
|
|
49
49
|
* @param fragment - fragment of the URL
|
|
50
50
|
* @returns a new URL
|
|
51
51
|
* @example
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* const my_socket = "main"; // specify by valid name
|
|
54
|
+
* const my_path = hash("/my_collection/my_gameobject"); // specify as string or hash
|
|
55
|
+
* const my_fragment = "component"; // specify as string or hash
|
|
56
|
+
* const my_url = msg.url(my_socket, my_path, my_fragment);
|
|
57
57
|
*
|
|
58
|
-
* print(my_url)
|
|
59
|
-
* print(my_url.socket)
|
|
60
|
-
* print(my_url.path)
|
|
61
|
-
* print(my_url.fragment)
|
|
58
|
+
* print(my_url); // => url: [main:/my_collection/my_gameobject#component]
|
|
59
|
+
* print(my_url.socket); // => 786443 (internal numeric value)
|
|
60
|
+
* print(my_url.path); // => hash: [/my_collection/my_gameobject]
|
|
61
|
+
* print(my_url.fragment); // => hash: [component]
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
64
|
function url(socket?: string | Hash, path?: string | Hash, fragment?: string | Hash): Url;
|