hytopia 0.7.2 → 0.7.3-dev2
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/bun-server.mjs +156 -156
- package/docs/server.array3number.md +13 -0
- package/docs/server.array4number.md +13 -0
- package/docs/server.audiomanager.getallaudios.md +37 -1
- package/docs/server.audiomanager.md +1 -1
- package/docs/server.blocktype._constructor_.md +15 -1
- package/docs/server.blocktype.blocktyperegistry.md +13 -0
- package/docs/server.blocktype.md +22 -1
- package/docs/server.blocktyperegistry.getallblocktypes.md +37 -1
- package/docs/server.blocktyperegistry.md +1 -1
- package/docs/server.chunk._constructor_.md +15 -1
- package/docs/server.chunk.chunklattice.md +13 -0
- package/docs/server.chunk.md +22 -1
- package/docs/server.chunklattice.getallchunks.md +37 -1
- package/docs/server.chunklattice.md +22 -1
- package/docs/server.chunklattice.world.md +13 -0
- package/docs/server.entitymanager.getallentities.md +37 -1
- package/docs/server.entitymanager.md +1 -1
- package/docs/server.lightmanager.getalllights.md +37 -1
- package/docs/server.lightmanager.md +1 -1
- package/docs/server.md +33 -0
- package/docs/server.particleemittermanager.getallparticleemitters.md +37 -1
- package/docs/server.particleemittermanager.md +1 -1
- package/docs/server.sceneuimanager.getallsceneuis.md +37 -1
- package/docs/server.sceneuimanager.md +1 -1
- package/docs/server.tickallocator.getarray.md +71 -0
- package/docs/server.tickallocator.getarray3number.md +55 -0
- package/docs/server.tickallocator.getarray4number.md +55 -0
- package/docs/server.tickallocator.getobject.md +71 -0
- package/docs/server.tickallocator.getset.md +71 -0
- package/docs/server.tickallocator.map.md +71 -0
- package/docs/server.tickallocator.md +148 -0
- package/docs/server.tickallocator.reset.md +17 -0
- package/docs/server.world.md +21 -0
- package/docs/server.world.tickallocator.md +13 -0
- package/node-server.mjs +156 -156
- package/package.json +1 -1
- package/server.api.json +930 -39
- package/server.d.ts +164 -27
package/server.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ import { SdpMatrix3 } from '@dimforge/rapier3d-simd-compat';
|
|
|
12
12
|
import type { Socket } from 'net';
|
|
13
13
|
import { WebSocket as WebSocket_2 } from 'ws';
|
|
14
14
|
|
|
15
|
+
/** A 3-element number array. @public */
|
|
16
|
+
export declare type Array3Number = [number, number, number];
|
|
17
|
+
|
|
18
|
+
/** A 4-element number array. @public */
|
|
19
|
+
export declare type Array4Number = [number, number, number, number];
|
|
20
|
+
|
|
15
21
|
/**
|
|
16
22
|
* Represents a audio playback in a world.
|
|
17
23
|
*
|
|
@@ -272,9 +278,14 @@ export declare class AudioManager {
|
|
|
272
278
|
/**
|
|
273
279
|
* Retrieves all loaded audio instances for the world.
|
|
274
280
|
*
|
|
281
|
+
* @param tickAllocated - Whether to use the tick allocator to allocate the
|
|
282
|
+
* returned array of Audio instances. The allocated array will be collected
|
|
283
|
+
* and released at the end of the current tick if true. Only use this if
|
|
284
|
+
* you know what you're doing.
|
|
285
|
+
*
|
|
275
286
|
* @returns An array of audio instances.
|
|
276
287
|
*/
|
|
277
|
-
getAllAudios(): Audio[];
|
|
288
|
+
getAllAudios(tickAllocated?: boolean): Audio[];
|
|
278
289
|
/**
|
|
279
290
|
* Retrieves all loaded audio instances attached to a specific entity.
|
|
280
291
|
*
|
|
@@ -603,14 +614,17 @@ export declare class BlockType extends EventRouter implements protocol.Serializa
|
|
|
603
614
|
|
|
604
615
|
|
|
605
616
|
|
|
617
|
+
|
|
606
618
|
/**
|
|
607
619
|
* Creates a new block type instance.
|
|
608
620
|
* @param world - The world the block type is for.
|
|
609
621
|
* @param options - The options for the block type.
|
|
610
622
|
*/
|
|
611
|
-
constructor(options?: BlockTypeOptions);
|
|
623
|
+
constructor(blockTypeRegistry: BlockTypeRegistry, options?: BlockTypeOptions);
|
|
612
624
|
/** The unique identifier for the block type. */
|
|
613
625
|
get id(): number;
|
|
626
|
+
/** The block type registry that the block type belongs to. */
|
|
627
|
+
get blockTypeRegistry(): BlockTypeRegistry;
|
|
614
628
|
/** The collider options for the block type. */
|
|
615
629
|
get colliderOptions(): VoxelsColliderOptions;
|
|
616
630
|
/** The half extents size of the block type. */
|
|
@@ -702,9 +716,15 @@ export declare class BlockTypeRegistry extends EventRouter implements protocol.S
|
|
|
702
716
|
get world(): World;
|
|
703
717
|
/**
|
|
704
718
|
* Get all registered block types.
|
|
719
|
+
*
|
|
720
|
+
* @param tickAllocated - Whether to use the tick allocator to allocate the
|
|
721
|
+
* returned array of BlockType instances. The allocated array will be collected
|
|
722
|
+
* and released at the end of the current tick if true. Only use this if
|
|
723
|
+
* you know what you're doing.
|
|
724
|
+
*
|
|
705
725
|
* @returns An array of all registered block types.
|
|
706
726
|
*/
|
|
707
|
-
getAllBlockTypes(): BlockType[];
|
|
727
|
+
getAllBlockTypes(tickAllocated?: boolean): BlockType[];
|
|
708
728
|
/**
|
|
709
729
|
* Get a registered block type by its id.
|
|
710
730
|
* @param id - The id of the block type to get.
|
|
@@ -862,12 +882,15 @@ export declare class ChatManager extends EventRouter {
|
|
|
862
882
|
export declare class Chunk implements protocol.Serializable {
|
|
863
883
|
|
|
864
884
|
|
|
885
|
+
|
|
865
886
|
/**
|
|
866
887
|
* Creates a new chunk instance.
|
|
867
888
|
*/
|
|
868
|
-
constructor(originCoordinate: Vector3Like);
|
|
889
|
+
constructor(chunkLattice: ChunkLattice, originCoordinate: Vector3Like);
|
|
869
890
|
/** The blocks in the chunk as a flat Uint8Array[4096], each index as 0 or a block type id. */
|
|
870
891
|
get blocks(): Readonly<Uint8Array>;
|
|
892
|
+
/** The chunk lattice that the chunk belongs to. */
|
|
893
|
+
get chunkLattice(): ChunkLattice;
|
|
871
894
|
/** The origin coordinate of the chunk. */
|
|
872
895
|
get originCoordinate(): Vector3Like;
|
|
873
896
|
/**
|
|
@@ -928,6 +951,8 @@ export declare class ChunkLattice extends EventRouter {
|
|
|
928
951
|
constructor(world: World);
|
|
929
952
|
/** The number of chunks in the lattice. */
|
|
930
953
|
get chunkCount(): number;
|
|
954
|
+
/** The world that the chunk lattice belongs to. */
|
|
955
|
+
get world(): World;
|
|
931
956
|
/**
|
|
932
957
|
* Removes and clears all chunks and their blocks from the lattice.
|
|
933
958
|
*/
|
|
@@ -966,9 +991,15 @@ export declare class ChunkLattice extends EventRouter {
|
|
|
966
991
|
getOrCreateChunk(globalCoordinate: Vector3Like): Chunk;
|
|
967
992
|
/**
|
|
968
993
|
* Get all chunks in the lattice.
|
|
994
|
+
*
|
|
995
|
+
* @param tickAllocated - Whether to use the tick allocator to allocate the
|
|
996
|
+
* returned array of Chunk instances. The allocated array will be collected
|
|
997
|
+
* and released at the end of the current tick if true. Only use this if
|
|
998
|
+
* you know what you're doing.
|
|
999
|
+
*
|
|
969
1000
|
* @returns An array of all chunks in the lattice.
|
|
970
1001
|
*/
|
|
971
|
-
getAllChunks(): Chunk[];
|
|
1002
|
+
getAllChunks(tickAllocated?: boolean): Chunk[];
|
|
972
1003
|
/**
|
|
973
1004
|
* Check if a block exists at a specific global coordinate.
|
|
974
1005
|
* @param globalCoordinate - The global coordinate of the block to check.
|
|
@@ -2108,9 +2139,15 @@ export declare class EntityManager {
|
|
|
2108
2139
|
|
|
2109
2140
|
/**
|
|
2110
2141
|
* Gets all spawned entities in the world.
|
|
2142
|
+
*
|
|
2143
|
+
* @param tickAllocated - Whether to use the tick allocator to allocate the
|
|
2144
|
+
* returned array of Entity instances. The allocated array will be collected
|
|
2145
|
+
* and released at the end of the current tick if true. Only use this if
|
|
2146
|
+
* you know what you're doing.
|
|
2147
|
+
*
|
|
2111
2148
|
* @returns All spawned entities in the world.
|
|
2112
2149
|
*/
|
|
2113
|
-
getAllEntities(): Entity[];
|
|
2150
|
+
getAllEntities(tickAllocated?: boolean): Entity[];
|
|
2114
2151
|
/**
|
|
2115
2152
|
* Gets all spawned player entities in the world.
|
|
2116
2153
|
* @returns All spawned player entities in the world.
|
|
@@ -2760,9 +2797,14 @@ export declare class LightManager {
|
|
|
2760
2797
|
/**
|
|
2761
2798
|
* Retrieves all spawned Light instances for the world.
|
|
2762
2799
|
*
|
|
2800
|
+
* @param tickAllocated - Whether to use the tick allocator to allocate the
|
|
2801
|
+
* returned array of Light instances. The allocated array will be collected
|
|
2802
|
+
* and released at the end of the current tick if true. Only use this if
|
|
2803
|
+
* you know what you're doing.
|
|
2804
|
+
*
|
|
2763
2805
|
* @returns An array of Light instances.
|
|
2764
2806
|
*/
|
|
2765
|
-
getAllLights(): Light[];
|
|
2807
|
+
getAllLights(tickAllocated?: boolean): Light[];
|
|
2766
2808
|
/**
|
|
2767
2809
|
* Retrieves all spawned Light instances attached to a specific entity.
|
|
2768
2810
|
*
|
|
@@ -4096,9 +4138,14 @@ export declare class ParticleEmitterManager {
|
|
|
4096
4138
|
/**
|
|
4097
4139
|
* Retrieves all spawned ParticleEmitter instances for the world.
|
|
4098
4140
|
*
|
|
4141
|
+
* @param tickAllocated - Whether to use the tick allocator to allocate the
|
|
4142
|
+
* returned array of ParticleEmitter instances. The allocated array will be collected
|
|
4143
|
+
* and released at the end of the current tick if true. Only use this if
|
|
4144
|
+
* you know what you're doing.
|
|
4145
|
+
*
|
|
4099
4146
|
* @returns An array of ParticleEmitter instances.
|
|
4100
4147
|
*/
|
|
4101
|
-
getAllParticleEmitters(): ParticleEmitter[];
|
|
4148
|
+
getAllParticleEmitters(tickAllocated?: boolean): ParticleEmitter[];
|
|
4102
4149
|
/**
|
|
4103
4150
|
* Retrieves all spawned ParticleEmitter instances attached to a specific entity.
|
|
4104
4151
|
*
|
|
@@ -5729,9 +5776,14 @@ export declare class SceneUIManager {
|
|
|
5729
5776
|
/**
|
|
5730
5777
|
* Retrieves all loaded SceneUI instances for the world.
|
|
5731
5778
|
*
|
|
5779
|
+
* @param tickAllocated - Whether to use the tick allocator to allocate the
|
|
5780
|
+
* returned array of SceneUI instances. The allocated array will be collected
|
|
5781
|
+
* and released at the end of the current tick if true. Only use this if
|
|
5782
|
+
* you know what you're doing.
|
|
5783
|
+
*
|
|
5732
5784
|
* @returns An array of SceneUI instances.
|
|
5733
5785
|
*/
|
|
5734
|
-
getAllSceneUIs(): SceneUI[];
|
|
5786
|
+
getAllSceneUIs(tickAllocated?: boolean): SceneUI[];
|
|
5735
5787
|
/**
|
|
5736
5788
|
* Retrieves all loaded SceneUI instances attached to a specific entity.
|
|
5737
5789
|
*
|
|
@@ -6071,6 +6123,88 @@ export declare function startServer(init: ((() => void) | ((world: World) => voi
|
|
|
6071
6123
|
/** The input keys that are included in the PlayerInput. @public */
|
|
6072
6124
|
export declare const SUPPORTED_INPUT_KEYS: readonly ["w", "a", "s", "d", "sp", "sh", "tb", "ml", "mr", "q", "e", "r", "f", "z", "x", "c", "v", "u", "i", "o", "j", "k", "l", "n", "m", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
|
|
6073
6125
|
|
|
6126
|
+
/**
|
|
6127
|
+
* High-performance tick-scoped allocator for temporary objects, arrays, and buffers.
|
|
6128
|
+
* All allocations are automatically bulk-released when reset() is called.
|
|
6129
|
+
*
|
|
6130
|
+
* @remarks
|
|
6131
|
+
* TickAllocator maintains separate pools for different data types and tracks all
|
|
6132
|
+
* allocations made during a tick cycle. Objects are reused across ticks to eliminate
|
|
6133
|
+
* garbage collection overhead in hot paths like network synchronization.
|
|
6134
|
+
*
|
|
6135
|
+
* @example
|
|
6136
|
+
* ```typescript
|
|
6137
|
+
* // Allocate during tick
|
|
6138
|
+
* const position = tickAllocator.getArray3Number();
|
|
6139
|
+
* const rotation = tickAllocator.getArray4Number();
|
|
6140
|
+
* const data = tickAllocator.getObject<EntitySchema>();
|
|
6141
|
+
*
|
|
6142
|
+
* // At end of tick - bulk release everything
|
|
6143
|
+
* tickAllocator.reset();
|
|
6144
|
+
* ```
|
|
6145
|
+
*
|
|
6146
|
+
* @public
|
|
6147
|
+
*/
|
|
6148
|
+
export declare class TickAllocator {
|
|
6149
|
+
|
|
6150
|
+
|
|
6151
|
+
|
|
6152
|
+
|
|
6153
|
+
|
|
6154
|
+
|
|
6155
|
+
|
|
6156
|
+
|
|
6157
|
+
|
|
6158
|
+
|
|
6159
|
+
/**
|
|
6160
|
+
* Gets a generic array from the pool.
|
|
6161
|
+
* Array is reset to empty state and ready for use.
|
|
6162
|
+
* @typeParam T - The array type.
|
|
6163
|
+
* @returns A reusable array.
|
|
6164
|
+
*/
|
|
6165
|
+
getArray<T extends unknown[] = unknown[]>(copyFromA?: Iterable<unknown>, copyFromB?: Iterable<unknown>): T;
|
|
6166
|
+
/**
|
|
6167
|
+
* Gets a 3-element number array from the pool.
|
|
6168
|
+
* Array is reset to [0, 0, 0] and ready for use.
|
|
6169
|
+
* @returns A reusable 3-element array.
|
|
6170
|
+
*/
|
|
6171
|
+
getArray3Number(copyFrom?: Array3Number | Set<number>): Array3Number;
|
|
6172
|
+
/**
|
|
6173
|
+
* Gets a 4-element number array from the pool.
|
|
6174
|
+
* Array is reset to [0, 0, 0, 0] and ready for use.
|
|
6175
|
+
* @returns A reusable 4-element array.
|
|
6176
|
+
*/
|
|
6177
|
+
getArray4Number(copyFrom?: Array4Number | Set<number>): Array4Number;
|
|
6178
|
+
/**
|
|
6179
|
+
* Gets a plain object from the pool.
|
|
6180
|
+
* Object is reset to empty state and ready for use.
|
|
6181
|
+
* @typeParam T - The type interface for the object.
|
|
6182
|
+
* @returns A reusable plain object.
|
|
6183
|
+
*/
|
|
6184
|
+
getObject<T extends Record<string, unknown> = Record<string, unknown>>(copyFromA?: T, copyFromB?: T): T;
|
|
6185
|
+
/**
|
|
6186
|
+
* Gets a set from the pool.
|
|
6187
|
+
* Set is reset to empty state and ready for use.
|
|
6188
|
+
* @typeParam T - The type of the set.
|
|
6189
|
+
* @returns A reusable set.
|
|
6190
|
+
*/
|
|
6191
|
+
getSet<T>(copyFromA?: Set<T> | T[], copyFromB?: Set<T> | T[]): Set<T>;
|
|
6192
|
+
/**
|
|
6193
|
+
* Maps an array to a new array using a callback function.
|
|
6194
|
+
* @typeParam T - The type of the array.
|
|
6195
|
+
* @typeParam U - The type of the resulting array.
|
|
6196
|
+
* @param array - The array to map.
|
|
6197
|
+
* @param callback - The callback function to map the array.
|
|
6198
|
+
* @returns A new array with the mapped values.
|
|
6199
|
+
*/
|
|
6200
|
+
map<T, U>(array: T[], callback: (value: T, index: number, array: T[]) => U): U[];
|
|
6201
|
+
/**
|
|
6202
|
+
* Releases all allocated objects back to their respective pools.
|
|
6203
|
+
* This is intended to be called at the end of a tick.
|
|
6204
|
+
*/
|
|
6205
|
+
reset(): void;
|
|
6206
|
+
}
|
|
6207
|
+
|
|
6074
6208
|
/** The options for a trimesh collider. @public */
|
|
6075
6209
|
export declare interface TrimeshColliderOptions extends BaseColliderOptions {
|
|
6076
6210
|
shape: ColliderShape.TRIMESH;
|
|
@@ -6685,6 +6819,7 @@ export declare class World extends EventRouter implements protocol.Serializable
|
|
|
6685
6819
|
|
|
6686
6820
|
|
|
6687
6821
|
|
|
6822
|
+
|
|
6688
6823
|
|
|
6689
6824
|
|
|
6690
6825
|
/**
|
|
@@ -6697,40 +6832,32 @@ export declare class World extends EventRouter implements protocol.Serializable
|
|
|
6697
6832
|
get ambientLightColor(): RgbColor;
|
|
6698
6833
|
/** The intensity of the ambient light. */
|
|
6699
6834
|
get ambientLightIntensity(): number;
|
|
6835
|
+
/** The block type registry for the world. */
|
|
6836
|
+
get blockTypeRegistry(): BlockTypeRegistry;
|
|
6837
|
+
/** The chat manager for the world. */
|
|
6838
|
+
get chatManager(): ChatManager;
|
|
6839
|
+
/** The chunk lattice for the world. */
|
|
6840
|
+
get chunkLattice(): ChunkLattice;
|
|
6700
6841
|
/** The color of the directional light. */
|
|
6701
6842
|
get directionalLightColor(): RgbColor;
|
|
6702
6843
|
/** The intensity of the directional light. */
|
|
6703
6844
|
get directionalLightIntensity(): number;
|
|
6704
6845
|
/** The position the directional light originates from. */
|
|
6705
6846
|
get directionalLightPosition(): Vector3Like;
|
|
6847
|
+
/** The entity manager for the world. */
|
|
6848
|
+
get entityManager(): EntityManager;
|
|
6706
6849
|
/** The color of the fog, if not explicitly set, defaults to ambient light color. */
|
|
6707
6850
|
get fogColor(): RgbColor | undefined;
|
|
6708
6851
|
/** The maximum distance from the camera at which fog stops being applied. */
|
|
6709
6852
|
get fogFar(): number;
|
|
6710
6853
|
/** The minimum distance from the camera to start applying fog. */
|
|
6711
6854
|
get fogNear(): number;
|
|
6712
|
-
/** The name of the world. */
|
|
6713
|
-
get name(): string;
|
|
6714
|
-
/** The intensity of the world's skybox brightness. */
|
|
6715
|
-
get skyboxIntensity(): number;
|
|
6716
|
-
/** The URI of the skybox cubemap for the world. */
|
|
6717
|
-
get skyboxUri(): string;
|
|
6718
|
-
/** The audio manager for the world. */
|
|
6719
|
-
get audioManager(): AudioManager;
|
|
6720
|
-
/** An arbitrary identifier tag of the world. Useful for your own logic. */
|
|
6721
|
-
get tag(): string | undefined;
|
|
6722
|
-
/** The block type registry for the world. */
|
|
6723
|
-
get blockTypeRegistry(): BlockTypeRegistry;
|
|
6724
|
-
/** The chat manager for the world. */
|
|
6725
|
-
get chatManager(): ChatManager;
|
|
6726
|
-
/** The chunk lattice for the world. */
|
|
6727
|
-
get chunkLattice(): ChunkLattice;
|
|
6728
|
-
/** The entity manager for the world. */
|
|
6729
|
-
get entityManager(): EntityManager;
|
|
6730
6855
|
/** The light manager for the world. */
|
|
6731
6856
|
get lightManager(): LightManager;
|
|
6732
6857
|
/** The world loop for the world. */
|
|
6733
6858
|
get loop(): WorldLoop;
|
|
6859
|
+
/** The name of the world. */
|
|
6860
|
+
get name(): string;
|
|
6734
6861
|
|
|
6735
6862
|
/** The particle emitter manager for the world. */
|
|
6736
6863
|
get particleEmitterManager(): ParticleEmitterManager;
|
|
@@ -6738,6 +6865,16 @@ export declare class World extends EventRouter implements protocol.Serializable
|
|
|
6738
6865
|
get sceneUIManager(): SceneUIManager;
|
|
6739
6866
|
/** The simulation for the world. */
|
|
6740
6867
|
get simulation(): Simulation;
|
|
6868
|
+
/** The intensity of the world's skybox brightness. */
|
|
6869
|
+
get skyboxIntensity(): number;
|
|
6870
|
+
/** The URI of the skybox cubemap for the world. */
|
|
6871
|
+
get skyboxUri(): string;
|
|
6872
|
+
/** The audio manager for the world. */
|
|
6873
|
+
get audioManager(): AudioManager;
|
|
6874
|
+
/** An arbitrary identifier tag of the world. Useful for your own logic. */
|
|
6875
|
+
get tag(): string | undefined;
|
|
6876
|
+
/** The tick allocator for the world. */
|
|
6877
|
+
get tickAllocator(): TickAllocator;
|
|
6741
6878
|
/**
|
|
6742
6879
|
* Loads a map into the world, clearing any prior map.
|
|
6743
6880
|
* @param map - The map to load.
|