hytopia 0.3.27 → 0.3.29

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 (58) hide show
  1. package/docs/server.audio.cutoffdistance.md +13 -0
  2. package/docs/server.audio.md +35 -0
  3. package/docs/server.audio.setcutoffdistance.md +57 -0
  4. package/docs/server.audio.setreferencedistance.md +4 -0
  5. package/docs/server.audioevent.md +14 -0
  6. package/docs/server.audioeventpayloads._audio.set_cutoff_distance_.md +16 -0
  7. package/docs/server.audioeventpayloads.md +19 -0
  8. package/docs/server.audiooptions.cutoffdistance.md +13 -0
  9. package/docs/server.audiooptions.md +20 -1
  10. package/docs/server.audiooptions.referencedistance.md +1 -1
  11. package/examples/hygrounds/assets/icons/ranks/bronze-1.png +0 -0
  12. package/examples/hygrounds/assets/icons/ranks/bronze-2.png +0 -0
  13. package/examples/hygrounds/assets/icons/ranks/bronze-3.png +0 -0
  14. package/examples/hygrounds/assets/icons/ranks/bronze-4.png +0 -0
  15. package/examples/hygrounds/assets/icons/ranks/bronze-5.png +0 -0
  16. package/examples/hygrounds/assets/icons/ranks/diamond-1.png +0 -0
  17. package/examples/hygrounds/assets/icons/ranks/diamond-2.png +0 -0
  18. package/examples/hygrounds/assets/icons/ranks/diamond-3.png +0 -0
  19. package/examples/hygrounds/assets/icons/ranks/diamond-4.png +0 -0
  20. package/examples/hygrounds/assets/icons/ranks/diamond-5.png +0 -0
  21. package/examples/hygrounds/assets/icons/ranks/elite-1.png +0 -0
  22. package/examples/hygrounds/assets/icons/ranks/elite-2.png +0 -0
  23. package/examples/hygrounds/assets/icons/ranks/elite-3.png +0 -0
  24. package/examples/hygrounds/assets/icons/ranks/elite-4.png +0 -0
  25. package/examples/hygrounds/assets/icons/ranks/elite-5.png +0 -0
  26. package/examples/hygrounds/assets/icons/ranks/gold-1.png +0 -0
  27. package/examples/hygrounds/assets/icons/ranks/gold-2.png +0 -0
  28. package/examples/hygrounds/assets/icons/ranks/gold-3.png +0 -0
  29. package/examples/hygrounds/assets/icons/ranks/gold-4.png +0 -0
  30. package/examples/hygrounds/assets/icons/ranks/gold-5.png +0 -0
  31. package/examples/hygrounds/assets/icons/ranks/platinum-1.png +0 -0
  32. package/examples/hygrounds/assets/icons/ranks/platinum-2.png +0 -0
  33. package/examples/hygrounds/assets/icons/ranks/platinum-3.png +0 -0
  34. package/examples/hygrounds/assets/icons/ranks/platinum-4.png +0 -0
  35. package/examples/hygrounds/assets/icons/ranks/platinum-5.png +0 -0
  36. package/examples/hygrounds/assets/icons/ranks/silver-1.png +0 -0
  37. package/examples/hygrounds/assets/icons/ranks/silver-2.png +0 -0
  38. package/examples/hygrounds/assets/icons/ranks/silver-3.png +0 -0
  39. package/examples/hygrounds/assets/icons/ranks/silver-4.png +0 -0
  40. package/examples/hygrounds/assets/icons/ranks/silver-5.png +0 -0
  41. package/examples/hygrounds/assets/icons/ranks/unranked.png +0 -0
  42. package/examples/hygrounds/assets/ui/index.html +305 -44
  43. package/examples/hygrounds/classes/ChestEntity.ts +1 -0
  44. package/examples/hygrounds/classes/GameManager.ts +17 -7
  45. package/examples/hygrounds/classes/GamePlayerEntity.ts +103 -3
  46. package/examples/hygrounds/classes/GunEntity.ts +3 -0
  47. package/examples/hygrounds/classes/ItemEntity.ts +1 -0
  48. package/examples/hygrounds/classes/MeleeWeaponEntity.ts +2 -0
  49. package/examples/hygrounds/classes/weapons/PistolEntity.ts +1 -1
  50. package/examples/hygrounds/classes/weapons/RocketLauncherEntity.ts +2 -1
  51. package/examples/hygrounds/dev/persistence/player-player-1.json +3 -0
  52. package/examples/hygrounds/dev/persistence/player-player-2.json +3 -0
  53. package/examples/hygrounds/dev/persistence/player-player-3.json +3 -0
  54. package/examples/hygrounds/gameConfig.ts +281 -21
  55. package/package.json +1 -1
  56. package/server.api.json +173 -2
  57. package/server.d.ts +33 -1
  58. package/server.js +114 -114
