@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.
Files changed (512) hide show
  1. package/dist/{System-V_mv07le.d.cts → System-8D-XBDKZ.d.cts} +734 -8
  2. package/dist/{System-V_mv07le.d.ts → System-DPMAW30g.d.ts} +734 -8
  3. package/dist/{XRHandPose-CU3vNFuS.d.ts → XRHandPose-CWSrsnYN.d.ts} +236 -3
  4. package/dist/{XRHandPose-CQTLGxFC.d.cts → XRHandPose-Dn2yiALk.d.cts} +236 -3
  5. package/dist/animation/index.cjs +252 -0
  6. package/dist/animation/index.cjs.map +1 -0
  7. package/dist/animation/index.d.cts +100 -0
  8. package/dist/animation/index.d.ts +100 -0
  9. package/dist/animation/index.js +4 -0
  10. package/dist/animation/index.js.map +1 -0
  11. package/dist/chunk-CKTHDXPS.js +11 -0
  12. package/dist/chunk-CKTHDXPS.js.map +1 -0
  13. package/dist/chunk-GSWC6LLD.js +241 -0
  14. package/dist/chunk-GSWC6LLD.js.map +1 -0
  15. package/dist/chunk-JEPUCLZX.js +1237 -0
  16. package/dist/chunk-JEPUCLZX.js.map +1 -0
  17. package/dist/{chunk-BUEKOSR5.js → chunk-JNYPJB55.js} +435 -14
  18. package/dist/chunk-JNYPJB55.js.map +1 -0
  19. package/dist/{chunk-RXBLOO5B.js → chunk-NXASMBDS.js} +105 -715
  20. package/dist/chunk-NXASMBDS.js.map +1 -0
  21. package/dist/chunk-OHCNPPMX.js +334 -0
  22. package/dist/chunk-OHCNPPMX.js.map +1 -0
  23. package/dist/{chunk-DF5SSRN6.js → chunk-VYIWOXAY.js} +2574 -3381
  24. package/dist/chunk-VYIWOXAY.js.map +1 -0
  25. package/dist/chunk-WWP46AEF.js +2878 -0
  26. package/dist/chunk-WWP46AEF.js.map +1 -0
  27. package/dist/{chunk-OY7ZODZP.js → chunk-XE4OXN2W.js} +3 -9
  28. package/dist/chunk-XE4OXN2W.js.map +1 -0
  29. package/dist/{chunk-OWQSESTO.js → chunk-XU2DVWCP.js} +4 -3
  30. package/dist/chunk-XU2DVWCP.js.map +1 -0
  31. package/dist/components/index.cjs +334 -10
  32. package/dist/components/index.cjs.map +1 -1
  33. package/dist/components/index.d.cts +5 -3
  34. package/dist/components/index.d.ts +5 -3
  35. package/dist/components/index.js +3 -2
  36. package/dist/docs/api/Behaviour/classes/Behaviour.md +366 -79
  37. package/dist/docs/api/Behaviour/index.md +7 -3
  38. package/dist/docs/api/Behaviour/type-aliases/UiInteractionEvent.md +35 -0
  39. package/dist/docs/api/Component/classes/Component.md +14 -1
  40. package/dist/docs/api/components/classes/AnimationComponent.md +26 -26
  41. package/dist/docs/api/components/classes/AudioComponent.md +19 -19
  42. package/dist/docs/api/components/classes/CameraComponent.md +14 -14
  43. package/dist/docs/api/components/classes/EntityType.md +4 -4
  44. package/dist/docs/api/components/classes/Environment.md +5 -4
  45. package/dist/docs/api/components/classes/ImageComponent.md +7 -7
  46. package/dist/docs/api/components/classes/ImageTarget.md +8 -8
  47. package/dist/docs/api/components/classes/ImageTargetAnchor.md +4 -4
  48. package/dist/docs/api/components/classes/InstanceSlotComponent.md +4 -4
  49. package/dist/docs/api/components/classes/InstancedMeshComponent.md +10 -10
  50. package/dist/docs/api/components/classes/LightComponent.md +6 -6
  51. package/dist/docs/api/components/classes/MaterialComponent.md +16 -16
  52. package/dist/docs/api/components/classes/MeshComponent.md +3 -3
  53. package/dist/docs/api/components/classes/MeshGeometryComponent.md +9 -9
  54. package/dist/docs/api/components/classes/ModelComponent.md +8 -5
  55. package/dist/docs/api/components/classes/Name.md +3 -3
  56. package/dist/docs/api/components/classes/Object3DRef.md +4 -4
  57. package/dist/docs/api/components/classes/ParentId.md +3 -3
  58. package/dist/docs/api/components/classes/PhysicsComponent.md +7 -6
  59. package/dist/docs/api/components/classes/Postprocessing.md +3 -3
  60. package/dist/docs/api/components/classes/PrefabInstance.md +5 -5
  61. package/dist/docs/api/components/classes/PrefabNode.md +3 -3
  62. package/dist/docs/api/components/classes/ScriptComponent.md +5 -5
  63. package/dist/docs/api/components/classes/ScriptObjectComponent.md +9 -9
  64. package/dist/docs/api/components/classes/Selectable.md +3 -3
  65. package/dist/docs/api/components/classes/SelectionTransformState.md +5 -5
  66. package/dist/docs/api/components/classes/SpriteComponent.md +7 -7
  67. package/dist/docs/api/components/classes/TransformComponent.md +12 -12
  68. package/dist/docs/api/components/classes/UIButtonComponent.md +63 -0
  69. package/dist/docs/api/components/classes/UIPanelComponent.md +62 -0
  70. package/dist/docs/api/components/classes/UISliderComponent.md +59 -0
  71. package/dist/docs/api/components/classes/UITextComponent.md +59 -0
  72. package/dist/docs/api/components/classes/UIToggleComponent.md +56 -0
  73. package/dist/docs/api/components/classes/VRTeleportAreaComponent.md +53 -0
  74. package/dist/docs/api/components/classes/VideoComponent.md +28 -28
  75. package/dist/docs/api/components/classes/XRAnchorComponent.md +64 -0
  76. package/dist/docs/api/components/classes/XREnvironmentComponent.md +64 -0
  77. package/dist/docs/api/components/classes/XRHandPoseComponent.md +50 -0
  78. package/dist/docs/api/components/classes/XRInteractableComponent.md +74 -0
  79. package/dist/docs/api/components/classes/XRInteractorComponent.md +57 -0
  80. package/dist/docs/api/components/classes/XRInteractorSideComponent.md +50 -0
  81. package/dist/docs/api/components/classes/XRRigComponent.md +68 -0
  82. package/dist/docs/api/components/functions/createAttachPoint.md +25 -0
  83. package/dist/docs/api/components/functions/createHandPoseEntry.md +25 -0
  84. package/dist/docs/api/components/functions/defaultMaterialValue.md +1 -1
  85. package/dist/docs/api/components/functions/handPoseDefinitionFor.md +33 -0
  86. package/dist/docs/api/components/functions/normalizeEnvironmentLighting.md +30 -0
  87. package/dist/docs/api/components/functions/normalizePhysicsState.md +1 -1
  88. package/dist/docs/api/components/functions/setModelLoadState.md +33 -0
  89. package/dist/docs/api/components/functions/setPhysicsLiveRef.md +3 -9
  90. package/dist/docs/api/components/index.md +61 -4
  91. package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +9 -9
  92. package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +13 -13
  93. package/dist/docs/api/components/type-aliases/CameraProjection.md +1 -1
  94. package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +5 -3
  95. package/dist/docs/api/components/type-aliases/ColliderShape.md +1 -1
  96. package/dist/docs/api/components/type-aliases/ColliderState.md +20 -20
  97. package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +4 -4
  98. package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +1 -1
  99. package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +8 -8
  100. package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +1 -1
  101. package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +1 -1
  102. package/dist/docs/api/components/type-aliases/EnvironmentLightingState.md +40 -0
  103. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxImageProjection.md +22 -0
  104. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +9 -7
  105. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +1 -1
  106. package/dist/docs/api/components/type-aliases/EnvironmentState.md +7 -5
  107. package/dist/docs/api/components/type-aliases/EnvironmentToneMapping.md +16 -0
  108. package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +3 -3
  109. package/dist/docs/api/components/type-aliases/ImageTargetReference.md +7 -7
  110. package/dist/docs/api/components/type-aliases/InstanceTransform.md +13 -13
  111. package/dist/docs/api/components/type-aliases/InstancedMeshKind.md +1 -1
  112. package/dist/docs/api/components/type-aliases/LightShadowState.md +37 -0
  113. package/dist/docs/api/components/type-aliases/LightValueState.md +13 -11
  114. package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +1 -1
  115. package/dist/docs/api/components/type-aliases/MaterialValueState.md +28 -28
  116. package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +1 -1
  117. package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +7 -7
  118. package/dist/docs/api/components/type-aliases/ModelLoadState.md +15 -0
  119. package/dist/docs/api/components/type-aliases/PhysicsState.md +3 -3
  120. package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +3 -3
  121. package/dist/docs/api/components/type-aliases/PostprocessingState.md +62 -62
  122. package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +3 -3
  123. package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +2 -2
  124. package/dist/docs/api/components/type-aliases/RigidbodyState.md +17 -17
  125. package/dist/docs/api/components/type-aliases/RigidbodyType.md +1 -1
  126. package/dist/docs/api/components/type-aliases/ScriptEntry.md +8 -8
  127. package/dist/docs/api/components/type-aliases/ScriptObjectComponentInput.md +1 -1
  128. package/dist/docs/api/components/type-aliases/ScriptObjectRuntimeState.md +1 -1
  129. package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +1 -1
  130. package/dist/docs/api/components/type-aliases/TransformData.md +4 -4
  131. package/dist/docs/api/components/type-aliases/TransformModeValue.md +1 -1
  132. package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +1 -1
  133. package/dist/docs/api/components/type-aliases/UIButtonOptions.md +45 -0
  134. package/dist/docs/api/components/type-aliases/UIPanelOptions.md +39 -0
  135. package/dist/docs/api/components/type-aliases/UISliderOptions.md +39 -0
  136. package/dist/docs/api/components/type-aliases/UITextOptions.md +41 -0
  137. package/dist/docs/api/components/type-aliases/UIToggleOptions.md +35 -0
  138. package/dist/docs/api/components/type-aliases/UiFollowMode.md +15 -0
  139. package/dist/docs/api/components/type-aliases/UiTextAlign.md +13 -0
  140. package/dist/docs/api/components/type-aliases/UiTextVAlign.md +13 -0
  141. package/dist/docs/api/components/type-aliases/VRTeleportAreaOptions.md +29 -0
  142. package/dist/docs/api/components/type-aliases/Vec3.md +4 -4
  143. package/dist/docs/api/components/type-aliases/VrTeleportShape.md +15 -0
  144. package/dist/docs/api/components/type-aliases/XRAnchorOptions.md +23 -0
  145. package/dist/docs/api/components/type-aliases/XRHandPoseOptions.md +23 -0
  146. package/dist/docs/api/components/type-aliases/XRInteractableOptions.md +75 -0
  147. package/dist/docs/api/components/type-aliases/XRInteractorOptions.md +37 -0
  148. package/dist/docs/api/components/type-aliases/XRRigOptions.md +51 -0
  149. package/dist/docs/api/components/type-aliases/XrAttachPoint.md +53 -0
  150. package/dist/docs/api/components/type-aliases/XrDistanceGrabBehavior.md +19 -0
  151. package/dist/docs/api/components/type-aliases/XrEnvironmentKind.md +15 -0
  152. package/dist/docs/api/components/type-aliases/XrEnvironmentOrientation.md +15 -0
  153. package/dist/docs/api/components/type-aliases/XrEnvironmentPhysics.md +25 -0
  154. package/dist/docs/api/components/type-aliases/XrGrabGesture.md +19 -0
  155. package/dist/docs/api/components/type-aliases/XrGrabHands.md +20 -0
  156. package/dist/docs/api/components/type-aliases/XrGrabReach.md +20 -0
  157. package/dist/docs/api/components/type-aliases/XrHandPoseEntry.md +49 -0
  158. package/dist/docs/api/components/type-aliases/XrHandPreset.md +19 -0
  159. package/dist/docs/api/components/type-aliases/XrInteractorSide.md +15 -0
  160. package/dist/docs/api/components/type-aliases/XrInteractorType.md +13 -0
  161. package/dist/docs/api/components/type-aliases/XrLocomotionMode.md +15 -0
  162. package/dist/docs/api/components/type-aliases/XrTrackingOrigin.md +24 -0
  163. package/dist/docs/api/components/type-aliases/XrTwoHandRotation.md +15 -0
  164. package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +1 -1
  165. package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_LIGHTING.md +15 -0
  166. package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +1 -1
  167. package/dist/docs/api/components/variables/DEFAULT_INSTANCED_MESH_PARAMETERS.md +1 -1
  168. package/dist/docs/api/components/variables/DEFAULT_INSTANCE_TRANSFORM.md +1 -1
  169. package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +1 -1
  170. package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +1 -1
  171. package/dist/docs/api/components/variables/DEFAULT_POSE_CURLS.md +13 -0
  172. package/dist/docs/api/components/variables/DEFAULT_POSE_DIRECTIONS.md +13 -0
  173. package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +1 -1
  174. package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +1 -1
  175. package/dist/docs/api/components/variables/MODEL_NO_PATH_MESSAGE.md +15 -0
  176. package/dist/docs/api/index/classes/AnimationStateMachine.md +16 -16
  177. package/dist/docs/api/index/classes/AnimationStateManager.md +13 -13
  178. package/dist/docs/api/index/classes/AnimationSystem.md +3 -3
  179. package/dist/docs/api/index/classes/AudioSystem.md +4 -4
  180. package/dist/docs/api/index/classes/CameraSyncSystem.md +2 -2
  181. package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +19 -4
  182. package/dist/docs/api/index/classes/HandPoseTracker.md +114 -0
  183. package/dist/docs/api/index/classes/InputSystem.md +33 -33
  184. package/dist/docs/api/index/classes/InstancedMeshSystem.md +2 -2
  185. package/dist/docs/api/index/classes/LightSyncSystem.md +2 -2
  186. package/dist/docs/api/index/classes/MaterialSyncSystem.md +3 -3
  187. package/dist/docs/api/index/classes/MeshGeometrySystem.md +2 -2
  188. package/dist/docs/api/index/classes/ObjectManagementSystem.md +14 -14
  189. package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +2 -2
  190. package/dist/docs/api/index/classes/PhysicsSyncSystem.md +4 -4
  191. package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +34 -10
  192. package/dist/docs/api/index/classes/RenderSystem.md +13 -4
  193. package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +9 -5
  194. package/dist/docs/api/index/classes/ScriptObject.md +10 -10
  195. package/dist/docs/api/index/classes/ScriptObjectSystem.md +6 -6
  196. package/dist/docs/api/index/classes/TeleportAimGate.md +114 -0
  197. package/dist/docs/api/index/classes/ThrowVelocityTracker.md +89 -0
  198. package/dist/docs/api/index/classes/TransformSyncSystem.md +2 -2
  199. package/dist/docs/api/index/classes/UIInteractionSystem.md +60 -0
  200. package/dist/docs/api/index/classes/UIPanelSystem.md +79 -0
  201. package/dist/docs/api/index/classes/VRTeleportAreaSystem.md +49 -0
  202. package/dist/docs/api/index/classes/VideoSystem.md +8 -6
  203. package/dist/docs/api/index/classes/World.md +282 -100
  204. package/dist/docs/api/index/classes/XRAnchorSystem.md +90 -0
  205. package/dist/docs/api/index/classes/XRControllerVisualSystem.md +77 -0
  206. package/dist/docs/api/index/classes/XREnvironmentSystem.md +137 -0
  207. package/dist/docs/api/index/classes/XRHandPoseSystem.md +107 -0
  208. package/dist/docs/api/index/classes/XRHitTestSystem.md +93 -0
  209. package/dist/docs/api/index/classes/XRHoverVisualSystem.md +76 -0
  210. package/dist/docs/api/index/classes/XRInputSystem.md +189 -0
  211. package/dist/docs/api/index/classes/XRInteractionSystem.md +323 -0
  212. package/dist/docs/api/index/classes/XRLocomotionSystem.md +128 -0
  213. package/dist/docs/api/index/classes/XRSessionSystem.md +116 -0
  214. package/dist/docs/api/index/classes/XRTeleportVisualSystem.md +75 -0
  215. package/dist/docs/api/index/functions/angularVelocityFrom.md +33 -0
  216. package/dist/docs/api/index/functions/applyHandMaterial.md +26 -0
  217. package/dist/docs/api/index/functions/applyPrefabToSnapshotInstances.md +1 -1
  218. package/dist/docs/api/index/functions/arcGroundCrossing.md +30 -0
  219. package/dist/docs/api/index/functions/buildComponentValueMaps.md +1 -1
  220. package/dist/docs/api/index/functions/buildNodeKeyMapsFromSnapshot.md +1 -1
  221. package/dist/docs/api/index/functions/buildNodeMapsFromSnapshot.md +1 -1
  222. package/dist/docs/api/index/functions/canonicalizeComponentValue.md +1 -1
  223. package/dist/docs/api/index/functions/clearModelCache.md +1 -1
  224. package/dist/docs/api/index/functions/clearPrefabCache.md +1 -1
  225. package/dist/docs/api/index/functions/cloneHandPose.md +23 -0
  226. package/dist/docs/api/index/functions/collectDiffPaths.md +1 -1
  227. package/dist/docs/api/index/functions/collectDirectPrefabDependencies.md +1 -1
  228. package/dist/docs/api/index/functions/collectEntitySubtree.md +1 -1
  229. package/dist/docs/api/index/functions/collectSnapshotSubtreeIds.md +1 -1
  230. package/dist/docs/api/index/functions/computeFingerCurl.md +29 -0
  231. package/dist/docs/api/index/functions/computeHandShape.md +29 -0
  232. package/dist/docs/api/index/functions/computeInstanceOverrides.md +1 -1
  233. package/dist/docs/api/index/functions/computePalmPose.md +30 -0
  234. package/dist/docs/api/index/functions/computePalmWidth.md +25 -0
  235. package/dist/docs/api/index/functions/computePinch.md +29 -0
  236. package/dist/docs/api/index/functions/computeSpread.md +33 -0
  237. package/dist/docs/api/index/functions/createAnimationComponent.md +1 -1
  238. package/dist/docs/api/index/functions/createAudioComponent.md +1 -1
  239. package/dist/docs/api/index/functions/createCameraComponent.md +1 -1
  240. package/dist/docs/api/index/functions/createEntityTypeComponent.md +2 -2
  241. package/dist/docs/api/index/functions/createEnvironmentComponent.md +1 -1
  242. package/dist/docs/api/index/functions/createHandMaterial.md +30 -0
  243. package/dist/docs/api/index/functions/createImageComponent.md +1 -1
  244. package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +1 -1
  245. package/dist/docs/api/index/functions/createImageTargetComponent.md +2 -2
  246. package/dist/docs/api/index/functions/createInstanceSlotComponent.md +1 -1
  247. package/dist/docs/api/index/functions/createInstancedMeshComponent.md +1 -1
  248. package/dist/docs/api/index/functions/createLightComponent.md +2 -2
  249. package/dist/docs/api/index/functions/createMaterialComponent.md +2 -2
  250. package/dist/docs/api/index/functions/createMeshComponent.md +1 -1
  251. package/dist/docs/api/index/functions/createMeshGeometryComponent.md +1 -1
  252. package/dist/docs/api/index/functions/createModelComponent.md +1 -1
  253. package/dist/docs/api/index/functions/createNameComponent.md +1 -1
  254. package/dist/docs/api/index/functions/createObject3DRefComponent.md +1 -1
  255. package/dist/docs/api/index/functions/createParentIdComponent.md +1 -1
  256. package/dist/docs/api/index/functions/createPhysicsComponent.md +1 -1
  257. package/dist/docs/api/index/functions/createPostprocessingComponent.md +1 -1
  258. package/dist/docs/api/index/functions/createScriptComponent.md +1 -1
  259. package/dist/docs/api/index/functions/createScriptObjectComponent.md +1 -1
  260. package/dist/docs/api/index/functions/createSelectableComponent.md +1 -1
  261. package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +1 -1
  262. package/dist/docs/api/index/functions/createSpriteComponent.md +1 -1
  263. package/dist/docs/api/index/functions/createTransformComponent.md +1 -1
  264. package/dist/docs/api/index/functions/createUIButtonComponent.md +28 -0
  265. package/dist/docs/api/index/functions/createUIPanelComponent.md +28 -0
  266. package/dist/docs/api/index/functions/createUISliderComponent.md +28 -0
  267. package/dist/docs/api/index/functions/createUITextComponent.md +28 -0
  268. package/dist/docs/api/index/functions/createUIToggleComponent.md +28 -0
  269. package/dist/docs/api/index/functions/createVRTeleportAreaComponent.md +28 -0
  270. package/dist/docs/api/index/functions/createVideoComponent.md +1 -1
  271. package/dist/docs/api/index/functions/createXRAnchorComponent.md +28 -0
  272. package/dist/docs/api/index/functions/createXRHandPoseComponent.md +28 -0
  273. package/dist/docs/api/index/functions/createXRInteractableComponent.md +28 -0
  274. package/dist/docs/api/index/functions/createXRInteractorComponent.md +28 -0
  275. package/dist/docs/api/index/functions/createXRInteractorSideComponent.md +28 -0
  276. package/dist/docs/api/index/functions/createXRRigComponent.md +28 -0
  277. package/dist/docs/api/index/functions/decanonicalizeComponentValue.md +1 -1
  278. package/dist/docs/api/index/functions/despawnPrefab.md +1 -1
  279. package/dist/docs/api/index/functions/encodeOverride.md +1 -1
  280. package/dist/docs/api/index/functions/estimateHandScale.md +28 -0
  281. package/dist/docs/api/index/functions/findSnapshotRootEntityIds.md +1 -1
  282. package/dist/docs/api/index/functions/findTopLevelNestedRegions.md +1 -1
  283. package/dist/docs/api/index/functions/getHandPosePreset.md +31 -0
  284. package/dist/docs/api/index/functions/groupOverridePaths.md +1 -1
  285. package/dist/docs/api/index/functions/handPoseFromCurls.md +42 -0
  286. package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +1 -1
  287. package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +1 -1
  288. package/dist/docs/api/index/functions/indexSnapshotByEntity.md +1 -1
  289. package/dist/docs/api/index/functions/instantiateSubtree.md +1 -1
  290. package/dist/docs/api/index/functions/loadPrefab.md +1 -1
  291. package/dist/docs/api/index/functions/loadSharedGltf.md +1 -1
  292. package/dist/docs/api/index/functions/matchHandPose.md +34 -0
  293. package/dist/docs/api/index/functions/mergeComponentValue.md +1 -1
  294. package/dist/docs/api/index/functions/parseOverride.md +1 -1
  295. package/dist/docs/api/index/functions/parsePrefabAsset.md +1 -1
  296. package/dist/docs/api/index/functions/prefabFileVersionFor.md +1 -1
  297. package/dist/docs/api/index/functions/readXrCapabilities.md +30 -0
  298. package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +1 -1
  299. package/dist/docs/api/index/functions/registerDefaultFactories.md +1 -1
  300. package/dist/docs/api/index/functions/remapSnapshotEntityIds.md +3 -3
  301. package/dist/docs/api/index/functions/resolveDracoDecoderPath.md +1 -1
  302. package/dist/docs/api/index/functions/restoreComponentState.md +1 -1
  303. package/dist/docs/api/index/functions/restorePostCreateComponents.md +1 -1
  304. package/dist/docs/api/index/functions/sampleTeleportArc.md +40 -0
  305. package/dist/docs/api/index/functions/serializeEntitySubtree.md +1 -1
  306. package/dist/docs/api/index/functions/setDracoDecoderPath.md +1 -1
  307. package/dist/docs/api/index/functions/setPrefabAssetUrlResolver.md +1 -1
  308. package/dist/docs/api/index/functions/spawnPrefab.md +1 -1
  309. package/dist/docs/api/index/index.md +116 -4
  310. package/dist/docs/api/index/interfaces/ChromaKeyOptions.md +20 -0
  311. package/dist/docs/api/index/interfaces/EcsSystem.md +3 -3
  312. package/dist/docs/api/index/interfaces/PostprocessingBuildContext.md +21 -0
  313. package/dist/docs/api/index/interfaces/PostprocessingPipeline.md +84 -0
  314. package/dist/docs/api/index/interfaces/RenderBackend.md +168 -0
  315. package/dist/docs/api/index/interfaces/StateMachine.md +13 -13
  316. package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +4 -4
  317. package/dist/docs/api/index/type-aliases/ApplyPrefabToSnapshotResult.md +3 -3
  318. package/dist/docs/api/index/type-aliases/ComponentFactory.md +1 -1
  319. package/dist/docs/api/index/type-aliases/ComponentValueMaps.md +50 -26
  320. package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +14 -2
  321. package/dist/docs/api/index/type-aliases/EcsRenderer.md +17 -0
  322. package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +3 -3
  323. package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +4 -4
  324. package/dist/docs/api/index/type-aliases/ExternalRefWarning.md +5 -5
  325. package/dist/docs/api/index/type-aliases/HandMaterialOptions.md +32 -0
  326. package/dist/docs/api/index/type-aliases/HandPoseTrackerOptions.md +27 -0
  327. package/dist/docs/api/index/type-aliases/HydrateOptions.md +3 -3
  328. package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +4 -4
  329. package/dist/docs/api/index/type-aliases/InstantiateSubtreeResult.md +3 -3
  330. package/dist/docs/api/index/type-aliases/KeyboardKey.md +1 -1
  331. package/dist/docs/api/index/type-aliases/ModuleLoader.md +1 -1
  332. package/dist/docs/api/index/type-aliases/MouseButton.md +1 -1
  333. package/dist/docs/api/index/type-aliases/NestedRegion.md +5 -5
  334. package/dist/docs/api/index/type-aliases/NodeKeyMaps.md +5 -5
  335. package/dist/docs/api/index/type-aliases/NodeMaps.md +4 -4
  336. package/dist/docs/api/index/type-aliases/PrefabAsset.md +5 -5
  337. package/dist/docs/api/index/type-aliases/RemapSnapshotOptions.md +2 -2
  338. package/dist/docs/api/index/type-aliases/RendererKind.md +15 -0
  339. package/dist/docs/api/index/type-aliases/ScriptBehaviourSystemOptions.md +23 -0
  340. package/dist/docs/api/index/type-aliases/ScriptErrorEvent.md +39 -0
  341. package/dist/docs/api/index/type-aliases/ScriptErrorListener.md +25 -0
  342. package/dist/docs/api/index/type-aliases/ScriptErrorPhase.md +28 -0
  343. package/dist/docs/api/index/type-aliases/ScriptErrorReport.md +31 -0
  344. package/dist/docs/api/index/type-aliases/ScriptErrorSource.md +15 -0
  345. package/dist/docs/api/index/type-aliases/SelectionContext.md +4 -4
  346. package/dist/docs/api/index/type-aliases/SerializeEntitySubtreeResult.md +4 -4
  347. package/dist/docs/api/index/type-aliases/SpawnPrefabOptions.md +5 -5
  348. package/dist/docs/api/index/type-aliases/SpawnPrefabSource.md +1 -1
  349. package/dist/docs/api/index/type-aliases/SubtreeSnapshot.md +3 -3
  350. package/dist/docs/api/index/type-aliases/UiCanvasLike.md +46 -0
  351. package/dist/docs/api/index/type-aliases/VelocitySample.md +23 -0
  352. package/dist/docs/api/index/type-aliases/XrCapabilities.md +41 -0
  353. package/dist/docs/api/index/type-aliases/XrFinger.md +13 -0
  354. package/dist/docs/api/index/type-aliases/XrFingerCurl.md +27 -0
  355. package/dist/docs/api/index/type-aliases/XrFingerTarget.md +31 -0
  356. package/dist/docs/api/index/type-aliases/XrHandJointName.md +40 -0
  357. package/dist/docs/api/index/type-aliases/XrHandJoints.md +18 -0
  358. package/dist/docs/api/index/type-aliases/XrHandPoseAxis.md +15 -0
  359. package/dist/docs/api/index/type-aliases/XrHandPoseContext.md +23 -0
  360. package/dist/docs/api/index/type-aliases/XrHandPoseDefinition.md +47 -0
  361. package/dist/docs/api/index/type-aliases/XrHandPoseDirection.md +21 -0
  362. package/dist/docs/api/index/type-aliases/XrHandPoseEvent.md +13 -0
  363. package/dist/docs/api/index/type-aliases/XrHandPoseEventDetail.md +27 -0
  364. package/dist/docs/api/index/type-aliases/XrHandPoseMatch.md +25 -0
  365. package/dist/docs/api/index/type-aliases/XrHandPoseOrientation.md +25 -0
  366. package/dist/docs/api/index/type-aliases/XrHandShape.md +46 -0
  367. package/dist/docs/api/index/type-aliases/XrHandedness.md +15 -0
  368. package/dist/docs/api/index/type-aliases/XrHitResult.md +25 -0
  369. package/dist/docs/api/index/type-aliases/XrInputKind.md +19 -0
  370. package/dist/docs/api/index/type-aliases/XrInputState.md +60 -0
  371. package/dist/docs/api/index/type-aliases/XrPalmPose.md +31 -0
  372. package/dist/docs/api/index/variables/ADDED_NODE_MARKER_COMPONENT.md +2 -2
  373. package/dist/docs/api/index/variables/ARC_GRAVITY.md +15 -0
  374. package/dist/docs/api/index/variables/ARC_MAX_TIME.md +15 -0
  375. package/dist/docs/api/index/variables/ARC_SPEED.md +15 -0
  376. package/dist/docs/api/index/variables/ARC_STEPS.md +15 -0
  377. package/dist/docs/api/index/variables/CURLED_COS.md +13 -0
  378. package/dist/docs/api/index/variables/DEFAULT_DIRECTION_TOLERANCE.md +15 -0
  379. package/dist/docs/api/index/variables/DEFAULT_ENTER_CONFIDENCE.md +13 -0
  380. package/dist/docs/api/index/variables/DEFAULT_EXIT_CONFIDENCE.md +13 -0
  381. package/dist/docs/api/index/variables/DEFAULT_LOST_GRACE_SECONDS.md +13 -0
  382. package/dist/docs/api/index/variables/DEFAULT_MIN_HOLD_SECONDS.md +13 -0
  383. package/dist/docs/api/index/variables/DEFAULT_SCRIPT_ERROR_RETRY_DELAY.md +17 -0
  384. package/dist/docs/api/index/variables/FALLBACK_HAND_SCALE.md +15 -0
  385. package/dist/docs/api/index/variables/HAND_POSE_PRESETS.md +19 -0
  386. package/dist/docs/api/index/variables/HAND_POSE_PRESET_IDS.md +15 -0
  387. package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +1 -1
  388. package/dist/docs/api/index/variables/KeyboardKeys.md +89 -89
  389. package/dist/docs/api/index/variables/MATCH_FALLOFF.md +15 -0
  390. package/dist/docs/api/index/variables/MAX_PLAUSIBLE_SPEED.md +25 -0
  391. package/dist/docs/api/index/variables/MAX_SAMPLE_AGE_SECONDS.md +18 -0
  392. package/dist/docs/api/index/variables/NODE_KEY_SEPARATOR.md +1 -1
  393. package/dist/docs/api/index/variables/NO_XR_CAPABILITIES.md +15 -0
  394. package/dist/docs/api/index/variables/OVERRIDE_DIFF_EXCLUDED_COMPONENTS.md +1 -1
  395. package/dist/docs/api/index/variables/OVERRIDE_ROOT_EXCLUDED_COMPONENTS.md +1 -1
  396. package/dist/docs/api/index/variables/PINCH_FINGERS.md +15 -0
  397. package/dist/docs/api/index/variables/PREFAB_FILE_VERSION.md +1 -1
  398. package/dist/docs/api/index/variables/PREFAB_FILE_VERSION_NESTED.md +1 -1
  399. package/dist/docs/api/index/variables/SCRIPT_OBJECT_ROOT_FLAG.md +1 -1
  400. package/dist/docs/api/index/variables/SHARED_MODEL_RESOURCE_FLAG.md +1 -1
  401. package/dist/docs/api/index/variables/STRAIGHT_COS.md +19 -0
  402. package/dist/docs/api/index/variables/VELOCITY_SAMPLES.md +15 -0
  403. package/dist/docs/api/index/variables/XR_FINGERS.md +13 -0
  404. package/dist/docs/api/index/variables/XR_HOVER_SHELL_FLAG.md +15 -0
  405. package/dist/docs/api/index/variables/webglBackend.md +16 -0
  406. package/dist/docs/api/typedoc-sidebar.json +1 -1
  407. package/dist/docs/api/types/type-aliases/AssetInput.md +3 -3
  408. package/dist/docs/api/types/type-aliases/CheckboxInput.md +3 -3
  409. package/dist/docs/api/types/type-aliases/ColorInput.md +1 -1
  410. package/dist/docs/api/types/type-aliases/ComponentInput.md +4 -4
  411. package/dist/docs/api/types/type-aliases/ComponentKind.md +1 -1
  412. package/dist/docs/api/types/type-aliases/DropdownInput.md +3 -3
  413. package/dist/docs/api/types/type-aliases/DropdownOption.md +3 -3
  414. package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +1 -1
  415. package/dist/docs/api/types/type-aliases/EcsEntityKind.md +10 -2
  416. package/dist/docs/api/types/type-aliases/EntityId.md +1 -1
  417. package/dist/docs/api/types/type-aliases/EntityInput.md +3 -3
  418. package/dist/docs/api/types/type-aliases/FloatInput.md +1 -1
  419. package/dist/docs/api/types/type-aliases/IntersectionResult.md +3 -3
  420. package/dist/docs/api/types/type-aliases/ParentLookup.md +3 -3
  421. package/dist/docs/api/types/type-aliases/SelectionListener.md +1 -1
  422. package/dist/docs/api/types/type-aliases/SliderInput.md +5 -5
  423. package/dist/docs/api/types/type-aliases/TextInput.md +1 -1
  424. package/dist/docs/api/types/type-aliases/ToggleInput.md +1 -1
  425. package/dist/docs/api/types/type-aliases/Vec3.md +1 -1
  426. package/dist/docs/api/types/type-aliases/Vector2Input.md +3 -3
  427. package/dist/docs/api/types/type-aliases/Vector3Input.md +4 -4
  428. package/dist/docs/api/types/type-aliases/WorldEntityView.md +1 -1
  429. package/dist/docs/guide/audio-mixing-and-sound-banks.md +71 -0
  430. package/dist/docs/guide/authoring-a-behaviour.md +3 -3
  431. package/dist/docs/guide/authoring-a-script-object.md +12 -9
  432. package/dist/docs/guide/behaviour-data-binding/index.md +11 -11
  433. package/dist/docs/guide/behaviour-lifecycle.md +9 -0
  434. package/dist/docs/guide/bone-attachments-and-ik.md +128 -0
  435. package/dist/docs/guide/component-catalog.md +10 -2
  436. package/dist/docs/guide/components/light.md +42 -0
  437. package/dist/docs/guide/components/model.md +32 -3
  438. package/dist/docs/guide/concepts.md +2 -2
  439. package/dist/docs/guide/getting-started/creating-objects.md +2 -2
  440. package/dist/docs/guide/getting-started/editing-objects.md +2 -2
  441. package/dist/docs/guide/getting-started/editor/ai-agent.md +227 -0
  442. package/dist/docs/guide/getting-started/editor/hierarchy.md +2 -2
  443. package/dist/docs/guide/getting-started/editor/index.md +3 -2
  444. package/dist/docs/guide/getting-started/editor/inspector.md +2 -2
  445. package/dist/docs/guide/getting-started/editor/scene-inspector.md +3 -3
  446. package/dist/docs/guide/getting-started/editor/toolbar.md +11 -11
  447. package/dist/docs/guide/getting-started/editor/viewport.md +17 -9
  448. package/dist/docs/guide/getting-started/index.md +1 -1
  449. package/dist/docs/guide/getting-started/installation.md +1 -1
  450. package/dist/docs/guide/getting-started/preview-and-test.md +7 -7
  451. package/dist/docs/guide/getting-started/project-types/image-tracking.md +23 -11
  452. package/dist/docs/guide/getting-started/project-types/index.md +4 -4
  453. package/dist/docs/guide/getting-started/project-types/vr.md +270 -2
  454. package/dist/docs/guide/getting-started/projects.md +4 -5
  455. package/dist/docs/guide/getting-started/shortcuts.md +5 -4
  456. package/dist/docs/guide/multiplayer.md +92 -0
  457. package/dist/docs/guide/scene/environment.md +101 -4
  458. package/dist/docs/guide/scene/index.md +4 -4
  459. package/dist/docs/guide/scene/postprocessing.md +67 -5
  460. package/dist/docs/guide/spatial-ui.md +83 -7
  461. package/dist/docs/guide/spawning/area-light.md +2 -0
  462. package/dist/docs/guide/systems/environment-sync-system.md +11 -6
  463. package/dist/docs/guide/systems/light-sync-system.md +5 -3
  464. package/dist/docs/guide/systems/postprocessing-sync-system.md +16 -6
  465. package/dist/docs/guide/systems/render-system.md +7 -6
  466. package/dist/docs/guide/systems/script-behaviour-system.md +7 -5
  467. package/dist/docs/guide/systems/script-object-system.md +3 -1
  468. package/dist/docs/guide/systems/video-system.md +1 -1
  469. package/dist/docs/guide/webgpu-and-tsl.md +415 -0
  470. package/dist/docs/guide/world-api.md +52 -2
  471. package/dist/factories/index.cjs +921 -283
  472. package/dist/factories/index.cjs.map +1 -1
  473. package/dist/factories/index.d.cts +14 -3
  474. package/dist/factories/index.d.ts +14 -3
  475. package/dist/factories/index.js +7 -4
  476. package/dist/{index-C3ik3sA1.d.ts → index-CAZHrh0q.d.cts} +28 -3
  477. package/dist/{index-Dlr-7-4m.d.cts → index-CLtSMf2M.d.ts} +28 -3
  478. package/dist/{index-D2Jt_JzH.d.ts → index-D5MmJNyj.d.ts} +161 -43
  479. package/dist/{index-DaG03vyN.d.cts → index-DiIjV2lm.d.cts} +161 -43
  480. package/dist/index.cjs +4959 -1414
  481. package/dist/index.cjs.map +1 -1
  482. package/dist/index.d.cts +113 -11
  483. package/dist/index.d.ts +113 -11
  484. package/dist/index.js +187 -12
  485. package/dist/index.js.map +1 -1
  486. package/dist/network/index.cjs +5069 -0
  487. package/dist/network/index.cjs.map +1 -0
  488. package/dist/network/index.d.cts +98 -0
  489. package/dist/network/index.d.ts +98 -0
  490. package/dist/network/index.js +493 -0
  491. package/dist/network/index.js.map +1 -0
  492. package/dist/systems/index.cjs +5319 -1957
  493. package/dist/systems/index.cjs.map +1 -1
  494. package/dist/systems/index.d.cts +4 -2
  495. package/dist/systems/index.d.ts +4 -2
  496. package/dist/systems/index.js +8 -4
  497. package/dist/types.d.cts +3 -1
  498. package/dist/types.d.ts +3 -1
  499. package/dist/webgpu/index.d.ts +113 -0
  500. package/dist/webgpu/index.js +302 -0
  501. package/dist/webgpu/index.js.map +1 -0
  502. package/dist/worldSnapshotUtils.d.cts +3 -1
  503. package/dist/worldSnapshotUtils.d.ts +3 -1
  504. package/dist/worldSnapshotUtils.js +3 -2
  505. package/package.json +19 -3
  506. package/dist/chunk-BUEKOSR5.js.map +0 -1
  507. package/dist/chunk-DF5SSRN6.js.map +0 -1
  508. package/dist/chunk-OWQSESTO.js.map +0 -1
  509. package/dist/chunk-OY7ZODZP.js.map +0 -1
  510. package/dist/chunk-RXBLOO5B.js.map +0 -1
  511. package/dist/chunk-WJD2VKEH.js +0 -315
  512. package/dist/chunk-WJD2VKEH.js.map +0 -1
