@relu-interactives/spatial-ecs 0.5.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{System-V_mv07le.d.cts → System-8D-XBDKZ.d.cts} +734 -8
- package/dist/{System-V_mv07le.d.ts → System-DPMAW30g.d.ts} +734 -8
- package/dist/{XRHandPose-CU3vNFuS.d.ts → XRHandPose-CWSrsnYN.d.ts} +236 -3
- package/dist/{XRHandPose-CQTLGxFC.d.cts → XRHandPose-Dn2yiALk.d.cts} +236 -3
- package/dist/animation/index.cjs +252 -0
- package/dist/animation/index.cjs.map +1 -0
- package/dist/animation/index.d.cts +100 -0
- package/dist/animation/index.d.ts +100 -0
- package/dist/animation/index.js +4 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/chunk-CKTHDXPS.js +11 -0
- package/dist/chunk-CKTHDXPS.js.map +1 -0
- package/dist/chunk-GSWC6LLD.js +241 -0
- package/dist/chunk-GSWC6LLD.js.map +1 -0
- package/dist/chunk-JEPUCLZX.js +1237 -0
- package/dist/chunk-JEPUCLZX.js.map +1 -0
- package/dist/{chunk-BUEKOSR5.js → chunk-JNYPJB55.js} +435 -14
- package/dist/chunk-JNYPJB55.js.map +1 -0
- package/dist/{chunk-RXBLOO5B.js → chunk-NXASMBDS.js} +105 -715
- package/dist/chunk-NXASMBDS.js.map +1 -0
- package/dist/chunk-OHCNPPMX.js +334 -0
- package/dist/chunk-OHCNPPMX.js.map +1 -0
- package/dist/{chunk-DF5SSRN6.js → chunk-VYIWOXAY.js} +2574 -3381
- package/dist/chunk-VYIWOXAY.js.map +1 -0
- package/dist/chunk-WWP46AEF.js +2878 -0
- package/dist/chunk-WWP46AEF.js.map +1 -0
- package/dist/{chunk-OY7ZODZP.js → chunk-XE4OXN2W.js} +3 -9
- package/dist/chunk-XE4OXN2W.js.map +1 -0
- package/dist/{chunk-OWQSESTO.js → chunk-XU2DVWCP.js} +4 -3
- package/dist/chunk-XU2DVWCP.js.map +1 -0
- package/dist/components/index.cjs +334 -10
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +5 -3
- package/dist/components/index.d.ts +5 -3
- package/dist/components/index.js +3 -2
- package/dist/docs/api/Behaviour/classes/Behaviour.md +366 -79
- package/dist/docs/api/Behaviour/index.md +7 -3
- package/dist/docs/api/Behaviour/type-aliases/UiInteractionEvent.md +35 -0
- package/dist/docs/api/Component/classes/Component.md +14 -1
- package/dist/docs/api/components/classes/AnimationComponent.md +26 -26
- package/dist/docs/api/components/classes/AudioComponent.md +19 -19
- package/dist/docs/api/components/classes/CameraComponent.md +14 -14
- package/dist/docs/api/components/classes/EntityType.md +4 -4
- package/dist/docs/api/components/classes/Environment.md +5 -4
- package/dist/docs/api/components/classes/ImageComponent.md +7 -7
- package/dist/docs/api/components/classes/ImageTarget.md +8 -8
- package/dist/docs/api/components/classes/ImageTargetAnchor.md +4 -4
- package/dist/docs/api/components/classes/InstanceSlotComponent.md +4 -4
- package/dist/docs/api/components/classes/InstancedMeshComponent.md +10 -10
- package/dist/docs/api/components/classes/LightComponent.md +6 -6
- package/dist/docs/api/components/classes/MaterialComponent.md +16 -16
- package/dist/docs/api/components/classes/MeshComponent.md +3 -3
- package/dist/docs/api/components/classes/MeshGeometryComponent.md +9 -9
- package/dist/docs/api/components/classes/ModelComponent.md +8 -5
- package/dist/docs/api/components/classes/Name.md +3 -3
- package/dist/docs/api/components/classes/Object3DRef.md +4 -4
- package/dist/docs/api/components/classes/ParentId.md +3 -3
- package/dist/docs/api/components/classes/PhysicsComponent.md +7 -6
- package/dist/docs/api/components/classes/Postprocessing.md +3 -3
- package/dist/docs/api/components/classes/PrefabInstance.md +5 -5
- package/dist/docs/api/components/classes/PrefabNode.md +3 -3
- package/dist/docs/api/components/classes/ScriptComponent.md +5 -5
- package/dist/docs/api/components/classes/ScriptObjectComponent.md +9 -9
- package/dist/docs/api/components/classes/Selectable.md +3 -3
- package/dist/docs/api/components/classes/SelectionTransformState.md +5 -5
- package/dist/docs/api/components/classes/SpriteComponent.md +7 -7
- package/dist/docs/api/components/classes/TransformComponent.md +12 -12
- package/dist/docs/api/components/classes/UIButtonComponent.md +63 -0
- package/dist/docs/api/components/classes/UIPanelComponent.md +62 -0
- package/dist/docs/api/components/classes/UISliderComponent.md +59 -0
- package/dist/docs/api/components/classes/UITextComponent.md +59 -0
- package/dist/docs/api/components/classes/UIToggleComponent.md +56 -0
- package/dist/docs/api/components/classes/VRTeleportAreaComponent.md +53 -0
- package/dist/docs/api/components/classes/VideoComponent.md +28 -28
- package/dist/docs/api/components/classes/XRAnchorComponent.md +64 -0
- package/dist/docs/api/components/classes/XREnvironmentComponent.md +64 -0
- package/dist/docs/api/components/classes/XRHandPoseComponent.md +50 -0
- package/dist/docs/api/components/classes/XRInteractableComponent.md +74 -0
- package/dist/docs/api/components/classes/XRInteractorComponent.md +57 -0
- package/dist/docs/api/components/classes/XRInteractorSideComponent.md +50 -0
- package/dist/docs/api/components/classes/XRRigComponent.md +68 -0
- package/dist/docs/api/components/functions/createAttachPoint.md +25 -0
- package/dist/docs/api/components/functions/createHandPoseEntry.md +25 -0
- package/dist/docs/api/components/functions/defaultMaterialValue.md +1 -1
- package/dist/docs/api/components/functions/handPoseDefinitionFor.md +33 -0
- package/dist/docs/api/components/functions/normalizeEnvironmentLighting.md +30 -0
- package/dist/docs/api/components/functions/normalizePhysicsState.md +1 -1
- package/dist/docs/api/components/functions/setModelLoadState.md +33 -0
- package/dist/docs/api/components/functions/setPhysicsLiveRef.md +3 -9
- package/dist/docs/api/components/index.md +61 -4
- package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +9 -9
- package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +13 -13
- package/dist/docs/api/components/type-aliases/CameraProjection.md +1 -1
- package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +5 -3
- package/dist/docs/api/components/type-aliases/ColliderShape.md +1 -1
- package/dist/docs/api/components/type-aliases/ColliderState.md +20 -20
- package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +4 -4
- package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +8 -8
- package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentLightingState.md +40 -0
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxImageProjection.md +22 -0
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +9 -7
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentState.md +7 -5
- package/dist/docs/api/components/type-aliases/EnvironmentToneMapping.md +16 -0
- package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +3 -3
- package/dist/docs/api/components/type-aliases/ImageTargetReference.md +7 -7
- package/dist/docs/api/components/type-aliases/InstanceTransform.md +13 -13
- package/dist/docs/api/components/type-aliases/InstancedMeshKind.md +1 -1
- package/dist/docs/api/components/type-aliases/LightShadowState.md +37 -0
- package/dist/docs/api/components/type-aliases/LightValueState.md +13 -11
- package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +1 -1
- package/dist/docs/api/components/type-aliases/MaterialValueState.md +28 -28
- package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +1 -1
- package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +7 -7
- package/dist/docs/api/components/type-aliases/ModelLoadState.md +15 -0
- package/dist/docs/api/components/type-aliases/PhysicsState.md +3 -3
- package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +3 -3
- package/dist/docs/api/components/type-aliases/PostprocessingState.md +62 -62
- package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +3 -3
- package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +2 -2
- package/dist/docs/api/components/type-aliases/RigidbodyState.md +17 -17
- package/dist/docs/api/components/type-aliases/RigidbodyType.md +1 -1
- package/dist/docs/api/components/type-aliases/ScriptEntry.md +8 -8
- package/dist/docs/api/components/type-aliases/ScriptObjectComponentInput.md +1 -1
- package/dist/docs/api/components/type-aliases/ScriptObjectRuntimeState.md +1 -1
- package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +1 -1
- package/dist/docs/api/components/type-aliases/TransformData.md +4 -4
- package/dist/docs/api/components/type-aliases/TransformModeValue.md +1 -1
- package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +1 -1
- package/dist/docs/api/components/type-aliases/UIButtonOptions.md +45 -0
- package/dist/docs/api/components/type-aliases/UIPanelOptions.md +39 -0
- package/dist/docs/api/components/type-aliases/UISliderOptions.md +39 -0
- package/dist/docs/api/components/type-aliases/UITextOptions.md +41 -0
- package/dist/docs/api/components/type-aliases/UIToggleOptions.md +35 -0
- package/dist/docs/api/components/type-aliases/UiFollowMode.md +15 -0
- package/dist/docs/api/components/type-aliases/UiTextAlign.md +13 -0
- package/dist/docs/api/components/type-aliases/UiTextVAlign.md +13 -0
- package/dist/docs/api/components/type-aliases/VRTeleportAreaOptions.md +29 -0
- package/dist/docs/api/components/type-aliases/Vec3.md +4 -4
- package/dist/docs/api/components/type-aliases/VrTeleportShape.md +15 -0
- package/dist/docs/api/components/type-aliases/XRAnchorOptions.md +23 -0
- package/dist/docs/api/components/type-aliases/XRHandPoseOptions.md +23 -0
- package/dist/docs/api/components/type-aliases/XRInteractableOptions.md +75 -0
- package/dist/docs/api/components/type-aliases/XRInteractorOptions.md +37 -0
- package/dist/docs/api/components/type-aliases/XRRigOptions.md +51 -0
- package/dist/docs/api/components/type-aliases/XrAttachPoint.md +53 -0
- package/dist/docs/api/components/type-aliases/XrDistanceGrabBehavior.md +19 -0
- package/dist/docs/api/components/type-aliases/XrEnvironmentKind.md +15 -0
- package/dist/docs/api/components/type-aliases/XrEnvironmentOrientation.md +15 -0
- package/dist/docs/api/components/type-aliases/XrEnvironmentPhysics.md +25 -0
- package/dist/docs/api/components/type-aliases/XrGrabGesture.md +19 -0
- package/dist/docs/api/components/type-aliases/XrGrabHands.md +20 -0
- package/dist/docs/api/components/type-aliases/XrGrabReach.md +20 -0
- package/dist/docs/api/components/type-aliases/XrHandPoseEntry.md +49 -0
- package/dist/docs/api/components/type-aliases/XrHandPreset.md +19 -0
- package/dist/docs/api/components/type-aliases/XrInteractorSide.md +15 -0
- package/dist/docs/api/components/type-aliases/XrInteractorType.md +13 -0
- package/dist/docs/api/components/type-aliases/XrLocomotionMode.md +15 -0
- package/dist/docs/api/components/type-aliases/XrTrackingOrigin.md +24 -0
- package/dist/docs/api/components/type-aliases/XrTwoHandRotation.md +15 -0
- package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_LIGHTING.md +15 -0
- package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_INSTANCED_MESH_PARAMETERS.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_INSTANCE_TRANSFORM.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_POSE_CURLS.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_POSE_DIRECTIONS.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +1 -1
- package/dist/docs/api/components/variables/MODEL_NO_PATH_MESSAGE.md +15 -0
- package/dist/docs/api/index/classes/AnimationStateMachine.md +16 -16
- package/dist/docs/api/index/classes/AnimationStateManager.md +13 -13
- package/dist/docs/api/index/classes/AnimationSystem.md +3 -3
- package/dist/docs/api/index/classes/AudioSystem.md +4 -4
- package/dist/docs/api/index/classes/CameraSyncSystem.md +2 -2
- package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +19 -4
- package/dist/docs/api/index/classes/HandPoseTracker.md +114 -0
- package/dist/docs/api/index/classes/InputSystem.md +33 -33
- package/dist/docs/api/index/classes/InstancedMeshSystem.md +2 -2
- package/dist/docs/api/index/classes/LightSyncSystem.md +2 -2
- package/dist/docs/api/index/classes/MaterialSyncSystem.md +3 -3
- package/dist/docs/api/index/classes/MeshGeometrySystem.md +2 -2
- package/dist/docs/api/index/classes/ObjectManagementSystem.md +14 -14
- package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +2 -2
- package/dist/docs/api/index/classes/PhysicsSyncSystem.md +4 -4
- package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +34 -10
- package/dist/docs/api/index/classes/RenderSystem.md +13 -4
- package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +9 -5
- package/dist/docs/api/index/classes/ScriptObject.md +10 -10
- package/dist/docs/api/index/classes/ScriptObjectSystem.md +6 -6
- package/dist/docs/api/index/classes/TeleportAimGate.md +114 -0
- package/dist/docs/api/index/classes/ThrowVelocityTracker.md +89 -0
- package/dist/docs/api/index/classes/TransformSyncSystem.md +2 -2
- package/dist/docs/api/index/classes/UIInteractionSystem.md +60 -0
- package/dist/docs/api/index/classes/UIPanelSystem.md +79 -0
- package/dist/docs/api/index/classes/VRTeleportAreaSystem.md +49 -0
- package/dist/docs/api/index/classes/VideoSystem.md +8 -6
- package/dist/docs/api/index/classes/World.md +282 -100
- package/dist/docs/api/index/classes/XRAnchorSystem.md +90 -0
- package/dist/docs/api/index/classes/XRControllerVisualSystem.md +77 -0
- package/dist/docs/api/index/classes/XREnvironmentSystem.md +137 -0
- package/dist/docs/api/index/classes/XRHandPoseSystem.md +107 -0
- package/dist/docs/api/index/classes/XRHitTestSystem.md +93 -0
- package/dist/docs/api/index/classes/XRHoverVisualSystem.md +76 -0
- package/dist/docs/api/index/classes/XRInputSystem.md +189 -0
- package/dist/docs/api/index/classes/XRInteractionSystem.md +323 -0
- package/dist/docs/api/index/classes/XRLocomotionSystem.md +128 -0
- package/dist/docs/api/index/classes/XRSessionSystem.md +116 -0
- package/dist/docs/api/index/classes/XRTeleportVisualSystem.md +75 -0
- package/dist/docs/api/index/functions/angularVelocityFrom.md +33 -0
- package/dist/docs/api/index/functions/applyHandMaterial.md +26 -0
- package/dist/docs/api/index/functions/applyPrefabToSnapshotInstances.md +1 -1
- package/dist/docs/api/index/functions/arcGroundCrossing.md +30 -0
- package/dist/docs/api/index/functions/buildComponentValueMaps.md +1 -1
- package/dist/docs/api/index/functions/buildNodeKeyMapsFromSnapshot.md +1 -1
- package/dist/docs/api/index/functions/buildNodeMapsFromSnapshot.md +1 -1
- package/dist/docs/api/index/functions/canonicalizeComponentValue.md +1 -1
- package/dist/docs/api/index/functions/clearModelCache.md +1 -1
- package/dist/docs/api/index/functions/clearPrefabCache.md +1 -1
- package/dist/docs/api/index/functions/cloneHandPose.md +23 -0
- package/dist/docs/api/index/functions/collectDiffPaths.md +1 -1
- package/dist/docs/api/index/functions/collectDirectPrefabDependencies.md +1 -1
- package/dist/docs/api/index/functions/collectEntitySubtree.md +1 -1
- package/dist/docs/api/index/functions/collectSnapshotSubtreeIds.md +1 -1
- package/dist/docs/api/index/functions/computeFingerCurl.md +29 -0
- package/dist/docs/api/index/functions/computeHandShape.md +29 -0
- package/dist/docs/api/index/functions/computeInstanceOverrides.md +1 -1
- package/dist/docs/api/index/functions/computePalmPose.md +30 -0
- package/dist/docs/api/index/functions/computePalmWidth.md +25 -0
- package/dist/docs/api/index/functions/computePinch.md +29 -0
- package/dist/docs/api/index/functions/computeSpread.md +33 -0
- package/dist/docs/api/index/functions/createAnimationComponent.md +1 -1
- package/dist/docs/api/index/functions/createAudioComponent.md +1 -1
- package/dist/docs/api/index/functions/createCameraComponent.md +1 -1
- package/dist/docs/api/index/functions/createEntityTypeComponent.md +2 -2
- package/dist/docs/api/index/functions/createEnvironmentComponent.md +1 -1
- package/dist/docs/api/index/functions/createHandMaterial.md +30 -0
- package/dist/docs/api/index/functions/createImageComponent.md +1 -1
- package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +1 -1
- package/dist/docs/api/index/functions/createImageTargetComponent.md +2 -2
- package/dist/docs/api/index/functions/createInstanceSlotComponent.md +1 -1
- package/dist/docs/api/index/functions/createInstancedMeshComponent.md +1 -1
- package/dist/docs/api/index/functions/createLightComponent.md +2 -2
- package/dist/docs/api/index/functions/createMaterialComponent.md +2 -2
- package/dist/docs/api/index/functions/createMeshComponent.md +1 -1
- package/dist/docs/api/index/functions/createMeshGeometryComponent.md +1 -1
- package/dist/docs/api/index/functions/createModelComponent.md +1 -1
- package/dist/docs/api/index/functions/createNameComponent.md +1 -1
- package/dist/docs/api/index/functions/createObject3DRefComponent.md +1 -1
- package/dist/docs/api/index/functions/createParentIdComponent.md +1 -1
- package/dist/docs/api/index/functions/createPhysicsComponent.md +1 -1
- package/dist/docs/api/index/functions/createPostprocessingComponent.md +1 -1
- package/dist/docs/api/index/functions/createScriptComponent.md +1 -1
- package/dist/docs/api/index/functions/createScriptObjectComponent.md +1 -1
- package/dist/docs/api/index/functions/createSelectableComponent.md +1 -1
- package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +1 -1
- package/dist/docs/api/index/functions/createSpriteComponent.md +1 -1
- package/dist/docs/api/index/functions/createTransformComponent.md +1 -1
- package/dist/docs/api/index/functions/createUIButtonComponent.md +28 -0
- package/dist/docs/api/index/functions/createUIPanelComponent.md +28 -0
- package/dist/docs/api/index/functions/createUISliderComponent.md +28 -0
- package/dist/docs/api/index/functions/createUITextComponent.md +28 -0
- package/dist/docs/api/index/functions/createUIToggleComponent.md +28 -0
- package/dist/docs/api/index/functions/createVRTeleportAreaComponent.md +28 -0
- package/dist/docs/api/index/functions/createVideoComponent.md +1 -1
- package/dist/docs/api/index/functions/createXRAnchorComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRHandPoseComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRInteractableComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRInteractorComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRInteractorSideComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRRigComponent.md +28 -0
- package/dist/docs/api/index/functions/decanonicalizeComponentValue.md +1 -1
- package/dist/docs/api/index/functions/despawnPrefab.md +1 -1
- package/dist/docs/api/index/functions/encodeOverride.md +1 -1
- package/dist/docs/api/index/functions/estimateHandScale.md +28 -0
- package/dist/docs/api/index/functions/findSnapshotRootEntityIds.md +1 -1
- package/dist/docs/api/index/functions/findTopLevelNestedRegions.md +1 -1
- package/dist/docs/api/index/functions/getHandPosePreset.md +31 -0
- package/dist/docs/api/index/functions/groupOverridePaths.md +1 -1
- package/dist/docs/api/index/functions/handPoseFromCurls.md +42 -0
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +1 -1
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +1 -1
- package/dist/docs/api/index/functions/indexSnapshotByEntity.md +1 -1
- package/dist/docs/api/index/functions/instantiateSubtree.md +1 -1
- package/dist/docs/api/index/functions/loadPrefab.md +1 -1
- package/dist/docs/api/index/functions/loadSharedGltf.md +1 -1
- package/dist/docs/api/index/functions/matchHandPose.md +34 -0
- package/dist/docs/api/index/functions/mergeComponentValue.md +1 -1
- package/dist/docs/api/index/functions/parseOverride.md +1 -1
- package/dist/docs/api/index/functions/parsePrefabAsset.md +1 -1
- package/dist/docs/api/index/functions/prefabFileVersionFor.md +1 -1
- package/dist/docs/api/index/functions/readXrCapabilities.md +30 -0
- package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +1 -1
- package/dist/docs/api/index/functions/registerDefaultFactories.md +1 -1
- package/dist/docs/api/index/functions/remapSnapshotEntityIds.md +3 -3
- package/dist/docs/api/index/functions/resolveDracoDecoderPath.md +1 -1
- package/dist/docs/api/index/functions/restoreComponentState.md +1 -1
- package/dist/docs/api/index/functions/restorePostCreateComponents.md +1 -1
- package/dist/docs/api/index/functions/sampleTeleportArc.md +40 -0
- package/dist/docs/api/index/functions/serializeEntitySubtree.md +1 -1
- package/dist/docs/api/index/functions/setDracoDecoderPath.md +1 -1
- package/dist/docs/api/index/functions/setPrefabAssetUrlResolver.md +1 -1
- package/dist/docs/api/index/functions/spawnPrefab.md +1 -1
- package/dist/docs/api/index/index.md +116 -4
- package/dist/docs/api/index/interfaces/ChromaKeyOptions.md +20 -0
- package/dist/docs/api/index/interfaces/EcsSystem.md +3 -3
- package/dist/docs/api/index/interfaces/PostprocessingBuildContext.md +21 -0
- package/dist/docs/api/index/interfaces/PostprocessingPipeline.md +84 -0
- package/dist/docs/api/index/interfaces/RenderBackend.md +168 -0
- package/dist/docs/api/index/interfaces/StateMachine.md +13 -13
- package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +4 -4
- package/dist/docs/api/index/type-aliases/ApplyPrefabToSnapshotResult.md +3 -3
- package/dist/docs/api/index/type-aliases/ComponentFactory.md +1 -1
- package/dist/docs/api/index/type-aliases/ComponentValueMaps.md +50 -26
- package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +14 -2
- package/dist/docs/api/index/type-aliases/EcsRenderer.md +17 -0
- package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +3 -3
- package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +4 -4
- package/dist/docs/api/index/type-aliases/ExternalRefWarning.md +5 -5
- package/dist/docs/api/index/type-aliases/HandMaterialOptions.md +32 -0
- package/dist/docs/api/index/type-aliases/HandPoseTrackerOptions.md +27 -0
- package/dist/docs/api/index/type-aliases/HydrateOptions.md +3 -3
- package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +4 -4
- package/dist/docs/api/index/type-aliases/InstantiateSubtreeResult.md +3 -3
- package/dist/docs/api/index/type-aliases/KeyboardKey.md +1 -1
- package/dist/docs/api/index/type-aliases/ModuleLoader.md +1 -1
- package/dist/docs/api/index/type-aliases/MouseButton.md +1 -1
- package/dist/docs/api/index/type-aliases/NestedRegion.md +5 -5
- package/dist/docs/api/index/type-aliases/NodeKeyMaps.md +5 -5
- package/dist/docs/api/index/type-aliases/NodeMaps.md +4 -4
- package/dist/docs/api/index/type-aliases/PrefabAsset.md +5 -5
- package/dist/docs/api/index/type-aliases/RemapSnapshotOptions.md +2 -2
- package/dist/docs/api/index/type-aliases/RendererKind.md +15 -0
- package/dist/docs/api/index/type-aliases/ScriptBehaviourSystemOptions.md +23 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorEvent.md +39 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorListener.md +25 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorPhase.md +28 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorReport.md +31 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorSource.md +15 -0
- package/dist/docs/api/index/type-aliases/SelectionContext.md +4 -4
- package/dist/docs/api/index/type-aliases/SerializeEntitySubtreeResult.md +4 -4
- package/dist/docs/api/index/type-aliases/SpawnPrefabOptions.md +5 -5
- package/dist/docs/api/index/type-aliases/SpawnPrefabSource.md +1 -1
- package/dist/docs/api/index/type-aliases/SubtreeSnapshot.md +3 -3
- package/dist/docs/api/index/type-aliases/UiCanvasLike.md +46 -0
- package/dist/docs/api/index/type-aliases/VelocitySample.md +23 -0
- package/dist/docs/api/index/type-aliases/XrCapabilities.md +41 -0
- package/dist/docs/api/index/type-aliases/XrFinger.md +13 -0
- package/dist/docs/api/index/type-aliases/XrFingerCurl.md +27 -0
- package/dist/docs/api/index/type-aliases/XrFingerTarget.md +31 -0
- package/dist/docs/api/index/type-aliases/XrHandJointName.md +40 -0
- package/dist/docs/api/index/type-aliases/XrHandJoints.md +18 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseAxis.md +15 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseContext.md +23 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseDefinition.md +47 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseDirection.md +21 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseEvent.md +13 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseEventDetail.md +27 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseMatch.md +25 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseOrientation.md +25 -0
- package/dist/docs/api/index/type-aliases/XrHandShape.md +46 -0
- package/dist/docs/api/index/type-aliases/XrHandedness.md +15 -0
- package/dist/docs/api/index/type-aliases/XrHitResult.md +25 -0
- package/dist/docs/api/index/type-aliases/XrInputKind.md +19 -0
- package/dist/docs/api/index/type-aliases/XrInputState.md +60 -0
- package/dist/docs/api/index/type-aliases/XrPalmPose.md +31 -0
- package/dist/docs/api/index/variables/ADDED_NODE_MARKER_COMPONENT.md +2 -2
- package/dist/docs/api/index/variables/ARC_GRAVITY.md +15 -0
- package/dist/docs/api/index/variables/ARC_MAX_TIME.md +15 -0
- package/dist/docs/api/index/variables/ARC_SPEED.md +15 -0
- package/dist/docs/api/index/variables/ARC_STEPS.md +15 -0
- package/dist/docs/api/index/variables/CURLED_COS.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_DIRECTION_TOLERANCE.md +15 -0
- package/dist/docs/api/index/variables/DEFAULT_ENTER_CONFIDENCE.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_EXIT_CONFIDENCE.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_LOST_GRACE_SECONDS.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_MIN_HOLD_SECONDS.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_SCRIPT_ERROR_RETRY_DELAY.md +17 -0
- package/dist/docs/api/index/variables/FALLBACK_HAND_SCALE.md +15 -0
- package/dist/docs/api/index/variables/HAND_POSE_PRESETS.md +19 -0
- package/dist/docs/api/index/variables/HAND_POSE_PRESET_IDS.md +15 -0
- package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +1 -1
- package/dist/docs/api/index/variables/KeyboardKeys.md +89 -89
- package/dist/docs/api/index/variables/MATCH_FALLOFF.md +15 -0
- package/dist/docs/api/index/variables/MAX_PLAUSIBLE_SPEED.md +25 -0
- package/dist/docs/api/index/variables/MAX_SAMPLE_AGE_SECONDS.md +18 -0
- package/dist/docs/api/index/variables/NODE_KEY_SEPARATOR.md +1 -1
- package/dist/docs/api/index/variables/NO_XR_CAPABILITIES.md +15 -0
- package/dist/docs/api/index/variables/OVERRIDE_DIFF_EXCLUDED_COMPONENTS.md +1 -1
- package/dist/docs/api/index/variables/OVERRIDE_ROOT_EXCLUDED_COMPONENTS.md +1 -1
- package/dist/docs/api/index/variables/PINCH_FINGERS.md +15 -0
- package/dist/docs/api/index/variables/PREFAB_FILE_VERSION.md +1 -1
- package/dist/docs/api/index/variables/PREFAB_FILE_VERSION_NESTED.md +1 -1
- package/dist/docs/api/index/variables/SCRIPT_OBJECT_ROOT_FLAG.md +1 -1
- package/dist/docs/api/index/variables/SHARED_MODEL_RESOURCE_FLAG.md +1 -1
- package/dist/docs/api/index/variables/STRAIGHT_COS.md +19 -0
- package/dist/docs/api/index/variables/VELOCITY_SAMPLES.md +15 -0
- package/dist/docs/api/index/variables/XR_FINGERS.md +13 -0
- package/dist/docs/api/index/variables/XR_HOVER_SHELL_FLAG.md +15 -0
- package/dist/docs/api/index/variables/webglBackend.md +16 -0
- package/dist/docs/api/typedoc-sidebar.json +1 -1
- package/dist/docs/api/types/type-aliases/AssetInput.md +3 -3
- package/dist/docs/api/types/type-aliases/CheckboxInput.md +3 -3
- package/dist/docs/api/types/type-aliases/ColorInput.md +1 -1
- package/dist/docs/api/types/type-aliases/ComponentInput.md +4 -4
- package/dist/docs/api/types/type-aliases/ComponentKind.md +1 -1
- package/dist/docs/api/types/type-aliases/DropdownInput.md +3 -3
- package/dist/docs/api/types/type-aliases/DropdownOption.md +3 -3
- package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +1 -1
- package/dist/docs/api/types/type-aliases/EcsEntityKind.md +10 -2
- package/dist/docs/api/types/type-aliases/EntityId.md +1 -1
- package/dist/docs/api/types/type-aliases/EntityInput.md +3 -3
- package/dist/docs/api/types/type-aliases/FloatInput.md +1 -1
- package/dist/docs/api/types/type-aliases/IntersectionResult.md +3 -3
- package/dist/docs/api/types/type-aliases/ParentLookup.md +3 -3
- package/dist/docs/api/types/type-aliases/SelectionListener.md +1 -1
- package/dist/docs/api/types/type-aliases/SliderInput.md +5 -5
- package/dist/docs/api/types/type-aliases/TextInput.md +1 -1
- package/dist/docs/api/types/type-aliases/ToggleInput.md +1 -1
- package/dist/docs/api/types/type-aliases/Vec3.md +1 -1
- package/dist/docs/api/types/type-aliases/Vector2Input.md +3 -3
- package/dist/docs/api/types/type-aliases/Vector3Input.md +4 -4
- package/dist/docs/api/types/type-aliases/WorldEntityView.md +1 -1
- package/dist/docs/guide/audio-mixing-and-sound-banks.md +71 -0
- package/dist/docs/guide/authoring-a-behaviour.md +3 -3
- package/dist/docs/guide/authoring-a-script-object.md +12 -9
- package/dist/docs/guide/behaviour-data-binding/index.md +11 -11
- package/dist/docs/guide/behaviour-lifecycle.md +9 -0
- package/dist/docs/guide/bone-attachments-and-ik.md +128 -0
- package/dist/docs/guide/component-catalog.md +10 -2
- package/dist/docs/guide/components/light.md +42 -0
- package/dist/docs/guide/components/model.md +32 -3
- package/dist/docs/guide/concepts.md +2 -2
- package/dist/docs/guide/getting-started/creating-objects.md +2 -2
- package/dist/docs/guide/getting-started/editing-objects.md +2 -2
- package/dist/docs/guide/getting-started/editor/ai-agent.md +227 -0
- package/dist/docs/guide/getting-started/editor/hierarchy.md +2 -2
- package/dist/docs/guide/getting-started/editor/index.md +3 -2
- package/dist/docs/guide/getting-started/editor/inspector.md +2 -2
- package/dist/docs/guide/getting-started/editor/scene-inspector.md +3 -3
- package/dist/docs/guide/getting-started/editor/toolbar.md +11 -11
- package/dist/docs/guide/getting-started/editor/viewport.md +17 -9
- package/dist/docs/guide/getting-started/index.md +1 -1
- package/dist/docs/guide/getting-started/installation.md +1 -1
- package/dist/docs/guide/getting-started/preview-and-test.md +7 -7
- package/dist/docs/guide/getting-started/project-types/image-tracking.md +23 -11
- package/dist/docs/guide/getting-started/project-types/index.md +4 -4
- package/dist/docs/guide/getting-started/project-types/vr.md +270 -2
- package/dist/docs/guide/getting-started/projects.md +4 -5
- package/dist/docs/guide/getting-started/shortcuts.md +5 -4
- package/dist/docs/guide/multiplayer.md +92 -0
- package/dist/docs/guide/scene/environment.md +101 -4
- package/dist/docs/guide/scene/index.md +4 -4
- package/dist/docs/guide/scene/postprocessing.md +67 -5
- package/dist/docs/guide/spatial-ui.md +83 -7
- package/dist/docs/guide/spawning/area-light.md +2 -0
- package/dist/docs/guide/systems/environment-sync-system.md +11 -6
- package/dist/docs/guide/systems/light-sync-system.md +5 -3
- package/dist/docs/guide/systems/postprocessing-sync-system.md +16 -6
- package/dist/docs/guide/systems/render-system.md +7 -6
- package/dist/docs/guide/systems/script-behaviour-system.md +7 -5
- package/dist/docs/guide/systems/script-object-system.md +3 -1
- package/dist/docs/guide/systems/video-system.md +1 -1
- package/dist/docs/guide/webgpu-and-tsl.md +415 -0
- package/dist/docs/guide/world-api.md +52 -2
- package/dist/factories/index.cjs +921 -283
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +14 -3
- package/dist/factories/index.d.ts +14 -3
- package/dist/factories/index.js +7 -4
- package/dist/{index-C3ik3sA1.d.ts → index-CAZHrh0q.d.cts} +28 -3
- package/dist/{index-Dlr-7-4m.d.cts → index-CLtSMf2M.d.ts} +28 -3
- package/dist/{index-D2Jt_JzH.d.ts → index-D5MmJNyj.d.ts} +161 -43
- package/dist/{index-DaG03vyN.d.cts → index-DiIjV2lm.d.cts} +161 -43
- package/dist/index.cjs +4959 -1414
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -11
- package/dist/index.d.ts +113 -11
- package/dist/index.js +187 -12
- package/dist/index.js.map +1 -1
- package/dist/network/index.cjs +5069 -0
- package/dist/network/index.cjs.map +1 -0
- package/dist/network/index.d.cts +98 -0
- package/dist/network/index.d.ts +98 -0
- package/dist/network/index.js +493 -0
- package/dist/network/index.js.map +1 -0
- package/dist/systems/index.cjs +5319 -1957
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +4 -2
- package/dist/systems/index.d.ts +4 -2
- package/dist/systems/index.js +8 -4
- package/dist/types.d.cts +3 -1
- package/dist/types.d.ts +3 -1
- package/dist/webgpu/index.d.ts +113 -0
- package/dist/webgpu/index.js +302 -0
- package/dist/webgpu/index.js.map +1 -0
- package/dist/worldSnapshotUtils.d.cts +3 -1
- package/dist/worldSnapshotUtils.d.ts +3 -1
- package/dist/worldSnapshotUtils.js +3 -2
- package/package.json +19 -3
- package/dist/chunk-BUEKOSR5.js.map +0 -1
- package/dist/chunk-DF5SSRN6.js.map +0 -1
- package/dist/chunk-OWQSESTO.js.map +0 -1
- package/dist/chunk-OY7ZODZP.js.map +0 -1
- package/dist/chunk-RXBLOO5B.js.map +0 -1
- package/dist/chunk-WJD2VKEH.js +0 -315
- package/dist/chunk-WJD2VKEH.js.map +0 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { y as NetworkTransport, z as NetEntityView, A as NetPose, B as EcsSystem, F as NetworkService, W as World, G as EntityId, H as NetworkHandle } from '../System-8D-XBDKZ.cjs';
|
|
2
|
+
export { J as NetSpawnOptions } from '../System-8D-XBDKZ.cjs';
|
|
3
|
+
import 'three';
|
|
4
|
+
import '@dimforge/rapier3d-compat';
|
|
5
|
+
import '../animation/index.cjs';
|
|
6
|
+
import 'three/webgpu';
|
|
7
|
+
|
|
8
|
+
/** A shared world in a Colyseus room running `ReluRoom`. */
|
|
9
|
+
declare class ColyseusTransport implements NetworkTransport {
|
|
10
|
+
private readonly room;
|
|
11
|
+
private constructor();
|
|
12
|
+
static connect(options: {
|
|
13
|
+
endpoint: string;
|
|
14
|
+
room: string;
|
|
15
|
+
join?: Record<string, unknown>;
|
|
16
|
+
}): Promise<ColyseusTransport>;
|
|
17
|
+
get sessionId(): string;
|
|
18
|
+
get host(): string;
|
|
19
|
+
get players(): string[];
|
|
20
|
+
private get $();
|
|
21
|
+
onEntityAdd(cb: (entity: NetEntityView) => void): void;
|
|
22
|
+
onEntityChange(cb: (entity: NetEntityView) => void): void;
|
|
23
|
+
onEntityRemove(cb: (id: string) => void): void;
|
|
24
|
+
onPlayerJoin(cb: (id: string) => void): void;
|
|
25
|
+
onPlayerLeave(cb: (id: string) => void): void;
|
|
26
|
+
onMessage(cb: (name: string, payload: unknown, from: string) => void): void;
|
|
27
|
+
onCorrect(cb: (id: string, pose: NetPose) => void): void;
|
|
28
|
+
onClose(cb: () => void): void;
|
|
29
|
+
registerScene(entities: Parameters<NetworkTransport["registerScene"]>[0]): void;
|
|
30
|
+
spawn(request: Parameters<NetworkTransport["spawn"]>[0]): void;
|
|
31
|
+
despawn(id: string): void;
|
|
32
|
+
sendPose(id: string, pose: NetPose): void;
|
|
33
|
+
setProp(id: string, key: string, json: string): void;
|
|
34
|
+
send(name: string, payload: unknown): void;
|
|
35
|
+
leave(): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A transport with a bad connection: everything takes `ms` longer round trip.
|
|
40
|
+
* For testing a game at a real player's latency on a local server.
|
|
41
|
+
*/
|
|
42
|
+
declare function withLatency(transport: NetworkTransport, ms: number): NetworkTransport;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Keeps a world in step with a shared room: spawns what others spawned, sends
|
|
46
|
+
* what this client owns, and plays back what it doesn't. Add it to
|
|
47
|
+
* `world.setup({ systems })` after the script systems, then call `connect`
|
|
48
|
+
* once the scene is hydrated.
|
|
49
|
+
*
|
|
50
|
+
* @category Systems
|
|
51
|
+
*/
|
|
52
|
+
declare class NetworkSystem implements EcsSystem, NetworkService {
|
|
53
|
+
private readonly now;
|
|
54
|
+
private world;
|
|
55
|
+
private transport;
|
|
56
|
+
private readonly tracked;
|
|
57
|
+
private readonly byEntity;
|
|
58
|
+
private readonly listeners;
|
|
59
|
+
private readonly handles;
|
|
60
|
+
private spawnedAvatar;
|
|
61
|
+
constructor(now?: () => number);
|
|
62
|
+
/** Join the shared world. Call after hydrating, so scene objects exist. */
|
|
63
|
+
connect(world: World, transport: NetworkTransport): void;
|
|
64
|
+
/** Scene objects: every client hydrates the same scene, so their ids already match. */
|
|
65
|
+
private registerScene;
|
|
66
|
+
private spawnAvatar;
|
|
67
|
+
private track;
|
|
68
|
+
/** The buffer needs the entity's own teleport setting, known once the entity exists. */
|
|
69
|
+
private bindEntity;
|
|
70
|
+
private entityAdded;
|
|
71
|
+
private entityChanged;
|
|
72
|
+
private entityRemoved;
|
|
73
|
+
private applyProps;
|
|
74
|
+
private corrected;
|
|
75
|
+
private disconnected;
|
|
76
|
+
/** Call a Behaviour hook: on one entity's scripts, or every script. */
|
|
77
|
+
private dispatch;
|
|
78
|
+
update(world: World): void;
|
|
79
|
+
dispose(): void;
|
|
80
|
+
private spawn;
|
|
81
|
+
handleFor(entityId: EntityId): NetworkHandle;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Plays a remote entity back slightly in the past, between the two updates
|
|
86
|
+
* around that moment. Packets arrive unevenly; a small delay turns that into
|
|
87
|
+
* smooth motion.
|
|
88
|
+
*/
|
|
89
|
+
declare class SnapshotBuffer {
|
|
90
|
+
private readonly teleportDistance;
|
|
91
|
+
private snapshots;
|
|
92
|
+
constructor(teleportDistance?: number);
|
|
93
|
+
push(at: number, pose: NetPose): void;
|
|
94
|
+
/** The pose at time `at`: holds the first and last, and never extrapolates. */
|
|
95
|
+
sample(at: number): NetPose | null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { ColyseusTransport, NetEntityView, NetPose, NetworkHandle, NetworkService, NetworkSystem, NetworkTransport, SnapshotBuffer, withLatency };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { G as NetworkTransport, H as NetEntityView, J as NetPose, K as EcsSystem, L as NetworkService, W as World, M as EntityId, O as NetworkHandle } from '../System-DPMAW30g.js';
|
|
2
|
+
export { Q as NetSpawnOptions } from '../System-DPMAW30g.js';
|
|
3
|
+
import 'three';
|
|
4
|
+
import '@dimforge/rapier3d-compat';
|
|
5
|
+
import '../animation/index.js';
|
|
6
|
+
import 'three/webgpu';
|
|
7
|
+
|
|
8
|
+
/** A shared world in a Colyseus room running `ReluRoom`. */
|
|
9
|
+
declare class ColyseusTransport implements NetworkTransport {
|
|
10
|
+
private readonly room;
|
|
11
|
+
private constructor();
|
|
12
|
+
static connect(options: {
|
|
13
|
+
endpoint: string;
|
|
14
|
+
room: string;
|
|
15
|
+
join?: Record<string, unknown>;
|
|
16
|
+
}): Promise<ColyseusTransport>;
|
|
17
|
+
get sessionId(): string;
|
|
18
|
+
get host(): string;
|
|
19
|
+
get players(): string[];
|
|
20
|
+
private get $();
|
|
21
|
+
onEntityAdd(cb: (entity: NetEntityView) => void): void;
|
|
22
|
+
onEntityChange(cb: (entity: NetEntityView) => void): void;
|
|
23
|
+
onEntityRemove(cb: (id: string) => void): void;
|
|
24
|
+
onPlayerJoin(cb: (id: string) => void): void;
|
|
25
|
+
onPlayerLeave(cb: (id: string) => void): void;
|
|
26
|
+
onMessage(cb: (name: string, payload: unknown, from: string) => void): void;
|
|
27
|
+
onCorrect(cb: (id: string, pose: NetPose) => void): void;
|
|
28
|
+
onClose(cb: () => void): void;
|
|
29
|
+
registerScene(entities: Parameters<NetworkTransport["registerScene"]>[0]): void;
|
|
30
|
+
spawn(request: Parameters<NetworkTransport["spawn"]>[0]): void;
|
|
31
|
+
despawn(id: string): void;
|
|
32
|
+
sendPose(id: string, pose: NetPose): void;
|
|
33
|
+
setProp(id: string, key: string, json: string): void;
|
|
34
|
+
send(name: string, payload: unknown): void;
|
|
35
|
+
leave(): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A transport with a bad connection: everything takes `ms` longer round trip.
|
|
40
|
+
* For testing a game at a real player's latency on a local server.
|
|
41
|
+
*/
|
|
42
|
+
declare function withLatency(transport: NetworkTransport, ms: number): NetworkTransport;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Keeps a world in step with a shared room: spawns what others spawned, sends
|
|
46
|
+
* what this client owns, and plays back what it doesn't. Add it to
|
|
47
|
+
* `world.setup({ systems })` after the script systems, then call `connect`
|
|
48
|
+
* once the scene is hydrated.
|
|
49
|
+
*
|
|
50
|
+
* @category Systems
|
|
51
|
+
*/
|
|
52
|
+
declare class NetworkSystem implements EcsSystem, NetworkService {
|
|
53
|
+
private readonly now;
|
|
54
|
+
private world;
|
|
55
|
+
private transport;
|
|
56
|
+
private readonly tracked;
|
|
57
|
+
private readonly byEntity;
|
|
58
|
+
private readonly listeners;
|
|
59
|
+
private readonly handles;
|
|
60
|
+
private spawnedAvatar;
|
|
61
|
+
constructor(now?: () => number);
|
|
62
|
+
/** Join the shared world. Call after hydrating, so scene objects exist. */
|
|
63
|
+
connect(world: World, transport: NetworkTransport): void;
|
|
64
|
+
/** Scene objects: every client hydrates the same scene, so their ids already match. */
|
|
65
|
+
private registerScene;
|
|
66
|
+
private spawnAvatar;
|
|
67
|
+
private track;
|
|
68
|
+
/** The buffer needs the entity's own teleport setting, known once the entity exists. */
|
|
69
|
+
private bindEntity;
|
|
70
|
+
private entityAdded;
|
|
71
|
+
private entityChanged;
|
|
72
|
+
private entityRemoved;
|
|
73
|
+
private applyProps;
|
|
74
|
+
private corrected;
|
|
75
|
+
private disconnected;
|
|
76
|
+
/** Call a Behaviour hook: on one entity's scripts, or every script. */
|
|
77
|
+
private dispatch;
|
|
78
|
+
update(world: World): void;
|
|
79
|
+
dispose(): void;
|
|
80
|
+
private spawn;
|
|
81
|
+
handleFor(entityId: EntityId): NetworkHandle;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Plays a remote entity back slightly in the past, between the two updates
|
|
86
|
+
* around that moment. Packets arrive unevenly; a small delay turns that into
|
|
87
|
+
* smooth motion.
|
|
88
|
+
*/
|
|
89
|
+
declare class SnapshotBuffer {
|
|
90
|
+
private readonly teleportDistance;
|
|
91
|
+
private snapshots;
|
|
92
|
+
constructor(teleportDistance?: number);
|
|
93
|
+
push(at: number, pose: NetPose): void;
|
|
94
|
+
/** The pose at time `at`: holds the first and last, and never extrapolates. */
|
|
95
|
+
sample(at: number): NetPose | null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { ColyseusTransport, NetEntityView, NetPose, NetworkHandle, NetworkService, NetworkSystem, NetworkTransport, SnapshotBuffer, withLatency };
|
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import { spawnPrefab, despawnPrefab, Behaviour, reportBehaviourHookError } from '../chunk-WWP46AEF.js';
|
|
2
|
+
import '../chunk-JEPUCLZX.js';
|
|
3
|
+
import { NetworkIdentityComponent, TransformComponent, NetworkedPropsComponent, NetworkSpawnerComponent, NetworkTransformComponent, ScriptComponent } from '../chunk-JNYPJB55.js';
|
|
4
|
+
import '../chunk-CKTHDXPS.js';
|
|
5
|
+
import '../chunk-GSWC6LLD.js';
|
|
6
|
+
import { __name } from '../chunk-XE4OXN2W.js';
|
|
7
|
+
import { Client, Callbacks } from '@colyseus/sdk';
|
|
8
|
+
import * as THREE from 'three';
|
|
9
|
+
|
|
10
|
+
var view = /* @__PURE__ */ __name((e) => ({
|
|
11
|
+
id: e.id,
|
|
12
|
+
owner: e.owner,
|
|
13
|
+
prefab: e.prefab,
|
|
14
|
+
x: e.x,
|
|
15
|
+
y: e.y,
|
|
16
|
+
z: e.z,
|
|
17
|
+
qx: e.qx,
|
|
18
|
+
qy: e.qy,
|
|
19
|
+
qz: e.qz,
|
|
20
|
+
qw: e.qw,
|
|
21
|
+
props: Object.fromEntries(e.props.entries())
|
|
22
|
+
}), "view");
|
|
23
|
+
var _ColyseusTransport = class _ColyseusTransport {
|
|
24
|
+
constructor(room) {
|
|
25
|
+
this.room = room;
|
|
26
|
+
}
|
|
27
|
+
static async connect(options) {
|
|
28
|
+
const client = new Client(options.endpoint);
|
|
29
|
+
const room = await client.joinOrCreate(options.room, options.join ?? {});
|
|
30
|
+
return new _ColyseusTransport(room);
|
|
31
|
+
}
|
|
32
|
+
get sessionId() {
|
|
33
|
+
return this.room.sessionId;
|
|
34
|
+
}
|
|
35
|
+
get host() {
|
|
36
|
+
return this.room.state.host;
|
|
37
|
+
}
|
|
38
|
+
get players() {
|
|
39
|
+
return [...this.room.state.players.keys()];
|
|
40
|
+
}
|
|
41
|
+
get $() {
|
|
42
|
+
return Callbacks.get(this.room);
|
|
43
|
+
}
|
|
44
|
+
onEntityAdd(cb) {
|
|
45
|
+
this.$.onAdd("entities", (entity) => cb(view(entity)));
|
|
46
|
+
}
|
|
47
|
+
onEntityChange(cb) {
|
|
48
|
+
const $ = this.$;
|
|
49
|
+
$.onAdd("entities", (entity) => {
|
|
50
|
+
$.onChange(entity, () => cb(view(entity)));
|
|
51
|
+
$.onChange(entity, "props", () => cb(view(entity)));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
onEntityRemove(cb) {
|
|
55
|
+
this.$.onRemove("entities", (_entity, id) => cb(id));
|
|
56
|
+
}
|
|
57
|
+
onPlayerJoin(cb) {
|
|
58
|
+
this.$.onAdd("players", (_player, id) => cb(id));
|
|
59
|
+
}
|
|
60
|
+
onPlayerLeave(cb) {
|
|
61
|
+
this.$.onRemove("players", (_player, id) => cb(id));
|
|
62
|
+
}
|
|
63
|
+
onMessage(cb) {
|
|
64
|
+
this.room.onMessage(
|
|
65
|
+
"m",
|
|
66
|
+
(m) => cb(m.name, m.payload, m.from)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
onCorrect(cb) {
|
|
70
|
+
this.room.onMessage("correct", (m) => cb(m.id, m));
|
|
71
|
+
}
|
|
72
|
+
onClose(cb) {
|
|
73
|
+
this.room.onLeave(() => cb());
|
|
74
|
+
}
|
|
75
|
+
registerScene(entities) {
|
|
76
|
+
this.room.send("scene", entities);
|
|
77
|
+
}
|
|
78
|
+
spawn(request) {
|
|
79
|
+
this.room.send("spawn", request);
|
|
80
|
+
}
|
|
81
|
+
despawn(id) {
|
|
82
|
+
this.room.send("despawn", { id });
|
|
83
|
+
}
|
|
84
|
+
sendPose(id, pose) {
|
|
85
|
+
this.room.send("pose", { id, ...pose });
|
|
86
|
+
}
|
|
87
|
+
setProp(id, key, json) {
|
|
88
|
+
this.room.send("prop", { id, key, json });
|
|
89
|
+
}
|
|
90
|
+
send(name, payload) {
|
|
91
|
+
this.room.send("m", { name, payload });
|
|
92
|
+
}
|
|
93
|
+
leave() {
|
|
94
|
+
void this.room.leave();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
__name(_ColyseusTransport, "ColyseusTransport");
|
|
98
|
+
var ColyseusTransport = _ColyseusTransport;
|
|
99
|
+
|
|
100
|
+
// core/network/latency.ts
|
|
101
|
+
function withLatency(transport, ms) {
|
|
102
|
+
if (ms <= 0) return transport;
|
|
103
|
+
const oneWay = ms / 2;
|
|
104
|
+
return new Proxy(transport, {
|
|
105
|
+
get(target, key) {
|
|
106
|
+
const value = Reflect.get(target, key);
|
|
107
|
+
if (typeof value !== "function") return value;
|
|
108
|
+
const name = String(key);
|
|
109
|
+
const fn = value;
|
|
110
|
+
if (name === "leave") return fn.bind(target);
|
|
111
|
+
if (name.startsWith("on")) {
|
|
112
|
+
return (cb) => fn.call(target, (...args) => {
|
|
113
|
+
setTimeout(() => cb(...args), oneWay);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return (...args) => {
|
|
117
|
+
setTimeout(() => fn.apply(target, args), oneWay);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
__name(withLatency, "withLatency");
|
|
123
|
+
|
|
124
|
+
// core/network/snapshotBuffer.ts
|
|
125
|
+
var MAX_SNAPSHOTS = 32;
|
|
126
|
+
function lerpPose(a, b, t) {
|
|
127
|
+
const dot = a.qx * b.qx + a.qy * b.qy + a.qz * b.qz + a.qw * b.qw;
|
|
128
|
+
const s = dot < 0 ? -1 : 1;
|
|
129
|
+
const qx = a.qx + (s * b.qx - a.qx) * t;
|
|
130
|
+
const qy = a.qy + (s * b.qy - a.qy) * t;
|
|
131
|
+
const qz = a.qz + (s * b.qz - a.qz) * t;
|
|
132
|
+
const qw = a.qw + (s * b.qw - a.qw) * t;
|
|
133
|
+
const len = Math.hypot(qx, qy, qz, qw) || 1;
|
|
134
|
+
return {
|
|
135
|
+
x: a.x + (b.x - a.x) * t,
|
|
136
|
+
y: a.y + (b.y - a.y) * t,
|
|
137
|
+
z: a.z + (b.z - a.z) * t,
|
|
138
|
+
qx: qx / len,
|
|
139
|
+
qy: qy / len,
|
|
140
|
+
qz: qz / len,
|
|
141
|
+
qw: qw / len
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
__name(lerpPose, "lerpPose");
|
|
145
|
+
var _SnapshotBuffer = class _SnapshotBuffer {
|
|
146
|
+
constructor(teleportDistance = Number.POSITIVE_INFINITY) {
|
|
147
|
+
this.teleportDistance = teleportDistance;
|
|
148
|
+
this.snapshots = [];
|
|
149
|
+
}
|
|
150
|
+
push(at, pose) {
|
|
151
|
+
this.snapshots.push({ at, pose });
|
|
152
|
+
if (this.snapshots.length > MAX_SNAPSHOTS) this.snapshots.shift();
|
|
153
|
+
}
|
|
154
|
+
/** The pose at time `at`: holds the first and last, and never extrapolates. */
|
|
155
|
+
sample(at) {
|
|
156
|
+
const list = this.snapshots;
|
|
157
|
+
if (list.length === 0) return null;
|
|
158
|
+
if (at <= list[0].at) return list[0].pose;
|
|
159
|
+
for (let i = list.length - 1; i > 0; i--) {
|
|
160
|
+
const a = list[i - 1];
|
|
161
|
+
const b = list[i];
|
|
162
|
+
if (at < a.at) continue;
|
|
163
|
+
if (i > 1) this.snapshots = list.slice(i - 1);
|
|
164
|
+
if (at >= b.at) return b.pose;
|
|
165
|
+
const jump = Math.hypot(b.pose.x - a.pose.x, b.pose.y - a.pose.y, b.pose.z - a.pose.z);
|
|
166
|
+
if (jump > this.teleportDistance) return b.pose;
|
|
167
|
+
return lerpPose(a.pose, b.pose, (at - a.at) / (b.at - a.at));
|
|
168
|
+
}
|
|
169
|
+
return list[list.length - 1].pose;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
__name(_SnapshotBuffer, "SnapshotBuffer");
|
|
173
|
+
var SnapshotBuffer = _SnapshotBuffer;
|
|
174
|
+
|
|
175
|
+
// core/network/NetworkSystem.ts
|
|
176
|
+
var POSITION_EPSILON = 1e-3;
|
|
177
|
+
var ROTATION_EPSILON = 5e-4;
|
|
178
|
+
var euler = new THREE.Euler();
|
|
179
|
+
var quat = new THREE.Quaternion();
|
|
180
|
+
function poseOf(transform) {
|
|
181
|
+
const { position: p, rotation: r } = transform;
|
|
182
|
+
quat.setFromEuler(euler.set(r.x, r.y, r.z));
|
|
183
|
+
return { x: p.x, y: p.y, z: p.z, qx: quat.x, qy: quat.y, qz: quat.z, qw: quat.w };
|
|
184
|
+
}
|
|
185
|
+
__name(poseOf, "poseOf");
|
|
186
|
+
function applyPose(transform, pose, rotation) {
|
|
187
|
+
transform.position.x = pose.x;
|
|
188
|
+
transform.position.y = pose.y;
|
|
189
|
+
transform.position.z = pose.z;
|
|
190
|
+
if (!rotation) return;
|
|
191
|
+
euler.setFromQuaternion(quat.set(pose.qx, pose.qy, pose.qz, pose.qw));
|
|
192
|
+
transform.rotation.x = euler.x;
|
|
193
|
+
transform.rotation.y = euler.y;
|
|
194
|
+
transform.rotation.z = euler.z;
|
|
195
|
+
}
|
|
196
|
+
__name(applyPose, "applyPose");
|
|
197
|
+
var moved = /* @__PURE__ */ __name((a, b) => Math.abs(a.x - b.x) > POSITION_EPSILON || Math.abs(a.y - b.y) > POSITION_EPSILON || Math.abs(a.z - b.z) > POSITION_EPSILON || Math.abs(a.qx - b.qx) > ROTATION_EPSILON || Math.abs(a.qy - b.qy) > ROTATION_EPSILON || Math.abs(a.qz - b.qz) > ROTATION_EPSILON || Math.abs(a.qw - b.qw) > ROTATION_EPSILON, "moved");
|
|
198
|
+
function encodeProps(props) {
|
|
199
|
+
return Object.fromEntries(
|
|
200
|
+
Object.entries(props ?? {}).map(([k, v]) => [k, JSON.stringify(v)])
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
__name(encodeProps, "encodeProps");
|
|
204
|
+
var _NetworkSystem = class _NetworkSystem {
|
|
205
|
+
constructor(now = () => performance.now()) {
|
|
206
|
+
this.now = now;
|
|
207
|
+
this.world = null;
|
|
208
|
+
this.transport = null;
|
|
209
|
+
this.tracked = /* @__PURE__ */ new Map();
|
|
210
|
+
this.byEntity = /* @__PURE__ */ new Map();
|
|
211
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
212
|
+
this.handles = /* @__PURE__ */ new Map();
|
|
213
|
+
this.spawnedAvatar = false;
|
|
214
|
+
}
|
|
215
|
+
/** Join the shared world. Call after hydrating, so scene objects exist. */
|
|
216
|
+
connect(world, transport) {
|
|
217
|
+
this.world = world;
|
|
218
|
+
this.transport = transport;
|
|
219
|
+
world.setNetwork(this);
|
|
220
|
+
transport.onEntityAdd((e) => this.entityAdded(e));
|
|
221
|
+
transport.onEntityChange((e) => this.entityChanged(e));
|
|
222
|
+
transport.onEntityRemove((id) => this.entityRemoved(id));
|
|
223
|
+
transport.onPlayerJoin((id) => this.dispatch("onPlayerJoin", id));
|
|
224
|
+
transport.onPlayerLeave((id) => this.dispatch("onPlayerLeave", id));
|
|
225
|
+
transport.onMessage((name, payload, from) => {
|
|
226
|
+
for (const fn of this.listeners.get(name) ?? []) fn(payload, from);
|
|
227
|
+
});
|
|
228
|
+
transport.onCorrect((id, pose) => this.corrected(id, pose));
|
|
229
|
+
transport.onClose(() => this.disconnected());
|
|
230
|
+
this.registerScene();
|
|
231
|
+
this.spawnAvatar();
|
|
232
|
+
}
|
|
233
|
+
/** Scene objects: every client hydrates the same scene, so their ids already match. */
|
|
234
|
+
registerScene() {
|
|
235
|
+
const world = this.world;
|
|
236
|
+
const transport = this.transport;
|
|
237
|
+
if (!world || !transport) return;
|
|
238
|
+
const entities = [];
|
|
239
|
+
for (const entityId of world.query(NetworkIdentityComponent)) {
|
|
240
|
+
const identity = world.getComponent(entityId, NetworkIdentityComponent);
|
|
241
|
+
if (!identity || identity.networkId) continue;
|
|
242
|
+
identity.networkId = `scene-${entityId}`;
|
|
243
|
+
const transform = world.getComponent(entityId, TransformComponent);
|
|
244
|
+
const props = world.getComponent(entityId, NetworkedPropsComponent);
|
|
245
|
+
const tracked = this.track(identity.networkId, entityId, "", null);
|
|
246
|
+
tracked.props = encodeProps(props?.values);
|
|
247
|
+
entities.push({
|
|
248
|
+
id: identity.networkId,
|
|
249
|
+
props: tracked.props,
|
|
250
|
+
...transform ? poseOf(transform) : { x: 0, y: 0, z: 0, qx: 0, qy: 0, qz: 0, qw: 1 }
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
if (entities.length) transport.registerScene(entities);
|
|
254
|
+
}
|
|
255
|
+
spawnAvatar() {
|
|
256
|
+
const world = this.world;
|
|
257
|
+
if (!world || this.spawnedAvatar) return;
|
|
258
|
+
const [entityId] = world.query(NetworkSpawnerComponent);
|
|
259
|
+
if (entityId === void 0) return;
|
|
260
|
+
const spawner = world.getComponent(entityId, NetworkSpawnerComponent);
|
|
261
|
+
if (!spawner?.playerPrefab) return;
|
|
262
|
+
this.spawnedAvatar = true;
|
|
263
|
+
const at = world.getComponent(entityId, TransformComponent)?.position;
|
|
264
|
+
const angle = Math.random() * Math.PI * 2;
|
|
265
|
+
this.spawn(spawner.playerPrefab, {
|
|
266
|
+
position: {
|
|
267
|
+
x: (at?.x ?? 0) + Math.cos(angle) * spawner.spawnRadius,
|
|
268
|
+
y: at?.y ?? 0,
|
|
269
|
+
z: (at?.z ?? 0) + Math.sin(angle) * spawner.spawnRadius
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
track(id, entityId, owner, view2) {
|
|
274
|
+
const entry = {
|
|
275
|
+
id,
|
|
276
|
+
entityId,
|
|
277
|
+
owner,
|
|
278
|
+
buffer: new SnapshotBuffer(),
|
|
279
|
+
sentAt: 0,
|
|
280
|
+
sent: null,
|
|
281
|
+
props: {}
|
|
282
|
+
};
|
|
283
|
+
if (view2) entry.buffer.push(this.now(), view2);
|
|
284
|
+
this.tracked.set(id, entry);
|
|
285
|
+
if (entityId !== null) this.byEntity.set(entityId, entry);
|
|
286
|
+
return entry;
|
|
287
|
+
}
|
|
288
|
+
/** The buffer needs the entity's own teleport setting, known once the entity exists. */
|
|
289
|
+
bindEntity(entry, entityId) {
|
|
290
|
+
const world = this.world;
|
|
291
|
+
if (!world) return;
|
|
292
|
+
entry.entityId = entityId;
|
|
293
|
+
this.byEntity.set(entityId, entry);
|
|
294
|
+
let identity = world.getComponent(entityId, NetworkIdentityComponent);
|
|
295
|
+
if (!identity) {
|
|
296
|
+
identity = new NetworkIdentityComponent();
|
|
297
|
+
world.addComponent(entityId, identity);
|
|
298
|
+
}
|
|
299
|
+
identity.networkId = entry.id;
|
|
300
|
+
identity.owner = entry.owner;
|
|
301
|
+
const settings = world.getComponent(entityId, NetworkTransformComponent);
|
|
302
|
+
entry.buffer = new SnapshotBuffer(settings?.teleportDistance);
|
|
303
|
+
}
|
|
304
|
+
entityAdded(view2) {
|
|
305
|
+
const existing = this.tracked.get(view2.id);
|
|
306
|
+
if (existing) {
|
|
307
|
+
this.entityChanged(view2);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const entry = this.track(view2.id, null, view2.owner, view2);
|
|
311
|
+
if (!view2.prefab || !this.world) return;
|
|
312
|
+
euler.setFromQuaternion(quat.set(view2.qx, view2.qy, view2.qz, view2.qw));
|
|
313
|
+
void spawnPrefab(this.world, view2.prefab, {
|
|
314
|
+
position: { x: view2.x, y: view2.y, z: view2.z },
|
|
315
|
+
rotation: { x: euler.x, y: euler.y, z: euler.z }
|
|
316
|
+
}).then((entityId) => {
|
|
317
|
+
if (this.tracked.get(view2.id) !== entry) {
|
|
318
|
+
if (this.world) despawnPrefab(this.world, entityId);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
this.bindEntity(entry, entityId);
|
|
322
|
+
entry.buffer.push(this.now(), view2);
|
|
323
|
+
this.applyProps(entry, view2.props);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
entityChanged(view2) {
|
|
327
|
+
const entry = this.tracked.get(view2.id);
|
|
328
|
+
if (!entry) return;
|
|
329
|
+
entry.owner = view2.owner;
|
|
330
|
+
if (entry.entityId !== null && this.world) {
|
|
331
|
+
const identity = this.world.getComponent(entry.entityId, NetworkIdentityComponent);
|
|
332
|
+
if (identity) identity.owner = view2.owner;
|
|
333
|
+
}
|
|
334
|
+
if (view2.owner !== this.transport?.sessionId) entry.buffer.push(this.now(), view2);
|
|
335
|
+
this.applyProps(entry, view2.props);
|
|
336
|
+
}
|
|
337
|
+
entityRemoved(id) {
|
|
338
|
+
const entry = this.tracked.get(id);
|
|
339
|
+
if (!entry) return;
|
|
340
|
+
this.tracked.delete(id);
|
|
341
|
+
if (entry.entityId === null) return;
|
|
342
|
+
this.byEntity.delete(entry.entityId);
|
|
343
|
+
if (this.world) despawnPrefab(this.world, entry.entityId);
|
|
344
|
+
}
|
|
345
|
+
applyProps(entry, props) {
|
|
346
|
+
if (entry.entityId === null || !this.world) return;
|
|
347
|
+
for (const [key, json] of Object.entries(props)) {
|
|
348
|
+
if (entry.props[key] === json) continue;
|
|
349
|
+
entry.props[key] = json;
|
|
350
|
+
const value = JSON.parse(json);
|
|
351
|
+
let component = this.world.getComponent(entry.entityId, NetworkedPropsComponent);
|
|
352
|
+
if (!component) {
|
|
353
|
+
component = new NetworkedPropsComponent();
|
|
354
|
+
this.world.addComponent(entry.entityId, component);
|
|
355
|
+
}
|
|
356
|
+
component.values[key] = value;
|
|
357
|
+
this.dispatch("onNetworkProp", key, value, entry.entityId);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
corrected(id, pose) {
|
|
361
|
+
const entry = this.tracked.get(id);
|
|
362
|
+
if (entry?.entityId == null || !this.world) return;
|
|
363
|
+
const transform = this.world.getComponent(entry.entityId, TransformComponent);
|
|
364
|
+
if (transform) applyPose(transform, pose, true);
|
|
365
|
+
entry.sent = pose;
|
|
366
|
+
}
|
|
367
|
+
disconnected() {
|
|
368
|
+
this.transport = null;
|
|
369
|
+
this.world?.setNetwork(null);
|
|
370
|
+
}
|
|
371
|
+
dispatch(hook, a, b, on) {
|
|
372
|
+
const world = this.world;
|
|
373
|
+
if (!world) return;
|
|
374
|
+
const ids = on !== void 0 ? [on] : world.query(ScriptComponent);
|
|
375
|
+
for (const entityId of ids) {
|
|
376
|
+
const instances = world.getComponent(entityId, ScriptComponent)?.scriptInstances;
|
|
377
|
+
for (const instance of instances?.values() ?? []) {
|
|
378
|
+
if (!(instance instanceof Behaviour)) continue;
|
|
379
|
+
try {
|
|
380
|
+
instance[hook]?.(a, b);
|
|
381
|
+
} catch (error) {
|
|
382
|
+
reportBehaviourHookError(world, entityId, instance, hook, error);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
update(world) {
|
|
388
|
+
const transport = this.transport;
|
|
389
|
+
if (!transport) return;
|
|
390
|
+
const now = this.now();
|
|
391
|
+
for (const entry of this.tracked.values()) {
|
|
392
|
+
if (entry.entityId === null) continue;
|
|
393
|
+
const settings = world.getComponent(entry.entityId, NetworkTransformComponent);
|
|
394
|
+
if (!settings?.enabled) continue;
|
|
395
|
+
const transform = world.getComponent(entry.entityId, TransformComponent);
|
|
396
|
+
if (!transform) continue;
|
|
397
|
+
if (entry.owner === transport.sessionId) {
|
|
398
|
+
if (now - entry.sentAt < 1e3 / settings.sendRate) continue;
|
|
399
|
+
const pose = poseOf(transform);
|
|
400
|
+
if (entry.sent && !moved(entry.sent, pose)) continue;
|
|
401
|
+
entry.sentAt = now;
|
|
402
|
+
entry.sent = pose;
|
|
403
|
+
transport.sendPose(entry.id, pose);
|
|
404
|
+
} else {
|
|
405
|
+
const pose = entry.buffer.sample(now - settings.interpolationMs);
|
|
406
|
+
if (pose) applyPose(transform, pose, settings.syncRotation);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
dispose() {
|
|
411
|
+
this.transport?.leave();
|
|
412
|
+
this.transport = null;
|
|
413
|
+
this.world?.setNetwork(null);
|
|
414
|
+
this.tracked.clear();
|
|
415
|
+
this.byEntity.clear();
|
|
416
|
+
this.handles.clear();
|
|
417
|
+
this.listeners.clear();
|
|
418
|
+
}
|
|
419
|
+
spawn(prefab, options = {}) {
|
|
420
|
+
const p = options.position;
|
|
421
|
+
const r = options.rotation;
|
|
422
|
+
quat.setFromEuler(euler.set(r?.x ?? 0, r?.y ?? 0, r?.z ?? 0));
|
|
423
|
+
this.transport?.spawn({
|
|
424
|
+
prefab: typeof prefab === "string" ? prefab : prefab.path,
|
|
425
|
+
props: encodeProps(options.props),
|
|
426
|
+
x: p?.x ?? 0,
|
|
427
|
+
y: p?.y ?? 0,
|
|
428
|
+
z: p?.z ?? 0,
|
|
429
|
+
qx: quat.x,
|
|
430
|
+
qy: quat.y,
|
|
431
|
+
qz: quat.z,
|
|
432
|
+
qw: quat.w
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
handleFor(entityId) {
|
|
436
|
+
const known = this.handles.get(entityId);
|
|
437
|
+
if (known) return known;
|
|
438
|
+
const self = this;
|
|
439
|
+
const entry = /* @__PURE__ */ __name(() => self.byEntity.get(entityId), "entry");
|
|
440
|
+
const handle = {
|
|
441
|
+
get connected() {
|
|
442
|
+
return self.transport !== null;
|
|
443
|
+
},
|
|
444
|
+
get sessionId() {
|
|
445
|
+
return self.transport?.sessionId ?? "";
|
|
446
|
+
},
|
|
447
|
+
get isHost() {
|
|
448
|
+
const t = self.transport;
|
|
449
|
+
return Boolean(t) && t?.host === t?.sessionId;
|
|
450
|
+
},
|
|
451
|
+
get isOwner() {
|
|
452
|
+
return entry()?.owner === self.transport?.sessionId;
|
|
453
|
+
},
|
|
454
|
+
get players() {
|
|
455
|
+
return self.transport?.players ?? [];
|
|
456
|
+
},
|
|
457
|
+
send: /* @__PURE__ */ __name((name, payload) => self.transport?.send(name, payload ?? null), "send"),
|
|
458
|
+
onMessage: /* @__PURE__ */ __name((name, fn) => {
|
|
459
|
+
const set = self.listeners.get(name) ?? /* @__PURE__ */ new Set();
|
|
460
|
+
self.listeners.set(name, set);
|
|
461
|
+
set.add(fn);
|
|
462
|
+
return () => set.delete(fn);
|
|
463
|
+
}, "onMessage"),
|
|
464
|
+
spawn: /* @__PURE__ */ __name((prefab, options) => self.spawn(prefab, options), "spawn"),
|
|
465
|
+
despawn: /* @__PURE__ */ __name((id = entityId) => {
|
|
466
|
+
const target = self.byEntity.get(id);
|
|
467
|
+
if (target) self.transport?.despawn(target.id);
|
|
468
|
+
}, "despawn"),
|
|
469
|
+
setProp: /* @__PURE__ */ __name((key, value) => {
|
|
470
|
+
const target = entry();
|
|
471
|
+
if (!target || target.entityId === null || !self.world) return;
|
|
472
|
+
const json = JSON.stringify(value);
|
|
473
|
+
target.props[key] = json;
|
|
474
|
+
let component = self.world.getComponent(target.entityId, NetworkedPropsComponent);
|
|
475
|
+
if (!component) {
|
|
476
|
+
component = new NetworkedPropsComponent();
|
|
477
|
+
self.world.addComponent(target.entityId, component);
|
|
478
|
+
}
|
|
479
|
+
component.values[key] = value;
|
|
480
|
+
self.transport?.setProp(target.id, key, json);
|
|
481
|
+
}, "setProp"),
|
|
482
|
+
getProp: /* @__PURE__ */ __name((key) => self.world?.getComponent(entityId, NetworkedPropsComponent)?.values[key], "getProp")
|
|
483
|
+
};
|
|
484
|
+
this.handles.set(entityId, handle);
|
|
485
|
+
return handle;
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
__name(_NetworkSystem, "NetworkSystem");
|
|
489
|
+
var NetworkSystem = _NetworkSystem;
|
|
490
|
+
|
|
491
|
+
export { ColyseusTransport, NetworkSystem, SnapshotBuffer, withLatency };
|
|
492
|
+
//# sourceMappingURL=index.js.map
|
|
493
|
+
//# sourceMappingURL=index.js.map
|