@@ -44,18 +44,18 @@ export const BLOCK_ID_MATERIALS: Record<string | number, number> = {
44
44
 
45
45
  export const BUILD_BLOCK_ID = 37; // stone
46
46
 
47
- export const CHEST_DROP_INTERVAL_MS = 15 * 1000; // 20 seconds
47
+ export const CHEST_DROP_INTERVAL_MS = 15 * 1000; // 15 seconds
48
48
 
49
49
  export const CHEST_DROP_REGION_AABB = {
50
50
  min: { x: -45, y: 100, z: -45 },
51
51
  max: { x: 45, y: 100, z: 45 },
52
52
  };
53
53
 
54
- export const CHEST_SPAWNS_AT_START = 15;
54
+ export const CHEST_SPAWNS_AT_START = 20;
55
55
 
56
56
  export const CHEST_MAX_DROP_ITEMS = 2;
57
57
 
58
- export const CHEST_OPEN_DESPAWN_MS = 20 * 1000; // 20 seconds
58
+ export const CHEST_OPEN_DESPAWN_MS = 10 * 1000; // 10 seconds
59
59
 
60
60
  export const CHEST_DROP_ITEMS = [
61
61
  {
@@ -92,7 +92,7 @@ export const CHEST_DROP_ITEMS = [
92
92
  },
93
93
  {
94
94
  itemId: 'pistol',
95
- pickWeight: 1.5,
95
+ pickWeight: 0.8,
96
96
  },
97
97
  {
98
98
  itemId: 'revolver',
@@ -339,9 +339,9 @@ export const CHEST_SPAWNS = [
339
339
  },
340
340
  ];
341
341
 
342
- export const GAME_DURATION_MS = 10 * 60 * 1000; // 10 minutes
342
+ export const GAME_DURATION_MS = 8 * 60 * 1000; // 8 minutes
343
343
 
344
- export const ITEM_DESPAWN_TIME_MS = 30 * 1000; // 30 seconds
344
+ export const ITEM_DESPAWN_TIME_MS = 25 * 1000; // 25 seconds
345
345
 
346
346
  export const ITEM_SPAWNS = [
347
347
  { position: { x: -21.5, y: 2, z: -17 } },
@@ -364,66 +364,326 @@ export const ITEM_SPAWNS = [
364
364
  export const ITEM_SPAWN_ITEMS = [
365
365
  {
366
366
  itemId: 'ak47',
367
- pickWeight: 0.05,
367
+ pickWeight: 0.5,
368
368
  },
369
369
  {
370
370
  itemId: 'auto-shotgun',
371
- pickWeight: 0.05,
371
+ pickWeight: 0.5,
372
372
  },
373
373
  {
374
374
  itemId: 'auto-sniper',
375
- pickWeight: 0.05,
375
+ pickWeight: 0.5,
376
376
  },
377
377
  {
378
378
  itemId: 'bolt-action-sniper',
379
- pickWeight: 0.05,
379
+ pickWeight: 0.5,
380
380
  },
381
381
  {
382
382
  itemId: 'gravity-potion',
383
- pickWeight: 0.05,
383
+ pickWeight: 0.5,
384
384
  },
385
385
  {
386
386
  itemId: 'light-machine-gun',
387
- pickWeight: 0.05,
387
+ pickWeight: 0.5,
388
388
  },
389
389
  {
390
390
  itemId: 'medpack',
391
- pickWeight: 1,
391
+ pickWeight: 0.5,
392
392
  },
393
393
  {
394
394
  itemId: 'mining-drill',
395
- pickWeight: 0.05,
395
+ pickWeight: 0.5,
396
396
  },
397
397
  {
398
398
  itemId: 'pistol',
399
- pickWeight: 1,
399
+ pickWeight: 0.3,
400
400
  },
401
401
  {
402
402
  itemId: 'revolver',
403
- pickWeight: 0.1,
403
+ pickWeight: 0.5,
404
404
  },
405
405
  {
406
406
  itemId: 'rocket-launcher',
407
- pickWeight: 0.03,
407
+ pickWeight: 0.3,
408
408
  },
409
409
  {
410
410
  itemId: 'shotgun',
411
- pickWeight: 0.08,
411
+ pickWeight: 0.8,
412
412
  },
413
413
  {
414
414
  itemId: 'shield-potion',
415
- pickWeight: 1,
415
+ pickWeight: 0.5,
416
416
  },
417
417
  {
418
418
  itemId: 'submachine-gun',
419
- pickWeight: 0.05,
419
+ pickWeight: 0.5,
420
420
  },
421
421
  ];
422
422
 
423
- export const ITEM_SPAWNS_AT_START = 8;
423
+ export const ITEM_SPAWNS_AT_START = 12;
424
424
 
425
425
  export const MINIMUM_PLAYERS_TO_START = 2;
426
426
 
427
+ export const RANK_ASSIST_EXP = 20;
428
+ export const RANK_SAVE_INTERVAL_EXP = 500; // Every increment of this, save the persisted data.
429
+ export const RANK_KILL_EXP = 100;
430
+ export const RANK_WIN_EXP = 1000;
431
+ export const RANKS = [
432
+ {
433
+ name: 'Unranked',
434
+ totalExp: 0,
435
+ iconUri: 'icons/ranks/unranked.png',
436
+ unlocks: [],
437
+ },
438
+ {
439
+ name: 'Bronze I',
440
+ totalExp: 500,
441
+ iconUri: 'icons/ranks/bronze-1.png',
442
+ unlocks: [
443
+ 'Visible Rank & Medal - Your rank and medal will be visible to all players in game above your head.',
444
+ 'Bronze I Rank',
445
+ ]
446
+ },
447
+ {
448
+ name: 'Bronze II',
449
+ totalExp: 1000,
450
+ iconUri: 'icons/ranks/bronze-2.png',
451
+ unlocks: [
452
+ 'Bronze II Rank',
453
+ ]
454
+ },
455
+ {
456
+ name: 'Bronze III',
457
+ totalExp: 1500,
458
+ iconUri: 'icons/ranks/bronze-3.png',
459
+ unlocks: [
460
+ 'Bronze III Rank',
461
+ ]
462
+ },
463
+ {
464
+ name: 'Bronze IV',
465
+ totalExp: 2500,
466
+ iconUri: 'icons/ranks/bronze-4.png',
467
+ unlocks: [
468
+ 'Bronze IV Rank',
469
+ ]
470
+ },
471
+ {
472
+ name: 'Bronze V',
473
+ totalExp: 4000,
474
+ iconUri: 'icons/ranks/bronze-5.png',
475
+ unlocks: [
476
+ 'Bronze V Rank',
477
+ ]
478
+ },
479
+ {
480
+ name: 'Silver I',
481
+ totalExp: 6000,
482
+ iconUri: 'icons/ranks/silver-1.png',
483
+ unlocks: [
484
+ 'Competitive Matches - Your performance in any match that includes other Silver rank or higher players will affect your competitive ranking based on your relative finishing position.',
485
+ 'Silver I Rank',
486
+ ]
487
+ },
488
+ {
489
+ name: 'Silver II',
490
+ totalExp: 9000,
491
+ iconUri: 'icons/ranks/silver-2.png',
492
+ unlocks: [
493
+ 'Silver II Rank',
494
+ ]
495
+ },
496
+ {
497
+ name: 'Silver III',
498
+ totalExp: 13000,
499
+ iconUri: 'icons/ranks/silver-3.png',
500
+ unlocks: [
501
+ 'Silver III Rank',
502
+ ]
503
+ },
504
+ {
505
+ name: 'Silver IV',
506
+ totalExp: 18000,
507
+ iconUri: 'icons/ranks/silver-4.png',
508
+ unlocks: [
509
+ 'Silver IV Rank',
510
+ ]
511
+ },
512
+ {
513
+ name: 'Silver V',
514
+ totalExp: 24000,
515
+ iconUri: 'icons/ranks/silver-5.png',
516
+ unlocks: [
517
+ 'Silver V Rank',
518
+ ]
519
+ },
520
+ {
521
+ name: 'Gold I',
522
+ totalExp: 32000,
523
+ iconUri: 'icons/ranks/gold-1.png',
524
+ unlocks: [
525
+ 'Gold Flex - All weapons will be tinted gold when you hold them.',
526
+ 'Gold I Rank',
527
+ ]
528
+ },
529
+ {
530
+ name: 'Gold II',
531
+ totalExp: 42000,
532
+ iconUri: 'icons/ranks/gold-2.png',
533
+ unlocks: [
534
+ 'Gold II Rank',
535
+ ]
536
+ },
537
+ {
538
+ name: 'Gold III',
539
+ totalExp: 54000,
540
+ iconUri: 'icons/ranks/gold-3.png',
541
+ unlocks: [
542
+ 'Gold III Rank',
543
+ ]
544
+ },
545
+ {
546
+ name: 'Gold IV',
547
+ totalExp: 68000,
548
+ iconUri: 'icons/ranks/gold-4.png',
549
+ unlocks: [
550
+ 'Gold IV Rank',
551
+ ]
552
+ },
553
+ {
554
+ name: 'Gold V',
555
+ totalExp: 85000,
556
+ iconUri: 'icons/ranks/gold-5.png',
557
+ unlocks: [
558
+ 'Gold V Rank',
559
+ ]
560
+ },
561
+ {
562
+ name: 'Platinum I',
563
+ totalExp: 105000,
564
+ iconUri: 'icons/ranks/platinum-1.png',
565
+ unlocks: [
566
+ 'Celestial Hammer - Your pickaxe is replaced with a magnificent celestial hammer.',
567
+ 'Platinum I Rank',
568
+ ]
569
+ },
570
+ {
571
+ name: 'Platinum II',
572
+ totalExp: 130000,
573
+ iconUri: 'icons/ranks/platinum-2.png',
574
+ unlocks: [
575
+ 'Platinum II Rank',
576
+ ]
577
+ },
578
+ {
579
+ name: 'Platinum III',
580
+ totalExp: 160000,
581
+ iconUri: 'icons/ranks/platinum-3.png',
582
+ unlocks: [
583
+ 'Platinum III Rank',
584
+ ]
585
+ },
586
+ {
587
+ name: 'Platinum IV',
588
+ totalExp: 195000,
589
+ iconUri: 'icons/ranks/platinum-4.png',
590
+ unlocks: [
591
+ 'Platinum IV Rank',
592
+ ]
593
+ },
594
+ {
595
+ name: 'Platinum V',
596
+ totalExp: 235000,
597
+ iconUri: 'icons/ranks/platinum-5.png',
598
+ unlocks: [
599
+ 'Platinum V Rank',
600
+ ]
601
+ },
602
+ {
603
+ name: 'Diamond I',
604
+ totalExp: 280000,
605
+ iconUri: 'icons/ranks/diamond-1.png',
606
+ unlocks: [
607
+ 'Opulent Wings - Your character will be adorned with visual wings.',
608
+ 'Diamond I Rank',
609
+ ]
610
+ },
611
+ {
612
+ name: 'Diamond II',
613
+ totalExp: 330000,
614
+ iconUri: 'icons/ranks/diamond-2.png',
615
+ unlocks: [
616
+ 'Diamond II Rank',
617
+ ]
618
+ },
619
+ {
620
+ name: 'Diamond III',
621
+ totalExp: 385000,
622
+ iconUri: 'icons/ranks/diamond-3.png',
623
+ unlocks: [
624
+ 'Diamond III Rank',
625
+ ]
626
+ },
627
+ {
628
+ name: 'Diamond IV',
629
+ totalExp: 445000,
630
+ iconUri: 'icons/ranks/diamond-4.png',
631
+ unlocks: [
632
+ 'Diamond IV Rank',
633
+ ]
634
+ },
635
+ {
636
+ name: 'Diamond V',
637
+ totalExp: 510000,
638
+ iconUri: 'icons/ranks/diamond-5.png',
639
+ unlocks: [
640
+ 'Diamond V Rank',
641
+ ]
642
+ },
643
+ {
644
+ name: 'Elite I',
645
+ totalExp: 580000,
646
+ iconUri: 'icons/ranks/elite-1.png',
647
+ unlocks: [
648
+ 'Elite Outfit - Your character will be adorned with a special elite outfit.',
649
+ 'Elite I Rank',
650
+ ]
651
+ },
652
+ {
653
+ name: 'Elite II',
654
+ totalExp: 655000,
655
+ iconUri: 'icons/ranks/elite-2.png',
656
+ unlocks: [
657
+ 'Elite II Rank',
658
+ ]
659
+ },
660
+ {
661
+ name: 'Elite III',
662
+ totalExp: 735000,
663
+ iconUri: 'icons/ranks/elite-3.png',
664
+ unlocks: [
665
+ 'Elite III Rank',
666
+ ]
667
+ },
668
+ {
669
+ name: 'Elite IV',
670
+ totalExp: 820000,
671
+ iconUri: 'icons/ranks/elite-4.png',
672
+ unlocks: [
673
+ 'Elite IV Rank',
674
+ ]
675
+ },
676
+ {
677
+ name: 'Elite V',
678
+ totalExp: 910000,
679
+ iconUri: 'icons/ranks/elite-5.png',
680
+ unlocks: [
681
+ 'Highest Honor - Your character will receive something extremely special. You will need to reach this rank to find out what it is!',
682
+ 'Elite V Rank',
683
+ ]
684
+ },
685
+ ]
686
+
427
687
  export const SPAWN_REGION_AABB = {
428
688
  min: { x: -45, y: 30, z: -45 },
429
689
  max: { x: 45, y: 35, z: 45 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.3.27",
3
+ "version": "0.3.29",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.api.json CHANGED
@@ -275,6 +275,36 @@
275
275
  "isProtected": false,
276
276
  "isAbstract": false
277
277
  },
278
+ {
279
+ "kind": "Property",
280
+ "canonicalReference": "server!Audio#cutoffDistance:member",
281
+ "docComment": "/**\n * The cutoff distance where the audio will be reduced to 0 volume.\n */\n",
282
+ "excerptTokens": [
283
+ {
284
+ "kind": "Content",
285
+ "text": "get cutoffDistance(): "
286
+ },
287
+ {
288
+ "kind": "Content",
289
+ "text": "number"
290
+ },
291
+ {
292
+ "kind": "Content",
293
+ "text": ";"
294
+ }
295
+ ],
296
+ "isReadonly": true,
297
+ "isOptional": false,
298
+ "releaseTag": "Public",
299
+ "name": "cutoffDistance",
300
+ "propertyTypeTokenRange": {
301
+ "startIndex": 1,
302
+ "endIndex": 2
303
+ },
304
+ "isStatic": false,
305
+ "isProtected": false,
306
+ "isAbstract": false
307
+ },
278
308
  {
279
309
  "kind": "Property",
280
310
  "canonicalReference": "server!Audio#detune:member",
@@ -785,6 +815,54 @@
785
815
  "isAbstract": false,
786
816
  "name": "setAttachedToEntity"
787
817
  },
818
+ {
819
+ "kind": "Method",
820
+ "canonicalReference": "server!Audio#setCutoffDistance:member(1)",
821
+ "docComment": "/**\n * Sets the cutoff distance of the audio.\n *\n * @remarks\n *\n * The cutoff distance defines the maximum range at which the audio can be heard. Beyond this distance, the audio volume becomes zero. As the listener moves from the reference distance toward the cutoff distance, the volume decreases linearly, providing a natural spatial audio experience with smooth volume falloff based on distance.\n *\n * @param cutoffDistance - The cutoff distance.\n */\n",
822
+ "excerptTokens": [
823
+ {
824
+ "kind": "Content",
825
+ "text": "setCutoffDistance(cutoffDistance: "
826
+ },
827
+ {
828
+ "kind": "Content",
829
+ "text": "number"
830
+ },
831
+ {
832
+ "kind": "Content",
833
+ "text": "): "
834
+ },
835
+ {
836
+ "kind": "Content",
837
+ "text": "void"
838
+ },
839
+ {
840
+ "kind": "Content",
841
+ "text": ";"
842
+ }
843
+ ],
844
+ "isStatic": false,
845
+ "returnTypeTokenRange": {
846
+ "startIndex": 3,
847
+ "endIndex": 4
848
+ },
849
+ "releaseTag": "Public",
850
+ "isProtected": false,
851
+ "overloadIndex": 1,
852
+ "parameters": [
853
+ {
854
+ "parameterName": "cutoffDistance",
855
+ "parameterTypeTokenRange": {
856
+ "startIndex": 1,
857
+ "endIndex": 2
858
+ },
859
+ "isOptional": false
860
+ }
861
+ ],
862
+ "isOptional": false,
863
+ "isAbstract": false,
864
+ "name": "setCutoffDistance"
865
+ },
788
866
  {
789
867
  "kind": "Method",
790
868
  "canonicalReference": "server!Audio#setDetune:member(1)",
@@ -981,7 +1059,7 @@
981
1059
  {
982
1060
  "kind": "Method",
983
1061
  "canonicalReference": "server!Audio#setReferenceDistance:member(1)",
984
- "docComment": "/**\n * Sets the reference distance of the audio.\n *\n * @param referenceDistance - The reference distance.\n */\n",
1062
+ "docComment": "/**\n * Sets the reference distance of the audio.\n *\n * @remarks\n *\n * The reference distance defines the range within which the audio plays at full volume. When a listener is within this distance from the audio source, they will hear the sound at its maximum volume. Beyond this distance, the volume decreases linearly until reaching the cutoff distance, where the sound becomes inaudible. This creates a natural spatial audio experience with smooth volume falloff based on distance.\n *\n * @param referenceDistance - The reference distance.\n */\n",
985
1063
  "excerptTokens": [
986
1064
  {
987
1065
  "kind": "Content",
@@ -1310,6 +1388,27 @@
1310
1388
  "releaseTag": "Public",
1311
1389
  "name": "SET_ATTACHED_TO_ENTITY"
1312
1390
  },
1391
+ {
1392
+ "kind": "EnumMember",
1393
+ "canonicalReference": "server!AudioEvent.SET_CUTOFF_DISTANCE:member",
1394
+ "docComment": "",
1395
+ "excerptTokens": [
1396
+ {
1397
+ "kind": "Content",
1398
+ "text": "SET_CUTOFF_DISTANCE = "
1399
+ },
1400
+ {
1401
+ "kind": "Content",
1402
+ "text": "\"AUDIO.SET_CUTOFF_DISTANCE\""
1403
+ }
1404
+ ],
1405
+ "initializerTokenRange": {
1406
+ "startIndex": 1,
1407
+ "endIndex": 2
1408
+ },
1409
+ "releaseTag": "Public",
1410
+ "name": "SET_CUTOFF_DISTANCE"
1411
+ },
1313
1412
  {
1314
1413
  "kind": "EnumMember",
1315
1414
  "canonicalReference": "server!AudioEvent.SET_DETUNE:member",
@@ -1642,6 +1741,51 @@
1642
1741
  "endIndex": 8
1643
1742
  }
1644
1743
  },
1744
+ {
1745
+ "kind": "PropertySignature",
1746
+ "canonicalReference": "server!AudioEventPayloads#\"AUDIO.SET_CUTOFF_DISTANCE\":member",
1747
+ "docComment": "/**\n * Emitted when the audio's cutoff distance is set.\n */\n",
1748
+ "excerptTokens": [
1749
+ {
1750
+ "kind": "Content",
1751
+ "text": "["
1752
+ },
1753
+ {
1754
+ "kind": "Reference",
1755
+ "text": "AudioEvent.SET_CUTOFF_DISTANCE",
1756
+ "canonicalReference": "server!AudioEvent.SET_CUTOFF_DISTANCE:member"
1757
+ },
1758
+ {
1759
+ "kind": "Content",
1760
+ "text": "]: "
1761
+ },
1762
+ {
1763
+ "kind": "Content",
1764
+ "text": "{\n audio: "
1765
+ },
1766
+ {
1767
+ "kind": "Reference",
1768
+ "text": "Audio",
1769
+ "canonicalReference": "server!Audio:class"
1770
+ },
1771
+ {
1772
+ "kind": "Content",
1773
+ "text": ";\n cutoffDistance: number;\n }"
1774
+ },
1775
+ {
1776
+ "kind": "Content",
1777
+ "text": ";"
1778
+ }
1779
+ ],
1780
+ "isReadonly": false,
1781
+ "isOptional": false,
1782
+ "releaseTag": "Public",
1783
+ "name": "\"AUDIO.SET_CUTOFF_DISTANCE\"",
1784
+ "propertyTypeTokenRange": {
1785
+ "startIndex": 3,
1786
+ "endIndex": 6
1787
+ }
1788
+ },
1645
1789
  {
1646
1790
  "kind": "PropertySignature",
1647
1791
  "canonicalReference": "server!AudioEventPayloads#\"AUDIO.SET_DETUNE\":member",
@@ -2277,6 +2421,33 @@
2277
2421
  "endIndex": 2
2278
2422
  }
2279
2423
  },
2424
+ {
2425
+ "kind": "PropertySignature",
2426
+ "canonicalReference": "server!AudioOptions#cutoffDistance:member",
2427
+ "docComment": "/**\n * The cutoff distance between the audio source and the listener where the audio will be reduced to 0 volume. Must be greater than reference distance. Defaults to reference distance + 10.\n */\n",
2428
+ "excerptTokens": [
2429
+ {
2430
+ "kind": "Content",
2431
+ "text": "cutoffDistance?: "
2432
+ },
2433
+ {
2434
+ "kind": "Content",
2435
+ "text": "number"
2436
+ },
2437
+ {
2438
+ "kind": "Content",
2439
+ "text": ";"
2440
+ }
2441
+ ],
2442
+ "isReadonly": false,
2443
+ "isOptional": true,
2444
+ "releaseTag": "Public",
2445
+ "name": "cutoffDistance",
2446
+ "propertyTypeTokenRange": {
2447
+ "startIndex": 1,
2448
+ "endIndex": 2
2449
+ }
2450
+ },
2280
2451
  {
2281
2452
  "kind": "PropertySignature",
2282
2453
  "canonicalReference": "server!AudioOptions#detune:member",
@@ -2470,7 +2641,7 @@
2470
2641
  {
2471
2642
  "kind": "PropertySignature",
2472
2643
  "canonicalReference": "server!AudioOptions#referenceDistance:member",
2473
- "docComment": "/**\n * The reference distance for reducing volume as the audio source moves away from the listener.\n */\n",
2644
+ "docComment": "/**\n * The maximum reference distance between the audio source and the listener where the audio will still be max volume. Defaults to 10.\n */\n",
2474
2645
  "excerptTokens": [
2475
2646
  {
2476
2647
  "kind": "Content",
package/server.d.ts CHANGED
@@ -54,6 +54,7 @@ export declare class Audio extends EventRouter implements protocol.Serializable
54
54
 
55
55
 
56
56
 
57
+
57
58
  /**
58
59
  * @param options - The options for the Audio instance.
59
60
  */
@@ -62,6 +63,8 @@ export declare class Audio extends EventRouter implements protocol.Serializable
62
63
  get id(): number | undefined;
63
64
  /** The entity to which the audio is attached if explicitly set. */
64
65
  get attachedToEntity(): Entity | undefined;
66
+ /** The cutoff distance where the audio will be reduced to 0 volume. */
67
+ get cutoffDistance(): number;
65
68
  /** The duration of the audio in seconds if explicitly set. */
66
69
  get duration(): number | undefined;
67
70
  /** The detune of the audio in cents if explicitly set. */
@@ -109,6 +112,19 @@ export declare class Audio extends EventRouter implements protocol.Serializable
109
112
  * @param entity - The entity to attach the Audio to.
110
113
  */
111
114
  setAttachedToEntity(entity: Entity): void;
115
+ /**
116
+ * Sets the cutoff distance of the audio.
117
+ *
118
+ * @remarks
119
+ * The cutoff distance defines the maximum range at which the audio can be heard.
120
+ * Beyond this distance, the audio volume becomes zero. As the listener moves
121
+ * from the reference distance toward the cutoff distance, the volume decreases
122
+ * linearly, providing a natural spatial audio experience with smooth volume
123
+ * falloff based on distance.
124
+ *
125
+ * @param cutoffDistance - The cutoff distance.
126
+ */
127
+ setCutoffDistance(cutoffDistance: number): void;
112
128
  /**
113
129
  * Sets the detune of the audio.
114
130
  *
@@ -136,6 +152,14 @@ export declare class Audio extends EventRouter implements protocol.Serializable
136
152
  /**
137
153
  * Sets the reference distance of the audio.
138
154
  *
155
+ * @remarks
156
+ * The reference distance defines the range within which the audio plays at
157
+ * full volume. When a listener is within this distance from the audio source,
158
+ * they will hear the sound at its maximum volume. Beyond this distance, the
159
+ * volume decreases linearly until reaching the cutoff distance, where the
160
+ * sound becomes inaudible. This creates a natural spatial audio experience
161
+ * with smooth volume falloff based on distance.
162
+ *
139
163
  * @param referenceDistance - The reference distance.
140
164
  */
141
165
  setReferenceDistance(referenceDistance: number): void;
@@ -155,6 +179,7 @@ export declare enum AudioEvent {
155
179
  PLAY = "AUDIO.PLAY",
156
180
  PLAY_RESTART = "AUDIO.PLAY_RESTART",
157
181
  SET_ATTACHED_TO_ENTITY = "AUDIO.SET_ATTACHED_TO_ENTITY",
182
+ SET_CUTOFF_DISTANCE = "AUDIO.SET_CUTOFF_DISTANCE",
158
183
  SET_DETUNE = "AUDIO.SET_DETUNE",
159
184
  SET_DISTORTION = "AUDIO.SET_DISTORTION",
160
185
  SET_POSITION = "AUDIO.SET_POSITION",
@@ -182,6 +207,11 @@ export declare interface AudioEventPayloads {
182
207
  audio: Audio;
183
208
  entity: Entity | undefined;
184
209
  };
210
+ /** Emitted when the audio's cutoff distance is set. */
211
+ [AudioEvent.SET_CUTOFF_DISTANCE]: {
212
+ audio: Audio;
213
+ cutoffDistance: number;
214
+ };
185
215
  /** Emitted when the audio's detune is set. */
186
216
  [AudioEvent.SET_DETUNE]: {
187
217
  audio: Audio;
@@ -283,6 +313,8 @@ export declare class AudioManager {
283
313
  export declare interface AudioOptions {
284
314
  /** If set, audio playback will follow the entity's position. */
285
315
  attachedToEntity?: Entity;
316
+ /** The cutoff distance between the audio source and the listener where the audio will be reduced to 0 volume. Must be greater than reference distance. Defaults to reference distance + 10. */
317
+ cutoffDistance?: number;
286
318
  /** The duration of the audio in seconds. Defaults to full duration. */
287
319
  duration?: number;
288
320
  /** The detuning of the audio in cents. */
@@ -297,7 +329,7 @@ export declare interface AudioOptions {
297
329
  position?: Vector3Like;
298
330
  /** The playback speed of the audio. Defaults to 1. */
299
331
  playbackRate?: number;
300
- /** The reference distance for reducing volume as the audio source moves away from the listener. */
332
+ /** The maximum reference distance between the audio source and the listener where the audio will still be max volume. Defaults to 10. */
301
333
  referenceDistance?: number;
302
334
  /** The URI or path to the audio asset to be played. */
303
335
  uri: string;