@@ -0,0 +1,2878 @@
1
+ import { applyTransform } from './chunk-JEPUCLZX.js';
2
+ import { ScriptComponent, ParentId, Object3DRef, ScriptObjectComponent, XRRigComponent, VRTeleportAreaComponent, XRInteractableComponent, createAttachPoint, XRHandPoseComponent, createHandPoseEntry, XRAnchorComponent, BoneAttachmentComponent, NetworkIdentityComponent, NetworkTransformComponent, NetworkedPropsComponent, NetworkSpawnerComponent, IKComponent, normalizeIKChain, UIPanelComponent, UITextComponent, UIButtonComponent, UIToggleComponent, UISliderComponent, XRInteractorComponent, XRInteractorSideComponent, InstancedMeshComponent, InstanceSlotComponent, AnimationComponent, Name, TransformComponent, ModelComponent, ImageComponent, SpriteComponent, VideoComponent, AudioComponent, CameraComponent, Environment, Postprocessing, ImageTarget, LightComponent, MaterialComponent, MeshGeometryComponent, Selectable, PhysicsComponent, PrefabNode, PrefabInstance, normalizeUiStyle, normalizeUiTokens } from './chunk-JNYPJB55.js';
3
+ import { __name } from './chunk-XE4OXN2W.js';
4
+ import * as THREE from 'three';
5
+
6
+ // core/systems/scriptShared.ts
7
+ async function defaultModuleLoader(scriptUrl) {
8
+ return await import(
9
+ /* webpackIgnore: true */
10
+ scriptUrl
11
+ );
12
+ }
13
+ __name(defaultModuleLoader, "defaultModuleLoader");
14
+ function sanitizeErrorText(value) {
15
+ return value.replace(/localasset:\/\/[^/]+\//g, "localasset://").replace(/\/Users\/[^\s)]+/g, "[local path]");
16
+ }
17
+ __name(sanitizeErrorText, "sanitizeErrorText");
18
+ function toErrorMessage(error) {
19
+ if (error instanceof Error && error.message) {
20
+ return sanitizeErrorText(error.message);
21
+ }
22
+ if (typeof error === "string" && error) {
23
+ return sanitizeErrorText(error);
24
+ }
25
+ return "Unknown script error.";
26
+ }
27
+ __name(toErrorMessage, "toErrorMessage");
28
+ function toErrorStack(error) {
29
+ const stack = error && typeof error === "object" ? error.stack : void 0;
30
+ return typeof stack === "string" && stack.length > 0 ? sanitizeErrorText(stack) : void 0;
31
+ }
32
+ __name(toErrorStack, "toErrorStack");
33
+ var SCRIPT_PHASE = /* @__PURE__ */ Symbol("scriptErrorPhase");
34
+ function withScriptPhase(phase, error) {
35
+ if (error && typeof error === "object" && SCRIPT_PHASE in error) {
36
+ return error;
37
+ }
38
+ return { [SCRIPT_PHASE]: phase, error };
39
+ }
40
+ __name(withScriptPhase, "withScriptPhase");
41
+ function readScriptPhase(thrown, fallback) {
42
+ if (thrown && typeof thrown === "object" && SCRIPT_PHASE in thrown) {
43
+ const phased = thrown;
44
+ return { phase: phased[SCRIPT_PHASE], error: phased.error };
45
+ }
46
+ return { phase: fallback, error: thrown };
47
+ }
48
+ __name(readScriptPhase, "readScriptPhase");
49
+ function reportScriptError(world, report, error) {
50
+ const reporter = world.reportScriptError;
51
+ if (typeof reporter === "function") {
52
+ reporter.call(world, report, error);
53
+ return;
54
+ }
55
+ console.error(
56
+ `[spatial-ecs] ${report.className || "Script"} failed in ${report.phase} (entity ${report.entityId}):`,
57
+ error
58
+ );
59
+ }
60
+ __name(reportScriptError, "reportScriptError");
61
+ function reportBehaviourHookError(world, entityId, instance, hook, error) {
62
+ let scriptUrl = "";
63
+ let className = instance?.constructor?.name ?? "";
64
+ const script = typeof world.getComponent === "function" ? world.getComponent(entityId, ScriptComponent) : void 0;
65
+ if (script?.scriptInstances && Array.isArray(script.entries)) {
66
+ const entries = script.entries.filter(
67
+ (entry) => entry && (entry.className || entry.scriptUrl)
68
+ );
69
+ for (const [index, live] of script.scriptInstances) {
70
+ if (live !== instance) continue;
71
+ const entry = entries[index];
72
+ if (entry) {
73
+ scriptUrl = typeof entry.scriptUrl === "string" ? entry.scriptUrl : "";
74
+ className = typeof entry.className === "string" && entry.className ? entry.className : className;
75
+ }
76
+ break;
77
+ }
78
+ }
79
+ reportScriptError(
80
+ world,
81
+ { entityId, scriptUrl, className, phase: hook, source: "behaviour" },
82
+ error
83
+ );
84
+ }
85
+ __name(reportBehaviourHookError, "reportBehaviourHookError");
86
+ function resolveScriptCtor(moduleValue, className, options) {
87
+ const named = moduleValue[className];
88
+ const fallback = moduleValue.default;
89
+ const candidate = typeof named === "function" ? named : typeof fallback === "function" ? fallback : null;
90
+ if (!candidate) {
91
+ return null;
92
+ }
93
+ if (!(candidate.prototype instanceof options.baseClass)) {
94
+ const marker = candidate[options.markerKey];
95
+ if (!marker) {
96
+ return null;
97
+ }
98
+ }
99
+ return candidate;
100
+ }
101
+ __name(resolveScriptCtor, "resolveScriptCtor");
102
+ function normalizeScriptData(value) {
103
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
104
+ }
105
+ __name(normalizeScriptData, "normalizeScriptData");
106
+ function isPlainObject(value) {
107
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
108
+ }
109
+ __name(isPlainObject, "isPlainObject");
110
+ function mergeValueByDefaultShape(defaultValue, currentValue) {
111
+ if (Array.isArray(defaultValue)) {
112
+ return Array.isArray(currentValue) ? currentValue : defaultValue;
113
+ }
114
+ if (isPlainObject(defaultValue)) {
115
+ if (!isPlainObject(currentValue)) {
116
+ return defaultValue;
117
+ }
118
+ const next = {};
119
+ for (const key of Object.keys(defaultValue)) {
120
+ next[key] = mergeValueByDefaultShape(defaultValue[key], currentValue[key]);
121
+ }
122
+ return next;
123
+ }
124
+ if (typeof defaultValue === "number") {
125
+ return typeof currentValue === "number" ? currentValue : defaultValue;
126
+ }
127
+ if (typeof defaultValue === "string") {
128
+ return typeof currentValue === "string" ? currentValue : defaultValue;
129
+ }
130
+ if (typeof defaultValue === "boolean") {
131
+ return typeof currentValue === "boolean" ? currentValue : defaultValue;
132
+ }
133
+ if (defaultValue === null) {
134
+ return currentValue !== void 0 ? currentValue : null;
135
+ }
136
+ return typeof currentValue === "undefined" ? defaultValue : currentValue;
137
+ }
138
+ __name(mergeValueByDefaultShape, "mergeValueByDefaultShape");
139
+ function mergeDataByCurrentDefaults(defaults, current) {
140
+ const next = {};
141
+ for (const key of Object.keys(defaults)) {
142
+ next[key] = mergeValueByDefaultShape(defaults[key], current[key]);
143
+ }
144
+ return next;
145
+ }
146
+ __name(mergeDataByCurrentDefaults, "mergeDataByCurrentDefaults");
147
+ function isRawEntityInput(value) {
148
+ if (!isPlainObject(value)) return false;
149
+ return value.type === "entity";
150
+ }
151
+ __name(isRawEntityInput, "isRawEntityInput");
152
+ function isRawComponentInput(value) {
153
+ if (!isPlainObject(value)) return false;
154
+ return value.type === "component";
155
+ }
156
+ __name(isRawComponentInput, "isRawComponentInput");
157
+ function findComponentByKind(components, componentKind) {
158
+ return components.find(
159
+ (c) => c.constructor.name === `${componentKind}Component` || c.constructor.name === componentKind
160
+ ) ?? null;
161
+ }
162
+ __name(findComponentByKind, "findComponentByKind");
163
+ function resolveInputData(world, rawData) {
164
+ const resolved = { ...rawData };
165
+ for (const [key, value] of Object.entries(rawData)) {
166
+ if (isRawEntityInput(value)) {
167
+ const entityId = value.value;
168
+ const entityView = typeof entityId === "number" ? world.getEntityById(entityId) : null;
169
+ resolved[key] = { ...value, value: entityView };
170
+ } else if (isRawComponentInput(value)) {
171
+ const ref = value.value;
172
+ if (isPlainObject(ref) && typeof ref.entityId === "number" && typeof ref.componentKind === "string") {
173
+ const { entityId: refEntityId, componentKind } = ref;
174
+ const entityView = world.getEntityById(refEntityId);
175
+ const component = entityView ? findComponentByKind(entityView.components, componentKind) : null;
176
+ resolved[key] = { ...value, value: component };
177
+ }
178
+ }
179
+ }
180
+ return resolved;
181
+ }
182
+ __name(resolveInputData, "resolveInputData");
183
+ function serializeDataForStorage(rawData, instanceData) {
184
+ const result = { ...instanceData };
185
+ for (const [key, rawValue] of Object.entries(rawData)) {
186
+ if (isRawEntityInput(rawValue) || isRawComponentInput(rawValue)) {
187
+ result[key] = rawValue;
188
+ }
189
+ }
190
+ return result;
191
+ }
192
+ __name(serializeDataForStorage, "serializeDataForStorage");
193
+
194
+ // core/prefab/collectEntitySubtree.ts
195
+ function collectEntitySubtree(world, rootIds) {
196
+ const childrenByParent = /* @__PURE__ */ new Map();
197
+ for (const entityId of world.query(ParentId)) {
198
+ const parentId = world.getComponent(entityId, ParentId)?.value;
199
+ if (parentId === null || parentId === void 0) {
200
+ continue;
201
+ }
202
+ const siblings = childrenByParent.get(parentId);
203
+ if (siblings) {
204
+ siblings.push(entityId);
205
+ } else {
206
+ childrenByParent.set(parentId, [entityId]);
207
+ }
208
+ }
209
+ const ordered = [];
210
+ const seen = /* @__PURE__ */ new Set();
211
+ const queue = [...rootIds];
212
+ while (queue.length > 0) {
213
+ const entityId = queue.shift();
214
+ if (seen.has(entityId)) {
215
+ continue;
216
+ }
217
+ seen.add(entityId);
218
+ ordered.push(entityId);
219
+ const children = childrenByParent.get(entityId);
220
+ if (children) {
221
+ queue.push(...children.sort((a, b) => a - b));
222
+ }
223
+ }
224
+ return ordered;
225
+ }
226
+ __name(collectEntitySubtree, "collectEntitySubtree");
227
+
228
+ // core/hydration/readers.ts
229
+ function asRecord(value) {
230
+ if (!value || typeof value !== "object") {
231
+ return null;
232
+ }
233
+ return value;
234
+ }
235
+ __name(asRecord, "asRecord");
236
+ function readString(value) {
237
+ if (typeof value === "string") {
238
+ return value;
239
+ }
240
+ const record = asRecord(value);
241
+ if (!record) {
242
+ return null;
243
+ }
244
+ return typeof record.value === "string" ? record.value : null;
245
+ }
246
+ __name(readString, "readString");
247
+ function readTransform(value) {
248
+ const record = asRecord(value);
249
+ if (!record) {
250
+ return void 0;
251
+ }
252
+ const position = asRecord(record.position);
253
+ const rotation = asRecord(record.rotation);
254
+ const scale = asRecord(record.scale);
255
+ return {
256
+ position: position ? {
257
+ x: typeof position.x === "number" ? position.x : void 0,
258
+ y: typeof position.y === "number" ? position.y : void 0,
259
+ z: typeof position.z === "number" ? position.z : void 0
260
+ } : void 0,
261
+ rotation: rotation ? {
262
+ x: typeof rotation.x === "number" ? rotation.x : void 0,
263
+ y: typeof rotation.y === "number" ? rotation.y : void 0,
264
+ z: typeof rotation.z === "number" ? rotation.z : void 0
265
+ } : void 0,
266
+ scale: scale ? {
267
+ x: typeof scale.x === "number" ? scale.x : void 0,
268
+ y: typeof scale.y === "number" ? scale.y : void 0,
269
+ z: typeof scale.z === "number" ? scale.z : void 0
270
+ } : void 0
271
+ };
272
+ }
273
+ __name(readTransform, "readTransform");
274
+ function readByComponent(components, componentName) {
275
+ const component = components.find((entry) => entry.component === componentName);
276
+ const map = /* @__PURE__ */ new Map();
277
+ if (!component) {
278
+ return map;
279
+ }
280
+ for (const entry of component.entries) {
281
+ map.set(entry.entityId, entry.value);
282
+ }
283
+ return map;
284
+ }
285
+ __name(readByComponent, "readByComponent");
286
+ function readBoolean(value) {
287
+ return typeof value === "boolean" ? value : void 0;
288
+ }
289
+ __name(readBoolean, "readBoolean");
290
+ function readNumber(value) {
291
+ return typeof value === "number" ? value : void 0;
292
+ }
293
+ __name(readNumber, "readNumber");
294
+
295
+ // core/hydration/componentValues.ts
296
+ function buildComponentValueMaps(snapshot) {
297
+ return {
298
+ object3DRefValues: readByComponent(snapshot.components, "Object3DRef"),
299
+ nameValues: readByComponent(snapshot.components, "Name"),
300
+ transformValues: readByComponent(snapshot.components, "TransformComponent"),
301
+ modelValues: readByComponent(snapshot.components, "ModelComponent"),
302
+ imageValues: readByComponent(snapshot.components, "ImageComponent"),
303
+ spriteValues: readByComponent(snapshot.components, "SpriteComponent"),
304
+ videoValues: readByComponent(snapshot.components, "VideoComponent"),
305
+ cameraValues: readByComponent(snapshot.components, "CameraComponent"),
306
+ environmentValues: readByComponent(snapshot.components, "Environment"),
307
+ postprocessingValues: readByComponent(snapshot.components, "Postprocessing"),
308
+ audioValues: readByComponent(snapshot.components, "AudioComponent"),
309
+ imageTargetValues: readByComponent(snapshot.components, "ImageTarget"),
310
+ lightValues: readByComponent(snapshot.components, "LightComponent"),
311
+ materialValues: readByComponent(snapshot.components, "MaterialComponent"),
312
+ meshGeometryValues: readByComponent(snapshot.components, "MeshGeometryComponent"),
313
+ selectableValues: readByComponent(snapshot.components, "Selectable"),
314
+ physicsValues: readByComponent(snapshot.components, "PhysicsComponent"),
315
+ animationValues: readByComponent(snapshot.components, "AnimationComponent"),
316
+ imageTargetAnchorValues: readByComponent(snapshot.components, "ImageTargetAnchor"),
317
+ scriptValues: readByComponent(snapshot.components, "ScriptComponent"),
318
+ scriptObjectValues: readByComponent(
319
+ snapshot.components,
320
+ "ScriptObjectComponent"
321
+ ),
322
+ xrRigValues: readByComponent(snapshot.components, "XRRigComponent"),
323
+ vrTeleportAreaValues: readByComponent(
324
+ snapshot.components,
325
+ "VRTeleportAreaComponent"
326
+ ),
327
+ xrInteractableValues: readByComponent(
328
+ snapshot.components,
329
+ "XRInteractableComponent"
330
+ ),
331
+ xrInteractorValues: readByComponent(
332
+ snapshot.components,
333
+ "XRInteractorComponent"
334
+ ),
335
+ xrHandPoseValues: readByComponent(
336
+ snapshot.components,
337
+ "XRHandPoseComponent"
338
+ ),
339
+ xrAnchorValues: readByComponent(snapshot.components, "XRAnchorComponent"),
340
+ boneAttachmentValues: readByComponent(snapshot.components, "BoneAttachmentComponent"),
341
+ ikValues: readByComponent(snapshot.components, "IKComponent"),
342
+ networkIdentityValues: readByComponent(snapshot.components, "NetworkIdentityComponent"),
343
+ networkTransformValues: readByComponent(snapshot.components, "NetworkTransformComponent"),
344
+ networkedPropsValues: readByComponent(snapshot.components, "NetworkedPropsComponent"),
345
+ networkSpawnerValues: readByComponent(snapshot.components, "NetworkSpawnerComponent"),
346
+ uiPanelValues: readByComponent(snapshot.components, "UIPanelComponent"),
347
+ uiTextValues: readByComponent(snapshot.components, "UITextComponent"),
348
+ uiButtonValues: readByComponent(snapshot.components, "UIButtonComponent"),
349
+ uiToggleValues: readByComponent(snapshot.components, "UIToggleComponent"),
350
+ uiSliderValues: readByComponent(snapshot.components, "UISliderComponent"),
351
+ xrInteractorSideValues: readByComponent(
352
+ snapshot.components,
353
+ "XRInteractorSideComponent"
354
+ ),
355
+ instancedMeshValues: readByComponent(snapshot.components, "InstancedMeshComponent"),
356
+ instanceSlotValues: readByComponent(snapshot.components, "InstanceSlotComponent"),
357
+ prefabNodeValues: readByComponent(snapshot.components, "PrefabNode"),
358
+ prefabInstanceValues: readByComponent(snapshot.components, "PrefabInstance")
359
+ };
360
+ }
361
+ __name(buildComponentValueMaps, "buildComponentValueMaps");
362
+
363
+ // core/hydration/postCreateComponents.ts
364
+ var OPTIONAL_UI_FIELDS = {
365
+ pixelDensity: "number",
366
+ icon: "string",
367
+ iconPosition: "string",
368
+ variant: "string",
369
+ step: "number",
370
+ readOnly: "boolean"
371
+ };
372
+ function remapEntityRefsInScriptData(data, idMap) {
373
+ const result = {};
374
+ for (const [key, value] of Object.entries(data)) {
375
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
376
+ const v = value;
377
+ if (v.type === "entity" && typeof v.value === "number") {
378
+ result[key] = { ...v, value: idMap.get(v.value) ?? v.value };
379
+ } else if (v.type === "component" && v.value !== null && typeof v.value === "object" && !Array.isArray(v.value) && typeof v.value.entityId === "number") {
380
+ const ref = v.value;
381
+ result[key] = {
382
+ ...v,
383
+ value: { ...ref, entityId: idMap.get(ref.entityId) ?? ref.entityId }
384
+ };
385
+ } else {
386
+ result[key] = value;
387
+ }
388
+ } else {
389
+ result[key] = value;
390
+ }
391
+ }
392
+ return result;
393
+ }
394
+ __name(remapEntityRefsInScriptData, "remapEntityRefsInScriptData");
395
+ function restorePostCreateComponents(world, objectManagementSystem, targetEntityId, sourceEntityId, entityType, values, idMap) {
396
+ const objectRef = world.getComponent(targetEntityId, Object3DRef)?.object ?? null;
397
+ const sourceAudio = asRecord(values.audioValues.get(sourceEntityId));
398
+ if (sourceAudio && entityType !== "audio") {
399
+ const sourceOptions = asRecord(sourceAudio.options) ?? {};
400
+ objectManagementSystem.createComponentNow(
401
+ "audio",
402
+ world,
403
+ targetEntityId,
404
+ typeof sourceAudio.path === "string" ? sourceAudio.path : "",
405
+ sourceOptions,
406
+ {
407
+ object: objectRef,
408
+ listener: objectManagementSystem.getOrCreateAudioListener(),
409
+ isEditor: objectManagementSystem.isEditorMode()
410
+ }
411
+ );
412
+ }
413
+ const sourceImageTarget = asRecord(values.imageTargetValues.get(sourceEntityId));
414
+ if (sourceImageTarget && entityType !== "imageTarget") {
415
+ objectManagementSystem.createComponentNow(
416
+ "imageTarget",
417
+ world,
418
+ targetEntityId,
419
+ {
420
+ targets: Array.isArray(sourceImageTarget.targets) ? sourceImageTarget.targets : [],
421
+ compiledTargetUrl: typeof sourceImageTarget.compiledTargetUrl === "string" ? sourceImageTarget.compiledTargetUrl : void 0,
422
+ compiledTargetDir: typeof sourceImageTarget.compiledTargetDir === "string" ? sourceImageTarget.compiledTargetDir : void 0
423
+ }
424
+ );
425
+ }
426
+ const sourceImageTargetAnchor = asRecord(values.imageTargetAnchorValues.get(sourceEntityId));
427
+ if (sourceImageTargetAnchor) {
428
+ const mappedTargetId = typeof sourceImageTargetAnchor.targetId === "number" && Number.isFinite(sourceImageTargetAnchor.targetId) ? sourceImageTargetAnchor.targetId : null;
429
+ objectManagementSystem.createComponentNow("imageTargetAnchor", world, targetEntityId, {
430
+ targetId: mappedTargetId,
431
+ targetUrl: typeof sourceImageTargetAnchor.targetUrl === "string" ? sourceImageTargetAnchor.targetUrl : void 0
432
+ });
433
+ }
434
+ const sourceScript = asRecord(values.scriptValues.get(sourceEntityId));
435
+ if (sourceScript) {
436
+ const entries = Array.isArray(sourceScript.entries) ? sourceScript.entries.map((entry) => asRecord(entry)).filter((entry) => Boolean(entry)).map((entry) => {
437
+ const runtimeState = entry.runtimeState === "idle" || entry.runtimeState === "loading" || entry.runtimeState === "ready" || entry.runtimeState === "error" ? entry.runtimeState : void 0;
438
+ return {
439
+ entityId: targetEntityId,
440
+ className: typeof entry.className === "string" ? entry.className : "",
441
+ scriptUrl: typeof entry.scriptUrl === "string" ? entry.scriptUrl : "",
442
+ enabled: typeof entry.enabled === "boolean" ? entry.enabled : true,
443
+ data: entry.data && typeof entry.data === "object" && !Array.isArray(entry.data) ? remapEntityRefsInScriptData(entry.data, idMap) : {},
444
+ runtimeState,
445
+ runtimeMessage: typeof entry.runtimeMessage === "string" ? entry.runtimeMessage : void 0
446
+ };
447
+ }).filter((entry) => entry.className || entry.scriptUrl) : [];
448
+ if (entries.length) {
449
+ world.addComponent(targetEntityId, new ScriptComponent(entries));
450
+ }
451
+ }
452
+ const sourceScriptObject = asRecord(values.scriptObjectValues.get(sourceEntityId));
453
+ if (sourceScriptObject) {
454
+ const soc = world.getComponent(targetEntityId, ScriptObjectComponent);
455
+ const data = asRecord(sourceScriptObject.data);
456
+ if (soc && data) {
457
+ soc.data = remapEntityRefsInScriptData(data, idMap);
458
+ }
459
+ }
460
+ {
461
+ const sourceXrRig = asRecord(values.xrRigValues.get(sourceEntityId));
462
+ const rig = world.getComponent(targetEntityId, XRRigComponent);
463
+ if (sourceXrRig && rig) {
464
+ if (typeof sourceXrRig.locomotion === "string") {
465
+ rig.locomotion = sourceXrRig.locomotion;
466
+ }
467
+ if (typeof sourceXrRig.moveSpeed === "number") {
468
+ rig.moveSpeed = sourceXrRig.moveSpeed;
469
+ }
470
+ if (typeof sourceXrRig.snapTurn === "boolean") {
471
+ rig.snapTurn = sourceXrRig.snapTurn;
472
+ }
473
+ if (typeof sourceXrRig.snapTurnDegrees === "number") {
474
+ rig.snapTurnDegrees = sourceXrRig.snapTurnDegrees;
475
+ }
476
+ if (typeof sourceXrRig.teleportArcColor === "string") {
477
+ rig.teleportArcColor = sourceXrRig.teleportArcColor;
478
+ }
479
+ if (typeof sourceXrRig.teleportArcInvalidColor === "string") {
480
+ rig.teleportArcInvalidColor = sourceXrRig.teleportArcInvalidColor;
481
+ }
482
+ if (typeof sourceXrRig.teleportArcThickness === "number") {
483
+ rig.teleportArcThickness = sourceXrRig.teleportArcThickness;
484
+ }
485
+ if (typeof sourceXrRig.fallbackEyeHeight === "number") {
486
+ rig.fallbackEyeHeight = sourceXrRig.fallbackEyeHeight;
487
+ }
488
+ if (typeof sourceXrRig.passthrough === "boolean") {
489
+ rig.passthrough = sourceXrRig.passthrough;
490
+ }
491
+ if (typeof sourceXrRig.depthOcclusion === "boolean") {
492
+ rig.depthOcclusion = sourceXrRig.depthOcclusion;
493
+ }
494
+ if (typeof sourceXrRig.environmentPhysics === "string") {
495
+ rig.environmentPhysics = sourceXrRig.environmentPhysics;
496
+ }
497
+ if (typeof sourceXrRig.environmentDebug === "boolean") {
498
+ rig.environmentDebug = sourceXrRig.environmentDebug;
499
+ }
500
+ if (typeof sourceXrRig.hitTest === "boolean") {
501
+ rig.hitTest = sourceXrRig.hitTest;
502
+ }
503
+ if (typeof sourceXrRig.anchors === "boolean") {
504
+ rig.anchors = sourceXrRig.anchors;
505
+ }
506
+ }
507
+ }
508
+ {
509
+ const sourceArea = asRecord(values.vrTeleportAreaValues.get(sourceEntityId));
510
+ const area = world.getComponent(targetEntityId, VRTeleportAreaComponent);
511
+ if (sourceArea && area) {
512
+ if (typeof sourceArea.enabled === "boolean") {
513
+ area.enabled = sourceArea.enabled;
514
+ }
515
+ if (typeof sourceArea.shape === "string") {
516
+ area.shape = sourceArea.shape === "cylinder" ? "circle" : sourceArea.shape;
517
+ }
518
+ if (typeof sourceArea.width === "number") area.width = sourceArea.width;
519
+ if (typeof sourceArea.depth === "number") area.depth = sourceArea.depth;
520
+ }
521
+ }
522
+ {
523
+ const sourceInteractable = asRecord(
524
+ values.xrInteractableValues.get(sourceEntityId)
525
+ );
526
+ let interactable = world.getComponent(
527
+ targetEntityId,
528
+ XRInteractableComponent
529
+ );
530
+ if (sourceInteractable && !interactable) {
531
+ interactable = new XRInteractableComponent();
532
+ world.addComponent(targetEntityId, interactable);
533
+ }
534
+ if (sourceInteractable && interactable) {
535
+ if (typeof sourceInteractable.enabled === "boolean") {
536
+ interactable.enabled = sourceInteractable.enabled;
537
+ }
538
+ if (typeof sourceInteractable.grabbable === "boolean") {
539
+ interactable.grabbable = sourceInteractable.grabbable;
540
+ }
541
+ if (typeof sourceInteractable.pointable === "boolean") {
542
+ interactable.pointable = sourceInteractable.pointable;
543
+ }
544
+ if (typeof sourceInteractable.grabReach === "string") {
545
+ interactable.grabReach = sourceInteractable.grabReach;
546
+ }
547
+ if (typeof sourceInteractable.distanceBehavior === "string") {
548
+ interactable.distanceBehavior = sourceInteractable.distanceBehavior;
549
+ }
550
+ if (typeof sourceInteractable.grabGesture === "string") {
551
+ interactable.grabGesture = sourceInteractable.grabGesture;
552
+ }
553
+ if (typeof sourceInteractable.grabRadius === "number") {
554
+ interactable.grabRadius = sourceInteractable.grabRadius;
555
+ }
556
+ if (typeof sourceInteractable.grabHands === "string") {
557
+ interactable.grabHands = sourceInteractable.grabHands;
558
+ }
559
+ if (typeof sourceInteractable.twoHandRotation === "string") {
560
+ interactable.twoHandRotation = sourceInteractable.twoHandRotation;
561
+ }
562
+ if (typeof sourceInteractable.allowTwoHandScale === "boolean") {
563
+ interactable.allowTwoHandScale = sourceInteractable.allowTwoHandScale;
564
+ }
565
+ if (typeof sourceInteractable.minScale === "number") {
566
+ interactable.minScale = sourceInteractable.minScale;
567
+ }
568
+ if (typeof sourceInteractable.maxScale === "number") {
569
+ interactable.maxScale = sourceInteractable.maxScale;
570
+ }
571
+ if (Array.isArray(sourceInteractable.attachPoints)) {
572
+ interactable.attachPoints = sourceInteractable.attachPoints.map((point) => asRecord(point)).filter(
573
+ (point) => point !== null && typeof point.id === "string"
574
+ ).map(
575
+ (point) => createAttachPoint(
576
+ point
577
+ )
578
+ );
579
+ }
580
+ if (typeof sourceInteractable.applyVelocityOnRelease === "boolean") {
581
+ interactable.applyVelocityOnRelease = sourceInteractable.applyVelocityOnRelease;
582
+ } else if (typeof sourceInteractable.throwOnRelease === "boolean") {
583
+ interactable.applyVelocityOnRelease = sourceInteractable.throwOnRelease;
584
+ }
585
+ if (typeof sourceInteractable.velocityScale === "number") {
586
+ interactable.velocityScale = sourceInteractable.velocityScale;
587
+ } else if (typeof sourceInteractable.throwStrength === "number") {
588
+ interactable.velocityScale = sourceInteractable.throwStrength;
589
+ }
590
+ const grabPos = asRecord(sourceInteractable.grabOffsetPosition);
591
+ if (grabPos) {
592
+ interactable.grabOffsetPosition = {
593
+ x: typeof grabPos.x === "number" ? grabPos.x : 0,
594
+ y: typeof grabPos.y === "number" ? grabPos.y : 0,
595
+ z: typeof grabPos.z === "number" ? grabPos.z : 0
596
+ };
597
+ }
598
+ const grabRot = asRecord(sourceInteractable.grabOffsetRotation);
599
+ if (grabRot) {
600
+ interactable.grabOffsetRotation = {
601
+ x: typeof grabRot.x === "number" ? grabRot.x : 0,
602
+ y: typeof grabRot.y === "number" ? grabRot.y : 0,
603
+ z: typeof grabRot.z === "number" ? grabRot.z : 0
604
+ };
605
+ }
606
+ if (typeof sourceInteractable.hoverBehavior === "string") {
607
+ interactable.hoverBehavior = sourceInteractable.hoverBehavior;
608
+ } else if (sourceInteractable.highlightOnHover === false) {
609
+ interactable.hoverBehavior = "none";
610
+ }
611
+ if (typeof sourceInteractable.hoverColor === "string") {
612
+ interactable.hoverColor = sourceInteractable.hoverColor;
613
+ }
614
+ if (typeof sourceInteractable.hoverScale === "number") {
615
+ interactable.hoverScale = sourceInteractable.hoverScale;
616
+ }
617
+ }
618
+ }
619
+ {
620
+ const sourceHandPose = asRecord(
621
+ values.xrHandPoseValues.get(sourceEntityId)
622
+ );
623
+ let handPose = world.getComponent(targetEntityId, XRHandPoseComponent);
624
+ if (sourceHandPose && !handPose) {
625
+ handPose = new XRHandPoseComponent();
626
+ world.addComponent(targetEntityId, handPose);
627
+ }
628
+ if (sourceHandPose && handPose) {
629
+ if (typeof sourceHandPose.enabled === "boolean") {
630
+ handPose.enabled = sourceHandPose.enabled;
631
+ }
632
+ if (Array.isArray(sourceHandPose.poses)) {
633
+ handPose.poses = sourceHandPose.poses.map((entry) => asRecord(entry)).filter(
634
+ (entry) => entry !== null && typeof entry.id === "string"
635
+ ).map(
636
+ (entry) => createHandPoseEntry(
637
+ entry
638
+ )
639
+ );
640
+ }
641
+ }
642
+ }
643
+ {
644
+ const sourceAnchor = asRecord(values.xrAnchorValues.get(sourceEntityId));
645
+ let anchor = world.getComponent(targetEntityId, XRAnchorComponent);
646
+ if (sourceAnchor && !anchor) {
647
+ anchor = new XRAnchorComponent();
648
+ world.addComponent(targetEntityId, anchor);
649
+ }
650
+ if (sourceAnchor && anchor) {
651
+ if (typeof sourceAnchor.enabled === "boolean") {
652
+ anchor.enabled = sourceAnchor.enabled;
653
+ }
654
+ }
655
+ }
656
+ {
657
+ const source = asRecord(values.boneAttachmentValues.get(sourceEntityId));
658
+ if (source) {
659
+ let attachment = world.getComponent(targetEntityId, BoneAttachmentComponent);
660
+ if (!attachment) {
661
+ attachment = new BoneAttachmentComponent();
662
+ world.addComponent(targetEntityId, attachment);
663
+ }
664
+ if (typeof source.bone === "string") attachment.bone = source.bone;
665
+ if (typeof source.humanoid === "string" || source.humanoid === null) attachment.humanoid = source.humanoid;
666
+ if (typeof source.compensateScale === "boolean") attachment.compensateScale = source.compensateScale;
667
+ if (typeof source.enabled === "boolean") attachment.enabled = source.enabled;
668
+ }
669
+ }
670
+ if (values.networkIdentityValues.has(sourceEntityId) && !world.getComponent(targetEntityId, NetworkIdentityComponent)) {
671
+ world.addComponent(targetEntityId, new NetworkIdentityComponent());
672
+ }
673
+ {
674
+ const source = asRecord(values.networkTransformValues.get(sourceEntityId));
675
+ if (source) {
676
+ let net = world.getComponent(targetEntityId, NetworkTransformComponent);
677
+ if (!net) {
678
+ net = new NetworkTransformComponent();
679
+ world.addComponent(targetEntityId, net);
680
+ }
681
+ if (typeof source.enabled === "boolean") net.enabled = source.enabled;
682
+ if (typeof source.sendRate === "number") net.sendRate = source.sendRate;
683
+ if (typeof source.interpolationMs === "number") {
684
+ net.interpolationMs = source.interpolationMs;
685
+ }
686
+ if (typeof source.syncRotation === "boolean") {
687
+ net.syncRotation = source.syncRotation;
688
+ }
689
+ if (typeof source.teleportDistance === "number") {
690
+ net.teleportDistance = source.teleportDistance;
691
+ }
692
+ }
693
+ }
694
+ {
695
+ const source = asRecord(values.networkedPropsValues.get(sourceEntityId));
696
+ if (source) {
697
+ let props = world.getComponent(targetEntityId, NetworkedPropsComponent);
698
+ if (!props) {
699
+ props = new NetworkedPropsComponent();
700
+ world.addComponent(targetEntityId, props);
701
+ }
702
+ props.values = asRecord(source.values) ?? {};
703
+ }
704
+ }
705
+ {
706
+ const source = asRecord(values.networkSpawnerValues.get(sourceEntityId));
707
+ if (source) {
708
+ let spawner = world.getComponent(targetEntityId, NetworkSpawnerComponent);
709
+ if (!spawner) {
710
+ spawner = new NetworkSpawnerComponent();
711
+ world.addComponent(targetEntityId, spawner);
712
+ }
713
+ if (typeof source.playerPrefab === "string") {
714
+ spawner.playerPrefab = source.playerPrefab;
715
+ }
716
+ if (typeof source.spawnRadius === "number") {
717
+ spawner.spawnRadius = source.spawnRadius;
718
+ }
719
+ }
720
+ }
721
+ {
722
+ const source = asRecord(values.ikValues.get(sourceEntityId));
723
+ if (source) {
724
+ let ik = world.getComponent(targetEntityId, IKComponent);
725
+ if (!ik) {
726
+ ik = new IKComponent();
727
+ world.addComponent(targetEntityId, ik);
728
+ }
729
+ if (typeof source.enabled === "boolean") ik.enabled = source.enabled;
730
+ if (Array.isArray(source.chains)) {
731
+ const mapId = /* @__PURE__ */ __name((v) => typeof v === "number" ? idMap.get(v) ?? v : null, "mapId");
732
+ ik.chains = source.chains.map((raw) => asRecord(raw)).filter((c) => !!c && typeof c.limb === "string").map(
733
+ (c) => normalizeIKChain({
734
+ ...c,
735
+ limb: c.limb,
736
+ target: mapId(c.target),
737
+ pole: mapId(c.pole)
738
+ })
739
+ );
740
+ }
741
+ }
742
+ }
743
+ {
744
+ const restoreUi = /* @__PURE__ */ __name((map, Ctor, existing) => {
745
+ const source = asRecord(map.get(sourceEntityId));
746
+ if (!source) return;
747
+ let component = existing;
748
+ if (!component) {
749
+ component = new Ctor();
750
+ world.addComponent(targetEntityId, component);
751
+ }
752
+ const target = component;
753
+ for (const [key, value] of Object.entries(source)) {
754
+ const current = target[key];
755
+ if (key === "style") {
756
+ const style = normalizeUiStyle(value);
757
+ if (style) target.style = style;
758
+ continue;
759
+ }
760
+ if (key === "tokens") {
761
+ const tokens = normalizeUiTokens(value);
762
+ if (tokens) target.tokens = tokens;
763
+ continue;
764
+ }
765
+ if (OPTIONAL_UI_FIELDS[key] === typeof value) {
766
+ target[key] = value;
767
+ continue;
768
+ }
769
+ if ((typeof value === "string" || typeof value === "number" || typeof value === "boolean") && typeof current === typeof value) {
770
+ target[key] = value;
771
+ }
772
+ }
773
+ }, "restoreUi");
774
+ restoreUi(
775
+ values.uiPanelValues,
776
+ UIPanelComponent,
777
+ world.getComponent(targetEntityId, UIPanelComponent)
778
+ );
779
+ restoreUi(
780
+ values.uiTextValues,
781
+ UITextComponent,
782
+ world.getComponent(targetEntityId, UITextComponent)
783
+ );
784
+ restoreUi(
785
+ values.uiButtonValues,
786
+ UIButtonComponent,
787
+ world.getComponent(targetEntityId, UIButtonComponent)
788
+ );
789
+ restoreUi(
790
+ values.uiToggleValues,
791
+ UIToggleComponent,
792
+ world.getComponent(targetEntityId, UIToggleComponent)
793
+ );
794
+ restoreUi(
795
+ values.uiSliderValues,
796
+ UISliderComponent,
797
+ world.getComponent(targetEntityId, UISliderComponent)
798
+ );
799
+ }
800
+ {
801
+ const sourceInteractor = asRecord(
802
+ values.xrInteractorValues.get(sourceEntityId)
803
+ );
804
+ const interactor = world.getComponent(targetEntityId, XRInteractorComponent);
805
+ if (sourceInteractor && interactor) {
806
+ if (typeof sourceInteractor.interactorType === "string") {
807
+ interactor.interactorType = sourceInteractor.interactorType;
808
+ }
809
+ if (typeof sourceInteractor.handPreset === "string") {
810
+ interactor.handPreset = sourceInteractor.handPreset;
811
+ }
812
+ if (typeof sourceInteractor.handColor === "string") {
813
+ interactor.handColor = sourceInteractor.handColor;
814
+ }
815
+ if (typeof sourceInteractor.handOpacity === "number") {
816
+ interactor.handOpacity = sourceInteractor.handOpacity;
817
+ }
818
+ if (typeof sourceInteractor.handEmissiveIntensity === "number") {
819
+ interactor.handEmissiveIntensity = sourceInteractor.handEmissiveIntensity;
820
+ }
821
+ if (typeof sourceInteractor.rayVisibility === "string") {
822
+ interactor.rayVisibility = sourceInteractor.rayVisibility;
823
+ } else if (typeof sourceInteractor.showRay === "boolean") {
824
+ interactor.rayVisibility = sourceInteractor.showRay ? "interacting" : "never";
825
+ }
826
+ if (typeof sourceInteractor.rayColor === "string") {
827
+ interactor.rayColor = sourceInteractor.rayColor;
828
+ }
829
+ if (typeof sourceInteractor.rayThickness === "number") {
830
+ interactor.rayThickness = sourceInteractor.rayThickness;
831
+ }
832
+ }
833
+ }
834
+ {
835
+ const sourceSide = asRecord(
836
+ values.xrInteractorSideValues.get(sourceEntityId)
837
+ );
838
+ if (sourceSide && typeof sourceSide.side === "string") {
839
+ const existing = world.getComponent(
840
+ targetEntityId,
841
+ XRInteractorSideComponent
842
+ );
843
+ if (existing) {
844
+ existing.side = sourceSide.side;
845
+ } else {
846
+ world.addComponent(
847
+ targetEntityId,
848
+ new XRInteractorSideComponent({
849
+ side: sourceSide.side
850
+ })
851
+ );
852
+ }
853
+ }
854
+ }
855
+ {
856
+ const sourceRigOrigin = asRecord(values.xrRigValues.get(sourceEntityId));
857
+ const rigForOrigin = world.getComponent(targetEntityId, XRRigComponent);
858
+ if (sourceRigOrigin && rigForOrigin && typeof sourceRigOrigin.trackingOrigin === "string") {
859
+ rigForOrigin.trackingOrigin = sourceRigOrigin.trackingOrigin;
860
+ }
861
+ }
862
+ {
863
+ const imComponent = world.getComponent(targetEntityId, InstancedMeshComponent);
864
+ if (imComponent && imComponent.instanceEntityIds.length > 0) {
865
+ imComponent.instanceEntityIds = imComponent.instanceEntityIds.map(
866
+ (oldId) => idMap.get(oldId) ?? oldId
867
+ );
868
+ }
869
+ }
870
+ {
871
+ const slotComponent = world.getComponent(targetEntityId, InstanceSlotComponent);
872
+ if (slotComponent && slotComponent.groupEntityId !== -1) {
873
+ slotComponent.groupEntityId = idMap.get(slotComponent.groupEntityId) ?? slotComponent.groupEntityId;
874
+ }
875
+ }
876
+ }
877
+ __name(restorePostCreateComponents, "restorePostCreateComponents");
878
+
879
+ // core/hydration/animation.ts
880
+ function readAnimationClipName(value) {
881
+ if (typeof value === "string") {
882
+ return value;
883
+ }
884
+ const record = asRecord(value);
885
+ if (!record) {
886
+ return null;
887
+ }
888
+ if (typeof record.name === "string") {
889
+ return record.name;
890
+ }
891
+ return null;
892
+ }
893
+ __name(readAnimationClipName, "readAnimationClipName");
894
+ function readAnimationStates(value) {
895
+ if (!Array.isArray(value)) {
896
+ return [];
897
+ }
898
+ const states = [];
899
+ for (const entry of value) {
900
+ const state = asRecord(entry);
901
+ if (!state) {
902
+ continue;
903
+ }
904
+ const name = typeof state.name === "string" ? state.name : null;
905
+ const clip = readAnimationClipName(state.clip);
906
+ if (!name || !clip) {
907
+ continue;
908
+ }
909
+ states.push({
910
+ name,
911
+ clip,
912
+ clipId: typeof state.clipId === "string" ? state.clipId : void 0,
913
+ loop: typeof state.loop === "boolean" ? state.loop : false
914
+ });
915
+ }
916
+ return states;
917
+ }
918
+ __name(readAnimationStates, "readAnimationStates");
919
+ function readAnimationClipSources(value) {
920
+ if (!Array.isArray(value)) {
921
+ return [];
922
+ }
923
+ const seen = /* @__PURE__ */ new Set();
924
+ const sources = [];
925
+ for (const entry of value) {
926
+ if (typeof entry !== "string") {
927
+ continue;
928
+ }
929
+ const trimmed = entry.trim();
930
+ if (!trimmed || seen.has(trimmed)) {
931
+ continue;
932
+ }
933
+ seen.add(trimmed);
934
+ sources.push(trimmed);
935
+ }
936
+ return sources;
937
+ }
938
+ __name(readAnimationClipSources, "readAnimationClipSources");
939
+ function toAnimationOptions(sourceAnimation) {
940
+ const paused = readBoolean(sourceAnimation.paused);
941
+ const reverse = readBoolean(sourceAnimation.reverse);
942
+ const timeScale = readNumber(sourceAnimation.timeScale);
943
+ const crossFadeDuration = readNumber(sourceAnimation.crossFadeDuration);
944
+ const states = readAnimationStates(sourceAnimation.states);
945
+ const externalClipSources = readAnimationClipSources(
946
+ sourceAnimation.externalClipSources
947
+ );
948
+ const activeStateName = typeof sourceAnimation.activeStateName === "string" ? sourceAnimation.activeStateName : typeof sourceAnimation.activeState === "string" ? sourceAnimation.activeState : typeof sourceAnimation.active?.name === "string" ? sourceAnimation.active.name ?? null : null;
949
+ return {
950
+ paused,
951
+ reverse,
952
+ timeScale,
953
+ crossFadeDuration,
954
+ states,
955
+ externalClipSources,
956
+ activeState: activeStateName
957
+ };
958
+ }
959
+ __name(toAnimationOptions, "toAnimationOptions");
960
+ function restoreAnimationComponent(world, objectManagementSystem, targetEntityId, sourceAnimation) {
961
+ const options = toAnimationOptions(sourceAnimation);
962
+ let animation = world.getComponent(targetEntityId, AnimationComponent);
963
+ if (!animation) {
964
+ objectManagementSystem.createComponentNow(
965
+ "animation",
966
+ world,
967
+ targetEntityId,
968
+ options
969
+ );
970
+ animation = world.getComponent(targetEntityId, AnimationComponent);
971
+ }
972
+ if (!animation) {
973
+ return;
974
+ }
975
+ const availableClips = Array.isArray(sourceAnimation.availableClips) ? sourceAnimation.availableClips.filter(
976
+ (clip) => typeof clip === "string" && clip.length > 0
977
+ ) : [];
978
+ if (availableClips.length > 0) {
979
+ animation.availableClips = [...availableClips];
980
+ }
981
+ if (Array.isArray(options.externalClipSources)) {
982
+ animation.setExternalClipSources(options.externalClipSources);
983
+ }
984
+ const states = options.states ?? [];
985
+ const hasClips = Array.isArray(animation.clips) && animation.clips.length > 0;
986
+ if (!hasClips) {
987
+ animation.__pendingHydratedOptions = options;
988
+ if (typeof options.reverse === "boolean") {
989
+ animation.reverse = options.reverse;
990
+ }
991
+ if (typeof options.timeScale === "number") {
992
+ animation.timeScale = options.timeScale;
993
+ }
994
+ if (typeof options.crossFadeDuration === "number") {
995
+ animation.crossFadeDuration = options.crossFadeDuration;
996
+ }
997
+ if (typeof options.paused === "boolean") {
998
+ animation.paused = options.paused;
999
+ }
1000
+ return;
1001
+ }
1002
+ if (states.length > 0) {
1003
+ animation.setStates(states);
1004
+ }
1005
+ if (typeof options.reverse === "boolean") {
1006
+ animation.reverse = options.reverse;
1007
+ }
1008
+ if (typeof options.timeScale === "number") {
1009
+ animation.timeScale = options.timeScale;
1010
+ }
1011
+ if (typeof options.crossFadeDuration === "number") {
1012
+ animation.crossFadeDuration = options.crossFadeDuration;
1013
+ }
1014
+ if (typeof options.activeState === "string" && options.activeState.length > 0) {
1015
+ animation.setActiveState(options.activeState, !options.paused);
1016
+ }
1017
+ if (typeof options.paused === "boolean") {
1018
+ if (options.paused) {
1019
+ animation.pauseState();
1020
+ } else if (typeof options.activeState === "string" && options.activeState.length > 0) {
1021
+ animation.playState(options.activeState);
1022
+ }
1023
+ }
1024
+ }
1025
+ __name(restoreAnimationComponent, "restoreAnimationComponent");
1026
+
1027
+ // core/hydration/restoreComponentState.ts
1028
+ function readEnvironmentState(value) {
1029
+ const record = asRecord(value);
1030
+ if (!record) {
1031
+ return null;
1032
+ }
1033
+ const nestedValues = asRecord(record.values);
1034
+ if (nestedValues) {
1035
+ return nestedValues;
1036
+ }
1037
+ return record;
1038
+ }
1039
+ __name(readEnvironmentState, "readEnvironmentState");
1040
+ function readPostprocessingState(value) {
1041
+ const record = asRecord(value);
1042
+ if (!record) {
1043
+ return null;
1044
+ }
1045
+ const nestedValues = asRecord(record.values);
1046
+ if (nestedValues) {
1047
+ return nestedValues;
1048
+ }
1049
+ return record;
1050
+ }
1051
+ __name(readPostprocessingState, "readPostprocessingState");
1052
+ function restoreComponentState(world, objectManagementSystem, targetEntityId, sourceEntityId, entityType, values) {
1053
+ const sourceName = readString(values.nameValues.get(sourceEntityId));
1054
+ if (sourceName !== null) {
1055
+ const nameComponent = world.getComponent(targetEntityId, Name);
1056
+ if (nameComponent) {
1057
+ nameComponent.value = sourceName;
1058
+ }
1059
+ }
1060
+ const sourceObject3DRef = asRecord(values.object3DRefValues.get(sourceEntityId));
1061
+ if (sourceObject3DRef) {
1062
+ const object3DRefComponent = world.getComponent(targetEntityId, Object3DRef);
1063
+ const visibility = readBoolean(sourceObject3DRef.visibility);
1064
+ if (object3DRefComponent && typeof visibility === "boolean") {
1065
+ object3DRefComponent.visibility = visibility;
1066
+ }
1067
+ }
1068
+ const sourceTransform = readTransform(values.transformValues.get(sourceEntityId));
1069
+ if (sourceTransform) {
1070
+ const transformComponent = world.getComponent(targetEntityId, TransformComponent);
1071
+ if (transformComponent) {
1072
+ if (typeof sourceTransform.position?.x === "number") {
1073
+ transformComponent.position.x = sourceTransform.position.x;
1074
+ }
1075
+ if (typeof sourceTransform.position?.y === "number") {
1076
+ transformComponent.position.y = sourceTransform.position.y;
1077
+ }
1078
+ if (typeof sourceTransform.position?.z === "number") {
1079
+ transformComponent.position.z = sourceTransform.position.z;
1080
+ }
1081
+ if (typeof sourceTransform.rotation?.x === "number") {
1082
+ transformComponent.rotation.x = sourceTransform.rotation.x;
1083
+ }
1084
+ if (typeof sourceTransform.rotation?.y === "number") {
1085
+ transformComponent.rotation.y = sourceTransform.rotation.y;
1086
+ }
1087
+ if (typeof sourceTransform.rotation?.z === "number") {
1088
+ transformComponent.rotation.z = sourceTransform.rotation.z;
1089
+ }
1090
+ if (typeof sourceTransform.scale?.x === "number") {
1091
+ transformComponent.scale.x = sourceTransform.scale.x;
1092
+ }
1093
+ if (typeof sourceTransform.scale?.y === "number") {
1094
+ transformComponent.scale.y = sourceTransform.scale.y;
1095
+ }
1096
+ if (typeof sourceTransform.scale?.z === "number") {
1097
+ transformComponent.scale.z = sourceTransform.scale.z;
1098
+ }
1099
+ }
1100
+ }
1101
+ const sourceModel = asRecord(values.modelValues.get(sourceEntityId));
1102
+ if (sourceModel) {
1103
+ const modelComponent = world.getComponent(targetEntityId, ModelComponent);
1104
+ if (modelComponent && typeof sourceModel.path === "string") {
1105
+ modelComponent.path = sourceModel.path;
1106
+ }
1107
+ }
1108
+ const sourceImage = asRecord(values.imageValues.get(sourceEntityId));
1109
+ if (sourceImage) {
1110
+ const imageComponent = world.getComponent(targetEntityId, ImageComponent);
1111
+ if (imageComponent) {
1112
+ if (typeof sourceImage.path === "string") {
1113
+ imageComponent.path = sourceImage.path;
1114
+ }
1115
+ const width = readNumber(sourceImage.width);
1116
+ if (typeof width === "number") {
1117
+ imageComponent.width = width;
1118
+ }
1119
+ const height = readNumber(sourceImage.height);
1120
+ if (typeof height === "number") {
1121
+ imageComponent.height = height;
1122
+ }
1123
+ }
1124
+ }
1125
+ const sourceSprite = asRecord(values.spriteValues.get(sourceEntityId));
1126
+ if (sourceSprite) {
1127
+ const spriteComponent = world.getComponent(targetEntityId, SpriteComponent);
1128
+ if (spriteComponent) {
1129
+ if (typeof sourceSprite.path === "string") {
1130
+ spriteComponent.path = sourceSprite.path;
1131
+ }
1132
+ const width = readNumber(sourceSprite.width);
1133
+ if (typeof width === "number") {
1134
+ spriteComponent.width = width;
1135
+ }
1136
+ const height = readNumber(sourceSprite.height);
1137
+ if (typeof height === "number") {
1138
+ spriteComponent.height = height;
1139
+ }
1140
+ }
1141
+ }
1142
+ const sourceVideo = asRecord(values.videoValues.get(sourceEntityId));
1143
+ if (sourceVideo) {
1144
+ const videoComponent = world.getComponent(targetEntityId, VideoComponent);
1145
+ if (videoComponent) {
1146
+ if (typeof sourceVideo.path === "string") {
1147
+ videoComponent.path = sourceVideo.path;
1148
+ }
1149
+ const videoOptions = asRecord(sourceVideo.options);
1150
+ if (videoOptions) {
1151
+ videoComponent.options = {
1152
+ ...videoComponent.options,
1153
+ ...videoOptions
1154
+ };
1155
+ }
1156
+ }
1157
+ }
1158
+ const sourceAudio = asRecord(values.audioValues.get(sourceEntityId));
1159
+ if (sourceAudio && entityType === "audio") {
1160
+ const audioComponent = world.getComponent(targetEntityId, AudioComponent);
1161
+ if (audioComponent) {
1162
+ if (typeof sourceAudio.path === "string") {
1163
+ audioComponent.path = sourceAudio.path;
1164
+ }
1165
+ const audioOptions = asRecord(sourceAudio.options);
1166
+ if (audioOptions) {
1167
+ audioComponent.options = {
1168
+ ...audioComponent.options,
1169
+ ...audioOptions
1170
+ };
1171
+ }
1172
+ }
1173
+ }
1174
+ const sourceCamera = asRecord(values.cameraValues.get(sourceEntityId));
1175
+ if (sourceCamera) {
1176
+ const cameraComponent = world.getComponent(targetEntityId, CameraComponent);
1177
+ if (cameraComponent) {
1178
+ if (sourceCamera.projection === "orthographic" || sourceCamera.projection === "perspective") {
1179
+ cameraComponent.projection = sourceCamera.projection;
1180
+ }
1181
+ if (sourceCamera.type === "3d" || sourceCamera.type === "ar") {
1182
+ cameraComponent.type = sourceCamera.type;
1183
+ }
1184
+ if (typeof sourceCamera.isDefault === "boolean") {
1185
+ cameraComponent.isDefault = sourceCamera.isDefault;
1186
+ }
1187
+ const fov = readNumber(sourceCamera.fov);
1188
+ if (typeof fov === "number") {
1189
+ cameraComponent.fov = fov;
1190
+ }
1191
+ const near = readNumber(sourceCamera.near);
1192
+ if (typeof near === "number") {
1193
+ cameraComponent.near = near;
1194
+ }
1195
+ const far = readNumber(sourceCamera.far);
1196
+ if (typeof far === "number") {
1197
+ cameraComponent.far = far;
1198
+ }
1199
+ const left = readNumber(sourceCamera.left);
1200
+ if (typeof left === "number") {
1201
+ cameraComponent.left = left;
1202
+ }
1203
+ const right = readNumber(sourceCamera.right);
1204
+ if (typeof right === "number") {
1205
+ cameraComponent.right = right;
1206
+ }
1207
+ const top = readNumber(sourceCamera.top);
1208
+ if (typeof top === "number") {
1209
+ cameraComponent.top = top;
1210
+ }
1211
+ const bottom = readNumber(sourceCamera.bottom);
1212
+ if (typeof bottom === "number") {
1213
+ cameraComponent.bottom = bottom;
1214
+ }
1215
+ const zoom = readNumber(sourceCamera.zoom);
1216
+ if (typeof zoom === "number") {
1217
+ cameraComponent.zoom = zoom;
1218
+ }
1219
+ }
1220
+ }
1221
+ const sourceEnvironment = readEnvironmentState(
1222
+ values.environmentValues.get(sourceEntityId)
1223
+ );
1224
+ if (sourceEnvironment) {
1225
+ let environmentComponent = world.getComponent(targetEntityId, Environment);
1226
+ if (!environmentComponent) {
1227
+ objectManagementSystem.createComponentNow(
1228
+ "environment",
1229
+ world,
1230
+ targetEntityId,
1231
+ sourceEnvironment
1232
+ );
1233
+ environmentComponent = world.getComponent(targetEntityId, Environment);
1234
+ }
1235
+ if (environmentComponent) {
1236
+ environmentComponent.values = new Environment({
1237
+ ...environmentComponent.values,
1238
+ ...sourceEnvironment
1239
+ }).values;
1240
+ }
1241
+ }
1242
+ const sourcePostprocessing = readPostprocessingState(
1243
+ values.postprocessingValues.get(sourceEntityId)
1244
+ );
1245
+ if (sourcePostprocessing) {
1246
+ let postprocessingComponent = world.getComponent(targetEntityId, Postprocessing);
1247
+ if (!postprocessingComponent) {
1248
+ objectManagementSystem.createComponentNow(
1249
+ "postprocessing",
1250
+ world,
1251
+ targetEntityId,
1252
+ sourcePostprocessing
1253
+ );
1254
+ postprocessingComponent = world.getComponent(targetEntityId, Postprocessing);
1255
+ }
1256
+ if (postprocessingComponent) {
1257
+ postprocessingComponent.values = new Postprocessing({
1258
+ ...postprocessingComponent.values,
1259
+ ...sourcePostprocessing
1260
+ }).values;
1261
+ }
1262
+ }
1263
+ const sourceImageTarget = asRecord(values.imageTargetValues.get(sourceEntityId));
1264
+ if (sourceImageTarget && entityType === "imageTarget") {
1265
+ const imageTargetComponent = world.getComponent(targetEntityId, ImageTarget);
1266
+ if (imageTargetComponent) {
1267
+ imageTargetComponent.targets = Array.isArray(sourceImageTarget.targets) ? sourceImageTarget.targets : [];
1268
+ imageTargetComponent.compiledTargetUrl = typeof sourceImageTarget.compiledTargetUrl === "string" ? sourceImageTarget.compiledTargetUrl : void 0;
1269
+ imageTargetComponent.compiledTargetDir = typeof sourceImageTarget.compiledTargetDir === "string" ? sourceImageTarget.compiledTargetDir : void 0;
1270
+ }
1271
+ }
1272
+ const sourceLight = asRecord(values.lightValues.get(sourceEntityId));
1273
+ if (sourceLight) {
1274
+ const lightComponent = world.getComponent(targetEntityId, LightComponent);
1275
+ const sourceValues = asRecord(sourceLight.values);
1276
+ if (lightComponent && sourceValues) {
1277
+ lightComponent.values = {
1278
+ ...lightComponent.values,
1279
+ ...sourceValues
1280
+ };
1281
+ }
1282
+ }
1283
+ const sourceMaterial = asRecord(values.materialValues.get(sourceEntityId));
1284
+ if (sourceMaterial) {
1285
+ const materialComponent = world.getComponent(targetEntityId, MaterialComponent);
1286
+ const sourceValues = sourceMaterial.values;
1287
+ if (materialComponent && Array.isArray(sourceValues)) {
1288
+ materialComponent.values = sourceValues;
1289
+ }
1290
+ const sourceAssetRefs = sourceMaterial.assetRefs;
1291
+ if (materialComponent && Array.isArray(sourceAssetRefs)) {
1292
+ materialComponent.assetRefs = sourceAssetRefs;
1293
+ }
1294
+ }
1295
+ const sourceMeshGeometry = asRecord(values.meshGeometryValues.get(sourceEntityId));
1296
+ if (sourceMeshGeometry) {
1297
+ const meshGeometryComponent = world.getComponent(
1298
+ targetEntityId,
1299
+ MeshGeometryComponent
1300
+ );
1301
+ if (meshGeometryComponent) {
1302
+ const parameters = asRecord(sourceMeshGeometry.parameters);
1303
+ if (parameters) {
1304
+ meshGeometryComponent.parameters = parameters;
1305
+ }
1306
+ if (typeof sourceMeshGeometry.modelName === "string") {
1307
+ meshGeometryComponent.modelName = sourceMeshGeometry.modelName;
1308
+ }
1309
+ if (typeof sourceMeshGeometry.castShadow === "boolean") {
1310
+ meshGeometryComponent.castShadow = sourceMeshGeometry.castShadow;
1311
+ }
1312
+ if (typeof sourceMeshGeometry.receiveShadow === "boolean") {
1313
+ meshGeometryComponent.receiveShadow = sourceMeshGeometry.receiveShadow;
1314
+ }
1315
+ }
1316
+ }
1317
+ const sourceSelectable = asRecord(values.selectableValues.get(sourceEntityId));
1318
+ if (sourceSelectable) {
1319
+ const enabled = readBoolean(sourceSelectable.enabled);
1320
+ let selectable = world.getComponent(targetEntityId, Selectable);
1321
+ if (!selectable) {
1322
+ objectManagementSystem.createComponentNow(
1323
+ "selectable",
1324
+ world,
1325
+ targetEntityId,
1326
+ enabled ?? true
1327
+ );
1328
+ selectable = world.getComponent(targetEntityId, Selectable);
1329
+ }
1330
+ if (selectable && typeof enabled === "boolean") {
1331
+ selectable.enabled = enabled;
1332
+ }
1333
+ }
1334
+ const sourcePhysics = asRecord(values.physicsValues.get(sourceEntityId));
1335
+ if (sourcePhysics) {
1336
+ const physicsValues = asRecord(sourcePhysics.values) ?? sourcePhysics;
1337
+ let physics = world.getComponent(targetEntityId, PhysicsComponent);
1338
+ if (!physics) {
1339
+ objectManagementSystem.createComponentNow(
1340
+ "physics",
1341
+ world,
1342
+ targetEntityId,
1343
+ physicsValues
1344
+ );
1345
+ physics = world.getComponent(targetEntityId, PhysicsComponent);
1346
+ }
1347
+ if (physics) {
1348
+ physics.setValues({
1349
+ rigidbody: asRecord(physicsValues.rigidbody) ?? {},
1350
+ collider: asRecord(physicsValues.collider) ?? {}
1351
+ });
1352
+ }
1353
+ }
1354
+ const sourceAnimation = asRecord(values.animationValues.get(sourceEntityId));
1355
+ if (sourceAnimation) {
1356
+ restoreAnimationComponent(
1357
+ world,
1358
+ objectManagementSystem,
1359
+ targetEntityId,
1360
+ sourceAnimation
1361
+ );
1362
+ }
1363
+ const sourceInstancedMesh = asRecord(values.instancedMeshValues.get(sourceEntityId));
1364
+ if (sourceInstancedMesh) {
1365
+ const imComponent = world.getComponent(targetEntityId, InstancedMeshComponent);
1366
+ if (imComponent) {
1367
+ if (typeof sourceInstancedMesh.meshKind === "string") {
1368
+ imComponent.meshKind = sourceInstancedMesh.meshKind;
1369
+ }
1370
+ if (typeof sourceInstancedMesh.modelPath === "string") {
1371
+ imComponent.modelPath = sourceInstancedMesh.modelPath;
1372
+ }
1373
+ const parameters = asRecord(sourceInstancedMesh.meshParameters);
1374
+ if (parameters) {
1375
+ imComponent.meshParameters = parameters;
1376
+ }
1377
+ if (typeof sourceInstancedMesh.castShadow === "boolean") {
1378
+ imComponent.castShadow = sourceInstancedMesh.castShadow;
1379
+ }
1380
+ if (typeof sourceInstancedMesh.receiveShadow === "boolean") {
1381
+ imComponent.receiveShadow = sourceInstancedMesh.receiveShadow;
1382
+ }
1383
+ if (Array.isArray(sourceInstancedMesh.instanceEntityIds)) {
1384
+ imComponent.instanceEntityIds = sourceInstancedMesh.instanceEntityIds;
1385
+ }
1386
+ imComponent.instancedMesh = null;
1387
+ }
1388
+ }
1389
+ const sourceInstanceSlot = asRecord(values.instanceSlotValues.get(sourceEntityId));
1390
+ if (sourceInstanceSlot) {
1391
+ const slotComponent = world.getComponent(targetEntityId, InstanceSlotComponent);
1392
+ if (slotComponent) {
1393
+ if (typeof sourceInstanceSlot.slotIndex === "number") {
1394
+ slotComponent.slotIndex = sourceInstanceSlot.slotIndex;
1395
+ }
1396
+ }
1397
+ }
1398
+ const sourcePrefabNode = asRecord(values.prefabNodeValues.get(sourceEntityId));
1399
+ if (sourcePrefabNode && typeof sourcePrefabNode.nodeId === "string") {
1400
+ if (!world.getComponent(targetEntityId, PrefabNode)) {
1401
+ world.addComponent(targetEntityId, new PrefabNode(sourcePrefabNode.nodeId));
1402
+ }
1403
+ }
1404
+ const sourcePrefabInstance = asRecord(
1405
+ values.prefabInstanceValues.get(sourceEntityId)
1406
+ );
1407
+ if (sourcePrefabInstance && typeof sourcePrefabInstance.url === "string") {
1408
+ if (!world.getComponent(targetEntityId, PrefabInstance)) {
1409
+ const overrides = Array.isArray(sourcePrefabInstance.overrides) ? sourcePrefabInstance.overrides.filter(
1410
+ (entry) => typeof entry === "string"
1411
+ ) : [];
1412
+ world.addComponent(
1413
+ targetEntityId,
1414
+ new PrefabInstance(
1415
+ sourcePrefabInstance.url,
1416
+ overrides,
1417
+ // Preserve the placement identity; the constructor generates a
1418
+ // fresh one for legacy snapshots that predate instanceId.
1419
+ typeof sourcePrefabInstance.instanceId === "string" && sourcePrefabInstance.instanceId.length > 0 ? sourcePrefabInstance.instanceId : void 0
1420
+ )
1421
+ );
1422
+ }
1423
+ }
1424
+ }
1425
+ __name(restoreComponentState, "restoreComponentState");
1426
+
1427
+ // core/hydration/types.ts
1428
+ var HYDRATABLE_ENTITY_KINDS = /* @__PURE__ */ new Set([
1429
+ "cube",
1430
+ "sphere",
1431
+ "plane",
1432
+ "capsule",
1433
+ "cylinder",
1434
+ "empty",
1435
+ "model",
1436
+ "image",
1437
+ "imageTarget",
1438
+ "sprite",
1439
+ "audio",
1440
+ "camera",
1441
+ "video",
1442
+ "ambientLight",
1443
+ "directionalLight",
1444
+ "pointLight",
1445
+ "spotLight",
1446
+ "areaLight",
1447
+ "instancedMesh",
1448
+ "instanceSlot",
1449
+ "scriptObject",
1450
+ "xrRig",
1451
+ "xrInteractor",
1452
+ "teleportArea",
1453
+ "uiPanel",
1454
+ "uiText",
1455
+ "uiButton",
1456
+ "uiToggle",
1457
+ "uiSlider"
1458
+ ]);
1459
+
1460
+ // core/hydration/parentLinks.ts
1461
+ function applyParentLinks(snapshot, idMap, objectManagementSystem, world) {
1462
+ const parentValues = readByComponent(snapshot.components, "ParentId");
1463
+ for (const [sourceEntityId, parentValue] of parentValues.entries()) {
1464
+ const targetEntityId = idMap.get(sourceEntityId);
1465
+ if (targetEntityId === void 0) {
1466
+ continue;
1467
+ }
1468
+ const parentRecord = asRecord(parentValue);
1469
+ const sourceParentId = parentRecord && typeof parentRecord.value === "number" ? parentRecord.value : null;
1470
+ if (sourceParentId === null) {
1471
+ objectManagementSystem.setParent(world, targetEntityId, null, {
1472
+ preserveWorldTransform: false
1473
+ });
1474
+ continue;
1475
+ }
1476
+ const mappedParentId = idMap.get(sourceParentId);
1477
+ objectManagementSystem.setParent(world, targetEntityId, mappedParentId ?? null, {
1478
+ preserveWorldTransform: false
1479
+ });
1480
+ }
1481
+ }
1482
+ __name(applyParentLinks, "applyParentLinks");
1483
+
1484
+ // core/hydration/hydrateWorld.ts
1485
+ function buildEntityCreationPayload(sourceEntityId, kind, componentValues) {
1486
+ const payload = {
1487
+ name: readString(componentValues.nameValues.get(sourceEntityId)) ?? void 0,
1488
+ transform: readTransform(componentValues.transformValues.get(sourceEntityId))
1489
+ };
1490
+ if (kind === "model") {
1491
+ const model = asRecord(componentValues.modelValues.get(sourceEntityId));
1492
+ if (typeof model?.path === "string") {
1493
+ payload.path = model.path;
1494
+ }
1495
+ }
1496
+ if (kind === "image") {
1497
+ const image = asRecord(componentValues.imageValues.get(sourceEntityId));
1498
+ if (typeof image?.path === "string") {
1499
+ payload.path = image.path;
1500
+ }
1501
+ }
1502
+ if (kind === "sprite") {
1503
+ const sprite = asRecord(componentValues.spriteValues.get(sourceEntityId));
1504
+ if (typeof sprite?.path === "string") {
1505
+ payload.path = sprite.path;
1506
+ }
1507
+ }
1508
+ if (kind === "video") {
1509
+ const video = asRecord(componentValues.videoValues.get(sourceEntityId));
1510
+ if (typeof video?.path === "string") {
1511
+ payload.path = video.path;
1512
+ }
1513
+ const videoOptions = asRecord(video?.options);
1514
+ if (videoOptions) {
1515
+ payload.options = videoOptions;
1516
+ }
1517
+ }
1518
+ if (kind === "audio") {
1519
+ const audio = asRecord(componentValues.audioValues.get(sourceEntityId));
1520
+ if (typeof audio?.path === "string") {
1521
+ payload.path = audio.path;
1522
+ }
1523
+ const audioOptions = asRecord(audio?.options);
1524
+ if (audioOptions) {
1525
+ payload.options = audioOptions;
1526
+ }
1527
+ }
1528
+ if (kind === "camera") {
1529
+ const camera = asRecord(componentValues.cameraValues.get(sourceEntityId));
1530
+ if (camera) {
1531
+ const projection = camera.projection === "orthographic" || camera.projection === "perspective" ? camera.projection : void 0;
1532
+ const type = camera.type === "3d" || camera.type === "ar" ? camera.type : void 0;
1533
+ payload.options = {
1534
+ isDefault: typeof camera.isDefault === "boolean" ? camera.isDefault : void 0,
1535
+ projection,
1536
+ type,
1537
+ fov: typeof camera.fov === "number" ? camera.fov : void 0,
1538
+ near: typeof camera.near === "number" ? camera.near : void 0,
1539
+ far: typeof camera.far === "number" ? camera.far : void 0,
1540
+ left: typeof camera.left === "number" ? camera.left : void 0,
1541
+ right: typeof camera.right === "number" ? camera.right : void 0,
1542
+ top: typeof camera.top === "number" ? camera.top : void 0,
1543
+ bottom: typeof camera.bottom === "number" ? camera.bottom : void 0,
1544
+ zoom: typeof camera.zoom === "number" ? camera.zoom : void 0
1545
+ };
1546
+ }
1547
+ }
1548
+ if (kind === "imageTarget") {
1549
+ const imageTarget = asRecord(componentValues.imageTargetValues.get(sourceEntityId));
1550
+ if (imageTarget) {
1551
+ payload.options = {
1552
+ targets: Array.isArray(imageTarget.targets) ? imageTarget.targets : [],
1553
+ compiledTargetUrl: typeof imageTarget.compiledTargetUrl === "string" ? imageTarget.compiledTargetUrl : void 0,
1554
+ compiledTargetDir: typeof imageTarget.compiledTargetDir === "string" ? imageTarget.compiledTargetDir : void 0
1555
+ };
1556
+ }
1557
+ }
1558
+ if (kind === "instancedMesh") {
1559
+ const im = asRecord(componentValues.instancedMeshValues.get(sourceEntityId));
1560
+ if (im) {
1561
+ payload.options = {
1562
+ meshKind: typeof im.meshKind === "string" ? im.meshKind : "cube",
1563
+ modelPath: typeof im.modelPath === "string" ? im.modelPath : void 0,
1564
+ meshParameters: asRecord(im.meshParameters) ?? void 0,
1565
+ castShadow: typeof im.castShadow === "boolean" ? im.castShadow : false,
1566
+ receiveShadow: typeof im.receiveShadow === "boolean" ? im.receiveShadow : false,
1567
+ // New format: signal the factory to skip child entity creation.
1568
+ // Old format (instances[]): pass through for migration — factory will
1569
+ // create slot entities from the legacy InstanceTransform array.
1570
+ ...Array.isArray(im.instanceEntityIds) ? { instanceEntityIds: im.instanceEntityIds } : Array.isArray(im.instances) ? { instances: im.instances } : {}
1571
+ };
1572
+ }
1573
+ }
1574
+ if (kind === "instanceSlot") {
1575
+ const slot = asRecord(componentValues.instanceSlotValues.get(sourceEntityId));
1576
+ if (slot) {
1577
+ payload.options = {
1578
+ groupEntityId: typeof slot.groupEntityId === "number" ? slot.groupEntityId : -1,
1579
+ slotIndex: typeof slot.slotIndex === "number" ? slot.slotIndex : 0
1580
+ };
1581
+ }
1582
+ }
1583
+ if (kind === "scriptObject") {
1584
+ const so = asRecord(componentValues.scriptObjectValues.get(sourceEntityId));
1585
+ if (so) {
1586
+ payload.options = {
1587
+ scriptUrl: typeof so.scriptUrl === "string" ? so.scriptUrl : null,
1588
+ className: typeof so.className === "string" ? so.className : null,
1589
+ enabled: typeof so.enabled === "boolean" ? so.enabled : true
1590
+ };
1591
+ }
1592
+ }
1593
+ return payload;
1594
+ }
1595
+ __name(buildEntityCreationPayload, "buildEntityCreationPayload");
1596
+ function resolvePrimaryCameraSourceEntityId(snapshot, componentValues, entityTypeValues) {
1597
+ let firstCameraSourceEntityId = null;
1598
+ for (const sourceEntityId of snapshot.entities) {
1599
+ const entityType = readString(entityTypeValues.get(sourceEntityId));
1600
+ if (entityType !== "camera") {
1601
+ continue;
1602
+ }
1603
+ if (firstCameraSourceEntityId === null) {
1604
+ firstCameraSourceEntityId = sourceEntityId;
1605
+ }
1606
+ const cameraValue = asRecord(componentValues.cameraValues.get(sourceEntityId));
1607
+ if (cameraValue?.isDefault === true) {
1608
+ return sourceEntityId;
1609
+ }
1610
+ }
1611
+ return firstCameraSourceEntityId;
1612
+ }
1613
+ __name(resolvePrimaryCameraSourceEntityId, "resolvePrimaryCameraSourceEntityId");
1614
+ function applyLocalTransformsAfterHierarchyRestore(world, scopeEntityIds) {
1615
+ const transformEntities = scopeEntityIds ? Array.from(scopeEntityIds) : world.query(TransformComponent, Object3DRef);
1616
+ for (const entityId of transformEntities) {
1617
+ const transform = world.getComponent(entityId, TransformComponent);
1618
+ const object = world.getComponent(entityId, Object3DRef)?.object;
1619
+ if (!transform || !object) {
1620
+ continue;
1621
+ }
1622
+ applyTransform(object, transform);
1623
+ object.updateMatrixWorld(true);
1624
+ }
1625
+ }
1626
+ __name(applyLocalTransformsAfterHierarchyRestore, "applyLocalTransformsAfterHierarchyRestore");
1627
+ function hydrateWorldFromSnapshotDetailed(snapshot, world, objectManagementSystem, options) {
1628
+ if (!snapshot || !snapshot.entities.length) {
1629
+ return {
1630
+ restoredCount: 0,
1631
+ selectedEntityId: null,
1632
+ idMap: /* @__PURE__ */ new Map()
1633
+ };
1634
+ }
1635
+ const assignPrimaryCamera = options?.assignPrimaryCamera !== false;
1636
+ const entityTypeValues = readByComponent(snapshot.components, "EntityType");
1637
+ const componentValues = buildComponentValueMaps(snapshot);
1638
+ const primaryCameraSourceEntityId = assignPrimaryCamera ? resolvePrimaryCameraSourceEntityId(
1639
+ snapshot,
1640
+ componentValues,
1641
+ entityTypeValues
1642
+ ) : null;
1643
+ const idMap = /* @__PURE__ */ new Map();
1644
+ for (const sourceEntityId of snapshot.entities) {
1645
+ const entityTypeValue = entityTypeValues.get(sourceEntityId);
1646
+ const entityType = readString(entityTypeValue);
1647
+ if (!entityType || !HYDRATABLE_ENTITY_KINDS.has(entityType)) {
1648
+ continue;
1649
+ }
1650
+ const kind = entityType;
1651
+ const payload = buildEntityCreationPayload(sourceEntityId, kind, componentValues);
1652
+ if (kind === "camera" && sourceEntityId === primaryCameraSourceEntityId) {
1653
+ payload.useWorldCamera = true;
1654
+ const options2 = asRecord(payload.options);
1655
+ payload.options = {
1656
+ ...options2 ?? {},
1657
+ isDefault: true
1658
+ };
1659
+ }
1660
+ payload.skipDefaultChildren = true;
1661
+ const createdEntityId = objectManagementSystem.createNow(kind, world, payload);
1662
+ idMap.set(sourceEntityId, createdEntityId);
1663
+ }
1664
+ for (const sourceEntityId of snapshot.entities) {
1665
+ const targetEntityId = idMap.get(sourceEntityId);
1666
+ if (targetEntityId === void 0) {
1667
+ continue;
1668
+ }
1669
+ const entityType = readString(entityTypeValues.get(sourceEntityId));
1670
+ restoreComponentState(
1671
+ world,
1672
+ objectManagementSystem,
1673
+ targetEntityId,
1674
+ sourceEntityId,
1675
+ entityType,
1676
+ componentValues
1677
+ );
1678
+ restorePostCreateComponents(
1679
+ world,
1680
+ objectManagementSystem,
1681
+ targetEntityId,
1682
+ sourceEntityId,
1683
+ entityType,
1684
+ componentValues,
1685
+ idMap
1686
+ );
1687
+ }
1688
+ applyParentLinks(snapshot, idMap, objectManagementSystem, world);
1689
+ objectManagementSystem.reconcileSceneFromWorld(world);
1690
+ applyLocalTransformsAfterHierarchyRestore(
1691
+ world,
1692
+ options?.applyTransformsScope === "created" ? idMap.values() : void 0
1693
+ );
1694
+ const selectedEntityId = typeof snapshot.selectedEntityId === "number" ? idMap.get(snapshot.selectedEntityId) ?? null : null;
1695
+ return {
1696
+ restoredCount: idMap.size,
1697
+ selectedEntityId,
1698
+ idMap
1699
+ };
1700
+ }
1701
+ __name(hydrateWorldFromSnapshotDetailed, "hydrateWorldFromSnapshotDetailed");
1702
+ function hydrateWorldFromSnapshot(snapshot, world, objectManagementSystem) {
1703
+ return hydrateWorldFromSnapshotDetailed(
1704
+ snapshot,
1705
+ world,
1706
+ objectManagementSystem
1707
+ ).restoredCount;
1708
+ }
1709
+ __name(hydrateWorldFromSnapshot, "hydrateWorldFromSnapshot");
1710
+
1711
+ // core/prefab/nodeKeys.ts
1712
+ var NODE_KEY_SEPARATOR = "/";
1713
+ var ADDED_NODE_MARKER_COMPONENT = "+node";
1714
+ var asRecord2 = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null, "asRecord");
1715
+ var readBlock = /* @__PURE__ */ __name((snapshot, component) => {
1716
+ const map = /* @__PURE__ */ new Map();
1717
+ const block = snapshot.components.find((b) => b.component === component);
1718
+ for (const entry of block?.entries ?? []) {
1719
+ const record = asRecord2(entry.value);
1720
+ if (record) {
1721
+ map.set(entry.entityId, record);
1722
+ }
1723
+ }
1724
+ return map;
1725
+ }, "readBlock");
1726
+ var fallbackInstanceId = /* @__PURE__ */ __name((entityId) => `e${entityId}`, "fallbackInstanceId");
1727
+ function buildNodeKeyMapsFromSnapshot(snapshot, options) {
1728
+ const parentValues = readBlock(snapshot, "ParentId");
1729
+ const nodeValues = readBlock(snapshot, "PrefabNode");
1730
+ const instanceValues = readBlock(snapshot, "PrefabInstance");
1731
+ const inDocument = new Set(snapshot.entities);
1732
+ const childrenByParent = /* @__PURE__ */ new Map();
1733
+ const rootIds = [];
1734
+ for (const entityId of snapshot.entities) {
1735
+ const parent = parentValues.get(entityId)?.value;
1736
+ if (typeof parent === "number" && inDocument.has(parent)) {
1737
+ const siblings = childrenByParent.get(parent);
1738
+ if (siblings) siblings.push(entityId);
1739
+ else childrenByParent.set(parent, [entityId]);
1740
+ } else {
1741
+ rootIds.push(entityId);
1742
+ }
1743
+ }
1744
+ const scopeRoots = options?.scopeRootEntityId !== void 0 ? [options.scopeRootEntityId] : rootIds;
1745
+ const idToKey = /* @__PURE__ */ new Map();
1746
+ const keyToId = /* @__PURE__ */ new Map();
1747
+ const boundaryIds = /* @__PURE__ */ new Map();
1748
+ const scopeRootSet = new Set(scopeRoots);
1749
+ const queue = scopeRoots.map(
1750
+ (entityId) => ({ entityId, prefix: "" })
1751
+ );
1752
+ while (queue.length > 0) {
1753
+ const { entityId, prefix } = queue.shift();
1754
+ const instance = instanceValues.get(entityId);
1755
+ const isBoundary = Boolean(
1756
+ instance && typeof instance.url === "string" && !scopeRootSet.has(entityId)
1757
+ );
1758
+ let ownPrefix = prefix;
1759
+ let childPrefix = prefix;
1760
+ if (isBoundary && instance) {
1761
+ const instanceId = typeof instance.instanceId === "string" && instance.instanceId.length > 0 ? instance.instanceId : fallbackInstanceId(entityId);
1762
+ childPrefix = `${prefix}${instanceId}${NODE_KEY_SEPARATOR}`;
1763
+ ownPrefix = childPrefix;
1764
+ boundaryIds.set(entityId, {
1765
+ url: instance.url,
1766
+ instanceId
1767
+ });
1768
+ }
1769
+ const nodeId = nodeValues.get(entityId)?.nodeId;
1770
+ if (typeof nodeId === "string" && nodeId.length > 0) {
1771
+ const key = `${ownPrefix}${nodeId}`;
1772
+ idToKey.set(entityId, key);
1773
+ keyToId.set(key, entityId);
1774
+ }
1775
+ for (const child of childrenByParent.get(entityId) ?? []) {
1776
+ queue.push({ entityId: child, prefix: childPrefix });
1777
+ }
1778
+ }
1779
+ const rootEntityId = scopeRoots[0];
1780
+ const rootNodeId = rootEntityId !== void 0 ? nodeValues.get(rootEntityId)?.nodeId : void 0;
1781
+ return {
1782
+ idToKey,
1783
+ keyToId,
1784
+ rootKey: typeof rootNodeId === "string" && rootNodeId.length > 0 ? rootNodeId : null,
1785
+ boundaryIds
1786
+ };
1787
+ }
1788
+ __name(buildNodeKeyMapsFromSnapshot, "buildNodeKeyMapsFromSnapshot");
1789
+ function collectSnapshotSubtreeIds(snapshot, rootEntityId) {
1790
+ const parentValues = readBlock(snapshot, "ParentId");
1791
+ const childrenByParent = /* @__PURE__ */ new Map();
1792
+ for (const entityId of snapshot.entities) {
1793
+ const parent = parentValues.get(entityId)?.value;
1794
+ if (typeof parent === "number") {
1795
+ const siblings = childrenByParent.get(parent);
1796
+ if (siblings) siblings.push(entityId);
1797
+ else childrenByParent.set(parent, [entityId]);
1798
+ }
1799
+ }
1800
+ const ordered = [];
1801
+ const seen = /* @__PURE__ */ new Set();
1802
+ const queue = [rootEntityId];
1803
+ while (queue.length > 0) {
1804
+ const entityId = queue.shift();
1805
+ if (seen.has(entityId)) continue;
1806
+ seen.add(entityId);
1807
+ ordered.push(entityId);
1808
+ queue.push(...childrenByParent.get(entityId) ?? []);
1809
+ }
1810
+ return ordered;
1811
+ }
1812
+ __name(collectSnapshotSubtreeIds, "collectSnapshotSubtreeIds");
1813
+ function findTopLevelNestedRegions(snapshot) {
1814
+ const parentValues = readBlock(snapshot, "ParentId");
1815
+ const instanceValues = readBlock(snapshot, "PrefabInstance");
1816
+ const inDocument = new Set(snapshot.entities);
1817
+ const roots = new Set(
1818
+ snapshot.entities.filter((entityId) => {
1819
+ const parent = parentValues.get(entityId)?.value;
1820
+ return typeof parent !== "number" || !inDocument.has(parent);
1821
+ })
1822
+ );
1823
+ const regions = [];
1824
+ for (const [entityId, instance] of instanceValues) {
1825
+ if (roots.has(entityId)) continue;
1826
+ if (typeof instance.url !== "string" || instance.url.length === 0) continue;
1827
+ let ancestor = parentValues.get(entityId)?.value;
1828
+ let nestedDeeper = false;
1829
+ let hops = 0;
1830
+ while (typeof ancestor === "number" && hops < 512) {
1831
+ if (instanceValues.has(ancestor) && !roots.has(ancestor)) {
1832
+ nestedDeeper = true;
1833
+ break;
1834
+ }
1835
+ ancestor = parentValues.get(ancestor)?.value;
1836
+ hops += 1;
1837
+ }
1838
+ if (nestedDeeper) continue;
1839
+ regions.push({
1840
+ rootEntityId: entityId,
1841
+ url: instance.url,
1842
+ instanceId: typeof instance.instanceId === "string" && instance.instanceId.length > 0 ? instance.instanceId : fallbackInstanceId(entityId),
1843
+ overrides: Array.isArray(instance.overrides) ? instance.overrides.filter(
1844
+ (entry) => typeof entry === "string"
1845
+ ) : []
1846
+ });
1847
+ }
1848
+ regions.sort((a, b) => a.rootEntityId - b.rootEntityId);
1849
+ return regions;
1850
+ }
1851
+ __name(findTopLevelNestedRegions, "findTopLevelNestedRegions");
1852
+
1853
+ // core/prefab/overrides.ts
1854
+ var OVERRIDE_DIFF_EXCLUDED_COMPONENTS = /* @__PURE__ */ new Set([
1855
+ "PrefabNode",
1856
+ "PrefabInstance",
1857
+ "EntityType",
1858
+ "Selectable",
1859
+ "SelectionTransformState"
1860
+ ]);
1861
+ var OVERRIDE_ROOT_EXCLUDED_COMPONENTS = /* @__PURE__ */ new Set([
1862
+ "TransformComponent",
1863
+ "Name",
1864
+ "ParentId"
1865
+ ]);
1866
+ var asRecord3 = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null, "asRecord");
1867
+ var clone = /* @__PURE__ */ __name((value) => value === void 0 ? value : structuredClone(value), "clone");
1868
+ var isNodeRef = /* @__PURE__ */ __name((value) => {
1869
+ const record = asRecord3(value);
1870
+ return Boolean(
1871
+ record && typeof record.$node === "string" && Object.keys(record).length === 1
1872
+ );
1873
+ }, "isNodeRef");
1874
+ var makeNodeRef = /* @__PURE__ */ __name((nodeId) => ({ $node: nodeId }), "makeNodeRef");
1875
+ function findSnapshotRootEntityIds(snapshot) {
1876
+ const parentBlock = snapshot.components.find(
1877
+ (block) => block.component === "ParentId"
1878
+ );
1879
+ const parentByEntity = /* @__PURE__ */ new Map();
1880
+ for (const entry of parentBlock?.entries ?? []) {
1881
+ parentByEntity.set(entry.entityId, asRecord3(entry.value)?.value ?? null);
1882
+ }
1883
+ return snapshot.entities.filter(
1884
+ (entityId) => typeof parentByEntity.get(entityId) !== "number"
1885
+ );
1886
+ }
1887
+ __name(findSnapshotRootEntityIds, "findSnapshotRootEntityIds");
1888
+ function buildNodeMapsFromSnapshot(snapshot) {
1889
+ const idToNode = /* @__PURE__ */ new Map();
1890
+ const nodeToId = /* @__PURE__ */ new Map();
1891
+ const nodeBlock = snapshot.components.find(
1892
+ (block) => block.component === "PrefabNode"
1893
+ );
1894
+ for (const entry of nodeBlock?.entries ?? []) {
1895
+ const nodeId = asRecord3(entry.value)?.nodeId;
1896
+ if (typeof nodeId === "string" && nodeId.length > 0) {
1897
+ idToNode.set(entry.entityId, nodeId);
1898
+ nodeToId.set(nodeId, entry.entityId);
1899
+ }
1900
+ }
1901
+ const rootEntityId = findSnapshotRootEntityIds(snapshot)[0];
1902
+ const rootNodeId = rootEntityId !== void 0 ? idToNode.get(rootEntityId) ?? null : null;
1903
+ return { idToNode, nodeToId, rootNodeId };
1904
+ }
1905
+ __name(buildNodeMapsFromSnapshot, "buildNodeMapsFromSnapshot");
1906
+ function indexSnapshotByEntity(snapshot) {
1907
+ const byEntity = /* @__PURE__ */ new Map();
1908
+ for (const block of snapshot.components) {
1909
+ for (const entry of block.entries) {
1910
+ let componentMap = byEntity.get(entry.entityId);
1911
+ if (!componentMap) {
1912
+ componentMap = /* @__PURE__ */ new Map();
1913
+ byEntity.set(entry.entityId, componentMap);
1914
+ }
1915
+ componentMap.set(block.component, entry.value);
1916
+ }
1917
+ }
1918
+ return byEntity;
1919
+ }
1920
+ __name(indexSnapshotByEntity, "indexSnapshotByEntity");
1921
+ var toRefOrRaw = /* @__PURE__ */ __name((id, idToNode) => {
1922
+ const nodeId = idToNode.get(id);
1923
+ return nodeId !== void 0 ? makeNodeRef(nodeId) : id;
1924
+ }, "toRefOrRaw");
1925
+ function canonicalizeScriptDataFields(data, idToNode) {
1926
+ const canonicalData = {};
1927
+ for (const [key, fieldValue] of Object.entries(data)) {
1928
+ const field = asRecord3(fieldValue);
1929
+ if (field?.type === "entity" && typeof field.value === "number") {
1930
+ canonicalData[key] = {
1931
+ ...field,
1932
+ value: toRefOrRaw(field.value, idToNode)
1933
+ };
1934
+ continue;
1935
+ }
1936
+ const componentRef = asRecord3(field?.value);
1937
+ if (field?.type === "component" && componentRef && typeof componentRef.entityId === "number") {
1938
+ canonicalData[key] = {
1939
+ ...field,
1940
+ value: {
1941
+ ...componentRef,
1942
+ entityId: toRefOrRaw(componentRef.entityId, idToNode)
1943
+ }
1944
+ };
1945
+ continue;
1946
+ }
1947
+ canonicalData[key] = fieldValue;
1948
+ }
1949
+ return canonicalData;
1950
+ }
1951
+ __name(canonicalizeScriptDataFields, "canonicalizeScriptDataFields");
1952
+ function canonicalizeComponentValue(componentName, value, idToNode) {
1953
+ const cloned = clone(value);
1954
+ const record = asRecord3(cloned);
1955
+ if (!record) {
1956
+ return cloned;
1957
+ }
1958
+ if (componentName === "ParentId") {
1959
+ if (typeof record.value === "number") {
1960
+ record.value = toRefOrRaw(record.value, idToNode);
1961
+ }
1962
+ return record;
1963
+ }
1964
+ if (componentName === "Object3DRef") {
1965
+ return {
1966
+ visibility: typeof record.visibility === "boolean" ? record.visibility : true
1967
+ };
1968
+ }
1969
+ if (componentName === "ScriptComponent") {
1970
+ const entries = Array.isArray(record.entries) ? record.entries : [];
1971
+ return {
1972
+ entries: entries.map((rawEntry) => {
1973
+ const entry = asRecord3(rawEntry);
1974
+ if (!entry) {
1975
+ return rawEntry;
1976
+ }
1977
+ return {
1978
+ className: typeof entry.className === "string" ? entry.className : "",
1979
+ scriptUrl: typeof entry.scriptUrl === "string" ? entry.scriptUrl : "",
1980
+ enabled: typeof entry.enabled === "boolean" ? entry.enabled : true,
1981
+ data: canonicalizeScriptDataFields(asRecord3(entry.data) ?? {}, idToNode)
1982
+ };
1983
+ })
1984
+ };
1985
+ }
1986
+ if (componentName === "ScriptObjectComponent") {
1987
+ return {
1988
+ scriptUrl: typeof record.scriptUrl === "string" ? record.scriptUrl : null,
1989
+ className: typeof record.className === "string" ? record.className : null,
1990
+ enabled: typeof record.enabled === "boolean" ? record.enabled : true,
1991
+ data: canonicalizeScriptDataFields(asRecord3(record.data) ?? {}, idToNode)
1992
+ };
1993
+ }
1994
+ if (componentName === "InstancedMeshComponent") {
1995
+ if (Array.isArray(record.instanceEntityIds)) {
1996
+ record.instanceEntityIds = record.instanceEntityIds.map(
1997
+ (id) => typeof id === "number" ? toRefOrRaw(id, idToNode) : id
1998
+ );
1999
+ }
2000
+ return record;
2001
+ }
2002
+ if (componentName === "IKComponent") {
2003
+ if (Array.isArray(record.chains)) {
2004
+ record.chains = record.chains.map((rawChain) => {
2005
+ const chain = asRecord3(rawChain);
2006
+ if (!chain) return rawChain;
2007
+ for (const key of ["target", "pole"]) {
2008
+ if (typeof chain[key] === "number") chain[key] = toRefOrRaw(chain[key], idToNode);
2009
+ }
2010
+ return chain;
2011
+ });
2012
+ }
2013
+ return record;
2014
+ }
2015
+ if (componentName === "InstanceSlotComponent") {
2016
+ if (typeof record.groupEntityId === "number" && record.groupEntityId !== -1) {
2017
+ record.groupEntityId = toRefOrRaw(record.groupEntityId, idToNode);
2018
+ }
2019
+ return record;
2020
+ }
2021
+ return record;
2022
+ }
2023
+ __name(canonicalizeComponentValue, "canonicalizeComponentValue");
2024
+ function decanonicalizeComponentValue(value, nodeToId) {
2025
+ if (isNodeRef(value)) {
2026
+ return nodeToId.get(value.$node) ?? null;
2027
+ }
2028
+ if (Array.isArray(value)) {
2029
+ return value.map((item) => decanonicalizeComponentValue(item, nodeToId));
2030
+ }
2031
+ const record = asRecord3(value);
2032
+ if (record) {
2033
+ const result = {};
2034
+ for (const [key, item] of Object.entries(record)) {
2035
+ result[key] = decanonicalizeComponentValue(item, nodeToId);
2036
+ }
2037
+ return result;
2038
+ }
2039
+ return value;
2040
+ }
2041
+ __name(decanonicalizeComponentValue, "decanonicalizeComponentValue");
2042
+ var encodeOverride = /* @__PURE__ */ __name((nodeId, componentName, path) => `${nodeId}|${componentName}|${path}`, "encodeOverride");
2043
+ function parseOverride(encoded) {
2044
+ const firstSep = encoded.indexOf("|");
2045
+ if (firstSep <= 0) {
2046
+ return null;
2047
+ }
2048
+ const secondSep = encoded.indexOf("|", firstSep + 1);
2049
+ if (secondSep <= firstSep + 1) {
2050
+ return null;
2051
+ }
2052
+ return {
2053
+ nodeId: encoded.slice(0, firstSep),
2054
+ componentName: encoded.slice(firstSep + 1, secondSep),
2055
+ path: encoded.slice(secondSep + 1)
2056
+ };
2057
+ }
2058
+ __name(parseOverride, "parseOverride");
2059
+ function groupOverridePaths(overrides) {
2060
+ const grouped = /* @__PURE__ */ new Map();
2061
+ for (const encoded of overrides) {
2062
+ const parsed = parseOverride(encoded);
2063
+ if (!parsed) {
2064
+ continue;
2065
+ }
2066
+ let byComponent = grouped.get(parsed.nodeId);
2067
+ if (!byComponent) {
2068
+ byComponent = /* @__PURE__ */ new Map();
2069
+ grouped.set(parsed.nodeId, byComponent);
2070
+ }
2071
+ let paths = byComponent.get(parsed.componentName);
2072
+ if (!paths) {
2073
+ paths = /* @__PURE__ */ new Set();
2074
+ byComponent.set(parsed.componentName, paths);
2075
+ }
2076
+ paths.add(parsed.path);
2077
+ }
2078
+ return grouped;
2079
+ }
2080
+ __name(groupOverridePaths, "groupOverridePaths");
2081
+ var isPrimitive = /* @__PURE__ */ __name((value) => value === null || typeof value !== "object", "isPrimitive");
2082
+ function collectDiffPaths(base, current, prefix = "", out = []) {
2083
+ if (isNodeRef(base) || isNodeRef(current)) {
2084
+ const same = isNodeRef(base) && isNodeRef(current) && base.$node === current.$node;
2085
+ if (!same) {
2086
+ out.push(prefix);
2087
+ }
2088
+ return out;
2089
+ }
2090
+ if (isPrimitive(base) || isPrimitive(current)) {
2091
+ if (base !== current) {
2092
+ out.push(prefix);
2093
+ }
2094
+ return out;
2095
+ }
2096
+ const baseIsArray = Array.isArray(base);
2097
+ const currentIsArray = Array.isArray(current);
2098
+ if (baseIsArray !== currentIsArray) {
2099
+ out.push(prefix);
2100
+ return out;
2101
+ }
2102
+ if (baseIsArray && currentIsArray) {
2103
+ if (base.length !== current.length) {
2104
+ out.push(prefix);
2105
+ return out;
2106
+ }
2107
+ base.forEach((item, index) => {
2108
+ collectDiffPaths(
2109
+ item,
2110
+ current[index],
2111
+ prefix ? `${prefix}/${index}` : String(index),
2112
+ out
2113
+ );
2114
+ });
2115
+ return out;
2116
+ }
2117
+ const baseRecord = base;
2118
+ const currentRecord = current;
2119
+ const keys = /* @__PURE__ */ new Set([
2120
+ ...Object.keys(baseRecord),
2121
+ ...Object.keys(currentRecord)
2122
+ ]);
2123
+ for (const key of keys) {
2124
+ const childPrefix = prefix ? `${prefix}/${key}` : key;
2125
+ if (!(key in baseRecord) || !(key in currentRecord)) {
2126
+ out.push(childPrefix);
2127
+ continue;
2128
+ }
2129
+ collectDiffPaths(baseRecord[key], currentRecord[key], childPrefix, out);
2130
+ }
2131
+ return out;
2132
+ }
2133
+ __name(collectDiffPaths, "collectDiffPaths");
2134
+ function computeInstanceOverrides(baseSnapshot, instanceSnapshot, options) {
2135
+ const baseMaps = buildNodeKeyMapsFromSnapshot(baseSnapshot);
2136
+ const instanceMaps = buildNodeKeyMapsFromSnapshot(instanceSnapshot);
2137
+ const baseByEntity = indexSnapshotByEntity(baseSnapshot);
2138
+ const instanceByEntity = indexSnapshotByEntity(instanceSnapshot);
2139
+ const overrides = [];
2140
+ for (const [nodeKey, instanceEntityId] of instanceMaps.keyToId) {
2141
+ const baseEntityId = baseMaps.keyToId.get(nodeKey);
2142
+ if (baseEntityId === void 0) {
2143
+ if (options?.emitAdditionMarkers) {
2144
+ overrides.push(
2145
+ encodeOverride(nodeKey, ADDED_NODE_MARKER_COMPONENT, "")
2146
+ );
2147
+ }
2148
+ continue;
2149
+ }
2150
+ const baseComponents = baseByEntity.get(baseEntityId);
2151
+ const instanceComponents = instanceByEntity.get(instanceEntityId);
2152
+ if (!baseComponents) {
2153
+ continue;
2154
+ }
2155
+ const isRoot = nodeKey === baseMaps.rootKey;
2156
+ for (const [componentName, baseRaw] of baseComponents) {
2157
+ if (OVERRIDE_DIFF_EXCLUDED_COMPONENTS.has(componentName)) {
2158
+ continue;
2159
+ }
2160
+ if (isRoot && OVERRIDE_ROOT_EXCLUDED_COMPONENTS.has(componentName)) {
2161
+ continue;
2162
+ }
2163
+ const instanceRaw = instanceComponents?.get(componentName);
2164
+ if (instanceRaw === void 0) {
2165
+ continue;
2166
+ }
2167
+ const baseCanonical = canonicalizeComponentValue(
2168
+ componentName,
2169
+ baseRaw,
2170
+ baseMaps.idToKey
2171
+ );
2172
+ const instanceCanonical = canonicalizeComponentValue(
2173
+ componentName,
2174
+ instanceRaw,
2175
+ instanceMaps.idToKey
2176
+ );
2177
+ for (const path of collectDiffPaths(baseCanonical, instanceCanonical)) {
2178
+ overrides.push(encodeOverride(nodeKey, componentName, path));
2179
+ }
2180
+ }
2181
+ }
2182
+ return overrides;
2183
+ }
2184
+ __name(computeInstanceOverrides, "computeInstanceOverrides");
2185
+ var PATH_TOKEN_SPLIT = "/";
2186
+ function getAtPath(value, tokens) {
2187
+ let cursor = value;
2188
+ for (const token of tokens) {
2189
+ if (Array.isArray(cursor)) {
2190
+ cursor = cursor[Number(token)];
2191
+ } else {
2192
+ const record = asRecord3(cursor);
2193
+ if (!record) {
2194
+ return void 0;
2195
+ }
2196
+ cursor = record[token];
2197
+ }
2198
+ if (cursor === void 0) {
2199
+ return void 0;
2200
+ }
2201
+ }
2202
+ return cursor;
2203
+ }
2204
+ __name(getAtPath, "getAtPath");
2205
+ function setAtPath(target, tokens, value) {
2206
+ let cursor = target;
2207
+ for (let i = 0; i < tokens.length - 1; i++) {
2208
+ const token = tokens[i];
2209
+ if (Array.isArray(cursor)) {
2210
+ cursor = cursor[Number(token)];
2211
+ } else {
2212
+ const record = asRecord3(cursor);
2213
+ if (!record) {
2214
+ return;
2215
+ }
2216
+ cursor = record[token];
2217
+ }
2218
+ if (cursor === null || typeof cursor !== "object") {
2219
+ return;
2220
+ }
2221
+ }
2222
+ const last = tokens[tokens.length - 1];
2223
+ if (Array.isArray(cursor)) {
2224
+ cursor[Number(last)] = value;
2225
+ } else {
2226
+ const record = asRecord3(cursor);
2227
+ if (record) {
2228
+ if (value === void 0) {
2229
+ delete record[last];
2230
+ } else {
2231
+ record[last] = value;
2232
+ }
2233
+ }
2234
+ }
2235
+ }
2236
+ __name(setAtPath, "setAtPath");
2237
+ function mergeComponentValue(newFileCanonical, instanceCanonical, overridePaths) {
2238
+ if (!overridePaths || overridePaths.size === 0) {
2239
+ return clone(newFileCanonical);
2240
+ }
2241
+ if (overridePaths.has("")) {
2242
+ return clone(instanceCanonical);
2243
+ }
2244
+ const merged = clone(newFileCanonical);
2245
+ for (const path of overridePaths) {
2246
+ const tokens = path.split(PATH_TOKEN_SPLIT);
2247
+ const instanceValue = getAtPath(instanceCanonical, tokens);
2248
+ setAtPath(merged, tokens, clone(instanceValue));
2249
+ }
2250
+ return merged;
2251
+ }
2252
+ __name(mergeComponentValue, "mergeComponentValue");
2253
+
2254
+ // core/prefab/instantiateSubtree.ts
2255
+ var INSTANTIATE_EXCLUDED_COMPONENTS = /* @__PURE__ */ new Set([
2256
+ "Environment",
2257
+ "Postprocessing",
2258
+ "SelectionTransformState"
2259
+ ]);
2260
+ function instantiateSubtree(world, objectManagementSystem, snapshot) {
2261
+ const snapshotRootIds = new Set(findSnapshotRootEntityIds(snapshot));
2262
+ const safeSnapshot = {
2263
+ entities: snapshot.entities,
2264
+ components: snapshot.components.filter((block) => !INSTANTIATE_EXCLUDED_COMPONENTS.has(block.component)).map(
2265
+ (block) => block.component === "PrefabInstance" ? {
2266
+ component: block.component,
2267
+ entries: block.entries.filter(
2268
+ (entry) => !snapshotRootIds.has(entry.entityId)
2269
+ )
2270
+ } : block
2271
+ ).filter((block) => block.entries.length > 0)
2272
+ };
2273
+ const result = hydrateWorldFromSnapshotDetailed(
2274
+ safeSnapshot,
2275
+ world,
2276
+ objectManagementSystem,
2277
+ { assignPrimaryCamera: false, applyTransformsScope: "created" }
2278
+ );
2279
+ const rootSourceId = findSnapshotRootEntityIds(safeSnapshot).find(
2280
+ (sourceId) => result.idMap.has(sourceId)
2281
+ );
2282
+ return {
2283
+ rootId: rootSourceId !== void 0 ? result.idMap.get(rootSourceId) ?? null : null,
2284
+ idMap: result.idMap
2285
+ };
2286
+ }
2287
+ __name(instantiateSubtree, "instantiateSubtree");
2288
+
2289
+ // core/prefab/types.ts
2290
+ var PREFAB_FILE_VERSION = 1;
2291
+ var PREFAB_FILE_VERSION_NESTED = 2;
2292
+ function prefabFileVersionFor(snapshot) {
2293
+ return findTopLevelNestedRegions(snapshot).length > 0 ? PREFAB_FILE_VERSION_NESTED : PREFAB_FILE_VERSION;
2294
+ }
2295
+ __name(prefabFileVersionFor, "prefabFileVersionFor");
2296
+ var isRecord = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isRecord");
2297
+ function parsePrefabAsset(json) {
2298
+ if (!isRecord(json)) {
2299
+ return null;
2300
+ }
2301
+ if (typeof json.version !== "number" || json.version < 1) {
2302
+ return null;
2303
+ }
2304
+ const snapshot = json.snapshot;
2305
+ if (!isRecord(snapshot)) {
2306
+ return null;
2307
+ }
2308
+ const entities = snapshot.entities;
2309
+ const components = snapshot.components;
2310
+ if (!Array.isArray(entities) || !Array.isArray(components)) {
2311
+ return null;
2312
+ }
2313
+ if (!entities.every((id) => typeof id === "number")) {
2314
+ return null;
2315
+ }
2316
+ if (!components.every(
2317
+ (block) => isRecord(block) && typeof block.component === "string" && Array.isArray(block.entries)
2318
+ )) {
2319
+ return null;
2320
+ }
2321
+ return {
2322
+ version: json.version,
2323
+ type: json.type === "scene" ? "scene" : "prefab",
2324
+ name: typeof json.name === "string" ? json.name : void 0,
2325
+ snapshot
2326
+ };
2327
+ }
2328
+ __name(parsePrefabAsset, "parsePrefabAsset");
2329
+
2330
+ // core/prefab/spawnPrefab.ts
2331
+ var prefabAssetUrlResolver = null;
2332
+ function setPrefabAssetUrlResolver(resolver) {
2333
+ prefabAssetUrlResolver = resolver;
2334
+ }
2335
+ __name(setPrefabAssetUrlResolver, "setPrefabAssetUrlResolver");
2336
+ var resolvePrefabAssetUrl = /* @__PURE__ */ __name((url) => prefabAssetUrlResolver ? prefabAssetUrlResolver(url) : url, "resolvePrefabAssetUrl");
2337
+ var resolveUrl = resolvePrefabAssetUrl;
2338
+ function transformStringsDeep(value, fn) {
2339
+ if (typeof value === "string") {
2340
+ return fn(value);
2341
+ }
2342
+ if (Array.isArray(value)) {
2343
+ return value.map((item) => transformStringsDeep(item, fn));
2344
+ }
2345
+ if (value !== null && typeof value === "object") {
2346
+ const result = {};
2347
+ for (const [key, item] of Object.entries(value)) {
2348
+ result[key] = transformStringsDeep(item, fn);
2349
+ }
2350
+ return result;
2351
+ }
2352
+ return value;
2353
+ }
2354
+ __name(transformStringsDeep, "transformStringsDeep");
2355
+ var prefabCache = /* @__PURE__ */ new Map();
2356
+ function loadPrefab(url) {
2357
+ const cached = prefabCache.get(url);
2358
+ if (cached) {
2359
+ return cached;
2360
+ }
2361
+ const pending = (async () => {
2362
+ const response = await fetch(resolveUrl(url));
2363
+ if (!response.ok) {
2364
+ throw new Error(`Failed to fetch prefab "${url}" (${response.status})`);
2365
+ }
2366
+ const json = await response.json();
2367
+ const parsed = parsePrefabAsset(json);
2368
+ if (!parsed) {
2369
+ throw new Error(`Invalid prefab file at "${url}"`);
2370
+ }
2371
+ return {
2372
+ ...parsed,
2373
+ snapshot: transformStringsDeep(
2374
+ parsed.snapshot,
2375
+ resolveUrl
2376
+ )
2377
+ };
2378
+ })();
2379
+ prefabCache.set(url, pending);
2380
+ pending.catch(() => {
2381
+ if (prefabCache.get(url) === pending) {
2382
+ prefabCache.delete(url);
2383
+ }
2384
+ });
2385
+ return pending;
2386
+ }
2387
+ __name(loadPrefab, "loadPrefab");
2388
+ function clearPrefabCache(url) {
2389
+ if (typeof url === "string") {
2390
+ prefabCache.delete(url);
2391
+ } else {
2392
+ prefabCache.clear();
2393
+ }
2394
+ }
2395
+ __name(clearPrefabCache, "clearPrefabCache");
2396
+ function resolveSource(source) {
2397
+ if (typeof source === "string") {
2398
+ return { url: source, asset: loadPrefab(source) };
2399
+ }
2400
+ if ("path" in source && typeof source.path === "string") {
2401
+ return { url: source.path, asset: loadPrefab(source.path) };
2402
+ }
2403
+ const asset = source;
2404
+ return { url: asset.name ?? "", asset };
2405
+ }
2406
+ __name(resolveSource, "resolveSource");
2407
+ async function spawnPrefab(world, source, options) {
2408
+ const { url, asset } = resolveSource(source);
2409
+ const prefab = await asset;
2410
+ const objectManagementSystem = world.getObjectManagementSystem();
2411
+ const { rootId } = instantiateSubtree(
2412
+ world,
2413
+ objectManagementSystem,
2414
+ prefab.snapshot
2415
+ );
2416
+ if (rootId === null) {
2417
+ throw new Error(
2418
+ `Prefab "${url || prefab.name || "unknown"}" contained no spawnable entities`
2419
+ );
2420
+ }
2421
+ if (!world.getComponent(rootId, PrefabInstance)) {
2422
+ world.addComponent(rootId, new PrefabInstance(url, []));
2423
+ }
2424
+ if (options?.parentId !== void 0 && options.parentId !== null) {
2425
+ objectManagementSystem.setParent(world, rootId, options.parentId, {
2426
+ preserveWorldTransform: false
2427
+ });
2428
+ }
2429
+ const transform = world.getComponent(rootId, TransformComponent);
2430
+ if (transform && (options?.position || options?.rotation || options?.scale)) {
2431
+ const write = /* @__PURE__ */ __name((target, src) => {
2432
+ if (!src) return;
2433
+ if (typeof src.x === "number") target.x = src.x;
2434
+ if (typeof src.y === "number") target.y = src.y;
2435
+ if (typeof src.z === "number") target.z = src.z;
2436
+ }, "write");
2437
+ write(transform.position, options.position);
2438
+ write(transform.rotation, options.rotation);
2439
+ write(transform.scale, options.scale);
2440
+ const object = world.getComponent(rootId, Object3DRef)?.object;
2441
+ if (object) {
2442
+ applyTransform(object, transform);
2443
+ object.updateMatrixWorld(true);
2444
+ }
2445
+ }
2446
+ return rootId;
2447
+ }
2448
+ __name(spawnPrefab, "spawnPrefab");
2449
+ function despawnPrefab(world, rootId, dispose = true) {
2450
+ const objectManagementSystem = world.getObjectManagementSystem();
2451
+ const subtree = collectEntitySubtree(world, [rootId]).reverse();
2452
+ let removed = 0;
2453
+ for (const entityId of subtree) {
2454
+ if (objectManagementSystem.deleteEntity(world, entityId, dispose)) {
2455
+ removed += 1;
2456
+ }
2457
+ }
2458
+ return removed;
2459
+ }
2460
+ __name(despawnPrefab, "despawnPrefab");
2461
+ var _Behaviour = class _Behaviour {
2462
+ /**
2463
+ * Engine-managed constructor. Hosts (`ScriptBehaviourSystem`) instantiate
2464
+ * subclasses with the owning world, the entity id, and the script's `data`
2465
+ * payload. User code should not call this directly.
2466
+ *
2467
+ * @param world - The owning ECS world.
2468
+ * @param entityId - The entity this script is bound to.
2469
+ * @param component - The `ScriptComponent.data` payload, or any object that
2470
+ * should be exposed to the script as `this.data`.
2471
+ */
2472
+ constructor(world, entityId, component) {
2473
+ /**
2474
+ * Inspector-bound payload from the entity's `ScriptComponent`. Override the
2475
+ * type on subclasses with `declare data: MyDataShape` to get type safety
2476
+ * inside hooks. Saved with the project so values persist across reloads.
2477
+ */
2478
+ this.data = {};
2479
+ /**
2480
+ * Seconds elapsed since the last frame. Set by the engine before each
2481
+ * {@link Behaviour.onUpdate}.
2482
+ */
2483
+ this.deltaTime = 0;
2484
+ this.world = world;
2485
+ this.entityId = entityId;
2486
+ if (component) this.data = component;
2487
+ this.entity = this.getEntity();
2488
+ this.threeRef = this.getComponent(Object3DRef);
2489
+ this.transform = this.getComponent(TransformComponent);
2490
+ }
2491
+ /**
2492
+ * Engine-managed per-frame entry point. Refreshes {@link Behaviour.deltaTime}
2493
+ * and delegates to {@link Behaviour.onUpdate}.
2494
+ *
2495
+ * @remarks Do **not** override this method — override
2496
+ * {@link Behaviour.onUpdate} instead.
2497
+ *
2498
+ * @param world - The owning world (may differ from the constructor world
2499
+ * after hot reload).
2500
+ * @param deltaTime - Seconds since the last frame.
2501
+ */
2502
+ update(world, deltaTime) {
2503
+ this.deltaTime = deltaTime;
2504
+ this.world = world;
2505
+ this.onUpdate();
2506
+ }
2507
+ /**
2508
+ * Optional cleanup hook invoked when the script is detached or the entity
2509
+ * is destroyed. Override to release timers, listeners, or other resources.
2510
+ *
2511
+ * @param world - The owning world at disposal time.
2512
+ */
2513
+ dispose(world) {
2514
+ }
2515
+ /**
2516
+ * Instantiate a prefab asset into the world at runtime.
2517
+ *
2518
+ * `source` is typically an `AssetInput` field from this script's `data`
2519
+ * (drag a `.prefab` from the asset browser onto the field in the editor),
2520
+ * a URL string, or a pre-loaded `PrefabAsset`. Resolves with the new root
2521
+ * entity id.
2522
+ *
2523
+ * ```ts
2524
+ * data = { enemyPrefab: { path: "", type: "prefab" } };
2525
+ * async onUpdate() {
2526
+ * if (shouldSpawn) {
2527
+ * const id = await this.spawnPrefab(this.data.enemyPrefab, {
2528
+ * position: { x: 0, y: 0, z: -5 },
2529
+ * });
2530
+ * }
2531
+ * }
2532
+ * ```
2533
+ */
2534
+ spawnPrefab(source, options) {
2535
+ return spawnPrefab(this.world, source, options);
2536
+ }
2537
+ /**
2538
+ * The shared world, or `null` in a single-player run, so a script can work
2539
+ * both ways:
2540
+ *
2541
+ * ```ts
2542
+ * if (this.network && !this.network.isOwner) return; // someone else moves this
2543
+ * ```
2544
+ */
2545
+ get network() {
2546
+ return this.world.getNetwork()?.handleFor(this.entityId) ?? null;
2547
+ }
2548
+ /** Someone joined the room. `playerId` is their session id. */
2549
+ onPlayerJoin(_playerId) {
2550
+ }
2551
+ /** Someone left the room. */
2552
+ onPlayerLeave(_playerId) {
2553
+ }
2554
+ /** A shared value on this entity changed. */
2555
+ onNetworkProp(_key, _value) {
2556
+ }
2557
+ /**
2558
+ * Load a `.soundbank.json` asset so {@link Behaviour.playSlot} can play it.
2559
+ * `source` is an asset path or an `AssetInput` field.
2560
+ */
2561
+ loadSoundBank(source) {
2562
+ return this.world.getAudioSystem()?.loadSoundBank(source) ?? Promise.resolve();
2563
+ }
2564
+ /**
2565
+ * Play a named sound from a loaded bank, as a random take. Returns whether it
2566
+ * sounded: its chance, cooldown or priority may keep it quiet.
2567
+ *
2568
+ * ```ts
2569
+ * this.playSlot("hit", { position: this.transform.position });
2570
+ * ```
2571
+ */
2572
+ playSlot(id, options) {
2573
+ return this.world.getAudioSystem()?.playSlot(id, options) ?? false;
2574
+ }
2575
+ /**
2576
+ * Remove a spawned prefab instance (the root entity and all descendants).
2577
+ * Returns the number of entities removed.
2578
+ */
2579
+ despawn(rootEntityId) {
2580
+ return despawnPrefab(this.world, rootEntityId);
2581
+ }
2582
+ /**
2583
+ * Returns the entity's world-space position as a new `THREE.Vector3`, or
2584
+ * `null` if the entity has no scene presence.
2585
+ */
2586
+ getWorldPosition() {
2587
+ if (!this.threeRef) {
2588
+ return null;
2589
+ }
2590
+ const position = new THREE.Vector3();
2591
+ this.threeRef.object.getWorldPosition(position);
2592
+ return position;
2593
+ }
2594
+ /**
2595
+ * Returns the entity's forward direction in world space (the +Z axis of its
2596
+ * world matrix), or `null` if the entity has no scene presence.
2597
+ */
2598
+ getWorldDirection() {
2599
+ if (!this.threeRef) {
2600
+ return null;
2601
+ }
2602
+ const target = new THREE.Vector3();
2603
+ this.threeRef.object.getWorldDirection(target);
2604
+ return target;
2605
+ }
2606
+ /**
2607
+ * Returns a unit vector pointing from this entity toward the given world
2608
+ * position, or `null` if the entity has no scene presence.
2609
+ *
2610
+ * @param targetPosition - Destination point in world space.
2611
+ */
2612
+ directionTo(targetPosition) {
2613
+ const currentPosition = this.getWorldPosition();
2614
+ if (!currentPosition) {
2615
+ return null;
2616
+ }
2617
+ return targetPosition.clone().sub(currentPosition).normalize();
2618
+ }
2619
+ /**
2620
+ * Returns the world-space distance from this entity to the given position,
2621
+ * or `null` if the entity has no scene presence.
2622
+ *
2623
+ * @param targetPosition - Destination point in world space.
2624
+ */
2625
+ distanceTo(targetPosition) {
2626
+ const currentPosition = this.getWorldPosition();
2627
+ if (!currentPosition) {
2628
+ return null;
2629
+ }
2630
+ return currentPosition.distanceTo(targetPosition);
2631
+ }
2632
+ /**
2633
+ * Linearly interpolates the entity's position toward `targetPosition` and
2634
+ * writes the result back through {@link TransformComponent}. No-op if the
2635
+ * entity has no scene presence.
2636
+ *
2637
+ * @param targetPosition - Destination point in world space.
2638
+ * @param alpha - Interpolation factor in [0, 1]. Multiply by `deltaTime`
2639
+ * for frame-rate-independent smoothing.
2640
+ */
2641
+ lerpTo(targetPosition, alpha) {
2642
+ if (!this.threeRef) {
2643
+ return;
2644
+ }
2645
+ const currentPosition = this.getWorldPosition();
2646
+ if (!currentPosition) {
2647
+ return;
2648
+ }
2649
+ const newPosition = currentPosition.lerp(targetPosition, alpha);
2650
+ this.transform.setPosition(newPosition);
2651
+ }
2652
+ /**
2653
+ * Spherically interpolates the entity's rotation toward `targetRotation`
2654
+ * and writes the result back through {@link TransformComponent}. No-op if
2655
+ * the entity has no scene presence.
2656
+ *
2657
+ * @param targetRotation - Destination orientation as a quaternion.
2658
+ * @param alpha - Interpolation factor in [0, 1].
2659
+ */
2660
+ slerpTo(targetRotation, alpha) {
2661
+ if (!this.threeRef) {
2662
+ return;
2663
+ }
2664
+ const rotation = new THREE.Quaternion();
2665
+ this.threeRef.object.getWorldQuaternion(rotation);
2666
+ rotation.slerp(targetRotation, alpha);
2667
+ this.transform.setRotation(rotation);
2668
+ }
2669
+ /**
2670
+ * Rotates the entity to face `targetPosition` in world space and writes the
2671
+ * resulting orientation back through {@link TransformComponent}. No-op if
2672
+ * the entity has no scene presence.
2673
+ *
2674
+ * @param targetPosition - Point in world space to face.
2675
+ */
2676
+ lookAt(targetPosition) {
2677
+ if (!this.threeRef) {
2678
+ return;
2679
+ }
2680
+ const clone2 = this.threeRef.object.clone();
2681
+ const rotation = new THREE.Quaternion();
2682
+ clone2.lookAt(targetPosition);
2683
+ clone2.getWorldQuaternion(rotation);
2684
+ this.transform.setRotation(rotation);
2685
+ }
2686
+ /** Returns every component currently attached to this entity. */
2687
+ getComponents() {
2688
+ return this.world.getEntityById(this.entityId)?.components ?? [];
2689
+ }
2690
+ /**
2691
+ * Returns the entity's component of the given class, or `null` if it has
2692
+ * no such component.
2693
+ *
2694
+ * @typeParam T - Concrete component type.
2695
+ * @param componentClass - Component class constructor to look up.
2696
+ *
2697
+ * @example
2698
+ * ```ts
2699
+ * const mesh = this.getComponent(MeshComponent);
2700
+ * if (mesh) console.log(mesh.geometryRef);
2701
+ * ```
2702
+ */
2703
+ getComponent(componentClass) {
2704
+ return this.world.getComponent(this.entityId, componentClass) ?? null;
2705
+ }
2706
+ /**
2707
+ * Returns the latest {@link WorldEntityView} snapshot for this entity, or
2708
+ * `null` if it was destroyed.
2709
+ */
2710
+ getEntity() {
2711
+ return this.world.getEntityById(this.entityId);
2712
+ }
2713
+ /**
2714
+ * Resolves the entity's parent from the {@link ParentId} component, if any.
2715
+ *
2716
+ * @returns A {@link ParentLookup} with the parent component reference and
2717
+ * the parent entity view (or `null` if the entity is at the root).
2718
+ */
2719
+ getParent() {
2720
+ const parentIdComponent = this.getComponent(ParentId);
2721
+ const parentEntityId = parentIdComponent?.value ?? null;
2722
+ if (parentEntityId === null) {
2723
+ return {
2724
+ parentIdComponent,
2725
+ parent: null
2726
+ };
2727
+ }
2728
+ return {
2729
+ parentIdComponent,
2730
+ parent: this.world.getEntityById(parentEntityId)
2731
+ };
2732
+ }
2733
+ /**
2734
+ * Returns every direct child entity of this one (entities whose
2735
+ * {@link ParentId} matches `entityId`).
2736
+ */
2737
+ getChildren() {
2738
+ return this.world.getAllEntities().filter((entity) => {
2739
+ const parentIdComponent = entity.components.find(
2740
+ (component) => component instanceof ParentId
2741
+ );
2742
+ return parentIdComponent?.value === this.entityId;
2743
+ });
2744
+ }
2745
+ /**
2746
+ * Called once before the first {@link Behaviour.onUpdate}. Override to
2747
+ * default and validate {@link Behaviour.data}, cache references, or set
2748
+ * initial state. Runs at preview/runtime only — never in the editor.
2749
+ */
2750
+ init() {
2751
+ }
2752
+ /**
2753
+ * Called every frame while the script is enabled. Override with the
2754
+ * script's main per-frame logic. Runs at preview/runtime only — never in the
2755
+ * editor (use {@link ScriptObject} for editor-visible visuals).
2756
+ */
2757
+ onUpdate() {
2758
+ }
2759
+ /** Called when the editor selects this entity. Optional UX hook. */
2760
+ onSelect() {
2761
+ }
2762
+ /** Called when the editor deselects this entity. Optional UX hook. */
2763
+ onDeselect() {
2764
+ }
2765
+ /**
2766
+ * Called when an image-tracking target this entity depends on becomes
2767
+ * visible. Optional AR hook.
2768
+ *
2769
+ * @param target - The newly-visible target entity view.
2770
+ */
2771
+ onTargetFound(target) {
2772
+ }
2773
+ /**
2774
+ * Called when an image-tracking target this entity depends on is lost.
2775
+ * Optional AR hook.
2776
+ *
2777
+ * @param target - The target entity view that became invisible.
2778
+ */
2779
+ onTargetLost(target) {
2780
+ }
2781
+ // ─── WebXR (VR / MR) hooks ────────────────────────────────────────────────
2782
+ // Dispatched by XRSessionSystem / XRInteractionSystem, following the same
2783
+ // pattern as the AR hooks above: public no-op methods that subclasses opt
2784
+ // into by overriding. They never fire outside an immersive session.
2785
+ /**
2786
+ * Called once when an immersive session starts. Optional XR hook.
2787
+ *
2788
+ * Use it to set up XR-only state. Inspect `capabilities` rather than guessing
2789
+ * by device: feature support differs sharply per headset (for example Vision
2790
+ * Pro grants no passthrough on the web today).
2791
+ *
2792
+ * @param capabilities - What the session actually granted, read from
2793
+ * `XRSession.enabledFeatures`.
2794
+ */
2795
+ onXRSessionStart(capabilities) {
2796
+ }
2797
+ /** Called once when the immersive session ends. Optional XR hook. */
2798
+ onXRSessionEnd() {
2799
+ }
2800
+ /**
2801
+ * Called when a primary action begins — controller trigger, hand pinch, or
2802
+ * Vision Pro gaze-pinch. Optional XR hook.
2803
+ *
2804
+ * @param input - Normalized state for the source that acted.
2805
+ */
2806
+ onSelectStart(input) {
2807
+ }
2808
+ /** Called when the primary action ends. Optional XR hook. */
2809
+ onSelectEnd(input) {
2810
+ }
2811
+ /**
2812
+ * Called when this entity is grabbed. Optional XR hook.
2813
+ *
2814
+ * Only fires for entities carrying an enabled, grabbable
2815
+ * `XRInteractableComponent`.
2816
+ *
2817
+ * @param input - The source doing the grabbing.
2818
+ */
2819
+ /**
2820
+ * A SECOND hand joined a two-hand grab on this entity.
2821
+ *
2822
+ * The first hand anchors the object and keeps holding it; this fires for the
2823
+ * hand that came second — the foregrip on a rifle, say.
2824
+ */
2825
+ onSecondaryGrab(_input) {
2826
+ }
2827
+ /** The second hand let go, leaving the object in the first hand alone. */
2828
+ onSecondaryRelease(_input) {
2829
+ }
2830
+ /**
2831
+ * A hand pose declared on this entity started being held.
2832
+ *
2833
+ * Fires once the pose has been sustained for its hold time, not the instant
2834
+ * the fingers pass through it.
2835
+ */
2836
+ onHandPoseStart(_event) {
2837
+ }
2838
+ /** A held hand pose ended, or its hand stopped being tracked. */
2839
+ onHandPoseEnd(_event) {
2840
+ }
2841
+ onGrab(input) {
2842
+ }
2843
+ /** Called when this entity is released. Optional XR hook. */
2844
+ onRelease(input) {
2845
+ }
2846
+ /** A UI button on this entity (or a descendant) was clicked. Clicks fire on
2847
+ * RELEASE while still pointing at the widget — sliding off cancels. */
2848
+ onUiPress(_event) {
2849
+ }
2850
+ /** A pointer began hovering a UI widget on this entity (or a descendant). */
2851
+ onUiHoverStart(_event) {
2852
+ }
2853
+ /** The pointer left the widget. */
2854
+ onUiHoverEnd(_event) {
2855
+ }
2856
+ /** A UI toggle flipped; `event.value` is the new boolean. */
2857
+ onUiToggle(_event) {
2858
+ }
2859
+ /** A UI slider moved; `event.value` is the new number. Fires on real value
2860
+ * changes during the drag and once more on release. */
2861
+ onUiChange(_event) {
2862
+ }
2863
+ };
2864
+ __name(_Behaviour, "Behaviour");
2865
+ /**
2866
+ * Static marker used by `ScriptBehaviourSystem` to detect `Behaviour`
2867
+ * subclasses across bundle-identity splits (esbuild may produce a second
2868
+ * copy of the package when scripts are bundled, breaking `instanceof`).
2869
+ * Inherited by every subclass via the prototype chain.
2870
+ *
2871
+ * @internal
2872
+ */
2873
+ _Behaviour.__reluBehaviourClass = true;
2874
+ var Behaviour = _Behaviour;
2875
+
2876
+ export { ADDED_NODE_MARKER_COMPONENT, Behaviour, HYDRATABLE_ENTITY_KINDS, NODE_KEY_SEPARATOR, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, PREFAB_FILE_VERSION, PREFAB_FILE_VERSION_NESTED, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, decanonicalizeComponentValue, defaultModuleLoader, despawnPrefab, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, mergeComponentValue, mergeDataByCurrentDefaults, normalizeScriptData, parseOverride, parsePrefabAsset, prefabFileVersionFor, readScriptPhase, reportBehaviourHookError, reportScriptError, resolveInputData, resolvePrefabAssetUrl, resolveScriptCtor, restoreComponentState, restorePostCreateComponents, serializeDataForStorage, setPrefabAssetUrlResolver, spawnPrefab, toErrorMessage, toErrorStack, withScriptPhase };
2877
+ //# sourceMappingURL=chunk-WWP46AEF.js.map
2878
+ //# sourceMappingURL=chunk-WWP46AEF.js.map