@dcl/hammurabi-server 1.0.0-17268386187.commit-b609629
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/CLAUDE.md +90 -0
- package/LICENSE +201 -0
- package/README.md +125 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +79 -0
- package/dist/cli.js.map +1 -0
- package/dist/lib/babylon/avatar-rendering-system.d.ts +16 -0
- package/dist/lib/babylon/avatar-rendering-system.d.ts.map +1 -0
- package/dist/lib/babylon/avatar-rendering-system.js +96 -0
- package/dist/lib/babylon/avatar-rendering-system.js.map +1 -0
- package/dist/lib/babylon/avatars/AvatarRenderer.d.ts +40 -0
- package/dist/lib/babylon/avatars/AvatarRenderer.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/AvatarRenderer.js +260 -0
- package/dist/lib/babylon/avatars/AvatarRenderer.js.map +1 -0
- package/dist/lib/babylon/avatars/CharacterController.d.ts +88 -0
- package/dist/lib/babylon/avatars/CharacterController.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/CharacterController.js +463 -0
- package/dist/lib/babylon/avatars/CharacterController.js.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/body.d.ts +4 -0
- package/dist/lib/babylon/avatars/adr-65/body.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/body.js +47 -0
- package/dist/lib/babylon/avatars/adr-65/body.js.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/customizations.d.ts +11 -0
- package/dist/lib/babylon/avatars/adr-65/customizations.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/customizations.js +111 -0
- package/dist/lib/babylon/avatars/adr-65/customizations.js.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/emote.d.ts +9 -0
- package/dist/lib/babylon/avatars/adr-65/emote.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/emote.js +46 -0
- package/dist/lib/babylon/avatars/adr-65/emote.js.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/loader.d.ts +8 -0
- package/dist/lib/babylon/avatars/adr-65/loader.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/loader.js +54 -0
- package/dist/lib/babylon/avatars/adr-65/loader.js.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/representation.d.ts +12 -0
- package/dist/lib/babylon/avatars/adr-65/representation.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/representation.js +77 -0
- package/dist/lib/babylon/avatars/adr-65/representation.js.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/slots.d.ts +5 -0
- package/dist/lib/babylon/avatars/adr-65/slots.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/slots.js +62 -0
- package/dist/lib/babylon/avatars/adr-65/slots.js.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/types.d.ts +17 -0
- package/dist/lib/babylon/avatars/adr-65/types.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/types.js +3 -0
- package/dist/lib/babylon/avatars/adr-65/types.js.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/utils.d.ts +8 -0
- package/dist/lib/babylon/avatars/adr-65/utils.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/utils.js +29 -0
- package/dist/lib/babylon/avatars/adr-65/utils.js.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/wearable.d.ts +7 -0
- package/dist/lib/babylon/avatars/adr-65/wearable.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/adr-65/wearable.js +64 -0
- package/dist/lib/babylon/avatars/adr-65/wearable.js.map +1 -0
- package/dist/lib/babylon/avatars/avatar-asset-manager.d.ts +12 -0
- package/dist/lib/babylon/avatars/avatar-asset-manager.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/avatar-asset-manager.js +31 -0
- package/dist/lib/babylon/avatars/avatar-asset-manager.js.map +1 -0
- package/dist/lib/babylon/avatars/loader.d.ts +6 -0
- package/dist/lib/babylon/avatars/loader.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/loader.js +108 -0
- package/dist/lib/babylon/avatars/loader.js.map +1 -0
- package/dist/lib/babylon/avatars/urn.d.ts +2 -0
- package/dist/lib/babylon/avatars/urn.d.ts.map +1 -0
- package/dist/lib/babylon/avatars/urn.js +9 -0
- package/dist/lib/babylon/avatars/urn.js.map +1 -0
- package/dist/lib/babylon/index.d.ts +6 -0
- package/dist/lib/babylon/index.d.ts.map +1 -0
- package/dist/lib/babylon/index.js +85 -0
- package/dist/lib/babylon/index.js.map +1 -0
- package/dist/lib/babylon/input.d.ts +35 -0
- package/dist/lib/babylon/input.d.ts.map +1 -0
- package/dist/lib/babylon/input.js +137 -0
- package/dist/lib/babylon/input.js.map +1 -0
- package/dist/lib/babylon/scene/AssetManager.d.ts +19 -0
- package/dist/lib/babylon/scene/AssetManager.d.ts.map +1 -0
- package/dist/lib/babylon/scene/AssetManager.js +271 -0
- package/dist/lib/babylon/scene/AssetManager.js.map +1 -0
- package/dist/lib/babylon/scene/BabylonEntity.d.ts +84 -0
- package/dist/lib/babylon/scene/BabylonEntity.d.ts.map +1 -0
- package/dist/lib/babylon/scene/BabylonEntity.js +174 -0
- package/dist/lib/babylon/scene/BabylonEntity.js.map +1 -0
- package/dist/lib/babylon/scene/connect-context-rpc.d.ts +8 -0
- package/dist/lib/babylon/scene/connect-context-rpc.d.ts.map +1 -0
- package/dist/lib/babylon/scene/connect-context-rpc.js +210 -0
- package/dist/lib/babylon/scene/connect-context-rpc.js.map +1 -0
- package/dist/lib/babylon/scene/coordinates.d.ts +5 -0
- package/dist/lib/babylon/scene/coordinates.d.ts.map +1 -0
- package/dist/lib/babylon/scene/coordinates.js +17 -0
- package/dist/lib/babylon/scene/coordinates.js.map +1 -0
- package/dist/lib/babylon/scene/hot-reload.d.ts +9 -0
- package/dist/lib/babylon/scene/hot-reload.d.ts.map +1 -0
- package/dist/lib/babylon/scene/hot-reload.js +65 -0
- package/dist/lib/babylon/scene/hot-reload.js.map +1 -0
- package/dist/lib/babylon/scene/load.d.ts +54 -0
- package/dist/lib/babylon/scene/load.d.ts.map +1 -0
- package/dist/lib/babylon/scene/load.js +154 -0
- package/dist/lib/babylon/scene/load.js.map +1 -0
- package/dist/lib/babylon/scene/logic/apply-animations.d.ts +3 -0
- package/dist/lib/babylon/scene/logic/apply-animations.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/apply-animations.js +50 -0
- package/dist/lib/babylon/scene/logic/apply-animations.js.map +1 -0
- package/dist/lib/babylon/scene/logic/billboards.d.ts +3 -0
- package/dist/lib/babylon/scene/logic/billboards.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/billboards.js +12 -0
- package/dist/lib/babylon/scene/logic/billboards.js.map +1 -0
- package/dist/lib/babylon/scene/logic/camera-follows-player.d.ts +7 -0
- package/dist/lib/babylon/scene/logic/camera-follows-player.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/camera-follows-player.js +35 -0
- package/dist/lib/babylon/scene/logic/camera-follows-player.js.map +1 -0
- package/dist/lib/babylon/scene/logic/colliders.d.ts +9 -0
- package/dist/lib/babylon/scene/logic/colliders.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/colliders.js +79 -0
- package/dist/lib/babylon/scene/logic/colliders.js.map +1 -0
- package/dist/lib/babylon/scene/logic/cyclic-transform.d.ts +12 -0
- package/dist/lib/babylon/scene/logic/cyclic-transform.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/cyclic-transform.js +67 -0
- package/dist/lib/babylon/scene/logic/cyclic-transform.js.map +1 -0
- package/dist/lib/babylon/scene/logic/delayed-interpolation.d.ts +27 -0
- package/dist/lib/babylon/scene/logic/delayed-interpolation.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/delayed-interpolation.js +49 -0
- package/dist/lib/babylon/scene/logic/delayed-interpolation.js.map +1 -0
- package/dist/lib/babylon/scene/logic/easings.d.ts +7 -0
- package/dist/lib/babylon/scene/logic/easings.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/easings.js +100 -0
- package/dist/lib/babylon/scene/logic/easings.js.map +1 -0
- package/dist/lib/babylon/scene/logic/hide-camera-obstuction-system.d.ts +5 -0
- package/dist/lib/babylon/scene/logic/hide-camera-obstuction-system.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/hide-camera-obstuction-system.js +145 -0
- package/dist/lib/babylon/scene/logic/hide-camera-obstuction-system.js.map +1 -0
- package/dist/lib/babylon/scene/logic/local-avatar-scene.d.ts +10 -0
- package/dist/lib/babylon/scene/logic/local-avatar-scene.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/local-avatar-scene.js +50 -0
- package/dist/lib/babylon/scene/logic/local-avatar-scene.js.map +1 -0
- package/dist/lib/babylon/scene/logic/pointer-events.d.ts +12 -0
- package/dist/lib/babylon/scene/logic/pointer-events.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/pointer-events.js +199 -0
- package/dist/lib/babylon/scene/logic/pointer-events.js.map +1 -0
- package/dist/lib/babylon/scene/logic/raycasts.d.ts +21 -0
- package/dist/lib/babylon/scene/logic/raycasts.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/raycasts.js +142 -0
- package/dist/lib/babylon/scene/logic/raycasts.js.map +1 -0
- package/dist/lib/babylon/scene/logic/static-entities.d.ts +18 -0
- package/dist/lib/babylon/scene/logic/static-entities.d.ts.map +1 -0
- package/dist/lib/babylon/scene/logic/static-entities.js +64 -0
- package/dist/lib/babylon/scene/logic/static-entities.js.map +1 -0
- package/dist/lib/babylon/scene/nodejs-runtime.d.ts +4 -0
- package/dist/lib/babylon/scene/nodejs-runtime.d.ts.map +1 -0
- package/dist/lib/babylon/scene/nodejs-runtime.js +100 -0
- package/dist/lib/babylon/scene/nodejs-runtime.js.map +1 -0
- package/dist/lib/babylon/scene/scene-context.d.ts +116 -0
- package/dist/lib/babylon/scene/scene-context.d.ts.map +1 -0
- package/dist/lib/babylon/scene/scene-context.js +492 -0
- package/dist/lib/babylon/scene/scene-context.js.map +1 -0
- package/dist/lib/babylon/scene/scene-culling.d.ts +6 -0
- package/dist/lib/babylon/scene/scene-culling.d.ts.map +1 -0
- package/dist/lib/babylon/scene/scene-culling.js +23 -0
- package/dist/lib/babylon/scene/scene-culling.js.map +1 -0
- package/dist/lib/babylon/scene/update-scheduler.d.ts +7 -0
- package/dist/lib/babylon/scene/update-scheduler.d.ts.map +1 -0
- package/dist/lib/babylon/scene/update-scheduler.js +40 -0
- package/dist/lib/babylon/scene/update-scheduler.js.map +1 -0
- package/dist/lib/babylon/time-based-animation.d.ts +13 -0
- package/dist/lib/babylon/time-based-animation.d.ts.map +1 -0
- package/dist/lib/babylon/time-based-animation.js +35 -0
- package/dist/lib/babylon/time-based-animation.js.map +1 -0
- package/dist/lib/babylon/visual/ambientLights.d.ts +6 -0
- package/dist/lib/babylon/visual/ambientLights.d.ts.map +1 -0
- package/dist/lib/babylon/visual/ambientLights.js +65 -0
- package/dist/lib/babylon/visual/ambientLights.js.map +1 -0
- package/dist/lib/babylon/visual/glowLayer.d.ts +6 -0
- package/dist/lib/babylon/visual/glowLayer.d.ts.map +1 -0
- package/dist/lib/babylon/visual/glowLayer.js +59 -0
- package/dist/lib/babylon/visual/glowLayer.js.map +1 -0
- package/dist/lib/babylon/visual/parcelOutline.d.ts +7 -0
- package/dist/lib/babylon/visual/parcelOutline.d.ts.map +1 -0
- package/dist/lib/babylon/visual/parcelOutline.js +88 -0
- package/dist/lib/babylon/visual/parcelOutline.js.map +1 -0
- package/dist/lib/babylon/visual/reticle.d.ts +3 -0
- package/dist/lib/babylon/visual/reticle.d.ts.map +1 -0
- package/dist/lib/babylon/visual/reticle.js +60 -0
- package/dist/lib/babylon/visual/reticle.js.map +1 -0
- package/dist/lib/babylon/visual/ui.d.ts +8 -0
- package/dist/lib/babylon/visual/ui.d.ts.map +1 -0
- package/dist/lib/babylon/visual/ui.js +54 -0
- package/dist/lib/babylon/visual/ui.js.map +1 -0
- package/dist/lib/common-runtime/game-loop.d.ts +4 -0
- package/dist/lib/common-runtime/game-loop.d.ts.map +1 -0
- package/dist/lib/common-runtime/game-loop.js +31 -0
- package/dist/lib/common-runtime/game-loop.js.map +1 -0
- package/dist/lib/common-runtime/modules.d.ts +244 -0
- package/dist/lib/common-runtime/modules.d.ts.map +1 -0
- package/dist/lib/common-runtime/modules.js +74 -0
- package/dist/lib/common-runtime/modules.js.map +1 -0
- package/dist/lib/common-runtime/startup.d.ts +8 -0
- package/dist/lib/common-runtime/startup.d.ts.map +1 -0
- package/dist/lib/common-runtime/startup.js +45 -0
- package/dist/lib/common-runtime/startup.js.map +1 -0
- package/dist/lib/common-runtime/types.d.ts +15 -0
- package/dist/lib/common-runtime/types.d.ts.map +1 -0
- package/dist/lib/common-runtime/types.js +7 -0
- package/dist/lib/common-runtime/types.js.map +1 -0
- package/dist/lib/decentraland/ByteBuffer/index.d.ts +75 -0
- package/dist/lib/decentraland/ByteBuffer/index.d.ts.map +1 -0
- package/dist/lib/decentraland/ByteBuffer/index.js +279 -0
- package/dist/lib/decentraland/ByteBuffer/index.js.map +1 -0
- package/dist/lib/decentraland/ByteBuffer/types.d.ts +109 -0
- package/dist/lib/decentraland/ByteBuffer/types.d.ts.map +1 -0
- package/dist/lib/decentraland/ByteBuffer/types.js +3 -0
- package/dist/lib/decentraland/ByteBuffer/types.js.map +1 -0
- package/dist/lib/decentraland/communications/CommsTransportWrapper.d.ts +45 -0
- package/dist/lib/decentraland/communications/CommsTransportWrapper.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/CommsTransportWrapper.js +174 -0
- package/dist/lib/decentraland/communications/CommsTransportWrapper.js.map +1 -0
- package/dist/lib/decentraland/communications/avatar-communication-system.d.ts +18 -0
- package/dist/lib/decentraland/communications/avatar-communication-system.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/avatar-communication-system.js +203 -0
- package/dist/lib/decentraland/communications/avatar-communication-system.js.map +1 -0
- package/dist/lib/decentraland/communications/connect-adapter.d.ts +5 -0
- package/dist/lib/decentraland/communications/connect-adapter.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/connect-adapter.js +110 -0
- package/dist/lib/decentraland/communications/connect-adapter.js.map +1 -0
- package/dist/lib/decentraland/communications/connect-transport.d.ts +5 -0
- package/dist/lib/decentraland/communications/connect-transport.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/connect-transport.js +32 -0
- package/dist/lib/decentraland/communications/connect-transport.js.map +1 -0
- package/dist/lib/decentraland/communications/networked-profile-system.d.ts +10 -0
- package/dist/lib/decentraland/communications/networked-profile-system.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/networked-profile-system.js +73 -0
- package/dist/lib/decentraland/communications/networked-profile-system.js.map +1 -0
- package/dist/lib/decentraland/communications/player-entity-manager.d.ts +55 -0
- package/dist/lib/decentraland/communications/player-entity-manager.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/player-entity-manager.js +167 -0
- package/dist/lib/decentraland/communications/player-entity-manager.js.map +1 -0
- package/dist/lib/decentraland/communications/position-report-system.d.ts +8 -0
- package/dist/lib/decentraland/communications/position-report-system.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/position-report-system.js +51 -0
- package/dist/lib/decentraland/communications/position-report-system.js.map +1 -0
- package/dist/lib/decentraland/communications/realm-communications-system.d.ts +17 -0
- package/dist/lib/decentraland/communications/realm-communications-system.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/realm-communications-system.js +111 -0
- package/dist/lib/decentraland/communications/realm-communications-system.js.map +1 -0
- package/dist/lib/decentraland/communications/scene-comms.d.ts +9 -0
- package/dist/lib/decentraland/communications/scene-comms.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/scene-comms.js +20 -0
- package/dist/lib/decentraland/communications/scene-comms.js.map +1 -0
- package/dist/lib/decentraland/communications/transports/livekit.d.ts +27 -0
- package/dist/lib/decentraland/communications/transports/livekit.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/transports/livekit.js +135 -0
- package/dist/lib/decentraland/communications/transports/livekit.js.map +1 -0
- package/dist/lib/decentraland/communications/transports/ws-room.d.ts +26 -0
- package/dist/lib/decentraland/communications/transports/ws-room.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/transports/ws-room.js +235 -0
- package/dist/lib/decentraland/communications/transports/ws-room.js.map +1 -0
- package/dist/lib/decentraland/communications/types.d.ts +76 -0
- package/dist/lib/decentraland/communications/types.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/types.js +6 -0
- package/dist/lib/decentraland/communications/types.js.map +1 -0
- package/dist/lib/decentraland/communications/ws-async-channel.d.ts +6 -0
- package/dist/lib/decentraland/communications/ws-async-channel.d.ts.map +1 -0
- package/dist/lib/decentraland/communications/ws-async-channel.js +52 -0
- package/dist/lib/decentraland/communications/ws-async-channel.js.map +1 -0
- package/dist/lib/decentraland/crdt-internal/components.d.ts +156 -0
- package/dist/lib/decentraland/crdt-internal/components.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-internal/components.js +8 -0
- package/dist/lib/decentraland/crdt-internal/components.js.map +1 -0
- package/dist/lib/decentraland/crdt-internal/conflict-resolution.d.ts +45 -0
- package/dist/lib/decentraland/crdt-internal/conflict-resolution.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-internal/conflict-resolution.js +49 -0
- package/dist/lib/decentraland/crdt-internal/conflict-resolution.js.map +1 -0
- package/dist/lib/decentraland/crdt-internal/dataCompare.d.ts +6 -0
- package/dist/lib/decentraland/crdt-internal/dataCompare.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-internal/dataCompare.js +34 -0
- package/dist/lib/decentraland/crdt-internal/dataCompare.js.map +1 -0
- package/dist/lib/decentraland/crdt-internal/generational-index-pool.d.ts +22 -0
- package/dist/lib/decentraland/crdt-internal/generational-index-pool.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-internal/generational-index-pool.js +91 -0
- package/dist/lib/decentraland/crdt-internal/generational-index-pool.js.map +1 -0
- package/dist/lib/decentraland/crdt-internal/grow-only-set.d.ts +10 -0
- package/dist/lib/decentraland/crdt-internal/grow-only-set.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-internal/grow-only-set.js +129 -0
- package/dist/lib/decentraland/crdt-internal/grow-only-set.js.map +1 -0
- package/dist/lib/decentraland/crdt-internal/last-write-win-element-set.d.ts +11 -0
- package/dist/lib/decentraland/crdt-internal/last-write-win-element-set.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-internal/last-write-win-element-set.js +224 -0
- package/dist/lib/decentraland/crdt-internal/last-write-win-element-set.js.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/appendValue.d.ts +15 -0
- package/dist/lib/decentraland/crdt-wire-protocol/appendValue.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/appendValue.js +50 -0
- package/dist/lib/decentraland/crdt-wire-protocol/appendValue.js.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/crdtMessageProtocol.d.ts +31 -0
- package/dist/lib/decentraland/crdt-wire-protocol/crdtMessageProtocol.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/crdtMessageProtocol.js +72 -0
- package/dist/lib/decentraland/crdt-wire-protocol/crdtMessageProtocol.js.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/deleteComponent.d.ts +14 -0
- package/dist/lib/decentraland/crdt-wire-protocol/deleteComponent.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/deleteComponent.js +44 -0
- package/dist/lib/decentraland/crdt-wire-protocol/deleteComponent.js.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/deleteEntity.d.ts +11 -0
- package/dist/lib/decentraland/crdt-wire-protocol/deleteEntity.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/deleteEntity.js +35 -0
- package/dist/lib/decentraland/crdt-wire-protocol/deleteEntity.js.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/index.d.ts +8 -0
- package/dist/lib/decentraland/crdt-wire-protocol/index.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/index.js +24 -0
- package/dist/lib/decentraland/crdt-wire-protocol/index.js.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/message.d.ts +17 -0
- package/dist/lib/decentraland/crdt-wire-protocol/message.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/message.js +49 -0
- package/dist/lib/decentraland/crdt-wire-protocol/message.js.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/prettyPrint.d.ts +4 -0
- package/dist/lib/decentraland/crdt-wire-protocol/prettyPrint.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/prettyPrint.js +26 -0
- package/dist/lib/decentraland/crdt-wire-protocol/prettyPrint.js.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/putComponent.d.ts +15 -0
- package/dist/lib/decentraland/crdt-wire-protocol/putComponent.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/putComponent.js +48 -0
- package/dist/lib/decentraland/crdt-wire-protocol/putComponent.js.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/types.d.ts +80 -0
- package/dist/lib/decentraland/crdt-wire-protocol/types.d.ts.map +1 -0
- package/dist/lib/decentraland/crdt-wire-protocol/types.js +15 -0
- package/dist/lib/decentraland/crdt-wire-protocol/types.js.map +1 -0
- package/dist/lib/decentraland/identifiers.d.ts +6 -0
- package/dist/lib/decentraland/identifiers.d.ts.map +1 -0
- package/dist/lib/decentraland/identifiers.js +22 -0
- package/dist/lib/decentraland/identifiers.js.map +1 -0
- package/dist/lib/decentraland/identity/avatar.d.ts +4 -0
- package/dist/lib/decentraland/identity/avatar.d.ts.map +1 -0
- package/dist/lib/decentraland/identity/avatar.js +57 -0
- package/dist/lib/decentraland/identity/avatar.js.map +1 -0
- package/dist/lib/decentraland/identity/login.d.ts +8 -0
- package/dist/lib/decentraland/identity/login.d.ts.map +1 -0
- package/dist/lib/decentraland/identity/login.js +121 -0
- package/dist/lib/decentraland/identity/login.js.map +1 -0
- package/dist/lib/decentraland/identity/signed-fetch.d.ts +17 -0
- package/dist/lib/decentraland/identity/signed-fetch.d.ts.map +1 -0
- package/dist/lib/decentraland/identity/signed-fetch.js +47 -0
- package/dist/lib/decentraland/identity/signed-fetch.js.map +1 -0
- package/dist/lib/decentraland/identity/types.d.ts +11 -0
- package/dist/lib/decentraland/identity/types.d.ts.map +1 -0
- package/dist/lib/decentraland/identity/types.js +3 -0
- package/dist/lib/decentraland/identity/types.js.map +1 -0
- package/dist/lib/decentraland/positions.d.ts +15 -0
- package/dist/lib/decentraland/positions.d.ts.map +1 -0
- package/dist/lib/decentraland/positions.js +40 -0
- package/dist/lib/decentraland/positions.js.map +1 -0
- package/dist/lib/decentraland/realm/resolution.d.ts +2 -0
- package/dist/lib/decentraland/realm/resolution.d.ts.map +1 -0
- package/dist/lib/decentraland/realm/resolution.js +39 -0
- package/dist/lib/decentraland/realm/resolution.js.map +1 -0
- package/dist/lib/decentraland/scene/content-server-entity.d.ts +34 -0
- package/dist/lib/decentraland/scene/content-server-entity.d.ts.map +1 -0
- package/dist/lib/decentraland/scene/content-server-entity.js +22 -0
- package/dist/lib/decentraland/scene/content-server-entity.js.map +1 -0
- package/dist/lib/decentraland/scene/spawn-points.d.ts +16 -0
- package/dist/lib/decentraland/scene/spawn-points.d.ts.map +1 -0
- package/dist/lib/decentraland/scene/spawn-points.js +78 -0
- package/dist/lib/decentraland/scene/spawn-points.js.map +1 -0
- package/dist/lib/decentraland/scene/types.d.ts +38 -0
- package/dist/lib/decentraland/scene/types.d.ts.map +1 -0
- package/dist/lib/decentraland/scene/types.js +3 -0
- package/dist/lib/decentraland/scene/types.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/animator-component.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/animator-component.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/animator-component.js +12 -0
- package/dist/lib/decentraland/sdk-components/animator-component.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/avatar-base.d.ts +5 -0
- package/dist/lib/decentraland/sdk-components/avatar-base.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/avatar-base.js +40 -0
- package/dist/lib/decentraland/sdk-components/avatar-base.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/avatar-customizations.d.ts +5 -0
- package/dist/lib/decentraland/sdk-components/avatar-customizations.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/avatar-customizations.js +9 -0
- package/dist/lib/decentraland/sdk-components/avatar-customizations.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/avatar-shape.d.ts +5 -0
- package/dist/lib/decentraland/sdk-components/avatar-shape.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/avatar-shape.js +33 -0
- package/dist/lib/decentraland/sdk-components/avatar-shape.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/billboard-component.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/billboard-component.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/billboard-component.js +15 -0
- package/dist/lib/decentraland/sdk-components/billboard-component.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/delayed-interpolation.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/delayed-interpolation.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/delayed-interpolation.js +15 -0
- package/dist/lib/decentraland/sdk-components/delayed-interpolation.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/engine-info.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/engine-info.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/engine-info.js +7 -0
- package/dist/lib/decentraland/sdk-components/engine-info.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/gltf-component.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/gltf-component.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/gltf-component.js +114 -0
- package/dist/lib/decentraland/sdk-components/gltf-component.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/gltf-loading-state.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/gltf-loading-state.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/gltf-loading-state.js +7 -0
- package/dist/lib/decentraland/sdk-components/gltf-loading-state.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/material-component.d.ts +5 -0
- package/dist/lib/decentraland/sdk-components/material-component.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/material-component.js +92 -0
- package/dist/lib/decentraland/sdk-components/material-component.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/mesh-collider-component.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/mesh-collider-component.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/mesh-collider-component.js +37 -0
- package/dist/lib/decentraland/sdk-components/mesh-collider-component.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/mesh-renderer-component.d.ts +5 -0
- package/dist/lib/decentraland/sdk-components/mesh-renderer-component.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/mesh-renderer-component.js +111 -0
- package/dist/lib/decentraland/sdk-components/mesh-renderer-component.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/pb-based-component-helper.d.ts +10 -0
- package/dist/lib/decentraland/sdk-components/pb-based-component-helper.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/pb-based-component-helper.js +23 -0
- package/dist/lib/decentraland/sdk-components/pb-based-component-helper.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/player-identity-data.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/player-identity-data.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/player-identity-data.js +7 -0
- package/dist/lib/decentraland/sdk-components/player-identity-data.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/pointer-events-result.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/pointer-events-result.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/pointer-events-result.js +7 -0
- package/dist/lib/decentraland/sdk-components/pointer-events-result.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/pointer-events.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/pointer-events.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/pointer-events.js +15 -0
- package/dist/lib/decentraland/sdk-components/pointer-events.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/raycast-component.d.ts +5 -0
- package/dist/lib/decentraland/sdk-components/raycast-component.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/raycast-component.js +66 -0
- package/dist/lib/decentraland/sdk-components/raycast-component.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/transform-component.d.ts +13 -0
- package/dist/lib/decentraland/sdk-components/transform-component.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/transform-component.js +84 -0
- package/dist/lib/decentraland/sdk-components/transform-component.js.map +1 -0
- package/dist/lib/decentraland/sdk-components/tween.d.ts +3 -0
- package/dist/lib/decentraland/sdk-components/tween.d.ts.map +1 -0
- package/dist/lib/decentraland/sdk-components/tween.js +15 -0
- package/dist/lib/decentraland/sdk-components/tween.js.map +1 -0
- package/dist/lib/decentraland/state.d.ts +24 -0
- package/dist/lib/decentraland/state.d.ts.map +1 -0
- package/dist/lib/decentraland/state.js +16 -0
- package/dist/lib/decentraland/state.js.map +1 -0
- package/dist/lib/decentraland/system.d.ts +7 -0
- package/dist/lib/decentraland/system.d.ts.map +1 -0
- package/dist/lib/decentraland/system.js +13 -0
- package/dist/lib/decentraland/system.js.map +1 -0
- package/dist/lib/decentraland/types.d.ts +9 -0
- package/dist/lib/decentraland/types.d.ts.map +1 -0
- package/dist/lib/decentraland/types.js +3 -0
- package/dist/lib/decentraland/types.js.map +1 -0
- package/dist/lib/decentraland/virtual-scene.d.ts +12 -0
- package/dist/lib/decentraland/virtual-scene.d.ts.map +1 -0
- package/dist/lib/decentraland/virtual-scene.js +3 -0
- package/dist/lib/decentraland/virtual-scene.js.map +1 -0
- package/dist/lib/engine-main.d.ts +8 -0
- package/dist/lib/engine-main.d.ts.map +1 -0
- package/dist/lib/engine-main.js +103 -0
- package/dist/lib/engine-main.js.map +1 -0
- package/dist/lib/misc/atom.d.ts +13 -0
- package/dist/lib/misc/atom.d.ts.map +1 -0
- package/dist/lib/misc/atom.js +66 -0
- package/dist/lib/misc/atom.js.map +1 -0
- package/dist/lib/misc/bit-operations.d.ts +3 -0
- package/dist/lib/misc/bit-operations.d.ts.map +1 -0
- package/dist/lib/misc/bit-operations.js +14 -0
- package/dist/lib/misc/bit-operations.js.map +1 -0
- package/dist/lib/misc/flat-fetch.d.ts +16 -0
- package/dist/lib/misc/flat-fetch.d.ts.map +1 -0
- package/dist/lib/misc/flat-fetch.js +26 -0
- package/dist/lib/misc/flat-fetch.js.map +1 -0
- package/dist/lib/misc/json.d.ts +3 -0
- package/dist/lib/misc/json.d.ts.map +1 -0
- package/dist/lib/misc/json.js +24 -0
- package/dist/lib/misc/json.js.map +1 -0
- package/dist/lib/misc/logger.d.ts +6 -0
- package/dist/lib/misc/logger.d.ts.map +1 -0
- package/dist/lib/misc/logger.js +24 -0
- package/dist/lib/misc/logger.js.map +1 -0
- package/dist/lib/misc/memoize.d.ts +2 -0
- package/dist/lib/misc/memoize.d.ts.map +1 -0
- package/dist/lib/misc/memoize.js +16 -0
- package/dist/lib/misc/memoize.js.map +1 -0
- package/dist/lib/misc/promises.d.ts +3 -0
- package/dist/lib/misc/promises.d.ts.map +1 -0
- package/dist/lib/misc/promises.js +14 -0
- package/dist/lib/misc/promises.js.map +1 -0
- package/dist/lib/polyfills/xmlhttprequest.d.ts +6 -0
- package/dist/lib/polyfills/xmlhttprequest.d.ts.map +1 -0
- package/dist/lib/polyfills/xmlhttprequest.js +127 -0
- package/dist/lib/polyfills/xmlhttprequest.js.map +1 -0
- package/dist/lib/quick-js/convert-handles.d.ts +14 -0
- package/dist/lib/quick-js/convert-handles.d.ts.map +1 -0
- package/dist/lib/quick-js/convert-handles.js +83 -0
- package/dist/lib/quick-js/convert-handles.js.map +1 -0
- package/dist/lib/quick-js/index.d.ts +12 -0
- package/dist/lib/quick-js/index.d.ts.map +1 -0
- package/dist/lib/quick-js/index.js +159 -0
- package/dist/lib/quick-js/index.js.map +1 -0
- package/dist/lib/quick-js/rpc-scene-runtime.d.ts +13 -0
- package/dist/lib/quick-js/rpc-scene-runtime.d.ts.map +1 -0
- package/dist/lib/quick-js/rpc-scene-runtime.js +32 -0
- package/dist/lib/quick-js/rpc-scene-runtime.js.map +1 -0
- package/dist/lib/quick-js/types.d.ts +35 -0
- package/dist/lib/quick-js/types.d.ts.map +1 -0
- package/dist/lib/quick-js/types.js +3 -0
- package/dist/lib/quick-js/types.js.map +1 -0
- package/dist/lib/web-worker-runtime/context.d.ts +12 -0
- package/dist/lib/web-worker-runtime/context.d.ts.map +1 -0
- package/dist/lib/web-worker-runtime/context.js +97 -0
- package/dist/lib/web-worker-runtime/context.js.map +1 -0
- package/dist/lib/web-worker-runtime/sandbox.d.ts +9 -0
- package/dist/lib/web-worker-runtime/sandbox.d.ts.map +1 -0
- package/dist/lib/web-worker-runtime/sandbox.js +98 -0
- package/dist/lib/web-worker-runtime/sandbox.js.map +1 -0
- package/dist/lib/web-worker-runtime/web-worker-scene-runtime.d.ts +13 -0
- package/dist/lib/web-worker-runtime/web-worker-scene-runtime.d.ts.map +1 -0
- package/dist/lib/web-worker-runtime/web-worker-scene-runtime.js +32 -0
- package/dist/lib/web-worker-runtime/web-worker-scene-runtime.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.playerEntityManager = exports.PlayerEntityManager = exports.EntityUtils = void 0;
|
|
4
|
+
// Entity utilities for bit-packed entity numbers and versions
|
|
5
|
+
const MAX_U16 = 0xffff;
|
|
6
|
+
const MASK_UPPER_16_ON_32 = 0xffff0000;
|
|
7
|
+
var EntityUtils;
|
|
8
|
+
(function (EntityUtils) {
|
|
9
|
+
function fromEntityId(entityId) {
|
|
10
|
+
return [(entityId & MAX_U16) >>> 0, (((entityId & MASK_UPPER_16_ON_32) >> 16) & MAX_U16) >>> 0];
|
|
11
|
+
}
|
|
12
|
+
EntityUtils.fromEntityId = fromEntityId;
|
|
13
|
+
function toEntityId(entityNumber, entityVersion) {
|
|
14
|
+
return (((entityNumber & MAX_U16) | ((entityVersion & MAX_U16) << 16)) >>> 0);
|
|
15
|
+
}
|
|
16
|
+
EntityUtils.toEntityId = toEntityId;
|
|
17
|
+
})(EntityUtils = exports.EntityUtils || (exports.EntityUtils = {}));
|
|
18
|
+
// Based on Unity's SpecialEntitiesID constants
|
|
19
|
+
const PLAYER_ENTITY = 1;
|
|
20
|
+
const OTHER_PLAYER_ENTITIES_FROM = 32;
|
|
21
|
+
const OTHER_PLAYER_ENTITIES_TO = 256;
|
|
22
|
+
class PlayerEntityManager {
|
|
23
|
+
constructor() {
|
|
24
|
+
// Set of allocated entities for efficient checking
|
|
25
|
+
this.allocatedEntities = new Set();
|
|
26
|
+
// Map from player address to entity ID
|
|
27
|
+
this.addressToEntityMap = new Map();
|
|
28
|
+
// Map from entity ID to player address
|
|
29
|
+
this.entityToAddressMap = new Map();
|
|
30
|
+
// Track entity versions for reuse (entity number -> highest version)
|
|
31
|
+
this.entityVersions = new Map();
|
|
32
|
+
// Next available entity number to allocate
|
|
33
|
+
this.nextEntityNumber = OTHER_PLAYER_ENTITIES_FROM;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Allocates a reserved entity ID for a player address.
|
|
37
|
+
* Returns the local player entity (1) for the local player, or a versioned entity (32-255) for remote players.
|
|
38
|
+
*/
|
|
39
|
+
allocateEntityForPlayer(address, isLocalPlayer = false) {
|
|
40
|
+
// Normalize address to lowercase to match Unity behavior
|
|
41
|
+
const normalizedAddress = address.toLowerCase();
|
|
42
|
+
// Return existing entity if already allocated
|
|
43
|
+
if (this.addressToEntityMap.has(normalizedAddress)) {
|
|
44
|
+
return this.addressToEntityMap.get(normalizedAddress);
|
|
45
|
+
}
|
|
46
|
+
let entityId;
|
|
47
|
+
if (isLocalPlayer) {
|
|
48
|
+
entityId = PLAYER_ENTITY;
|
|
49
|
+
this.addressToEntityMap.set(normalizedAddress, entityId);
|
|
50
|
+
this.entityToAddressMap.set(entityId, normalizedAddress);
|
|
51
|
+
console.log(`Allocated local player entity ${entityId} for ${normalizedAddress}`);
|
|
52
|
+
return entityId;
|
|
53
|
+
}
|
|
54
|
+
// For remote players, try to reuse an entity with incremented version first
|
|
55
|
+
for (const [entityNumber, currentVersion] of this.entityVersions) {
|
|
56
|
+
if (entityNumber >= OTHER_PLAYER_ENTITIES_FROM && entityNumber < OTHER_PLAYER_ENTITIES_TO) {
|
|
57
|
+
if (currentVersion < MAX_U16) {
|
|
58
|
+
const newEntity = EntityUtils.toEntityId(entityNumber, currentVersion + 1);
|
|
59
|
+
if (!this.allocatedEntities.has(newEntity)) {
|
|
60
|
+
this.entityVersions.set(entityNumber, currentVersion + 1);
|
|
61
|
+
this.allocatedEntities.add(newEntity);
|
|
62
|
+
this.addressToEntityMap.set(normalizedAddress, newEntity);
|
|
63
|
+
this.entityToAddressMap.set(newEntity, normalizedAddress);
|
|
64
|
+
console.log(`Reused entity ${entityNumber} version ${currentVersion + 1} (id: ${newEntity}) for ${normalizedAddress}`);
|
|
65
|
+
return newEntity;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Allocate new entity number if no reusable entities available
|
|
71
|
+
if (this.nextEntityNumber < OTHER_PLAYER_ENTITIES_TO) {
|
|
72
|
+
const entityNumber = this.nextEntityNumber++;
|
|
73
|
+
const entityVersion = 0;
|
|
74
|
+
const newEntity = EntityUtils.toEntityId(entityNumber, entityVersion);
|
|
75
|
+
this.entityVersions.set(entityNumber, entityVersion);
|
|
76
|
+
this.allocatedEntities.add(newEntity);
|
|
77
|
+
this.addressToEntityMap.set(normalizedAddress, newEntity);
|
|
78
|
+
this.entityToAddressMap.set(newEntity, normalizedAddress);
|
|
79
|
+
return newEntity;
|
|
80
|
+
}
|
|
81
|
+
console.warn('No available entity slots for remote players');
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Frees the entity allocated to a player address
|
|
86
|
+
*/
|
|
87
|
+
freeEntityForPlayer(address) {
|
|
88
|
+
const normalizedAddress = address.toLowerCase();
|
|
89
|
+
const entityId = this.addressToEntityMap.get(normalizedAddress);
|
|
90
|
+
if (entityId !== undefined) {
|
|
91
|
+
// Don't free the local player entity, just clear mappings
|
|
92
|
+
if (entityId === PLAYER_ENTITY) {
|
|
93
|
+
this.addressToEntityMap.delete(normalizedAddress);
|
|
94
|
+
this.entityToAddressMap.delete(entityId);
|
|
95
|
+
console.log(`Cleared local player entity ${entityId} for ${normalizedAddress}`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// For remote player entities, remove from allocated set but keep version info
|
|
99
|
+
const [entityNumber] = EntityUtils.fromEntityId(entityId);
|
|
100
|
+
if (entityNumber >= OTHER_PLAYER_ENTITIES_FROM && entityNumber < OTHER_PLAYER_ENTITIES_TO) {
|
|
101
|
+
this.allocatedEntities.delete(entityId);
|
|
102
|
+
// Keep entityVersions entry for potential reuse with incremented version
|
|
103
|
+
}
|
|
104
|
+
this.addressToEntityMap.delete(normalizedAddress);
|
|
105
|
+
this.entityToAddressMap.delete(entityId);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Gets the player address for a given entity ID
|
|
110
|
+
*/
|
|
111
|
+
getAddressForEntity(entityId) {
|
|
112
|
+
return this.entityToAddressMap.get(entityId) || null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Gets the entity ID for a given player address
|
|
116
|
+
*/
|
|
117
|
+
getEntityForAddress(address) {
|
|
118
|
+
const normalizedAddress = address.toLowerCase();
|
|
119
|
+
return this.addressToEntityMap.get(normalizedAddress) || null;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Checks if an entity ID is a reserved player entity
|
|
123
|
+
*/
|
|
124
|
+
isPlayerEntity(entityId) {
|
|
125
|
+
if (entityId === PLAYER_ENTITY)
|
|
126
|
+
return true;
|
|
127
|
+
const [entityNumber] = EntityUtils.fromEntityId(entityId);
|
|
128
|
+
return entityNumber >= OTHER_PLAYER_ENTITIES_FROM && entityNumber < OTHER_PLAYER_ENTITIES_TO;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Gets all allocated player entities
|
|
132
|
+
*/
|
|
133
|
+
getAllPlayerEntities() {
|
|
134
|
+
return new Map(this.entityToAddressMap);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Gets entity state information for debugging
|
|
138
|
+
*/
|
|
139
|
+
getEntityInfo(entityId) {
|
|
140
|
+
const [number, version] = EntityUtils.fromEntityId(entityId);
|
|
141
|
+
return {
|
|
142
|
+
number,
|
|
143
|
+
version,
|
|
144
|
+
allocated: this.allocatedEntities.has(entityId)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Clears all reserved entities (for cleanup)
|
|
149
|
+
*/
|
|
150
|
+
clear() {
|
|
151
|
+
this.allocatedEntities.clear();
|
|
152
|
+
this.addressToEntityMap.clear();
|
|
153
|
+
this.entityToAddressMap.clear();
|
|
154
|
+
this.entityVersions.clear();
|
|
155
|
+
this.nextEntityNumber = OTHER_PLAYER_ENTITIES_FROM;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Gets all allocated entities
|
|
159
|
+
*/
|
|
160
|
+
getAllocatedEntities() {
|
|
161
|
+
return new Set(this.allocatedEntities);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.PlayerEntityManager = PlayerEntityManager;
|
|
165
|
+
// Singleton instance for global use
|
|
166
|
+
exports.playerEntityManager = new PlayerEntityManager();
|
|
167
|
+
//# sourceMappingURL=player-entity-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player-entity-manager.js","sourceRoot":"","sources":["../../../../src/lib/decentraland/communications/player-entity-manager.ts"],"names":[],"mappings":";;;AAEA,8DAA8D;AAC9D,MAAM,OAAO,GAAG,MAAM,CAAA;AACtB,MAAM,mBAAmB,GAAG,UAAU,CAAA;AAEtC,IAAiB,WAAW,CAQ3B;AARD,WAAiB,WAAW;IAC1B,SAAgB,YAAY,CAAC,QAAgB;QAC3C,OAAO,CAAC,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,mBAAmB,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IACjG,CAAC;IAFe,wBAAY,eAE3B,CAAA;IAED,SAAgB,UAAU,CAAC,YAAoB,EAAE,aAAqB;QACpE,OAAO,CAAC,CAAC,CAAC,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,aAAa,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAW,CAAA;IACzF,CAAC;IAFe,sBAAU,aAEzB,CAAA;AACH,CAAC,EARgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAQ3B;AAED,+CAA+C;AAC/C,MAAM,aAAa,GAAG,CAAC,CAAA;AACvB,MAAM,0BAA0B,GAAG,EAAE,CAAA;AACrC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAEpC,MAAa,mBAAmB;IAAhC;QACE,mDAAmD;QAC3C,sBAAiB,GAAG,IAAI,GAAG,EAAU,CAAA;QAE7C,uCAAuC;QAC/B,uBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAA;QAEtD,uCAAuC;QAC/B,uBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAA;QAEtD,qEAAqE;QAC7D,mBAAc,GAAG,IAAI,GAAG,EAAkB,CAAA;QAElD,2CAA2C;QACnC,qBAAgB,GAAG,0BAA0B,CAAA;IAo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,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,QAAgB;QAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QAC5D,OAAO;YACL,MAAM;YACN,OAAO;YACP,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC;SAChD,CAAA;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAA;QAC9B,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAA;QAC/B,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAA;QAC/B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAA;QAC3B,IAAI,CAAC,gBAAgB,GAAG,0BAA0B,CAAA;IACpD,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IACxC,CAAC;CACF;AAlKD,kDAkKC;AAED,oCAAoC;AACvB,QAAA,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommsTransportWrapper } from "./CommsTransportWrapper";
|
|
2
|
+
import { Quaternion, TransformNode, Vector3 } from "@babylonjs/core";
|
|
3
|
+
import { DecentralandSystem } from "../system";
|
|
4
|
+
export type ReportPositionSystem = DecentralandSystem & {
|
|
5
|
+
reportPosition(position: Vector3, rotation: Quaternion, forcePosition: boolean): void;
|
|
6
|
+
};
|
|
7
|
+
export declare function createCommunicationsPositionReportSystem(transports: () => Iterable<CommsTransportWrapper>, playerEntity: TransformNode): ReportPositionSystem;
|
|
8
|
+
//# sourceMappingURL=position-report-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position-report-system.d.ts","sourceRoot":"","sources":["../../../../src/lib/decentraland/communications/position-report-system.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAwB,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAG9C,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,GAAG;IACtD,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CAAA;CACtF,CAAA;AAGD,wBAAgB,wCAAwC,CAAC,UAAU,EAAE,MAAM,QAAQ,CAAC,qBAAqB,CAAC,EAAE,YAAY,EAAE,aAAa,GAAG,oBAAoB,CAgD7J"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCommunicationsPositionReportSystem = void 0;
|
|
4
|
+
const CommsTransportWrapper_1 = require("./CommsTransportWrapper");
|
|
5
|
+
const core_1 = require("@babylonjs/core");
|
|
6
|
+
const static_entities_1 = require("../../babylon/scene/logic/static-entities");
|
|
7
|
+
// this function generates a delegate that filters by time and limits position reports to 10Hz
|
|
8
|
+
function createCommunicationsPositionReportSystem(transports, playerEntity) {
|
|
9
|
+
// force max of 10Hz
|
|
10
|
+
const MAX_POSITIONS_PER_SECOND = 10;
|
|
11
|
+
let globalPositionIndex = 0;
|
|
12
|
+
let lastReport = performance.now();
|
|
13
|
+
function shouldDiscard() {
|
|
14
|
+
const now = performance.now();
|
|
15
|
+
if ((now - lastReport) < (1000 / MAX_POSITIONS_PER_SECOND)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
lastReport = now;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
function reportPosition(position, rotation, forcePosition) {
|
|
22
|
+
globalPositionIndex++;
|
|
23
|
+
if (!forcePosition && shouldDiscard())
|
|
24
|
+
return;
|
|
25
|
+
const positionReport = {
|
|
26
|
+
index: globalPositionIndex,
|
|
27
|
+
positionX: position.x,
|
|
28
|
+
positionY: position.y,
|
|
29
|
+
positionZ: position.z,
|
|
30
|
+
rotationX: rotation.x,
|
|
31
|
+
rotationY: rotation.y,
|
|
32
|
+
rotationZ: rotation.z,
|
|
33
|
+
rotationW: rotation.w,
|
|
34
|
+
// timestamp: performance.now()
|
|
35
|
+
};
|
|
36
|
+
for (const it of transports()) {
|
|
37
|
+
if (it.state === CommsTransportWrapper_1.RoomConnectionStatus.CONNECTED) {
|
|
38
|
+
it.sendPositionMessage(positionReport);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
update() {
|
|
44
|
+
// report the position of the first person camera to all transports
|
|
45
|
+
reportPosition(playerEntity.absolutePosition.subtract(new core_1.Vector3(0, static_entities_1.PLAYER_HEIGHT, 0)), playerEntity.absoluteRotationQuaternion, false);
|
|
46
|
+
},
|
|
47
|
+
reportPosition
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
exports.createCommunicationsPositionReportSystem = createCommunicationsPositionReportSystem;
|
|
51
|
+
//# sourceMappingURL=position-report-system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position-report-system.js","sourceRoot":"","sources":["../../../../src/lib/decentraland/communications/position-report-system.ts"],"names":[],"mappings":";;;AACA,mEAAqF;AACrF,0CAAoE;AAEpE,+EAAyE;AAMzE,8FAA8F;AAC9F,SAAgB,wCAAwC,CAAC,UAAiD,EAAE,YAA2B;IACrI,oBAAoB;IACpB,MAAM,wBAAwB,GAAG,EAAE,CAAA;IAEnC,IAAI,mBAAmB,GAAG,CAAC,CAAA;IAE3B,IAAI,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAElC,SAAS,aAAa;QACpB,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QA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ter } from "./types";
|
|
4
|
+
import { CommsTransportWrapper } from "./CommsTransportWrapper";
|
|
5
|
+
import { Scene } from "@babylonjs/core";
|
|
6
|
+
import { CurrentRealm } from "../state";
|
|
7
|
+
/**
|
|
8
|
+
* This system is in charge to handle realm connections and connect/disconnect transports accordingly.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createRealmCommunicationSystem(userIdentity: Atom<ExplorerIdentity>, currentRealm: Atom<CurrentRealm>, scene: Scene): {
|
|
11
|
+
currentAdapter: Atom<CommsAdapter>;
|
|
12
|
+
currentRealm: Atom<CurrentRealm>;
|
|
13
|
+
getTransports(): IterableIterator<CommsTransportWrapper>;
|
|
14
|
+
lateUpdate(): void;
|
|
15
|
+
};
|
|
16
|
+
export declare function connectRealm(currentRealm: Atom<CurrentRealm>, realmConnectionString: string): Promise<CurrentRealm>;
|
|
17
|
+
//# sourceMappingURL=realm-communications-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realm-communications-system.d.ts","sourceRoot":"","sources":["../../../../src/lib/decentraland/communications/realm-communications-system.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,EAAE,YAAY,EAAe,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK;;;;;EAsFlI;AAED,wBAAsB,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAoBzH"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectRealm = exports.createRealmCommunicationSystem = void 0;
|
|
4
|
+
const atom_1 = require("../../misc/atom");
|
|
5
|
+
const connect_adapter_1 = require("./connect-adapter");
|
|
6
|
+
const connect_transport_1 = require("./connect-transport");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const resolution_1 = require("../realm/resolution");
|
|
9
|
+
/**
|
|
10
|
+
* This system is in charge to handle realm connections and connect/disconnect transports accordingly.
|
|
11
|
+
*/
|
|
12
|
+
function createRealmCommunicationSystem(userIdentity, currentRealm, scene) {
|
|
13
|
+
const currentAdapter = (0, atom_1.Atom)();
|
|
14
|
+
const activeTransports = new Map();
|
|
15
|
+
currentRealm.pipe(async function connectNewCommsAdapter(realm) {
|
|
16
|
+
const identity = await userIdentity.deref();
|
|
17
|
+
const isLocalPreview = realm.aboutResponse.configurations?.realmName === "LocalPreview";
|
|
18
|
+
const newAdapter = isLocalPreview ? await (0, connect_adapter_1.connectLocalAdapter)(realm.baseUrl) : await (0, connect_adapter_1.connectAdapter)(realm.aboutResponse.comms?.fixedAdapter ?? "offline:offline", identity, 'realm');
|
|
19
|
+
const oldAdapter = currentAdapter.swap(newAdapter);
|
|
20
|
+
if (oldAdapter) {
|
|
21
|
+
oldAdapter.disconnect();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
// this function returns the absolute list of transports that should be connected
|
|
25
|
+
// for the moment it only takes the desired transports from the CommsAdapter only
|
|
26
|
+
function getDesiredTransports() {
|
|
27
|
+
const ret = [];
|
|
28
|
+
const adapter = currentAdapter.getOrNull();
|
|
29
|
+
if (adapter) {
|
|
30
|
+
const desiredTransports = adapter.desiredTransports.getOrNull();
|
|
31
|
+
if (desiredTransports)
|
|
32
|
+
ret.push(...desiredTransports);
|
|
33
|
+
}
|
|
34
|
+
// TODO: here we add more desired transports from i.e. the scenes
|
|
35
|
+
return ret;
|
|
36
|
+
}
|
|
37
|
+
// updateAdapters connects the adapters that are not connected yet and disconnects the ones that are not desired anymore
|
|
38
|
+
// TODO: debounce this function to prevent fast reconnections and DDoSing the servers
|
|
39
|
+
function updateAdapters(connectionStrings) {
|
|
40
|
+
const identity = userIdentity.getOrNull();
|
|
41
|
+
if (!identity)
|
|
42
|
+
return;
|
|
43
|
+
// first remove all the extra adapters
|
|
44
|
+
for (const [connectionString, connection] of activeTransports) {
|
|
45
|
+
if (!connectionStrings.find($ => $.url === connectionString)) {
|
|
46
|
+
connection.disconnect().finally(() => {
|
|
47
|
+
types_1.commsLogger.log(`removinng not needed transport ${connectionString}`);
|
|
48
|
+
activeTransports.delete(connectionString);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// then connect all missing transports
|
|
53
|
+
for (const connectionString of connectionStrings) {
|
|
54
|
+
if (!activeTransports.has(connectionString.url)) {
|
|
55
|
+
const transport = (0, connect_transport_1.connectTransport)(connectionString.url, identity, scene, connectionString.sceneId);
|
|
56
|
+
// store the handle of the active transport
|
|
57
|
+
activeTransports.set(connectionString.url, transport);
|
|
58
|
+
// and then hook into its connection events
|
|
59
|
+
transport.events.on('DISCONNECTION', (e) => {
|
|
60
|
+
types_1.commsLogger.error(`🔌❌ ${connectionString.url} disconnected`, e);
|
|
61
|
+
if (activeTransports.get(connectionString.url) === transport) {
|
|
62
|
+
activeTransports.delete(connectionString.url);
|
|
63
|
+
types_1.commsLogger.log(`Removing disconnected transport ${connectionString}`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
transport.connect().then(() => {
|
|
67
|
+
types_1.commsLogger.log(`🔌 Connected to ${connectionString}`);
|
|
68
|
+
}).catch((e) => {
|
|
69
|
+
types_1.commsLogger.error(`❌ Could not connect to ${connectionString}`, e);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
let applicationRunning = true;
|
|
75
|
+
return {
|
|
76
|
+
currentAdapter,
|
|
77
|
+
currentRealm,
|
|
78
|
+
getTransports() {
|
|
79
|
+
return activeTransports.values();
|
|
80
|
+
},
|
|
81
|
+
lateUpdate() {
|
|
82
|
+
// connects and disconnect the transports based on the desired list
|
|
83
|
+
if (applicationRunning) {
|
|
84
|
+
const desiredTransports = getDesiredTransports();
|
|
85
|
+
updateAdapters(desiredTransports);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
exports.createRealmCommunicationSystem = createRealmCommunicationSystem;
|
|
91
|
+
async function connectRealm(currentRealm, realmConnectionString) {
|
|
92
|
+
// naively, first destroy all created scenes before loading the new realm.
|
|
93
|
+
// in the future many optimization could be applied here, like only destroying
|
|
94
|
+
// the scenes that will be replaced by the new realm.
|
|
95
|
+
const baseUrl = (await (0, resolution_1.resolveRealmBaseUrl)(realmConnectionString)).replace(/\/$/, '');
|
|
96
|
+
// fetch the standard /about endpoint for the realm
|
|
97
|
+
const res = await fetch(baseUrl + '/about');
|
|
98
|
+
if (res.ok) {
|
|
99
|
+
const aboutResponse = await res.json();
|
|
100
|
+
const newRealm = {
|
|
101
|
+
baseUrl,
|
|
102
|
+
connectionString: realmConnectionString,
|
|
103
|
+
aboutResponse
|
|
104
|
+
};
|
|
105
|
+
currentRealm.swap(newRealm);
|
|
106
|
+
return newRealm;
|
|
107
|
+
}
|
|
108
|
+
throw new Error(`Could not load the realm ${realmConnectionString}`);
|
|
109
|
+
}
|
|
110
|
+
exports.connectRealm = connectRealm;
|
|
111
|
+
//# sourceMappingURL=realm-communications-system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realm-communications-system.js","sourceRoot":"","sources":["../../../../src/lib/decentraland/communications/realm-communications-system.ts"],"names":[],"mappings":";;;AACA,0CAAsC;AAEtC,uDAAuE;AACvE,2DAAs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AA;QACD,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC3B,OAAO,QAAQ,CAAA;KAChB;IAED,MAAM,IAAI,KAAK,CAAC,4BAA4B,qBAAqB,EAAE,CAAC,CAAA;AACtE,CAAC;AApBD,oCAoBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Atom } from "../../misc/atom";
|
|
2
|
+
import { ExplorerIdentity } from "../identity/types";
|
|
3
|
+
import { Scene } from "@babylonjs/core";
|
|
4
|
+
import { CurrentRealm } from "../state";
|
|
5
|
+
/**
|
|
6
|
+
* This system is in charge to handle realm connections and connect/disconnect transports accordingly.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createSceneComms(realm: CurrentRealm, userIdentity: Atom<ExplorerIdentity>, scene: Scene): Promise<import("./CommsTransportWrapper").CommsTransportWrapper>;
|
|
9
|
+
//# sourceMappingURL=scene-comms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene-comms.d.ts","sourceRoot":"","sources":["../../../../src/lib/decentraland/communications/scene-comms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,oEAY7G"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSceneComms = void 0;
|
|
4
|
+
const connect_adapter_1 = require("./connect-adapter");
|
|
5
|
+
const connect_transport_1 = require("./connect-transport");
|
|
6
|
+
/**
|
|
7
|
+
* This system is in charge to handle realm connections and connect/disconnect transports accordingly.
|
|
8
|
+
*/
|
|
9
|
+
async function createSceneComms(realm, userIdentity, scene) {
|
|
10
|
+
const identity = await userIdentity.deref();
|
|
11
|
+
const isLocalPreview = realm.aboutResponse.configurations?.realmName === "LocalPreview";
|
|
12
|
+
const newAdapter = isLocalPreview ? await (0, connect_adapter_1.connectLocalAdapter)(realm.baseUrl) : await (0, connect_adapter_1.connectAdapter)(realm.aboutResponse.comms?.fixedAdapter ?? "offline:offline", identity, 'realm');
|
|
13
|
+
const desiredTransports = await newAdapter.desiredTransports.deref();
|
|
14
|
+
const connectionString = desiredTransports[0];
|
|
15
|
+
const transport = (0, connect_transport_1.connectTransport)(connectionString.url, identity, scene, connectionString.sceneId);
|
|
16
|
+
transport.connect();
|
|
17
|
+
return transport;
|
|
18
|
+
}
|
|
19
|
+
exports.createSceneComms = createSceneComms;
|
|
20
|
+
//# sourceMappingURL=scene-comms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene-comms.js","sourceRoot":"","sources":["../../../../src/lib/decentraland/communications/scene-comms.ts"],"names":[],"mappings":";;;AAEA,uDAAuE;AACvE,2DAAsD;AAItD;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,KAAmB,EAAE,YAAoC,EAAE,KAAY;IAC5G,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,CAAA;IAE3C,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,EAAE,SAAS,KAAK,cAAc,CAAA;IACvF,MAAM,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,MAAM,IAAA,qCAAmB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,gCAAc,EAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IACpL,MAAM,iBAAiB,GAAG,MAAM,UAAU,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAA;IACpE,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;IAC7C,MAAM,SAAS,GAAG,IAAA,oCAAgB,EAAC,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAEnG,SAAS,CAAC,OAAO,EAAE,CAAA;IAEnB,OAAO,SAAS,CAAA;AAClB,CAAC;AAZD,4CAYC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as proto from '@dcl/protocol/out-js/decentraland/kernel/comms/rfc4/comms.gen';
|
|
2
|
+
import { CommsTransportEvents, MinimumCommunicationsTransport, SendHints } from '../types';
|
|
3
|
+
import { Scene } from '@babylonjs/core';
|
|
4
|
+
export type LivekitConfig = {
|
|
5
|
+
url: string;
|
|
6
|
+
token: string;
|
|
7
|
+
scene: Scene;
|
|
8
|
+
};
|
|
9
|
+
export type VoiceSpatialParams = {
|
|
10
|
+
position: [number, number, number];
|
|
11
|
+
orientation: [number, number, number];
|
|
12
|
+
};
|
|
13
|
+
export declare class LivekitAdapter implements MinimumCommunicationsTransport {
|
|
14
|
+
private config;
|
|
15
|
+
readonly events: import("mitt").Emitter<CommsTransportEvents>;
|
|
16
|
+
private disposed;
|
|
17
|
+
private readonly room;
|
|
18
|
+
constructor(config: LivekitConfig);
|
|
19
|
+
connect(): Promise<void>;
|
|
20
|
+
send(data: Uint8Array, { reliable }: SendHints, destination?: string[]): Promise<void>;
|
|
21
|
+
disconnect(): Promise<void>;
|
|
22
|
+
doDisconnect(kicked: boolean): Promise<void>;
|
|
23
|
+
setVoicePosition(address: string, position: proto.Position): void;
|
|
24
|
+
handleMessage(address: string, data: Uint8Array): void;
|
|
25
|
+
}
|
|
26
|
+
export declare function getSpatialParamsFor(position: proto.Position): VoiceSpatialParams;
|
|
27
|
+
//# sourceMappingURL=livekit.d.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,QAAQ,GAAG,kBAAkB,CAKhF"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getSpatialParamsFor = exports.LivekitAdapter = void 0;
|
|
30
|
+
const proto = __importStar(require("@dcl/protocol/out-js/decentraland/kernel/comms/rfc4/comms.gen"));
|
|
31
|
+
const rtc_node_1 = require("@livekit/rtc-node");
|
|
32
|
+
const mitt_1 = __importDefault(require("mitt"));
|
|
33
|
+
const types_1 = require("../types");
|
|
34
|
+
const MAXIMUM_NETWORK_MSG_LENGTH = 30000;
|
|
35
|
+
class LivekitAdapter {
|
|
36
|
+
constructor(config) {
|
|
37
|
+
this.config = config;
|
|
38
|
+
this.events = (0, mitt_1.default)();
|
|
39
|
+
this.disposed = false;
|
|
40
|
+
this.room = new rtc_node_1.Room();
|
|
41
|
+
this.room
|
|
42
|
+
.on(rtc_node_1.RoomEvent.ParticipantConnected, (_) => {
|
|
43
|
+
const address = _.identity;
|
|
44
|
+
this.events.emit('PEER_CONNECTED', {
|
|
45
|
+
address: address
|
|
46
|
+
});
|
|
47
|
+
})
|
|
48
|
+
.on(rtc_node_1.RoomEvent.ParticipantDisconnected, (_) => {
|
|
49
|
+
const address = _.identity;
|
|
50
|
+
this.events.emit('PEER_DISCONNECTED', {
|
|
51
|
+
address: address
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
.on(rtc_node_1.RoomEvent.Disconnected, (reason) => {
|
|
55
|
+
if (this.disposed) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// Only show the warning if it's not a manual disconnect during restart
|
|
59
|
+
if (reason !== rtc_node_1.DisconnectReason.CLIENT_INITIATED) {
|
|
60
|
+
console.error('\n' + '═'.repeat(60));
|
|
61
|
+
console.error('⚠️ LIVEKIT DISCONNECTED - SERVER COMMUNICATION LOST');
|
|
62
|
+
console.error('═'.repeat(60));
|
|
63
|
+
console.error(`Reason: ${rtc_node_1.DisconnectReason[reason] || reason}`);
|
|
64
|
+
console.error(`Room: ${this.room.name}`);
|
|
65
|
+
console.error('═'.repeat(60));
|
|
66
|
+
console.error('Press [R] to restart the server or [Ctrl+C] to exit');
|
|
67
|
+
console.error('═'.repeat(60) + '\n');
|
|
68
|
+
}
|
|
69
|
+
const kicked = reason === rtc_node_1.DisconnectReason.DUPLICATE_IDENTITY;
|
|
70
|
+
this.doDisconnect(kicked).catch((err) => {
|
|
71
|
+
types_1.commsLogger.error(`error during disconnection ${err.toString()}`);
|
|
72
|
+
});
|
|
73
|
+
})
|
|
74
|
+
.on(rtc_node_1.RoomEvent.DataReceived, (payload, participant, _) => {
|
|
75
|
+
if (participant) {
|
|
76
|
+
this.handleMessage(participant.identity, payload);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async connect() {
|
|
81
|
+
await this.room.connect(this.config.url, this.config.token);
|
|
82
|
+
types_1.commsLogger.log(`Connected to livekit room ${this.room.name?.split(':')[0]}`, { sid: await this.room.getSid(), metadata: this.room.metadata });
|
|
83
|
+
}
|
|
84
|
+
async send(data, { reliable }, destination) {
|
|
85
|
+
if (this.disposed) {
|
|
86
|
+
types_1.commsLogger.error('disposed');
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (data.length > MAXIMUM_NETWORK_MSG_LENGTH) {
|
|
90
|
+
const message = proto.Packet.decode(data);
|
|
91
|
+
types_1.commsLogger.error('Skipping big message over comms', message);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (this.room.connectionState !== rtc_node_1.ConnectionState.CONN_CONNECTED) {
|
|
95
|
+
types_1.commsLogger.error('Not connected to LiveKit', this.room.connectionState);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
await this.room.localParticipant?.publishData(data, { reliable, destination_identities: destination });
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
// NOTE: for tracking purposes only, this is not a "code" error, this is a failed connection or a problem with the livekit instance
|
|
103
|
+
await this.disconnect();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async disconnect() {
|
|
107
|
+
return this.doDisconnect(false);
|
|
108
|
+
}
|
|
109
|
+
async doDisconnect(kicked) {
|
|
110
|
+
if (this.disposed) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.disposed = true;
|
|
114
|
+
await this.room.disconnect().catch(types_1.commsLogger.error);
|
|
115
|
+
this.events.emit('DISCONNECTION', { kicked });
|
|
116
|
+
}
|
|
117
|
+
setVoicePosition(address, position) {
|
|
118
|
+
// No-op for headless server
|
|
119
|
+
}
|
|
120
|
+
handleMessage(address, data) {
|
|
121
|
+
this.events.emit('message', {
|
|
122
|
+
address,
|
|
123
|
+
data
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.LivekitAdapter = LivekitAdapter;
|
|
128
|
+
function getSpatialParamsFor(position) {
|
|
129
|
+
return {
|
|
130
|
+
position: [position.positionX, position.positionY, position.positionZ],
|
|
131
|
+
orientation: [0, 0, 1] // Default forward orientation for headless
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
exports.getSpatialParamsFor = getSpatialParamsFor;
|
|
135
|
+
//# sourceMappingURL=livekit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"livekit.js","sourceRoot":"","sources":["../../../../../src/lib/decentraland/communications/transports/livekit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qGAAsF;AACtF,gDAK0B;AAE1B,gDAAuB;AACvB,oCAAuG;AAcvG,MAAM,0BAA0B,GAAG,KAAM,CAAA;AAEzC,MAAa,cAAc;IAMzB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QALzB,WAAM,GAAG,IAAA,cAAI,GAAwB,CAAA;QAE7C,aAAQ,GAAG,KAAK,CAAA;QAItB,IAAI,CAAC,IAAI,GAAG,IAAI,eAAI,EAAE,CAAA;QAEtB,IAAI,CAAC,IAAI;aACN,EAAE,CAAC,oBAAS,CAAC,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE;YACxC,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,CAAA;YAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;gBACjC,OAAO,EAAE,OAAO;aACjB,CAAC,CAAA;QACJ,CAAC,CAAC;aACD,EAAE,CAAC,oBAAS,CAAC,uBA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
|
|
1
|
+
import { IFuture } from 'fp-future';
|
|
2
|
+
import { WebSocket } from 'ws';
|
|
3
|
+
import * as rfc5 from '@dcl/protocol/out-js/decentraland/kernel/comms/rfc5/ws_comms.gen';
|
|
4
|
+
import { ExplorerIdentity } from '../../identity/types';
|
|
5
|
+
import { CommsTransportEvents, MinimumCommunicationsTransport, SendHints } from '../types';
|
|
6
|
+
import { Position } from '@dcl/protocol/out-js/decentraland/kernel/comms/rfc4/comms.gen';
|
|
7
|
+
export declare class WebSocketAdapter implements MinimumCommunicationsTransport {
|
|
8
|
+
url: string;
|
|
9
|
+
private identity;
|
|
10
|
+
alias: number | null;
|
|
11
|
+
events: import("mitt").Emitter<CommsTransportEvents>;
|
|
12
|
+
private connected;
|
|
13
|
+
private peersToAddress;
|
|
14
|
+
get connectedPromise(): IFuture<Set<string>>;
|
|
15
|
+
private ws;
|
|
16
|
+
constructor(url: string, identity: ExplorerIdentity);
|
|
17
|
+
setVoicePosition(_address: string, _position: Position): void;
|
|
18
|
+
connect(): Promise<void>;
|
|
19
|
+
handleWelcomeMessage(welcomeMessage: rfc5.WsWelcome, socket: WebSocket): Set<string>;
|
|
20
|
+
send(body: Uint8Array, hints: SendHints): void;
|
|
21
|
+
disconnect(error?: Error): Promise<void>;
|
|
22
|
+
internalDisconnect(kicked: boolean, _error?: Error): void;
|
|
23
|
+
private onWsMessage;
|
|
24
|
+
private internalSend;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ws-room.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-room.d.ts","sourceRoot":"","sources":["../../../../../src/lib/decentraland/communications/transports/ws-room.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,OAAO,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAgB,MAAM,IAAI,CAAA;AAE5C,OAAO,KAAK,IAAI,MAAM,kEAAkE,CAAA;AAKxF,OAAO,EAAE,gBAAgB,EAAE,MA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